Files
crm.twinpol.com/modules/EcmPriceBooks2/update_accounts_ecmproducts.php

11 lines
735 B
PHP
Raw Normal View History

2025-05-12 15:44:39 +00:00
<?php
$w=$GLOBALS['db']->query("select id,account_id from ecmpricebooks where deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$ww=$GLOBALS['db']->query("select ecmproduct_id from ecmpricebooks_ecmproducts where deleted='0' and ecmpricebook_id='".$r['id']."'");
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
if(mysql_num_rows($GLOBALS['db']->query("select id from accounts_ecmproducts where account_id='".$r['account_id']."' and ecmproduct_id='".$rr['ecmproduct_id']."' and deleted='0'"))==0){
$GLOBALS['db']->query("insert into accounts_ecmproducts set id='".create_guid()."',account_id='".$r['account_id']."',ecmproduct_id='".$rr['ecmproduct_id']."',date_modified='".date("Y-m-d H:i:s")."',deleted='0'");
}
}
}
?>