%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 AddLead extends VENDOR_Controller { public function __construct() { parent::__construct(); $this->load->model(array( 'Products_model', 'admin/Languages_model', 'admin/Categories_model' )); } public function index($id = 0) { $data = array(); $head = array(); $head['title'] = 'Add Lead'; $head['description'] = 'Add Lead'; $head['keywords'] = ''; $data['languages'] = $this->Languages_model->getLanguages(); $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['setLead'])) { unset($_POST['setLead']); $error = $this->saveLead(); //print_r($_POST);die; if($error == true){ $_POST['vendor_id'] = $this->vendor_id; $_POST['prescription'] = $this->uploadImage(); $result = $this->Products_model->setLead($_POST); if ($result > 0) { $result_msg = 'Lead saved successfully'; } $this->session->set_flashdata('result_publish', $result_msg); redirect(LANG_URL . '/vendor/leads'); } else { $this->session->set_flashdata('error_leads', $this->registerErrors); $this->load->view('_parts/header', $head); $this->load->view('add_lead', $data); $this->load->view('_parts/footer'); return; } } $this->load->view('_parts/header', $head); $this->load->view('add_lead', $data); $this->load->view('_parts/footer'); } private function uploadImage() { $config['upload_path'] = './attachments/prescription/'; $config['allowed_types'] = 'gif|jpg|png|jpeg|JPG|PNG|JPEG|PDF|pdf'; $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload('prescription')) { print_r($this->upload->display_errors()); die; log_message('error', 'Image Upload Error: ' . $this->upload->display_errors()); } $img = $this->upload->data(); return $img['file_name']; } private function saveLead() { $errors = array(); if (mb_strlen(trim($_POST['full_name'])) == 0) { $errors[] = 'Enter Name'; } else if (mb_strlen(trim($_POST['mobile_number'])) == 0) { $errors[] = 'Enter Contact Number'; } else if ($_POST['email_id'] && !filter_var($_POST['email_id'], FILTER_VALIDATE_EMAIL)) { $errors[] = 'Invalid Email id'; } /*else if (mb_strlen(trim($_POST['prescription'])) == 0) { $errors[] = 'Please Upload prescription'; }*/ 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); } } }