dff9b077 by prami

campaign: removed dublicate sql query request

1 parent 85b15def
...@@ -1613,6 +1613,22 @@ function popMail($userid) ...@@ -1613,6 +1613,22 @@ function popMail($userid)
1613 } 1613 }
1614 function clientsReadAccess() 1614 function clientsReadAccess()
1615 { 1615 {
1616 $companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
1617 $campaigns=array();
1618 $now = new \DateTime();
1619 foreach($companyarr as $tcompany){
1620 $campaignstartdate = new \DateTime($tcompany['campaignstartdate']);
1621 $campaignenddate = new \DateTime($tcompany['campaignenddate']);
1622
1623 if(empty($tcompany['campaignstartdate']) || empty($tcompany['campaignenddate'])){
1624 $campaigns[]=$tcompany['mkey'];
1625 }else{
1626 if($campaignstartdate < $now and $campaignenddate > $now){
1627 $campaigns[]=$tcompany['mkey'];
1628 }
1629 }
1630 }
1631
1616 $clientlst=array(); 1632 $clientlst=array();
1617 if($this->GetBBBUserData("readotherdata")=="No") 1633 if($this->GetBBBUserData("readotherdata")=="No")
1618 { 1634 {
...@@ -1633,43 +1649,20 @@ function popMail($userid) ...@@ -1633,43 +1649,20 @@ function popMail($userid)
1633 } 1649 }
1634 else 1650 else
1635 { 1651 {
1636 $companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
1637 foreach($companyarr as $tcompany)$clientlst[]=$tcompany['mkey'];
1638
1639 $selectarr=$this->loadAllDBMasters("client",'select'); 1652 $selectarr=$this->loadAllDBMasters("client",'select');
1640 $values=explode(",",$selectarr["mvalue"]);$newvalues=array();foreach($values as $value)$newvalues[]=trim($value); 1653 $values=explode(",",$selectarr["mvalue"]);$newvalues=array();foreach($values as $value)$newvalues[]=trim($value);
1641 1654
1642 if(is_array($clientlst))$clientlst=array_unique(array_merge($clientlst,$newvalues)); 1655 if(is_array($clientlst))$clientlst=array_unique(array_merge($campaigns,$newvalues));
1643
1644 } 1656 }
1645 } 1657 }
1646 1658 $activeClientCampaign = array();
1647 $companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
1648 $campaigns=array();
1649 $now = new \DateTime();
1650 foreach($companyarr as $tcompany)
1651 {
1652 $campaignstartdate = new \DateTime($tcompany['campaignstartdate']);
1653 $campaignenddate = new \DateTime($tcompany['campaignenddate']);
1654
1655 if(empty($tcompany['campaignstartdate']) || empty($tcompany['campaignenddate'])){
1656 $campaigns[]=$tcompany['mkey'];
1657 }else{
1658 if($campaignstartdate < $now and $campaignenddate > $now){
1659 $campaigns[]=$tcompany['mkey'];
1660 }
1661 }
1662
1663 }
1664
1665 $activeCampaign = array();
1666 foreach ($clientlst as $key => $value) { 1659 foreach ($clientlst as $key => $value) {
1667 if(in_array($value, $campaigns)){ 1660 if(in_array($value, $campaigns)){
1668 $activeCampaign[]=$value; 1661 $activeClientCampaign[]=$value;
1669 } 1662 }
1670 } 1663 }
1671 1664
1672 return $activeCampaign; 1665 return $activeClientCampaign;
1673 } 1666 }
1674 function clientsOwnerRWAccess() 1667 function clientsOwnerRWAccess()
1675 { 1668 {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!