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
|
<?php $formid = "Order"; require_once "inc/configure.php"; require_once "inc/ord_cn_rm_func.php";
//$refid = (int) filter_var($_REQUEST['refid'], FILTER_SANITIZE_STRING);
if( $_POST['action']=="cnr_rm_addform" ){ //vdump($_REQUEST);//exit; $cn_supplier_refid = (int)filter_var($_REQUEST['cn_supplier_refid'], FILTER_SANITIZE_STRING); $cn_supplier = getDB("master_supplier", $cn_supplier_refid); $cn_customer = filter_var($_REQUEST['cn_customer'], FILTER_SANITIZE_STRING); $bomcategy = filter_var($_REQUEST['bomcategy'], FILTER_SANITIZE_STRING); $launch_date = filter_var($_REQUEST['launch_date'], FILTER_SANITIZE_STRING);
$customer_status = filter_var($_REQUEST['customer_status'], FILTER_SANITIZE_STRING); $customer_remarks = filter_var($_REQUEST['customer_remarks'], FILTER_SANITIZE_STRING);
$createby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $lastupby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); list($cnrq_nbr, $cnrq_seq) = po_getNewPoNo($cn_customer, $cn_supplier_refid, $bomcategy, 'CN'); $sql_param = array(':cn_customer' => $cn_customer, ':cn_supplier' => $cn_supplier['code'], ':launch_date' => $launch_date, ':uom_cy' => 'USD', ':customer_status' => $customer_status, ':supplier_status' => $supplier_status, ':customer_remarks' => $customer_remarks, ':cnrq_nbr' => $cnrq_nbr, ':cnrq_seq' => $cnrq_seq, ':bomcategy' => $bomcategy, ':createby' => $createby, ':lastupby' => $lastupby); /* if($customer_status=='SENT' && empty($main['customer_sent_time'])) { $sql_field = 'customer_sent_time, '; $sql_val = 'GETDATE(), '; }*/ $dbh->beginTransaction();
//update main $sql = "INSERT INTO cn_rm_main ( cn_customer, cn_supplier, launch_date, uom_cy, customer_status, supplier_status, customer_remarks, cnrq_nbr, cnrq_seq, bomcategy, $sql_field createby, createdate, lastupby, lastupdate ) VALUES ( :cn_customer, :cn_supplier, :launch_date, :uom_cy, :customer_status, :supplier_status, :customer_remarks, :cnrq_nbr, :cnrq_seq, :bomcategy, $sql_val :createby, GETDATE(), :lastupby, GETDATE() ) "; $sth = $dbh->prepare($sql); $q = $sth->execute( $sql_param ); //echo $sth->getSQL( $sql_param ) . HTML_EOL; pdo_showerror($sth, $q, $sql_param); $refid = $dbh->lastInsertId(); //vdump($refid, $sql_param); //$k = generateFlag();
//mark all dtl ($refid, $k) cnr_markAllUnused($refid);
foreach($_REQUEST['material'] as $key=>$mat_item){ if($key>0){ //valid row //insert new record cnr_Dtl($refid, $mat_item, $customer_status); } } //delete all dtl with the flag ($refid, $k) cnr_deleteUnused($refid); cnr_updateSummary($refid); if($customer_status=='SENT') { cnr_setCNRSenttime($refid); } //exit; $dbh->commit();
//exit; form_dest($_REQUEST['godest'], $_REQUEST['formdest']); header("Location: cnr_rm_modifyform.php?refid=$refid&msg=Saved."); print "Saved."; exit; } print "Invalid Request";
?>
|