Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
10582 lgm 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
 
3
class Myaccount extends MY_Controller {
4
 
5
public $layoutName ='';
6
 
7
	function __construct() {
8
 
9
		// Call the CI_controller constructor
10
		parent::__construct();
11108 lgm 11
		// $admin = $this->session->userdata('admin');
12
		// if(!isset($admin) || empty($admin)) {
13
		// 	redirect(base_url().'authorize');
14
		// }
11403 lgm 15
		$authorized = $this->session->userdata('authorized');
16
		if(!isset($authorized) || empty($authorized)){
11520 lgm 17
			$method = $this->router->fetch_method();
18
			if(strcasecmp($method, 'wallet') == 0){
19
				$this->session->set_userdata('location','my-wallet');
20
			}elseif(strcasecmp($method, 'recharges') == 0){
21
				$this->session->set_userdata('location','my-recharges');
22
			}
11508 anikendra 23
			redirect(base_url().'auth/login');
11403 lgm 24
		}
10582 lgm 25
		$this->layout->setlayout('layout/layout_main');
26
		$this->load->model('myaccount_model');
27
		$this->layoutName= $this->layout->getLayout();
28
		$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
29
		//print_r($this->session->userdata);
30
 
31
	}
32
	public function index()
33
	{
11379 anikendra 34
		redirect(base_url().'myaccount/closed');	
10582 lgm 35
		$authorized = $this->session->userdata('authorized');
36
		if(isset($authorized) && !empty($authorized)){
37
			$_GET['userId'] = $authorized['Id'];
38
			if($authorized['isLoggedIn'] == 1){
39
				$_GET['isLoggedIn'] = 'true';
40
			}
41
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
42
				$_GET['isLoggedIn'] = 'false';
43
			}
44
		}
45
		//standard array
11169 lgm 46
		$configdata = $this->config->item('myaccount');
47
		$cachemodule = array('header','footer');
48
		$configdata = getCache($configdata,$cachemodule);
10582 lgm 49
		$data = array();
50
		$this->lessphp->object()->ccompile('assets/css/profile.less','assets/css/profile.css');
51
		$data['stylesheet'] = 'profile.css';
11169 lgm 52
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$configdata['module']);
53
		if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
54
		{
55
			foreach($cachemodule as $cm)
56
			{
57
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
58
				{
59
					$data['response'][$cm]=$configdata[$cm];
60
				}
61
			}
62
		}
63
		setCache($configdata['module'],$cachemodule,$data['response']);
10582 lgm 64
		$this->layout->view('myaccount/account_view',$data);
65
	}
66
 
67
	public function closed(){
11324 anikendra 68
		$this->load->helper('text');
10582 lgm 69
		$authorized = $this->session->userdata('authorized');
70
		if(isset($authorized) && !empty($authorized)){
71
			$_GET['userId'] = $authorized['Id'];
72
			if($authorized['isLoggedIn'] == 1){
73
				$_GET['isLoggedIn'] = 'true';
74
			}
75
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
76
				$_GET['isLoggedIn'] = 'false';
77
			}
78
		}
79
		//standard array
11169 lgm 80
		$configdata = $this->config->item('completed-orders');
81
		//$checkConfig = $this->config->item('home');
82
		$cachemodule = array('header','footer');
83
		$configdata = getCache($configdata,$cachemodule);
10582 lgm 84
		$data = array();
85
		$this->lessphp->object()->ccompile('assets/css/profile.less','assets/css/profile.css');
86
		$data['stylesheet'] = 'profile.css';
11169 lgm 87
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$configdata['module']);
88
		if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
89
		{
90
			foreach($cachemodule as $cm)
91
			{
92
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
93
				{
94
					$data['response'][$cm]=$configdata[$cm];
95
				}
96
			}
97
		}
98
		setCache($configdata['module'],$cachemodule,$data['response']);
10582 lgm 99
		$this->layout->view('myaccount/account_view',$data);
100
	}
101
 
102
	public function failed(){
103
 
104
		$authorized = $this->session->userdata('authorized');
105
		if(isset($authorized) && !empty($authorized)){
106
			$_GET['userId'] = $authorized['Id'];
107
			if($authorized['isLoggedIn'] == 1){
108
				$_GET['isLoggedIn'] = 'true';
109
			}
110
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
111
				$_GET['isLoggedIn'] = 'false';
112
			}
113
		}
114
		//standard array
115
		$data = array();
116
		$this->lessphp->object()->ccompile('assets/css/profile.less','assets/css/profile.css');
117
		$data['stylesheet'] = 'profile.css';
118
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$this->config->item('failed-orders'));
119
		//if(isset($data['response']['response']['track_order']))
120
		$this->layout->view('myaccount/account_view',$data);
121
	}
122
 
123
	public function purchases(){
124
 
125
		$authorized = $this->session->userdata('authorized');
126
		if(isset($authorized) && !empty($authorized)){
127
			$_GET['userId'] = $authorized['Id'];
128
			if($authorized['isLoggedIn'] == 1){
129
				$_GET['isLoggedIn'] = 'true';
130
			}
131
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
132
				$_GET['isLoggedIn'] = 'false';
133
			}
134
		}
135
		//standard array
136
		$data = array();
137
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$this->config->item('mypurchases'));
138
		//if(isset($data['response']['response']['track_order']))
139
		$this->layout->view('trackorder/trackorder_view',$data);
140
	}
141
	public function order(){
142
		$last = $this->uri->total_segments();
143
		$orderId = $this->uri->segment($last);
144
		$authorized = $this->session->userdata('authorized');
145
		if(isset($authorized) && !empty($authorized)){
146
			$_GET['userId'] = $authorized['Id'];
147
			if($authorized['isLoggedIn'] == 1){
148
				$_GET['isLoggedIn'] = 'true';
149
			}
150
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
151
				$_GET['isLoggedIn'] = 'false';
152
			}
153
		}
154
		//standard array
155
		$data = array();
11169 lgm 156
    	$configdata = $this->config->item('order');
157
		//$checkConfig = $this->config->item('home');
158
		$cachemodule = array('header','footer');
159
		$configdata = getCache($configdata,$cachemodule);
160
		$data = array();
161
		$this->lessphp->object()->ccompile('assets/css/profile.less','assets/css/profile.css');
10582 lgm 162
		$data['stylesheet'] = 'profile.css';
11169 lgm 163
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$configdata['module']);
164
		if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
165
		{
166
			foreach($cachemodule as $cm)
167
			{
168
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
169
				{
170
					$data['response'][$cm]=$configdata[$cm];
171
				}
172
			}
173
		}
174
		setCache($configdata['module'],$cachemodule,$data['response']);
10582 lgm 175
		//if(isset($data['response']['response']['track_order']))
176
		$this->layout->view('myaccount/account_view',$data);
177
	}
178
 
179
	public function wallet(){
180
 
181
		$authorized = $this->session->userdata('authorized');
182
		if(isset($authorized) && !empty($authorized)){
183
			$_GET['userId'] = $authorized['Id'];
184
			if($authorized['isLoggedIn'] == 1){
185
				$_GET['isLoggedIn'] = 'true';
186
			}
187
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
188
				$_GET['isLoggedIn'] = 'false';
189
			}
190
		}else{
11507 anikendra 191
			redirect(base_url().'auth/login');
10582 lgm 192
		}
193
		//standard array
11169 lgm 194
		$configdata = $this->config->item('my-wallet');
195
		//$checkConfig = $this->config->item('home');
196
		$cachemodule = array('header','footer');
197
		$configdata = getCache($configdata,$cachemodule);
10582 lgm 198
		$data = array();
11169 lgm 199
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$configdata['module']);
200
		if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
201
		{
202
			foreach($cachemodule as $cm)
203
			{
204
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
205
				{
206
					$data['response'][$cm]=$configdata[$cm];
207
				}
208
			}
209
		}
210
		setCache($configdata['module'],$cachemodule,$data['response']);
10582 lgm 211
		if(isset($data['response']['response']['wallet'][0]) && !empty($data['response']['response']['wallet'][0])){
212
			$this->lessphp->object()->ccompile('assets/css/profile.less','assets/css/profile.css');
213
			$data['stylesheet'] = 'profile.css';
17571 manish.sha 214
			if(isset($authorized['isPrivateDealUser']) && !empty($authorized['isPrivateDealUser'])) {
215
		        	$userId = $this->session->userdata['authorized']['Id'];
216
		        	$ch = curl_init();
17972 manish.sha 217
					$url = $this->config->item('curl_base_url').'private-deals/1/?userId='.$userId.'&isLoggedIn=true&privateDealUser=true';
17571 manish.sha 218
					// Set the url, number of POST vars, POST data
219
					curl_setopt($ch, CURLOPT_URL, $url);
220
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
221
 
222
					// Disabling SSL Certificate support temporarly
223
					curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
224
 
225
					// Execute post
226
					$result = curl_exec($ch);
227
					if ($result === FALSE) {
228
						die('Curl failed: ' . curl_error($ch));
229
					}
230
					$res = json_decode($result,1);
231
		        	$data['privatedeals']=$res;
232
		    }
10582 lgm 233
			$this->layout->view('myaccount/account_view',$data);
234
		}else{
235
			redirect(base_url());
236
		}
237
	}
238
	public function recharges(){
239
 
240
		$authorized = $this->session->userdata('authorized');
241
		if(isset($authorized) && !empty($authorized)){
242
			$_GET['userId'] = $authorized['Id'];
243
			if($authorized['isLoggedIn'] == 1){
244
				$_GET['isLoggedIn'] = 'true';
245
			}
246
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
247
				$_GET['isLoggedIn'] = 'false';
248
			}
249
		}else{
11507 anikendra 250
			redirect(base_url().'auth/login');
10582 lgm 251
		}
252
		//standard array
11169 lgm 253
		$configdata = $this->config->item('my-recharges');
254
		//$checkConfig = $this->config->item('home');
255
		$cachemodule = array('header','footer');
256
		$configdata = getCache($configdata,$cachemodule);
10582 lgm 257
		$data = array();
11169 lgm 258
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$configdata['module']);
259
		if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
260
		{
261
			foreach($cachemodule as $cm)
262
			{
263
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
264
				{
265
					$data['response'][$cm]=$configdata[$cm];
266
				}
267
			}
268
		}
269
		setCache($configdata['module'],$cachemodule,$data['response']);
10582 lgm 270
		if(isset($data['response']['response']['myrecharges'][0]) && !empty($data['response']['response']['myrecharges'][0])){
271
			$this->lessphp->object()->ccompile('assets/css/profile.less','assets/css/profile.css');
272
			$data['stylesheet'] = 'profile.css';
273
			$this->layout->view('myaccount/account_view',$data);
274
		}else{
275
			redirect(base_url());
276
		}
277
	}
278
	public function contact($email,$orderId,$subject,$message,$awb){
279
		$configUrl = $this->config->item('contact');
280
		$configUrl = $configUrl['url'];
281
		$url = $this->config->item('curl_base_url').$configUrl;
282
		$params = array();
283
		$params['email'] = urldecode($email);
284
		$params['order_id'] = $orderId;
285
		$params['subject'] = urldecode($subject);
286
		$params['message'] = urldecode($message);
287
		$params['communication_type'] = 2;
288
		if($awb == 'null'){
289
			$params['awb'] = '';
290
		}else{
291
			$params['awb'] = urldecode($awb);
292
		}
293
		$this->mcurl->add_call('contact','post',$url,$params);
294
	    $response = $this->mcurl->execute($url);
295
	    $data['response'] = $response['contact']['response'];
296
	    $response = $this->magento_model->payment_submit($data);
297
	    echo json_encode($response[0]);
298
	}
299
 
300
    public function refund($orderId){
15927 amit.gupta 301
    $url = $this->config->item('curl_base_url').'my-recharges';
10582 lgm 302
    $params = array();
303
    //$params['email'] = urldecode($email);
15927 amit.gupta 304
    $params['orderId'] = $orderId;
10582 lgm 305
    // $params['subject'] = urldecode($subject);
306
    // $params['message'] = urldecode($message);
15927 amit.gupta 307
    #$params['communication_type'] = 2;
10582 lgm 308
    // if($awb == 'null'){
309
      // $params['awb'] = '';
310
    // }else{
311
      // $params['awb'] = urldecode($awb);
312
    // }
15927 amit.gupta 313
      $this->mcurl->add_call('refund','post',$url,$params);
10582 lgm 314
      $response = $this->mcurl->execute($url);
315
      $data['response'] = $response['contact']['response'];
316
      $response = $this->magento_model->payment_submit($data);
317
      echo json_encode($response[0]);
318
  }
319
  public function showAddress(){
320
    $configUrl = $this->config->item('shipping_process');
321
    $configUrl = $configUrl['url'];
322
    $url = $this->config->item('curl_base_url').$configUrl;
323
    $params = array();
324
    $authorized = $this->session->userdata('authorized');
325
    if(isset($authorized) && !empty($authorized)){
326
		$params['userId'] = $authorized['Id'];
327
		if($authorized['isLoggedIn'] == 1){
328
			$params['isLoggedIn'] = 'true';
329
		}
330
		elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
331
			$params['isLoggedIn'] = 'false';
332
		}
333
	}
334
    $this->mcurl->add_call('address','get',$url,$params);
335
    $response = $this->mcurl->execute($url);
336
    $data['response'] = $response['address']['response'];
337
    $addresses = json_decode($data['response']);
338
    $addresslist = '';
339
    if(isset($addresses->defaultAddress) && !empty($addresses->defaultAddress)){
340
    	$defaultAddress = $addresses->defaultAddress;
341
    	$addresslist .= '<div class="deliver-here">';
342
    	foreach ($addresses->addresses as $address) {
343
    	   $addresslist .= '<div class="deliver-address';
344
    	   if($addresses->defaultAddress == $address->id){
345
    	   	$addresslist .= ' selected-add" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
346
    	   }else{
347
    	   	$addresslist .='" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
348
    	   }
349
    	   $addresslist .= '<div>'.$address->name.'</div><div>'.$address->line1.'</div>';
350
    	   if(isset($address->line2) && !empty($address->line2)) {
351
    	   	$addresslist .='<div>'.$address->line2.'</div>';
352
    	   }
353
    	   $addresslist .= '<div>'.$address->city.', '.$address->pin.'</div>';
354
    	   if(isset($address->state) && !empty($address->state)) {
10638 lgm 355
    	 	  $addresslist .= '<div>'.$address->state.'</div>';
10582 lgm 356
    		}
10638 lgm 357
    	$addresslist .='</div>';	
10582 lgm 358
    	}
10638 lgm 359
    	//$addresslist .='</div>';
10582 lgm 360
    	$addresslist .= '<div class="add-address" onclick="showAddressForm();">+ Add new Address</div></div><input type="hidden" id="default" value="'.$defaultAddress.'"/>';
361
    	echo $addresslist;
362
    }
363
    else{
364
    	echo $addresslist;
365
    }
366
  }
367
  public function modifyAddress($orderId,$addressId,$days){
368
  	if(isset($orderId) && isset($addressId) && isset($days)){
369
  		$configUrl = $this->config->item('modifyAddress');
370
    	$configUrl = $configUrl['url'];
371
    	$url = $this->config->item('curl_base_url').$configUrl;
372
    	$params = array();
373
    	$params['orderId'] = $orderId;
374
    	$params['addressId'] = $addressId;
375
    	$params['days'] = $days;
376
    	$this->mcurl->add_call('address','post',$url,$params);
377
    	$response = $this->mcurl->execute($url);
378
    	$data['response'] = $response['address']['response'];
379
    	print_r($data['response']);
380
  	}
381
  }
382
  public function saveAddress($name,$line1,$line2=null,$state,$city,$pincode,$phone){
383
  	if(isset($name) && isset($line1) && isset($state) && isset($city) && isset($pincode) && isset($phone)){
384
  		if(is_numeric($pincode) && is_numeric($phone)){
385
  			$configUrl = $this->config->item('shipping_process');
386
	    	$configUrl = $configUrl['url'];
387
	    	$url = $this->config->item('curl_base_url').$configUrl;
388
	    	$params = array();
389
	    	$params['name'] = urldecode($name);
390
	    	$params['line1'] = urldecode($line1);
391
	    	if(isset($line2) && !empty($line2) && $line2 != 'null'){
392
	    		$params['line2'] = urldecode($line2);
393
	    	}
394
	    	$params['city'] = urldecode($city);
395
	    	$params['state'] = urldecode($state);
396
	    	$params['pin'] = $pincode;
397
	    	$params['pnone'] = $phone;
398
	    	$authorized = $this->session->userdata('authorized');
399
			if(isset($authorized) && !empty($authorized)){
400
				$params['userId'] = $authorized['Id'];
401
					if($authorized['isLoggedIn'] == 1){
402
						$params['isLoggedIn'] = 'true';
403
					}
404
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
405
						$params['isLoggedIn'] = 'false';
406
					}
407
				}
408
	    	$this->mcurl->add_call('address','post',$url,$params);
409
    		$response = $this->mcurl->execute($url);
410
    		$data['response'] = $response['address']['response'];
411
		    $addresses = json_decode($data['response']);
412
		    $addresslist = '';
413
		    if(isset($addresses->defaultAddress) && !empty($addresses->defaultAddress)){
414
		    	$defaultAddress = $addresses->defaultAddress;
415
		    	$addresslist .= '<div class="deliver-here">';
416
		    	foreach ($addresses->addresses as $address) {
417
		    	   $addresslist .= '<div class="deliver-address';
418
		    	   if($addresses->defaultAddress == $address->id){
419
		    	   	$addresslist .= ' selected-add" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
420
		    	   }else{
421
		    	   	$addresslist .='" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
422
		    	   }
423
		    	   $addresslist .= '<div>'.$address->name.'</div><div>'.$address->line1.'</div>';
424
		    	   if(isset($address->line2) && !empty($address->line2)) {
425
		    	   	$addresslist .='<div>'.$address->line2.'</div>';
426
		    	   }
427
		    	   $addresslist .= '<div>'.$address->city.', '.$address->pin.'</div>';
428
		    	   if(isset($address->state) && !empty($address->state)) {
10638 lgm 429
		    	 	  $addresslist .= '<div>'.$address->state.'</div>';
10582 lgm 430
		    		}
10639 lgm 431
		    		$addresslist .='</div>';
10582 lgm 432
		    	}
433
		    	$addresslist .= '<div class="add-address" onclick="showAddressForm();">+ Add new Address</div></div><input type="hidden" id="default" value="'.$defaultAddress.'"/>';
434
		    	echo $addresslist;
435
		    }
436
		    else{
437
		    	echo $addresslist;
438
		    }
439
		}
440
	}
441
  }
442
 
443
 
444
}
445
 
446
/* End of file welcome.php */
11324 anikendra 447
/* Location: ./application/controllers/welcome.php */