/var/www/enzatesting.onesolution.hk/ord_fild_unpick_hmmaterial.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
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
166
167
168
169
170
171
172
<?php 
$formid 
"Order";
require_once 
"inc/configure.php";

function 
txfilo_update($txmain_refid$opr_param){
    
//write tx details to $param['subtable']
    
global $dbh;    
/*
    $sql = "SELECT * From ord_txfilo WHERE txmain_refid = :txmain_refid";
    $q = $sth->execute(  array( ':txmain_refid' => $opr_param['txmain_refid']) );
*/
    
    
$sql "UPDATE top (1) ord_txfilo SET
                checkin_wt = ISNULL(checkin_wt,0) + :checkin_wt,
                handmade_wt = ISNULL(handmade_wt,0) + :handmade_wt,         
                lastupby = :lastupby, 
                lastupdate = GETDATE()
            WHERE txmain_refid = :txmain_refid"
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute(  array( ':txmain_refid' => $txmain_refid,    
                            
':checkin_wt' => $opr_param['handmade_wt'],    
                            
':handmade_wt' => $opr_param['handmade_wt'],        
                            
':lastupby' => $opr_param['lastupby']) );    
/*
    echo $sth->getSQL(  array( ':txmain_refid' => $txmain_refid,    
                            ':handmade_wt' => $opr_param['handmade_wt'],        
                            ':handmade_itemno' => $opr_param['handmade_itemno'],
                            ':lastupby' => $opr_param['lastupby']) );
*/        
    
pdo_showerror($sth$q);                                                
                                           
}

function 
pick_checkinout($opr_param){
    
//write tx details to txpick
    
global $dbh;        
    
$sql "INSERT into ord_txpick (
                txmain_refid, ordbom_refid, txqty, txwt, uom_qty, uom_wt,
                checkinby, checkin_time, checkoutby, checkout_time, status, 
                bomcategy, itemnoid, worker, repick_reason,
                createby, createdate, lastupby, lastupdate
            ) VALUES (
                :txmain_refid, :ordbom_refid, :txqty, :txwt, :uom_qty, :uom_wt,
                :checkinby, GETDATE(), :checkoutby, GETDATE(), :status, 
                :bomcategy, :itemnoid, :worker, :repick_reason,
                :createby, GETDATE(), :lastupby, GETDATE()
            )"
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute(  array(':txmain_refid' => $opr_param['txmain_refid'],                             
                            
':ordbom_refid' => $opr_param['ordbom_refid'],                            
                            
':txqty' => $opr_param['txqty'],                            
                            
':txwt' => $opr_param['txwt'],                            
                            
':uom_qty' => $opr_param['uom_qty'],                            
                            
':uom_wt' => $opr_param['uom_wt'],                            
                            
':checkinby' => $opr_param['checkinby'],                            
                            
':checkoutby' => $opr_param['checkoutby'],                            
                            
':status' => $opr_param['status'],
                            
':bomcategy' => $opr_param['bomcategy'],
                            
':itemnoid' => $opr_param['itemnoid'],    
                            
':worker' => $opr_param['worker'],    
                            
':repick_reason' => $opr_param['repick_reason'],                            
                            
':createby' => $opr_param['createby'], 
                            
':lastupby' => $opr_param['lastupby']) );    
/*
    echo $sth->getSQL(  array(':txmain_refid' => $opr_param['txmain_refid'],                             
                            ':ordbom_refid' => $opr_param['ordbom_refid'],                            
                            ':txqty' => $opr_param['txqty'],                            
                            ':txwt' => $opr_param['txwt'],                            
                            ':uom_qty' => $opr_param['uom_qty'],                            
                            ':uom_wt' => $opr_param['uom_wt'],                            
                            ':checkinby' => $opr_param['checkinby'],                            
                            ':checkoutby' => $opr_param['checkoutby'],                            
                            ':status' => $opr_param['status'],
                            ':bomcategy' => $opr_param['bomcategy'],
                            ':itemnoid' => $opr_param['itemnoid'],    
                            ':worker' => $opr_param['worker'],    
                            ':repick_reason' => $opr_param['repick_reason'],                            
                            ':createby' => $opr_param['createby'], 
                            ':lastupby' => $opr_param['lastupby']) );    
*/        
    
pdo_showerror($sth$q);    
    
$inc_refid $dbh->lastInsertId();

    return 
$inc_refid;                                            
}


//--------------------------------------------------------------------------------------

$refid                 = (int) filter_var($_REQUEST['refid'], FILTER_SANITIZE_STRING);
//$txmain_refid         = (int) filter_var($_REQUEST['txmain_refid'], FILTER_SANITIZE_STRING);

if( $_POST['action']=="ord_fild_unpick_hmmaterial" && !empty($refid) ){
    
//vdump($_REQUEST); exit;    
    
    
$opr_param['opr_code']    = "FILO";
    
$opr_param['createby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
    
$opr_param['lastupby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
    
    
$opr_param['handmade_refid']     = filter_var($_REQUEST['handmade_refid'], FILTER_SANITIZE_STRING);
    
$handmade_accessory getDB("inv_accessory"$opr_param['handmade_refid']);
    
$opr_param['handmade_itemno']     = filter_var($handmade_accessory['itemno'], FILTER_SANITIZE_STRING);
    
    
$opr_param['handmade_wt'] = (-1) * (float)filter_var($_REQUEST['handmade_wt'], FILTER_SANITIZE_NUMBER_FLOATFILTER_FLAG_ALLOW_FRACTION);
    
//vdump($opr_param);
    
    
$dbh->beginTransaction();
    
//check the job card status to ensure the JC is ready to checkin
    
if($opr oprReadyForCheckout($refid$opr_param)){
        
txfilo_update($opr['ordtxmain_refid'], $opr_param);        
    }
    
//$dbh->commit();    
    //vdump($opr);
    
$opr_param_filo $opr_param;
    unset(
$opr_param);
    
//vdump($opr_param, $opr_param_filo);
//--picking operation--------------------------------------------------------------
    
    
$orddtl_refid $refid;
    
$opr_param['opr_code']     = "PICK";    
    
$opr_param['subtable']    = "ord_txpick";
    
$opr_param['checkinby'] = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);    
    
$opr_param['createby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
    
$opr_param['lastupby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
    
$opr_param['checkoutby']    = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);            
    
$opr_param['status']        = "PICK";    //mark picked in txpick
    
$opr_param['worker']        = filter_var($_REQUEST['worker'], FILTER_SANITIZE_STRING);
    
$opr_param['repick_reason']    = "FILO_RM_RETURN";
    
    
$opr_param['bomcategy']        = 'accessory';    
    
$opr_param['itemnoid']        = $opr_param_filo['handmade_refid'];            
    
$opr_param['uom_qty']        = 'gr';            
    
$opr_param['ordbom_refid']    = null;                        
    
$opr_param['txqty']            = $opr_param_filo['handmade_wt'];            
    
$opr_param['txwt']            = $opr_param_filo['handmade_wt'];    
    
$opr_param['uom_wt']        = 'gr';
                            
    
//check if there is a txmain of PICK of the job card
    //if yes-> get the txmain_refid
    //if no-> create txmain for PICK and return txmain_refid
    
$txmain_all ord_getTxmain($orddtl_refid$opr_param['opr_code']);
    if( empty(
$txmain_all[0]) ){
        
$txmain_refid ord_checkin_tx($orddtl_refid$opr_param);    
    } else {        
        
$txmain_refid $txmain_all[0]['refid'];
    }
    
//vdump($txmain_refid);
    
$opr_param['txmain_refid']    = $txmain_refid;
        
    
pick_checkinout($opr_param);    
    
inv_disableNoStocktake($opr_param['bomcategy'], $opr_param['itemnoid']);

    
        
    
//exit;
        
    
$dbh->commit();    
    
    
    
form_dest($_REQUEST['godest'], $_REQUEST['formdest']);
    
header("Location: ord_fild_checkoutform.php?refid=$refid$error_nvp");
    print 
"Saved.";
    exit;        
        
    
//$checkin_time = ord_checkin($refid, $checkin_info['refid'], $opr_param);        


}
myerror("Invalid Request");


?>