/var/www/enzatesting.onesolution.hk/01_20240711_full_backup/ord_setd_checkout.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
88
89
<?php 
$formid 
"Order";
require_once 
"inc/configure.php";

function 
seto_checkout($orddtl_refid$opr_param){
    
//write tx details to $param['subtable']
    
global $dbh;        
    
$sql "UPDATE ord_txseto SET
                checkout_wt=:checkout_wt,
                checkout_time = GETDATE(),
                act_svc_duration=:act_svc_duration,
                lastupby = :lastupby,
                lastupdate = GETDATE()
                where checkout_time is NULL AND txmain_refid=:txmain_refid"
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute(  array(':txmain_refid' => $opr_param['txmain_refid'],                                             
                            
':checkout_wt' => $opr_param['checkout_wt'],
                            
':lastupby' => $opr_param['lastupby'],
                            
':act_svc_duration' => $opr_param['act_svc_duration']) );    
/*    echo $sth->getSQL(   array(':txmain_refid' => $opr_param['txmain_refid'],                                             
                            ':checkout_wt' => $opr_param['checkout_wt'],
                            ':lastupby' => $opr_param['lastupby'],
                            ':act_svc_duration' => $opr_param['act_svc_duration'])  );*/        
    
pdo_showerror($sth$q);            
    
    
//write checkout time to route    
    
$sql "UPDATE ord_route SET
                lastupby = :lastupby,
                lastupdate = GETDATE()
                WHERE checkout_time is NULL
                AND ordtxmain_refid=:txmain_refid"
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute(  array(    ':lastupby' => $opr_param['lastupby'], 
                            
':txmain_refid' => $opr_param['txmain_refid']) );    
/*    echo $sth->getSQL(  array(
                            ':lastupby' => $opr_param['lastupby'], 
                            ':txmain_refid' => $opr_param['txmain_refid'])  );    */    
    
pdo_showerror($sth$q);                
}

$refid                 = (int) filter_var($_REQUEST['refid'], FILTER_SANITIZE_STRING);
/*$route_refid        = (int) filter_var($_REQUEST['route_refid'], FILTER_SANITIZE_STRING);
$txmain_refid         = (int) filter_var($_REQUEST['txmain_refid'], FILTER_SANITIZE_STRING);
$qc                 = filter_var($_REQUEST['qc'], FILTER_SANITIZE_STRING);
*/
if( $_POST['action']=="ord_setd_checkout" && !empty($refid) ){
//vdump($_REQUEST);

    
    
$opr_param['opr_code']    = "SETO";
    
$opr_param['subtable']     = "ord_seto";
    
$opr_param['php_function']    = "seto_checkout";
    
//$opr_param['worker']             = filter_var($_REQUEST['worker'], FILTER_SANITIZE_STRING);
    
$opr_param['act_svc_duration']     = (float)filter_var($_REQUEST['act_svc_duration'], FILTER_SANITIZE_NUMBER_FLOATFILTER_FLAG_ALLOW_FRACTION);
    
$opr_param['checkout_wt']        = (float)filter_var($_REQUEST['ttl_wt'], FILTER_SANITIZE_NUMBER_FLOATFILTER_FLAG_ALLOW_FRACTION);
    
$opr_param['ttl_wt']     = (float)filter_var($_REQUEST['ttl_wt'], FILTER_SANITIZE_NUMBER_FLOATFILTER_FLAG_ALLOW_FRACTION);
    
$opr_param['uom_wt']     = filter_var($_REQUEST['uom_wt'], FILTER_SANITIZE_STRING);
    
$opr_param['createby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
    
$opr_param['lastupby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
    
    
$opr oprReadyForCheckout($refid$opr_param);
    
//vdump($opr); 
    
    
$opr_param['route_refid']    = (int) filter_var($opr['refid'], FILTER_SANITIZE_STRING);
    
$opr_param['txmain_refid']    = (int) filter_var($opr['ordtxmain_refid'], FILTER_SANITIZE_STRING);    

    
//vdump($opr_param); //exit;

    
if($opr === false || empty($opr_param['checkout_wt']) ){        
        
//echo"Unable to checkout"; exit; 
        
myerror("Unable to checkout: "  $msg);    
        exit;
    } else {
        
$dbh->beginTransaction();
        
$checkout_time ord_checkout($refid$opr_param);
        
//exit;
        
$dbh->commit();            
        
//vdump($checkout_time);    exit;
        
form_dest($_REQUEST['godest'], $_REQUEST['formdest']);
        
header("Location: ord_setd_modifyform.php?refid=$refid");
        print 
"Saved.";
        exit;
    }
        
}
myerror(INVALID.WS.REQUEST);


?>