private function breadCrumb($categoryId, $title) { $breadCrumbStr = '<a href="' . BASE_URL . '">Home</a>'; $categoryArr = $this->get_category_arr_for_breadcrumb($categoryId); ksort($categoryArr); //pre($categoryArr);die; foreach ($categoryArr as $k => $v) { //echo $k .' = '.$v;die; $breadCrumbStr .= ' >> <a href="' . BASE_URL . 'category/details/' . my_seo_freindly_url($v) . '/' . base64_encode('k') . '~' . md5('tidiit') . '">' . $v . '</a>'; } return $breadCrumbStr .= ' >> ' . $title; }
function order_delivery_post() { $orderId = trim($this->post('orderId')); $userId = trim($this->post('userId')); $UDID = trim($this->post('UDID')); $deviceToken = trim($this->post('deviceToken')); $deviceType = "android"; $latitude = trim($this->post('latitude')); $longitude = trim($this->post('longitude')); $receiveStaffName = trim($this->input->post('receiveStaffName', TRUE)); $receiveStaffContactNo = trim($this->input->post('receiveStaffContactNo', TRUE)); $oldReceiveDateTime = trim($this->input->post('receiveDateTime', TRUE)); if ($receiveStaffName == "") { $this->response(array('error' => 'Please enter the receive staff name.'), 400); return FALSE; } if ($receiveStaffContactNo == "") { $this->response(array('error' => 'Please enter the receive staff contact number.'), 400); return FALSE; } $receiveDateTimeArr = explode(' ', $oldReceiveDateTime); $receiveDateArr = explode('-', $receiveDateTimeArr[0]); $receiveDateTime = $receiveDateArr[2] . '-' . $receiveDateArr[1] . '-' . $receiveDateArr[0] . ' ' . $receiveDateTimeArr[1] . ':00'; $defaultDataArr = array('UDID' => $UDID, 'deviceType' => $deviceType, 'deviceToken' => $deviceToken, 'latitude' => $latitude, 'longitude' => $longitude); $isValideDefaultData = $this->check_default_data($defaultDataArr); if ($isValideDefaultData['type'] == 'fail') { $this->response(array('error' => $isValideDefaultData['message']), 400); return FALSE; } $order = $this->order->get_single_order_by_id($orderId); if (empty($order)) { $this->response(array('error' => "Getting invalid order index"), 400); return FALSE; } if ($order->status != 5) { $this->response(array('error' => 'Selected order is yet not out for delivery or already delivered.'), 400); return FALSE; } /// need check payment has done or not. $logisticDetails = $this->user->get_logistics_details_by_user_id($userId); $logisticsId = $logisticDetails[0]['logisticsId']; $deliveryStaffName = $logisticDetails[0]['firstName'] . ' ' . $logisticDetails[0]['lastName']; $deliveryStaffContactNo = $logisticDetails[0]['contactNo']; $deliveryStaffEmail = $logisticDetails[0]['email']; $dataArr = array('orderId' => $orderId, 'logisticsId' => $logisticsId, 'deliveryStaffName' => $deliveryStaffName, 'deliveryStaffContactNo' => $deliveryStaffContactNo, 'IP' => $this->input->ip_address(), 'deliveryStaffEmail' => $deliveryStaffEmail, 'receiveStaffName' => $receiveStaffName, 'receiveStaffContactNo' => $receiveStaffContactNo, 'receiveDateTime' => $receiveDateTime); //$config['upload_path'] =$this->config->item('ResourcesPath').'order_delivery/original/'; $config['upload_path'] = MAIN_SERVER_RESOURCES_PATH . 'order_delivery/original/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['file_name'] = strtolower(my_seo_freindly_url($orderId)) . '-' . rand(1, 9) . '-' . time(); $config['max_size'] = '2047'; $config['max_width'] = '1550'; $config['max_height'] = '1550'; $upload_files = array(); $this->load->library('upload'); foreach ($_FILES as $fieldname => $fileObject) { //fieldname is the form field name //pre($fieldname); //pre($fileObject);die; $this->upload->initialize($config); if (!$this->upload->do_upload($fieldname)) { foreach ($upload_files as $k) { ///@unlink($this->config->item('ResourcesPath').'order_delivery/original/'.$k); @unlink(MAIN_SERVER_RESOURCES_PATH . 'order_delivery/original/' . $k); } $errors = $this->upload->display_errors(); //pre($errors);die; $this->response(array('error' => $errors), 400); return FALSE; } else { $data = $this->upload->data(); $this->order_delivery_image_resize($data['file_name']); $upload_files[] = $data['file_name']; } } if (empty($upload_files) || count($upload_files) < 2) { $this->response(array('error' => 'You must upload 2 photo for tidiit order delivery proof.'), 400); return FALSE; } $dataArr['photo1'] = $upload_files[0]; $dataArr['photo2'] = $upload_files[1]; //pre($dataArr);die; if (empty($oldDeliveryRequestDetails)) { $orderDeliveredRequestId = $this->Order_model->add_order_delivered_request($dataArr); } else { //pre($oldDeliveryRequestDetails);die; if ($oldDeliveryRequestDetails[0]['photo1'] != "") { if ($data['photo1'] != "") { $this->delete_delivery_image($oldDeliveryRequestDetails[0]['photo1']); } } if ($oldDeliveryRequestDetails[0]['photo2'] != "") { if ($data['photo2'] != "") { $this->delete_delivery_image($oldDeliveryRequestDetails[0]['photo2']); } } $this->Order_model->update_order_delivered_request($dataArr, $orderId); $orderDeliveredRequestId = $oldDeliveryRequestDetails[0]['orderDeliveredRequestId']; } if ($orderDeliveredRequestId) { $result = array(); $result['message'] = 'Delivery information updated successfully.'; success_response_after_post_get($result); } else { $this->response(array('error' => 'Unknown error arises, please try again'), 400); return FALSE; } }
function display_category_products($name) { if (strtoupper(trim($this->session->userdata('FE_SESSION_USER_LOCATION_VAR'))) != 'IN') { redirect(BASE_URL); } //echo $_SERVER['SERVER_ADDR'];print_r($_GET);die; $SEODataArr = array(); if ($this->is_loged_in()) { $data = $this->_get_logedin_template($SEODataArr); } else { $data = $this->_get_tobe_login_template($SEODataArr); } if (!isset($_GET['cpid']) || !$_GET['cpid']) { $this->session->set_flashdata('error', 'Invalid location. Please click proper category link!'); redirect(BASE_URL . 'products/ord-message'); } else { $categoryId = base64_decode($_GET['cpid']) / 226201; $currentCat = $this->Category_model->get_details_by_id($categoryId); $currCat = $currentCat[0]; if (my_seo_freindly_url($currCat->categoryName) != $name) { $this->session->set_flashdata('error', 'Invalid location. Please click proper category link!'); redirect(BASE_URL . 'products/ord-message'); } } $data['currCat'] = $currCat; $is_last = $this->Category_model->is_category_last($categoryId); $data['widget_cats'] = $this->Category_model->get_parent_categories($categoryId); if (!$is_last) { $data['body_cats'] = $this->Category_model->display_children_categories($categoryId); } $data['is_last'] = $is_last; $data['s_widget_cats'] = $data['widget_cats']; $options = $this->Option_model->get_category_product_option_wedgets($currCat->option_ids); $data['options'] = $options; unset($_GET['cpid']); $cond = array(); $data['sort'] = 'popular'; $data['brand'] = array(); $data['range'] = array(0, 100000); $data['query'] = array(); foreach ($_GET as $key => $get) { if ($key == 'sort' && $get) { $cond['order_by'] = $get; $data['sort'] = $get; } if ($key == 'brand' && $get) { $brands = explode("|", $get); $cond['brand'] = $brands; $data['brand'] = $brands; } if ($key == 'range' && $get) { $ranges = explode("|", $get); $cond['range'] = $ranges; $data['range'] = array($ranges[0], $ranges[1]); } if ($key == 'query' && $get) { $queries = explode("|", $get); $cond['query'] = $queries; $data['query'] = $queries; } if ($key == 'querys' && $get) { if (!isset($cond['query'])) { $cond['query'] = []; } array_push($cond['query'], $get); array_push($data['query'], $get); } } $item_per_page = 8; if (isset($_GET['page']) && $_GET['page']) { $offset = $_GET['page'] * $item_per_page; } else { $offset = 0; } if (isset($_GET['cls']) && $_GET['cls']) { $offset = 0; } else { $offset = $offset; } $products = $this->Category_model->get_children_categories_products($categoryId, $offset, $limit = $item_per_page, $cond); $total_rows = $this->Category_model->get_children_categories_products($categoryId, 0, false, $cond); $tr = isset($total_rows['products']) ? $total_rows['products'] : false; $totalrows = !empty($tr) ? count($tr) : 0; $total_pages = ceil($totalrows / $item_per_page); $data['total_pages'] = $total_pages; $products['brands'] = $total_rows['brands']; $data['products'] = $products; if ($total_pages <= $item_per_page) { $data['show_loads'] = true; } else { $data['show_loads'] = false; } if (isset($_GET['stype']) && $_GET['stype'] == "ajax") { if (isset($_GET['cls']) && $_GET['cls']) { $data['cls'] = 1; } else { $data['cls'] = 0; } $brnd = isset($_GET['brand']) ? explode("|", $_GET['brand']) : array(); $data['products'] = $this->create_product_view($products); $data['brands'] = $this->display_brands_view($total_rows['brands'], $brnd); echo json_encode($data); die; } $data['feedback'] = $this->load->view('feedback', $data, TRUE); $data['common_how_it_works'] = $this->load->view('common_how_it_works', $data, TRUE); $this->load->view('category_details', $data); }
public function edit_mobile_submit() { //pre($_POST);die; $retDataArr = $this->default_data_validate(); if ($retDataArr['status'] == 'fail') { $this->session->set_flashdata('Message', $retDataArr['data']); redirect(BASE_URL . 'product/add_product/'); //echo json_encode(array('result'=>'bad','msg'=>$retDataArr['data'])); } else { $config = array(array('field' => 'mobileBoxContent[]', 'label' => 'Items in the box', 'rules' => 'trim|required|xss_clean'), array('field' => 'model', 'label' => 'Model', 'rules' => 'trim|required|xss_clean'), array('field' => 'brandId', 'label' => 'Brand', 'rules' => 'trim|required|xss_clean'), array('field' => 'noOfSims', 'label' => 'Nos of SIM in the box', 'rules' => 'trim|required|xss_clean'), array('field' => 'color', 'label' => 'Mobile Color', 'rules' => 'trim|required|xss_clean'), array('field' => 'os', 'label' => 'Operating System', 'rules' => 'trim|required|xss_clean'), array('field' => 'qty', 'label' => 'Quantity', 'rules' => 'trim|required|xss_clean'), array('field' => 'minQty', 'label' => 'Minimum Quantity', 'rules' => 'trim|required|xss_clean'), array('field' => 'bulkQty', 'label' => 'First Quantity Range', 'rules' => 'trim|required|xss_clean'), array('field' => 'price', 'label' => 'First Price Range', 'rules' => 'trim|required|xss_clean')); $type = 'mobile'; $mobileBoxContent = $this->input->post('mobileBoxContent'); //$mobileBoxContent=$this->input->post('mobileBoxContent[]',TRUE); $model = $this->input->post('model', TRUE); $brandId = $this->input->post('brandId', TRUE); $noOfSims = $this->input->post('noOfSims', TRUE); $color = $this->input->post('color', TRUE); $mobileOtherFeatures = $this->input->post('mobileOtherFeatures', TRUE); $screenSize = $this->input->post('screenSize', TRUE); $displayResolution = $this->input->post('displayResolution', TRUE); $displayType = $this->input->post('displayType', TRUE); $pixelDensity = $this->input->post('pixelDensity', TRUE); $os = $this->input->post('os', TRUE); $osVersion = $this->input->post('osVersion', TRUE); $multiLanguages = $this->input->post('multiLanguages', TRUE); $mobileRearCamera = $this->input->post('mobileRearCamera', TRUE); $mobileFlash = $this->input->post('mobileFlash', TRUE); $frontCamera = $this->input->post('frontCamera', TRUE); $mobileOtherCameraFeatures = $this->input->post('mobileOtherCameraFeatures', TRUE); $mobileConnectivity = $this->input->post('mobileConnectivity', TRUE); $processorSpeed = $this->input->post('processorSpeed', TRUE); $processorCores = $this->input->post('processorCores', TRUE); $processorBrand = $this->input->post('processorBrand', TRUE); $ram = $this->input->post('ram', TRUE); $internalMemory = $this->input->post('internalMemory', TRUE); $expandableMemory = $this->input->post('expandableMemory', TRUE); $memoryCardSlot = $this->input->post('memoryCardSlot', TRUE); $batteryCapacity = $this->input->post('batteryCapacity', TRUE); $batteryType = $this->input->post('batteryType', TRUE); $talkTime = $this->input->post('talkTime', TRUE); $standbyTime = $this->input->post('standbyTime', TRUE); $warrantyType = $this->input->post('warrantyType', TRUE); $warrantyDuration = $this->input->post('warrantyDuration', TRUE); $categoryId = $this->input->post('categoryId', TRUE); $taxable = $this->input->post('taxable', TRUE); $minQty = $this->input->post('minQty', TRUE); $qty = $this->input->post('qty', TRUE); $length = $this->input->post('length', TRUE); $width = $this->input->post('width', TRUE); $height = $this->input->post('height', TRUE); $lengthClass = $this->input->post('lengthClass', TRUE); $weight = $this->input->post('weight', TRUE); $weightClass = $this->input->post('weightClass', TRUE); $bulkQty = $this->input->post('bulkQty', TRUE); $price = $this->input->post('price', TRUE); $productId = $this->input->post('productId', TRUE); $total_price_row_added = $this->input->post('total_price_row_added', TRUE); //$status=$this->input->post('status',TRUE); $this->form_validation->set_rules($config); if ($this->form_validation->run() == FALSE) { $data = validation_errors(); //pre($data);die; //return array('status'=>'fail','data'=>$data); $this->session->set_flashdata('Message', $data); redirect(BASE_URL . 'product/add_product/'); } else { $priceArr = array(); $lowestPrice = $price; $priceArr[] = array('qty' => $bulkQty, 'price' => $price); for ($i = 1; $i < $total_price_row_added; $i++) { $bulkQty = $this->input->post('bulkQty_' . $i, TRUE); $price = $this->input->post('price_' . $i, TRUE); if ($bulkQty == "" || $price == "") { //echo '$bulkQty= '.$bulkQty.' === $price '.$price;die; $this->session->set_flashdata('Message', 'Please fill the price and relted quanity'); redirect(BASE_URL . 'product/add_product/'); } $priceArr[] = array('qty' => $bulkQty, 'price' => $price); } usort($priceArr, 'sortingProductPriceArr'); //pre($priceArr);die; $newPriceArr = array(); foreach ($priceArr as $k) { $k['productId'] = $productId; $newPriceArr[] = $k; } //pre($newPriceArr);die; $this->Product_model->edit_product_price($newPriceArr, $productId); $heighestPrice = $price; $minQty = $priceArr[count($priceArr) - 1]['qty']; //$dataArr=$retDataArr['data']; $dataArr = array('mobileBoxContent' => implode(',', $mobileBoxContent), 'model' => $model, 'noOfSims' => $noOfSims, 'color' => $color, 'mobileOtherFeatures' => $mobileOtherFeatures, 'screenSize' => $screenSize, 'displayResolution' => $displayResolution, 'displayType' => $displayType, 'pixelDensity' => $pixelDensity, 'os' => $os, 'osVersion' => $osVersion, 'multiLanguages' => $multiLanguages, 'mobileRearCamera' => $mobileRearCamera, 'mobileFlash' => $mobileFlash, 'frontCamera' => $frontCamera, 'mobileOtherCameraFeatures' => $mobileOtherCameraFeatures, 'batteryType' => $batteryType, 'processorSpeed' => $processorSpeed, 'processorCores' => $processorCores, 'ram' => $ram, 'processorBrand' => $processorBrand, 'internalMemory' => $internalMemory, 'expandableMemory' => $expandableMemory, 'memoryCardSlot' => $memoryCardSlot, 'batteryCapacity' => $batteryCapacity, 'talkTime' => $talkTime, 'standbyTime' => $standbyTime, 'warrantyType' => $warrantyType, 'taxable' => $taxable, 'warrantyDuration' => $warrantyDuration, 'minQty' => $minQty, 'qty' => $qty, 'length' => $length, 'width' => $width, 'height' => $height, 'lengthClass' => $lengthClass, 'weight' => $weight, 'weightClass' => $weightClass, 'lowestPrice' => $lowestPrice, 'heighestPrice' => $heighestPrice); $ParrentDataArr = $this->Category_model->get_all_parrent_details($categoryId); //pre($ParrentDataArr); if ($ParrentDataArr[0]->secondParentcategoryId == "") { $dataArr['CategoryID1'] = $ParrentDataArr[0]->firstParentcategoryId; $dataArr['CategoryID2'] = $categoryId; } else { $dataArr['CategoryID1'] = $ParrentDataArr[0]->secondParentcategoryId; $dataArr['CategoryID2'] = $ParrentDataArr[0]->firstParentcategoryId; $dataArr['CategoryID3'] = $categoryId; } if (!empty($mobileConnectivity)) { $dataArr['mobileConnectivity'] = implode(',', $mobileConnectivity); } $tag = $retDataArr['data']['tag']; unset($retDataArr['data']['tag']); $mobileDataArr = array_merge($retDataArr['data'], $dataArr); $config['upload_path'] = $this->config->item('ResourcesPath') . 'product/original/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['file_name'] = strtolower(my_seo_freindly_url($mobileDataArr['title'])) . '-' . rand(1, 9) . '-' . time(); $config['max_size'] = '2047'; $config['max_width'] = '1550'; $config['max_height'] = '1550'; //$config['max_width'] = '1024'; //$config['max_height'] = '1024'; $upload_files = array(); $this->load->library('upload'); //pre($_FILES);die; $blank = 0; foreach ($_FILES as $fieldname => $fileObject) { //fieldname is the form field name //pre($fileObject); if (!empty($fileObject['name'])) { $this->upload->initialize($config); if (!$this->upload->do_upload($fieldname)) { foreach ($upload_files as $k) { @unlink($this->config->item('ResourcesPath') . 'product/original/' . $k); } $errors = $this->upload->display_errors(); //pre($errors);die; $this->session->set_flashdata('Message', $errors); redirect(base_url() . 'product/add_product/'); } else { // Code After Files Upload Success GOES HERE $currgImgNo = substr($fieldname, 3); $oldUploadedFileName = $this->input->post('oldImgFile' . $currgImgNo, TRUE); $this->Product_model->remove_product_by_file($oldUploadedFileName, $productId); $this->delete_product_file($oldUploadedFileName); $data = $this->upload->data(); $this->product_image_resize($data['file_name']); $upload_files[] = $data['file_name']; } } else { if (substr($fieldname, -1) == 1) { $blank++; } } } $this->Product_model->edit($mobileDataArr, $productId); //$productId=1; //echo 'product added done.<br>'; $imageBatchArr = array(); if (!empty($upload_files)) { foreach ($upload_files as $k => $v) { $imageBatchArr[] = array('productId' => $productId, 'image' => $v); } } if (!empty($imageBatchArr)) { //pre($imageBatchArr);die; $this->Product_model->edit_image_product($imageBatchArr, $productId); } //pre($imageBatchArr);die; $productTagArr = array('productId' => $productId, 'tagStr' => $tag); $this->Product_model->edit_product_tag($productTagArr); //$this->Product_model->add_product_category(array('categoryId'=>$categoryId)); //$this->Product_model->add_product_owner(array('productId'=>$productId,'userId'=>$this->session->userdata('FE_SESSION_VAR'))); $this->Product_model->edit_brand(array('brandId' => $brandId), $productId); $this->session->set_flashdata('Message', 'Product updated successfully.'); redirect(base_url() . 'product/viewlist'); } } }
<a href="<?php echo BASE_URL . 'category/details/' . my_seo_freindly_url($vvv->categoryName) . '/' . base64_encode($vvv->categoryId) . '~' . md5('tidiit'); ?> "><?php echo $vvv->categoryName; ?> <i class="fa fa-angle-down mobl_vrsn"></i></a> <?php if (property_exists($vvv, 'SubCategory')) { ?> <ul class="sub_sub_ctgrs"> <?php foreach ($vvv->SubCategory as $j => $l) { ?> <li><a href="<?php echo BASE_URL . 'category/details/' . my_seo_freindly_url($l->categoryName) . '/' . base64_encode($l->categoryId) . '~' . md5('tidiit'); ?> "><?php echo $l->categoryName; ?> </a></li> <?php } ?> </ul> <?php } ?> </li> <?php }
function multi_cat_menu_float_list_menu($pcat) { ?> <ul class="dropdown-menu"> <?php foreach ($pcat as $pkey => $cat) { ?> <li <?php if (isset($cat->parent) && $cat->parent) { ?> class="dropdown-submenu"<?php } ?> > <a href="<?php echo BASE_URL . 'products/' . my_seo_freindly_url($cat->categoryName) . '/?cpid=' . base64_encode($cat->categoryId * 226201); ?> &sort=popular"><?php echo $cat->categoryName; ?> </a> <?php if (isset($cat->parent) && $cat->parent) { $this->multi_cat_menu_float_list_menu($cat->parent); } ?> </li> <?php } ?> </ul><?php }
<?php foreach ($body_cats as $bdkey => $bcat) { //print_r($bcat); ?> <div class="item"> <div class="prodct_box"> <a href="<?php echo BASE_URL . 'products/' . my_seo_freindly_url($bcat->categoryName) . '/?cpid=' . base64_encode($bcat->categoryId * 226201); ?> "> <img src="<?php echo SiteImagesURL; ?> prdct_img.png" class="img-responsive" /> </a> <p class="text-center"><a href="<?php echo BASE_URL . 'products/' . my_seo_freindly_url($bcat->categoryName) . '/?cpid=' . base64_encode($bcat->categoryId * 226201); ?> "><?php echo $bcat->categoryName; ?> </a></p> </div> </div> <?php } ?> </div> </div> </div> <?php }
function submit_delivery() { $config = array(array('field' => 'orderId', 'label' => 'Enter the OrderID', 'rules' => 'trim|required|xss_clean|callback_valid_user_order_for_delivery'), array('field' => 'logisticsId', 'label' => 'Logistics Tidiit Sign ID', 'rules' => 'trim|required|xss_clean'), array('field' => 'deliveryStaffName', 'label' => 'Delivery Staff Name', 'rules' => 'trim|required|xss_clean'), array('field' => 'deliveryStaffContactNo', 'label' => 'Delivery Staff Contact No', 'rules' => 'trim|required|xss_clean'), array('field' => 'deliveryStaffEmail', 'label' => 'Delivery Staff Email', 'rules' => 'trim|required|xss_clean|valid_email'), array('field' => 'receiveStaffName', 'label' => 'Receive Staff Name', 'rules' => 'trim|required|xss_clean'), array('field' => 'receiveStaffContactNo', 'label' => 'Receive Staff Contact No', 'rules' => 'trim|required|xss_clean'), array('field' => 'receiveDateTime', 'label' => 'Receive Date Time', 'rules' => 'trim|required|xss_clean')); $this->form_validation->set_rules($config); //checking validation if ($this->form_validation->run() == FALSE) { //retun to login page with peroper error echo json_encode(array('result' => 'bad', 'msg' => str_replace('</p>', '', str_replace('<p>', '', validation_errors())))); die; } else { $orderId = trim($this->input->post('orderId', TRUE)); $logisticsId = trim($this->input->post('logisticsId', TRUE)); $deliveryStaffName = $this->input->post('deliveryStaffName', TRUE); $deliveryStaffContactNo = $this->input->post('deliveryStaffContactNo', TRUE); $deliveryStaffEmail = $this->input->post('deliveryStaffEmail', TRUE); $receiveStaffName = $this->input->post('receiveStaffName', TRUE); $receiveStaffContactNo = $this->input->post('receiveStaffContactNo', TRUE); $oldReceiveDateTime = $this->input->post('receiveDateTime', TRUE); $receiveDateTimeArr = explode(' ', $oldReceiveDateTime); $receiveDateArr = explode('-', $receiveDateTimeArr[0]); $receiveDateTime = $receiveDateArr[2] . '-' . $receiveDateArr[1] . '-' . $receiveDateArr[0] . ' ' . $receiveDateTimeArr[1] . ':00'; $this->load->model('Logistics_model'); $logisticDetails = $this->Logistics_model->details($logisticsId); $this->load->model('Order_model'); $oldDeliveryRequestDetails = $this->Order_model->get_latest_delivery_details($orderId); if (empty($logisticDetails)) { echo json_encode(array('result' => 'bad', 'msg' => 'Invalid logistics data entered.')); die; } $dataArr = array('orderId' => $orderId, 'logisticsId' => $logisticsId, 'deliveryStaffName' => $deliveryStaffName, 'deliveryStaffContactNo' => $deliveryStaffContactNo, 'IP' => $this->input->ip_address(), 'deliveryStaffEmail' => $deliveryStaffEmail, 'receiveStaffName' => $receiveStaffName, 'receiveStaffContactNo' => $receiveStaffContactNo, 'receiveDateTime' => $receiveDateTime); $config['upload_path'] = $this->config->item('ResourcesPath') . 'order_delivery/original/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['file_name'] = strtolower(my_seo_freindly_url($orderId)) . '-' . rand(1, 9) . '-' . time(); $config['max_size'] = '2047'; $config['max_width'] = '1550'; $config['max_height'] = '1550'; $upload_files = array(); $this->load->library('upload'); //pre($_FILES);die; foreach ($_FILES as $fieldname => $fileObject) { //fieldname is the form field name //pre($fieldname); //pre($fileObject);die; $this->upload->initialize($config); if (!$this->upload->do_upload($fieldname)) { foreach ($upload_files as $k) { @unlink($this->config->item('ResourcesPath') . 'order_delivery/original/' . $k); } $errors = $this->upload->display_errors(); //pre($errors);die; echo json_encode(array('result' => 'bad', 'msg' => $errors)); die; } else { $data = $this->upload->data(); $this->order_delivery_image_resize($data['file_name']); $upload_files[] = $data['file_name']; } } if (empty($upload_files) || count($upload_files) < 2) { echo json_encode(array('result' => 'bad', 'msg' => 'You must upload 2 photo for tidiit order delivery proof.')); die; } $dataArr['photo1'] = $upload_files[0]; $dataArr['photo2'] = $upload_files[1]; //pre($dataArr);die; if (empty($oldDeliveryRequestDetails)) { $orderDeliveredRequestId = $this->Order_model->add_order_delivered_request($dataArr); } else { //pre($oldDeliveryRequestDetails);die; if ($oldDeliveryRequestDetails[0]['photo1'] != "") { if ($data['photo1'] != "") { $this->delete_delivery_image($oldDeliveryRequestDetails[0]['photo1']); } } if ($oldDeliveryRequestDetails[0]['photo2'] != "") { if ($data['photo2'] != "") { $this->delete_delivery_image($oldDeliveryRequestDetails[0]['photo2']); } } $this->Order_model->update_order_delivered_request($dataArr, $orderId); $orderDeliveredRequestId = $oldDeliveryRequestDetails[0]['orderDeliveredRequestId']; } if ($orderDeliveredRequestId) { echo json_encode(array('result' => 'good', 'msg' => 'Delivery information updated successfully.')); die; } else { echo json_encode(array('result' => 'good', 'msg' => 'Unknown error arises, please try again')); die; } } }
public function update_common_product() { //pre($_POST);die; $productId = $this->input->post('productId', TRUE); $enc_pro_id = $productId * 999999; $retDataArr = $this->default_data_validate(); if ($retDataArr['status'] == 'fail') { $this->session->set_flashdata('Message', $retDataArr['data']); redirect(BASE_URL . 'product/edit_product/' . $enc_pro_id); } else { $config = array(array('field' => 'brandId', 'label' => 'Brand', 'rules' => 'trim|required|xss_clean'), array('field' => 'qty', 'label' => 'Quantity', 'rules' => 'trim|required|xss_clean'), array('field' => 'minQty', 'label' => 'Minimum Quantity', 'rules' => 'trim|required|xss_clean'), array('field' => 'bulkQty', 'label' => 'First Quantity Range', 'rules' => 'trim|required|xss_clean'), array('field' => 'price', 'label' => 'First Price Range', 'rules' => 'trim|required|xss_clean')); $brandId = $this->input->post('brandId', TRUE); $categoryId = $this->input->post('categoryId', TRUE); $taxable = $this->input->post('taxable', TRUE); $minQty = $this->input->post('minQty', TRUE); $qty = $this->input->post('qty', TRUE); $length = $this->input->post('length', TRUE); $width = $this->input->post('width', TRUE); $height = $this->input->post('height', TRUE); $lengthClass = $this->input->post('lengthClass', TRUE); $weight = $this->input->post('weight', TRUE); $weightClass = $this->input->post('weightClass', TRUE); $bulkQty = $this->input->post('bulkQty', TRUE); $price = $this->input->post('price', TRUE); $total_price_row_added = $this->input->post('total_price_row_added', TRUE); //$status=$this->input->post('status',TRUE); $this->form_validation->set_rules($config); if ($this->form_validation->run() == FALSE) { $data = validation_errors(); $this->session->set_flashdata('Message', $data); redirect(BASE_URL . 'product/edit_product/' . $enc_pro_id); } else { $priceArr = array(); $lowestPrice = $price; $priceArr[] = array('qty' => $bulkQty, 'price' => $price); for ($i = 1; $i < $total_price_row_added; $i++) { $bulkQty = $this->input->post('bulkQty_' . $i, TRUE); $price = $this->input->post('price_' . $i, TRUE); if ($bulkQty == "" || $price == "") { //echo '$bulkQty= '.$bulkQty.' === $price '.$price;die; $this->session->set_flashdata('Message', 'Please fill the price and relted quanity'); redirect(BASE_URL . 'product/edit_product/' . $enc_pro_id); } if ($this->is_tidiit_commission_updated($productId) == TRUE) { $shippingPrice = $this->calculate_shiiping_price($bulkQty, $weight); $shippingCharges = round($bulkQty * $weight) * $shippingPrice; $tidiitCommissionsPer = $this->get_tidiit_commission($productId); $tidiitCommissions = $price * $tidiitCommissionsPer / 100; $fPrice = $price + $shippingCharges + $tidiitCommissions; $priceArr[] = array('qty' => $bulkQty, 'price' => $fPrice, 'shippingCharges' => $shippingCharges, 'tidiitCommissions' => $tidiitCommissions); } else { $priceArr[] = array('qty' => $bulkQty, 'price' => $price); } } usort($priceArr, 'sortingProductPriceArr'); $newPriceArr = array(); foreach ($priceArr as $k) { $k['productId'] = $productId; $newPriceArr[] = $k; } $this->Product_model->edit_product_price($newPriceArr, $productId); $heighestPrice = $price; $minQty = $priceArr[count($priceArr) - 1]['qty']; $dataArr = array('taxable' => $taxable, 'minQty' => $minQty, 'qty' => $qty, 'length' => $length, 'width' => $width, 'height' => $height, 'lengthClass' => $lengthClass, 'weight' => $weight, 'weightClass' => $weightClass, 'lowestPrice' => $lowestPrice, 'heighestPrice' => $heighestPrice); $ParrentDataArr = $this->Category_model->get_all_parrent_details($categoryId); //pre($ParrentDataArr); if ($ParrentDataArr[0]->secondParentcategoryId == "") { $dataArr['CategoryID1'] = $ParrentDataArr[0]->firstParentcategoryId; $dataArr['CategoryID2'] = $categoryId; } else { $dataArr['CategoryID1'] = $ParrentDataArr[0]->secondParentcategoryId; $dataArr['CategoryID2'] = $ParrentDataArr[0]->firstParentcategoryId; $dataArr['CategoryID3'] = $categoryId; } $dataArr['isNew'] = $this->input->post('isNew') ? $this->input->post('isNew', TRUE) : 0; $dataArr['popular'] = $this->input->post('popular') ? $this->input->post('popular', TRUE) : 0; $dataArr['featured'] = $this->input->post('featured') ? $this->input->post('featured', TRUE) : 0; if (!empty($mobileConnectivity)) { $dataArr['mobileConnectivity'] = implode(',', $mobileConnectivity); } $tag = $retDataArr['data']['tag']; unset($retDataArr['data']['tag']); $mobileDataArr = array_merge($retDataArr['data'], $dataArr); $config['upload_path'] = $this->config->item('ResourcesPath') . 'product/original/'; $config['allowed_types'] = 'jpg|png|jpeg'; $config['file_name'] = strtolower(my_seo_freindly_url($mobileDataArr['title'])) . '-' . rand(1, 9) . '-' . time(); $config['max_size'] = '2047'; $config['max_width'] = '1550'; $config['max_height'] = '1550'; //$config['max_width'] = '1024'; //$config['max_height'] = '1024'; $upload_files = array(); $this->load->library('upload'); //pre($_FILES);die; $blank = 0; foreach ($_FILES as $fieldname => $fileObject) { //fieldname is the form field name //pre($fileObject); if (!empty($fileObject['name'])) { $this->upload->initialize($config); if (!$this->upload->do_upload($fieldname)) { foreach ($upload_files as $k) { @unlink($this->config->item('ResourcesPath') . 'product/original/' . $k); } $errors = $this->upload->display_errors(); //pre($errors);die; $this->session->set_flashdata('Message', $errors); redirect(BASE_URL . 'product/edit_product/' . $enc_pro_id); } else { // Code After Files Upload Success GOES HERE $currgImgNo = substr($fieldname, 3); $oldUploadedFileName = $this->input->post('oldImgFile' . $currgImgNo, TRUE); $this->Product_model->remove_product_by_file($oldUploadedFileName, $productId); $this->delete_product_file($oldUploadedFileName); $data = $this->upload->data(); $this->product_image_resize($data['file_name']); $upload_files[] = $data['file_name']; } } else { if (substr($fieldname, -1) == 1) { $blank++; } } } $this->Product_model->edit($mobileDataArr, $productId); //$productId=1; //echo 'product added done.<br>'; $imageBatchArr = array(); if (!empty($upload_files)) { foreach ($upload_files as $k => $v) { $imageBatchArr[] = array('productId' => $productId, 'image' => $v); } } if (!empty($imageBatchArr)) { //pre($imageBatchArr);die; $this->Product_model->edit_image_product($imageBatchArr, $productId); } //pre($imageBatchArr);die; $productTagArr = array('productId' => $productId, 'tagStr' => $tag); $this->Product_model->edit_product_tag($productTagArr); $this->Product_model->edit_brand(array('brandId' => $brandId), $productId); //Add product option values $this->Option_model->saveOptionsValues($this->input->post('options', TRUE) ? $this->input->post('options', TRUE) : [], $productId); $this->session->set_flashdata('Message', 'Product updated successfully.'); redirect(base_url() . 'product/viewlist'); } } }