From 238e55f8d81e6960a71f873f09883610582ad8f0 Mon Sep 17 00:00:00 2001 From: Jansa Jose <jansa@techware.in> Date: Thu, 23 May 2019 09:42:06 +0530 Subject: [PATCH] dc --- application/controllers/Orders.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ application/controllers/Product.php | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------- application/controllers/Webservices.php | 229 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------- application/models/Order_model.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ application/models/Product_model.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- application/models/Webservice_model.php | 263 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- application/views/Orders/list_orders.php | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ application/views/Product/addproduct.php | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- application/views/Product/viewProduct.php | 10 +++++++--- application/views/Settings/viewSettings.php | 6 +++++- application/views/Templates/left-menu.php | 4 ++++ assets/js/custom-script.js | 291 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 1215 insertions(+), 67 deletions(-) create mode 100644 application/controllers/Orders.php create mode 100644 application/models/Order_model.php create mode 100644 application/views/Orders/list_orders.php diff --git a/application/controllers/Orders.php b/application/controllers/Orders.php new file mode 100644 index 0000000..a8a4610 --- /dev/null +++ b/application/controllers/Orders.php @@ -0,0 +1,45 @@ +<?php +defined('BASEPATH') OR exit('No direct script access allowed'); + +class Orders extends CI_Controller { + + public function __construct() { + parent::__construct(); + date_default_timezone_set("Asia/Kolkata"); + $this->load->model('Order_model'); + + if(!$this->session->userdata('logged_in')) { + redirect(base_url('Login')); + } + } + + public function listOrders(){ + + $template['page'] = 'Orders/list_orders'; + $template['pTitle'] = "View Orders"; + $template['pDescription'] = "View and Manage Orders"; + + $template['menu'] = "Order Management"; + $template['smenu'] = "View Orders"; + + $template['orderData'] = $this->Order_model->getOrders(); + $this->load->view('template',$template); + } + + public function getOrderData(){ + $return_arr = array('status'=>'0'); + if(!isset($_POST) || empty($_POST) || !isset($_POST['order_id']) || empty($_POST['order_id']) || empty(decode_param($_POST['order_id']))){ + echo json_encode($return_arr);exit; + } + $order_id = decode_param($_POST['order_id']); + $return_arr['order_data'] = $this->Order_model->getOrderDetails($order_id); + $return_arr['product_image'] = $this->Order_model->getProductImage($order_id); + + if(!empty($return_arr)){ + $return_arr['status'] = 1; + echo json_encode($return_arr);exit; + } + echo json_encode($return_arr);exit; + } +} +?> \ No newline at end of file diff --git a/application/controllers/Product.php b/application/controllers/Product.php index f9885c2..d779dcc 100644 --- a/application/controllers/Product.php +++ b/application/controllers/Product.php @@ -77,6 +77,15 @@ class Product extends CI_Controller { }else if($err == 0 && (!isset($_POST['amount']) || empty($_POST['amount']))){ $err = 1; $errMsg = 'Provide a Amount'; + }else if($err == 0 && (!isset($_POST['vehYear']) || empty($_POST['vehYear']))){ + $err = 1; + $errMsg = 'Select Vehicle Year'; + }else if($err == 0 && (!isset($_POST['vehMake']) || empty($_POST['vehMake']))){ + $err = 1; + $errMsg = 'Select Vehicle Make'; + }else if($err == 0 && (!isset($_POST['vehModel']) || empty($_POST['vehModel']))){ + $err = 1; + $errMsg = 'Select Vehicle Model'; } if($err == 1){ @@ -121,29 +130,33 @@ class Product extends CI_Controller { } } - public function editproduct($brand_id){ + public function editproduct($product_id){ $flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error'); - if(empty($brand_id) || !is_numeric($brand_id = decode_param($brand_id))){ + if(empty($product_id) || !is_numeric($product_id = decode_param($product_id))){ $this->session->set_flashdata('message',$flashMsg); redirect(base_url('Product/viewProducts')); } - $template['page'] = 'Product/addProducts'; - $template['menu'] = 'brand Management'; + $template['page'] = 'Product/addProduct'; + $template['menu'] = 'Brand Management'; $template['smenu'] = 'Edit brand'; $template['pTitle'] = "Edit brand"; $template['pDescription'] = "Update brand Data"; - $template['brand_id'] = encode_param($brand_id); - $template['brand_data'] = $this->Product_model->getbrand($brand_id,1); + $template['product_id'] = encode_param($product_id); + $template['brand_data'] = $this->Brand_model->getbrand('',1); + $template['product_data'] = $this->Product_model->getProduct($product_id); + $template['product_image'] = $this->Product_model->getProductImage($product_id); + $template['brand_id'] = $template['product_data']->brand_id; + $this->load->view('template',$template); } - public function updateproduct($brand_id = ''){ + public function updateproduct($product_id = ''){ $err = 0; $errMsg = ''; $flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error'); - if(empty($brand_id) || !isset($_POST) || empty($_POST) || !is_numeric(decode_param($brand_id))){ + if(empty($product_id) || !isset($_POST) || empty($_POST) || !is_numeric(decode_param($product_id))){ $this->session->set_flashdata('message',$flashMsg); redirect(base_url('Product/viewProducts')); } @@ -151,23 +164,33 @@ class Product extends CI_Controller { $this->session->set_flashdata('message',$flashMsg); redirect(base_url('Product/addProduct')); } - if($err == 0 && (!isset($_POST['brand_name']) || empty($_POST['brand_name']))){ + if($err == 0 && (!isset($_POST['brand_id']) || empty($_POST['brand_id']))){ $err = 1; - $errMsg = 'Provide a brand Name'; - } - - if($err == 0){ - $config = set_upload_service("assets/uploads/brands"); - $this->load->library('upload'); - $config['file_name'] = time()."_".$_FILES['brand_logo']['name']; - $this->upload->initialize($config); - if(!$this->upload->do_upload('brand_logo')){ - $err = 1; - $errMsg = $this->upload->display_errors(); - }else{ - $upload_data = $this->upload->data(); - $_POST['brand_logo'] = $config['upload_path']."/".$upload_data['file_name']; - } + $errMsg = 'Please Select a Brand'; + }else if($err == 0 && (!isset($_POST['short_description']) || empty($_POST['short_description']))){ + $err = 1; + $errMsg = 'Provide a short Description'; + }else if($err == 0 && (!isset($_POST['product_name']) || empty($_POST['product_name']))){ + $err = 1; + $errMsg = 'Provide a Product Name'; + }else if($err == 0 && (!isset($_POST['description']) || empty($_POST['description']))){ + $err = 1; + $errMsg = 'Provide a Description'; + }else if($err == 0 && (!isset($_POST['about']) || empty($_POST['about']))){ + $err = 1; + $errMsg = 'Provide a About'; + }else if($err == 0 && (!isset($_POST['amount']) || empty($_POST['amount']))){ + $err = 1; + $errMsg = 'Provide a Amount'; + }else if($err == 0 && (!isset($_POST['vehYear']) || empty($_POST['vehYear']))){ + $err = 1; + $errMsg = 'Select Vehicle Year'; + }else if($err == 0 && (!isset($_POST['vehMake']) || empty($_POST['vehMake']))){ + $err = 1; + $errMsg = 'Select Vehicle Make'; + }else if($err == 0 && (!isset($_POST['vehModel']) || empty($_POST['vehModel']))){ + $err = 1; + $errMsg = 'Select Vehicle Model'; } if($err == 1){ @@ -175,9 +198,37 @@ class Product extends CI_Controller { $this->session->set_flashdata('message',$flashMsg); redirect(base_url('Product/addProduct')); } + $existingImages = (isset($_POST['existingImages']) && !empty($_POST['existingImages']))? + $_POST['existingImages']:''; + unset($_POST['existingImages']); + $product = $this->Product_model->updateProduct(decode_param($product_id),$_POST); + if($product){ + $evtMediaData = array(); + if(!empty($files = $_FILES)){ + $images = array(); + $this->load->library('upload'); + $config = set_upload_service("assets/uploads/products"); + for ($typ = 0; $typ < count($files['product_image']['name']); $typ++) { + $_FILES['file']['name'] = $files['product_image']['name'][$typ]; + $_FILES['file']['type'] = $files['product_image']['type'][$typ]; + $_FILES['file']['size'] = $files['product_image']['size'][$typ]; + $_FILES['file']['error'] = $files['product_image']['error'][$typ]; + $_FILES['file']['tmp_name'] = $files['product_image']['tmp_name'][$typ]; + + $config['file_name'] = time()."_".$_FILES['file']['name']; + $this->upload->initialize($config); + if($this->upload->do_upload('file')){ + $imgData = $this->upload->data(); + $evtMediaData[] = array( + 'product_id'=>decode_param($product_id), + 'image'=>"assets/uploads/products/".$imgData['file_name']); + } + } + $status = $this->Product_model->updateProductImage(decode_param($product_id),$evtMediaData,$existingImages); + } + } - $status = $this->Product_model->updateProducts(decode_param($brand_id),$_POST); - if($status == 1){ + if($status || $product){ $flashMsg =array('message'=>'Successfully Updated brand Details..!','class'=>'success'); $this->session->set_flashdata('message', $flashMsg); redirect(base_url('Product/viewProducts')); @@ -187,6 +238,23 @@ class Product extends CI_Controller { } } + public function getProductData(){ + $return_arr = array('status'=>'0'); + if(!isset($_POST) || empty($_POST) || !isset($_POST['product_id']) || empty($_POST['product_id']) || + empty(decode_param($_POST['product_id']))){ + echo json_encode($return_arr);exit; + } + $product_id = decode_param($_POST['product_id']); + $return_arr['product_data'] = $this->Product_model->getProduct($product_id); + $return_arr['product_image'] = $this->Product_model->getProductImage($product_id); + + if(!empty($return_arr)){ + $return_arr['status'] = 1; + echo json_encode($return_arr);exit; + } + echo json_encode($return_arr);exit; + } + } ?> \ No newline at end of file diff --git a/application/controllers/Webservices.php b/application/controllers/Webservices.php index 2613115..2f9faaa 100644 --- a/application/controllers/Webservices.php +++ b/application/controllers/Webservices.php @@ -188,7 +188,7 @@ echo json_encode($respArr); exit; } - // customer_registration + // Service Provider registration public function service_provider_registration(){ header('Content-type: application/json'); $post = file_get_contents("php://input"); @@ -1325,6 +1325,7 @@ echo json_encode($getServices);exit; } + //Mechanic Rating public function rate_mechanic(){ header('Content-type:application/json'); $headers = apache_request_headers(); @@ -1347,6 +1348,7 @@ echo json_encode($result);exit; } + //Accept Mechanic Quote public function acceptMechanicQuote(){ header('Content-type:application/json'); $headers = apache_request_headers(); @@ -1358,15 +1360,45 @@ echo json_encode($result);exit; } - public function payNow($transId) { - $result = array(); - $mech_data = $this->Webservice_model->getMechAmount($transId); - $amount = $mech_data['data']['amount'] * 100; - $callback_url = base_url().'Webservices/verify_payment/'.$transId; - $postdata = array('email' => $mech_data['emailId'], 'amount' => $amount,"reference" => $transId, "callback_url" => $callback_url); + //Payment Integration of Mechanic Booking + public function payNow($transId=''){ + if(empty($transId)){ + $this->fail(); + } + + $mechData = $this->Webservice_model->getMechAmount($transId); + $amount = $mechData['data']['amount'] * 100; + $callback = base_url().'Webservices/verify_payment/'.$transId.'/1'; + $postdata = array('email' => $mechData['emailId'], + 'amount' => $amount, + 'reference' => $transId, + 'callback_url' => $callback); + + $this->payStackPayment($postdata); + } + + //Payment Integration of Order Booking + public function orderPayNow($orderId=''){ + if(empty($orderId)){ + $this->fail(); + } + + $orderData = $this->Webservice_model->getOrderPayDetails($orderId); + if($orderData['status'] == 'success'){ + $amount = $orderData['data']->amount * 100; + $callback = base_url().'Webservices/verify_payment/'.$orderId.'/2'; + $postdata = array('email' => $orderData['data']->email, + 'amount' => $amount, + 'reference' => $orderId, + 'callback_url' => $callback); + $this->payStackPayment($postdata); + } + } + + public function payStackPayment($postdata=array()) { $url = "https://api.paystack.co/transaction/initialize"; - $ch = curl_init(); + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($postdata)); //Post Fields @@ -1378,10 +1410,12 @@ 'Authorization: Bearer '.PAYSTACK_SECRET_KEY, 'Content-Type: application/json', ]; + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $request = curl_exec ($ch); curl_close ($ch); + $result = array(); if ($request) { $result = json_decode($request, true); } @@ -1389,7 +1423,11 @@ header("Location: ".$redir); } - public function verify_payment($ref) { + public function verify_payment($ref='',$payFor='1') { + if(empty($ref)){ + $this->fail(); + } + $result = array(); $url = 'https://api.paystack.co/transaction/verify/'.$ref; $ch = curl_init(); @@ -1406,34 +1444,50 @@ if ($request) { $result = json_decode($request, true); - $status = $this->Webservice_model->transactionResp($ref,$result); + $status = $this->Webservice_model->transactionResp($ref,$result,$payFor); if($status){ if($result){ if($result['data']){ if($result['data']['status'] == 'success'){ - header("Location: ".base_url().'Webservices/success/'.$ref); + header("Location:".base_url('Webservices/success/'.$ref.'/'.$payFor)); }else{ - header("Location: ".base_url().'Webservices/fail/'.$ref); + header("Location:".base_url('Webservices/fail/'.$ref.'/'.$payFor)); } } else{ - header("Location: ".base_url().'Webservices/fail/'.$ref); + header("Location: ".base_url('Webservices/fail/'.$ref.'/'.$payFor)); } }else{ - header("Location: ".base_url().'Webservices/fail/'.$ref); + header("Location: ".base_url('Webservices/fail/'.$ref.'/'.$payFor)); } } }else{ - header("Location: ".base_url().'Webservices/fail/'.$ref); + header("Location: ".base_url('Webservices/fail/'.$ref.'/'.$payFor)); } } - public function fail($ref = ''){ - header("Location: https://carfixxers.com/dashboard?status=failure&tab=appointment&ref=".$ref); + public function fail($ref='',$payFor='1'){ + $settings = getSettings(); + if($payFor == '1'){ + $url = $settings['web_url']."/dashboard?status=failure&tab=appointment&ref=".$ref; + header("Location:".$url); + }else{ + $url = $settings['web_url']."/purchaseHome?status=failure&ref=".$ref; + header("Location:".$url); + } + } + + public function success($ref='',$payFor='1'){ + if($payFor == '1'){ + $this->serviceBookSuccess($ref); + }else{ + $this->orderPlacedSuccess($ref); + } } - public function success($ref = ''){ - $this->db->select('customer_vehicle.car_name,bookings.scheduled_date,bookings.scheduled_time,customers.email,bookings.cost'); + public function serviceBookSuccess($ref=''){ + $this->db->select('customer_vehicle.car_name,bookings.scheduled_date,bookings.scheduled_time, + customers.email,bookings.cost'); $this->db->from('transaction'); $this->db->join('bookings','transaction.booking_id = bookings.booking_id'); $this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id'); @@ -1453,7 +1507,142 @@ $message = str_replace(array('{:car_name}','{:book_date}','{:amount}'),array($bookData->car_name,$bookData->scheduled_date,$bookData->cost),$template['success_booking']); } send_mail($subject,$email_id,$message); - header("Location: https://carfixxers.com/dashboard?status=success&tab=appointment&ref=".$ref); + + $settings = getSettings(); + $url = $settings['web_url']."/dashboard?status=success&tab=appointment&ref=".$ref; + header("Location: ".$url); + } + + public function orderPlacedSuccess($ref=''){ + $settings = getSettings(); + $url = $settings['web_url']."/track?status=success&ref=".$ref; + header("Location: ".$url); + } + + //Search Products + public function productSearch(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + $result = $this->Webservice_model->productSearch($postData); + echo json_encode($result);exit; + } + + //Get Brands + public function getBrands(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + $result = $this->Webservice_model->getBrands(); + echo json_encode($result);exit; + } + + //Search Product By Brand + public function productSearchbyBrand(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->productSearchbyBrand($postData); + echo json_encode($result);exit; + } + + //Single Product Search + public function SingleProductSearch(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->SingleProductSearch($postData); + echo json_encode($result);exit; + } + + //Save User Address + public function saveUserAddress(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->saveUserAddress($postData); + echo json_encode($result);exit; + } + + //Initiate Order Booking + public function initOrderBooking(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->initOrderBooking($postData); + echo json_encode($result);exit; + } + + //Get User Address + public function getUserAddress(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->getUserAddress($postData); + echo json_encode($result);exit; + } + + //Get User Address By Id + public function getUserAddressById(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->getUserAddressById($postData); + echo json_encode($result);exit; + } + + //Update User Address + public function updateUserAddress(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->updateUserAddress($postData); + echo json_encode($result);exit; + } + + //Get Order Details + public function getOrderDetail(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->getOrderDetail($postData); + echo json_encode($result);exit; + } + + public function rateProduct(){ + header('Content-type:application/json'); + $headers = apache_request_headers(); + + $post = file_get_contents("php://input"); + $postData = json_decode($post,true); + + $result = $this->Webservice_model->rateProduct($postData); + echo json_encode($result);exit; } } diff --git a/application/models/Order_model.php b/application/models/Order_model.php new file mode 100644 index 0000000..330c993 --- /dev/null +++ b/application/models/Order_model.php @@ -0,0 +1,53 @@ +<?php +class Order_model extends CI_Model { + + public function _consruct(){ + parent::_construct(); + } + + public function getOrders(){ + $this->db->select("ORD.format_order_id,ORD.quantity,ORD.amount,ORD.status,PRD.product_name,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as customer_name,ORD.order_id"); + $this->db->from('orders AS ORD'); + $this->db->join('products AS PRD','PRD.product_id = ORD.product_id'); + $this->db->join('customers AS CUST','CUST.customer_id = ORD.customer_id'); + $result = $this->db->get()->result(); + if(!empty($result)){ + return $result; + } + } + + public function getOrderDetails($order_id){ + if($order_id == ''){ + return 0; + } + $result = $this->db->query("SELECT ORD.*,PRD.product_name,PRD.short_description,PRDB.brand_name,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as customer_name, + CASE WHEN ORD.status = 0 THEN 'Inactive' + WHEN ORD.status = 1 THEN 'Payment Processing' + WHEN ORD.status = 2 THEN 'Order Places' + WHEN ORD.status = 3 THEN 'Order Packed' + WHEN ORD.status = 4 THEN 'Order Shipped' + WHEN ORD.status = 5 THEN 'Ordered Delivered' + WHEN ORD.status = 6 THEN 'Returned' + WHEN ORD.status = 7 THEN 'Cancelled' + WHEN ORD.status = 8 THEN 'Deleted' + ELSE 'Payment Failed' END AS status + FROM orders AS ORD + JOIN products AS PRD on PRD.product_id = ORD.product_id + JOIN product_brand AS PRDB on PRDB.brand_id = PRD.brand_id + JOIN customers AS CUST on CUST.customer_id = ORD.customer_id + WHERE ORD.order_id = $order_id"); + if(empty($result)){ + return; + } + return $result->row(); + } + + public function getProductImage($order_id){ + $result = $this->db->query("SELECT PRDI.image FROM orders AS ORD join product_images AS PRDI on PRDI.product_id = ORD.product_id WHERE ORD.order_id = $order_id"); + + return (empty($result))?'':$result->result(); + } + + +} +?> diff --git a/application/models/Product_model.php b/application/models/Product_model.php index 3ea6a9d..e6b961a 100644 --- a/application/models/Product_model.php +++ b/application/models/Product_model.php @@ -9,7 +9,17 @@ class Product_model extends CI_Model { if(empty($product_data)){ return 0; } - + $cardata = $this->db->get_where('cardetails',array('year'=>$product_data['vehYear'],'make'=>$product_data['vehMake'],'model'=>$product_data['vehModel']))->row(); + if($cardata){ + $product_data['cardetail_id'] = $cardata->id; + }else{ + $this->db->insert('cardetails',array('year'=>$product_data['vehYear'],'make'=>$product_data['vehMake'],'model'=>$product_data['vehModel'])); + $product_data['cardetail_id'] = $this->db->insert_id(); + } + unset($product_data['vehYear']); + unset($product_data['vehMake']); + unset($product_data['vehModel']); + $status = $this->db->insert('products',$product_data); $last_id = $this->db->insert_id(); return $last_id; @@ -19,7 +29,7 @@ class Product_model extends CI_Model { $cond = ($view_all != 0)?' products.status IN (0,1) ':' products.status IN (1) '; $cond .= (!empty($product_id))?" AND products.product_id = '$product_id'":""; - $result = $this->db->query("SELECT products.*,product_brand.brand_name FROM products join product_brand on product_brand.brand_id = products.brand_id WHERE $cond"); + $result = $this->db->query("SELECT cardetails.make,cardetails.year,cardetails.model,products.*,product_brand.brand_name FROM products join product_brand on product_brand.brand_id = products.brand_id join cardetails on cardetails.id = products.cardetail_id WHERE $cond"); if(empty($result)){ return; } @@ -30,6 +40,7 @@ class Product_model extends CI_Model { if(empty($product_id)){ return 0; } + $this->db->update('product_images',array('status'=>$status),array('product_id'=>$product_id)); $status = $this->db->update('products',array('status'=>$status), array('product_id'=>$product_id)); return $status; } @@ -38,7 +49,16 @@ class Product_model extends CI_Model { if(empty($product_id) || empty($product_data)){ return 0; } - + $cardata = $this->db->get_where('cardetails',array('year'=>$product_data['vehYear'],'make'=>$product_data['vehMake'],'model'=>$product_data['vehModel']))->row(); + if($cardata){ + $product_data['cardetail_id'] = $cardata->id; + }else{ + $this->db->insert('cardetails',array('year'=>$product_data['vehYear'],'make'=>$product_data['vehMake'],'model'=>$product_data['vehModel'])); + $product_data['cardetail_id'] = $this->db->insert_id(); + } + unset($product_data['vehYear']); + unset($product_data['vehMake']); + unset($product_data['vehModel']); $status = $this->db->update('products',$product_data,array('product_id'=>$product_id)); return ($status)?1:0; } @@ -51,5 +71,35 @@ class Product_model extends CI_Model { return ($status)?1:0; } + function updateProductImage($product_id = '', $imagearray = array(), $existingImages = array()){ + if(empty($product_id)){ + return 0; + } + if(!empty($existingImages)){ + $this->db->query("DELETE FROM product_images + WHERE id NOT IN (".implode(",",$existingImages).") AND product_id=$product_id"); + } else { + $this->db->query("DELETE FROM product_images WHERE product_id='$product_id'"); + } + + if(!empty($imagearray)){ + $status = $this->db->insert_batch('product_images',$imagearray); + } + return $status; + } + + + function getProductImage($product_id = ''){ + if(empty($product_id)){ + return 0; + } + $status = $this->db->get_where('product_images',array('product_id'=>$product_id))->result_array(); + return $status; + } + + function getVehdata(){ + return $this->db->get_where('cardetails')->result_array(); + } + } ?> \ No newline at end of file diff --git a/application/models/Webservice_model.php b/application/models/Webservice_model.php index 9b3f41a..e0ada72 100644 --- a/application/models/Webservice_model.php +++ b/application/models/Webservice_model.php @@ -571,16 +571,277 @@ class Webservice_model extends CI_Model { return $respArr; } - public function transactionResp($transId,$result){ + public function transactionResp($transId,$result,$payfor){ $status = 0; if($result['data']['status'] == 'success'){ $status = 1; } + + $odr_status = 9; + if($result['data']['status'] == 'success' && $payfor == '2'){ + $odr_status = 2; + } $this->db->update('transaction',array('transaction_response'=>json_encode($result),'transaction_reference'=>$result['data']['id'],'status'=>$status),array('id'=>$transId)); $bookData = $this->db->get_where('transaction',array('id'=>$transId))->row(); $this->db->update('bookings',array('status'=>'1'),array('booking_id'=>$bookData->booking_id)); + + if($payfor == '2'){ + $this->db->query("UPDATE orders JOIN transaction ON transaction.booking_id = orders.order_id SET orders.status = $odr_status WHERE transaction.id = $transId"); + } return 1; } + + public function productSearch($postData){ + $respArr = array('status'=>'error'); + if(empty($postData)){ + return $respArr; + } + + $per_page = 10; + $page = (isset($data['page']))?$data['page']:'0'; + + $where = ''; + if(isset($postData['key']) && !empty($postData['key'])){ + $where .= " (PRD.product_name LIKE '%".$postData['key']."%' OR + PRD.short_description LIKE '%".$postData['key']."%' OR + PRD.description LIKE '%".$postData['key']."%') AND "; + } + + if(isset($postData['brand_id']) && !empty($postData['brand_id'])){ + $where .= " PRD.brand_id IN (".implode(',',$postData['brand_id']).") AND "; + } + + if(isset($postData['minPrice']) && $postData['minPrice'] != ''){ + $where .= " PRD.amount > ".$postData['minPrice']." AND "; + } + + if(isset($postData['maxPrice']) && $postData['maxPrice'] != ''){ + $where .= " PRD.amount < ".$postData['maxPrice']." AND "; + } + + $result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating, + COUNT(REV.id) AS count,PRD.*,PI.image + FROM products AS PRD + LEFT JOIN product_images AS PI ON + (PI.id=(SELECT MIN(id) + FROM product_images + WHERE product_id= PRD.product_id AND + PRD.status='1')) + LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id + WHERE $where PRD.status='1' + GROUP BY PRD.product_id,PI.product_id + LIMIT $page,$per_page"); + //pr($this->db->last_query()); + if(!empty($result) && $result->num_rows() > 0){ + $respArr['status'] = 'success'; + $respArr['data'] = $result->result_array(); + } + return $respArr; + } + + public function getBrands(){ + $respArr = array('status'=>'error'); + $prdt_brand = $this->db->get_where('product_brand',array('status'=>'1'))->result(); + if(count($prdt_brand) > 0){ + $query = $this->db->query("SELECT MIN(amount) AS minamount, MAX(amount) AS maxamount + FROM products WHERE status='1'")->row(); + $respArr['status'] = 'success'; + $respArr['brands'] = $prdt_brand; + $respArr['minamount'] = $query->minamount; + $respArr['maxamount'] = $query->maxamount; + } + return $respArr; + } + + public function SingleProductSearch($postData){ + $respArr = array('status'=>'error'); + if(empty($postData)){ + return $respArr; + } + + $sql = "SELECT ROUND(AVG(REV.rating),2) AS rating, COUNT(REV.id) AS count,PRD.* + FROM products AS PRD + LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id + WHERE PRD.product_id =".$postData['product_id']; + $this->db->query($sql); + $result = $this->db->query($sql); + if(!empty($result) && $result->num_rows() > 0){ + $respArr['status'] = 'success'; + $respArr['data'] = $result->row(); + $prdt_img = $this->db->get_where('product_images',array('product_id'=>$postData['product_id'],'status'=>'1'))->result(); + $reviews = $this->db->get_where('product_rating',array('product_id'=>$postData['product_id'],'status'=>'1'))->result(); + $respArr['data']->images = ''; + $respArr['data']->reviews = ''; + if(count($prdt_img) > 0){ + $respArr['data']->images = $prdt_img; + } + if(count($reviews) > 0){ + $respArr['data']->reviews = $reviews ; + } + } + return $respArr; + } + + public function saveUserAddress($postData = array()){ + $respArr = array('status'=>'error','message'=>'Something Went Wrong.. Try Again Later'); + if(empty($postData)){ + $respArr['message'] = 'All Field is required'; + return $respArr; + } + + if($this->db->insert('customer_address',$postData)){ + $respArr['status'] = "success"; + $respArr['message'] = "Address Added Successfully"; + } + return $respArr; + } + + public function getUserAddress($postData){ + $respArr = array('status'=>'error'); + if(empty($postData['user_id'])){ + $respArr['message'] = 'User Id is required'; + return $respArr; + } + + $result = $this->db->get_where('customer_address',array('customer_id'=>$postData['user_id'],'status'=>'1')); + if(!empty($result) && !empty($result = $result->result())){ + $respArr['status'] = 'success'; + $respArr['data'] = $result; + } + return $respArr; + } + + public function getUserAddressById($postData){ + $respArr = array('status'=>'error'); + if(empty($postData['address_id'])){ + $respArr['message'] = 'Address Id is required'; + return $respArr; + } + if(empty($postData['customer_id'])){ + $respArr['message'] = 'Customer Id is required'; + return $respArr; + } + + $result = $this->db->get_where('customer_address',array('id'=>$postData['address_id'],'customer_id'=>$postData['customer_id'])); + if(!empty($result) && !empty($result = $result->row())){ + $respArr['status'] = 'success'; + $respArr['data'] = $result; + } + return $respArr; + } + + public function updateUserAddress($postData){ + $respArr = array('status'=>'error'); + if(empty($postData['data'])){ + $respArr['message'] = 'All Field is required'; + return $respArr; + } + + if(empty($postData['address_id'])){ + $respArr['message'] = 'Address Id is required'; + return $respArr; + } + + if($this->db->update('customer_address',$postData['data'],array('id'=>$postData['address_id']))){ + $respArr['status'] = 'success'; + $respArr['message'] = 'Address Updated Successfully'; + } + return $respArr; + } + + public function initOrderBooking($postData=array()){ + $respArr = array('status'=>'error'); + if(empty($postData['data'])){ + $respArr['message'] = 'All Field is required'; + return $respArr; + } + + $squence = str_pad(rand(1111,9999),4,0,STR_PAD_LEFT); + + $insert_array = array( + 'format_order_id'=>'ORD'.date('ymd').$squence, + 'product_id'=>$postData['data']['product_id'], + 'customer_id'=>$postData['data']['customer_id'], + 'address_id'=>$postData['data']['address_id'], + 'quantity'=>$postData['data']['quantity'], + 'amount'=>$postData['data']['total_amount'] + ); + $this->db->insert('orders',$insert_array); + $insert_id = $this->db->insert_id(); + + $this->db->insert('transaction',array( + 'customer_id'=>$postData['data']['customer_id'], + 'booking_id'=>$insert_id, + 'payment_for'=>'2', + 'datetime'=>date('Y-m-d h:i:s'), + 'amount'=>$postData['data']['total_amount'] + )); + $last_id = $this->db->insert_id(); + $respArr['status'] = 'success'; + $respArr['data'] = $last_id; + return $respArr; + } + + public function getOrderPayDetails($orderId){ + $respArr = array('status'=>'error'); + if(empty($orderId)){ + $respArr['message'] = 'Order Id is required'; + return $respArr; + } + + $result = $this->db->query("SELECT TRANS.amount,CUST.email + FROM transaction TRANS + LEFT JOIN customers CUST + ON CUST.customer_id = TRANS.customer_id + WHERE TRANS.id = $orderId" + ); + if(!empty($result) && !empty($result = $result->row())){ + $this->db->query("UPDATE orders JOIN transaction ON transaction.booking_id = orders.order_id SET orders.status = '1' WHERE transaction.id = $orderId"); + + $respArr['status'] = 'success'; + $respArr['data'] = $result; + } + return $respArr; + } + + public function getOrderDetail($postData){ + $respArr = array('status'=>'error'); + if(empty($postData['ref_id'])){ + $respArr['message'] = 'Transaction Id is required'; + return $respArr; + } + + $result = $this->db->query("SELECT TRANS.datetime,TRANS.amount,TRANS.status,PRD.product_id, + PRD.product_name,PRD.short_description,ORDS.format_order_id,ORDS.quantity,ORDS.expected_delivery,ORDS.delivered,ORDS.status AS odr_status + FROM transaction TRANS + JOIN orders ORDS ON ORDS.order_id = TRANS.booking_id + JOIN products PRD ON PRD.product_id = ORDS.product_id + WHERE TRANS.id =".$postData['ref_id']); + if(!empty($result) && !empty($result = $result->row())){ + $prdt_img = $this->db->get_where('product_images',array('product_id'=>$result->product_id))->result(); + $result->images = ''; + if(count($prdt_img) > 0){ + $result->images = $prdt_img; + } + $respArr['status'] = 'success'; + $respArr['data'] = $result; + } + return $respArr; + } + + public function rateProduct($postData=array()){ + $respArr = array('status'=>'error'); + if(empty($postData)){ + $respArr['message'] = 'All Field is required'; + return $respArr; + } + $postData['datetime'] = date('Y-m-d h:i:s'); + if($this->db->insert('product_rating',$postData)){ + $respArr['status'] = 'success'; + $respArr['message'] = 'Rated Successfully'; + } + return $respArr; + } } ?> diff --git a/application/views/Orders/list_orders.php b/application/views/Orders/list_orders.php new file mode 100644 index 0000000..12ec532 --- /dev/null +++ b/application/views/Orders/list_orders.php @@ -0,0 +1,83 @@ +<div class="content-wrapper"> + <section class="content-header"> + <h1> + <?= $pTitle ?> + <small><?= $pDescription ?></small> + </h1> + <ol class="breadcrumb"> + <li><a href="<?= base_url() ?>"><i class="fa fa-star-o" aria-hidden="true"></i>Home</a></li> + <li><?= $menu ?></li> + <li class="active"><?= $smenu ?></li> + </ol> + </section> + <section class="content"> + <div class="row"> + <div class="col-sm-12"> + <?php if($this->session->flashdata('message')) { + $flashdata = $this->session->flashdata('message'); ?> + <div class="alert alert-<?= $flashdata['class'] ?>"> + <button class="close" data-dismiss="alert" type="button">×</button> + <?= $flashdata['message'] ?> + </div> + <?php } ?> + </div> + <div class="col-xs-12"> + <div class="box box-warning"> + <div class="box-body"> + <table id="mechanicUsers" class="table table-bordered table-striped datatable "> + <thead> + <tr> + <th class="hidden">ID</th> + <th width="12%;">Order ID</th> + <th width="18%;">Product</th> + <th width="14%;">Customer</th> + <th width="9%;">Quantity</th> + <th width="9%;">Amount</th> + <th width="18%;">Status</th> + <th width="20%;">Action</th> + </tr> + </thead> + <tbody> + <?php if(!empty($orderData)){ + foreach($orderData as $odrData) { ?> + <tr> + <th class="hidden"><?= $odrData->order_id ?></th> + <th class="center"><?= $odrData->format_order_id ?></th> + <th class="center"><?= $odrData->product_name ?></th> + <th class="center"><?= $odrData->customer_name ?></th> + <th class="center"><?= $odrData->quantity ?></th> + <th class="center"><?= $odrData->amount ?></th> + <th class="center"> + <?php + switch($odrData->status){ + case 0: echo 'Inactive'; break; + case 1: echo 'Payment Processing'; break; + case 2: echo 'Order Places'; break; + case 3: echo 'Order Packed'; break; + case 4: echo 'Order Shipped'; break; + case 5: echo 'Ordered Delivered'; break; + case 6: echo 'Returned'; break; + case 7: echo 'Cancelled'; break; + case 8: echo 'Deleted'; break; + case 9: echo 'Payment Failed'; break; + } + ?> + </th> + <td class="center"> + <a class="btn btn-sm btn-info" id="viewOrderDetails" + order_id="<?= encode_param($odrData->order_id) ?>"> + <i class="fa fa-fw fa-eye"></i>View + </a> + + <a class="btn btn-sm btn-success" id="changeOrderStatus" style="background-color:#ac2925" order_id="<?= encode_param($odrData->order_id) ?>"><i class="fa fa-cog"></i>Change Status</a> + </td> + </tr> + <?php } }?> + </tbody> + </table> + </div> + </div> + </div> + </div> + </section> +</div> \ No newline at end of file diff --git a/application/views/Product/addproduct.php b/application/views/Product/addproduct.php index bc4fe32..580cfe4 100644 --- a/application/views/Product/addproduct.php +++ b/application/views/Product/addproduct.php @@ -14,7 +14,7 @@ <div class="row"> <div class="col-md-12"> <?php - $url = (!isset($product_id) || empty($product_id))?'Product/createproduct':'Product/updateproduct/'.$mechanic_id; + $url = (!isset($product_id) || empty($product_id))?'Product/createproduct':'Product/updateproduct/'.$product_id; if($this->session->flashdata('message')) { $flashdata = $this->session->flashdata('message'); ?> <div class="alert alert-<?= $flashdata['class'] ?>"> @@ -52,8 +52,8 @@ <div class="form-group"> <label>Short Description</label> <textarea type="text" class="form-control required" data-parsley-trigger="change" - data-parsley-minlength="2" name="short_description" required="" value="<?= (isset($user_data->username))?$user_data->username:'' ?>" - data-parsley-pattern="^[a-zA-Z0-9\ . _ @ \/]+$" placeholder="Enter Short Description"></textarea> + data-parsley-minlength="2" name="short_description" required="" value="<?= (isset($product_data->short_description))?$product_data->short_description:'' ?>" + data-parsley-pattern="^[a-zA-Z0-9\ . _ @ \/]+$" placeholder="Enter Short Description"><?= (isset($product_data->short_description))?$product_data->short_description:'' ?></textarea> <span class="glyphicon form-control-feedback"></span> </div> </div> @@ -61,13 +61,13 @@ <div class="form-group"> <label>Product Name</label> <input type="text" class="form-control required" data-parsley-trigger="change" data-parsley-minlength="2" name="product_name" required="" - placeholder="Enter Product Name" value="<?= (isset($user_data->display_name))?$user_data->display_name:'' ?>"> + placeholder="Enter Product Name" value="<?= (isset($product_data->product_name))?$product_data->product_name:'' ?>"> <span class="glyphicon form-control-feedback"></span> </div> <div class="form-group"> <label>Amount</label> <input type="text" class="form-control required" data-parsley-trigger="change" - data-parsley-minlength="2" name="amount" required="" value="<?= (isset($user_data->username))?$user_data->username:'' ?>" + data-parsley-minlength="2" name="amount" required="" value="<?= (isset($product_data->amount))?$product_data->amount:'' ?>" data-parsley-pattern="^[0-9\ . \/]+$" placeholder="Enter Amount"> <span class="glyphicon form-control-feedback"></span> </div> @@ -82,28 +82,124 @@ <div class="form-group"> <label>Product Images</label> <div id="multipleImageInputCntr"> - <div class="dropZoneContainer" id="multiImageCntr_1" count="1"> - <div id="multiImageClose_1" class="close_custom hide" onclick="removeImage('1');">×</div> - <input id="product_image_1" type="file" name="product_image[]" accept="image/*" class="multiFileUpload" onchange="setMultiImg(this,jQuery(this));" count="1" /> - <img class="multiDropZoneOverlay" id="multiImageImg_1" src="<?=base_url("assets/images/add-image.png")?>" /> + <?php + $count = 1; + if(isset($product_image) && !empty($product_image)){ + foreach($product_image AS $photos){ ?> + <div class="dropZoneContainer" id="multiImageCntr_<?= $count ?>"> + <input type="hidden" name="existingImages[]" value="<?= $photos['id'] ?>"> + <div id="multiImageClose_<?= $count ?>" class="close_custom cpoint" + onclick="removeImage('<?= $count ?>');">×</div> + <input disabled type="file" name="product_image[]" class="multiFileUpload" + accept="image/*" onchange="setMultiImg(this,jQuery(this));" + count="<?= $count ?>" /> + <img class="multiDropZoneOverlay" id="multiImageImg_<?= $count ?>" + src="<?= base_url($photos['image']) ?>" onerror="this.src='<?=base_url("assets/images/add-image.png")?>';" /> + </div> + <?php + $count += 1; + } + } + ?> + <div class="dropZoneContainer" id="multiImageCntr_<?= $count ?>"> + <div id="multiImageClose_<?= $count ?>" class="close_custom cpoint hide" + onclick="removeImage('<?= $count ?>');">×</div> + <input type="file" name="product_image[]" class="multiFileUpload" accept="image/*" + onchange="setMultiImg(this,jQuery(this));" count="<?= $count ?>" /> + <img class="multiDropZoneOverlay" id="multiImageImg_<?= $count ?>" + src="<?=base_url("assets/images/add-image.png")?>" /> </div> </div> </div> </div> - <div class="col-md-6"> + + <div class="col-md-12"> + <div class="box-header with-border padUnset"> + <h3 class="box-title">Product Details</h3> + </div><br> + </div> + + <div class="form-group"> + <div class="col-md-4"> + <label>Vehicle Model Year</label> + <select name="vehYear" class="form-control required" input="search_params" + data-parsley-trigger="change" required=""> + <option selected disabled value="">Choose Vehicle Model Year</option> + <?php + for($year=date('Y'); $year>=1950; $year--){ + $cond = (isset($product_data) && isset($product_data->year) && + !empty($product_data->year) && + $product_data->year == $year)?'selected':''; + echo '<option '.$cond.' value="'.$year.'">'.$year.'</option>'; + } + ?> + </select> + </div> + <div class="col-md-4"> + <label>Vehicle Make</label> + <select name="vehMake" class="form-control required" input="search_params" + data-parsley-trigger="change" required=""> + <option selected disabled value="">Choose Vehicle Make</option> + <option <?= ($product_data->make == 'Toyota') ? 'selected' : ''?> value="Toyota">Toyota</option> + <option <?= ($product_data->make == 'Alto') ? 'selected' : ''?> value="Alto">Alto</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Hyundai') ? 'selected' : ''?> value="Hyundai">Hyundai</option> + <option <?= ($product_data->make == 'Ford') ? 'selected' : ''?> value="Ford">Ford</option> + <option <?= ($product_data->make == 'Ford') ? 'selected' : ''?> value="Ford">Ford</option> + <option <?= ($product_data->make == 'Honda') ? 'selected' : ''?> value="Honda">Honda</option> + <option <?= ($product_data->make == 'Honda') ? 'selected' : ''?> value="Honda">Honda</option> + <option <?= ($product_data->make == 'Honda') ? 'selected' : ''?> value="Honda">Honda</option> + </select> + </div> + <div class="col-md-4"> + <label>Vehicle Model</label> + <select name="vehModel" class="form-control required" input="search_params" + data-parsley-trigger="change" required=""> + <option selected="" disabled="" value="">Choose Vehicle Model</option> + <option <?= ($product_data->model == 'Corolla') ? 'selected' : ''?> value="Corolla">Corolla</option> + <option <?= ($product_data->model == '800') ? 'selected' : ''?> value="800">800</option> + <option <?= ($product_data->model == 'Eon') ? 'selected' : ''?>value="Eon">Eon</option> + <option <?= ($product_data->model == 'Eon') ? 'selected' : ''?> value="Eon">Eon</option> + <option <?= ($product_data->model == 'i10') ? 'selected' : ''?> value="i10">i10</option> + <option <?= ($product_data->model == 'i20') ? 'selected' : ''?> value="i20">i20</option> + <option <?= ($product_data->model == 'i10 Grand') ? 'selected' : ''?>value="i10 Grand">i10 Grand</option> + <option <?= ($product_data->model == 'i20 Grand') ? 'selected' : ''?> value="i20 Grand">i20 Grand</option> + <option <?= ($product_data->model == 'i10 Magna') ? 'selected' : ''?> value="i10 Magna">i10 Magna</option> + <option <?= ($product_data->model == 'i20 Magna') ? 'selected' : ''?> value="i20 Magna">i20 Magna</option> + <option <?= ($product_data->model == 'Sonata') ? 'selected' : ''?> value="Sonata">Sonata</option> + <option <?= ($product_data->model == 'Creta') ? 'selected' : ''?> value="Creta">Creta</option> + <option <?= ($product_data->model == 'Aspair') ? 'selected' : ''?> value="Aspair">Aspair</option> + <option <?= ($product_data->model == 'Eco-sport') ? 'selected' : ''?> value="Eco-sport">Eco-sport</option> + <option <?= ($product_data->model == 'City') ? 'selected' : ''?> value="City">City</option> + <option <?= ($product_data->model == 'Amaze') ? 'selected' : ''?> value="Amaze">Amaze</option> + <option <?= ($product_data->model == 'Sonata') ? 'selected' : ''?> value="Sonata">Sonata</option> + </select> + </div> + </div> + + <div class="col-md-6 padTop20"> <div class="form-group"> <label>Product Description</label> <textarea id="rich_editor" type="text" class="ip_reg_form_input form-control reset-form-custom" placeholder="Product Description" name="description" - style="height:108px;" data-parsley-trigger="change" data-parsley-minlength="2"></textarea> + style="height:108px;" data-parsley-trigger="change" data-parsley-minlength="2"><?= (isset($product_data->description))?$product_data->description:'' ?></textarea> </div> </div> - <div class="col-md-6"> + <div class="col-md-6 padTop20"> <div class="form-group"> <label>About</label> <textarea id="rich_editor1" type="text" class="ip_reg_form_input form-control reset-form-custom" placeholder="About" name="about" - style="height:108px;" data-parsley-trigger="change" data-parsley-minlength="2"></textarea> + style="height:108px;" data-parsley-trigger="change" data-parsley-minlength="2"><?= (isset($product_data->about))?$product_data->about:'' ?></textarea> </div> </div> + <div class="col-md-12"> <div class="box-footer textCenterAlign"> <button id="addProductButton" type="submit" class="btn btn-primary">Submit</button> diff --git a/application/views/Product/viewProduct.php b/application/views/Product/viewProduct.php index 7c832b4..4a9212d 100644 --- a/application/views/Product/viewProduct.php +++ b/application/views/Product/viewProduct.php @@ -42,7 +42,7 @@ <th width="150px;">Short Description</th> <th width="150px;">Amount</th> <th width="100px;">Status</th> - <!-- <th width="300px;">Action</th> --> + <th width="300px;">Action</th> </tr> </thead> <tbody> @@ -56,7 +56,11 @@ <th class="center"><?= $product->short_description ?></th> <th class="center"><?= $product->amount ?></th> <th class="center"><?= ($product->status == 1)?'Active':'De-activate' ?></th> - <!-- <td class="center"> + <td class="center"> + <a class="btn btn-sm btn-info" id="viewProductDetails" + product_id="<?= encode_param($product->product_id) ?>"> + <i class="fa fa-fw fa-eye"></i>View + </a> <a class="btn btn-sm btn-primary" href="<?= base_url('Product/editproduct/'.encode_param($product->product_id)) ?>"> <i class="fa fa-fw fa-edit"></i>Edit @@ -66,7 +70,7 @@ onClick="return doconfirm()"> <i class="fa fa-fw fa-trash"></i>Delete </a> - </td> --> + </td> </tr> <?php } } ?> </tbody> diff --git a/application/views/Settings/viewSettings.php b/application/views/Settings/viewSettings.php index c76219b..b366b60 100644 --- a/application/views/Settings/viewSettings.php +++ b/application/views/Settings/viewSettings.php @@ -92,10 +92,14 @@ </div> </div> <div class="row"> - <div class="form-group col-xs-3"> + <div class="form-group col-xs-4"> <label>Vin Audit API</label> <input type="text" name="vin_audit_api" class="form-control required" placeholder="Enter Vin Audit API" value="<?= $data['vin_audit_api'] ?>"> </div> + <div class="form-group col-xs-3"> + <label>Web Url</label> + <input type="text" name="web_url" class="form-control required" placeholder="Enter Web Url" value="<?= $data['web_url'] ?>"> + </div> </div> </div> <div class="box-footer" style="padding-left:46%"> diff --git a/application/views/Templates/left-menu.php b/application/views/Templates/left-menu.php index 5bdb456..0fc1cd1 100644 --- a/application/views/Templates/left-menu.php +++ b/application/views/Templates/left-menu.php @@ -127,6 +127,10 @@ <a href="<?= base_url('Bookings/listBookings') ?>"><i class="fa fa-book" aria-hidden="true"> </i><span>Request Management</span></a> </li> + <li> + <a href="<?= base_url('Orders/listOrders') ?>"><i class="fa fa-book" aria-hidden="true"> + </i><span>Order Management</span></a> + </li> <li class="treeview"> <a href="#"> <i class="fa fa-bars" aria-hidden="true"></i> diff --git a/assets/js/custom-script.js b/assets/js/custom-script.js index 3f3d8fc..6cbdb57 100644 --- a/assets/js/custom-script.js +++ b/assets/js/custom-script.js @@ -1237,4 +1237,295 @@ jQuery('[id="addProductButton"]').on('click',function(event) { if(validation && error == 0){ jQuery('[name="productAddForm"]').submit(); } +}); + +jQuery('[id="viewProductDetails"]').on('click',function() { + var product_id = jQuery(this).attr('product_id'); + + if(product_id=='' || product_id==undefined || product_id=='undefined' || product_id==null || product_id=='null'){ + return true; + } + + modalTrigger('Product Details',''); + addModalLoader(); + jQuery.ajax({ + url : base_url+"Product/getProductData", + type : 'POST', + data : {'product_id':product_id,'view_all':'1'}, + success: function(resp){ + if(resp == '' || resp == undefined || resp == 'undefined' || resp == null || resp == 'null'){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + return false; + } + var resp_data = jQuery.parseJSON(resp); + console.log(resp_data); + if(resp_data['status'] == '0'){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + return false; + } + var html = '', + imgCount = 0, + optionalHtml = ''; + + if(resp_data.product_image.length > 0){ + optionalHtml = '<div class="col-md-12" style="padding-top:20px;">'+ + '<div class="row"><label>Product Images</label></div>'; + + optionalHtml += '<div class="row">'+ + '<div class="col-md-2">Images</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-9">'; + + jQuery.each(resp_data.product_image, function (index, image) { + console.log(image.image); + imgCount += 1; + optionalHtml += '<img id="optionalImage_'+imgCount+'" src="'+base_url+image.image+'" height="100" width="100" /> '; + }); + optionalHtml += '</div>'; + optionalHtml += '</div>'; + } + + html = '<div class="col-xs-12">'+ + '<div class="row"><label>Product Details</label></div>'+ + '<div class="col-md-6">'+ + '<div class="row">'+ + '<div class="col-md-4">Brand Name</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.product_data.brand_name+'</label></div>'+ + '</div> '+ + '<div class="row">'+ + '<div class="col-md-4">Product Name</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.product_data.product_name+'</label></div>'+ + '</div> '+ + '</div>'+ + '<div class="col-md-6">'+ + '<div class="row"> '+ + '<div class="col-md-4">Amount</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.product_data.amount+'</label></div>'+ + '</div> '+ + '<div class="row"> '+ + '<div class="col-md-4">Short Description</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.product_data.short_description+'</label></div> '+ + '</div> '+ + '</div> '+ + '<div class="col-md-12"> '+ + '<br>'+ + '<div class="row"><label>Product Description</label></div>'+ + '<div class="row"> '+ + '<div class="col-md-2">Description</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-9"><label>'+resp_data.product_data.description+'</label></div> '+ + '</div> '+ + '</div> '+ + '<div class="col-md-12"> '+ + '<br>'+ + '<div class="row"><label>About Product</label></div>'+ + '<div class="row"> '+ + '<div class="col-md-2">Description</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-9"><label>'+resp_data.product_data.about+'</label></div> '+ + '</div> '+ + '</div> '+ + optionalHtml+ + '</div>'; + + remModalLoader(); + jQuery('[id="modal_content"]').html(html); + + jQuery('[id^="optionalImage_"]').error(function() { + jQuery('[id^="optionalImage_"]').attr('src',base_url+'assets/images/no_image_text.png'); + }); + }, + fail: function(xhr, textStatus, errorThrown){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + }, + error: function (ajaxContext) { + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + } + }); +}); + + +jQuery('[id="viewOrderDetails"]').on('click',function() { + var order_id = jQuery(this).attr('order_id'); + + if(order_id=='' || order_id==undefined || order_id=='undefined' || order_id==null || order_id=='null'){ + return true; + } + + modalTrigger('Order Details',''); + addModalLoader(); + jQuery.ajax({ + url : base_url+"Orders/getOrderData", + type : 'POST', + data : {'order_id':order_id,'view_all':'1'}, + success: function(resp){ + if(resp == '' || resp == undefined || resp == 'undefined' || resp == null || resp == 'null'){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + return false; + } + var resp_data = jQuery.parseJSON(resp); + if(resp_data['status'] == '0'){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + return false; + } + var html = '', + imgCount = 0, + optionalHtml = ''; + + if(resp_data.product_image.length > 0){ + optionalHtml = '<div class="col-md-12" style="padding-top:20px;">'+ + '<div class="row"><label>Product Images</label></div>'; + + optionalHtml += '<div class="row">'+ + '<div class="col-md-12">'; + + jQuery.each(resp_data.product_image, function (index, image) { + imgCount += 1; + optionalHtml += '<img id="optionalImage_'+imgCount+'" src="'+base_url+image.image+'" height="100" width="100" /> '; + }); + optionalHtml += '</div>'; + optionalHtml += '</div>'; + } + + html = '<div class="col-xs-12">'+ + '<div class="row"><label>Order Details</label></div>'+ + '<div class="col-md-6">'+ + '<div class="row">'+ + '<div class="col-md-4">Order Id</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.format_order_id+'</label></div>'+ + '</div> '+ + '<div class="row">'+ + '<div class="col-md-4">Customer Name</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.customer_name+'</label></div>'+ + '</div> '+ + '<div class="row">'+ + '<div class="col-md-4">Product Name</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.product_name+'</label></div>'+ + '</div> '+ + '<div class="row">'+ + '<div class="col-md-4">Quantity</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.quantity+'</label></div>'+ + '</div> '+ + '</div>'+ + '<div class="col-md-6">'+ + '<div class="row"> '+ + '<div class="col-md-4">Brand Name</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.brand_name+'</label></div>'+ + '</div> '+ + '<div class="row"> '+ + '<div class="col-md-4">Short Description</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.short_description+'</label></div> '+ + '</div> '+ + '<div class="row"> '+ + '<div class="col-md-4">Amount</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.amount+'</label></div> '+ + '</div> '+ + '<div class="row"> '+ + '<div class="col-md-4">Status</div>'+ + '<div class="col-md-1">:</div>'+ + '<div class="col-md-6"><label>'+resp_data.order_data.status+'</label></div> '+ + '</div> '+ + '</div> '+ + optionalHtml+ + '</div>'; + + remModalLoader(); + jQuery('[id="modal_content"]').html(html); + + jQuery('[id^="optionalImage_"]').error(function() { + jQuery('[id^="optionalImage_"]').attr('src',base_url+'assets/images/no_image_text.png'); + }); + }, + fail: function(xhr, textStatus, errorThrown){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + }, + error: function (ajaxContext) { + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + } + }); +}); + +jQuery('[id="changeOrderStatus"]').on('click',function() { + var order_id = jQuery(this).attr('order_id'); + + if(order_id=='' || order_id==undefined || order_id=='undefined' || order_id==null || order_id=='null'){ + return true; + } + + modalTrigger('Change Order Detail Status',''); + addModalLoader(); + jQuery.ajax({ + url : base_url+"Orders/changeOrderStatus", + type : 'POST', + data : {'order_id':order_id,'view_all':'1'}, + success: function(resp){ + if(resp == '' || resp == undefined || resp == 'undefined' || resp == null || resp == 'null'){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + return false; + } + + var resp_data = jQuery.parseJSON(resp); + if(resp_data['status'] == '0'){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + return false; + } + var html = '', + imgCount = 0, + optionalHtml = ''; + + if(issues_selected != ''){ + var comma = ''; + issueHtml += '<form id="customQuote" role="form" method="post">'+ + '<div class="col-md-12" style="padding-top:10px">'+ + '<div class="col-md-3"><div class="row"><label>Selected Issue</label></div></div>'+ + '<div class="col-md-6"><div class="row"><label>Description</label></div></div>'+ + '<div class="col-md-3"><div class="row"><label>Amount</label></div></div>'+ + '<div class="row">'+ + '</div>'+ + '</div>'+ + '<div class="col-md-12">'+ + '<div class="box-footer textCenterAlign">'+ + '<button type="button" onclick="submitCustQuote(event);" class="btn btn-primary">Submit</button>'+ + '</div>'+ + '</div>'+ + '</form>'; + } + + remModalLoader(); + jQuery('[id="modal_content"]').html(html); + + jQuery('[id^="optionalImage_"]').error(function() { + jQuery('[id^="optionalImage_"]').attr('src',base_url+'assets/images/no_image_text.png'); + }); + }, + fail: function(xhr, textStatus, errorThrown){ + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + }, + error: function (ajaxContext) { + remModalLoader(); + jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!'); + } + }); }); \ No newline at end of file -- libgit2 0.27.1