Subversion Repositories SmartDukaan

Rev

Rev 10735 | Rev 10757 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10606 amit.gupta 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
10611 amit.gupta 2
 
10582 lgm 3
class Checkout extends MY_Controller {
4
 
5
public $layoutName ='';
6
 
7
	function __construct() {
8
 
9
		// Call the CI_controller constructor
10
		parent::__construct();
11
		$admin = $this->session->userdata('admin');
12
		if(!isset($admin) || empty($admin)) {
13
			redirect(base_url().'authorize');
14
		}
15
		$this->layout->setlayout('layout/layout_main');
16
		$this->load->model('checkout_model');
17
		$this->load->model('captcha_model');
18
		$this->layoutName= $this->layout->getLayout();
19
		$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
20
			//print_r($this->session->userdata);
21
 
22
 
23
	}
24
	public function index()
25
	{
26
		$authorized = $this->session->userdata('authorized');
27
		if(isset($authorized) and !empty($authorized['id']))
28
		{
29
			//if user logged-in
30
			redirect(base_url().strtolower(__CLASS__).'/shipping');
31
		}
32
 
33
		//standard array
34
	}
35
	public function __paginateList($data=array())
36
	{
37
			//$data['baseSubTotal']=$data['baseSubTotal'];
38
			$data['subTotal'] = $data['subTotal'];
39
			//$data['shippingCharges'] = $data['shippingCharges'];
40
			return $data;	
41
 
42
	}
43
 
44
	public function orderconfirmation()
45
	{
46
		$authorized = $this->session->userdata('authorized');
47
	    if(isset($authorized) && !empty($authorized)){
48
			$_GET['userId'] = $authorized['Id'];
49
			$_GET['Id'] = $authorized['cartId'];
50
			if($authorized['isLoggedIn'] == 1){
51
				$_GET['isLoggedIn'] = 'true';
52
			}
53
		elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
54
				$_GET['isLoggedIn'] = 'false';
55
			}
56
		}
57
    	//die();
58
    	$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
59
        $data['stylesheet'] = 'shipping.css';
60
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$this->config->item('orderconfirmation'));
61
		// $this->session->unset_userdata('shipping');
62
		// $this->session->unset_userdata('billing');
63
		// $this->session->unset_userdata('shoppingId');
64
		$this->session->unset_userdata('hotspotId');
65
		$this->session->unset_userdata('addressId');
66
		$this->layout->view('checkout/checkout_view',$data);
67
	}
68
	public function payment()
69
	{
70
		//standard array
71
		//print_r($this->session->all_userdata())
72
		$authorized = $this->session->userdata('authorized');
73
		if(!isset($authorized) || empty($authorized)){
74
			redirect(base_url()."cart");
75
		}
76
 
77
		$data = array();
78
		$codCaptcha = $this->session->userdata('cod');
79
		if(isset($codCaptcha) && $codCaptcha == 1){
80
			$data['codCaptcha'] = 1;
81
			$this->session->unset_userdata('cod');
82
		}else{
83
			$data['codCaptcha'] = 0;
84
		}
85
		$paymentconfig = $this->config->item('payment');
86
		if(!isset($_POST['submit'])){
87
			$hotspot = $this->session->userdata('hotspotId');
88
			if(isset($hotspot) && !empty($hotspot)){
89
				$_GET['hotSpotAddressId'] = $hotspot;
90
				$_GET['deliveryLocation'] = 'hotSpot';
91
			}else{
92
				$_GET['deliveryLocation'] = 'myLocation';
93
			}
94
			unset($paymentconfig['response'][2]);
95
			if(isset($authorized) && !empty($authorized)){
96
				$_GET['userId'] = $authorized['Id'];
97
				$_GET['Id'] = $authorized['cartId'];
98
				if($authorized['isLoggedIn'] == 1){
99
					$_GET['isLoggedIn'] = 'true';
100
				}
101
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
102
					$_GET['isLoggedIn'] = 'false';
103
				}
104
			}
105
			$addressId = $this->session->userdata('addressId');
106
			$_GET['addressid'] = $addressId;
107
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
108
      		$data['stylesheet'] = 'shipping.css';
109
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),'',$paymentconfig);
110
			if(isset($data['response']['response']['payment_process'])){
111
				$result = json_decode($data['response']['response']['payment_process'][0]);
112
				$totalAmount = $result->results->totalAmount;
113
				if(isset($result->results->isTotalAmountZero)){
114
					$isTotalAmountZero = $result->results->isTotalAmountZero;
115
				}
116
				$totalAmount = number_format((float)$totalAmount,0,'.','');
117
				$captcha = $this->captcha_model->generateCaptcha();
118
				$this->session->set_userdata('captcha',$captcha['word']);
119
				$data['captcha'] = $captcha;
120
				// if($totalAmount == 0 && isset($isTotalAmountZero) && $isTotalAmountZero == 1){
121
				// 	$captcha = $this->captcha_model->generateCaptcha();
122
				// 	$this->session->set_userdata('captcha',$captcha['word']);
123
				// 	$this->session->set_userdata('captchaDisplay',$isTotalAmountZero);
124
				// 	$data['captcha'] = $captcha;
125
				// }
126
				$this->layout->view('checkout/checkout_view',$data);
127
			}
128
			else{
129
				redirect(base_url()."cart");
130
			}
131
		}
132
		elseif(isset($_POST['submit'])){
133
			if(isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field'])){
134
				$captcha = $this->session->userdata('captcha');
135
				if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
10630 lgm 136
					if(isset($_POST['payoption']) && ($_POST['payoption'] == 3000) || $_POST['payoption'] == 3001) {
10582 lgm 137
						$this->session->set_userdata('cod',1);
138
					}
139
        			redirect(base_url().'payment');
140
      			}
141
			}
142
			unset($paymentconfig['response'][0]);
143
			unset($paymentconfig['response'][1]);
144
			if(isset($authorized) && !empty($authorized)){
145
				$_POST['userId'] = $authorized['Id'];
146
				if($authorized['isLoggedIn'] == 1){
147
					$_POST['isLoggedIn'] = 'true';
148
				}
149
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
150
					$_POST['isLoggedIn'] = 'false';
151
				}
152
			}
153
			$addressId = $this->session->userdata('addressId');
154
			$_POST['addressid'] = $addressId;
155
			$_POST['payment_option'] = $_POST['payoption'];
156
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
157
			if(isset($data['response']['response']['payment_submit'][0]) && !empty($data['response']['response']['payment_submit'][0])){
158
				$paymentSubmit = $data['response']['response']['payment_submit'][0];
159
				if(isset($paymentSubmit->response->isPaymentRedirect) && $paymentSubmit->response->isPaymentRedirect == 1){
10735 lgm 160
					$image = base_url().'assets/images/loading.gif';
10582 lgm 161
					$location = $paymentSubmit->response->redirectUrl;
10735 lgm 162
					echo '<html><head><meta http-equiv="refresh" content="1;url='.$paymentSubmit->response->redirectUrl.'">
10582 lgm 163
  					<title>Saholic Mobile Site: Redirecting to <'.$paymentSubmit->response->gatewayName.'> Payment Gateway</title>
164
 					</head>
165
 						<body>
166
     					<div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
167
     					<div align="center" class="img">
168
      					<img title="loading" alt="loading" src="'.$image.'">
169
     					</div>
170
 						</body>
171
						</html>';
172
				}elseif(strpos($paymentSubmit->response->redirectUrl, 'ebs-pay') !== false){
173
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
174
					//echo $url;
175
					$authorized = $this->session->userdata('authorized');
176
					if(isset($authorized) && !empty($authorized)){
177
						$params['userId'] = $authorized['Id'];
178
						if($authorized['isLoggedIn'] == 1){
179
							$params['isLoggedIn'] = 'true';
180
						}
181
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
182
							$params['isLoggedIn'] = 'false';
183
						}
184
					}
185
					$this->mcurl->add_call('ebs','get',$url,$params);
186
         			$response = $this->mcurl->execute($url);
187
         			$data['response'] = $response['ebs']['response'];
188
         			$response = $this->magento_model->payment_submit($data);
189
         			if(isset($response) && !empty($response)){
190
         				$ebs = $response[0]->response;
10735 lgm 191
         				$image = base_url().'assets/images/loading.gif';
10582 lgm 192
         				echo '<html>
193
						<head>
194
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
195
						</head>
196
						<body>
197
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
198
						 <div align="center" class="img">
10735 lgm 199
						  <img title="loading" alt="loading" src="'.$image.'">
10582 lgm 200
						 </div>
201
						 <div style="display:none">
202
						  <form  method="post" action="'.$ebs->postAction.'" name="frmTransaction" id="frmTransaction">  
203
				           <!-- Account Id -->
204
				           <input name="account_id" type="hidden" value="'.$ebs->account_id.'" />
205
				           <!-- Transaction Details -->
206
				           <input name="reference_no" type="hidden" value="'.$ebs->reference_no.'" />
207
				           <input name="amount" type="hidden" value="'.$ebs->amount.'" />
208
				           <input name="description" type="hidden" value="'.$ebs->description.'" />
209
				           <input name="payment_option" type="hidden" value="'.$ebs->payment_option.'"/>
210
				           <!-- Billing Address -->
211
				           <input name="name" type="hidden" value="'.$ebs->name.'" />
212
				           <input name="address" type="hidden" value="'.$ebs->address.'" />
213
				           <input name="city" type="hidden" value="'.$ebs->city.'" />
214
				           <input name="state" type="hidden" value="'.$ebs->state.'" />
215
				           <input name="postal_code" type="hidden" value="'.$ebs->postal_code.'" />
216
				           <input name="country" type="hidden" value="IND"/>
217
				           <input name="email" type="hidden" value="'.$ebs->email.'" />
218
				           <input name="phone" type="hidden" value="'.$ebs->phone.'" />
219
				           <!-- Delivery Address -->
220
				           <input name="ship_name" type="hidden" value="'.$ebs->ship_name.'" />
221
				           <input name="ship_address" type="hidden" value="'.$ebs->ship_address.'" />
222
				           <input name="ship_city" type="hidden" value="'.$ebs->ship_city.'" />
223
				           <input name="ship_state" type="hidden" value="'.$ebs->ship_state.'" />
224
				           <input name="ship_postal_code" type="hidden" value="'.$ebs->ship_postal_code.'" />
225
				           <input name="ship_country" type="hidden" value="IND"/> 
226
				           <input name="ship_phone" type="hidden" value="'.$ebs->ship_phone.'" />
227
				           <input name="return_url" type="hidden" value="'.$ebs->return_url.'" />
228
				           <input name="mode" value="'.$ebs->mode.'"/>
229
				           <input name="secure_hash" type="hidden" value="'.$ebs->secure_hash.'" />
230
				           <input name="channel" type="hidden" value="'.$ebs->channel.'" />
231
				           <input name="page_id" type="hidden" value="'.$ebs->page_id.'" />
232
				           <input name="submitted" value="Submit" type="submit" /> 
233
				           <input value="Reset" type="reset" />
234
						  </form>
235
						    </div>
236
						    <script type="text/javascript">
237
						     document.getElementById("frmTransaction").submit();
238
						    </script>
239
						  </body>
240
						</html>';
241
         			}else{
242
         				redirect(base_url().'payment');
243
         			}
244
				}
245
				else{
246
					redirect(base_url().$paymentSubmit->response->redirectUrl);
247
				}
248
			}
249
			else{
250
			redirect(base_url()."payment");	
251
			}
252
		}
253
 
254
	}
255
	public function ebsprocessing(){
256
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
257
			$paymentconfig = $this->config->item('ebsProcessing');
258
			$authorized = $this->session->userdata('authorized');
259
			if(isset($authorized) && !empty($authorized)){
260
				$_GET['userId'] = $authorized['Id'];
261
				if($authorized['isLoggedIn'] == 1){
262
					$_GET['isLoggedIn'] = 'true';
263
				}
264
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
265
					$_GET['isLoggedIn'] = 'false';
266
				}
267
			}
268
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
269
			if(isset($data['response']['response']['ebs_processing'][0]->response)){
270
				$redirectUrl = $data['response']['response']['ebs_processing'][0]->response->redirectUrl;
271
				$redirectUrl = explode('?', $redirectUrl);
272
				$redirectUrl = base_url().'ebs-pay-response/?'.$redirectUrl[1];
10735 lgm 273
				$image = base_url().'assets/images/loading.gif';
10582 lgm 274
				echo '<html><head><meta http-equiv="refresh" content="2;url='.$redirectUrl.'">
275
  					<title>Saholic Mobile Site:</title>
276
 					</head>
277
 						<body>
278
     					<div style="text-align:center; margin-top:200px;">'.$data['response']['response']['ebs_processing'][0]->response->redirectMessage.'</div>
279
     					<div align="center" class="img">
10735 lgm 280
      					<img title="loading" alt="loading" src="'.$image.'">
10582 lgm 281
     					</div>
282
 						</body>
283
						</html>';
284
			}
285
		}
286
	}
287
	public function ebsresponse(){
288
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
289
			$paymentconfig = $this->config->item('ebsResponse');
290
			$authorized = $this->session->userdata('authorized');
291
			if(isset($authorized) && !empty($authorized)){
292
				$_GET['userId'] = $authorized['Id'];
293
				if($authorized['isLoggedIn'] == 1){
294
					$_GET['isLoggedIn'] = 'true';
295
				}
296
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
297
					$_GET['isLoggedIn'] = 'false';
298
				}
299
			}
300
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
301
			if(isset($data['response']['response']['ebs_response'][0]->response) && !empty($data['response']['response']['ebs_response'][0]->response)){
302
				$redirectUrl = $data['response']['response']['ebs_response'][0]->response->redirectUrl;
303
				redirect($redirectUrl);
304
			}
305
			else{
306
				redirect(base_url().'payment');
307
			}
308
		}
309
	}
310
	public function hdfcPayResponse(){
311
		if(isset($_POST)){
312
			$paymentconfig = $this->config->item('hdfcResponse');
313
			$authorized = $this->session->userdata('authorized');
314
			if(isset($authorized) && !empty($authorized)){
315
				$_POST['userId'] = $authorized['Id'];
316
				if($authorized['isLoggedIn'] == 1){
317
					$_POST['isLoggedIn'] = 'true';
318
				}
319
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
320
					$_POST['isLoggedIn'] = 'false';
321
				}
322
			}
323
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
324
			if(isset($data['response']['response']['hdfc_response'][0]->response) && !empty($data['response']['response']['hdfc_response'][0]->response)){
325
				$redirectUrl = $data['response']['response']['hdfc_response'][0]->response->redirectUrl;
326
				redirect($redirectUrl);
327
			}
328
			else{
329
				redirect(base_url());
330
			}	
331
		}else{
332
			redirect(base_url());
333
		}
334
	}
335
	public function innovitiPayment(){
336
		$last = $this->uri->total_segments();
337
		$itemcode = $this->uri->segment($last);
338
		if(isset($itemcode) && !empty($itemcode)){
339
			$url = $this->config->item('curl_base_url').'innoviti-pay/'.$itemcode;
340
			$params = array();
341
			$authorized = $this->session->userdata('authorized');
342
			if(isset($authorized) && !empty($authorized)){
343
				$params['userId'] = $authorized['Id'];
344
				if($authorized['isLoggedIn'] == 1){
345
					$params['isLoggedIn'] = 'true';
346
				}
347
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
348
					$params['isLoggedIn'] = 'false';
349
				}
350
			$this->mcurl->add_call('innoviti','get',$url,$params);
351
 			$response = $this->mcurl->execute($url);
352
 			$data['response'] = $response['innoviti']['response'];
353
         	$response = $this->magento_model->payment_submit($data);
354
         	if(isset($response) && !empty($response)){
355
         		$innoviti = $response[0]->response;
10630 lgm 356
         		echo '<form  method="post" action="'.$innoviti->action.'" name="frmTransaction" id="frmTransaction">  
10582 lgm 357
           				<input name="merchantId" type="hidden" value="'.$innoviti->merchantId.'" />
358
     					<input name="subMerchantId" type="hidden" value="'.$innoviti->subMerchantId.'" />
359
           				<!-- Transaction Details -->
360
           				<input name="orderId" type="hidden" value="'.$innoviti->orderId.'" />
361
     					<input name="amt" type="hidden" value="'.$innoviti->amt.'" />   
362
     					<input name="cur" type="hidden" value="INR" />
363
     					<input name="processingCode" type="hidden" value="'.$innoviti->processingCode.'" />
364
     					<input name="proSku" type="hidden" value="'.$innoviti->proSku.'" />
365
           				<input name="Cname" type="hidden" value="'.$innoviti->Cname.'" /></td>
366
     					<input name="mobile" type="hidden" value="'.$innoviti->mobile.'" />
367
     					<input name="emailId" type="hidden" value="'.$innoviti->emailId.'" />     
368
   						<input name="redirUrl" type="hidden" value="'.$innoviti->redirUrl.'" />
369
     					<input name="chksum" type="hidden" value="'.$innoviti->chksum.'" />
370
     					<input name="isCtx" type="hidden" value="NO" />
10630 lgm 371
        				<input name="submitted" value="Submit" type="submit" />&nbsp; 
372
           				<input value="Reset" type="reset" />
10582 lgm 373
           				<script type="text/javascript">
374
						    document.getElementById("frmTransaction").submit();
375
						</script>
376
      				  </form>';
377
         	}
378
			}else{
379
				redirect(base_url());
380
			}
381
 
382
		}else{
383
			redirect(base_url());
384
		}
385
	}
386
	public function innovitiResponse(){
387
		if(isset($_POST)){
388
			$paymentconfig = $this->config->item('innovitiResponse');
389
			$authorized = $this->session->userdata('authorized');
390
			if(isset($authorized) && !empty($authorized)){
391
				$_POST['userId'] = $authorized['Id'];
392
				if($authorized['isLoggedIn'] == 1){
393
					$_POST['isLoggedIn'] = 'true';
394
				}
395
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
396
					$_POST['isLoggedIn'] = 'false';
397
				}
398
			}
399
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
400
			if(isset($data['response']['response']['innoviti_response'][0]->response) && !empty($data['response']['response']['innoviti_response'][0]->response)){
401
				$redirectUrl = $data['response']['response']['innoviti_response'][0]->response->redirectUrl;
402
				redirect($redirectUrl);
403
			}
404
			else{
405
				redirect(base_url());
406
			}	
407
		}else{
408
			redirect(base_url());
409
		}
410
	}
411
	public function paymenterror(){
412
			$authorized = $this->session->userdata('authorized');
413
			if(isset($authorized) && !empty($authorized)){
414
				$data = array();
415
				$paymentconfig = $this->config->item('paymenterror');
10634 lgm 416
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
10582 lgm 417
				$data['stylesheet'] = 'shipping.css';
418
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
419
				$this->layout->view('checkout/checkout_view',$data);
420
			}else{
421
				redirect(base_url());
422
			}
423
	}
424
	public function shipping()
425
	{
426
 
427
		$data = array();
428
		$authorized = $this->session->userdata('authorized');
429
		if($authorized['isLoggedIn'] != 1){
430
			$this->session->set_userdata('location','shipping');
431
			redirect(base_url()."login");
432
		}
433
		$shippingconfig = $this->config->item('shipping');
434
		if(!isset($_POST['submit']))
435
		{
436
			$authorized = $this->session->userdata('authorized');
437
				if(isset($authorized) && !empty($authorized)){
438
					$_GET['userId'] = $authorized['Id'];
439
					$_GET['Id'] = $authorized['cartId'];
440
					if($authorized['isLoggedIn'] == 1){
441
						$_GET['isLoggedIn'] = 'true';
442
					}
443
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
444
						$_GET['isLoggedIn'] = 'false';
445
					}
446
				}
447
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
448
			$data['stylesheet'] = 'shipping.css';
449
			$cache = getFileCache('pickup');
450
			if(isset($cache) && !empty($cache)){
451
				unset($shippingconfig['response'][1]);
452
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
453
				$data['response']['response']['pickup'] = $cache;
454
			}else{
455
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
456
        		if(isset($data['response']['response']['pickup']) && !empty($data['response']['response']['pickup']))
457
        		setFileCache($data['response']['response']['pickup'], 'pickup',900);
458
			}
10752 lgm 459
			if(isset($data['response']['response']['shipping_process'][0]) && !empty($data['response']['response']['shipping_process'][0])){
460
				$this->layout->view('checkout/checkout_view',$data);
461
			}else{
462
				redirect(base_url()."cart");
463
			}
10582 lgm 464
		}
465
		if(isset($_POST['submit']))
466
		{
467
			unset($shippingconfig['response'][1]);	
468
			$data = $this->get_shipping_billing($_POST);
469
			$this->session->set_userdata($data);
470
			$authorized = $this->session->userdata('authorized');
471
			if(isset($authorized) && !empty($authorized)){
472
				$_POST['userId'] = $authorized['Id'];
473
				//$_POST['Id'] = $authorized['cartId'];
474
					if($authorized['isLoggedIn'] == 1){
475
						$_POST['isLoggedIn'] = 'true';
476
					}
477
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
478
						$_POST['isLoggedIn'] = 'false';
479
					}
480
				}
481
			//$data['stylesheet'] = 'shipping.less';
482
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
483
			//$this->layout->view('checkout/checkout_view',$data);
484
			redirect(base_url()."shipping");
485
 
486
		}
487
 
488
	}
489
 
490
	public function get_shipping_billing($data=array()){
491
		$billing =array();
492
		$shipping =array();
493
		if (isset($data) && !empty($data)) {
494
			$shipping=array('name'  => $data['name'],'line1' => $data['line1'],'line2' => $data['line2'], 'city' => $data['city'], 'pin' => $data['pin'], 'phonenumber' => $data['phone']);
495
			return array('shipping'=>$shipping,'billing'=>$billing);
496
		}
497
	}
498
 
499
	public function delete($addressId){
500
		$shippingconfig = $this->config->item('shipping_delete');
501
		$_GET['addressId'] = $addressId;
502
		$authorized = $this->session->userdata('authorized');
503
		if(isset($authorized) && !empty($authorized)){
504
			$_GET['userId'] = $authorized['Id'];
505
			$_GET['Id'] = $authorized['cartId'];
506
			if($authorized['isLoggedIn'] == 1){
507
				$_GET['isLoggedIn'] = 'true';
508
			}
509
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
510
				$_GET['isLoggedIn'] = 'false';
511
				}
512
			}
513
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
514
			print_r($data['response']);
515
		}
516
 
517
	public function changeAddress($addressId,$type){
518
		if(isset($addressId) && isset($type)){
519
		$shippingconfig = $this->config->item('shipping_change');
520
		$_GET['addressId'] = $addressId;
521
		$_GET['addressType'] = $type;
522
		$authorized = $this->session->userdata('authorized');
523
		if(isset($authorized) && !empty($authorized)){
524
			$_GET['userId'] = $authorized['Id'];
525
			$_GET['Id'] = $authorized['cartId'];
526
			if($authorized['isLoggedIn'] == 1){
527
				$_GET['isLoggedIn'] = 'true';
528
			}
529
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
530
				$_GET['isLoggedIn'] = 'false';
531
				}
532
			}
533
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
534
			$this->session->set_userdata('addressId',$addressId);
535
			print_r($data['response']['response']['changeAddress'][0]->message);
536
		}
537
	}
538
	public function changeCaptcha(){
539
		$captchaDisplay = $this->session->userdata('captchaDisplay');
540
		//if(isset($captchaDisplay) && $captchaDisplay == 1){
541
			$captcha = $this->captcha_model->generateCaptcha();
542
			$this->session->set_userdata('captcha',$captcha['word']);
543
			unset($captcha['word']);
544
			unset($captcha['time']);
545
			unset($captcha['name']);
546
			echo json_encode($captcha);
547
		//}
548
	}
549
	public function insuranceInfo($bday,$gname,$addressId){
550
	if((isset($bday) && !empty($bday)) && (isset($gname) && !empty($gname)) && (isset($addressId) && !empty($addressId))){
551
		if(isset($gname) && !empty($gname)){
552
			$gname = str_replace('-','',$gname);
553
			$gname = ltrim($gname);
554
			$gname = rtrim($gname);
555
			$_GET['guardianName'] = $gname;
556
		}
557
		if(isset($bday) && !empty($bday)){
558
			$dob = explode('-',$bday);
559
			$dob = array_reverse($dob);
560
			$temp1 = $dob[1];
561
			$temp2 = $dob[0];
562
			$dob[0] = $temp1;
563
			$dob[1] = $temp2;
564
			$dob = implode('/', $dob);
565
			$_GET['dob'] = $dob; 
566
		}
567
		$insuranceconfig = $this->config->item('insurance_info');
568
		$_GET['addressId'] = $addressId;
569
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$insuranceconfig);
570
		if(isset($data['response']['response']['insuranceInfo'][0]->response) && (!empty($data['response']['response']['insuranceInfo'][0]->response))) {
571
			echo json_encode($data['response']['response']['insuranceInfo'][0]);
572
		}
573
	}
574
  }
575
  public function pickupSpot($id){
576
  	if(isset($id) && !empty($id) && is_numeric($id)){
577
  		$this->session->set_userdata('hotspotId',$id);
578
  		$response['msg'] = 'sucess';
579
  		echo json_encode($response);
580
  	}
581
  }
582
 
583
}
584
 
10611 amit.gupta 585
 
10582 lgm 586
/* End of file welcome.php */
587
/* Location: ./application/controllers/welcome.php */