| Line 704... |
Line 704... |
| 704 |
$options = array('limit'=>100,'order'=>array('id'=>'desc'));
|
704 |
$options = array('limit'=>100,'order'=>array('id'=>'desc'));
|
| 705 |
if($type == 'unactivated'){
|
705 |
if($type == 'unactivated'){
|
| 706 |
$options['conditions'] = array('activated' =>0);
|
706 |
$options['conditions'] = array('activated' =>0);
|
| 707 |
}
|
707 |
}
|
| 708 |
else if(!empty($type) && !empty($search)){
|
708 |
else if(!empty($type) && !empty($search)){
|
| - |
|
709 |
if($type=='id'){
|
| - |
|
710 |
$options['conditions'] = array($type =>$search);
|
| - |
|
711 |
}else{
|
| 709 |
$options['conditions'] = array($type.' LIKE '=>"%$search%");
|
712 |
$options['conditions'] = array($type.' LIKE '=>"%$search%");
|
| - |
|
713 |
}
|
| 710 |
}else{
|
714 |
}else{
|
| 711 |
$options['conditions'] = array('date(created)'=>date('Y-m-d',time()));
|
715 |
$options['conditions'] = array('date(created)'=>date('Y-m-d',time()));
|
| 712 |
}
|
716 |
}
|
| - |
|
717 |
$options['fields'] = array('id','email','first_name','referrer','utm_source','utm_medium','utm_term','utm_campaign','mobile_number','activated','Useractive.last_active','created');
|
| - |
|
718 |
$options['joins'] = array(
|
| - |
|
719 |
array('table' => 'useractive',
|
| - |
|
720 |
'alias' => 'Useractive',
|
| - |
|
721 |
'type' => 'LEFT',
|
| - |
|
722 |
'conditions' => array(
|
| - |
|
723 |
'Useractive.user_id = User.id',
|
| - |
|
724 |
)
|
| - |
|
725 |
)
|
| - |
|
726 |
);
|
| 713 |
$this->Paginator->settings = $options;
|
727 |
$this->Paginator->settings = $options;
|
| 714 |
$users = $this->Paginator->paginate();
|
728 |
$users = $this->Paginator->paginate();
|
| 715 |
foreach ($users as $key => $value) {
|
729 |
foreach ($users as $key => $value) {
|
| 716 |
$userId = $value['User']['id'];
|
730 |
$userId = $value['User']['id'];
|
| 717 |
$quer= "select r.retailer_id,a.name from retailerlinks r join agents a on r.agent_id=a.id where user_id=$userId";
|
731 |
$quer= "select r.retailer_id,a.name from retailerlinks r join agents a on r.agent_id=a.id where user_id=$userId";
|
| Line 911... |
Line 925... |
| 911 |
}
|
925 |
}
|
| 912 |
}
|
926 |
}
|
| 913 |
}
|
927 |
}
|
| 914 |
}
|
928 |
}
|
| 915 |
$rand_keys = array_rand(array_keys($temp), 3);
|
929 |
$rand_keys = array_rand(array_keys($temp), 3);
|
| 916 |
$sql = "select p.brand,count(p.brand) count,b.id from pushnotificationusergroups p left join brands b on p.brand = b.name where p.userids = $userId and p.category_id = $categoryId group by p.brand order by count desc limit 5";
|
930 |
$sql = "select b.id,u.user_id,u.brand,sum(u.weight) w from userlinkssegmentation u left join brands b on lower(u.brand) = lower(b.name) where u.user_id = $userId and u.category_id = $categoryId group by u.brand order by w desc limit 5";
|
| 917 |
$brands = $this->User->query($sql);
|
931 |
$brands = $this->User->query($sql);
|
| 918 |
if(!empty($brands)){
|
932 |
if(!empty($brands)){
|
| 919 |
foreach ($brands as $key => $brand) {
|
933 |
foreach ($brands as $key => $brand) {
|
| 920 |
if($key>2 && !empty($temp))continue;
|
934 |
if($key>2 && !empty($temp))continue;
|
| 921 |
$links[$categoryId][$brand['p']['brand']] = "?filter=brand&brands=".$brand['b']['id'];
|
935 |
$links[$categoryId][$brand['u']['brand']] = "?filter=brand&brands=".$brand['b']['id'];
|
| 922 |
}
|
936 |
}
|
| 923 |
if(!empty($temp)){
|
937 |
if(!empty($temp)){
|
| 924 |
for($i=0;$i<2;$i++) {
|
938 |
for($i=0;$i<2;$i++) {
|
| 925 |
$links[$categoryId][$temp[$rand_keys[$i]]['name']] = "?filter=brand&brands=".$temp[$rand_keys[$i]]['id'];
|
939 |
$links[$categoryId][$temp[$rand_keys[$i]]['name']] = "?filter=brand&brands=".$temp[$rand_keys[$i]]['id'];
|
| 926 |
}
|
940 |
}
|