%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 /* * @Author: Chandni Gupta */ if (!defined('BASEPATH')) { exit('No direct script access allowed'); } class AddProduct extends VENDOR_Controller { public function __construct() { parent::__construct(); $this->load->model(array( 'Products_model', 'admin/Languages_model', 'admin/Categories_model' )); } /* * Function : index */ public function index($id = 0) { $data = array(); $head = array(); $head['title'] = 'Booking'; $head['description'] = 'Add Home Collection Booking'; $head['keywords'] = ''; $data['languages'] = $this->Languages_model->getLanguages(); $data['shop_categories'] = $this->Categories_model->getShopCategories(); $data['risk_categories'] = $this->Categories_model->getTestsCategories(); $data['tests'] = $this->Products_model->getTest(); $data['packages'] = $this->Products_model->getPacakes(); $data['otherImgs'] = $this->loadOthersImages(); $data['trans_load'] = $trans_load; $collection_time =array("05:00 - 06:00"=>"05:00 - 06:00", "05:30 - 06:30"=>"05:30 - 06:30", "06:00 - 07:00" =>"06:00 - 07:00", "06:30 - 07:30" =>"06:30 - 07:30", "07:00 - 08:00" =>"07:00 - 08:00", "07:30 - 08:30" =>"07:30 - 08:30", "08:00 - 09:00" =>"08:00 - 09:00", "08:30 - 09:30" =>"08:30 - 09:30", "09:00 - 10:00" =>"09:00 - 10:00", "09:30 - 10:30" =>"09:30 - 10:30", "10:00 - 11:00" =>"10:00 - 11:00", "10:30 - 11:30" =>"10:30 - 11:30", "11:00 - 12:00" =>"11:00 - 12:00", "11:30 - 12:30" =>"11:30 - 12:30", "12:00 - 13:00" =>"12:00 - 13:00", "12:30 - 13:30" =>"12:30 - 13:30", "13:00 - 14:00" =>"13:00 - 14:00"); $data['collection_time'] = $collection_time; $trans_load = null; if ($id > 0 && $_POST == null) { $_POST = $this->Products_model->getOneProduct($id, $this->vendor_id); $trans_load = $this->Products_model->getTranslations($id); } if (isset($_POST['setProduct'])) { //check user input $error = $this->saveBooking(); if($error == true){ $_POST['vendor_id'] = $this->vendor_id; $_POST['order_otp'] = $this->Products_model->getOTP(); $id = $this->Products_model->registerPatient($_POST); $result = $this->Products_model->setBooking($_POST, $id); $order_otp = $_POST['order_otp']; $sms_content = str_replace(array('##name##','##OTP##'),array($_POST['name'],$order_otp),ORDER_BOOKED); if ($result == 1) { try { $result = $this->Products_model->sendSMS($_POST['phone'], $sms_content); } catch (Exception $e) { //echo 'Caught exception: ', $e->getMessage(), "\n"; } $result_msg = 'You Booked an order'; } else { $result_msg = lang('vendor_product_publish_err'); } $this->session->set_flashdata('result_publish', $result_msg); if($_POST['booking_enqiry_id']>0){ redirect(LANG_URL . '/vendor/callcenter?getid='.$_POST['booking_enqiry_id'].'&msg=1001'); } else { redirect(LANG_URL . '/vendor/products'); } } else { $this->session->set_flashdata('error_booking', $this->registerErrors); $this->load->view('_parts/header', $head); $this->load->view('add_product', $data); $this->load->view('_parts/footer'); return ; } } $data = array(); $head = array(); $head['title'] = 'Add Booking'; $head['description'] = 'Add Booking'; $head['keywords'] = ''; $data['languages'] = $this->Languages_model->getLanguages(); $data['shop_categories'] = $this->Categories_model->getShopCategories(); $data['risk_categories'] = $this->Categories_model->getTestsCategories(); $data['tests'] = $this->Products_model->getTest(); $data['packages'] = $this->Products_model->getPacakes(); $data['otherImgs'] = $this->loadOthersImages(); $data['trans_load'] = $trans_load; $data['collection_time'] = $collection_time; $this->load->view('_parts/header', $head); $this->load->view('add_product', $data); $this->load->view('_parts/footer'); } private function uploadImage() { $config['upload_path'] = './attachments/shop_images/'; $config['allowed_types'] = $this->allowed_img_types; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('userfile')) { log_message('error', 'Image Upload Error: ' . $this->upload->display_errors()); } $img = $this->upload->data(); return $img['file_name']; } private function saveBooking() { $errors = array(); if (mb_strlen(trim($_POST['name'])) == 0) { $errors[] = 'Enter Name'; } else if (mb_strlen(trim($_POST['phone'])) == 0) { $errors[] = 'Enter Contact Number'; } else if (mb_strlen(trim($_POST['email'])) == 0) { $errors[] = 'Invalid Email id'; } else if ($_POST['email'] && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errors[] = 'Invalid Email id'; } else if (mb_strlen(trim($_POST['shop_categorie'])) == 0) { $errors[] = 'Please Select Category'; } else if (mb_strlen(trim($_POST['risk_categorie'])) == 0) { $errors[] = 'Please Select Risk Area'; } else if (mb_strlen(trim($_POST['booking_date'])) == 0) { $errors[] = 'Please Choose Booking Date'; } else if (mb_strlen(trim($_POST['collection_time'])) == 0) { $errors[] = 'Please Choose Booking Time'; } else if (mb_strlen(trim($_POST['city'])) == 0) { $errors[] = 'Please Choose City'; } else if (mb_strlen(trim($_POST['address'])) == 0) { $errors[] = 'Please Enter Address'; } if (!empty($errors)) { $this->registerErrors = $errors; return false; } return true; } /* * called from ajax */ public function do_upload_others_images() { if ($this->input->is_ajax_request()) { $upath = '.' . DIRECTORY_SEPARATOR . 'attachments' . DIRECTORY_SEPARATOR . 'shop_images' . DIRECTORY_SEPARATOR . $_POST['folder'] . DIRECTORY_SEPARATOR; if (!file_exists($upath)) { mkdir($upath, 0777); } $this->load->library('upload'); $files = $_FILES; $cpt = count($_FILES['others']['name']); for ($i = 0; $i < $cpt; $i++) { unset($_FILES); $_FILES['others']['name'] = $files['others']['name'][$i]; $_FILES['others']['type'] = $files['others']['type'][$i]; $_FILES['others']['tmp_name'] = $files['others']['tmp_name'][$i]; $_FILES['others']['error'] = $files['others']['error'][$i]; $_FILES['others']['size'] = $files['others']['size'][$i]; $this->upload->initialize(array( 'upload_path' => $upath, 'allowed_types' => $this->allowed_img_types )); $this->upload->do_upload('others'); } } } public function loadOthersImages() { $output = ''; if (isset($_POST['folder']) && $_POST['folder'] != null) { $dir = 'attachments' . DIRECTORY_SEPARATOR . 'shop_images' . DIRECTORY_SEPARATOR . $_POST['folder'] . DIRECTORY_SEPARATOR; if (is_dir($dir)) { if ($dh = opendir($dir)) { $i = 0; while (($file = readdir($dh)) !== false) { if (is_file($dir . $file)) { $output .= ' <div class="other-img" id="image-container-' . $i . '"> <img src="' . base_url('attachments/shop_images/' . $_POST['folder'] . '/' . $file) . '" style="width:100px; height: 100px;"> <a href="javascript:void(0);" onclick="removeSecondaryProductImage(\'' . $file . '\', \'' . $_POST['folder'] . '\', ' . $i . ')"> <span class="glyphicon glyphicon-remove"></span> </a> </div> '; } $i++; } closedir($dh); } } } if ($this->input->is_ajax_request()) { echo $output; } else { return $output; } } /* * called from ajax */ public function removeSecondaryImage() { if ($this->input->is_ajax_request()) { $img = '.' . DIRECTORY_SEPARATOR . 'attachments' . DIRECTORY_SEPARATOR . 'shop_images' . DIRECTORY_SEPARATOR . '' . $_POST['folder'] . DIRECTORY_SEPARATOR . $_POST['image']; unlink($img); } } }