Files
crm.e5.pl/modules/EcmStockOperations/testa.php
2024-04-27 09:23:34 +02:00

28 lines
824 B
PHP

<?php
$db = $GLOBALS['db'];
$r=$db->query("select * from ecmstockoperations where
product_id='582'
and stock_id='c7afd71a-4c3a-bde4-138d-4acaee1644e4'
and in_id is null and used=0 and type=0");
$docs=array();
$l=0;
while($tmp=$db->fetchByAssoc($r)){
$ii=$db->query("select * from ecmstockoperations where in_id='".$tmp['id']."' and type=1");
if($ii->num_rows>0){
$quantity_tmp=$tmp['quantity'];
while($tmp2=$db->fetchByAssoc($ii)){
$quantity_tmp-=$tmp2['quantity'];
}
$doc['quantity']=$quantity_tmp;
$doc['parent_name']=$tmp['parent_name'];
$docs[]=$doc;
} else {
$doc['quantity']=$tmp['quantity'];
$doc['parent_name']=$tmp['parent_name'];
$docs[]=$doc;
}
}
var_dump($docs);
?>