init
This commit is contained in:
52
modules/EcmStockStates/rebuildStates.php
Executable file
52
modules/EcmStockStates/rebuildStates.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?
|
||||
//return;
|
||||
|
||||
require_once("modules/EcmStockStates/EcmStockState.php");
|
||||
$ss=new EcmStockState();
|
||||
set_time_limit(1000000);
|
||||
//error_reporting(E_ALL);
|
||||
|
||||
$sarr=array();
|
||||
$parr=array();
|
||||
|
||||
// https://crm.e5.pl/index.php?module=EcmStockStates&action=rebuildStates&ids=2096adf3-d888-a84f-c7ec-59f810381701,75d70d0d-8f48-bf2c-3cd7-63a426511e9e,8f0d5583-468a-9c14-83b2-50a25be72052,cbead744-99e9-7d1c-0d7e-58622d8e6d8b,e95ac585-b616-b83f-e5e4-4ae5952dae8f
|
||||
|
||||
if (isset($_GET['ids'])) {
|
||||
$ids = explode(',', $_GET['ids']);
|
||||
$w=$GLOBALS['db']->query("SELECT so.stock_id, so.product_id FROM ecmstockoperations AS so
|
||||
INNER JOIN ecmproducts AS p ON p.id = so.product_id
|
||||
WHERE p.id IN ('".implode("','", $ids)."')
|
||||
ORDER BY so.date_entered");
|
||||
} else if (isset($_GET['codes'])) {
|
||||
$codes = explode(',', $_GET['codes']);
|
||||
$w=$GLOBALS['db']->query("SELECT so.stock_id, so.product_id FROM ecmstockoperations AS so
|
||||
INNER JOIN ecmproducts AS p ON p.id = so.product_id
|
||||
WHERE p.code IN ('".implode("','", $codes)."')
|
||||
ORDER BY so.date_entered");
|
||||
} else {
|
||||
$w=$GLOBALS['db']->query("
|
||||
select stock_id, product_id from ecmstockoperations
|
||||
order by date_entered");
|
||||
}
|
||||
|
||||
|
||||
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||||
if(!in_array($r['stock_id'],$sarr))$sarr[]=$r['stock_id'];
|
||||
if(!in_array($r['product_id'],$parr))$parr[]=$r['product_id'];
|
||||
}
|
||||
|
||||
for($i=0;$i<count($parr);$i++){
|
||||
for($j=0;$j<count($sarr);$j++){
|
||||
if($parr[$j] && $sarr[$j])$ss->UpdateStockState($sarr[$j],$parr[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
function brecho() {
|
||||
echo '<pre>';
|
||||
foreach(func_get_args() as $obj) {
|
||||
print_r($obj);
|
||||
echo "<br>";
|
||||
}
|
||||
echo '</pre>';
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user