Subversion Repositories SmartDukaan

Rev

Rev 15655 | Rev 17386 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15655 Rev 17380
Line 718... Line 718...
718
		$json = array('success'=>true);
718
		$json = array('success'=>true);
719
		$this->response->type('json');
719
		$this->response->type('json');
720
		$this->layout = 'ajax';
720
		$this->layout = 'ajax';
721
	    echo(json_encode($json));die;
721
	    echo(json_encode($json));die;
722
	}
722
	}
-
 
723
 
-
 
724
	public function admin_search() {
-
 
725
		$type = $this->request->query('type');
-
 
726
		$search = $this->request->query('search');
-
 
727
		$this->User->recursive = -1;
-
 
728
		$options = array('limit'=>100,'order'=>array('id'=>'desc'));
-
 
729
		if($type == 'unactivated'){
-
 
730
			$options['conditions'] = array('activated' =>0);
-
 
731
		}
-
 
732
		else if(!empty($type) && !empty($search)){
-
 
733
			if($type=='id'){
-
 
734
				$options['conditions'] = array($type =>$search);			
-
 
735
			}else{
-
 
736
				$options['conditions'] = array($type.' LIKE '=>"%$search%");			
-
 
737
			}
-
 
738
		}else{
-
 
739
			$options['conditions'] = array('date(User.created)'=>date('Y-m-d',time()));			
-
 
740
		}	
-
 
741
		
-
 
742
		$sql = "SELECT * from (SELECT * from daily_visitors order by visited desc) as x group by x.user_id ";
-
 
743
		$last_act = $this->User->query($sql);
-
 
744
		// debug($last_act);
-
 
745
		$last_act_user_id = array();
-
 
746
		$last_activated = array();
-
 
747
		foreach ($last_act as $key => $row) {
-
 
748
			// echo $key;
-
 
749
			foreach ($row as $key => $value) {
-
 
750
				$last_activated['visited'] = $value['visited'];
-
 
751
				$last_act_user_id[$value['user_id']] = $last_activated['visited'];
-
 
752
			}
-
 
753
		}
-
 
754
		// debug($last_act_user_id);
-
 
755
		$this->set(compact('last_act_user_id'));
-
 
756
		$options['fields'] = array('id','email','first_name','referrer','utm_source','utm_medium','utm_term','utm_campaign','mobile_number','activated','User.created','Appacl.access');
-
 
757
		$options['joins'] = array(
-
 
758
		    array('table' => 'appacls',
-
 
759
		        'alias' => 'Appacl',
-
 
760
		        'type' => 'LEFT',
-
 
761
		        'conditions' => array(
-
 
762
		            'Appacl.user_id = User.id',
-
 
763
		        )
-
 
764
		    )
-
 
765
	    );
-
 
766
		$this->Paginator->settings = $options;
-
 
767
		$users = $this->Paginator->paginate();		
-
 
768
		
-
 
769
 
-
 
770
		$this->set(compact('users'));	
-
 
771
	}
-
 
772
 
-
 
773
	public function getDateInstallsBy($date, $user_id){
-
 
774
		
-
 
775
		$this->autoRender = false;	
-
 
776
		$this->request->onlyAllow('ajax');
-
 
777
		$url = $this->apihost.'appUserBatchDateDrillDown/'.$user_id.'/'.$date;
-
 
778
		$getApp = $this->make_request($url,null);
-
 
779
		return json_encode($getApp);	
-
 
780
	}
723
}
781
}