Commit f9f7a779 by Tobin

Merge branch 'master' into 'dev_production'

Master See merge request !51
parents 0d22429b f4f71a89
......@@ -98,7 +98,6 @@ class Bookings extends CI_Controller {
echo json_encode($return_arr);exit;
}
$custom_booking_id = decode_param($_POST['custom_id']);
// print_r($custom_booking_id);exit();
$CustData = $this->Booking_model->getCustomData($custom_booking_id);
if(!empty($CustData)){
$return_arr['status'] = 1;
......@@ -107,5 +106,60 @@ class Bookings extends CI_Controller {
}
echo json_encode($return_arr);exit;
}
public function exportBookingData($mechanic_id = ''){
$bookingData = $this->Booking_model->getMechBookings($mechanic_id,'','0,1,3,4');
if(empty($bookingData)){
return;
}
$header = array('Booking ID','Name','Current Milage','Service Free','Scheduled Date','Scheduled Time','Customer Phone','Customer Mail','Car Name','Car Model','Car Model Year','Car Location','Selected Issue','Status','Mechanic Name');
$file = 'bookData_'.time().'.csv';
$fpoint = fopen('php://memory', 'w');
fputcsv($fpoint, $header, ',');
foreach($bookingData AS $mechanic){
$new = array();
$bookData = $this->Booking_model->getMechBookings($mechanic_id,$mechanic->booking_id,'0,1,3,4');
foreach (json_decode($bookData->issues_selected) as $key => $value) {
$new[] = $value->issue_category;
}
$status = 'Pending';
switch ($bookData->status) {
case '0': $status = 'Pending';break;
case '1': $status = 'Accepted ';break;
case '2': $status = 'Deleted';break;
case '3': $status = 'Completed';break;
case '4': $status = 'Cancelled';break;
case '5': $status = 'Payment Processing';break;
}
$data = array();
$data[] = $mechanic->booking_id;
$data[] = $bookData->custFirstName.' '.$mechanic->custLastName;
$data[] = $mechanic->mileage;
$data[] = $bookData->cost;
$data[] = $bookData->scheduled_date;
$data[] = $bookData->scheduled_time;
$data[] = $bookData->phone;
$data[] = $bookData->email;
$data[] = $bookData->car_model.' '.$bookData->car_maker.' '.$bookData->car_model_year;
$data[] = $bookData->car_maker;
$data[] = $bookData->car_model_year;
$data[] = $bookData->car_location;
$data[] = implode(',',$new);
$data[] = $status;
if($bookData->status == '1'){
$data[] = $bookData->mechanic_data[0]->first_name.' '.$bookData->mechanic_data[0]->last_name;
}
fputcsv($fpoint, $data, ',');
}
fseek($fpoint, 0);
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $file . '";');
fpassthru($fpoint);
}
}
?>
\ No newline at end of file
......@@ -155,6 +155,33 @@ class Brand extends CI_Controller {
}
}
// public function import_data(){
// $template['page'] = 'Brand/importdata';
// $template['menu'] = 'brand Management';
// $template['smenu'] = 'Edit brand';
// $template['pTitle'] = "Edit brand";
// $template['brand_id'] = '';
// $template['pDescription'] = "Update brand Data";
// $this->load->view('template',$template);
// }
// public function importCsvData(){
// $filename=$_FILES["brand_logo"]["name"];
// $ext=pathinfo($filename, PATHINFO_EXTENSION);
// if($ext=="csv")
// {
// $file = fopen($filename, "r");
// while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
// {
// $sql = "INSERT into import(product_id,name,brand_name,short_description,part_id,vehicle_model,amount,status) values('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]','$emapData[7]')";
// $this->db->query($sql);
// }
// fclose($file);
// echo "CSV File has been successfully Imported.";
// }
// }
}
?>
\ No newline at end of file
......@@ -7,6 +7,7 @@ class Customer extends CI_Controller {
parent::__construct();
date_default_timezone_set("Asia/Kolkata");
$this->load->model('Customer_model');
$this->load->model('Vehicle_model');
if(!$this->session->userdata('logged_in')) {
redirect(base_url('Login'));
......@@ -25,7 +26,8 @@ class Customer extends CI_Controller {
$template['menu'] = "Customer Management";
$template['smenu'] = "Add Customer";
$template['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1);
$template['veh_data']['model'] = $this->Vehicle_model->getVehModel('',1);
$this->load->view('template',$template);
}
......@@ -171,6 +173,8 @@ class Customer extends CI_Controller {
$template['pTitle'] = "Edit Customer";
$template['customer_id'] = $customer_id;
$template['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1);
$template['veh_data']['model'] = $this->Vehicle_model->getVehModel('',1);
$customer_id = decode_param($customer_id);
$template['customer_data']=$this->Customer_model->getCustomer(array('customer_id'=>$customer_id));
......@@ -248,5 +252,44 @@ class Customer extends CI_Controller {
redirect(base_url('Customer/editCustomer/'.$customer_id));
}
public function exportCustomerData(){
$custData = $this->Customer_model->getCustomer();
if(empty($custData)){
return;
}
$header = array('ID','Name','Phone','Email','Address','Date Of Birth','Status','Cars');
$file = 'custData_'.time().'.csv';
$fpoint = fopen('php://memory', 'w');
fputcsv($fpoint, $header, ',');
foreach($custData AS $customer){
$carData = $this->Customer_model->getCustomer(array('customer_id'=>$customer->customer_id));
$cars = '';
$data = array();
if(!empty($carData->vehicle_data)){
foreach($carData->vehicle_data AS $car){
$cars = $car->car_name.',';
$cars = trim($cars,',');
}
}
$data[] = $customer->customer_id;
$data[] = $customer->first_name.' '.$customer->last_name;
$data[] = $customer->phone;
$data[] = $customer->email;
$data[] = $customer->address;
$data[] = $customer->date_of_birth;
$data[] = ($customer->status == 1)?'Active':'De-active';
$data[] = $cars;
fputcsv($fpoint, $data, ',');
}
fseek($fpoint, 0);
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $file . '";');
fpassthru($fpoint);
}
}
?>
\ No newline at end of file
......@@ -304,5 +304,47 @@ class Mechanic extends CI_Controller {
redirect(base_url('Mechanic/editMechanics/'.$mechanic_id));
}
}
public function exportMechanicData(){
$mechData = $this->Mechanic_model->getMechanic();
if(empty($mechData)){
return;
}
$header = array('ID','Username','Name','Phone','Email','Address','City','State','Licence Number','Licence Exp Date','Start Time','End Time','Status','Shop Id','Shop Name','Shop Address',
'Shop Phone','Shop Email');
$file = 'mechData_'.time().'.csv';
$fpoint = fopen('php://memory', 'w');
fputcsv($fpoint, $header, ',');
foreach($mechData AS $mechanic){
$data = array();
$data[] = $mechanic->mechanic_id;
$data[] = $mechanic->username;
$data[] = $mechanic->display_name;
$data[] = $mechanic->phone;
$data[] = $mechanic->email_id;
$data[] = $mechanic->address;
$data[] = $mechanic->city;
$data[] = $mechanic->state;
$data[] = $mechanic->licence_number;
$data[] = $mechanic->licence_exp_date;
$data[] = $mechanic->start_time;
$data[] = $mechanic->end_time;
$data[] = ($mechanic->status == 1)?'Active':'De-active';
$data[] = $mechanic->shop_id;
$data[] = $mechanic->shop_name;
$data[] = $mechanic->shop_address;
$data[] = $mechanic->shop_phone;
$data[] = $mechanic->shop_email;
fputcsv($fpoint, $data, ',');
}
fseek($fpoint, 0);
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $file . '";');
fpassthru($fpoint);
}
}
?>
\ No newline at end of file
......@@ -41,5 +41,56 @@ class Orders extends CI_Controller {
}
echo json_encode($return_arr);exit;
}
public function changeOrderStatus(){
$status = 0;
$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;
}
$status = $this->Order_model->changeOrderStatus($_POST);
$return_arr['status'] = $status;
echo json_encode($return_arr);exit;
}
public function exportOrderData(){
$orderData = $this->Order_model->getOrders();
if(empty($orderData)){
return;
}
$header = array('Order ID','Name','Product Name','Brand Name','Short Description','Quantity','Amount','Status','Expected Delivery','Delivered');
$file = 'orderData_'.time().'.csv';
$fpoint = fopen('php://memory', 'w');
fputcsv($fpoint, $header, ',');
foreach($orderData AS $order){
$new = array();
$odrData = $this->Order_model->getOrderDetails($order->order_id);
$data = array();
$data[] = $odrData->format_order_id;
$data[] = $odrData->customer_name;
$data[] = $odrData->product_name;
$data[] = $odrData->brand_name;
$data[] = $odrData->short_description;
$data[] = $odrData->quantity;
$data[] = $odrData->amount;
$data[] = $odrData->ord_status;
if($odrData->status == '2' || $odrData->status == '3' || $odrData->status == '4'){
$data[] = $odrData->expected_delivery;
}
if($odrData->status == '5' || $odrData->status == '6'){
$data[] = $odrData->delivered;
}
fputcsv($fpoint, $data, ',');
}
fseek($fpoint, 0);
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $file . '";');
fpassthru($fpoint);
}
}
?>
\ No newline at end of file
......@@ -8,6 +8,7 @@ class Product extends CI_Controller {
date_default_timezone_set("Asia/Kolkata");
$this->load->model('Brand_model');
$this->load->model('Product_model');
$this->load->model('Vehicle_model');
if(!$this->session->userdata('logged_in')) {
redirect(base_url('Login'));
......@@ -23,6 +24,8 @@ class Product extends CI_Controller {
$template['brand_id'] = '';
$template['product_data'] = $this->Product_model->getProduct();
$template['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1);
$template['veh_data']['model'] = $this->Vehicle_model->getVehModel('',1);
$template['brand_data'] = $this->Brand_model->getbrand('',1);
$this->load->view('template',$template);
}
......@@ -34,7 +37,8 @@ class Product extends CI_Controller {
$template['pTitle'] = "View Product";
$template['pDescription'] = "View and Manage Product";
$template['product_data'] = $this->Product_model->getProduct('',1);
$mechanic_id = ($this->session->userdata['user_type']==2)?$this->session->userdata['id']:'';
$template['product_data'] = $this->Product_model->getProduct('',1,$mechanic_id);
$this->load->view('template',$template);
}
......@@ -57,7 +61,7 @@ class Product extends CI_Controller {
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(!isset($_POST) || empty($_POST)){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Product/addProduct'));
redirect(base_url('Product/addproduct'));
}
if($err == 0 && (!isset($_POST['brand_id']) || empty($_POST['brand_id']))){
$err = 1;
......@@ -91,8 +95,9 @@ class Product extends CI_Controller {
if($err == 1){
$flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Product/addProduct'));
redirect(base_url('Product/addproduct'));
}
$_POST['created_by']=($this->session->userdata['user_type']==2)?$this->session->userdata['id']:0;
$product_id = $this->Product_model->addProduct($_POST);
if($product_id){
......@@ -125,7 +130,7 @@ class Product extends CI_Controller {
redirect(base_url('Product/viewProducts'));
}else {
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Product/addProduct'));
redirect(base_url('Product/addproduct'));
}
}
}
......@@ -137,7 +142,7 @@ class Product extends CI_Controller {
redirect(base_url('Product/viewProducts'));
}
$template['page'] = 'Product/addProduct';
$template['page'] = 'Product/addproduct';
$template['menu'] = 'Brand Management';
$template['smenu'] = 'Edit brand';
$template['pTitle'] = "Edit brand";
......@@ -146,6 +151,8 @@ class Product extends CI_Controller {
$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['veh_data']['make'] = $this->Vehicle_model->getVehBrand('',1);
$template['veh_data']['model'] = $this->Vehicle_model->getVehModel('',1, $template['product_data']->veh_brand_id);
$template['product_image'] = $this->Product_model->getProductImage($product_id);
$template['brand_id'] = $template['product_data']->brand_id;
......@@ -162,7 +169,7 @@ class Product extends CI_Controller {
}
if(!isset($_POST) || empty($_POST)){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Product/addProduct'));
redirect(base_url('Product/addproduct'));
}
if($err == 0 && (!isset($_POST['brand_id']) || empty($_POST['brand_id']))){
$err = 1;
......@@ -196,7 +203,7 @@ class Product extends CI_Controller {
if($err == 1){
$flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Product/addProduct'));
redirect(base_url('Product/addproduct'));
}
$existingImages = (isset($_POST['existingImages']) && !empty($_POST['existingImages']))?
$_POST['existingImages']:'';
......@@ -256,5 +263,41 @@ class Product extends CI_Controller {
}
public function exportProductData(){
$mechanic_id = ($this->session->userdata['user_type']==2)?$this->session->userdata['id']:'';
$productData = $this->Product_model->getProduct('',1,$mechanic_id);
if(empty($productData)){
return;
}
$header = array('Product ID','Product Name','Brand Name','Short Description','Part ID','Vehicle Model','Amount','Status');
$file = 'productData_'.time().'.csv';
$fpoint = fopen('php://memory', 'w');
fputcsv($fpoint, $header, ',');
foreach($productData AS $product){
$data = array();
$status = 'Active';
switch ($product->status) {
case '0': $status = 'Inactive';break;
case '1': $status = 'Active ';break;
case '2': $status = 'Deleted';break;
}
$data[] = $product->product_id;
$data[] = $product->product_name;
$data[] = $product->brand_name;
$data[] = $product->short_description;
$data[] = $product->part_id;
$data[] = $product->model;
$data[] = $product->amount;
$data[] = $status;
fputcsv($fpoint, $data, ',');
}
fseek($fpoint, 0);
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $file . '";');
fpassthru($fpoint);
}
}
?>
\ No newline at end of file
......@@ -19,7 +19,7 @@ class Vehicle extends CI_Controller {
!isset($_POST['vehLocation']) || empty($vehLocation = $_POST['vehLocation'])){
echo json_encode($return_arr);exit;
}
$param = "";
$url = "";
$searchType = $_POST['searchType'];
$vehicle_data = array('car_location'=>$vehLocation);
......@@ -34,22 +34,24 @@ class Vehicle extends CI_Controller {
$vehicle_data['car_model'] = $_POST['vehModel'];
$vehicle_data['car_model_year'] = $_POST['vehYear'];
$param = "?format=json&key=".urlencode($settings['vin_audit_api'])."&year=".
urlencode($_POST['vehYear'])."&make=".urlencode($_POST['vehMaker'])."&model=".
urlencode($_POST['vehModel']);
$url = "https://specifications.vinaudit.com/v3/selections?format=json&key=".
urlencode($settings['vin_audit_api'])."&id=".urlencode($_POST['vehYear'])."_".
urlencode($_POST['vehMaker'])."_".urlencode($_POST['vehModel']);
}
else if($searchType == 2 && isset($_POST['vehVin']) && !empty($_POST['vehVin'])){
$vehicle_data['car_vin'] = $_POST['vehVin'];
$param = "?format=json&key=".urlencode($settings['vin_audit_api']).
"&vin=".urlencode($_POST['vehVin']);
$url = "https://specifications.vinaudit.com/v3/specifications?format=json&key=".urlencode($settings['vin_audit_api'])."&vin=".urlencode($_POST['vehVin']);
}
if(!empty($param)){
$vehData=file_get_contents("https://specifications.vinaudit.com/getspecifications.php".$param);
if(!empty($url)){
$vehData=file_get_contents($url);
if(empty($vehData) || empty($vehData = json_decode($vehData,true))){
echo json_encode($return_arr);exit;
}
if(!isset($vehData['success']) || empty($vehData['success']) || $vehData['success'] == false){
if(!isset($vehData['success']) || empty($vehData['success']) || $vehData['success']==false ||
((!isset($vehData['attributes']) || empty($vehData['attributes'])) &&
(!isset($vehData['selections']) || empty($vehData['selections'])))){
$return_arr['status'] = 2;
echo json_encode($return_arr);exit;
}
......@@ -58,13 +60,24 @@ class Vehicle extends CI_Controller {
$return_arr['status'] = 3;
echo json_encode($return_arr);exit;
}
if($searchType == 2){
$vehicle_data['car_model'] = $vehData['attributes']['Model'];
$vehicle_data['car_maker'] = $vehData['attributes']['Make'];
$vehicle_data['car_model_year'] = $vehData['attributes']['Year'];
$vehData['vehicle'] = $vehData['attributes']['Year'].' '.$vehData['attributes']['Make'].' '.
$vehData['attributes']['Model'].' '.$vehData['attributes']['Trim'];
$vehData['vehicle'] = $vehData['attributes']['year'].' '.
$vehData['attributes']['make'].' '.
$vehData['attributes']['model'].' '.
$vehData['attributes']['trim'];
} else if($searchType == 1){
$vehSele = $vehData['selections'];
$vehicle_data['car_model_year'] = $vehSele['years'][0]['name'];
$vehicle_data['car_maker'] = $vehSele['years'][0]['makes'][0]['name'];
$vehicle_data['car_model'] = $vehSele['years'][0]['makes'][0]['models'][0]['name'];
$vehData['vehicle'] = $vehSele['years'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['trims'][0]['name'];
}
$vehicle_data['car_name'] = $vehData['vehicle'];
$vehicle_data['car_loc_lat'] = $lat_lng['lat'];
$vehicle_data['car_loc_lng'] = $lat_lng['lng'];
......@@ -74,6 +87,7 @@ class Vehicle extends CI_Controller {
if(!empty($car_id)){
$return_arr['status'] = '1';
$return_arr['car_id'] = $car_id;
$return_arr['searchType'] = $searchType;
$return_arr['veh_data'] = $vehData;
}
}
......@@ -90,5 +104,271 @@ class Vehicle extends CI_Controller {
$return_arr['status'] = $this->Vehicle_model->changeStatus($car_id,$action);
echo json_encode($return_arr); exit;
}
public function addVehBrand(){
$template['page'] = 'Vehicles/addBrand';
$template['pTitle'] = "Add Vehicle Brand";
$template['pDescription'] = "Add Vehicle Brand";
$template['menu'] = "Vehicle Brand Management";
$template['smenu'] = "View Brand";
$template['brand_id'] = '';
$template['vehBrand_data'] = $this->Vehicle_model->getVehBrand('',1);
$this->load->view('template',$template);
}
public function viewVehBrand(){
$template['page'] = 'Vehicles/viewBrand';
$template['menu'] = 'Vehicles Brand Management';
$template['smenu'] = 'View Vehicles Brand ';
$template['pTitle'] = "View Vehicles Brand ";
$template['pDescription'] = "View and Manage Vehicles Brands";
$template['vehBrand_data'] = $this->Vehicle_model->getVehBrand('',1);
$this->load->view('template',$template);
}
function changeVehicleStatus($brand_id = '',$status = '1'){
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(empty($brand_id) || !is_numeric($brand_id = decode_param($brand_id))){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/viewVehBrand'));
}
$status = $this->Vehicle_model->changeVehicleStatus($brand_id,$status);
if(!$status){
$this->session->set_flashdata('message',$flashMsg);
}
redirect(base_url('Vehicle/viewVehBrand'));
}
public function createbrand(){
$err = 0;
$errMsg = '';
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(!isset($_POST) || empty($_POST)){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehBrand'));
}
if($err == 0 && (!isset($_POST['maker']) || empty($_POST['maker']))){
$err = 1;
$errMsg = 'Vehicle Brand is Required';
}
if($err == 1){
$flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehBrand'));
}
$brand_id = $this->Vehicle_model->addBrand($_POST);
if($brand_id != '0'){
$flashMsg =array('message'=>'Successfully Updated Brand..!','class'=>'success');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/viewVehBrand'));
}else {
$flashMsg =array('message'=>'Brand Name Already Exist','class'=>'error');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/addVehBrand'));
}
}
public function editVehBrand($brand_id){
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(empty($brand_id) || !is_numeric($brand_id = decode_param($brand_id))){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/viewVehBrand'));
}
$template['page'] = 'Vehicles/addBrand';
$template['menu'] = 'Brand Management';
$template['smenu'] = 'Edit brand';
$template['pTitle'] = "Edit brand";
$template['pDescription'] = "Update brand Name";
$template['brand_id'] = encode_param($brand_id);
$template['vehBrand_data'] = $this->Vehicle_model->getVehBrand($brand_id,1);
$this->load->view('template',$template);
}
public function updateVehBrand($brand_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))){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/viewVehBrand'));
}
if(!isset($_POST) || empty($_POST)){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehBrand'));
}
if($err == 0 && (!isset($_POST['maker']) || empty($_POST['maker']))){
$err = 1;
$errMsg = 'Vehicle Brand is Required';
}
if($err == 1){
$flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehBrand'));
}
$brand = $this->Vehicle_model->updateVehBrand(decode_param($brand_id),$_POST);
if($brand){
$flashMsg =array('message'=>'Successfully Updated Brand Data..!','class'=>'success');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/viewVehBrand'));
} else {
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/editVehBrand/'.$brand_id));
}
}
public function addVehModel(){
$template['page'] = 'Vehicles/addModel';
$template['pTitle'] = "Add Vehicle Model";
$template['pDescription'] = "Add Vehicle Model";
$template['menu'] = "Vehicle Model Management";
$template['smenu'] = "View Model";
$template['model_id'] = '';
$template['vehBrand_data'] = $this->Vehicle_model->getVehBrand('',1);
$template['vehModel_data'] = $this->Vehicle_model->getVehModel('',1);
$this->load->view('template',$template);
}
public function viewVehModel(){
$template['page'] = 'Vehicles/viewModel';
$template['menu'] = 'Vehicles Model Management';
$template['smenu'] = 'View Vehicles Model ';
$template['pTitle'] = "View Vehicles Model ";
$template['pDescription'] = "View and Manage Vehicles Models";
$template['vehModel_data'] = $this->Vehicle_model->getVehModel('',1);
$this->load->view('template',$template);
}
function changeModelStatus($model_id = '',$status = '1'){
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(empty($model_id) || !is_numeric($model_id = decode_param($model_id))){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/viewVehModel'));
}
$status = $this->Vehicle_model->changeVehicleStatus($model_id,$status,'2');
if(!$status){
$this->session->set_flashdata('message',$flashMsg);
}
redirect(base_url('Vehicle/viewVehModel'));
}
public function createModel(){
$err = 0;
$errMsg = '';
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(!isset($_POST) || empty($_POST)){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehModel'));
}
if($err == 0 && (!isset($_POST['veh_brand_id']) || empty($_POST['veh_brand_id']))){
$err = 1;
$errMsg = 'Please Select a Brand';
}else if($err == 0 && (!isset($_POST['model']) || empty($_POST['model']))){
$err = 1;
$errMsg = 'Vehicle Model is Required';
}
if($err == 1){
$flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehModel'));
}
$model_id = $this->Vehicle_model->addModel($_POST);
if($model_id != '0'){
$flashMsg =array('message'=>'Successfully Updated Vehicle Model..!','class'=>'success');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/viewVehModel'));
}else {
$flashMsg =array('message'=>'Model Name Already Exist','class'=>'error');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/addVehModel'));
}
}
public function editVehModel($model_id){
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(empty($model_id) || !is_numeric($model_id = decode_param($model_id))){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/viewVehModel'));
}
$template['page'] = 'Vehicles/addModel';
$template['menu'] = 'Model Management';
$template['smenu'] = 'Edit Model';
$template['pTitle'] = "Edit Model";
$template['pDescription'] = "Update Model Name";
$template['model_id'] = encode_param($model_id);
$template['vehBrand_data'] = $this->Vehicle_model->getVehBrand('',1);
$template['vehModel_data'] = $this->Vehicle_model->getVehModel($model_id,1);
//pr($template['vehModel_data']);
$this->load->view('template',$template);
}
public function updateVehModel($model_id = ''){
$err = 0;
$errMsg = '';
$flashMsg = array('message'=>'Something went wrong, please try again..!','class'=>'error');
if(empty($model_id) || !isset($_POST) || empty($_POST) || !is_numeric(decode_param($model_id))){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/viewVehModel'));
}
if(!isset($_POST) || empty($_POST)){
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehModel'));
}
if($err == 0 && (!isset($_POST['veh_brand_id']) || empty($_POST['veh_brand_id']))){
$err = 1;
$errMsg = 'Please Select a Brand';
}else if($err == 0 && (!isset($_POST['model']) || empty($_POST['model']))){
$err = 1;
$errMsg = 'Vehicle Model is Required';
}
if($err == 1){
$flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Vehicle/addVehModel'));
}
$model = $this->Vehicle_model->updateVehModel(decode_param($model_id),$_POST);
if($model){
$flashMsg =array('message'=>'Successfully Updated Vehicle Model..!','class'=>'success');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/viewVehModel'));
} else {
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('Vehicle/editVehModel/'.$model_id));
}
}
public function getVehModel(){
$return_arr = array('status'=>'0');
if(!isset($_POST) || empty($_POST) || !isset($_POST['id']) || empty($_POST['id']) ||
empty($_POST['id'])){
echo json_encode($return_arr);exit;
}
$result = $this->Vehicle_model->getVehModel('',1,$_POST['id']);
$results = '<option value="-1">No Models</option>';
if($result){
$results = '<option value="-1">Choose Vehicle Model</option>';
foreach ($result as $model) {
$results .= '<option value="'.$model->veh_modal_id.'" model="'.$model->model.'">'.$model->model.'</option>';
}
}
echo $results;
}
}
?>
\ No newline at end of file
......@@ -519,7 +519,7 @@
echo json_encode($respArr);exit;
}
$param = "";
$url = "";
$searchType = $postData['type'];
$searchData = $postData['vehicleData'];
$locationData = $postData['location'];
......@@ -543,36 +543,50 @@
$vehicle_data['car_model'] = $searchData['modelName'];
$vehicle_data['car_model_year'] = $searchData['modelYear'];
$param = "?format=json&key=".urlencode($settings['vin_audit_api'])."&year=".
urlencode($searchData['modelYear'])."&make=".urlencode($searchData['car_maker']).
"&model=".urlencode($searchData['modelName']);
//$param = "?format=json&key=".urlencode($settings['vin_audit_api'])."&year=".
//urlencode($searchData['modelYear'])."&make=".urlencode($searchData['car_maker']).
//"&model=".urlencode($searchData['modelName']);
$url = "https://specifications.vinaudit.com/v3/selections?format=json&key=".
urlencode($settings['vin_audit_api'])."&id=".urlencode($searchData['modelYear'])."_".urlencode($searchData['car_maker'])."_".urlencode($searchData['modelName']);
}
else if($searchType == 2 && isset($searchData['vin']) && !empty($searchData['vin'])){
$vehicle_data['car_vin'] = $searchData['vin'];
$param = "?format=json&key=".urlencode($settings['vin_audit_api']).
"&vin=".urlencode($searchData['vin']);
// $param = "?format=json&key=".urlencode($settings['vin_audit_api']).
// "&vin=".urlencode($searchData['vin']);
$url = "https://specifications.vinaudit.com/v3/specifications?format=json&key=".urlencode($settings['vin_audit_api'])."&vin=".urlencode($searchData['vin']);
}
if(!empty($param)){
$vehData=file_get_contents("https://specifications.vinaudit.com/getspecifications.php".$param);
if(!empty($url)){
$vehData=file_get_contents($url);
if(empty($vehData) || empty($vehData = json_decode($vehData,true))){
echo json_encode($return_arr);exit;
}
if(!isset($vehData['success']) || empty($vehData['success']) || $vehData['success'] == false){
if(!isset($vehData['success']) || empty($vehData['success']) || $vehData['success'] == false || ((!isset($vehData['attributes']) || empty($vehData['attributes'])) &&
(!isset($vehData['selections']) || empty($vehData['selections'])))){
$return_arr['status'] = 2;
$return_arr['message'] = 'No Data Found.';
echo json_encode($return_arr);exit;
}
if($searchType == 2){
$vehicle_data['car_model'] = $vehData['attributes']['Model'];
$vehicle_data['car_maker'] = $vehData['attributes']['Make'];
$vehicle_data['car_model_year'] = $vehData['attributes']['Year'];
$vehData['vehicle']= $vehData['attributes']['Year'].' '.$vehData['attributes']['Make'].' '.
$vehData['attributes']['Model'].' '.$vehData['attributes']['Trim'];
}
$vehicle_data['car_model'] = $vehData['attributes']['model'];
$vehicle_data['car_maker'] = $vehData['attributes']['make'];
$vehicle_data['car_model_year'] = $vehData['attributes']['year'];
$vehData['vehicle']= $vehData['attributes']['year'].' '.$vehData['attributes']['make'].' '.
$vehData['attributes']['model'].' '.$vehData['attributes']['trim'];
} else if($searchType == 1){
$vehSele = $vehData['selections'];
$vehicle_data['car_model_year'] = $vehSele['years'][0]['name'];
$vehicle_data['car_maker'] = $vehSele['years'][0]['makes'][0]['name'];
$vehicle_data['car_model'] = $vehSele['years'][0]['makes'][0]['models'][0]['name'];
$vehData['vehicle'] = $vehSele['years'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['name'].' '.
$vehSele['years'][0]['makes'][0]['models'][0]['trims'][0]['name'];
}
$vehicle_data['car_name'] = $vehData['vehicle'];
$vehicle_data['vehicle_data'] = json_encode($vehData);
......@@ -1515,7 +1529,7 @@
public function orderPlacedSuccess($ref=''){
$settings = getSettings();
$url = $settings['web_url']."/track?status=success&ref=".$ref;
$url = $settings['web_url']."/track?ref=".$ref;
header("Location: ".$url);
}
......@@ -1526,8 +1540,52 @@
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$result = $this->Webservice_model->productSearch($postData);
echo json_encode($result);exit;
$total = 0;
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] != 1) ?$postData['page'] :'1';
$page_limit = ($page - 1) * $per_page;
$result = $this->Webservice_model->productSearch($postData,0,0);
$prodList = $this->Webservice_model->productSearch($postData,$page_limit,$per_page);
if($result['status'] == 'success'){
$total = count($result['data']);
}
if($total >= $per_page){
$totalPages = (int)($total%$per_page == 0?$total/$per_page:($total/$per_page)+1);
}
else{
$totalPages = 1;
}
if($prodList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $prodList['data'],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => [],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
//Get Brands
......@@ -1644,6 +1702,807 @@
$result = $this->Webservice_model->rateProduct($postData);
echo json_encode($result);exit;
}
public function get_latest_product_list(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page;
$productResult = $this->Webservice_model->get_latest_product_list(0,0);
$productList = $this->Webservice_model->get_latest_product_list($start,$per_page);
$product = array();
$total = 0;
if($productResult['status'] == 'success'){
$total = count($productResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($productList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => array(
'latest_products' => $productList['data']
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => array(
'latest_products' => []
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function get_trending_product_list(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page;
$productResult = $this->Webservice_model->get_trending_product_list(0,0);
$productList = $this->Webservice_model->get_trending_product_list($start,$per_page);
$product = array();
$total = 0;
if($productResult['status'] == 'success'){
$total = count($productResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($productList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => array(
'trending_products' => $productList['data']
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => array(
'trending_products' => []
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function product_details(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$result = $this->Webservice_model->SingleProductSearch($postData);
echo json_encode($result);exit;
}
public function add_address(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$postData['customer_id'] = $authRes['data']['customer_id'];
$result = $this->Webservice_model->saveUserAddress($postData);
echo json_encode($result);exit;
}
public function address_details(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$postData['user_id'] = $authRes['data']['customer_id'];
$result = $this->Webservice_model->getUserAddress($postData);
echo json_encode($result);exit;
}
public function getLatestPrdts(){
header('Content-type:application/json');
$headers = apache_request_headers();
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] != 1) ?$postData['page'] :'1';
$page_limit = ($page - 1) * $per_page;
$latestResult = $this->Webservice_model->get_latest_product_list(0,0);
$latestList = $this->Webservice_model->get_latest_product_list($page_limit,$per_page);
if($latestResult['status'] == 'success'){
$total = count($latestResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($latestList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $latestList['data'],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => [],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function getTrendingPrdts(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$total = 0;
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] != 1) ?$postData['page'] :'1';
$page_limit = ($page - 1) * $per_page;
$trendResult = $this->Webservice_model->get_trending_product_list(0,0);
$trendList = $this->Webservice_model->get_trending_product_list($page_limit,$per_page);
if($trendResult['status'] == 'success'){
$total = count($trendResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total%$per_page == 0?$total/$per_page:($total/$per_page)+1);
}
else{
$totalPages = 1;
}
if($trendList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $trendList['data'],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => [],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function getMyOrders(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$total = 0;
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] != 1) ?$postData['page'] :'1';
$page_limit = ($page - 1) * $per_page;
$result = $this->Webservice_model->getMyOrders($postData,0,0);
$resultList = $this->Webservice_model->getMyOrders($postData,$page_limit,$per_page);
if($result['status'] == 'success'){
$total = count($result['data']);
}
if($total >= $per_page){
$totalPages = (int)($total%$per_page == 0?$total/$per_page:($total/$per_page)+1);
}
else{
$totalPages = 1;
}
if($resultList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $resultList['data'],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => [],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function cancelOrder(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$result = $this->Webservice_model->cancelOrder($postData);
echo json_encode($result);exit;
}
public function getCartData(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$total = 0;
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] != 1) ?$postData['page'] :'1';
$page_limit = ($page - 1) * $per_page;
$result = $this->Webservice_model->getCartData($postData,0,0);
$cartList = $this->Webservice_model->getCartData($postData,$page_limit,$per_page);
if($result['status'] == 'success'){
$total = count($result['data']);
}
if($total >= $per_page){
$totalPages = (int)($total%$per_page == 0?$total/$per_page:($total/$per_page)+1);
}
else{
$totalPages = 1;
}
if($cartList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $cartList['data'],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => [],
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function removeCartPrdt(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$result = $this->Webservice_model->removeCartPrdt($postData);
echo json_encode($result);exit;
}
public function addToCart(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$result = $this->Webservice_model->addToCart($postData);
echo json_encode($result);exit;
}
public function add_to_cart(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$postData['customer_id'] = $authRes['data']['customer_id'];
$result = $this->Webservice_model->addToCart($postData);
echo json_encode($result);exit;
}
public function remove_product(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$result = $this->Webservice_model->removeCartPrdt($postData);
echo json_encode($result);exit;
}
public function cart_details(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page;
$postData['customer_id'] = $authRes['data']['customer_id'];
$cartResult = $this->Webservice_model->getCartData($postData,0,0);
$cartList = $this->Webservice_model->getCartData($postData,$start,$per_page);
$product = array();
$total = 0;
if($cartResult['status'] == 'success'){
$total = count($cartResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($cartList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => array(
'cart_products' => $cartList['data']
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => array(
'cart_products' => []
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function my_order_details(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page;
$postData['customer_id'] = $authRes['data']['customer_id'];
$orderResult = $this->Webservice_model->getMyOrders($postData,0,0);
$orderList = $this->Webservice_model->getMyOrders($postData,$start,$per_page);
$product = array();
$total = 0;
if($orderResult['status'] == 'success'){
$total = count($orderResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($orderList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => array(
'order_details' => $orderList['data']
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => array(
'order_details' => []
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function search_product(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page;
$searchResult = $this->Webservice_model->productSearch($postData,0,0);
$searchList = $this->Webservice_model->productSearch($postData,$start,$per_page);
$product = array();
$total = 0;
if($searchResult['status'] == 'success'){
$total = count($searchResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($searchList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => array(
'search_products' => $searchList['data']
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => array(
'search_products' => []
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function filter_product(){
header('Content-type:application/json');
$headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page;
$filterResult = $this->Webservice_model->productSearch($postData,0,0);
$filterList = $this->Webservice_model->productSearch($postData,$start,$per_page);
$product = array();
$total = 0;
if($filterResult['status'] == 'success'){
$total = count($filterResult['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($filterList['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => array(
'sorted_products' => $filterList['data']
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}else{
$respArr = array(
'status' => 'error',
'message'=>'No data',
'data' => array(
'sorted_products' => []
),
'meta' => array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page
)
);
}
echo json_encode($respArr);exit;
}
public function getMechanicShops(){
header('Content-type:application/json');
$headers = apache_request_headers();
$result = $this->Webservice_model->getMechanicShops();
echo json_encode($result);exit;
}
public function getVehicleBrand(){
header('Content-type:application/json');
$headers = apache_request_headers();
$result = $this->Webservice_model->getVehicleBrand();
echo json_encode($result);exit;
}
public function getVehicleModel(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$result = $this->Webservice_model->getVehicleModel($postData);
echo json_encode($result);exit;
}
}
......
......@@ -15,6 +15,7 @@ class Booking_model extends CI_Model {
return 0;
}
$vehData = $postData['vechile_info'];
//$vehName = $this->db->get_where('vehicles_brand',array('veh_brand_id'=>$vehData['maker']))->row();
$car_name = $vehData['modelYear'].' '.$vehData['maker'].' '.$vehData['modelName'];
$vehJson = array('vehicle' => $car_name,
......
......@@ -11,8 +11,8 @@ class Customer_model extends CI_Model {
$veh_data = array();
if(!empty($customer_data['customer_id'])){
$cond .= " AND customer_id = '".trim($customer_data['customer_id'])."'";
$veh_data = $this->db->get_where(
'customer_vehicle',array('status'=>'1','customer_id'=>$customer_data['customer_id']));
$veh_data = $this->db->get_where('customer_vehicle',
array('status'=>'1','customer_id'=>$customer_data['customer_id']));
$veh_data = (!empty($veh_data))?$veh_data->result():'';
}
......
......@@ -6,7 +6,8 @@ class Order_model extends CI_Model {
}
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->select("ORD.*,PRD.product_name,
TRIM(CONCAT(CUST.first_name,' ',IFNULL(CUST.last_name,''))) as customer_name");
$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');
......@@ -20,7 +21,8 @@ class Order_model extends CI_Model {
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,
$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'
......@@ -30,7 +32,7 @@ class Order_model extends CI_Model {
WHEN ORD.status = 6 THEN 'Returned'
WHEN ORD.status = 7 THEN 'Cancelled'
WHEN ORD.status = 8 THEN 'Deleted'
ELSE 'Payment Failed' END AS status
ELSE 'Payment Failed' END AS ord_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
......@@ -48,6 +50,23 @@ class Order_model extends CI_Model {
return (empty($result))?'':$result->result();
}
public function changeOrderStatus($data=array()){
$order_id = decode_param($data['order_id']);
if(empty($order_id) || $data['status'] == '' || empty($data['expected_date'])){
return 0;
}
if($data['status'] == '3' || $data['status'] == '4'){
$data['expected_delivery'] = $data['expected_date'];
}else if($data['status'] == '5'){
$data['delivered'] = $data['expected_date'];
}
unset($data['expected_date'],$data['order_id']);
$status = 0;
if($this->db->update('orders',$data,array('order_id'=>$order_id))){
$status = 1;
}
return $status;
}
}
?>
......@@ -9,27 +9,31 @@ 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']);
$cardata = $this->db->get_where('vehicles_model',array('veh_brand_id'=>$product_data['vehMake'],'veh_modal_id'=>$product_data['vehModel']))->row();
if(isset($product_data['cardetail_id']) && !empty($product_data['cardetail_id'])){
$this->db->update('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id),array('id'=>$product_data['cardetail_id']));
}else{
$this->db->insert('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id));
$product_data['cardetail_id'] = $this->db->insert_id();
}
unset($product_data['vehYear'],$product_data['vehMake'],$product_data['vehModel']);
$status = $this->db->insert('products',$product_data);
$last_id = $this->db->insert_id();
return $last_id;
}
function getProduct($product_id = '',$view_all = 0){
function getProduct($product_id = '',$view_all = 0,$mechanic_id = ''){
$cond = ($view_all != 0)?' products.status IN (0,1) ':' products.status IN (1) ';
$cond .= (!empty($product_id))?" AND products.product_id = '$product_id'":"";
$cond .= (!empty($mechanic_id))?" AND products.created_by = '$mechanic_id'":"";
$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");
$result = $this->db->query("SELECT cardetails.veh_modal_id,cardetails.year,vehicles_model.* ,products.*,product_brand.brand_name
FROM products
JOIN product_brand on product_brand.brand_id = products.brand_id
LEFT JOIN cardetails on cardetails.id = products.cardetail_id
LEFT JOIN vehicles_model on cardetails.veh_modal_id = vehicles_model.veh_modal_id
WHERE $cond");
if(empty($result)){
return;
}
......@@ -49,16 +53,14 @@ 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']);
$cardata = $this->db->get_where('vehicles_model',array('veh_brand_id'=>$product_data['vehMake'],'veh_modal_id'=>$product_data['vehModel']))->row();
if(isset($product_data['cardetail_id']) && !empty($product_data['cardetail_id'])){
$this->db->update('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id),array('id'=>$product_data['cardetail_id']));
}else{
$this->db->insert('cardetails',array('year'=>$product_data['vehYear'],' veh_modal_id'=>$cardata->veh_modal_id));
$product_data['cardetail_id'] = $this->db->insert_id();
}
unset($product_data['vehYear'],$product_data['vehMake'],$product_data['vehModel']);
$status = $this->db->update('products',$product_data,array('product_id'=>$product_id));
return ($status)?1:0;
}
......@@ -88,7 +90,6 @@ class Product_model extends CI_Model {
return $status;
}
function getProductImage($product_id = ''){
if(empty($product_id)){
return 0;
......@@ -97,9 +98,5 @@ class Product_model extends CI_Model {
return $status;
}
function getVehdata(){
return $this->db->get_where('cardetails')->result_array();
}
}
?>
\ No newline at end of file
......@@ -55,5 +55,90 @@ class Vehicle_model extends CI_Model {
return $upStatus;
}
public function addBrand($veh_data = array()){
if(empty($veh_data)){
return 0;
}
$result = $this->db->get_where('vehicles_brand',array('vehicles_brand.maker'=>$veh_data['maker']))->row();
if($result){
return 0;
}
$status = $this->db->insert('vehicles_brand',$veh_data);
$last_id = $this->db->insert_id();
return $last_id;
}
function getVehBrand($veh_brand_id = '',$view_all = 0){
$cond = ($view_all != 0)?' vehicles_brand.status IN (0,1) ':' vehicles_brand.status IN (1) ';
$cond .= (!empty($veh_brand_id))?" AND vehicles_brand.veh_brand_id = '$veh_brand_id'":"";
$result = $this->db->query("SELECT * FROM vehicles_brand
WHERE $cond ORDER BY vehicles_brand.maker");
if(empty($result)){
return;
}
return (empty($veh_brand_id))?$result->result():$result->row();
}
function changeVehicleStatus($brand_id = '', $status = '0',$type=''){
if(empty($brand_id)){
return 0;
}
if($type == '2'){
$status = $this->db->update('vehicles_model',array('status'=>$status), array('veh_modal_id'=>$brand_id));
}else{
$status = $this->db->update('vehicles_brand',array('status'=>$status), array('veh_brand_id'=>$brand_id));
}
return $status;
}
function updateVehBrand($brand_id = '', $brand_data = array()){
if(empty($brand_id) || empty($brand_data)){
return 0;
}
$status = $this->db->update('vehicles_brand',$brand_data,array('veh_brand_id'=>$brand_id));
return ($status)?1:0;
}
function getVehModel($veh_model_id = '',$view_all = 0,$veh_brand_id=''){
$cond = ($view_all != 0)?' vehicles_model.status IN (0,1) ':' vehicles_model.status IN (1) ';
$cond .= (!empty($veh_model_id))?" AND vehicles_model.veh_modal_id = '$veh_model_id'":"";
$cond .= (!empty($veh_brand_id))?" AND vehicles_model.veh_brand_id = '$veh_brand_id'":"";
$result = $this->db->query("SELECT vehicles_model.*, vehicles_brand.maker
FROM vehicles_model
JOIN vehicles_brand ON vehicles_brand.veh_brand_id = vehicles_model.veh_brand_id
WHERE $cond ORDER BY vehicles_model.model");
if(empty($result)){
return;
}
if(isset($veh_brand_id) && !empty($veh_brand_id)){
return $result->result();
}
return (empty($veh_model_id))?$result->result():$result->row();
}
public function addModel($veh_data = array()){
if(empty($veh_data)){
return 0;
}
$result = $this->db->get_where('vehicles_model',array('vehicles_model.model'=>$veh_data['model'],'vehicles_model.veh_brand_id'=>$veh_data['veh_brand_id']))->row();
if($result){
return 0;
}
$status = $this->db->insert('vehicles_model',$veh_data);
$last_id = $this->db->insert_id();
return $last_id;
}
function updateVehModel($model_id = '', $model_data = array()){
if(empty($model_id) || empty($model_data)){
return 0;
}
$status = $this->db->update('vehicles_model',$model_data,array('veh_modal_id'=>$model_id));
return ($status)?1:0;
}
}
?>
\ No newline at end of file
......@@ -78,7 +78,7 @@ class Webservice_model extends CI_Model {
'city'=>'',
'phone'=>$provider_data['phone'],
'state'=>'',
'shop_id'=>'',
'shop_id'=>(isset($provider_data['shop_id']) && !empty($provider_data['shop_id']))? $provider_data['shop_id']:'',
'address'=>'',
'licence'=>'',
'location'=>'',
......@@ -591,14 +591,16 @@ class Webservice_model extends CI_Model {
return 1;
}
public function productSearch($postData){
public function productSearch($postData,$start='',$per_page=''){
$respArr = array('status'=>'error');
if(empty($postData)){
return $respArr;
}
$per_page = 10;
$page = (isset($data['page']))?$data['page']:'0';
$lmt = '';
if($start != 0 || $per_page != 0){
$lmt .= "LIMIT $start,$per_page";
}
$where = '';
if(isset($postData['key']) && !empty($postData['key'])){
......@@ -630,11 +632,14 @@ class Webservice_model extends CI_Model {
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());
$lmt ");
if(!empty($result) && $result->num_rows() > 0){
$result = $result->result_array();
foreach ($result as $key => $value) {
$result[$key]['rating'] = (float)$value['rating'];
}
$respArr['status'] = 'success';
$respArr['data'] = $result->result_array();
$respArr['data'] = $result;
}
return $respArr;
}
......@@ -655,33 +660,88 @@ class Webservice_model extends CI_Model {
public function SingleProductSearch($postData){
$respArr = array('status'=>'error');
if(empty($postData)){
if(empty($postData['product_id'])){
return $respArr;
}
$total = 0;
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] != 1) ?$postData['page'] :'1';
$page_limit = ($page - 1) * $per_page;
$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
$cartSel = '';
$cartJoin = '';
if(isset($postData['user_id']) && !empty($postData['user_id'])){
$cartSel = ',CRT.cart_id';
$cartJoin = "LEFT JOIN cart AS CRT ON
(CRT.product_id=PRD.product_id AND CRT.customer_id=".$postData['user_id'].")";
}
$sql = "SELECT ROUND(AVG(REV.rating),2) AS rating, COUNT(REV.id) AS count,PRD.*,PRDB.brand_name".
$cartSel."
FROM products AS PRD
LEFT JOIN product_brand AS PRDB ON PRDB.brand_id = PRD.brand_id
LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id ".$cartJoin."
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();
$respArr['data']->rating = (float)$respArr['data']->rating;
$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();
$review = $this->getReviewCount($postData['product_id'],0,0);
$reviewList = $this->getReviewCount($postData['product_id'],$page_limit,$per_page);
if(count($review) > 0){
$total = count($review);
}
if($total >= $per_page){
$totalPages = (int)($total%$per_page == 0?$total/$per_page:($total/$per_page)+1);
}
else{
$totalPages = 1;
}
$respArr['data']->images = '';
$respArr['data']->reviews = '';
if(count($prdt_img) > 0){
$respArr['data']->images = $prdt_img;
}
if(count($reviews) > 0){
$respArr['data']->reviews = $reviews ;
}
if(count($reviewList) > 0){
$respArr['data']->reviews['data'] = $reviewList;
$respArr['data']->reviews['meta'] = array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page);
} else{
$respArr['data']->reviews['data'] = [];
$respArr['data']->reviews['meta'] = array(
'total_pages' => $totalPages,
'total' => $total,
'current_page' => ($page == 0)?1:$page,
'per_page' => $per_page);
}
}
return $respArr;
}
public function getReviewCount($product_id,$start,$per_page){
$this->db->select("PRD.*,TRIM(CONCAT(CUST.first_name,' ',IFNULL(CUST.last_name,''))) as customer_name,CUST.profile_image");
$this->db->join('customers CUST','CUST.customer_id = PRD.customer_id');
$this->db->order_by('PRD.id DESC');
if($start != 0 || $per_page != 0){
$this->db->limit($per_page,$start);
}
$reviews = $this->db->get_where('product_rating PRD',array('PRD.product_id'=>$product_id,'PRD.status'=>'1'))->result();
foreach ($reviews as $key => $value) {
$reviews[$key]->rating = (float)$value->rating;
}
return $reviews;
}
public function saveUserAddress($postData = array()){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.. Try Again Later');
if(empty($postData)){
......@@ -812,10 +872,11 @@ class Webservice_model extends CI_Model {
}
$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
PRD.product_name,PRD.short_description,PRD.part_id,ORDS.format_order_id,ORDS.quantity,ORDS.expected_delivery,ORDS.delivered,ORDS.status AS odr_status,PRDR.id AS review_id
FROM transaction TRANS
JOIN orders ORDS ON ORDS.order_id = TRANS.booking_id
JOIN products PRD ON PRD.product_id = ORDS.product_id
LEFT JOIN product_rating PRDR ON (ORDS.product_id = PRDR.product_id AND ORDS. customer_id = PRDR.customer_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();
......@@ -836,12 +897,253 @@ class Webservice_model extends CI_Model {
return $respArr;
}
$postData['datetime'] = date('Y-m-d h:i:s');
$result = $this->db->get_where('product_rating',array('product_id'=>$postData['product_id'],'customer_id'=>$postData['customer_id']))->row();
if(!empty($result) && !empty($result = $result->row())){
$respArr['status'] = 'error';
$respArr['message'] = 'Sorry Your are Already Rated for this Product';
return $respArr;
}
if($this->db->insert('product_rating',$postData)){
$respArr['status'] = 'success';
$respArr['message'] = 'Rated Successfully';
}
return $respArr;
}
public function get_latest_product_list($start = '',$per_page=''){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.');
$lmt = '';
if($start != 0 || $per_page != 0){
$lmt .= "LIMIT $start,$per_page";
}
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS reviews,PRD.*,PI.image as product_image,BRND.brand_name
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
JOIN product_brand AS BRND ON BRND.brand_id = PRD.brand_id
WHERE PRD.status='1'
GROUP BY PRD.product_id,PI.product_id
ORDER BY PRD.product_id DESC
$lmt");
if(!empty($result) && $result->num_rows() > 0){
$result = $result->result_array();
foreach ($result as $key => $value) {
$result[$key]['rating'] = (float)$value['rating'];
}
$respArr['status'] = 'success';
$respArr['message'] = 'success';
$respArr['data'] = $result;
}
return $respArr;
}
public function get_trending_product_list($start='',$per_page=''){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.');
$lmt = '';
if($start != 0 || $per_page != 0){
$lmt .= "LIMIT $start,$per_page";
}
$sql = $this->db->query("SELECT COUNT(ORDS.product_id) as count,PRD.product_id FROM products PRD LEFT JOIN orders AS ORDS ON ORDS.product_id = PRD.product_id WHERE PRD.status='1' GROUP BY PRD.product_id ORDER BY count DESC $lmt ");
if(!empty($sql) && $sql->num_rows() > 0){
foreach ($sql->result_array() as $key => $value) {
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS reviews,PRD.*,PI.image as product_image,BRND.brand_name
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
JOIN product_brand AS BRND ON BRND.brand_id = PRD.brand_id
WHERE PRD.status='1' AND PRD.product_id =".$value['product_id']);
if(!empty($result) && $result->num_rows() > 0){
$result = $result->row_array();
$result['rating'] = (float)$result['rating'];
$new_array[$key] = $result;
}
}
$respArr['status'] = 'success';
$respArr['message'] = 'success';
$respArr['data'] = $new_array;
}
return $respArr;
}
public function getMyOrders($postData,$start='',$per_page=''){
$respArr = array('status'=>'error');
if(empty($postData['customer_id'])){
$respArr['message'] = "Customer Id is Required";
return $respArr;
}
$lmt = '';
if($start != 0 || $per_page != 0){
$lmt .= "LIMIT $start,$per_page";
}
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS reviews,PRD.product_name,PRD.short_description,PRD.part_id,TRANS.id AS transId,
TRANS.status AS tranStatus,TRANS.datetime,ORD.*,PI.image as product_image
FROM orders ORD
JOIN products PRD ON ORD.product_id = PRD.product_id
JOIN transaction TRANS ON (ORD.order_id = TRANS.booking_id AND TRANS.payment_for= '2')
LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id
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'))
WHERE ORD.customer_id=".$postData['customer_id']." GROUP BY ORD.order_id ORDER BY ORD.order_id DESC $lmt");
if(empty($result) || empty($result = $result->result())){
$respArr['status'] = "error";
return $respArr;
}
foreach ($result as $key => $value) {
$result[$key]->rating = (float)$value->rating;
}
$respArr['status'] = "success";
$respArr['data'] = $result;
return $respArr;
}
public function cancelOrder($postData){
$respArr = array('status'=>'error');
if(empty($postData['order_id'])){
$respArr['message'] = "Order Id is Required";
return $respArr;
}
if($this->db->update('orders',array('status'=>'7'),array('order_id'=>$postData['order_id']))){
$respArr['status'] = 'success';
$respArr['message'] = 'Order Cancelled Successfully';
}
return $respArr;
}
public function getCartData($postData,$start='',$per_page=''){
$respArr = array('status'=>'error');
if(empty($postData['customer_id'])){
$respArr['message'] = "Customer Id is Required";
return $respArr;
}
$lmt = '';
if($start != 0 || $per_page != 0){
$lmt .= "LIMIT $start,$per_page";
}
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS reviews,PRD.product_name,PRD.short_description,PRD.part_id,CRT.cart_id,CRT.quantity
,CRT.product_id,PI.image as product_image,BRND.brand_name,PRD.amount
FROM cart CRT
JOIN products PRD ON CRT.product_id = PRD.product_id
JOIN product_brand BRND ON BRND.brand_id = PRD.brand_id
LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id
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'))
WHERE CRT.customer_id=".$postData['customer_id']." GROUP BY CRT.cart_id ORDER BY CRT.cart_id DESC $lmt");
if(empty($result) || empty($result = $result->result())){
$respArr['status'] = "error";
return $respArr;
}
foreach ($result as $key => $value) {
$result[$key]->rating = (float)$value->rating;
}
$respArr['status'] = "success";
$respArr['data'] = $result;
return $respArr;
}
public function removeCartPrdt($postData){
$respArr = array('status'=>'error');
if(empty($postData['cart_id'])){
$respArr['message'] = "Cart Id is Required";
return $respArr;
}
if($this->db->delete('cart',array('cart_id'=>$postData['cart_id']))){
$respArr['status'] = "success";
}
return $respArr;
}
public function addToCart($postData){
$respArr = array('status'=>'error');
if(empty($postData)){
$respArr['message'] = "All Field is Required";
return $respArr;
}
$postData['created_date'] = date('Y-m-d h:i:s');
if($this->db->insert('cart',$postData)){
$respArr['status'] = 'success';
}
return $respArr;
}
public function getMechanicShops(){
$respArr = array('status'=>'error');
$result = $this->db->get('mechanic_shop');
if(empty($result) || empty($result = $result->result())){
$respArr['status'] = "error";
return $respArr;
}
$respArr['status'] = 'success';
$respArr['data'] = $result;
return $respArr;
}
public function getVehicleBrand(){
$respArr = array('status'=>'error');
$this->db->order_by('maker');
$this->db->where('status','1');
$result = $this->db->get('vehicles_brand');
if(empty($result) || empty($result = $result->result())){
$respArr['status'] = "error";
return $respArr;
}
$respArr['status'] = 'success';
$respArr['data'] = $result;
return $respArr;
}
public function getVehicleModel($postData=array()){
$respArr = array('status'=>'error');
if(!isset($postData['vehBrand_id']) && empty($postData['vehBrand_id'])){
$respArr['message'] = 'Vehicle Brand Id is Required' ;
}
$this->db->order_by('model');
$result = $this->db->get_where('vehicles_model',array('veh_brand_id'=>$postData['vehBrand_id'],'status'=>'1'));
if(empty($result) || empty($result = $result->result())){
$respArr['status'] = "error";
return $respArr;
}
$respArr['status'] = 'success';
$respArr['data'] = $result;
return $respArr;
}
}
?>
......@@ -21,15 +21,21 @@
</div>
<?php } ?>
</div>
<?php if($this->session->userdata['user_type'] == 1 && !empty($mechanic_data)){ ?>
<div class="col-sm-12">
<div class="box box-warning">
<div class="box-header with-border">
<div class="col-md-6">
<h3 class="box-title">Booking Management</h3>
</div>
<div class="col-sm-12">
<div class="box box-warning">
<div class="box-header with-border">
<div class="col-md-6">
<h3 class="box-title">Booking Management</h3>
</div>
<div class="col-md-6" align="right">
<?php if(!empty($bookingData)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Bookings/exportBookingData/'.$mechanic_id) ?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div>
</div>
<?php if($this->session->userdata['user_type'] == 1 && !empty($mechanic_data)){ ?>
<div class="box-body">
<form id="chooseMechForm" role="form" action="<?=base_url('Bookings/listBookings')?>"
method="post" class="validate" data-parsley-validate="" enctype="multipart/form-data">
......@@ -57,10 +63,11 @@
</div>
</form>
</div>
</div>
<?php } ?>
</div>
<?php }
if($this->session->userdata['user_type'] != 1 || ($this->session->userdata['user_type'] == 1)){ ?>
</div>
<?php
if($this->session->userdata['user_type'] != 1 || ($this->session->userdata['user_type'] == 1)){ ?>
<div class="col-xs-12">
<div class="box box-warning">
<div class="box-body">
......
......@@ -52,7 +52,7 @@
<div class="form-group has-feedback">
<label>Date Of Birth</label>
<div class="input-group date" data-provide="datepicker">
<input id="datepicker" type="text" class="form-control required" data-parsley-trigger="change" data-parsley-minlength="2" required="" name="date_of_birth" placeholder="Pick Date Of Birth" autocomplete="off" value="<?= (isset($customer_data) && isset($customer_data->date_of_birth))?$customer_data->date_of_birth:'' ?>">
<input id="datepicker" type="text" class="form-control required" data-parsley-trigger="change" data-parsley-minlength="2" required="" name="date_of_birth" placeholder="Pick Date Of Birth" autocomplete="off" value="<?= (isset($customer_data) && isset($customer_data->date_of_birth))?$customer_data->date_of_birth:'' ?>" style="z-index: 1;">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
......@@ -150,14 +150,36 @@
<div id="searchTyp_1">
<div class="col-md-12">
<div class="col-md-6">
<label>Vehicle Model</label>
<input type="text" class="form-control required" name="vehModel" input="search_params"
placeholder="Enter Vehicle Model" required="">
<label>Vehicle Maker</label>
<!-- <input type="text" class="form-control required" name="vehMaker" input="search_params" placeholder="Enter Vehicle Maker" required> -->
<select name="vehMaker" class="form-control required" data-parsley-trigger="change" required="" id="veh_make" input="search_params">
<option selected disabled value="">Choose Vehicle Make</option>
<?php
foreach ($veh_data['make'] as $key => $value) {
// $cond = (isset($product_data) && isset($product_data->veh_brand_id) &&
//!empty($product_data->veh_brand_id) &&
// $product_data->veh_brand_id == $value->veh_brand_id)?'selected':'';
echo '<option maker="'.$value->veh_brand_id.'" value="'.$value->maker.'">'.$value->maker.'</option>';
}
?>
</select>
</div>
<div class="col-md-6">
<label>Vehicle Maker</label>
<input type="text" class="form-control required" name="vehMaker" input="search_params"
placeholder="Enter Vehicle Maker" required>
<label>Vehicle Model</label>
<!-- <input type="text" class="form-control required" name="vehModel" input="search_params" placeholder="Enter Vehicle Model" required=""> -->
<select name="vehModel" class="form-control required" data-parsley-trigger="change" required="" id="veh_model" input="search_params">
<option selected="" disabled="" value="">Choose Vehicle Model</option>
<?php
if((isset($customer_id) || !empty($customer_id))){
foreach ($veh_data['model'] as $key => $value) {
// $cond = (isset($product_data) && isset($product_data->veh_modal_id) &&
//!empty($product_data->veh_modal_id) &&
// $product_data->veh_modal_id == $value->veh_modal_id)?'selected':'';
echo '<option value="'.$value->model.'" model="'.$value->model.'">'.$value->model.'</option>';
}
}
?>
</select>
</div>
</div>
<div class="col-md-12 padTop10">
......
......@@ -26,6 +26,10 @@
<div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Customers List</h3></div>
<div class="col-md-6" align="right">
<?php
if(!empty($customerData)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Customer/exportCustomerData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url('Customer/addCustomerUser')?>">Add New Customer</a>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div>
......
......@@ -28,6 +28,10 @@
<div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Mechanics List</h3></div>
<div class="col-md-6" align="right">
<?php
if(!empty($user_data)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Mechanic/exportMechanicData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url('Mechanic/addMechanic')?>">Add New Mechanic</a>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div>
......
......@@ -22,19 +22,28 @@
<?php } ?>
</div>
<div class="col-xs-12">
<div class="box box-warning">
<div class="box box-warning">
<div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Order List</h3></div>
<div class="col-md-6" align="right">
<?php if(!empty($orderData)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Orders/exportOrderData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div>
</div>
<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="22%;">Product</th>
<th width="15%;">Customer</th>
<th width="9%;">Quantity</th>
<th width="9%;">Amount</th>
<th width="18%;">Status</th>
<th width="20%;">Action</th>
<th width="17%;">Status</th>
<th width="16%;">Action</th>
</tr>
</thead>
<tbody>
......@@ -47,15 +56,18 @@
<th class="center"><?= $odrData->customer_name ?></th>
<th class="center"><?= $odrData->quantity ?></th>
<th class="center"><?= $odrData->amount ?></th>
<th class="center">
<th class="center" id="orderStatus_<?= encode_param($odrData->order_id) ?>">
<?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 3: echo 'Order Packed <br>
(Deliver by '.$odrData->expected_delivery.')'; break;
case 4: echo 'Order Shipped <br>
(Deliver by '.$odrData->expected_delivery.')'; break;
case 5: echo 'Ordered Delivered <br>
(Deliver by '.$odrData->delivered.')'; break;
case 6: echo 'Returned'; break;
case 7: echo 'Cancelled'; break;
case 8: echo 'Deleted'; break;
......@@ -68,8 +80,9 @@
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>
<?php if($odrData->status == '2' || $odrData->status == '3' || $odrData->status == '4'){ ?>
<a class="btn btn-sm btn-success" order_status="<?= $odrData->status ?>" id="changeOrderStatus" style="background-color:#4CAF50;" order_id="<?= encode_param($odrData->order_id) ?>"><i class="fa fa-cog"></i>Status</a>
<?php } ?>
</td>
</tr>
<?php } }?>
......
......@@ -56,6 +56,13 @@
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 class="form-group">
<label>Part ID</label>
<input type="text" class="form-control" data-parsley-trigger="change" data-parsley-minlength="2" name="part_id"
placeholder="Enter Part ID" value="<?= (isset($product_data->part_id))?$product_data->part_id:'' ?>">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
......@@ -66,7 +73,7 @@
</div>
<div class="form-group">
<label>Amount</label>
<input type="text" class="form-control required" data-parsley-trigger="change"
<input type="number" class="form-control required" data-parsley-trigger="change"
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>
......@@ -137,53 +144,38 @@
</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="">
<select name="vehMake" class="form-control required" data-parsley-trigger="change" required="" id="veh_make">
<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>
<?php
foreach ($veh_data['make'] as $key => $value) {
$cond = (isset($product_data) && isset($product_data->veh_brand_id) &&
!empty($product_data->veh_brand_id) &&
$product_data->veh_brand_id == $value->veh_brand_id)?'selected':'';
echo '<option '.$cond.' maker="'.$value->veh_brand_id.'" value="'.$value->veh_brand_id.'">'.$value->maker.'</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="">
<select name="vehModel" class="form-control required" data-parsley-trigger="change" required="" id="veh_model">
<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>
<?php
if((isset($product_id) || !empty($product_id))){
foreach ($veh_data['model'] as $key => $value) {
$cond = (isset($product_data) && isset($product_data->veh_modal_id) &&
!empty($product_data->veh_modal_id) &&
$product_data->veh_modal_id == $value->veh_modal_id)?'selected':'';
echo '<option '.$cond.' value="'.$value->veh_modal_id.'">'.$value->model.'</option>';
}
}
?>
</select>
</div>
</div>
<input type="hidden" name="cardetail_id" value="<?= (isset($product_data->cardetail_id) && !empty($product_data->cardetail_id))?$product_data->cardetail_id:'' ?>" >
<div class="col-md-6 padTop20">
<div class="form-group">
......
......@@ -28,7 +28,9 @@
<div class="box-header with-border">
<div class="col-md-6"><h3 class="box-title">Brand List</h3></div>
<div class="col-md-6" align="right">
<a class="btn btn-sm btn-primary" href="<?= base_url('Brand/addBrand') ?>">Add New Products</a>
<?php if(!empty($product_data)){ ?>
<a class="btn btn-sm btn-success" href="<?= base_url('Product/exportProductData')?>">Generate Report</a>
<?php } ?>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div>
</div>
......
......@@ -122,15 +122,36 @@
<a href="<?= base_url('Mailtemplate') ?>"><i class="fa fa-book" aria-hidden="true">
</i><span>Mail Template</span></a>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-bars" aria-hidden="true"></i>
<span>Vehicle Management</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
<li>
<a href="<?= base_url('Vehicle/viewVehBrand') ?>">
<i class="fa fa-circle-o text-aqua"></i>
Vehicle Brand
</a>
</li>
<li>
<a href="<?= base_url('Vehicle/viewVehModel') ?>">
<i class="fa fa-circle-o text-aqua"></i>
Vehicle Models
</a>
</li>
</ul>
</li>
<li>
<a href="<?= base_url('Orders/listOrders') ?>"><i class="fa fa-book" aria-hidden="true">
</i><span>Order Management</span></a>
</li>
<?php } ?>
<li>
<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>
......
<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-md-12">
<?php
$url = (!isset($brand_id) || empty($brand_id))?'Vehicle/createbrand':'Vehicle/updateVehBrand/'.$brand_id;
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-md-12">
<div class="box box-warning">
<div class="box-body">
<form role="form" action="<?= base_url($url) ?>" method="post"
class="validate" data-parsley-validate="" enctype="multipart/form-data">
<div class="col-md-6">
<div class="form-group">
<label>Brand Name</label>
<input type="text" class="form-control required" data-parsley-trigger="change"
data-parsley-minlength="2" data-parsley-pattern="^[a-zA-Z0-9\ . _ - ' \/]+$"
name="maker" required="" value="<?= (isset($vehBrand_data->maker))?$vehBrand_data->maker:'' ?>"placeholder="Enter Vehicle Brand">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
<div class="col-md-12">
<div class="box-footer textCenterAlign">
<button type="submit" class="btn btn-primary">Submit</button>
<a href="<?= base_url('Vehicle/viewVehBrand') ?>" class="btn btn-primary">Cancel</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
\ No newline at end of file
<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-md-12">
<?php
$url = (!isset($model_id) || empty($model_id))?'Vehicle/createModel':'Vehicle/updateVehModel/'.$model_id;
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-md-12">
<div class="box box-warning">
<div class="box-body">
<form role="form" action="<?= base_url($url) ?>" method="post"
class="validate" data-parsley-validate="" enctype="multipart/form-data">
<div class="col-md-6">
<div class="form-group">
<label>Select Brand</label>
<select name="veh_brand_id" class="form-control required" placeholder="Select Brand" required="">
<option selected disabled>Choose a Brand</option>
<?php
foreach ($vehBrand_data as $brand) {
$select = (isset($vehModel_data->veh_brand_id) && $brand->veh_brand_id==
$vehModel_data->veh_brand_id)?'selected':'';
echo '<option '.$select.' value="'.$brand->veh_brand_id.'">'.
$brand->maker.
'</option>';
}
?>
</select>
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Model Name</label>
<input type="text" class="form-control required" data-parsley-trigger="change"
data-parsley-minlength="2" data-parsley-pattern="^[a-zA-Z0-9\ . _ - ' \/]+$"
name="model" required="" value="<?= (isset($vehModel_data->model))?$vehModel_data->model:'' ?>"placeholder="Enter Vehicle Model">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
<div class="col-md-12">
<div class="box-footer textCenterAlign">
<button type="submit" class="btn btn-primary">Submit</button>
<a href="<?= base_url('Vehicle/viewVehModel') ?>" class="btn btn-primary">Cancel</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
\ No newline at end of file
<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-md-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-header with-border">
<div class="col-md-6"><h3 class="box-title">Brand List</h3></div>
<div class="col-md-6" align="right">
<a class="btn btn-sm btn-primary" href="<?= base_url('Vehicle/addVehBrand') ?>">Add Vehicle Brand</a>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div>
</div>
<div class="box-body">
<table id="mechanicUsers" class="table table-bordered table-striped datatable ">
<thead>
<tr>
<th class="hidden">ID</th>
<th width="150px;">Brand Name</th>
<th width="100px;">Status</th>
<th width="300px;">Action</th>
</tr>
</thead>
<tbody>
<?php
if(!empty($vehBrand_data)){
foreach($vehBrand_data as $brand) { ?>
<tr>
<th class="hidden"><?= $brand->veh_brand_id ?></th>
<th class="center"><?= $brand->maker ?></th>
<th class="center"><?= ($brand->status == 1)?'Active':'De-activate' ?></th>
<td class="center">
<a class="btn btn-sm btn-primary"
href="<?= base_url('Vehicle/editVehBrand/'.encode_param($brand->veh_brand_id)) ?>">
<i class="fa fa-fw fa-edit"></i>Edit
</a>
<a class="btn btn-sm btn-danger"
href="<?= base_url("Vehicle/changeVehicleStatus/".encode_param($brand->veh_brand_id))."/2" ?>"
onClick="return doconfirm()">
<i class="fa fa-fw fa-trash"></i>Delete
</a> <?php if($brand->status == 1){ ?>
<a class="btn btn-sm btn-success" style="background-color:#ac2925" href="<?= base_url("Vehicle/changeVehicleStatus/".encode_param($brand->veh_brand_id))."/0" ?>">
<i class="fa fa-cog"></i> De-activate
</a>
<?php } else { ?>
<a class="btn btn-sm btn-success" href="<?= base_url("Vehicle/changeVehicleStatus/".encode_param($brand->veh_brand_id))."/1" ?>">
<i class="fa fa-cog"></i> Activate
</a>
<?php } ?>
</td>
</tr>
<?php } } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
\ No newline at end of file
<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-md-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-header with-border">
<div class="col-md-6"><h3 class="box-title">Vehicle Model List</h3></div>
<div class="col-md-6" align="right">
<a class="btn btn-sm btn-primary" href="<?= base_url('Vehicle/addVehModel') ?>">Add Vehicle Model</a>
<a class="btn btn-sm btn-primary" href="<?= base_url() ?>">Back</a>
</div>
</div>
<div class="box-body">
<table id="mechanicUsers" class="table table-bordered table-striped datatable ">
<thead>
<tr>
<th class="hidden">ID</th>
<th width="150px;">Vehicle Brand</th>
<th width="150px;">Vehicle Model</th>
<th width="100px;">Status</th>
<th width="300px;">Action</th>
</tr>
</thead>
<tbody>
<?php
if(!empty($vehModel_data)){
foreach($vehModel_data as $model) { ?>
<tr>
<th class="hidden"><?= $model->veh_modal_id ?></th>
<th class="center"><?= $model->maker ?></th>
<th class="center"><?= $model->model ?></th>
<th class="center"><?= ($model->status == 1)?'Active':'De-activate' ?></th>
<td class="center">
<a class="btn btn-sm btn-primary"
href="<?= base_url('Vehicle/editVehModel/'.encode_param($model->veh_modal_id)) ?>">
<i class="fa fa-fw fa-edit"></i>Edit
</a>
<a class="btn btn-sm btn-danger"
href="<?= base_url("Vehicle/changeModelStatus/".encode_param($model->veh_modal_id))."/2" ?>"
onClick="return doconfirm()">
<i class="fa fa-fw fa-trash"></i>Delete
</a>
<?php if($model->status == 1){ ?>
<a class="btn btn-sm btn-success" style="background-color:#ac2925" href="<?= base_url("Vehicle/changeModelStatus/".encode_param($model->veh_modal_id))."/0" ?>">
<i class="fa fa-cog"></i> De-activate
</a>
<?php } else { ?>
<a class="btn btn-sm btn-success" href="<?= base_url("Vehicle/changeModelStatus/".encode_param($model->veh_modal_id))."/1" ?>">
<i class="fa fa-cog"></i> Activate
</a>
<?php } ?>
</td>
</tr>
<?php } } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
\ No newline at end of file
......@@ -394,6 +394,9 @@
.float-right {
float: right;
}
.float-left {
float: left;
}
.disp-block {
display:block !important;
......
......@@ -436,7 +436,7 @@ jQuery('[id="vehSearch"]').on('click',function(event) {
}
var vehVin = jQuery('[name="vehVin"]').val(),
vehYear = jQuery('[name="vehYear"]').val(),
vehModel = jQuery('[name="vehModel"]').val(),
vehModel = jQuery('option:selected', jQuery('[name="vehModel"]')).attr('model'),
vehMaker = jQuery('[name="vehMaker"]').val();
vehLocVin = jQuery('[name="vehLocationVin"]').val();
vehLocDetls = jQuery('[name="vehLocationDetails"]').val();
......@@ -471,6 +471,7 @@ jQuery('[id="vehSearch"]').on('click',function(event) {
return false;
}
var resp_data = jQuery.parseJSON(resp);
if(resp_data['status'] != '1' || (resp_data['status'] == 1 && resp_data['veh_data'] == '' || resp_data['veh_data'] == null || resp_data['veh_data'] == undefined || resp_data['veh_data'] == 'null' || resp_data['veh_data'] == 'undefined' || resp_data['car_id'] == '' || resp_data['car_id'] == null || resp_data['car_id'] == undefined || resp_data['car_id'] == 'null' || resp_data['car_id'] == 'undefined')){
var msg = 'Something went wrong, please try again later...!';
if(resp_data['status'] == '2')
......@@ -482,27 +483,15 @@ jQuery('[id="vehSearch"]').on('click',function(event) {
return false;
}
var vehHtmlBody = '', car_id = resp_data['car_id'], vehicleData = resp_data['veh_data'];
vehHtmlBody = '<span class="vechile-body disp-block marginBottom-10">'
vehHtmlBody = '<span class="vechile-body disp-block marginBottom-10" style="border:1px solid #e2e2e2;padding: 12px;">'
+vehicleData['vehicle']+
'<div onclick="searchAction('+car_id+',3,0,\''+vehicleData['vehicle']+'\');" class="float-right">'+
'<i class="fa fa-fw fa-close cpoint"></i>'+
'<div class="float-right">'+
'<div class="float-right margin-all" style="margin-top:0px;"><i class="fa fa-fw fa-close cpoint"></i></div>'+
'<div class="float-right margin-all"><button onclick="searchAction('+car_id+',2,0,\''+vehicleData['vehicle']+'\');" type="button" class="btn btn-primary float-right margin-all" style="margin-top: -10px">Add</button></div>'+
'</div>'+
'</span>';
jQuery.each(vehicleData['attributes'], function (index, value) {
if(value == '' || value == undefined || value == 'undefined' || value == null || value == 'null'){
return true;
}
vehHtmlBody += '<div class="col-xs-4">'+
'<div class="col-xs-6"><span class="info-box-text">'+index+'</span></div>'+
'<div class="col-xs-6"><span class="info-box-text">'+value+'</span></div>'+
'</div>';
});
vehHtmlBody += '<div class="col-md-12">'+
'<button onclick="searchAction('+car_id+',3,0,\''+vehicleData['vehicle']+'\');" type="button" class="btn btn-danger float-right margin-all">Remove</button>'+
'<button onclick="searchAction('+car_id+',2,0,\''+vehicleData['vehicle']+'\');" type="button" class="btn btn-primary float-right margin-all">Add</button>'+
'</div>';
jQuery('[id="carSearchResult"]').html('<div id="search_result_'+car_id+'" class="box-body border marginTop10">'+vehHtmlBody+'</div>');
jQuery('[id="carSearchResult"]').html('<div id="search_result_'+car_id+'" class="box-body">'+vehHtmlBody+'</div>');
jQuery('[id="carSearchResult"]').removeClass('hide');
remFullScreenLoader();
slideTo('carSearchResult');
......@@ -1440,9 +1429,22 @@ jQuery('[id="viewOrderDetails"]').on('click',function() {
'<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> '+
'<div class="col-md-6"><label>'+resp_data.order_data.ord_status+'</label></div> '+
'</div> ';
if(resp_data.order_data.status == '3' || resp_data.order_data.status == '4'){
html += '<div class="row"> '+
'<div class="col-md-4">Expected Delivery Date</div>'+
'<div class="col-md-1">:</div>'+
'<div class="col-md-6"><label>'+resp_data.order_data.expected_delivery+'</label></div> '+
'</div> ';
}else if(resp_data.order_data.status == '5'){
html += '<div class="row"> '+
'<div class="col-md-4">Delivered On</div>'+
'<div class="col-md-1">:</div>'+
'<div class="col-md-6"><label>'+resp_data.order_data.delivered+'</label></div> '+
'</div> ';
}
html += '</div> '+
optionalHtml+
'</div>';
......@@ -1466,66 +1468,191 @@ jQuery('[id="viewOrderDetails"]').on('click',function() {
jQuery('[id="changeOrderStatus"]').on('click',function() {
var order_id = jQuery(this).attr('order_id');
var order_status = jQuery(this).attr('order_status');
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>';
}
var stat = '',
dropOption = '<option selected disabled value="">--Change Status--</option>';
switch (order_status){
case '2': stat = 'Order Places';
dropOption += '<option value="3">Order Packed</option>';
dropOption += '<option value="4">Order Shipped</option>';
dropOption += '<option value="5">Order Delivered</option>';
break;
case '3': stat = 'Order Packed';
dropOption += '<option value="4">Order Shipped</option>';
dropOption += '<option value="5">Order Delivered</option>';
break;
case '4': stat = 'Ordered Shipped';
dropOption += '<option value="5">Order Delivered</option>';
break;
}
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...!');
var html = '<form id="changeOrderStatus" role="form" method="post">'+
'<div class="col-md-12" style="padding-top:10px">'+
'<div class="col-md-3"><div class="row"><label>Current Status</label></div></div>'+
'<div class="col-md-1"> : </div>'+
'<div class="col-md-3"><div class="row"><label>'+stat+'</label></div></div>'+
'</div>'+
'<div class="col-md-12" style="padding-top:10px">'+
'<div class="col-md-3"><div class="row"><label>Change Status</label></div></div>'+
'<div class="col-md-1"> : </div>'+
'<div class="col-md-3">'+
'<div class="row">'+
'<select id="orderStatus" onchange="statusChangeFun()" name="status" class="form-control required">'+
dropOption+
'</select>'+
'</div>'+
'</div>'+
'<div class="col-md-5" id="deliverydatediv"></div>'+
'</div>'+
'<input type="hidden" name="order_id" id="order_id" value="'+order_id+'">'+
'<div class="col-md-12" style="padding-top:10px">'+
'<div class="box-footer textCenterAlign">'+
'<button type="button" onclick="changeOrderStatus(event);" class="btn btn-primary">Submit</button>'+
'</div>'+
'</div>'+
'</form>';
remModalLoader();
jQuery('[id="modal_content"]').html(html);
});
function statusChangeFun(){
var status = jQuery('[id="orderStatus"]').val();
if(status == '3' || status == '4'){
jQuery('[id="deliverydatediv"]').html('<div class="col-md-4">'+
'<div class="row">'+
'<label>Deliver On</label>'+
'</div>'+
'</div>'+
'<div class="col-md-1"> : </div>'+
'<div class="col-md-6">'+
'<div class="row">'+
'<input type="date" id="expected_delivery" class="form-control required" name="expected_delivery">'+
'</div>'+
'</div>');
}else if(status == '5'){
jQuery('[id="deliverydatediv"]').html('<div class="col-md-4">'+
'<div class="row">'+
'<label>Delivered on</label>'+
'</div>'+
'</div>'+
'<div class="col-md-1"> : </div>'+
'<div class="col-md-6">'+
'<div class="row">'+
'<input type="date" id="delivery" class="form-control required" name="expected_delivery">'+
'</div>'+
'</div>');
}
}
function changeOrderStatus(e){
e.preventDefault();
var errFlag = '1';
jQuery('[id^="orderStatus"]').removeClass('errInput');
var status = jQuery('[id="orderStatus"]').val();
var order_id = jQuery('[id="order_id"]').val();
if(status == '' || status == 'null' || status == 'NULL' || status == null){
jQuery('[id="orderStatus"]').addClass('errInput');
return false;
}
if(status != '' || status != 'null' || status != 'NULL' || status != null){
errFlag = '0';
if(status == '3' || status == '4'){
var expected_delivery = jQuery('[id="expected_delivery"]').val();
if(expected_delivery == '' || expected_delivery == 'null'){
jQuery('[id="expected_delivery"]').addClass('errInput');
errFlag = '1';
}
}else if(status == '5'){
var expected_delivery = jQuery('[id="delivery"]').val();
if(expected_delivery == '' || expected_delivery == 'null'){
jQuery('[id="delivery"]').addClass('errInput');
errFlag = '1';
}
}
}
if(errFlag == '1'){
return false;
}
jQuery.ajax({
url : base_url+"Orders/changeOrderStatus",
type : 'POST',
data : {'order_id':order_id,'status':status,'expected_date':expected_delivery},
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;
}
else{
remModalLoader();
if(status == '3'){
var html = 'Order Packed <br>(Deliver by '+expected_delivery+')';
}else if(status == '4'){
var html = 'Order Shipped <br>(Deliver by '+expected_delivery+')';
}else if(status == '5'){
var html = 'Order Delivered <br>(Delivered on '+expected_delivery+')';
}
jQuery('[id="orderStatus_'+order_id+'"]').html(html);
jQuery('[id="modal_content"]').html('Status Changed Successfully.');
setTimeout(function(){
modalHide();
}, 1000);
return false;
}
},
fail: function(xhr, textStatus, errorThrown){
remModalLoader();
jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!');
setTimeout(function(){
modalHide();
}, 1000);
},
error: function (ajaxContext) {
remModalLoader();
jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!');
setTimeout(function(){
modalHide();
}, 1000);
}
});
}
jQuery('#veh_make').on('change', function () {
var id = jQuery('option:selected', this).attr('maker');
if(id == '' || id == undefined || id == 'undefined' || id == null || id == 'null'){
return false;
}
showFullScreenLoader();
jQuery.ajax({
type: "POST",
url: base_url + 'Vehicle/getVehModel',
data:'id=' + id,
success: function (data) {
jQuery('#veh_model').html(data);
remFullScreenLoader();
}
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment