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

function 
updateOrderBOM_actualval($opr_param$orddtl_qty){
    global 
$dbh;
    
$sql "UPDATE ord_item_bom SET
                qty = :qty,
                actual_qty = :actual_qty,
                lastupby = :lastupby,
                lastupdate = GETDATE()
            WHERE refid = :refid"
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute(  array(':qty' => (float)$opr_param['txqty']/$orddtl_qty,
                            
':actual_qty' => $opr_param['txwt'],
                            
':lastupby' => $opr_param['lastupby'],
                            
':refid' => $opr_param['ordbom_refid']) );
    echo 
$sth->getSQL();
    
pdo_showerror($sth$q);
}

function 
txpending_receive($ord_txpending_refid$opr_param){
    global 
$dbh;

    
$ord_txpending getDB('ord_txpending'$ord_txpending_refid);
    
$ord_dtl getDB('ord_dtl'$ord_txpending['orddtl_refid']);
    if(
$ord_txpending && $ord_txpending['oprcode_fm']!=$opr_param['oprcode_to']){
        
$sql "UPDATE ord_txpending SET
                    oprcode_to = :oprcode_to,
                    outby = :outby,
                    outtime = GETDATE(),
                    status = :status,
                    lastupby = :lastupby,
                    lastupdate = GETDATE()
                WHERE refid = :refid"
;
        
$sth $dbh->prepare($sql);
        
$q $sth->execute( array(':oprcode_to' => $opr_param['oprcode_to'],
                                
':outby' => $opr_param['lastupby'],
                                
':status' => 'RECEIVED',
                                
':refid' => $ord_txpending_refid,
                                
':lastupby' => $opr_param['lastupby']) );
        
// echo $sth->getSQL( );
        
$opr_param['txwt'] = $ord_txpending['txwt'];
        
$opr_param['txqty'] = $ord_txpending['txqty'];
        
$opr_param['ordbom_refid'] = $ord_txpending['ordbom_refid'];

        if(
$opr_param['oprcode_to']=='WHOO'){
            
// return item to warehouse
            // update ord_txpick
            // exit('ord_txpick RETURN DAMAGE');
        
}else{
            
// picking
            // update ord_item_bom
            // exit('ord_item_bom ACTUAL QTY');
            
updateOrderBOM_actualval($opr_param$ord_dtl['qty']);
        }
    }else{
        exit(
INVALID.WS.REQUEST);
    }
}

if(
$_POST['opr_code'] && count($_REQUEST['ord_txpending_refid'])>){

    
$dbh->beginTransaction();

    
// vdump($_REQUEST);

    
foreach((array)$_REQUEST['ord_txpending_refid'] as $ord_txpending_refid => $val){
        
$opr_param['createby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
        
$opr_param['lastupby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
        
$opr_param['oprcode_to'] = $_REQUEST['opr_code'];
        
// vdump($ord_txpending_refid);
        
txpending_receive($ord_txpending_refid$opr_param);
    }

    
$dbh->commit();

    
form_dest($_REQUEST['godest'], $_REQUEST['formdest']);
    
header("Location: ord_txpending_index.php?dept={$_POST['opr_code']}");
    print 
"Saved.";
    exit;

}

print 
"Invalid Request";