15 lines
744 B
PHP
15 lines
744 B
PHP
|
|
<?php
|
||
|
|
include("../../config.php");
|
||
|
|
$sql=mysql_connect("localhost","e5crm.more7.com","5z#JaL");
|
||
|
|
mysql_select_db("e5crm_more7_com");
|
||
|
|
$w=$GLOBALS['db']->query("select id,product_code,quantity,price,parent_name from ecmstockoperations where (used=0 or used is null) and type=0 and deleted='0'");
|
||
|
|
while($r=$GLOBALS['db']->fetchByAssoc($w)){;
|
||
|
|
$qty=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(quantity) as qty from ecmstockoperations where type=1 and in_id='".$r['id']."' and deleted='0'"));
|
||
|
|
if($qty['qty']>=$r['quantity']){
|
||
|
|
echo $r['product_code']." ".$r['parent_name']." ".$r['quantity']." ".$qty['qty']."\n";
|
||
|
|
$GLOBALS['db']->query("update ecmstockoperations set used=1 where id='".$r['id']."'");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
mysql_close($sql);
|
||
|
|
?>
|