Subversion Repositories SmartDukaan

Rev

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