Subversion Repositories SmartDukaan

Rev

Rev 18969 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18900 naman 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Exceptionalnlcs Controller
5
 *
6
 * @property Exceptionalnlc $Exceptionalnlc
7
 * @property PaginatorComponent $Paginator
8
 */
9
class TinsController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
	public function beforeFilter() {
19
		parent::beforeFilter();
18908 naman 20
		$this->Auth->allow(array('tin_search'));
18900 naman 21
		$this->apihost = Configure::read('pythonapihost');
18915 naman 22
		$this->mobileapihost = Configure::read('saholicapihost');
18900 naman 23
	}
24
	public function tin_search($tin_num = null) {
25
		$this->layout = 'ajax';
18915 naman 26
		$user_email = $this->Auth->user('email');
18984 naman 27
		$phone_number = $this->Auth->user('mobile_number');
28
		$this->loadModel("UserAccount");
29
		$opt = array('conditions'=>array('user_id'=>$this->Auth->user('id'),'account_type'=>'saholic'),'recursive'=>-1,'fields'=>'account_key');
30
		$usId = $this->UserAccount->find('first',$opt);
31
		$cuid = $usId['UserAccount']['account_key'];
32
 
33
		$url = $this->mobileapihost."counter?userId=".$cuid."&isLoggedIn=true&privateDealUser=true&tin=".$tin_num;
34
		$tinres = $this->make_request($url, null);
35
		if($tinres["response"]["counterExists"] == true)
36
		{	$tinres = $tinres["response"];
37
			$this->set(compact('tinres'));
38
			$this->render('existtin');
18954 naman 39
		}
18984 naman 40
		else{
41
			// 		$tinres = json_decode('{"pin_required" : "false" , "tin" : "07976957280" , "cst" : "07976957280","counter_name" : "E-RETAIL SHOP","counter_address" : "SHOP IN H. NO. 61 BLOCK B MOLAR BAND EXTN.,-110044" ,"state" : "North Delhi","pan" : "AEEPV9740C","registered_on" :"16/03/15 ","cst_status" : "Active","valid_since" :"06/07/15", "isError": false, "errorMsg": "Error message"}',true);
42
			$url = $this->apihost."tinsearch?tin=".$tin_num;
43
			$tinres = $this->make_request($url,null);
44
			$pincheck = "nothing";
45
			if($tinres['pin_required'] == false){
46
				$pincheck = $tinres['pin'];
47
			}
48
			$this->set(compact('tinres' ,'tin_num','user_email','phone_number','pincheck'));
49
			$this->render('/Elements/gettindetail');
50
		}
18900 naman 51
	}
52
 
53
	public function index() {
54
		$this->layout = "innerpages";
18984 naman 55
		$res = false;
56
		$this->loadModel("UserAccount");
57
// 		$tinres = json_decode('{"pin_required" : "false" , "tin" : "07976957280" , "cst" : "07976957280","counter_name" : "E-RETAIL SHOP","counter_address" : "SHOP IN H. NO. 61 BLOCK B MOLAR BAND EXTN.,-110044" ,"state" : "North Delhi","pan" : "AEEPV9740C","registered_on" :"16/03/15 ","cst_status" : "Active","valid_since" :"06/07/15", "isError": false, "errorMsg": "Error message"}',true);
58
		$opt = array('conditions'=>array('user_id'=>$this->Auth->user('id'),'account_type'=>'saholic'),'recursive'=>-1,'fields'=>'account_key');
59
		$usId = $this->UserAccount->find('first',$opt);
60
		$cuid = $usId['UserAccount']['account_key'];
61
		$url = $this->mobileapihost."counter?userId=".$cuid."&isLoggedIn=true&privateDealUser=true";
62
 		$tinres = $this->make_request( $url, null );
63
//  		debug($tinres);
64
 		$res = $tinres["response"]["counterExists"];
65
 		$tinres= $tinres["response"];
66
		if($res == true){
67
// 			$this->redirect(array(
68
// 					'controller' => 'tins', 'action' => 'showtin', 'tinres' => $tinres
69
// 			));
70
			$this->set(compact('tinres'));
71
			$this->render('showtin');
72
		}
73
 
74
 
18900 naman 75
	}
76
 
77
	public function confirm(){
18954 naman 78
		$this->autoRender = false;
79
		$this->request->onlyAllow ( 'ajax' );
80
		$arr=array();
81
		$data = $this->request->data;
82
 
83
		$arr['tinMap'] = json_encode($data);
84
// 		$senddata = $this->request->query('aParam');
85
		$this->loadModel('UserAccount');
86
		$opt = array('conditions'=>array('user_id'=>$this->Auth->user('id'),'account_type'=>'saholic'),'recursive'=>-1,'fields'=>'account_key');
87
		$usId = $this->UserAccount->find('first',$opt);
88
		$cuid = $usId['UserAccount']['account_key'];
89
		$url = $this->mobileapihost."register!registerTin?userId=".$cuid."&isLoggedIn=true&privateDealUser=true";
90
// 		$url = "http://45.79.106.95:8080/mobileapi/register!registerTin?isLoggedIn=true&privateDealUser=true&userId=483649";
18969 naman 91
		$res = $this->post_request( $url, $arr, 'nojson' );
18954 naman 92
// 		$this->redirect('/category/3');
18969 naman 93
		return	$res;
18900 naman 94
	}
18984 naman 95
 
96
	public function showtin(){
97
		$this->layout = "innerpages";
98
	}
99
	public function existtin(){
100
		$this->layout = "innerpages";
101
	}
18900 naman 102
 
103
}
104
 
105
 
106
 
107
 
108
 
109
 
110