36 lines
1.4 KiB
PHP
36 lines
1.4 KiB
PHP
<?php
|
|
$db=$GLOBALS['db'];
|
|
$_GET['record'] = $id;
|
|
// id nie jest puste? jedziemy i szukamy leadsa ...
|
|
$r=$db->query("select ac.contact_id,ac.id,ac.date_modified,ac.deleted,ac.account_id from accounts_contacts as ac
|
|
join leads as aa on aa.id=ac.account_id");
|
|
if($r->num_rows>0){
|
|
// o jest kontakt!
|
|
while($row=$db->fetchByAssoc($r)){
|
|
// wybieranie ścierwa
|
|
$ct=$db->query("select * from contacts where id='".$row['contact_id']."'");
|
|
while($row2=$db->fetchByAssoc($ct)){
|
|
// przenoszenie ścierwa ...
|
|
|
|
// usuwanie starego ścierwa ...
|
|
$mail=$db->query("select * from email_addr_bean_rel where bean_id='".$row2['id']."'");
|
|
if($mail->num_rows>0){
|
|
// o jest email!
|
|
while($mu=$db->fetchByAssoc($mail)){
|
|
// podmianka relacji na kontakt
|
|
$db->query("update email_addr_bean_rel set bean_module='ContactLeads' where id='".$mu['id']."'");
|
|
}
|
|
}
|
|
if($rr->num_rows>0){
|
|
// o jest email!
|
|
while($re=$db->fetchByAssoc($rr)){
|
|
// podmianka relacji na kontrahenta
|
|
$re['deleted']=0;
|
|
// $db->query("INSERT INTO `leads_contactleads` VALUES('".implode("','",$re)."')");
|
|
// $db->query("update accounts_contacts set deleted='1' where lead_id='".$row['contact_id']."'");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|