Subversion Repositories SmartDukaan

Rev

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