Subversion Repositories SmartDukaan

Rev

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

Rev 19701 Rev 19798
Line 882... Line 882...
882
    		$usId = $this->User->find('first',$opt);
882
    		$usId = $this->User->find('first',$opt);
883
    		$user_email = $usId['User']['email'];
883
    		$user_email = $usId['User']['email'];
884
    	}
884
    	}
885
    	$this->set(compact('response','maxpercentage','user_email'));
885
    	$this->set(compact('response','maxpercentage','user_email'));
886
    }
886
    }
-
 
887
    
-
 
888
 
-
 
889
    public function admin_userretailer()
-
 
890
    {}
-
 
891
    
-
 
892
    public function admin_searchuserretailer()
-
 
893
    {
-
 
894
    	$this->autoRender = false;
-
 
895
    	$this->request->onlyAllow ( 'ajax' );
-
 
896
    	$type = $this->request->query('type');
-
 
897
    	$search = $this->request->query('search');
-
 
898
    	$searchfor = $this->request->query('searchfor');
-
 
899
    	$this->User->recursive = -1;
-
 
900
//     	$options = array('limit'=>100,'order'=>array('id'=>'desc'));
-
 
901
    
-
 
902
    	$response = "";
-
 
903
    	if(!empty($type) && !empty($search)){
-
 
904
    		if($searchfor == "usertype"){
-
 
905
    			$options['conditions'] = array($type.' LIKE '=>"%$search%");
-
 
906
    			$users = $this->User->find('all',$options);
-
 
907
    			$response = $users;
-
 
908
    		}elseif($searchfor == "retailertype"){
-
 
909
    			$this->loadModel('Retailer');
-
 
910
    			if($type=='contact'){
-
 
911
    				$options['conditions'] =array('OR'=>array('contact1 LIKE '=>"%$search%",'contact2 LIKE '=>"%$search%"));
-
 
912
    			}else{
-
 
913
    				$options['conditions'] = array($type.' LIKE '=>"%$search%");
-
 
914
    			}
-
 
915
    
-
 
916
    			$users = $this->Retailer->find('all',$options);
-
 
917
    
-
 
918
    			$response = $users;
-
 
919
    
-
 
920
    		}
-
 
921
    
-
 
922
    	}
-
 
923
    	return json_encode($response);
-
 
924
    }
-
 
925
    
-
 
926
    public function admin_addretailer(){
-
 
927
    
-
 
928
    
-
 
929
    	if ($this->request->is('post')) {
-
 
930
    		$agentid = Configure::read('agentid');
-
 
931
    		$cur_date = date('Y-m-d H:i:s', time());
-
 
932
    		$data = $this->request->data['Retailer'];
-
 
933
    		$retailer['Retailer']['identifier'] = NULL;
-
 
934
    		$retailer['Retailer']['title'] = $data['storeName'];
-
 
935
    		$retailer['Retailer']['address'] = $data['completeAddress'];
-
 
936
    		$retailer['Retailer']['contact1'] = $data['mobileNumber'];
-
 
937
    		$retailer['Retailer']['status'] = "pending_verification";
-
 
938
    		$retailer['Retailer']['is_elavated'] = 1;
-
 
939
    		$retailer['Retailer']['pin'] = $data['pin'];
-
 
940
    		$retailer['Retailer']['city'] = $data['city'];
-
 
941
    		$retailer['Retailer']['state'] = $data['state'];
-
 
942
    		$retailer['Retailer']['retry_count'] = 0;
-
 
943
    		$retailer['Retailer']['invalid_retry_count'] = 0;
-
 
944
    		$retailer['Retailer']['call_priority'] = NULL;
-
 
945
    		$retailer['Retailer']['next_call_time'] = 0;
-
 
946
    		$retailer['Retailer']['is_std'] = 0;
-
 
947
    		$retailer['Retailer']['is_or'] = 0;
-
 
948
    		$retailer['Retailer']['disposition'] = "inbound_call";
-
 
949
    		$retailer['Retailer']['source'] = "inbound";
-
 
950
    		$retailer['Retailer']['created'] = $cur_date;
-
 
951
    		$retailer['Retailer']['modified'] = $cur_date;
-
 
952
    		$retailer['Retailer']['tinnumber'] = $data['tinNumber'];
-
 
953
    		$retailer['Retailer']['next_call_time'] = NULL;
-
 
954
    		$retailer['Retailer']['isvalidated'] = 0;
-
 
955
    			
-
 
956
    			
-
 
957
    		$this->loadModel('Retailer');
-
 
958
    		$this->Retailer->create();
-
 
959
    		if ($retdata = $this->Retailer->save($retailer)) {
-
 
960
    			$this->Session->setFlash(__('The user has been saved'));
-
 
961
    			$callhistoryquery = "insert into callhistory (retailer_id,agent_id,mobile_number,call_type,sms_verified,call_time,duration_sec,last_fetch_time,call_disposition,disposition_description,disposition_comments,created) values (".$retdata['Retailer']['id'].",".$agentid.",'".$retailer['Retailer']['contact1']."','inbound',1,'".$cur_date."',0,'".$cur_date."','verified_link_sent','autosms of code will be sent','autosms of code will be sent','".$cur_date."')";
-
 
962
    			$contactquery = "insert into retailercontacts (retailer_id,agent_id,mobile_number,contact_type,call_type,created) values (".$retdata['Retailer']['id'].",".$agentid.",'".$retailer['Retailer']['contact1']."','sms','inbound','".date('Y-m-d h:i:s', time())."')";
-
 
963
    			$this->User->query($contactquery);
-
 
964
    			$this->User->query($callhistoryquery);
-
 
965
    			$this->redirect('userretailer');
-
 
966
    		} else {
-
 
967
    			$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
-
 
968
    		}
-
 
969
    	}
-
 
970
    }
-
 
971
    
-
 
972
    public function getcode($id){
-
 
973
    	$agentid = Configure::read('agentid'); 
-
 
974
    	$this->autoRender = false;
-
 
975
    	$this->request->onlyAllow('ajax');
-
 
976
    	$url = $this->apihost."getDtrLink/".$agentid."/fresh/".$id;
-
 
977
    	$response = $this->make_request($url,null);
-
 
978
    
-
 
979
    	return json_encode($response['result']);
-
 
980
    
-
 
981
    }
887
}
982
}