Subversion Repositories SmartDukaan

Rev

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