%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Checkout extends MY_Controller { private $orderId; public function __construct() { parent::__construct(); $this->load->library('session'); if(empty($_SESSION['logged_user']['id'])) { redirect(LANG_URL . '/home'); } $this->load->model('admin/Orders_model'); } public function index() { $data = array(); $head = array(); $arrSeo = $this->Public_model->getSeo('checkout'); $head['title'] = @$arrSeo['title']; $head['description'] = @$arrSeo['description']; $head['keywords'] = str_replace(" ", ",", $head['title']); // Get Cart Data $user_id = $_SESSION['logged_user']['id']; // Get All Members Details $data['family_members'] = $family_members = $this->Public_model->getAllFamilyMembers($user_id); // Get All Cart Items of user id $data['cart_items'] = $cart_items = $this->Public_model->getMyCartItems($user_id); $data['total_members'] = count($data['cart_items']); $total_packages = 0; $our_price = 0; $offer_price = 0; foreach($family_members as $fvalue){ foreach($cart_items[$fvalue['member_id']] as $value){ $total_packages = $total_packages+1; $our_price = $our_price+$value['old_price']; $offer_price = $offer_price+$value['price']; } } // Calculate discount in percentage $discount = round((($our_price-$offer_price)/$our_price)*100); // Set total packages Count $data['products'] = "Health Checkup Plan of ".$_SESSION['logged_user']['full_name']; $data['total_packages'] = $total_packages; $data['our_price'] = $our_price; $data['offer_price'] = $offer_price; $data['discount'] = $discount; $data['user_details'] = $_SESSION['logged_user']; // Get Address Details $data['booking_details'] = $this->Public_model->getBookkingAddress('user_booking','user_id', $_SESSION['logged_user']['id']); $this->render('checkout', $head, $data); } /* Apply cupon code */ public function applyCuponCode(){ if($_POST){ $_POST['user_id'] = $_SESSION['logged_user']['id']; $coupon_amount = $this->Public_model->applyCuponCode($_POST); $my_total_prise = $_POST['my_total_prise']; $needHardCopy = $_POST['needHardCopy']; $hardCopy = $_POST['hardCopy']; $final_amount = 0; if($hardCopy==1 && $coupon_amount>0) { $final_amount = (($my_total_prise+$needHardCopy)-($coupon_amount)); } else if($coupon_amount>0) { $final_amount = ($my_total_prise-$coupon_amount); } echo $final_amount; exit(); } } /* Place Order */ public function placeNewOrder(){ // Get Cart Data if($_POST){ $user_id = $_SESSION['logged_user']['id']; // Get All Members Details $data['family_members'] = $family_members = $this->Public_model->getAllFamilyMembers($user_id); // Get All Cart Items of user id $data['cart_items'] = $cart_items = $this->Public_model->getMyCartItems($user_id); $data['total_members'] = count($data['cart_items']); $total_packages = 0; $our_price = 0; $offer_price = 0; foreach($family_members as $fvalue){ foreach($cart_items[$fvalue['member_id']] as $value){ $total_packages = $total_packages+1; $our_price = $our_price+$value['old_price']; $offer_price = $offer_price+$value['price']; } } // Calculate discount in percentage $discount = 0; if($our_price>0 && $offer_price>0){ $discount = round((($our_price-$offer_price)/$our_price)*100); } // Set total packages Count $data['products'] = serialize($cart_items); $data['total_packages'] = $total_packages; $data['our_price'] = $our_price; $data['offer_price'] = $offer_price; // If hardcopy required $data['heard_copy_required'] = '0'; if($_POST['hardCopy']=='1') { //$data['offer_price'] = ($offer_price+heard_copy_amount); $data['heard_copy_required'] = $_POST['hardCopy']; } $data['discount'] = $discount; $data['user_details'] = $_SESSION['logged_user']; $data['post'] = $_POST; // Get Address Details $data['booking_details'] = $this->Public_model->getBookkingAddress('user_booking','user_id', $_SESSION['logged_user']['id']); $data['city'] = 'Noida'; $data['post_code'] = '201001'; $data['notes'] = 'NA'; $data['clean_referrer'] = 'NA'; $data['booking_slot'] = $_SESSION['slot_booking']; $data['order_otp'] = $this->Public_model->getOTP(); if(!empty($data)) { $response = $this->Public_model->setOrder($data); if($response>0){ $this->goToDestination($data, $response); } } } else { $this->session->set_flashdata('error', true); } } private function setVendorOrders() { $this->Public_model->setVendorOrder($_POST); } private function setActivationLink() { if ($this->config->item('send_confirm_link') === true) { $link = md5($this->orderId . time()); $result = $this->Public_model->setActivationLink($link, $this->orderId); if ($result == true) { $url = parse_url(base_url()); $msg = lang('please_confirm') . base_url('confirm/' . $link); $this->sendmail->sendTo($_POST['email'], $_POST['first_name'] . ' ' . $_POST['last_name'], lang('confirm_order_subj') . $url['host'], $msg); } } } function clearShoppingCart(){ $user_id = $_SESSION['logged_user']['id']; $this->Public_model->removeAllItemsFromCart("shopping_cart",$user_id); $this->Public_model->clearBookingTime('user_booking',$user_id); } public function goToDestination($post, $order_id) { if ($post['post']['payment_type'] == 'cashOnDelivery' || $post['post']['payment_type'] == 'Bank') { $this->clearShoppingCart($post); $this->session->set_flashdata('success_order', true); } if ($post['post']['payment_type']) { // Send SMS for Order Confirmation $mobile_number = $_SESSION['logged_user']['phone']; $order_otp = $post['order_otp']; $sms_content = str_replace(array('##name##','##OTP##'),array($_SESSION['logged_user']['name'],$order_otp),ORDER_BOOKED); try { $result = $this->Public_model->sendSMS($mobile_number, $sms_content); } catch (Exception $e) { //echo 'Caught exception: ', $e->getMessage(), "\n"; } redirect(LANG_URL . '/order/'.$order_id); } } private function userInfoValidate($post) { $errors = array(); if (mb_strlen(trim($post['first_name'])) == 0) { $errors[] = lang('first_name_empty'); } if (mb_strlen(trim($post['last_name'])) == 0) { $errors[] = lang('last_name_empty'); } if (!filter_var($post['email'], FILTER_VALIDATE_EMAIL)) { $errors[] = lang('invalid_email'); } $post['phone'] = preg_replace("/[^0-9]/", '', $post['phone']); if (mb_strlen(trim($post['phone'])) == 0) { $errors[] = lang('invalid_phone'); } if (mb_strlen(trim($post['address'])) == 0) { $errors[] = lang('address_empty'); } if (mb_strlen(trim($post['city'])) == 0) { $errors[] = lang('invalid_city'); } return $errors; } public function orderError() { if ($this->session->flashdata('order_error')) { $data = array(); $head = array(); $arrSeo = $this->Public_model->getSeo('checkout'); $head['title'] = @$arrSeo['title']; $head['description'] = @$arrSeo['description']; $head['keywords'] = str_replace(" ", ",", $head['title']); $this->render('checkout_parts/order_error', $head, $data); } else { redirect(LANG_URL . '/checkout'); } } public function paypalPayment() { $data = array(); $head = array(); $arrSeo = $this->Public_model->getSeo('checkout'); $head['title'] = @$arrSeo['title']; $head['description'] = @$arrSeo['description']; $head['keywords'] = str_replace(" ", ",", $head['title']); $data['paypal_sandbox'] = $this->Home_admin_model->getValueStore('paypal_sandbox'); $data['paypal_email'] = $this->Home_admin_model->getValueStore('paypal_email'); $this->render('checkout_parts/paypal_payment', $head, $data); } public function successPaymentCashOnD() { if ($this->session->flashdata('success_order')) { $data = array(); $head = array(); $arrSeo = $this->Public_model->getSeo('checkout'); $head['title'] = @$arrSeo['title']; $head['description'] = @$arrSeo['description']; $head['keywords'] = str_replace(" ", ",", $head['title']); $this->render('checkout_parts/payment_success_cash', $head, $data); } else { redirect(LANG_URL . '/checkout'); } } public function successPaymentBank() { if ($this->session->flashdata('success_order')) { $data = array(); $head = array(); $arrSeo = $this->Public_model->getSeo('checkout'); $head['title'] = @$arrSeo['title']; $head['description'] = @$arrSeo['description']; $head['keywords'] = str_replace(" ", ",", $head['title']); $data['bank_account'] = $this->Orders_model->getBankAccountSettings(); $this->render('checkout_parts/payment_success_bank', $head, $data); } else { redirect(LANG_URL . '/checkout'); } } public function paypal_cancel() { if (get_cookie('paypal') == null) { redirect(base_url()); } @delete_cookie('paypal'); $orderId = get_cookie('paypal'); $this->Public_model->changePaypalOrderStatus($orderId, 'canceled'); $data = array(); $head = array(); $head['title'] = ''; $head['description'] = ''; $head['keywords'] = ''; $this->render('checkout_parts/paypal_cancel', $head, $data); } public function paypal_success() { if (get_cookie('paypal') == null) { redirect(base_url()); } @delete_cookie('paypal'); $this->shoppingcart->clearShoppingCart(); $orderId = get_cookie('paypal'); $this->Public_model->changePaypalOrderStatus($orderId, 'payed'); $data = array(); $head = array(); $head['title'] = ''; $head['description'] = ''; $head['keywords'] = ''; $this->render('checkout_parts/paypal_success', $head, $data); } }