Files
crm.twinpol.com/modules/EcmReceipts2/update_prices.php

22 lines
1.1 KiB
PHP
Raw Normal View History

2025-05-12 15:44:39 +00:00
<?php
global $db;
$w=$GLOBALS[db]->query("select id,wz_id,document_no,type,ecmreceipt_id from ecmreceipts where register_date>='".$_REQUEST['date_from']."%' and register_date<='".$_REQUEST['date_to']."' and deleted='0'");
while($r=$GLOBALS[db]->fetchByAssoc($w)){
//echo $r['document_no'].'<br>';
$ww=$GLOBALS[db]->query("select id,ecmproduct_id from ecmreceiptitems where ecmreceipt_id='".$r['id']."'");
while($rr=$GLOBALS[db]->fetchByAssoc($ww)){
if($r['type']!="normal"){
$rcor=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select wz_id from ecmreceipts where id='".$r['ecmreceipt_id']."'"));
$r['wz_id']=$rcor['wz_id'];
}
$rrr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price from ecmstockoperations where parent_id='".$r['wz_id']."' and product_id='".$rr['ecmproduct_id']."'"));
$purchase_price=$rrr['price'];
echo $rr['code']."<br>";
//if($purchase_price<=0){
$GLOBALS[db]->query("update ecmreceiptitems set purchase_price='".$purchase_price."' where ecmreceipt_id='".$r['id']."' and ecmproduct_id='".$rr['ecmproduct_id']."';");
//echo $purchase_price."<br>";
}
}
?>