File manager - Edit - /home/webivo6/news.webivox.com/price_update.php.tar
Back
home/webivo6/rado.webivox.com/price_update.php 0000644 00000004052 15225320707 0015422 0 ustar 00 <?php //error_reporting(0); require_once('config.php'); require_once(DIR_SYSTEM.'class/class.inc.php'); $res=$db->select("*","inventory_items","","","id ASC"); while($row=$db->fetch($res)) { echo $row['id'].'<br>'; $available_qty=$row['closing']; $available_qtyasubstr=$available_qty; $available_qtyasubin=0; $total_cost=0; $ress=$db->select("*","stock_transactions","item='".$row['id']."' AND trn_type='in'","","added_date DESC"); while($rows=$db->fetch($ress)) { if($available_qtyasubstr>0) { $itemcost=0; if($rows['note_type']=='SRET') { $ressret=$db->select("*","sales_return","id='".$rows['note_id']."'","",""); $rowsret=$db->fetch($ressret); $invitem=$db->select("*","sales_invoice_items","invoice_id='".$rowsret['invoice_no']."' AND item='".$row['id']."'","",""); $rowinvitem=$db->fetch($invitem); $itemcost=$rowinvitem['cost']; } else{ $itemcost=$rows['amount']; } if($available_qtyasubstr==$rows['qty']) { $total_cost+=$rows['qty']*$itemcost; $available_qtyasubstr-=$rows['qty']; } elseif($available_qtyasubstr>$rows['qty']) { $total_cost+=$rows['qty']*$itemcost; $available_qtyasubstr-=$rows['qty']; } elseif($available_qtyasubstr<$rows['qty']) { $total_cost+=$available_qtyasubstr*$itemcost; $available_qtyasubstr-=$available_qtyasubstr; } } $available_qtyasubin+=$rows['qty']; } if($available_qtyasubstr>0) { if($available_qtyasubstr<=$row['opening_balance']) { $total_cost+=$available_qtyasubstr*$row['opening_cost']; $available_qtyasubstr-=$available_qtyasubstr; } $available_qtyasubin+=$row['opening_balance']; } if($available_qtyasubin<$available_qty) { $db->update("inventory_items","cost='0'","id='".$row['id']."'"); //echo ' --- '.$row['id'].'<bR>'; } else { $db->update("inventory_items","cost='".($total_cost/$available_qty)."'","id='".$row['id']."'"); //echo $total_cost/$available_qty; //echo ' --- '.$row['id'].'<bR>'; } } ?>