/var/www/enzatesting.onesolution.hk/invstocktake_material_modifyform.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php 
$formid 
"Inventory";
require_once 
"inc/configure.php";

$bomcategy "material";

if(
havePermission("STr")==false){
    
myerror(INVALID.WS.PERMISSION);    
}

$refid setDefaultReqVar("refid"'');
$location setDefaultReqVar("location"'');
$companyid setDefaultReqVar("companyid"$system_var['COMAPNY_FACTORY']);
if(
$refid){
    
$sql "SELECT * FROM inv_material WHERE refid=:refid";
    
$sth $dbh->prepare($sql);
    
$sth->execute(  array(':refid' => $refid) );    
} else {
    
myerror("Invalid request");
}
//echo $sql;
$row $sth->fetch();
$header $row;
$uom_qty $header['uom_inventory'];
$uom_wt $header['uom_wt'];
$sth=null;

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$system_var['COMPANY_NAME']?></title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<?php require_once "inc/jsheader.php"?>

<script>
$(document).ready(function(){
    $('#input_wt').on("change blur", function(){
        if($('#input_qty').val()==''){
            var std_wt = parseFloat( "<?=numf($header['weight'], 3)?>" );
            var input_wt = parseFloat( $('#input_wt').val() );
            var approx_qty = Math.round(input_wt / std_wt);
            $('#input_qty').val(approx_qty);
            //console.log(std_wt, input_wt, approx_qty);
        }
    });
    $('form#validateForm').submit(function(event) {      
        
        var std_wt = parseFloat( "<?=numf($header['weight'], 3)?>" );
        var input_wt = parseFloat( $('#input_wt').val() );
        var input_qty = parseFloat( $('#input_qty').val() );
        var diff = (input_wt)/(input_qty*std_wt);
        //alert( diff );
        if( diff<parseFloat("<?=$system_var['STOCKTAKETORR_LOW']?>") || diff>parseFloat("<?=$system_var['STOCKTAKETORR_UPP']?>") ){
            var sbt = confirm("<?=ARE_YOU_SURE_YOU_WANT_TO_?><?=SUBMIT?>? ("+round2d(diff*100)+"%)");
            if(sbt==false){
                event.preventDefault();
            }
        }
    })
});
</script>
</head>
<body>

<form action="invstocktake_material_modify.php" name="myform" id="validateForm" method="post" >
<input type="hidden" name="action" value="inv_stocktake_material_modifyform" />
<input type="hidden" name="refid" value="<?=$row['refid']?>" />
<input type="hidden" name="companyid" value="<?=$companyid?>" />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top" class="top"><?php require"mod_webhead.php"?></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <!--<td valign="top" class="menu_bg"><?php //require"mod_menu.php"; ?></td>-->
        <td valign="top" class="padding1"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr></tr>
          <tr>
            <td class="c3_bg"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <!--<td width="20" class="separator"><input type="image" src="image/icon_save.jpg" width="20" height="20" class="pressnhide2" /></td>-->
                <td width="20" class="separator"><a href="<?=basename($_SERVER['REQUEST_URI'])?>"><img src="image/icon_undo.jpg" width="20" height="20" /></a></td>
                <!--<td width="20" class="separator"><img src="image/icon_redo.jpg" width="20" height="20" /></td>
                <td width="20" class="separator"><img src="image/icon_delete.jpg" width="20" height="20" /></td>-->
                <td class="separator stext1"><?=STOCKTAKE?> - <span><?=DIAMOND?></span></td>
                <td class="separator etext1"><?=$row['itemno']?> - <span><?=$row['name_'.SYS_LANG]?></span> (<?=numf($header['weight'] ,3)?><?=$header['uom_wt']?>/<?=$header['uom_inventory']?>)</td>
                <!--<td width="200" align="right" class="separator etext2"><?=LAST_MODIFY?><?=lastUpdate($row)?></td>-->
                <td width="80" align="right" class="separator etext2"><a href="#" onclick="fbox_close()" class="closebtn"><?=CLOSE?></a></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td valign="top" class="c2_bg" style="height:auto">
            <!--main form-->
                <table border="1" width="100%">
                <tr>
                    <th><?=INVNO?></th><th><?=LOCATION?></th><th colspan="2"><?=QTY?></th><th colspan="2"><?=WEIGHT?></th><th><?=USER?></th>
                </tr>
<?php    
    $sql 
"SELECT
            dbo.inv_stocktake_raw.*
            FROM
            dbo.inv_stocktake_raw
            WHERE
            dbo.inv_stocktake_raw.bomcategy = :bomcategy AND
            dbo.inv_stocktake_raw.itemid = :itemid AND
            dbo.inv_stocktake_raw.invstocktake_refid = :invstocktake_refid"
;
    
$sth $dbh->prepare($sql);
    
$sth->execute(  array(':bomcategy' => $bomcategy,
                            
':itemid' => $refid,
                            
':invstocktake_refid' => inv_getCurrentStocktakeID($companyid)) );    
            
    
$ttl_qty 0;
    
$ttl_wt 0;
    while(
$row $sth->fetch()) { 
        
$ttl_qty += $row['input_qty'];
        
$ttl_wt += $row['input_wt'];
        
$i++;?>                
                <tr>
                    <td><?=$row['invno']?><input type="hidden" name="st_refid[<?=$i?>]" value="<?=$row['refid']?>" /></td>
                    <td><?=$row['location']?></td>
                    <td class="tdalignright"><?=numf($row['input_qty'])?></th><td><?=$row['uom_qty']?></td>
                    <td class="tdalignright"><?=numf($row['input_wt'], 3)?></td><td><?=$row['uom_wt']?></td>
                    <td><?=$row['lastupby']?></td>
                </tr>
<?php ?>    
                <tr>
                    <th colspan="2" class="tdalignright"><?=TOTAL?></th>
                    <th class="tdalignright"><?=numf($ttl_qty)?></th><th class="tdalignleft"><?=$uom_qty?></th>
                    <th class="tdalignright"><?=numf($ttl_wt3)?></th><th class="tdalignleft"><?=$uom_wt?></th>
                    <td>&nbsp;</td>
                </tr> 
                <tr>
                    <th colspan="2" class="tdalignright"><?=SAFE?></th>
                    <th class="tdalignright"><?=$LastSTQty numf(inv_getLastSTQty($companyid$bomcategy$refid))?></th><th class="tdalignleft"><?=$uom_qty?></th>
                    <th class="tdalignright"><?=$LastSTWt numf(inv_getLastSTWt($companyid$bomcategy$refid), 3)?></th><th class="tdalignleft"><?=$uom_wt?></th>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <th colspan="2" class="tdalignright"><?=GAP?></th>
                    <th class="tdalignright"><?=numf($ttl_qty $LastSTQty)?></th><th class="tdalignleft"><?=$uom_qty?></th>
                    <th class="tdalignright"><?=numf($ttl_wt $LastSTWt3)?></th><th class="tdalignleft"><?=$uom_wt?></th>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <th colspan="2" class="tdalignright"><?=MARGIN?></th>
                    <th class="tdalignright"><?=numfs(inv_margin($ttl_qty$LastSTQty))?></th><th class="tdalignleft">%</th>
                    <th class="tdalignright"><?=numfs(inv_margin($ttl_wt$LastSTWt))?></th><th class="tdalignleft">%</th>
                    <td>&nbsp;</td>
                </tr>                                                 
                
                <?php if(havePermission("STu")) { ?>
                <tr>
                    <td><!--<input type="text" name="invno" class="shortfield"/>--></td>
                    <td><select name="location"><?=master_option("INV_LOC"$locationtrue)?></select></td>
                    <td class="tdalignright"><input type="text" name="input_qty" id="input_qty" class="shortfield positive"/><input type="hidden" name="std_wt" id="std_wt" value="<?=numf($header['weight'],3)?>" /></td>
                    <td><?=$uom_qty?><input type="hidden" name="uom_qty" value="<?=$uom_qty?>" /></td>
                    <td class="tdalignright"><input type="text" name="input_wt" id="input_wt" class="shortfield positive"/></td><td><?=$uom_wt?><input type="hidden" name="uom_wt" value="<?=$uom_wt?>" /></td>
                    <td><?=$_SESSION['user']?></td>
                </tr> 
                <tr><td colspan="7" class="tdalignright">
                    <button type="submit" name="act" value="ADD" ><?=ADD?></button>&nbsp;&nbsp;&nbsp;&nbsp;
                    <button type="submit" name="act" value="REPLACE" ><?=REPLACE?></button>
                </td></tr> 
                <?php ?>          
                </table>
                
                
<?php if($i){ //allow replace function ?>


<?php ?>


    

            <!-- end of mainform-->
            </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>

</body>
</html>