/var/www/enzatesting.onesolution.hk/01_20240711_full_backup/cnr_rm_modify.php


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
<?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_modifyform" && $refid && $main=getDB("cn_rm_main"$refid) ){
//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(    ':customer_status' => $customer_status
                            
':customer_remarks' => $customer_remarks,
                            
':refid' => $refid,
                            
':lastupby' => $lastupby);
    
/*
    if($customer_status=='SENT' && empty($main['customer_sent_time'])) {
        $sql_field = 'customer_sent_time = GETDATE(), ';
    }
*/
    
    
$dbh->beginTransaction();

    
//update main
    
$sql "UPDATE cn_rm_main SET
                customer_status = :customer_status, 
                customer_remarks = :customer_remarks,
                lastupby = :lastupby,
                lastupdate = GETDATE()
            WHERE refid = :refid "
;
                
    
$sth $dbh->prepare($sql);
    
$q $sth->execute$sql_param );
    
//echo $sth->getSQL( $sql_param ) . HTML_EOL;    
    
pdo_showerror($sth$q$sql_param);
//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";


?>