init
This commit is contained in:
30
modules/EcmStockOperations/used_qty.php
Executable file
30
modules/EcmStockOperations/used_qty.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
$start=microtime();
|
||||
include("../../config.php");
|
||||
$sql=mysql_connect("localhost","e5crm.more7.com","5z#JaL");
|
||||
mysql_select_db("e5crm_more7_com");
|
||||
$q1=0;
|
||||
$pid="450";
|
||||
$w=$GLOBALS['db']->query("select quantity as qty,id,price,product_code from ecmstockoperations where deleted='0' and type='0' and in_id IS NULL and stock_id='c7afd71a-4c3a-bde4-138d-4acaee1644e4' and product_id='".$pid."' and (used=0 or used is null)");
|
||||
while($rrr=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
$ww=$GLOBALS['db']->query("select quantity from ecmstockoperations where in_id='".$rrr['id']."' and type='1' and in_id IS NOT NULL and stock_id='c7afd71a-4c3a-bde4-138d-4acaee1644e4' and product_id='".$pid."' and deleted='0'");
|
||||
$rqty=0;
|
||||
while($rrp=$GLOBALS['db']->fetchByAssoc($ww)){
|
||||
$rqty+=$rrp['quantity'];
|
||||
}
|
||||
$qty=$rrr['qty']-$rqty;
|
||||
if($qty>0){
|
||||
$arr[]=array("qty"=>$qty,"id"=>$rrr['id'],"price"=>$rrr['price']);
|
||||
}
|
||||
}
|
||||
|
||||
if(count($arr)>0){
|
||||
foreach($arr as $v){
|
||||
$q1+=$v['qty'];
|
||||
$pp1+=$v['qty']*$v['price'];
|
||||
}
|
||||
}
|
||||
|
||||
print $rrr['product_code']." ".$q1." ".(microtime()-$start)."\n";
|
||||
mysql_close($sql);
|
||||
?>
|
||||
Reference in New Issue
Block a user