Subversion Repositories SmartDukaan

Rev

Rev 20255 | Rev 20622 | 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');
11108 lgm 12
		// if(!isset($admin) || empty($admin)) {
13
		// 	redirect(base_url().'authorize');
14
		// }
11421 lgm 15
		$this->output->set_header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
16
		$this->output->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
17
		$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
18
		$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
19
		$this->output->set_header("Pragma: no-cache");
10582 lgm 20
		$this->layout->setlayout('layout/layout_main');
21
		$this->load->model('checkout_model');
22
		$this->load->model('captcha_model');
23
		$this->layoutName= $this->layout->getLayout();
24
		$this->layoutName =substr($this->layoutName , 0, strrpos($this->layoutName , "/")).'/';
11301 lgm 25
		//print_r($this->session->userdata);
10582 lgm 26
 
27
 
28
	}
29
	public function index()
30
	{
31
		$authorized = $this->session->userdata('authorized');
32
		if(isset($authorized) and !empty($authorized['id']))
33
		{
34
			//if user logged-in
35
			redirect(base_url().strtolower(__CLASS__).'/shipping');
36
		}
37
 
38
		//standard array
39
	}
40
	public function __paginateList($data=array())
41
	{
42
			//$data['baseSubTotal']=$data['baseSubTotal'];
43
			$data['subTotal'] = $data['subTotal'];
44
			//$data['shippingCharges'] = $data['shippingCharges'];
45
			return $data;	
46
 
47
	}
48
 
49
	public function orderconfirmation()
50
	{
51
		$authorized = $this->session->userdata('authorized');
52
	    if(isset($authorized) && !empty($authorized)){
53
			$_GET['userId'] = $authorized['Id'];
54
			$_GET['Id'] = $authorized['cartId'];
55
			if($authorized['isLoggedIn'] == 1){
56
				$_GET['isLoggedIn'] = 'true';
57
			}
16276 amit.gupta 58
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
10582 lgm 59
				$_GET['isLoggedIn'] = 'false';
60
			}
10834 lgm 61
			$newValues = $authorized;
62
			$newValues['totalItems'] = 0;
16276 amit.gupta 63
			$this->session->userdata['authorized'] = $newValues;
10582 lgm 64
		}
65
    	//die();
66
    	$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
67
        $data['stylesheet'] = 'shipping.css';
68
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$this->config->item('orderconfirmation'));
69
		// $this->session->unset_userdata('shipping');
70
		// $this->session->unset_userdata('billing');
71
		// $this->session->unset_userdata('shoppingId');
16276 amit.gupta 72
		$this->session->unset_userdata(array('hotspotId','addressId'));
10582 lgm 73
		$this->layout->view('checkout/checkout_view',$data);
74
	}
20609 amit.gupta 75
	public function payment1()
76
	{
77
		$this->layout->setlayout('layout/layout_bigutsav');
78
		//standard array
79
		if (!empty($_GET['cq'])) {
80
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];
81
			$this->session->set_userdata('addressId',$_GET['addressid']);
82
		}
83
		$authorized = $this->session->userdata('authorized');
84
		if(!isset($authorized) || empty($authorized)){
85
			redirect(base_url()."cart");
86
		}
87
 
88
		$data = array();
89
		$codCaptcha = $this->session->userdata('cod');
90
		if(isset($codCaptcha) && $codCaptcha == 1){
91
			$data['codCaptcha'] = 1;
92
			$this->session->unset_userdata('cod');
93
		}else{
94
			$data['codCaptcha'] = 0;
95
		}
96
		$paymentconfig = $this->config->item('payment1');
97
		if(!isset($_POST['submit'])){
98
			$hotspot = $this->session->userdata('hotspotId');
99
			if(isset($hotspot) && !empty($hotspot)){
100
				$_GET['hotSpotAddressId'] = $hotspot;
101
				$_GET['deliveryLocation'] = 'hotSpot';
102
			}else{
103
				$_GET['deliveryLocation'] = 'myLocation';
104
			}
105
			unset($paymentconfig['response'][2]);
106
			if(isset($authorized) && !empty($authorized)){
107
				$_GET['userId'] = $authorized['Id'];
108
				$_GET['Id'] = $authorized['cartId'];
109
				if($authorized['isLoggedIn'] == 1){
110
					$_GET['isLoggedIn'] = 'true';
111
				}
112
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
113
					$_GET['isLoggedIn'] = 'false';
114
				}
115
				if(isset($authorized['isPrivateDealUser']) && $authorized['isPrivateDealUser'] == 1){
116
					$this->session->set_userdata('skipcaptcha',1);
117
					$data['skipcaptcha'] = 1;
118
				}
119
			}
120
			$addressId = $this->session->userdata('addressId');
121
			$_GET['addressid'] = $addressId;
122
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
123
      		$data['stylesheet'] = 'shipping.css';
124
      		$data['title'] = 'Saholic';
125
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),'',$paymentconfig);
126
			if(isset($data['response']['response']['payment_process1'])){
127
				$result = json_decode($data['response']['response']['payment_process1'][0]);
128
				$totalAmount = $result->results->totalAmount;
129
				if(isset($result->results->isTotalAmountZero)){
130
					$isTotalAmountZero = $result->results->isTotalAmountZero;
131
				}
132
				$totalAmount = number_format((float)$totalAmount,0,'.','');
133
				$captcha = $this->captcha_model->generateCaptcha();
134
				$this->session->set_userdata('captcha',$captcha['word']);
135
				$data['captcha'] = $captcha;
136
				// if($totalAmount == 0 && isset($isTotalAmountZero) && $isTotalAmountZero == 1){
137
				// 	$captcha = $this->captcha_model->generateCaptcha();
138
				// 	$this->session->set_userdata('captcha',$captcha['word']);
139
				// 	$this->session->set_userdata('captchaDisplay',$isTotalAmountZero);
140
				// 	$data['captcha'] = $captcha;
141
				// }
142
				$this->layout->view('checkout/checkout_view',$data);
143
			}
144
			else{
145
				redirect(base_url()."cart");
146
			}
147
		}
148
		elseif(isset($_POST['submit'])) {
149
			if(isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field'])){
150
				$captcha = $this->session->userdata('captcha');
151
				if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
152
					if(isset($_POST['payoption']) && ($_POST['payoption'] == 3000) || $_POST['payoption'] == 3001) {
153
						$this->session->set_userdata('cod',1);
154
					}
155
        			redirect(base_url().'payment');
156
      			}
157
			}
158
			unset($paymentconfig['response'][0]);
159
			unset($paymentconfig['response'][1]);
160
			if(isset($authorized) && !empty($authorized)){
161
				$_POST['userId'] = $authorized['Id'];
162
				if($authorized['isLoggedIn'] == 1){
163
					$_POST['isLoggedIn'] = 'true';
164
				}
165
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
166
					$_POST['isLoggedIn'] = 'false';
167
				}
168
			}
169
			$addressId = $this->session->userdata('addressId');
170
			$_POST['addressid'] = $addressId;
171
			$_POST['payment_option'] = $_POST['payoption'];
172
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
173
			error_log('[USER] ' .print_r($authorized,1),3,'/tmp/payments.log');
174
			error_log('[RESPONSE] '. print_r($data['response']['response'],1),3,'/tmp/payments.log');
175
			if(isset($data['response']['response']['payment_submit'][0]) && !empty($data['response']['response']['payment_submit'][0])) {
176
				$paymentSubmit = $data['response']['response']['payment_submit'][0];
177
				if(isset($paymentSubmit->response->isPaymentRedirect) && $paymentSubmit->response->isPaymentRedirect == 1){
178
					$image = '/assets/images/loading.gif';
179
					$location = $paymentSubmit->response->redirectUrl;
180
					echo '<html><head><meta http-equiv="refresh" content="1;url='.$paymentSubmit->response->redirectUrl.'">
181
  					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
182
  					<title>Saholic Mobile Site: Redirecting to <'.$paymentSubmit->response->gatewayName.'> Payment Gateway</title>
183
 					</head>
184
 						<body>
185
     					<div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
186
     					<div align="center" class="img">
187
      					<img title="loading" alt="loading" src="'.$image.'">
188
     					</div>
189
 						</body>
190
						</html>';
191
				}elseif(strpos($paymentSubmit->response->redirectUrl, 'ebs-pay') !== false) {
192
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
193
					//echo $url;
194
					$authorized = $this->session->userdata('authorized');
195
					if(isset($authorized) && !empty($authorized)){
196
						$params['userId'] = $authorized['Id'];
197
						if($authorized['isLoggedIn'] == 1){
198
							$params['isLoggedIn'] = 'true';
199
						}
200
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
201
							$params['isLoggedIn'] = 'false';
202
						}
203
					}
204
					$this->mcurl->add_call('ebs','get',$url,$params);
205
         			$response = $this->mcurl->execute($url);
206
         			$data['response'] = $response['ebs']['response'];
207
         			$response = $this->magento_model->payment_submit($data);
208
         			if(isset($response) && !empty($response)) {
209
         				$ebs = $response[0]->response;
210
         				$image = './assets/images/loading.gif';
211
         				echo '<html>
212
						<head>
213
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
214
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
215
						</head>
216
						<body>
217
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
218
						 <div align="center" class="img">
219
						  <img title="loading" alt="loading" src="'.$image.'">
220
						 </div>
221
						 <div style="display:none">
222
						  <form  method="post" action="'.$ebs->postAction.'" name="frmTransaction" id="frmTransaction">  
223
				           <!-- Account Id -->
224
				           <input name="account_id" type="hidden" value="'.$ebs->account_id.'" />
225
				           <!-- Transaction Details -->
226
				           <input name="reference_no" type="hidden" value="'.$ebs->reference_no.'" />
227
				           <input name="amount" type="hidden" value="'.$ebs->amount.'" />
228
				           <input name="description" type="hidden" value="'.$ebs->description.'" />
229
				           <input name="payment_option" type="hidden" value="'.$ebs->payment_option.'"/>
230
				           <!-- Billing Address -->
231
				           <input name="name" type="hidden" value="'.$ebs->name.'" />
232
				           <input name="address" type="hidden" value="'.$ebs->address.'" />
233
				           <input name="city" type="hidden" value="'.$ebs->city.'" />
234
				           <input name="state" type="hidden" value="'.$ebs->state.'" />
235
				           <input name="postal_code" type="hidden" value="'.$ebs->postal_code.'" />
236
				           <input name="country" type="hidden" value="'.$ebs->country.'"/>
237
				           <input name="email" type="hidden" value="'.$ebs->email.'" />
238
				           <input name="phone" type="hidden" value="'.$ebs->phone.'" />
239
				           <!-- Delivery Address -->
240
				           <input name="ship_name" type="hidden" value="'.$ebs->ship_name.'" />
241
				           <input name="ship_address" type="hidden" value="'.$ebs->ship_address.'" />
242
				           <input name="ship_city" type="hidden" value="'.$ebs->ship_city.'" />
243
				           <input name="ship_state" type="hidden" value="'.$ebs->ship_state.'" />
244
				           <input name="ship_postal_code" type="hidden" value="'.$ebs->ship_postal_code.'" />
245
				           <input name="ship_country" type="hidden" value="'.$ebs->ship_country.'"/> 
246
				           <input name="ship_phone" type="hidden" value="'.$ebs->ship_phone.'" />
247
				           <input name="return_url" type="hidden" value="'.$ebs->return_url.'" />
248
				           <input name="mode" value="'.$ebs->mode.'"/>
249
				           <input name="secure_hash" type="hidden" value="'.$ebs->secure_hash.'" />
250
				           <input name="channel" type="hidden" value="'.$ebs->channel.'" />
251
				           <input name="page_id" type="hidden" value="'.$ebs->page_id.'" />
252
						  </form>
253
						    </div>
254
						    <script type="text/javascript">
255
						     document.getElementById("frmTransaction").submit();
256
						    </script>
257
						  </body>
258
						</html>';
259
         			}
260
         			else{
261
         				redirect(base_url().'payment');
262
         			}
263
				}
264
				elseif(strpos($paymentSubmit->response->redirectUrl, 'payu-pay') !== false) {
265
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
266
					//echo $url;
267
					$params = array();
268
					$authorized = $this->session->userdata('authorized');
269
					if(isset($authorized) && !empty($authorized)){
270
						$params['userId'] = $authorized['Id'];
271
						if($authorized['isLoggedIn'] == 1){
272
							$params['isLoggedIn'] = 'true';
273
						}
274
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
275
							$params['isLoggedIn'] = 'false';
276
						}
277
					}
278
					$this->mcurl->add_call('payu','get',$url,$params);
279
         			$response = $this->mcurl->execute($url);
280
         			error_log("payu response".print_r($response,1));
281
         			$data['response'] = $response['payu']['response'];
282
         			$response = $this->magento_model->payment_submit($data);
283
         			if(isset($response) && !empty($response)){
284
         				$payu = $response[0]->response;
285
         				$image = '/assets/images/loading.gif';
286
         				// $return_url = base_url().'ebs-pay-processing/?DR={DR}';
287
         				$ci = get_instance();
288
         			}
289
         			?>
290
         				<html>
291
						<head>
292
						<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
293
						 <title>m.saholic.com: Redirecting to PayU Payment Gateway</title>
294
						</head>
295
						<body>
296
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
297
						 <div align="center" class="img">
298
						  <img title="loading" alt="loading" src="<?php echo $image;?>">
299
						 </div>
300
						 <div style="display:none;">
301
						   <form action="<?php echo $payu->postActionUrl; ?>" method="post" id="payuForm">
302
						      	<input type="hidden" name="key" value="<?php echo $payu->key; ?>" />
303
						      	<input type="hidden" name="hash" value="<?php echo $payu->hash ?>"/>
304
						      	<input type="hidden" name="txnid" value="<?php echo $payu->txnid ?>" />
305
						      	<input name="amount" value="<?php echo $payu->amount; ?>" />
306
								<input name="firstname" id="firstname" value="<?php echo $payu->firstname;?>" />
307
						        <input name="email" id="email" value="<?php echo $payu->email; ?>" />
308
						        <input name="phone" value="<?php echo $payu->phone; ?>" />
309
						        <input name="productinfo" value="<?php echo $payu->productinfo; ?>" />
310
						        <input name="surl" value="<?php echo rtrim(base_url(), "/").$payu->surl; ?>"  />
311
						        <input name="furl" value="<?php echo rtrim(base_url(), "/").$payu->furl; ?>" />
312
						        <input name="bankcode" value="<?php echo $payu->bankcode; ?>" />
313
						        <input name="pg" value="<?php echo $payu->pg; ?>" />
314
						        <input name="curl" value="<?php echo rtrim(base_url(), "/").$payu->curl; ?>" />
315
						        <input type="submit" value="Submit" />						          
316
						    </form>
317
					    </div>
318
					    <script type="text/javascript">
319
						    document.getElementById("payuForm").submit();
320
					    </script>
321
					  </body>
322
					</html>
323
					<?php
324
				}  
325
				else{
326
					redirect(base_url().$paymentSubmit->response->redirectUrl);
327
				}
328
			} else {
329
				redirect(base_url()."payment");	
330
			}
331
		}		
332
	}
10582 lgm 333
	public function payment()
334
	{
335
		//standard array
17868 amit.gupta 336
		if (!empty($_GET['cq'])) {
337
			$this->session->userdata['authorized']['totalItems'] = $_GET['cq'];
17985 amit.gupta 338
			$this->session->set_userdata('addressId',$_GET['addressid']);
17868 amit.gupta 339
		}
17884 amit.gupta 340
		$authorized = $this->session->userdata('authorized');
10582 lgm 341
		if(!isset($authorized) || empty($authorized)){
342
			redirect(base_url()."cart");
343
		}
344
 
345
		$data = array();
346
		$codCaptcha = $this->session->userdata('cod');
347
		if(isset($codCaptcha) && $codCaptcha == 1){
348
			$data['codCaptcha'] = 1;
349
			$this->session->unset_userdata('cod');
350
		}else{
351
			$data['codCaptcha'] = 0;
352
		}
353
		$paymentconfig = $this->config->item('payment');
354
		if(!isset($_POST['submit'])){
355
			$hotspot = $this->session->userdata('hotspotId');
356
			if(isset($hotspot) && !empty($hotspot)){
357
				$_GET['hotSpotAddressId'] = $hotspot;
358
				$_GET['deliveryLocation'] = 'hotSpot';
359
			}else{
360
				$_GET['deliveryLocation'] = 'myLocation';
361
			}
362
			unset($paymentconfig['response'][2]);
363
			if(isset($authorized) && !empty($authorized)){
364
				$_GET['userId'] = $authorized['Id'];
365
				$_GET['Id'] = $authorized['cartId'];
366
				if($authorized['isLoggedIn'] == 1){
367
					$_GET['isLoggedIn'] = 'true';
368
				}
369
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
370
					$_GET['isLoggedIn'] = 'false';
371
				}
14939 anikendra 372
				if(isset($authorized['isPrivateDealUser']) && $authorized['isPrivateDealUser'] == 1){
373
					$this->session->set_userdata('skipcaptcha',1);
374
					$data['skipcaptcha'] = 1;
375
				}
10582 lgm 376
			}
377
			$addressId = $this->session->userdata('addressId');
378
			$_GET['addressid'] = $addressId;
379
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
380
      		$data['stylesheet'] = 'shipping.css';
11012 lgm 381
      		$data['title'] = 'Saholic';
10582 lgm 382
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),'',$paymentconfig);
383
			if(isset($data['response']['response']['payment_process'])){
384
				$result = json_decode($data['response']['response']['payment_process'][0]);
385
				$totalAmount = $result->results->totalAmount;
386
				if(isset($result->results->isTotalAmountZero)){
387
					$isTotalAmountZero = $result->results->isTotalAmountZero;
388
				}
389
				$totalAmount = number_format((float)$totalAmount,0,'.','');
390
				$captcha = $this->captcha_model->generateCaptcha();
391
				$this->session->set_userdata('captcha',$captcha['word']);
392
				$data['captcha'] = $captcha;
393
				// if($totalAmount == 0 && isset($isTotalAmountZero) && $isTotalAmountZero == 1){
394
				// 	$captcha = $this->captcha_model->generateCaptcha();
395
				// 	$this->session->set_userdata('captcha',$captcha['word']);
396
				// 	$this->session->set_userdata('captchaDisplay',$isTotalAmountZero);
397
				// 	$data['captcha'] = $captcha;
398
				// }
399
				$this->layout->view('checkout/checkout_view',$data);
400
			}
401
			else{
402
				redirect(base_url()."cart");
403
			}
404
		}
15792 anikendra 405
		elseif(isset($_POST['submit'])) {
10582 lgm 406
			if(isset($_POST['captcha_response_field']) && !empty($_POST['captcha_response_field'])){
407
				$captcha = $this->session->userdata('captcha');
408
				if(strcmp($captcha,$_POST['captcha_response_field']) != 0){
10630 lgm 409
					if(isset($_POST['payoption']) && ($_POST['payoption'] == 3000) || $_POST['payoption'] == 3001) {
10582 lgm 410
						$this->session->set_userdata('cod',1);
411
					}
412
        			redirect(base_url().'payment');
413
      			}
414
			}
415
			unset($paymentconfig['response'][0]);
416
			unset($paymentconfig['response'][1]);
417
			if(isset($authorized) && !empty($authorized)){
418
				$_POST['userId'] = $authorized['Id'];
419
				if($authorized['isLoggedIn'] == 1){
420
					$_POST['isLoggedIn'] = 'true';
421
				}
422
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
423
					$_POST['isLoggedIn'] = 'false';
424
				}
425
			}
426
			$addressId = $this->session->userdata('addressId');
427
			$_POST['addressid'] = $addressId;
428
			$_POST['payment_option'] = $_POST['payoption'];
429
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
15792 anikendra 430
			error_log('[USER] ' .print_r($authorized,1),3,'/tmp/payments.log');
431
			error_log('[RESPONSE] '. print_r($data['response']['response'],1),3,'/tmp/payments.log');
432
			if(isset($data['response']['response']['payment_submit'][0]) && !empty($data['response']['response']['payment_submit'][0])) {
10582 lgm 433
				$paymentSubmit = $data['response']['response']['payment_submit'][0];
434
				if(isset($paymentSubmit->response->isPaymentRedirect) && $paymentSubmit->response->isPaymentRedirect == 1){
16276 amit.gupta 435
					$image = '/assets/images/loading.gif';
10582 lgm 436
					$location = $paymentSubmit->response->redirectUrl;
10735 lgm 437
					echo '<html><head><meta http-equiv="refresh" content="1;url='.$paymentSubmit->response->redirectUrl.'">
11301 lgm 438
  					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 439
  					<title>Saholic Mobile Site: Redirecting to <'.$paymentSubmit->response->gatewayName.'> Payment Gateway</title>
440
 					</head>
441
 						<body>
442
     					<div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
443
     					<div align="center" class="img">
444
      					<img title="loading" alt="loading" src="'.$image.'">
445
     					</div>
446
 						</body>
447
						</html>';
13350 anikendra 448
				}elseif(strpos($paymentSubmit->response->redirectUrl, 'ebs-pay') !== false) {
10582 lgm 449
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
450
					//echo $url;
451
					$authorized = $this->session->userdata('authorized');
452
					if(isset($authorized) && !empty($authorized)){
453
						$params['userId'] = $authorized['Id'];
454
						if($authorized['isLoggedIn'] == 1){
455
							$params['isLoggedIn'] = 'true';
456
						}
457
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
458
							$params['isLoggedIn'] = 'false';
459
						}
460
					}
461
					$this->mcurl->add_call('ebs','get',$url,$params);
462
         			$response = $this->mcurl->execute($url);
463
         			$data['response'] = $response['ebs']['response'];
464
         			$response = $this->magento_model->payment_submit($data);
13350 anikendra 465
         			if(isset($response) && !empty($response)) {
10582 lgm 466
         				$ebs = $response[0]->response;
11339 lgm 467
         				$image = './assets/images/loading.gif';
10582 lgm 468
         				echo '<html>
469
						<head>
11301 lgm 470
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 471
						 <title>m.saholic.com: Redirecting to EBS Payment Page</title>
472
						</head>
473
						<body>
474
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
475
						 <div align="center" class="img">
10735 lgm 476
						  <img title="loading" alt="loading" src="'.$image.'">
10582 lgm 477
						 </div>
478
						 <div style="display:none">
479
						  <form  method="post" action="'.$ebs->postAction.'" name="frmTransaction" id="frmTransaction">  
480
				           <!-- Account Id -->
481
				           <input name="account_id" type="hidden" value="'.$ebs->account_id.'" />
482
				           <!-- Transaction Details -->
483
				           <input name="reference_no" type="hidden" value="'.$ebs->reference_no.'" />
484
				           <input name="amount" type="hidden" value="'.$ebs->amount.'" />
485
				           <input name="description" type="hidden" value="'.$ebs->description.'" />
486
				           <input name="payment_option" type="hidden" value="'.$ebs->payment_option.'"/>
487
				           <!-- Billing Address -->
488
				           <input name="name" type="hidden" value="'.$ebs->name.'" />
489
				           <input name="address" type="hidden" value="'.$ebs->address.'" />
490
				           <input name="city" type="hidden" value="'.$ebs->city.'" />
491
				           <input name="state" type="hidden" value="'.$ebs->state.'" />
492
				           <input name="postal_code" type="hidden" value="'.$ebs->postal_code.'" />
11413 amit.gupta 493
				           <input name="country" type="hidden" value="'.$ebs->country.'"/>
10582 lgm 494
				           <input name="email" type="hidden" value="'.$ebs->email.'" />
495
				           <input name="phone" type="hidden" value="'.$ebs->phone.'" />
496
				           <!-- Delivery Address -->
497
				           <input name="ship_name" type="hidden" value="'.$ebs->ship_name.'" />
498
				           <input name="ship_address" type="hidden" value="'.$ebs->ship_address.'" />
499
				           <input name="ship_city" type="hidden" value="'.$ebs->ship_city.'" />
500
				           <input name="ship_state" type="hidden" value="'.$ebs->ship_state.'" />
501
				           <input name="ship_postal_code" type="hidden" value="'.$ebs->ship_postal_code.'" />
11413 amit.gupta 502
				           <input name="ship_country" type="hidden" value="'.$ebs->ship_country.'"/> 
10582 lgm 503
				           <input name="ship_phone" type="hidden" value="'.$ebs->ship_phone.'" />
504
				           <input name="return_url" type="hidden" value="'.$ebs->return_url.'" />
505
				           <input name="mode" value="'.$ebs->mode.'"/>
506
				           <input name="secure_hash" type="hidden" value="'.$ebs->secure_hash.'" />
507
				           <input name="channel" type="hidden" value="'.$ebs->channel.'" />
508
				           <input name="page_id" type="hidden" value="'.$ebs->page_id.'" />
509
						  </form>
510
						    </div>
511
						    <script type="text/javascript">
512
						     document.getElementById("frmTransaction").submit();
513
						    </script>
514
						  </body>
515
						</html>';
13350 anikendra 516
         			}
517
         			else{
10582 lgm 518
         				redirect(base_url().'payment');
519
         			}
520
				}
13350 anikendra 521
				elseif(strpos($paymentSubmit->response->redirectUrl, 'payu-pay') !== false) {
522
					$url = $this->config->item('curl_base_url').$paymentSubmit->response->redirectUrl;
523
					//echo $url;
524
					$params = array();
525
					$authorized = $this->session->userdata('authorized');
526
					if(isset($authorized) && !empty($authorized)){
527
						$params['userId'] = $authorized['Id'];
528
						if($authorized['isLoggedIn'] == 1){
529
							$params['isLoggedIn'] = 'true';
530
						}
531
						elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
532
							$params['isLoggedIn'] = 'false';
533
						}
534
					}
535
					$this->mcurl->add_call('payu','get',$url,$params);
536
         			$response = $this->mcurl->execute($url);
537
         			error_log("payu response".print_r($response,1));
538
         			$data['response'] = $response['payu']['response'];
539
         			$response = $this->magento_model->payment_submit($data);
540
         			if(isset($response) && !empty($response)){
541
         				$payu = $response[0]->response;
16276 amit.gupta 542
         				$image = '/assets/images/loading.gif';
13350 anikendra 543
         				// $return_url = base_url().'ebs-pay-processing/?DR={DR}';
544
         				$ci = get_instance();
545
         			}
546
         			?>
547
         				<html>
548
						<head>
549
						<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
19411 amit.gupta 550
						 <title>m.saholic.com: Redirecting to PayU Payment Gateway</title>
13350 anikendra 551
						</head>
552
						<body>
553
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
554
						 <div align="center" class="img">
16276 amit.gupta 555
						  <img title="loading" alt="loading" src="<?php echo $image;?>">
13350 anikendra 556
						 </div>
557
						 <div style="display:none;">
558
						   <form action="<?php echo $payu->postActionUrl; ?>" method="post" id="payuForm">
559
						      	<input type="hidden" name="key" value="<?php echo $payu->key; ?>" />
560
						      	<input type="hidden" name="hash" value="<?php echo $payu->hash ?>"/>
561
						      	<input type="hidden" name="txnid" value="<?php echo $payu->txnid ?>" />
562
						      	<input name="amount" value="<?php echo $payu->amount; ?>" />
563
								<input name="firstname" id="firstname" value="<?php echo $payu->firstname;?>" />
564
						        <input name="email" id="email" value="<?php echo $payu->email; ?>" />
565
						        <input name="phone" value="<?php echo $payu->phone; ?>" />
566
						        <input name="productinfo" value="<?php echo $payu->productinfo; ?>" />
19411 amit.gupta 567
						        <input name="surl" value="<?php echo rtrim(base_url(), "/").$payu->surl; ?>"  />
568
						        <input name="furl" value="<?php echo rtrim(base_url(), "/").$payu->furl; ?>" />
13350 anikendra 569
						        <input name="bankcode" value="<?php echo $payu->bankcode; ?>" />
570
						        <input name="pg" value="<?php echo $payu->pg; ?>" />
19418 amit.gupta 571
						        <input name="curl" value="<?php echo rtrim(base_url(), "/").$payu->curl; ?>" />
13350 anikendra 572
						        <input type="submit" value="Submit" />						          
573
						    </form>
574
					    </div>
575
					    <script type="text/javascript">
576
						    document.getElementById("payuForm").submit();
577
					    </script>
578
					  </body>
579
					</html>
580
					<?php
581
				}  
10582 lgm 582
				else{
583
					redirect(base_url().$paymentSubmit->response->redirectUrl);
584
				}
15792 anikendra 585
			} else {
586
				redirect(base_url()."payment");	
10582 lgm 587
			}
15792 anikendra 588
		}		
10582 lgm 589
	}
13350 anikendra 590
 
10582 lgm 591
	public function ebsprocessing(){
592
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
593
			$paymentconfig = $this->config->item('ebsProcessing');
594
			$authorized = $this->session->userdata('authorized');
595
			if(isset($authorized) && !empty($authorized)){
596
				$_GET['userId'] = $authorized['Id'];
597
				if($authorized['isLoggedIn'] == 1){
598
					$_GET['isLoggedIn'] = 'true';
599
				}
600
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
601
					$_GET['isLoggedIn'] = 'false';
602
				}
603
			}
604
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
605
			if(isset($data['response']['response']['ebs_processing'][0]->response)){
606
				$redirectUrl = $data['response']['response']['ebs_processing'][0]->response->redirectUrl;
607
				$redirectUrl = explode('?', $redirectUrl);
608
				$redirectUrl = base_url().'ebs-pay-response/?'.$redirectUrl[1];
16276 amit.gupta 609
				$image = '/assets/images/loading.gif';
10582 lgm 610
				echo '<html><head><meta http-equiv="refresh" content="2;url='.$redirectUrl.'">
11301 lgm 611
					<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
10582 lgm 612
  					<title>Saholic Mobile Site:</title>
613
 					</head>
614
 						<body>
615
     					<div style="text-align:center; margin-top:200px;">'.$data['response']['response']['ebs_processing'][0]->response->redirectMessage.'</div>
616
     					<div align="center" class="img">
10735 lgm 617
      					<img title="loading" alt="loading" src="'.$image.'">
10582 lgm 618
     					</div>
619
 						</body>
620
						</html>';
621
			}
622
		}
623
	}
624
	public function ebsresponse(){
625
		if(isset($_GET['DR']) && !empty($_GET['DR'])){
626
			$paymentconfig = $this->config->item('ebsResponse');
627
			$authorized = $this->session->userdata('authorized');
628
			if(isset($authorized) && !empty($authorized)){
629
				$_GET['userId'] = $authorized['Id'];
630
				if($authorized['isLoggedIn'] == 1){
631
					$_GET['isLoggedIn'] = 'true';
632
				}
633
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
634
					$_GET['isLoggedIn'] = 'false';
635
				}
636
			}
637
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
638
			if(isset($data['response']['response']['ebs_response'][0]->response) && !empty($data['response']['response']['ebs_response'][0]->response)){
639
				$redirectUrl = $data['response']['response']['ebs_response'][0]->response->redirectUrl;
20255 amit.gupta 640
				redirect($redirectUrl);
10582 lgm 641
			}
642
			else{
643
				redirect(base_url().'payment');
644
			}
645
		}
646
	}
13304 anikendra 647
 
648
	public function payuresponse(){
649
		error_log("payu response ".print_r($_REQUEST,1));
650
		$paymentconfig = $this->config->item('payuResponse');
651
		$authorized = $this->session->userdata('authorized');
652
		if(isset($authorized) && !empty($authorized)){
653
			$_GET['userId'] = $authorized['Id'];
654
			if($authorized['isLoggedIn'] == 1){
655
				$_GET['isLoggedIn'] = 'true';
656
			}
657
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
658
				$_GET['isLoggedIn'] = 'false';
659
			}
660
		}
661
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
662
		error_log("payu response ".print_r($data['response'],1));
663
		if(isset($data['response']['response']['payu_response'][0]->response) && !empty($data['response']['response']['payu_response'][0]->response)){
664
			$redirectUrl = $data['response']['response']['payu_response'][0]->response->redirectUrl;
20061 amit.gupta 665
			redirect(rtrim(base_url(), "/").$redirectUrl);
13304 anikendra 666
		}
667
		else{
19417 amit.gupta 668
			redirect(rtrim(base_url(), "/").'payment');
13304 anikendra 669
		}
670
	}
671
 
10582 lgm 672
	public function hdfcPayResponse(){
673
		if(isset($_POST)){
674
			$paymentconfig = $this->config->item('hdfcResponse');
675
			$authorized = $this->session->userdata('authorized');
676
			if(isset($authorized) && !empty($authorized)){
677
				$_POST['userId'] = $authorized['Id'];
678
				if($authorized['isLoggedIn'] == 1){
679
					$_POST['isLoggedIn'] = 'true';
680
				}
681
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
682
					$_POST['isLoggedIn'] = 'false';
683
				}
684
			}
685
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
686
			if(isset($data['response']['response']['hdfc_response'][0]->response) && !empty($data['response']['response']['hdfc_response'][0]->response)){
687
				$redirectUrl = $data['response']['response']['hdfc_response'][0]->response->redirectUrl;
688
				redirect($redirectUrl);
689
			}
690
			else{
691
				redirect(base_url());
692
			}	
693
		}else{
694
			redirect(base_url());
695
		}
696
	}
10890 lgm 697
	public function hdfcEmiResponse(){
698
		if(isset($_POST)){
699
			$paymentconfig = $this->config->item('hdfcEmiResponse');
700
			$authorized = $this->session->userdata('authorized');
701
			if(isset($authorized) && !empty($authorized)){
702
				$_POST['userId'] = $authorized['Id'];
703
				if($authorized['isLoggedIn'] == 1){
704
					$_POST['isLoggedIn'] = 'true';
705
				}
706
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
707
					$_POST['isLoggedIn'] = 'false';
708
				}
709
			}
710
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
711
			if(isset($data['response']['response']['hdfc_emi_response'][0]->response) && !empty($data['response']['response']['hdfc_emi_response'][0]->response)){
712
				$redirectUrl = $data['response']['response']['hdfc_emi_response'][0]->response->redirectUrl;
713
				redirect($redirectUrl);
714
			}
715
			else{
716
				redirect(base_url());
717
			}	
718
		}else{
719
			redirect(base_url());
720
		}
721
	}
10582 lgm 722
	public function innovitiPayment(){
723
		$last = $this->uri->total_segments();
724
		$itemcode = $this->uri->segment($last);
725
		if(isset($itemcode) && !empty($itemcode)){
726
			$url = $this->config->item('curl_base_url').'innoviti-pay/'.$itemcode;
727
			$params = array();
728
			$authorized = $this->session->userdata('authorized');
729
			if(isset($authorized) && !empty($authorized)){
730
				$params['userId'] = $authorized['Id'];
731
				if($authorized['isLoggedIn'] == 1){
732
					$params['isLoggedIn'] = 'true';
733
				}
734
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
735
					$params['isLoggedIn'] = 'false';
736
				}
737
			$this->mcurl->add_call('innoviti','get',$url,$params);
738
 			$response = $this->mcurl->execute($url);
739
 			$data['response'] = $response['innoviti']['response'];
740
         	$response = $this->magento_model->payment_submit($data);
741
         	if(isset($response) && !empty($response)){
742
         		$innoviti = $response[0]->response;
11339 lgm 743
         		$image = './assets/images/loading.gif';
11301 lgm 744
         		echo '<html>
745
						<head>
746
						 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
747
						 <title>m.saholic.com: Redirecting to Innoviti Payment Page</title>
748
						</head>
749
						<body>
750
						    <div style="text-align:center; margin-top:200px;">Please wait while we redirect you to the Payment Gateway.</div>
751
						 <div align="center" class="img">
752
						  <img title="loading" alt="loading" src="'.$image.'">
753
						 </div>
754
						 <div style="display:none">
755
						  <form  method="post" action="'.$innoviti->action.'" name="frmTransaction" id="frmTransaction">  
756
								<input name="merchantId" type="hidden" value="'.$innoviti->merchantId.'" />
757
								<input name="subMerchantId" type="hidden" value="'.$innoviti->subMerchantId.'" />
758
										<!-- Transaction Details -->
759
								<input name="orderId" type="hidden" value="'.$innoviti->orderId.'" />
760
								<input name="amt" type="hidden" value="'.$innoviti->amt.'" />   
761
								<input name="cur" type="hidden" value="INR" />
762
								<input name="processingCode" type="hidden" value="'.$innoviti->processingCode.'" />
763
								<input name="proSku" type="hidden" value="'.$innoviti->proSku.'" />
764
								<input name="Cname" type="hidden" value="'.$innoviti->Cname.'" /></td>
765
								<input name="mobile" type="hidden" value="'.$innoviti->mobile.'" />
766
								<input name="emailId" type="hidden" value="'.$innoviti->emailId.'" />     
767
								<input name="redirUrl" type="hidden" value="'.$innoviti->redirUrl.'" />
768
								<input name="chksum" type="hidden" value="'.$innoviti->chksum.'" />
769
								<input name="isCtx" type="hidden" value="NO" />
770
							<input name="submitted" value="Submit" type="submit" />&nbsp; 
771
							  </form>
772
						    </div><script type="text/javascript">
10582 lgm 773
						    document.getElementById("frmTransaction").submit();
11301 lgm 774
						</script></body></html>';
10582 lgm 775
         	}
776
			}else{
777
				redirect(base_url());
778
			}
779
 
780
		}else{
781
			redirect(base_url());
782
		}
783
	}
784
	public function innovitiResponse(){
785
		if(isset($_POST)){
786
			$paymentconfig = $this->config->item('innovitiResponse');
787
			$authorized = $this->session->userdata('authorized');
788
			if(isset($authorized) && !empty($authorized)){
789
				$_POST['userId'] = $authorized['Id'];
790
				if($authorized['isLoggedIn'] == 1){
791
					$_POST['isLoggedIn'] = 'true';
792
				}
793
				elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
794
					$_POST['isLoggedIn'] = 'false';
795
				}
796
			}
797
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
798
			if(isset($data['response']['response']['innoviti_response'][0]->response) && !empty($data['response']['response']['innoviti_response'][0]->response)){
799
				$redirectUrl = $data['response']['response']['innoviti_response'][0]->response->redirectUrl;
800
				redirect($redirectUrl);
801
			}
802
			else{
803
				redirect(base_url());
804
			}	
805
		}else{
806
			redirect(base_url());
807
		}
808
	}
809
	public function paymenterror(){
810
			$authorized = $this->session->userdata('authorized');
811
			if(isset($authorized) && !empty($authorized)){
812
				$data = array();
813
				$paymentconfig = $this->config->item('paymenterror');
10634 lgm 814
				$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
10582 lgm 815
				$data['stylesheet'] = 'shipping.css';
816
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$paymentconfig);
817
				$this->layout->view('checkout/checkout_view',$data);
818
			}else{
819
				redirect(base_url());
820
			}
821
	}
822
	public function shipping()
823
	{
824
 
825
		$data = array();
826
		$authorized = $this->session->userdata('authorized');
827
		if($authorized['isLoggedIn'] != 1){
828
			$this->session->set_userdata('location','shipping');
829
			redirect(base_url()."login");
830
		}
831
		$shippingconfig = $this->config->item('shipping');
832
		if(!isset($_POST['submit']))
833
		{
834
			$authorized = $this->session->userdata('authorized');
835
				if(isset($authorized) && !empty($authorized)){
836
					$_GET['userId'] = $authorized['Id'];
837
					$_GET['Id'] = $authorized['cartId'];
838
					if($authorized['isLoggedIn'] == 1){
839
						$_GET['isLoggedIn'] = 'true';
840
					}
841
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
842
						$_GET['isLoggedIn'] = 'false';
843
					}
844
				}
845
			$this->lessphp->object()->ccompile('assets/css/shipping.less','assets/css/shipping.css');
846
			$data['stylesheet'] = 'shipping.css';
11012 lgm 847
			$data['title'] = 'Saholic';
10582 lgm 848
			$cache = getFileCache('pickup');
849
			if(isset($cache) && !empty($cache)){
850
				unset($shippingconfig['response'][1]);
851
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
852
				$data['response']['response']['pickup'] = $cache;
853
			}else{
854
				$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
855
        		if(isset($data['response']['response']['pickup']) && !empty($data['response']['response']['pickup']))
856
        		setFileCache($data['response']['response']['pickup'], 'pickup',900);
857
			}
10758 lgm 858
			$carts = $data['response']['response']['carts'][0];
10757 lgm 859
			$shipping = $data['response']['response']['shipping_process'][0]; 
860
			if((isset($carts) && !empty($carts)) && (isset($shipping) && !empty($shipping))){
10752 lgm 861
				$this->layout->view('checkout/checkout_view',$data);
862
			}else{
863
				redirect(base_url()."cart");
864
			}
10582 lgm 865
		}
866
		if(isset($_POST['submit']))
867
		{
868
			unset($shippingconfig['response'][1]);	
869
			$data = $this->get_shipping_billing($_POST);
870
			$this->session->set_userdata($data);
871
			$authorized = $this->session->userdata('authorized');
872
			if(isset($authorized) && !empty($authorized)){
873
				$_POST['userId'] = $authorized['Id'];
11530 lgm 874
				$_POST['Id'] = $authorized['cartId'];
10582 lgm 875
					if($authorized['isLoggedIn'] == 1){
876
						$_POST['isLoggedIn'] = 'true';
877
					}
878
					elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
879
						$_POST['isLoggedIn'] = 'false';
880
					}
881
				}
882
			//$data['stylesheet'] = 'shipping.less';
883
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
884
			//$this->layout->view('checkout/checkout_view',$data);
885
			redirect(base_url()."shipping");
886
 
887
		}
888
 
889
	}
890
 
891
	public function get_shipping_billing($data=array()){
892
		$billing =array();
893
		$shipping =array();
894
		if (isset($data) && !empty($data)) {
895
			$shipping=array('name'  => $data['name'],'line1' => $data['line1'],'line2' => $data['line2'], 'city' => $data['city'], 'pin' => $data['pin'], 'phonenumber' => $data['phone']);
896
			return array('shipping'=>$shipping,'billing'=>$billing);
897
		}
898
	}
899
 
900
	public function delete($addressId){
901
		$shippingconfig = $this->config->item('shipping_delete');
902
		$_GET['addressId'] = $addressId;
903
		$authorized = $this->session->userdata('authorized');
904
		if(isset($authorized) && !empty($authorized)){
905
			$_GET['userId'] = $authorized['Id'];
906
			$_GET['Id'] = $authorized['cartId'];
907
			if($authorized['isLoggedIn'] == 1){
908
				$_GET['isLoggedIn'] = 'true';
909
			}
910
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
911
				$_GET['isLoggedIn'] = 'false';
912
				}
913
			}
914
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
915
			print_r($data['response']);
916
		}
917
 
918
	public function changeAddress($addressId,$type){
919
		if(isset($addressId) && isset($type)){
920
		$shippingconfig = $this->config->item('shipping_change');
921
		$_GET['addressId'] = $addressId;
922
		$_GET['addressType'] = $type;
923
		$authorized = $this->session->userdata('authorized');
924
		if(isset($authorized) && !empty($authorized)){
925
			$_GET['userId'] = $authorized['Id'];
926
			$_GET['Id'] = $authorized['cartId'];
927
			if($authorized['isLoggedIn'] == 1){
928
				$_GET['isLoggedIn'] = 'true';
929
			}
930
			elseif(isset($authorized['isLoggedIn']) && empty($authorized['isLoggedIn'])) {
931
				$_GET['isLoggedIn'] = 'false';
932
				}
933
			}
934
			$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$shippingconfig);
935
			$this->session->set_userdata('addressId',$addressId);
10788 lgm 936
			echo json_encode($data['response']['response']['changeAddress'][0]);
10582 lgm 937
		}
938
	}
939
	public function changeCaptcha(){
940
		$captchaDisplay = $this->session->userdata('captchaDisplay');
941
		//if(isset($captchaDisplay) && $captchaDisplay == 1){
942
			$captcha = $this->captcha_model->generateCaptcha();
943
			$this->session->set_userdata('captcha',$captcha['word']);
944
			unset($captcha['word']);
945
			unset($captcha['time']);
946
			unset($captcha['name']);
947
			echo json_encode($captcha);
948
		//}
949
	}
950
	public function insuranceInfo($bday,$gname,$addressId){
951
	if((isset($bday) && !empty($bday)) && (isset($gname) && !empty($gname)) && (isset($addressId) && !empty($addressId))){
952
		if(isset($gname) && !empty($gname)){
10840 lgm 953
			$gname = str_replace('-',' ',$gname);
10582 lgm 954
			$gname = ltrim($gname);
955
			$gname = rtrim($gname);
956
			$_GET['guardianName'] = $gname;
957
		}
958
		if(isset($bday) && !empty($bday)){
959
			$dob = explode('-',$bday);
10840 lgm 960
			//$dob = array_reverse($dob);
10582 lgm 961
			$temp1 = $dob[1];
962
			$temp2 = $dob[0];
963
			$dob[0] = $temp1;
964
			$dob[1] = $temp2;
10840 lgm 965
 
10582 lgm 966
			$dob = implode('/', $dob);
967
			$_GET['dob'] = $dob; 
10840 lgm 968
		} 
10582 lgm 969
		$insuranceconfig = $this->config->item('insurance_info');
970
		$_GET['addressId'] = $addressId;
971
		$data['response']=$this->checkout_model->getCheckoutDetails($this->input->get(),$this->input->post(),$insuranceconfig);
972
		if(isset($data['response']['response']['insuranceInfo'][0]->response) && (!empty($data['response']['response']['insuranceInfo'][0]->response))) {
973
			echo json_encode($data['response']['response']['insuranceInfo'][0]);
974
		}
975
	}
976
  }
977
  public function pickupSpot($id){
978
  	if(isset($id) && !empty($id) && is_numeric($id)){
979
  		$this->session->set_userdata('hotspotId',$id);
980
  		$response['msg'] = 'sucess';
981
  		echo json_encode($response);
982
  	}
983
  }
984
 
985
}
986
 
10611 amit.gupta 987
 
10582 lgm 988
/* End of file welcome.php */
13350 anikendra 989
/* Location: ./application/controllers/welcome.php */