Subversion Repositories SmartDukaan

Rev

Rev 11520 | Rev 17571 | Go to most recent revision | 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';
214
			$this->layout->view('myaccount/account_view',$data);
215
		}else{
216
			redirect(base_url());
217
		}
218
	}
219
	public function recharges(){
220
 
221
		$authorized = $this->session->userdata('authorized');
222
		if(isset($authorized) && !empty($authorized)){
223
			$_GET['userId'] = $authorized['Id'];
224
			if($authorized['isLoggedIn'] == 1){
225
				$_GET['isLoggedIn'] = 'true';
226
			}
227
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
228
				$_GET['isLoggedIn'] = 'false';
229
			}
230
		}else{
11507 anikendra 231
			redirect(base_url().'auth/login');
10582 lgm 232
		}
233
		//standard array
11169 lgm 234
		$configdata = $this->config->item('my-recharges');
235
		//$checkConfig = $this->config->item('home');
236
		$cachemodule = array('header','footer');
237
		$configdata = getCache($configdata,$cachemodule);
10582 lgm 238
		$data = array();
11169 lgm 239
		$data['response']=$this->myaccount_model->getOrder($this->input->get(),$this->input->post(),$configdata['module']);
240
		if(isset($cachemodule) and !empty($cachemodule) && !isset($api))
241
		{
242
			foreach($cachemodule as $cm)
243
			{
244
				if(isset($configdata[$cm]) and !empty($configdata[$cm]))
245
				{
246
					$data['response'][$cm]=$configdata[$cm];
247
				}
248
			}
249
		}
250
		setCache($configdata['module'],$cachemodule,$data['response']);
10582 lgm 251
		if(isset($data['response']['response']['myrecharges'][0]) && !empty($data['response']['response']['myrecharges'][0])){
252
			$this->lessphp->object()->ccompile('assets/css/profile.less','assets/css/profile.css');
253
			$data['stylesheet'] = 'profile.css';
254
			$this->layout->view('myaccount/account_view',$data);
255
		}else{
256
			redirect(base_url());
257
		}
258
	}
259
	public function contact($email,$orderId,$subject,$message,$awb){
260
		$configUrl = $this->config->item('contact');
261
		$configUrl = $configUrl['url'];
262
		$url = $this->config->item('curl_base_url').$configUrl;
263
		$params = array();
264
		$params['email'] = urldecode($email);
265
		$params['order_id'] = $orderId;
266
		$params['subject'] = urldecode($subject);
267
		$params['message'] = urldecode($message);
268
		$params['communication_type'] = 2;
269
		if($awb == 'null'){
270
			$params['awb'] = '';
271
		}else{
272
			$params['awb'] = urldecode($awb);
273
		}
274
		$this->mcurl->add_call('contact','post',$url,$params);
275
	    $response = $this->mcurl->execute($url);
276
	    $data['response'] = $response['contact']['response'];
277
	    $response = $this->magento_model->payment_submit($data);
278
	    echo json_encode($response[0]);
279
	}
280
 
281
    public function refund($orderId){
15927 amit.gupta 282
    $url = $this->config->item('curl_base_url').'my-recharges';
10582 lgm 283
    $params = array();
284
    //$params['email'] = urldecode($email);
15927 amit.gupta 285
    $params['orderId'] = $orderId;
10582 lgm 286
    // $params['subject'] = urldecode($subject);
287
    // $params['message'] = urldecode($message);
15927 amit.gupta 288
    #$params['communication_type'] = 2;
10582 lgm 289
    // if($awb == 'null'){
290
      // $params['awb'] = '';
291
    // }else{
292
      // $params['awb'] = urldecode($awb);
293
    // }
15927 amit.gupta 294
      $this->mcurl->add_call('refund','post',$url,$params);
10582 lgm 295
      $response = $this->mcurl->execute($url);
296
      $data['response'] = $response['contact']['response'];
297
      $response = $this->magento_model->payment_submit($data);
298
      echo json_encode($response[0]);
299
  }
300
  public function showAddress(){
301
    $configUrl = $this->config->item('shipping_process');
302
    $configUrl = $configUrl['url'];
303
    $url = $this->config->item('curl_base_url').$configUrl;
304
    $params = array();
305
    $authorized = $this->session->userdata('authorized');
306
    if(isset($authorized) && !empty($authorized)){
307
		$params['userId'] = $authorized['Id'];
308
		if($authorized['isLoggedIn'] == 1){
309
			$params['isLoggedIn'] = 'true';
310
		}
311
		elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
312
			$params['isLoggedIn'] = 'false';
313
		}
314
	}
315
    $this->mcurl->add_call('address','get',$url,$params);
316
    $response = $this->mcurl->execute($url);
317
    $data['response'] = $response['address']['response'];
318
    $addresses = json_decode($data['response']);
319
    $addresslist = '';
320
    if(isset($addresses->defaultAddress) && !empty($addresses->defaultAddress)){
321
    	$defaultAddress = $addresses->defaultAddress;
322
    	$addresslist .= '<div class="deliver-here">';
323
    	foreach ($addresses->addresses as $address) {
324
    	   $addresslist .= '<div class="deliver-address';
325
    	   if($addresses->defaultAddress == $address->id){
326
    	   	$addresslist .= ' selected-add" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
327
    	   }else{
328
    	   	$addresslist .='" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
329
    	   }
330
    	   $addresslist .= '<div>'.$address->name.'</div><div>'.$address->line1.'</div>';
331
    	   if(isset($address->line2) && !empty($address->line2)) {
332
    	   	$addresslist .='<div>'.$address->line2.'</div>';
333
    	   }
334
    	   $addresslist .= '<div>'.$address->city.', '.$address->pin.'</div>';
335
    	   if(isset($address->state) && !empty($address->state)) {
10638 lgm 336
    	 	  $addresslist .= '<div>'.$address->state.'</div>';
10582 lgm 337
    		}
10638 lgm 338
    	$addresslist .='</div>';	
10582 lgm 339
    	}
10638 lgm 340
    	//$addresslist .='</div>';
10582 lgm 341
    	$addresslist .= '<div class="add-address" onclick="showAddressForm();">+ Add new Address</div></div><input type="hidden" id="default" value="'.$defaultAddress.'"/>';
342
    	echo $addresslist;
343
    }
344
    else{
345
    	echo $addresslist;
346
    }
347
  }
348
  public function modifyAddress($orderId,$addressId,$days){
349
  	if(isset($orderId) && isset($addressId) && isset($days)){
350
  		$configUrl = $this->config->item('modifyAddress');
351
    	$configUrl = $configUrl['url'];
352
    	$url = $this->config->item('curl_base_url').$configUrl;
353
    	$params = array();
354
    	$params['orderId'] = $orderId;
355
    	$params['addressId'] = $addressId;
356
    	$params['days'] = $days;
357
    	$this->mcurl->add_call('address','post',$url,$params);
358
    	$response = $this->mcurl->execute($url);
359
    	$data['response'] = $response['address']['response'];
360
    	print_r($data['response']);
361
  	}
362
  }
363
  public function saveAddress($name,$line1,$line2=null,$state,$city,$pincode,$phone){
364
  	if(isset($name) && isset($line1) && isset($state) && isset($city) && isset($pincode) && isset($phone)){
365
  		if(is_numeric($pincode) && is_numeric($phone)){
366
  			$configUrl = $this->config->item('shipping_process');
367
	    	$configUrl = $configUrl['url'];
368
	    	$url = $this->config->item('curl_base_url').$configUrl;
369
	    	$params = array();
370
	    	$params['name'] = urldecode($name);
371
	    	$params['line1'] = urldecode($line1);
372
	    	if(isset($line2) && !empty($line2) && $line2 != 'null'){
373
	    		$params['line2'] = urldecode($line2);
374
	    	}
375
	    	$params['city'] = urldecode($city);
376
	    	$params['state'] = urldecode($state);
377
	    	$params['pin'] = $pincode;
378
	    	$params['pnone'] = $phone;
379
	    	$authorized = $this->session->userdata('authorized');
380
			if(isset($authorized) && !empty($authorized)){
381
				$params['userId'] = $authorized['Id'];
382
					if($authorized['isLoggedIn'] == 1){
383
						$params['isLoggedIn'] = 'true';
384
					}
385
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
386
						$params['isLoggedIn'] = 'false';
387
					}
388
				}
389
	    	$this->mcurl->add_call('address','post',$url,$params);
390
    		$response = $this->mcurl->execute($url);
391
    		$data['response'] = $response['address']['response'];
392
		    $addresses = json_decode($data['response']);
393
		    $addresslist = '';
394
		    if(isset($addresses->defaultAddress) && !empty($addresses->defaultAddress)){
395
		    	$defaultAddress = $addresses->defaultAddress;
396
		    	$addresslist .= '<div class="deliver-here">';
397
		    	foreach ($addresses->addresses as $address) {
398
		    	   $addresslist .= '<div class="deliver-address';
399
		    	   if($addresses->defaultAddress == $address->id){
400
		    	   	$addresslist .= ' selected-add" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
401
		    	   }else{
402
		    	   	$addresslist .='" id="'.$address->id.'" data-type="'.$address->type.'" onclick="changeAddress(\''.$address->id.'\',\''.$address->type.'\',\''.$address->pin.'\')">';
403
		    	   }
404
		    	   $addresslist .= '<div>'.$address->name.'</div><div>'.$address->line1.'</div>';
405
		    	   if(isset($address->line2) && !empty($address->line2)) {
406
		    	   	$addresslist .='<div>'.$address->line2.'</div>';
407
		    	   }
408
		    	   $addresslist .= '<div>'.$address->city.', '.$address->pin.'</div>';
409
		    	   if(isset($address->state) && !empty($address->state)) {
10638 lgm 410
		    	 	  $addresslist .= '<div>'.$address->state.'</div>';
10582 lgm 411
		    		}
10639 lgm 412
		    		$addresslist .='</div>';
10582 lgm 413
		    	}
414
		    	$addresslist .= '<div class="add-address" onclick="showAddressForm();">+ Add new Address</div></div><input type="hidden" id="default" value="'.$defaultAddress.'"/>';
415
		    	echo $addresslist;
416
		    }
417
		    else{
418
		    	echo $addresslist;
419
		    }
420
		}
421
	}
422
  }
423
 
424
 
425
}
426
 
427
/* End of file welcome.php */
11324 anikendra 428
/* Location: ./application/controllers/welcome.php */