Subversion Repositories SmartDukaan

Rev

Rev 10834 | Rev 10862 | 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
				           <input name="submitted" value="Submit" type="submit" /> 
236
				           <input value="Reset" type="reset" />
237
						  </form>
238
						    </div>
239
						    <script type="text/javascript">
240
						     document.getElementById("frmTransaction").submit();
241
						    </script>
242
						  </body>
243
						</html>';
244
         			}else{
245
         				redirect(base_url().'payment');
246
         			}
247
				}
248
				else{
249
					redirect(base_url().$paymentSubmit->response->redirectUrl);
250
				}
251
			}
252
			else{
253
			redirect(base_url()."payment");	
254
			}
255
		}
256
 
257
	}
258
	public function ebsprocessing(){
259
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
260
			$paymentconfig = $this->config->item('ebsProcessing');
261
			$authorized = $this->session->userdata('authorized');
262
			if(isset($authorized) && !empty($authorized)){
263
				$_GET['userId'] = $authorized['Id'];
264
				if($authorized['isLoggedIn'] == 1){
265
					$_GET['isLoggedIn'] = 'true';
266
				}
267
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
268
					$_GET['isLoggedIn'] = 'false';
269
				}
270
			}
271
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
272
			if(isset($data['response']['response']['ebs_processing'][0]->response)){
273
				$redirectUrl = $data['response']['response']['ebs_processing'][0]->response->redirectUrl;
274
				$redirectUrl = explode('?', $redirectUrl);
275
				$redirectUrl = base_url().'ebs-pay-response/?'.$redirectUrl[1];
10735 lgm 276
				$image = base_url().'assets/images/loading.gif';
10582 lgm 277
				echo '<html><head><meta http-equiv="refresh" content="2;url='.$redirectUrl.'">
278
  					<title>Saholic Mobile Site:</title>
279
 					</head>
280
 						<body>
281
     					<div style="text-align:center; margin-top:200px;">'.$data['response']['response']['ebs_processing'][0]->response->redirectMessage.'</div>
282
     					<div align="center" class="img">
10735 lgm 283
      					<img title="loading" alt="loading" src="'.$image.'">
10582 lgm 284
     					</div>
285
 						</body>
286
						</html>';
287
			}
288
		}
289
	}
290
	public function ebsresponse(){
291
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
292
			$paymentconfig = $this->config->item('ebsResponse');
293
			$authorized = $this->session->userdata('authorized');
294
			if(isset($authorized) && !empty($authorized)){
295
				$_GET['userId'] = $authorized['Id'];
296
				if($authorized['isLoggedIn'] == 1){
297
					$_GET['isLoggedIn'] = 'true';
298
				}
299
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
300
					$_GET['isLoggedIn'] = 'false';
301
				}
302
			}
303
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
304
			if(isset($data['response']['response']['ebs_response'][0]->response) && !empty($data['response']['response']['ebs_response'][0]->response)){
305
				$redirectUrl = $data['response']['response']['ebs_response'][0]->response->redirectUrl;
306
				redirect($redirectUrl);
307
			}
308
			else{
309
				redirect(base_url().'payment');
310
			}
311
		}
312
	}
313
	public function hdfcPayResponse(){
314
		if(isset($_POST)){
315
			$paymentconfig = $this->config->item('hdfcResponse');
316
			$authorized = $this->session->userdata('authorized');
317
			if(isset($authorized) && !empty($authorized)){
318
				$_POST['userId'] = $authorized['Id'];
319
				if($authorized['isLoggedIn'] == 1){
320
					$_POST['isLoggedIn'] = 'true';
321
				}
322
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
323
					$_POST['isLoggedIn'] = 'false';
324
				}
325
			}
326
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
327
			if(isset($data['response']['response']['hdfc_response'][0]->response) && !empty($data['response']['response']['hdfc_response'][0]->response)){
328
				$redirectUrl = $data['response']['response']['hdfc_response'][0]->response->redirectUrl;
329
				redirect($redirectUrl);
330
			}
331
			else{
332
				redirect(base_url());
333
			}	
334
		}else{
335
			redirect(base_url());
336
		}
337
	}
338
	public function innovitiPayment(){
339
		$last = $this->uri->total_segments();
340
		$itemcode = $this->uri->segment($last);
341
		if(isset($itemcode) && !empty($itemcode)){
342
			$url = $this->config->item('curl_base_url').'innoviti-pay/'.$itemcode;
343
			$params = array();
344
			$authorized = $this->session->userdata('authorized');
345
			if(isset($authorized) && !empty($authorized)){
346
				$params['userId'] = $authorized['Id'];
347
				if($authorized['isLoggedIn'] == 1){
348
					$params['isLoggedIn'] = 'true';
349
				}
350
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
351
					$params['isLoggedIn'] = 'false';
352
				}
353
			$this->mcurl->add_call('innoviti','get',$url,$params);
354
 			$response = $this->mcurl->execute($url);
355
 			$data['response'] = $response['innoviti']['response'];
356
         	$response = $this->magento_model->payment_submit($data);
357
         	if(isset($response) && !empty($response)){
358
         		$innoviti = $response[0]->response;
10630 lgm 359
         		echo '<form  method="post" action="'.$innoviti->action.'" name="frmTransaction" id="frmTransaction">  
10582 lgm 360
           				<input name="merchantId" type="hidden" value="'.$innoviti->merchantId.'" />
361
     					<input name="subMerchantId" type="hidden" value="'.$innoviti->subMerchantId.'" />
362
           				<!-- Transaction Details -->
363
           				<input name="orderId" type="hidden" value="'.$innoviti->orderId.'" />
364
     					<input name="amt" type="hidden" value="'.$innoviti->amt.'" />   
365
     					<input name="cur" type="hidden" value="INR" />
366
     					<input name="processingCode" type="hidden" value="'.$innoviti->processingCode.'" />
367
     					<input name="proSku" type="hidden" value="'.$innoviti->proSku.'" />
368
           				<input name="Cname" type="hidden" value="'.$innoviti->Cname.'" /></td>
369
     					<input name="mobile" type="hidden" value="'.$innoviti->mobile.'" />
370
     					<input name="emailId" type="hidden" value="'.$innoviti->emailId.'" />     
371
   						<input name="redirUrl" type="hidden" value="'.$innoviti->redirUrl.'" />
372
     					<input name="chksum" type="hidden" value="'.$innoviti->chksum.'" />
373
     					<input name="isCtx" type="hidden" value="NO" />
10630 lgm 374
        				<input name="submitted" value="Submit" type="submit" />&nbsp; 
375
           				<input value="Reset" type="reset" />
10582 lgm 376
           				<script type="text/javascript">
377
						    document.getElementById("frmTransaction").submit();
378
						</script>
379
      				  </form>';
380
         	}
381
			}else{
382
				redirect(base_url());
383
			}
384
 
385
		}else{
386
			redirect(base_url());
387
		}
388
	}
389
	public function innovitiResponse(){
390
		if(isset($_POST)){
391
			$paymentconfig = $this->config->item('innovitiResponse');
392
			$authorized = $this->session->userdata('authorized');
393
			if(isset($authorized) && !empty($authorized)){
394
				$_POST['userId'] = $authorized['Id'];
395
				if($authorized['isLoggedIn'] == 1){
396
					$_POST['isLoggedIn'] = 'true';
397
				}
398
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
399
					$_POST['isLoggedIn'] = 'false';
400
				}
401
			}
402
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
403
			if(isset($data['response']['response']['innoviti_response'][0]->response) && !empty($data['response']['response']['innoviti_response'][0]->response)){
404
				$redirectUrl = $data['response']['response']['innoviti_response'][0]->response->redirectUrl;
405
				redirect($redirectUrl);
406
			}
407
			else{
408
				redirect(base_url());
409
			}	
410
		}else{
411
			redirect(base_url());
412
		}
413
	}
414
	public function paymenterror(){
415
			$authorized = $this->session->userdata('authorized');
416
			if(isset($authorized) && !empty($authorized)){
417
				$data = array();
418
				$paymentconfig = $this->config->item('paymenterror');
10634 lgm 419
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
10582 lgm 420
				$data['stylesheet'] = 'shipping.css';
421
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
422
				$this->layout->view('checkout/checkout_view',$data);
423
			}else{
424
				redirect(base_url());
425
			}
426
	}
427
	public function shipping()
428
	{
429
 
430
		$data = array();
431
		$authorized = $this->session->userdata('authorized');
432
		if($authorized['isLoggedIn'] != 1){
433
			$this->session->set_userdata('location','shipping');
434
			redirect(base_url()."login");
435
		}
436
		$shippingconfig = $this->config->item('shipping');
437
		if(!isset($_POST['submit']))
438
		{
439
			$authorized = $this->session->userdata('authorized');
440
				if(isset($authorized) && !empty($authorized)){
441
					$_GET['userId'] = $authorized['Id'];
442
					$_GET['Id'] = $authorized['cartId'];
443
					if($authorized['isLoggedIn'] == 1){
444
						$_GET['isLoggedIn'] = 'true';
445
					}
446
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
447
						$_GET['isLoggedIn'] = 'false';
448
					}
449
				}
450
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
451
			$data['stylesheet'] = 'shipping.css';
452
			$cache = getFileCache('pickup');
453
			if(isset($cache) && !empty($cache)){
454
				unset($shippingconfig['response'][1]);
455
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
456
				$data['response']['response']['pickup'] = $cache;
457
			}else{
458
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
459
        		if(isset($data['response']['response']['pickup']) && !empty($data['response']['response']['pickup']))
460
        		setFileCache($data['response']['response']['pickup'], 'pickup',900);
461
			}
10758 lgm 462
			$carts = $data['response']['response']['carts'][0];
10757 lgm 463
			$shipping = $data['response']['response']['shipping_process'][0]; 
464
			if((isset($carts) && !empty($carts)) && (isset($shipping) && !empty($shipping))){
10752 lgm 465
				$this->layout->view('checkout/checkout_view',$data);
466
			}else{
467
				redirect(base_url()."cart");
468
			}
10582 lgm 469
		}
470
		if(isset($_POST['submit']))
471
		{
472
			unset($shippingconfig['response'][1]);	
473
			$data = $this->get_shipping_billing($_POST);
474
			$this->session->set_userdata($data);
475
			$authorized = $this->session->userdata('authorized');
476
			if(isset($authorized) && !empty($authorized)){
477
				$_POST['userId'] = $authorized['Id'];
478
				//$_POST['Id'] = $authorized['cartId'];
479
					if($authorized['isLoggedIn'] == 1){
480
						$_POST['isLoggedIn'] = 'true';
481
					}
482
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
483
						$_POST['isLoggedIn'] = 'false';
484
					}
485
				}
486
			//$data['stylesheet'] = 'shipping.less';
487
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
488
			//$this->layout->view('checkout/checkout_view',$data);
489
			redirect(base_url()."shipping");
490
 
491
		}
492
 
493
	}
494
 
495
	public function get_shipping_billing($data=array()){
496
		$billing =array();
497
		$shipping =array();
498
		if (isset($data) && !empty($data)) {
499
			$shipping=array('name'  => $data['name'],'line1' => $data['line1'],'line2' => $data['line2'], 'city' => $data['city'], 'pin' => $data['pin'], 'phonenumber' => $data['phone']);
500
			return array('shipping'=>$shipping,'billing'=>$billing);
501
		}
502
	}
503
 
504
	public function delete($addressId){
505
		$shippingconfig = $this->config->item('shipping_delete');
506
		$_GET['addressId'] = $addressId;
507
		$authorized = $this->session->userdata('authorized');
508
		if(isset($authorized) && !empty($authorized)){
509
			$_GET['userId'] = $authorized['Id'];
510
			$_GET['Id'] = $authorized['cartId'];
511
			if($authorized['isLoggedIn'] == 1){
512
				$_GET['isLoggedIn'] = 'true';
513
			}
514
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
515
				$_GET['isLoggedIn'] = 'false';
516
				}
517
			}
518
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
519
			print_r($data['response']);
520
		}
521
 
522
	public function changeAddress($addressId,$type){
523
		if(isset($addressId) && isset($type)){
524
		$shippingconfig = $this->config->item('shipping_change');
525
		$_GET['addressId'] = $addressId;
526
		$_GET['addressType'] = $type;
527
		$authorized = $this->session->userdata('authorized');
528
		if(isset($authorized) && !empty($authorized)){
529
			$_GET['userId'] = $authorized['Id'];
530
			$_GET['Id'] = $authorized['cartId'];
531
			if($authorized['isLoggedIn'] == 1){
532
				$_GET['isLoggedIn'] = 'true';
533
			}
534
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
535
				$_GET['isLoggedIn'] = 'false';
536
				}
537
			}
538
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
539
			$this->session->set_userdata('addressId',$addressId);
10788 lgm 540
			echo json_encode($data['response']['response']['changeAddress'][0]);
10582 lgm 541
		}
542
	}
543
	public function changeCaptcha(){
544
		$captchaDisplay = $this->session->userdata('captchaDisplay');
545
		//if(isset($captchaDisplay) && $captchaDisplay == 1){
546
			$captcha = $this->captcha_model->generateCaptcha();
547
			$this->session->set_userdata('captcha',$captcha['word']);
548
			unset($captcha['word']);
549
			unset($captcha['time']);
550
			unset($captcha['name']);
551
			echo json_encode($captcha);
552
		//}
553
	}
554
	public function insuranceInfo($bday,$gname,$addressId){
555
	if((isset($bday) && !empty($bday)) && (isset($gname) && !empty($gname)) && (isset($addressId) && !empty($addressId))){
556
		if(isset($gname) && !empty($gname)){
10840 lgm 557
			$gname = str_replace('-',' ',$gname);
10582 lgm 558
			$gname = ltrim($gname);
559
			$gname = rtrim($gname);
560
			$_GET['guardianName'] = $gname;
561
		}
562
		if(isset($bday) && !empty($bday)){
563
			$dob = explode('-',$bday);
10840 lgm 564
			//$dob = array_reverse($dob);
10582 lgm 565
			$temp1 = $dob[1];
566
			$temp2 = $dob[0];
567
			$dob[0] = $temp1;
568
			$dob[1] = $temp2;
10840 lgm 569
 
10582 lgm 570
			$dob = implode('/', $dob);
571
			$_GET['dob'] = $dob; 
10840 lgm 572
		} 
10582 lgm 573
		$insuranceconfig = $this->config->item('insurance_info');
574
		$_GET['addressId'] = $addressId;
575
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$insuranceconfig);
576
		if(isset($data['response']['response']['insuranceInfo'][0]->response) && (!empty($data['response']['response']['insuranceInfo'][0]->response))) {
577
			echo json_encode($data['response']['response']['insuranceInfo'][0]);
578
		}
579
	}
580
  }
581
  public function pickupSpot($id){
582
  	if(isset($id) && !empty($id) && is_numeric($id)){
583
  		$this->session->set_userdata('hotspotId',$id);
584
  		$response['msg'] = 'sucess';
585
  		echo json_encode($response);
586
  	}
587
  }
588
 
589
}
590
 
10611 amit.gupta 591
 
10582 lgm 592
/* End of file welcome.php */
593
/* Location: ./application/controllers/welcome.php */