Commit c5a2b6d4 by Jansa Jose

mechanic webservices and import

parent ffe7f3d6
......@@ -155,33 +155,5 @@ 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
......@@ -17,9 +17,37 @@ class Dashboard extends CI_Controller {
$template['page'] = 'Dashboard/Dashboard';
$template['page_desc'] = "Control Panel";
$template['page_title'] = "Dashboard";
$template['bookingCount'] = $this->Dashboard_model->getBookingCount();
$template['shopCount'] = $this->Dashboard_model->getMechShpCount();
$template['completeBukngCnt'] = $this->Dashboard_model->getCompletedBookingCount();
$template['pendingBukngCnt'] = $this->Dashboard_model->getPendingBookingCount();
$template['mobileVendors'] = $this->Dashboard_model->getMbleVndrsCount();
$template['mobileMechanics'] = $this->Dashboard_model->getMbleMchnsCount();
$template['customerCount'] = $this->Dashboard_model->getCustomerCount();
$template['productCount'] = $this->Dashboard_model->getProductCount();
$template['productSold'] = $this->Dashboard_model->getProductSoldCount();
$this->load->view('template',$template);
}
public function getOrderSalesReportCount(){
$result = $this->Dashboard_model->getSalesReportCount();
if(count($result) > 0){
echo $result;
}else{
echo 1;
}
}
public function getBookingReportCount(){
$result = $this->Dashboard_model->getBookingReportCount();
if(count($result) > 0){
echo $result;
}else{
echo 1;
}
}
}
......
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class ImportData extends CI_Controller {
public function __construct() {
parent::__construct();
date_default_timezone_set("Asia/Kolkata");
$this->load->model('Import_model');
if(!$this->session->userdata('logged_in')) {
redirect(base_url('Login'));
}
}
public function import_data(){
$template['page'] = 'Import/importdata';
$template['menu'] = 'Import Data';
$template['smenu'] = 'Import Data';
$template['pTitle'] = "Import Data";
$template['import_id'] = '';
$template['pDescription'] = "Import Data";
$this->load->view('template',$template);
}
public function importCsvData(){
if($_POST['import_id'] == '1'){
$status = $this->addMechanic($_FILES);
}
}
public function addMechanic($files =array()){
$this->load->model('Mechanic_model');
if(isset($files) && !empty($files)){
$filename=$_FILES["file"]["name"];
$ext=pathinfo($filename, PATHINFO_EXTENSION);
if($ext=="csv")
{
$file = fopen($filename, "r");
$err = 0;
$errMsg = '';
$count = 0;
$new = array();
while (($mechData = fgetcsv($file, 10000, ",")) !== FALSE){
$count++;
if($count == 1){
continue;
}
if($err == 0 && (!isset($mechData[0]) || empty($mechData[0]))){
$err = 1;
$errMsg = 'Provide a First Name';
}else if($err == 0 && (!isset($mechData[1]) || empty($mechData[1]))){
$err = 1;
$errMsg = 'Provide a Last Name';
}else if($err == 0 && (!isset($mechData[2]) || empty($mechData[2]))){
$err = 1;
$errMsg = 'Provide a Password';
}else if($err == 0 && (!isset($mechData[3]) || empty($mechData[3]))){
$err = 1;
$errMsg = 'Provide a Phone Number';
}else if($err == 0 && (!isset($mechData[4]) || empty($mechData[4]))){
$err = 1;
$errMsg = 'Provide an Email ID';
}else if($err == 0 && (!isset($mechData[5]) || empty($mechData[5]))){
$err = 1;
$errMsg = 'Provide a Display Name';
}else if($err == 0 && (!isset($mechData[6]) || empty($mechData[6]))){
$err = 1;
$errMsg = 'Provide a city';
}else if($err == 0 && (!isset($mechData[7]) || empty($mechData[7]))){
$err = 1;
$errMsg = 'Provide a state';
}else if($err == 0 && (!isset($mechData[8]) || empty($mechData[8]))){
$err = 1;
$errMsg = 'Provide an address';
}else if($err == 0 && (!isset($mechData[9]) || empty($mechData[9]))){
$err = 1;
$errMsg = 'Provide a Functional Area';
}else if($err == 0 && (!isset($mechData[10]) || empty($mechData[10]))){
$err = 1;
$errMsg = 'Provide Work Start Time';
}else if($err == 0 && (!isset($mechData[11]) || empty($mechData[11]))){
$err = 1;
$errMsg = 'Provide Work End Time';
}else if($err == 0 && (!isset($mechData[12]) || empty($mechData[12]))){
$err = 1;
$errMsg = 'Provide a Username';
}else if($err == 0 && ($mechData[10] >= $mechData[11])){
$err = 1;
$errMsg = 'Provide proper Working Hours';
}
$fnLocation = getLocationLatLng($mechData[9]);
if(empty($fnLocation)){
$err = 1;
$errMsg = 'Provide a Valid Functional Area';
}
$mechData[2] = md5($mechData[2]);
$new = array(
'first_name'=>$mechData[0],
'last_name'=>$mechData[1],
'password'=>$mechData[2],
'phone'=>$mechData[3],
'email_id'=>$mechData[4],
'display_name'=>$mechData[5],
'city'=>$mechData[6],
'state'=>$mechData[7],
'address'=>$mechData[8],
'location'=>$mechData[9],
'start_time'=>$mechData[10],
'end_time'=>$mechData[11],
'username'=>$mechData[12],
'location_lat'=>$fnLocation['lat'],
'location_lng'=>$fnLocation['lng'],
'licence'=>$fnLocation['lng'],
'licence_number'=>'',
'licence_exp_date'=>'',
'profile_image'=>'',
'shop_id'=>0
);
$status = $this->Mechanic_model->addMechanic($new);
}
if($count > 0){
$flashMsg = array('message'=>($count -1).' Data Inserted Successfully','class'=>'success');
$this->session->set_flashdata('message', $flashMsg);
redirect(base_url('ImportData/import_data'));
}
}
}
}
// $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.";
// }
}
......@@ -2819,12 +2819,12 @@
$headers = apache_request_headers();
$product_data = $this->Webservice_model->getOrderData($order_id);
$time = explode(' ',$product_data->datetime);
$html = '';
$template = getNotifTemplate();
if(isset($template['invoice_template']) && !empty($template['invoice_template'])){
$html = str_replace(array('{:order_id}','{:order_date}','{:invoice_date}','{:shipping_address}','{:product_name}','{:brand_name}','{:quantity}','{:price}','{:total}'),array($product_data->format_order_id,$product_data->datetime,date('Y-m-d'),$product_data->shipping_address,$product_data->product_name,$product_data->brand_name,$product_data->quantity,$product_data->prd_amount,$product_data->amount),$template['invoice_template']);
$html = str_replace(array('{:order_id}','{:order_date}','{:invoice_date}','{:shipping_address}','{:product_name}','{:brand_name}','{:quantity}','{:price}','{:total}','{:name}'),array($product_data->format_order_id,$time[0],date('Y-m-d'),$product_data->shipping_address,$product_data->product_name,$product_data->brand_name,$product_data->quantity,$product_data->prd_amount,$product_data->amount,$product_data->name),$template['invoice_template']);
}
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
......
<?php
defined('BASEPATH')OR exit('No direct script access allowed');
header('Content-Type: text/html; charset=utf-8');
// Allow from any origin
if(isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day
}
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit(0);
}
class Webservices_mechanic extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('Webservice_mechanic_model');
$this->load->library('form_validation');
$auth = '';
$class = $this->router->fetch_class();
$method = $this->router->fetch_method();
if($this->input->server('REQUEST_METHOD') == 'GET')
$postdata = json_encode($_GET);
else if ($this->input->server('REQUEST_METHOD') == 'POST')
$postdata = file_get_contents("php://input");
if (isset(apache_request_headers()['Auth'])) {
$auth = apache_request_headers()['Auth'];
}
define("PAYSTACK_SECRET_KEY", "sk_test_36658e3260b1d1668b563e6d8268e46ad6da3273");
}
// customer_login
public function sign_in_mechanic(){
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Required Fields are empty.');
if(!isset($postData['user_name']) || empty($postData['user_name']) ||
!isset($postData['password']) || empty($postData['password'] = md5($postData['password']))){
echo json_encode($respArr);exit;
}
$respArr = $this->Webservice_driver_model->checkMechanicLogin($postData);
echo json_encode($respArr); exit;
}
//Get Booked Services
public function get_todays_services(){
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_driver_model->get_mechanic_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;
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_driver_model->getBookedService($postData,0,0,1);
$bookDataResult = $this->Webservice_driver_model->getBookedService($postData,$start,$per_page,1);
$total = 0;
if($bookDataCount['status'] == 'success'){
$total = count($bookDataCount['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($bookDataResult['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $bookDataResult['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 services_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_driver_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
if(!isset($postData['service_id']) || empty($postData['service_id'])){
$respArr['message'] = "Service Id is Required";
return $respArr;
}
$respArr = $this->Webservice_driver_model->getBookedService($postData);
echo json_encode($respArr);exit;
}
public function get_pending_services(){
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_driver_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page;
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_driver_model->getBookedService($postData,0,0,2);
$bookDataResult = $this->Webservice_driver_model->getBookedService($postData,$start,$per_page,2);
$total = 0;
if($bookDataCount['status'] == 'success'){
$total = count($bookDataCount['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($bookDataResult['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $bookDataResult['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 get_service_history(){
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_driver_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page;
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_driver_model->getBookedService($postData,0,0,3);
$bookDataResult = $this->Webservice_driver_model->getBookedService($postData,$start,$per_page,0,3);
$total = 0;
if($bookDataCount['status'] == 'success'){
$total = count($bookDataCount['data']);
}
if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
}
else{
$totalPages = 1;
}
if($bookDataResult['status'] == 'success'){
$respArr = array(
'status' => 'success',
'message'=>'success',
'data' => $bookDataResult['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;
}
}
?>
......@@ -204,13 +204,10 @@ class Booking_model extends CI_Model {
$cond .= (!empty($booking_id))?" AND BK.booking_id='".$booking_id."' ":"";
$cond .= (!empty($mechanic_id))?" AND MBK.mechanic_id='".$mechanic_id."' ":"";
$sql = "SELECT GROUP_CONCAT(DISTINCT(MBK.mechanic_id)) AS mechanic_ids,BK.booking_id,BK.customer_id,
BK.customer_veh_id,BK.scheduled_date,BK.scheduled_time,BK.cost,BK.status,BK.mileage,
BK.issues_selected,VEH.car_name,BK.custom_issue_data,VEH.car_model,VEH.car_maker,
VEH.car_model_year,VEH.car_vin,VEH.vehicle_data,BK.car_location,BK.car_loc_lat,
BK.car_loc_lng,CUST.first_name AS custFirstName,CUST.last_name AS custLastName,
CUST.phone,CUST.email,CUST.address,CUST.profile_image,CUST.date_of_birth,
CUSQTE.custom_id,MBK.status AS mech_status
$sql = "SELECT GROUP_CONCAT(DISTINCT(MBK.mechanic_id)) AS mechanic_ids,MBK.amount as cost,BK.booking_id,BK.customer_id,BK.customer_veh_id,BK.scheduled_date,BK.scheduled_time,BK.status,BK.mileage,BK.issues_selected,VEH.car_name,BK.custom_issue_data,VEH.car_model,VEH.car_maker,
VEH.car_model_year,VEH.car_vin,VEH.vehicle_data,BK.car_location,BK.car_loc_lat,BK.car_loc_lng,
CUST.first_name AS custFirstName,CUST.last_name AS custLastName,CUST.phone,CUST.email,CUST.address
,CUST.profile_image,CUST.date_of_birth,CUSQTE.custom_id,MBK.status AS mech_status
FROM bookings AS BK
INNER JOIN mechanic_booking AS MBK ON (MBK.booking_id=BK.booking_id)
INNER JOIN customers AS CUST ON (CUST.customer_id=BK.customer_id)
......
......@@ -4,5 +4,89 @@ class Dashboard_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function getBookingCount(){
$result = $this->db->get_where('bookings')->result();
return count($result);
}
public function getMechShpCount(){
$result = $this->db->get_where('mechanic_shop',array('status'=>'1'))->result();
return count($result);
}
public function getCompletedBookingCount(){
$result = $this->db->get_where('bookings',array('status'=>'3'))->result();
return count($result);
}
public function getPendingBookingCount(){
$result = $this->db->get_where('bookings',array('status'=>'1'))->result();
return count($result);
}
public function getMbleVndrsCount(){
$result = $this->db->get_where('mechanic',array('shop_id'=>'1'))->result();
return count($result);
}
public function getMbleMchnsCount(){
$result = $this->db->get_where('mechanic',array('shop_id'=>'0'))->result();
return count($result);
}
public function getCustomerCount(){
$result = $this->db->get_where('customers',array('status'=>'1'))->result();
return count($result);
}
public function getProductCount(){
$result = $this->db->get_where('products',array('status'=>'1'))->result();
return count($result);
}
public function getProductSoldCount(){
$result = $this->db->query("SELECT SUM(`quantity`) as count FROM `orders` WHERE status IN('2,3,4,5')")->row();
return $result->count;
}
public function getSalesReportCount(){
$query = $this->db->query("
SELECT COUNT(ORDS.order_id) AS count, SUBSTRING_INDEX(TRANS.datetime, '-', 1) AS year
FROM `orders` AS `ORDS`
INNER JOIN `transaction` AS `TRANS` ON (`TRANS`.`booking_id` = `ORDS`.`order_id`)
WHERE `TRANS`.`payment_for`='2' AND `TRANS`.`status` = '1'
GROUP BY SUBSTRING_INDEX(TRANS.datetime,'-',1)");
$result = array();
if(empty($query) || $query->num_rows < 0 || empty($query = $query->result_array())){
return $result;
}
foreach($query as $value){
$result[] = array('y'=>$value['year'],'item1'=>$value['count']);
}
return json_encode($result);
}
public function getBookingReportCount(){
$query = $this->db->query("
SELECT COUNT(BUK.booking_id) AS count, SUBSTRING_INDEX(TRANS.datetime, '-', 1) AS year
FROM `bookings` AS `BUK`
INNER JOIN `transaction` AS `TRANS` ON (`TRANS`.`booking_id` = `BUK`.`booking_id`)
WHERE `TRANS`.`payment_for`='1' AND `TRANS`.`status` = '1'
GROUP BY SUBSTRING_INDEX(TRANS.datetime,'-',1)");
$result = array();
if(empty($query) || $query->num_rows < 0 || empty($query = $query->result_array())){
return $result;
}
foreach($query as $value){
$result[] = array('y'=>$value['year'],'item1'=>$value['count']);
}
return json_encode($result);
}
}
?>
\ No newline at end of file
<?php
class Import_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function addShop($shop_data = array()){
if(empty($shop_data)){
return 0;
}
$status = $this->db->insert('mechanic_shop',$shop_data);
return ($status)?1:0;
}
function getShop($shop_id = '',$view_all = 0){
$cond = ($view_all != 0)?' status IN (0,1) ':' status IN (1) ';
$cond .= (!empty($shop_id))?" AND shop_id = '$shop_id'":"";
$result = $this->db->query("SELECT * FROM mechanic_shop WHERE $cond");
if(empty($result)){
return;
}
return (empty($shop_id))?$result->result():$result->row();
}
function changeStatus($shop_id = '', $status = '0'){
if(empty($shop_id)){
return 0;
}
$status = $this->db->update('mechanic_shop',array('status'=>$status), array('shop_id'=>$shop_id));
return $status;
}
function updateShop($shop_id = '', $shop_data = array()){
if(empty($shop_id) || empty($shop_data)){
return 0;
}
$status = $this->db->update('mechanic_shop',$shop_data,array('shop_id'=>$shop_id));
return ($status)?1:0;
}
}
?>
\ No newline at end of file
......@@ -39,7 +39,15 @@ class Vehicle_model extends CI_Model {
$vehData = $this->db->get_where('customer_vehicle',$cond);
if(!empty($vehData)){
return $vehData->result();
$vehData = $vehData->result();
foreach ($vehData as $key => $value) {
$make = $this->db->get_where('vehicles_brand',array('maker'=>$value->car_maker))->row();
$vehData[$key]->veh_brand_id = $make->veh_brand_id;
$model = $this->db->get_where('vehicles_model',array('model'=>$value->car_model,'veh_brand_id'=>$make->veh_brand_id))->row();
$vehData[$key]->veh_model_id = $model->veh_modal_id;
}
return $vehData;
}
return 0;
}
......
<?php
class Webservice_mechanic_model extends CI_Model {
function __construct() {
parent::__construct();
date_default_timezone_set('Asia/Kolkata');
}
/***************************************************************************************/
/****************************************Mobile API's***********************************/
function checkMechanicLogin($userLogData){
$respArr = array('status'=>'error');
if(empty($userLogData)){
return $respArr;
}
$this->db->select("MCH.mechanic_id as user_id,TRIM(CONCAT(MCH.first_name,' ' ,IFNULL(MCH.last_name,''))) as name,MCH.email_id,MCH.phone as phone_number,IFNULL(MCHSHP.shop_name,'') as workshop_name,MCH.city,MCH.location as place");
$this->db->from('admin_users as AU');
$this->db->join('mechanic as MCH','MCH.mechanic_id = AU.id');
$this->db->join('mechanic_shop as MCHSHP','MCHSHP.shop_id = MCH.shop_id','LEFT');
$this->db->where(array('AU.username'=>$userLogData['user_name'],'AU.password'=>$userLogData['password']));
$result = $this->db->get();
if(empty($result) || $result->num_rows() < 0 || empty($mechData = $result->row())){
$respArr['message'] = "Username or Password is Incorrect";
return $respArr;
}
$authdata = $this->insert_auth($mechData->user_id);
if($authdata){
$mechData->auth_token = $authdata;
$respArr['data'] = $mechData;
$respArr['status'] = 'success';
}
return $respArr;
}
public function insert_auth($id){
$static_string = time();
$authToken = 'Dcarfixs'.sha1($static_string);
$mechData = $this->db->get_where('authtable_mechanic',array('mechanic_id'=>$id));
if(!empty($mechData) && $mechData->num_rows() > 0){
$mechData = $mechData->row();
$authToken = $mechData->authtoken;
} else {
$this->db->insert('authtable_mechanic',array('mechanic_id'=>$id,'authtoken'=>$authToken));
}
return $authToken;
}
public function get_mechanic_authtoken($auth = ''){
$respArr = array('status'=>0,'error'=>'901','message'=>'Something Went Wrong.');
if(empty($auth)){
return $respArr;
}
$auth = $this->db->get_where('authtable_mechanic',array('authtoken'=>$auth));
if(!empty($auth) && $auth->num_rows() >= 1 && !empty($mechAuth = $auth->row_array())){
$respArr['status'] = 'success';
$respArr['data'] = $mechAuth;
}else{
$respArr['status'] = 'error';
$respArr['error'] = '902';
$respArr['message'] = 'Authtoken is not Valid';
}
return $respArr;
}
public function getBookedService($postData = array(),$start = '',$per_page = '',$type=0,$status=1){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.. Try Again Later');
if(empty($postData)){
$respArr['message'] = "All Field is Required";
return $respArr;
}
$where = array('BUK.status'=>$status,'MCHBUK.mechanic_id'=>$postData['mechanic_id']);
if(isset($postData['service_id']) && !empty($postData['service_id'])){
$where['BUK.booking_id'] = $postData['service_id'];
}
if($type == 1){
$where['BUK.scheduled_date'] = date('Y-m-d');
}else if($type == 2){
$where['BUK.scheduled_date'] = date("Y-m-d", strtotime('tomorrow'));
}
$this->db->select("BUK.scheduled_date as date,BUK.scheduled_time as time,BUK.booking_id as service_id,CSTVEH.car_name,BUK.mileage,BUK.issues_selected,BUK.custom_issue_data,BUK.service_type as type,MCHBUK.amount as total_amount");
$this->db->from('bookings as BUK');
$this->db->join('customer_vehicle as CSTVEH','CSTVEH.customer_veh_id = BUK.customer_veh_id');
$this->db->join('mechanic_booking as MCHBUK','MCHBUK.booking_id = BUK.booking_id');
$this->db->where($where);
if($start != 0 || $per_page != 0){
$this->db->limit($per_page,$start);
}
$bookData = $this->db->get();
//pr($this->db->last_query());
if(!empty($bookData) && $bookData->num_rows() > 0){
$bookData = $bookData->result_array();
foreach ($bookData as $key => $value) {
$issues_selected = json_decode($value['issues_selected']);
$custom_issue_data = json_decode($value['custom_issue_data']);
$bookData[$key]['service_image'] = $custom_issue_data->optionalImages;
$bookData[$key]['service_message'] = $custom_issue_data->optionlaDescription;
unset($bookData[$key]['issues_selected'],$bookData[$key]['custom_issue_data']);
$new = array();
foreach ($issues_selected as $issue_key => $issue_value) {
$sql = "SELECT IC.*, MI.custom_description, MI.custom_service_fee
FROM issues_category AS IC
LEFT JOIN mechanic_issues AS MI ON (MI.issue_cat_id=IC.issue_cat_id AND
MI.mechanic_id='".$postData['mechanic_id']."' AND MI.status='1')
WHERE IC.status='1' AND IC.issue_cat_id='".$issue_value->sub_issue_id."'";
$issue_data = $this->db->query($sql)->row();
if(!empty($issue_data)){
if($issue_data->custom_description != '' && $issue_data->custom_service_fee != ''){
$new[$issue_key]['description'] = $issue_data->custom_description;
$new[$issue_key]['service_fee'] = $issue_data->custom_service_fee;
}else{
$new[$issue_key]['description'] = $issue_data->default_description;
$new[$issue_key]['service_fee'] = $issue_data->default_service_fee;
}
$new[$issue_key]['issue_name'] = $issue_data->issue_category;
}
$bookData[$key]['service_name'] = $new;
}
}
$respArr['status'] = 'success';
$respArr['message'] = 'success';
$respArr['data'] = $bookData;
}
return $respArr;
}
}
?>
......@@ -678,7 +678,7 @@ class Webservice_model extends CI_Model {
WHERE product_id=PRD.product_id AND PRD.status='1')) ".$cartJoin."
WHERE $where PRD.status='1'
GROUP BY PRD.product_id,PI.product_id $lmt");
//pr($this->db->last_query());
if(!empty($result) && $result->num_rows() > 0){
$result = $result->result_array();
foreach ($result as $key => $value) {
......@@ -1408,12 +1408,13 @@ class Webservice_model extends CI_Model {
}
public function getOrderData($order_id){
$this->db->select("CONCAT(CUSTADRS.house_no, ' ', CUSTADRS.area, ' ', CUSTADRS.city, ' ', CUSTADRS.state) as shipping_address,PRD.product_name,PRD.amount as prd_amount,PRDBRD.brand_name,ORDS.quantity,ORDS.amount,ORDS.format_order_id,TRANS.datetime");
$this->db->select("CONCAT(CUSTADRS.house_no, ' ', CUSTADRS.area, ' ', CUSTADRS.city, ' ', CUSTADRS.state) as shipping_address,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as name,PRD.product_name,PRD.amount as prd_amount,PRDBRD.brand_name,ORDS.quantity,ORDS.amount,ORDS.format_order_id,TRANS.datetime");
$this->db->from("orders AS ORDS");
$this->db->join("transaction AS TRANS","TRANS.booking_id = ORDS.order_id AND TRANS.payment_for = '2'");
$this->db->join("products AS PRD","PRD.product_id = ORDS.product_id");
$this->db->join("product_brand AS PRDBRD","PRDBRD.brand_id = PRD.brand_id");
$this->db->join("customer_address AS CUSTADRS","ORDS.address_id = CUSTADRS.id");
$this->db->join("customers AS CUST","ORDS.customer_id = CUST.customer_id");
$this->db->where('ORDS.format_order_id',$order_id);
return $this->db->get()->row();
}
......
......@@ -72,7 +72,7 @@
<div class="col-sm-6">
<div class="form-group">
<label>Invoice Template</label>
<p>Order Id => {:order_id} , Order Date => {:order_date}, Invoice Date => {:invoice_date}, Shipping Address => {:shipping_address}, Product Name => {:product_name}, Brand Name => {:brand_name} , Quantity => {:quantity} , Price => {:price} , Total => {:total}</p>
<p>Customer Name => {:name} , Order Id => {:order_id} , Order Date => {:order_date}, Invoice Date => {:invoice_date}, Shipping Address => {:shipping_address}, Product Name => {:product_name}, Brand Name => {:brand_name} , Quantity => {:quantity} , Price => {:price} , Total => {:total}</p>
<textarea id="rich_editor_6" type="text" class="ip_reg_form_input form-control reset-form-custom" placeholder="Invoice Template" name="invoice_template" style="height:108px;" data-parsley-trigger="change"><?= $notificationData->invoice_template ?></textarea>
</div>
</div>
......
......@@ -19,7 +19,8 @@
<script src="https://cdn.ckeditor.com/4.5.7/standard/ckeditor.js"></script>
<script src="<?= base_url('assets/js/bootstrap-datepicker.js') ?>"></script>
<script src="<?= base_url('assets/js/clockpicker.js') ?>" type="text/javascript"></script>
<script src="<?= base_url('assets/js/raphael.min.js') ?>"></script>
<script src="<?= base_url('assets/js/morris.min.js')?>"></script>
<script>
jQuery('.clockpicker').clockpicker();
......
......@@ -22,6 +22,7 @@
<link rel="stylesheet" href="<?= base_url('assets/css/parsley/parsley.css') ?>">
<link rel="stylesheet" href="<?= base_url('assets/css/bootstrap-datepicker3.css') ?>">
<link rel="stylesheet" href="<?= base_url('assets/css/clockpicker.css') ?>" type="text/css" >
<link rel="stylesheet" href="<?= base_url('assets/css/morris.css')?>">
<script src="<?= base_url('assets/js/jQuery-2.1.4.min.js') ?>"></script>
</head>
\ No newline at end of file
......@@ -22,7 +22,7 @@
<li class="treeview">
<a href="#">
<i class="fa fa-bars" aria-hidden="true"></i>
<span>Shop Management</span>
<span>Auto Service Centers</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
......@@ -43,7 +43,7 @@
<li class="treeview">
<a href="#">
<i class="fa fa-bars" aria-hidden="true"></i>
<span>Service Orders</span>
<span>Services</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
......@@ -147,6 +147,10 @@
<a href="<?= base_url('Orders/listOrders') ?>"><i class="fa fa-book" aria-hidden="true">
</i><span>Order Management</span></a>
</li>
<li>
<a href="<?= base_url('ImportData/import_data') ?>"><i class="fa fa-book" aria-hidden="true">
</i><span>Import Data</span></a>
</li>
<?php } ?>
<li>
<a href="<?= base_url('Bookings/listBookings') ?>"><i class="fa fa-book" aria-hidden="true">
......
.morris-hover{position:absolute;z-index:1000}.morris-hover.morris-default-style{border-radius:10px;padding:6px;color:#666;background:rgba(255,255,255,0.8);border:solid 2px rgba(230,230,230,0.8);font-family:sans-serif;font-size:12px;text-align:center}.morris-hover.morris-default-style .morris-hover-row-label{font-weight:bold;margin:0.25em 0}
.morris-hover.morris-default-style .morris-hover-point{white-space:nowrap;margin:0.1em 0}
......@@ -1655,4 +1655,11 @@ jQuery('#veh_make').on('change', function () {
remFullScreenLoader();
}
});
});
\ No newline at end of file
});
jQuery('[id="import_id"]').on('change',function() {
var id = jQuery(this).val();
if(id != '' || id != undefined || id != 'undefined' || id != null || id != 'null'){
$('#import_file').removeClass('hide');
}
})
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