1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php $formid = "Order"; require_once "inc/configure.php";
if(havePermission("SUu")==false){ //echo $permissionstr; print INVALID.WS.PERMISSION; exit; }
$refid = (int) filter_var($_REQUEST['refid'], FILTER_SANITIZE_STRING); $unitprice = filter_var($_REQUEST['unitprice'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $lastupby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
if( $_POST['action']=="ord_dtl_express_modify" && $_REQUEST['format']=="ajax"){ //ord_dtl_express_modify
$dbh->beginTransaction();
// admin can change selling price $sql = "UPDATE ord_dtl SET unitprice=:unitprice, lastupby=:lastupby, lastupdate=GETDATE() WHERE refid=:refid"; $sth = $dbh->prepare($sql); $q= $sth->execute( array(':refid'=> $refid, ':unitprice'=> $unitprice, ':lastupby' => $lastupby) ); /* echo $sth->getSQL( array(':refid'=> $refid, ':unitprice'=> $unitprice, ':lastupby' => $lastupby) ).HTML_EOL; exit;*/ pdo_showerror($sth, $q); //update selling price and margin already in pako // admin can change selling price $sql = "SELECT * FROM ord_txpako WHERE orddtl_refid=:refid"; $sth = $dbh->prepare($sql); $q= $sth->execute( array(':refid'=> $refid) ); /* echo $sth->getSQL( array(':refid'=> $refid, ':unitprice'=> $unitprice, ':lastupby' => $lastupby) ).HTML_EOL; exit;*/ pdo_showerror($sth, $q); while($pako = $sth->fetch()){ //vdump($pako['refid']); //vdump(($unitprice-$pako['unitcost'])*100/$unitprice); if($unitprice!=0){ $margin = ($unitprice-$pako['unitcost'])*100/$unitprice; } else{ $margin = 0; } $sql = "UPDATE ord_txpako SET unitprice=:unitprice, margin=:margin, lastupby=:lastupby, lastupdate=GETDATE() WHERE refid=:refid"; $sth2 = $dbh->prepare($sql); $q= $sth2->execute( array(':refid'=> $pako['refid'], ':unitprice'=> $unitprice, ':margin'=> $margin, ':lastupby' => $lastupby) ); /* echo $sth->getSQL( array(':refid'=> $pako['refid'], ':unitprice'=> $unitprice, ':margin'=> ($unitprice-$pako['unitcost'])*100/$unitprice, ':lastupby' => $lastupby) ).HTML_EOL;// exit;*/ pdo_showerror($sth2, $q); } $dbh->commit(); require_once "inc/ord_dtl_func.php"; $ordmain_refid = ord_getOrdmain_refid($refid); updateMainValue($ordmain_refid); print SAVED; exit; } print "Invalid Request";
//http://localhost/enza/ajax_ord_dtl_modifyprice.php?action=ord_dtl_express_modify&refid=234&unitprice=1122
|