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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
<?php $formid = $_REQUEST['formid']; require_once "inc/configure.php"; require_once "inc/ord_dtl_func.php";
function pako_txlabel_print($labeltype, $tx){ global $dbh; $sql2 = "INSERT INTO prn_txlabel ( label_type, orddtl_refid, barcode, label_refid, actual_wt, actual_uom_wt, barcode_readable, status, computername, ipaddr, createby, createdate, lastupby, lastupdate ) VALUES ( :labeltype, :orddtl_refid, :barcode, :label_refid, :actual_wt, :actual_uom_wt, :barcode_readable, :status, :computername, :ipaddr, :createby, GETDATE(), :lastupby, GETDATE() )"; $sth2 = $dbh->prepare($sql2); $q = $sth2->execute(array( ':labeltype' => $labeltype, //packing label ':orddtl_refid' => $tx['orddtl_refid'], ':label_refid' => $tx['refid'], ':actual_wt' => $tx['product_wt'], ':actual_uom_wt' => $tx['uom_wt'], //':discount' => $order['discount'], ':barcode_readable' => 1, ':barcode' => generateSN($tx['refid']), ':status' => 0, ':computername' => getRealIpAddr(), //gethostbyaddr(getRealIpAddr()) ':ipaddr' => getRealIpAddr(), ':createby' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING), ':lastupby' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING) )); /* echo $sth2->getSQL(array( ':labeltype' => 3, //packing label ':orddtl_refid' => $tx['orddtl_refid'], ':label_refid' => $tx['refid'], ':actual_wt' => $tx['product_wt'], ':actual_uom_wt' => $tx['uom_wt'], ':barcode_readable' => 1, ':barcode' => generateSN($tx['refid']), ':status' => 0, ':computername' => gethostbyaddr(getRealIpAddr()), ':createby' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING), ':lastupby' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING) )); */ pdo_showerror($sth2, $q); }
$refid = (int)$_REQUEST['refid']; $tx_refid = (int)$_REQUEST['label_refid'];
if( $_POST['action']=="ord_pakd_printlabel" && !empty($refid) ){ //vdump($_REQUEST); $tx = gettxpako($tx_refid);
$orddtl_refid = $tx['orddtl_refid']; $orddtl = getDB("ord_dtl", $orddtl_refid); $ordmain_refid = $orddtl['main_refid']; $order = getDB("ord_main", $ordmain_refid); //vdump($orddtl, $ordmain_refid); exit;
if($tx){ //vdump($_REQUEST['uomwt']); if($_REQUEST['wt']>0 && (empty($tx['status']) || $tx['status']=="PACKED") ){
$uomwt = filter_var($_REQUEST['uomwt'], FILTER_SANITIZE_STRING); $product_wt = (float)filter_var($_REQUEST['wt'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if($uomwt != 'gr'){ $product_wt = weightConv($product_wt, $uomwt, 'gr'); $uomwt = 'gr'; }
//$order = getOrdmainByOrddtlrefid($tx['orddtl_refid']); //$order = getDB("ord_main", $ordmain_refid); //vdump($order); exit;
$cust = getCustomerByCode($order['custcode']); //vdump($cust['custvendor']==$system_var['COMPANY_FACTORY']); if($cust['custvendor']==$system_var['COMPANY_FACTORY']){ //bypass factory invoice for enza china customer $status = "PACKED"; $direct_sales = 1; } else { $status = "PACKED"; $direct_sales = 0; } //echo"direct_sales = $direct_sales".PHP_EOL; //exit; //update product weight to the txpako table $sql = "UPDATE ord_txpako SET product_wt = :product_wt, uom_wt = :uom_wt, worker = :worker, status = :status, packed_time = GETDATE(), direct_sales = :direct_sales, discount = :discount, uom_cy = :uom_cy, uom_cy2 = :uom_cy2, cy_cy2_rate = :cy_cy2_rate, lastupby = :lastupby, lastupdate = GETDATE() WHERE refid = :refid"; //-- AND (product_wt IS NULL OR product_wt = 0)"; $sth = $dbh->prepare($sql); $q = $sth->execute( array(':refid' => $tx_refid, ':product_wt' => $product_wt, ':uom_wt' => $uomwt, ':worker' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING), ':status' => $status, ':direct_sales' => $direct_sales, ':discount' => $order['discount'], ':uom_cy2' => $order['uom_cy2'], ':uom_cy' => $order['uom_cy'], ':cy_cy2_rate' => (float)$order['cy_cy2_rate'], ':lastupby' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING)) ); /* echo $sth->getSQL( array(':refid' => $tx_refid, ':product_wt' => (float)filter_var($_REQUEST['wt'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), ':uom_wt' => filter_var($_REQUEST['uomwt'], FILTER_SANITIZE_STRING), ':worker' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING), ':status' => 'PACKED', ':lastupby' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING)) );*/ pdo_showerror($sth, $q);
$updateProdSummary = true; //update summary after printing label } $tx = gettxpako($tx_refid);
pako_txlabel_print('3', $tx);
if($updateProdSummary){ updateProdSummary($tx); // $dbh->beginTransaction();
//if the jc's items are packed -> update Orddtl cost and mark all packed $isallpacked = ord_isallpacked($orddtl_refid); if($isallpacked){ //print 'ALL PACKED:'.$orddtl_refid; ord_updateOrddtlSummary($orddtl_refid); updateMainValue($ordmain_refid); ord_updateInvProductForFirstItem($orddtl_refid); } sys_tmp::save($orddtl_refid,'Orddtl.isallpacked',$isallpacked); // $dbh->commit(); //TODO: fix error: There is no active transaction }
}
/* //if the jc's items are packed -> update Orddtl cost and mark all packed if(ord_isallpacked($orddtl_refid)){ //print 'ALL PACKED'; ord_updateOrddtlSummary($orddtl_refid); updateMainValue($ordmain_refid); }*/
print 'DONE'; exit; } else{ header('HTTP/1.1 400 Bad Request'); die('ERROR'); } ?>
|