Subversion Repositories SmartDukaan

Rev

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