dff9b077 by prami

campaign: removed dublicate sql query request

1 parent 85b15def
......@@ -1613,6 +1613,22 @@ function popMail($userid)
}
function clientsReadAccess()
{
$companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
$campaigns=array();
$now = new \DateTime();
foreach($companyarr as $tcompany){
$campaignstartdate = new \DateTime($tcompany['campaignstartdate']);
$campaignenddate = new \DateTime($tcompany['campaignenddate']);
if(empty($tcompany['campaignstartdate']) || empty($tcompany['campaignenddate'])){
$campaigns[]=$tcompany['mkey'];
}else{
if($campaignstartdate < $now and $campaignenddate > $now){
$campaigns[]=$tcompany['mkey'];
}
}
}
$clientlst=array();
if($this->GetBBBUserData("readotherdata")=="No")
{
......@@ -1632,44 +1648,21 @@ function popMail($userid)
array_unshift($clientlst," ");
}
else
{
$companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
foreach($companyarr as $tcompany)$clientlst[]=$tcompany['mkey'];
{
$selectarr=$this->loadAllDBMasters("client",'select');
$values=explode(",",$selectarr["mvalue"]);$newvalues=array();foreach($values as $value)$newvalues[]=trim($value);
if(is_array($clientlst))$clientlst=array_unique(array_merge($clientlst,$newvalues));
if(is_array($clientlst))$clientlst=array_unique(array_merge($campaigns,$newvalues));
}
}
$companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
$campaigns=array();
$now = new \DateTime();
foreach($companyarr as $tcompany)
{
$campaignstartdate = new \DateTime($tcompany['campaignstartdate']);
$campaignenddate = new \DateTime($tcompany['campaignenddate']);
if(empty($tcompany['campaignstartdate']) || empty($tcompany['campaignenddate'])){
$campaigns[]=$tcompany['mkey'];
}else{
if($campaignstartdate < $now and $campaignenddate > $now){
$campaigns[]=$tcompany['mkey'];
}
}
}
$activeCampaign = array();
$activeClientCampaign = array();
foreach ($clientlst as $key => $value) {
if(in_array($value, $campaigns)){
$activeCampaign[]=$value;
$activeClientCampaign[]=$value;
}
}
return $activeCampaign;
return $activeClientCampaign;
}
function clientsOwnerRWAccess()
{
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!