Commit 1367c426 by Jansa Jose

changes in admin panel and webservice

parent d862c06e
...@@ -1573,12 +1573,14 @@ ...@@ -1573,12 +1573,14 @@
!empty($result['data']['authorization_url'])){ !empty($result['data']['authorization_url'])){
$redir = $result['data']['authorization_url']; $redir = $result['data']['authorization_url'];
header("Location: ".$redir); header("Location: ".$redir);
} }else{
//pr($result); $ref = $postdata['reference'];
$status = $this->Webservice_model->transactionResp($postdata['reference'],$result,$payFor); $status = $this->Webservice_model->transactionResp($ref,$result,$payFor);
$this->fail(); $this->fail();
} }
}
public function verify_payment($ref='',$payFor='1') { public function verify_payment($ref='',$payFor='1') {
if(empty($ref)){ if(empty($ref)){
$this->fail(); $this->fail();
......
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
defined('BASEPATH')OR exit('No direct script access allowed'); defined('BASEPATH')OR exit('No direct script access allowed');
header('Content-Type: text/html; charset=utf-8'); header('Content-Type: text/html; charset=utf-8');
// Allow from any origin
if(isset($_SERVER['HTTP_ORIGIN'])) { if(isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day header('Access-Control-Max-Age: 86400'); // cache for 1 day
} }
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
...@@ -28,27 +26,21 @@ ...@@ -28,27 +26,21 @@
$auth = ''; $auth = '';
$class = $this->router->fetch_class(); $class = $this->router->fetch_class();
$method = $this->router->fetch_method(); $method = $this->router->fetch_method();
if($this->input->server('REQUEST_METHOD') == 'GET') if($this->input->server('REQUEST_METHOD') == 'GET')
$postdata = json_encode($_GET); $postdata = json_encode($_GET);
else if ($this->input->server('REQUEST_METHOD') == 'POST') else if ($this->input->server('REQUEST_METHOD') == 'POST')
$postdata = file_get_contents("php://input"); $postdata = file_get_contents("php://input");
if (isset(apache_request_headers()['Auth'])) { if (isset(apache_request_headers()['Auth'])) {
$auth = apache_request_headers()['Auth']; $auth = apache_request_headers()['Auth'];
} }
define("PAYSTACK_SECRET_KEY", "sk_test_36658e3260b1d1668b563e6d8268e46ad6da3273"); define("PAYSTACK_SECRET_KEY", "sk_test_36658e3260b1d1668b563e6d8268e46ad6da3273");
} }
// customer_login // customer_login
public function sign_in_mechanic(){ public function sign_in_mechanic(){
header('Content-type: application/json'); header('Content-type: application/json');
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
$respArr = array('status'=>'error','message'=>'Required Fields are empty.'); $respArr = array('status'=>'error','message'=>'Required Fields are empty.');
if(!isset($postData['user_name']) || empty($postData['user_name']) || if(!isset($postData['user_name']) || empty($postData['user_name']) ||
!isset($postData['password']) || empty($postData['password'] = md5($postData['password']))){ !isset($postData['password']) || empty($postData['password'] = md5($postData['password']))){
...@@ -62,43 +54,33 @@ ...@@ -62,43 +54,33 @@
public function get_todays_services(){ public function get_todays_services(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){ if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error'; $respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required'; $respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
$per_page = 10; $per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1; $page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page; $start = ($page - 1) * $per_page;
$postData['mechanic_id'] = $authRes['data']['mechanic_id']; $postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,1); $bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,1);
$bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,1); $bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,1);
$total = 0; $total = 0;
if($bookDataCount['status'] == 'success'){ if($bookDataCount['status'] == 'success'){
$total = count($bookDataCount['data']); $total = count($bookDataCount['data']);
} }
if($total >= $per_page){ if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1); $totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
} }
else{ else{
$totalPages = 1; $totalPages = 1;
} }
if($bookDataResult['status'] == 'success'){ if($bookDataResult['status'] == 'success'){
$respArr = array( $respArr = array(
'status' => 'success', 'status' => 'success',
...@@ -130,71 +112,56 @@ ...@@ -130,71 +112,56 @@
public function services_details(){ public function services_details(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){ if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error'; $respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required'; $respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id']; $postData['mechanic_id'] = $authRes['data']['mechanic_id'];
if(!isset($postData['service_id']) || empty($postData['service_id'])){ if(!isset($postData['service_id']) || empty($postData['service_id'])){
$respArr['message'] = "Service Id is Required"; $respArr['message'] = "Service Id is Required";
return $respArr; return $respArr;
} }
$respArr = $this->Webservice_mechanic_model->getBookedService($postData); $respArr = $this->Webservice_mechanic_model->getBookedService($postData);
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
public function get_service_history(){ public function get_service_history(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){ if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error'; $respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required'; $respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
$per_page = 10; $per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1; $page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page; $start = ($page - 1) * $per_page;
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id']; $postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,0,3); $bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,0,3);
$bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,0,3); $bookDataResult = $this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,0,3);
$total = 0; $total = 0;
if($bookDataCount['status'] == 'success'){ if($bookDataCount['status'] == 'success'){
$total = count($bookDataCount['data']); $total = count($bookDataCount['data']);
} }
if($total >= $per_page){ if($total >= $per_page){
$totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1); $totalPages = (int)($total % $per_page ==0 ? $total / $per_page :($total / $per_page)+1);
} }
else{ else{
$totalPages = 1; $totalPages = 1;
} }
if($bookDataResult['status'] == 'success'){ if($bookDataResult['status'] == 'success'){
$respArr = array( $respArr = array(
'status' => 'success', 'status' => 'success',
...@@ -226,34 +193,28 @@ ...@@ -226,34 +193,28 @@
public function logout(){ public function logout(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){ if(!isset($headers['Auth']) || empty($headers['Auth'])){
$respArr['status'] = 'error'; $respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required'; $respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']); $authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
$respArr=$this->Webservice_mechanic_model->mechanic_logout($authRes['data']['mechanic_id']);
$respArr = $this->Webservice_mechanic_model->mechanic_logout($authRes['data']['mechanic_id']);
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
public function forgot_password(){ public function forgot_password(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
if(!isset($postData['user_name']) || empty($postData['user_name'])){ if(!isset($postData['user_name']) || empty($postData['user_name'])){
$respArr['message'] = "Username is Required"; $respArr['message'] = "Username is Required";
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$respArr = $this->Webservice_mechanic_model->forgot_password($postData['user_name']); $respArr = $this->Webservice_mechanic_model->forgot_password($postData['user_name']);
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
...@@ -261,10 +222,8 @@ ...@@ -261,10 +222,8 @@
public function change_password(){ public function change_password(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
$respArr = array("status"=>"error"); $respArr = array("status"=>"error");
if(!isset($postData['user_name']) || empty($postData['user_name'])){ if(!isset($postData['user_name']) || empty($postData['user_name'])){
$respArr['message'] = "Username is Required"; $respArr['message'] = "Username is Required";
...@@ -273,7 +232,6 @@ ...@@ -273,7 +232,6 @@
$respArr['message'] = "Password is Required"; $respArr['message'] = "Password is Required";
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
$respArr = $this->Webservice_mechanic_model->change_password($postData); $respArr = $this->Webservice_mechanic_model->change_password($postData);
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
...@@ -281,10 +239,8 @@ ...@@ -281,10 +239,8 @@
public function start_service(){ public function start_service(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
$respArr = array("status"=>"error"); $respArr = array("status"=>"error");
if(!isset($postData['service_id']) || empty($postData['service_id'])){ if(!isset($postData['service_id']) || empty($postData['service_id'])){
$respArr['message'] = "Booking Id is Required"; $respArr['message'] = "Booking Id is Required";
...@@ -301,10 +257,8 @@ ...@@ -301,10 +257,8 @@
public function stop_service(){ public function stop_service(){
header('Content-type: application/json'); header('Content-type: application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post, true); $postData = json_decode($post, true);
if(!isset($postData['service_id']) || empty($postData['service_id'])){ if(!isset($postData['service_id']) || empty($postData['service_id'])){
$respArr['message'] = "Booking Id is Required"; $respArr['message'] = "Booking Id is Required";
return $respArr; return $respArr;
...@@ -312,7 +266,6 @@ ...@@ -312,7 +266,6 @@
$respArr['message'] = "Emergency Field is Required"; $respArr['message'] = "Emergency Field is Required";
return $respArr; return $respArr;
} }
$respArr = $this->Webservice_mechanic_model->start_service($postData,1); $respArr = $this->Webservice_mechanic_model->start_service($postData,1);
echo json_encode($respArr);exit; echo json_encode($respArr);exit;
} }
......
...@@ -6,47 +6,91 @@ class Dashboard_model extends CI_Model { ...@@ -6,47 +6,91 @@ class Dashboard_model extends CI_Model {
} }
public function getBookingCount(){ public function getBookingCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('bookings')->result(); $result = $this->db->get_where('bookings')->result();
}else{
$id = $this->session->userdata('id');
$this->db->join('mechanic_booking','mechanic_booking.booking_id = bookings.booking_id','left');
$result = $this->db->get_where('bookings',array('mechanic_booking.mechanic_id'=>$id))->result();
}
return count($result); return count($result);
} }
public function getMechShpCount(){ public function getMechShpCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('mechanic_shop',array('status'=>'1'))->result(); $result = $this->db->get_where('mechanic_shop',array('status'=>'1'))->result();
}else{
return 0;
}
return count($result); return count($result);
} }
public function getCompletedBookingCount(){ public function getCompletedBookingCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('bookings',array('status'=>'3'))->result(); $result = $this->db->get_where('bookings',array('status'=>'3'))->result();
}else{
$id = $this->session->userdata('id');
$this->db->join('mechanic_booking','mechanic_booking.booking_id = bookings.booking_id','left');
$result = $this->db->get_where('bookings',array('mechanic_booking.mechanic_id'=>$id,'bookings.status'=>'3'))->result();
}
return count($result); return count($result);
} }
public function getPendingBookingCount(){ public function getPendingBookingCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('bookings',array('status'=>'1'))->result(); $result = $this->db->get_where('bookings',array('status'=>'1'))->result();
}else{
$id = $this->session->userdata('id');
$this->db->join('mechanic_booking','mechanic_booking.booking_id = bookings.booking_id','left');
$result = $this->db->get_where('bookings',array('mechanic_booking.mechanic_id'=>$id,'bookings.status'=>'1'))->result();
}
return count($result); return count($result);
} }
public function getMbleVndrsCount(){ public function getMbleVndrsCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('mechanic',array('shop_id'=>'1'))->result(); $result = $this->db->get_where('mechanic',array('shop_id'=>'1'))->result();
}else{
return 0;
}
return count($result); return count($result);
} }
public function getMbleMchnsCount(){ public function getMbleMchnsCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('mechanic',array('shop_id'=>'0'))->result(); $result = $this->db->get_where('mechanic',array('shop_id'=>'0'))->result();
}else{
return 0;
}
return count($result); return count($result);
} }
public function getCustomerCount(){ public function getCustomerCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('customers',array('status'=>'1'))->result(); $result = $this->db->get_where('customers',array('status'=>'1'))->result();
}else{
return 0;
}
return count($result); return count($result);
} }
public function getProductCount(){ public function getProductCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->get_where('products',array('status'=>'1'))->result(); $result = $this->db->get_where('products',array('status'=>'1'))->result();
}else{
$id = $this->session->userdata('id');
$result = $this->db->get_where('products',array('status'=>'1','created_by'=>$id))->result();
}
return count($result); return count($result);
} }
public function getProductSoldCount(){ public function getProductSoldCount(){
if($this->session->userdata('user_type') == 1){
$result = $this->db->query("SELECT SUM(`quantity`) as count FROM `orders` WHERE status IN('2,3,4,5')")->row(); $result = $this->db->query("SELECT SUM(`quantity`) as count FROM `orders` WHERE status IN('2,3,4,5')")->row();
}else{
$id = $this->session->userdata('id');
$result = $this->db->query("SELECT SUM(`quantity`) as count FROM `orders` INNER JOIN products ON products.product_id = orders.product_id WHERE orders.status IN('2,3,4,5') AND products.created_by='$id'")->row();
}
return $result->count; return $result->count;
} }
......
...@@ -4,10 +4,8 @@ ...@@ -4,10 +4,8 @@
parent::__construct(); parent::__construct();
date_default_timezone_set('Asia/Kolkata'); date_default_timezone_set('Asia/Kolkata');
} }
/***************************************************************************************/ /***************************************************************************************/
/****************************************Mobile API's***********************************/ /****************************************Mobile API's***********************************/
function checkMechanicLogin($userLogData){ function checkMechanicLogin($userLogData){
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
if(empty($userLogData)){ if(empty($userLogData)){
...@@ -19,12 +17,10 @@ function checkMechanicLogin($userLogData){ ...@@ -19,12 +17,10 @@ function checkMechanicLogin($userLogData){
$this->db->join('mechanic_shop as MCHSHP','MCHSHP.shop_id = MCH.shop_id','LEFT'); $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'])); $this->db->where(array('AU.username'=>$userLogData['user_name'],'AU.password'=>$userLogData['password']));
$result = $this->db->get(); $result = $this->db->get();
if(empty($result) || $result->num_rows() < 0 || empty($mechData = $result->row())){ if(empty($result) || $result->num_rows() < 0 || empty($mechData = $result->row())){
$respArr['message'] = "Username or Password is Incorrect"; $respArr['message'] = "Username or Password is Incorrect";
return $respArr; return $respArr;
} }
$authdata = $this->insert_auth($mechData->user_id); $authdata = $this->insert_auth($mechData->user_id);
if($authdata){ if($authdata){
$mechData->auth_token = $authdata; $mechData->auth_token = $authdata;
...@@ -41,10 +37,9 @@ public function insert_auth($id){ ...@@ -41,10 +37,9 @@ public function insert_auth($id){
if(!empty($mechData) && $mechData->num_rows() > 0){ if(!empty($mechData) && $mechData->num_rows() > 0){
$mechData = $mechData->row(); $mechData = $mechData->row();
$authToken = $mechData->authtoken; $authToken = $mechData->authtoken;
} else { }else {
$this->db->insert('authtable_mechanic',array('mechanic_id'=>$id,'authtoken'=>$authToken)); $this->db->insert('authtable_mechanic',array('mechanic_id'=>$id,'authtoken'=>$authToken));
} }
return $authToken; return $authToken;
} }
...@@ -71,7 +66,6 @@ public function getBookedService($postData = array(),$start = '',$per_page = '', ...@@ -71,7 +66,6 @@ public function getBookedService($postData = array(),$start = '',$per_page = '',
$respArr['message'] = "All Field is Required"; $respArr['message'] = "All Field is Required";
return $respArr; return $respArr;
} }
$where = array('BUK.status'=>$status,'MCHBUK.mechanic_id'=>$postData['mechanic_id']); $where = array('BUK.status'=>$status,'MCHBUK.mechanic_id'=>$postData['mechanic_id']);
if(isset($postData['service_id']) && !empty($postData['service_id'])){ if(isset($postData['service_id']) && !empty($postData['service_id'])){
$where['BUK.booking_id'] = $postData['service_id']; $where['BUK.booking_id'] = $postData['service_id'];
...@@ -86,7 +80,7 @@ public function getBookedService($postData = array(),$start = '',$per_page = '', ...@@ -86,7 +80,7 @@ public function getBookedService($postData = array(),$start = '',$per_page = '',
// $where['BUK.scheduled_date'] = date("Y-m-d", strtotime('tomorrow')); // $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,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as customer_name,CUST.phone as phone_number,CSTVEH.vehicle_data"); $this->db->select("BUK.scheduled_date as date,BUK.scheduled_time as time,BUK.booking_id as service_id,BUK.status,CSTVEH.car_name,BUK.mileage,BUK.issues_selected,BUK.custom_issue_data,BUK.service_type as type,MCHBUK.amount as total_amount,TRIM(CONCAT(CUST.first_name,' ' ,IFNULL(CUST.last_name,''))) as customer_name,CUST.phone as phone_number,CSTVEH.vehicle_data");
$this->db->from('bookings as BUK'); $this->db->from('bookings as BUK');
$this->db->join('customers as CUST','CUST.customer_id = BUK.customer_id'); $this->db->join('customers as CUST','CUST.customer_id = BUK.customer_id');
$this->db->join('customer_vehicle as CSTVEH','CSTVEH.customer_veh_id = BUK.customer_veh_id'); $this->db->join('customer_vehicle as CSTVEH','CSTVEH.customer_veh_id = BUK.customer_veh_id');
...@@ -183,7 +177,7 @@ public function start_service($postData = array(),$type = 0){ ...@@ -183,7 +177,7 @@ public function start_service($postData = array(),$type = 0){
return $respArr; return $respArr;
} }
$status = ($type == '1')?3:1; $status = ($type == '1')?3:6;
$cost = ($postData['emergency'] == '2')?$postData['amount']:''; $cost = ($postData['emergency'] == '2')?$postData['amount']:'';
if($this->db->update('bookings',array('service_type'=>$postData['emergency'],'cost'=>$cost,'status'=>$status),array('booking_id'=>$postData['service_id']))){ if($this->db->update('bookings',array('service_type'=>$postData['emergency'],'cost'=>$cost,'status'=>$status),array('booking_id'=>$postData['service_id']))){
$respArr['status'] = "success"; $respArr['status'] = "success";
......
...@@ -681,7 +681,7 @@ class Webservice_model extends CI_Model { ...@@ -681,7 +681,7 @@ class Webservice_model extends CI_Model {
} }
} }
$this->db->update('transaction',array('transaction_response'=>$respJson,'transaction_reference'=>$trancRef,'status'=>$status),array('id'=>$transId)); $this->db->update('transaction',array('transaction_response'=>$respJson,'transaction_reference'=>$trancReference,'status'=>$status),array('id'=>$transId));
if($payfor == '1'){ if($payfor == '1'){
$this->db->query("UPDATE bookings $this->db->query("UPDATE bookings
......
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
<div class="small-box bg-yellow"> <div class="small-box bg-yellow">
<div class="inner"> <div class="inner">
<h4>Users</h4> <h4>Users</h4>
<p><?php <p><?php echo 'Total : '. $customerCount ?></p>
echo 'Total : '. $customerCount ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-person-add"></i> <i class="ion ion-person-add"></i>
...@@ -33,17 +32,13 @@ ...@@ -33,17 +32,13 @@
<a href="<?= base_url('Customer/listCustomerUsers') ?>" class="small-box-footer ">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Customer/listCustomerUsers') ?>" class="small-box-footer ">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($bookingCount) && !empty($bookingCount)){ ?>
<?php if(isset($bookingCount) && !empty($bookingCount)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-green"> <div class="small-box bg-green">
<div class="inner"> <div class="inner">
<h4>Total Bookings</h4> <h4>Total Bookings</h4>
<p> <p>
<?php <?php echo 'Total : '.$bookingCount; ?>
echo 'Total : '.$bookingCount;
?>
</p> </p>
</div> </div>
<div class="icon"> <div class="icon">
...@@ -52,15 +47,12 @@ ...@@ -52,15 +47,12 @@
<a href="<?= base_url('Bookings/listBookings') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Bookings/listBookings') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($completeBukngCnt) && !empty($completeBukngCnt)){ ?>
<?php if(isset($completeBukngCnt) && !empty($completeBukngCnt)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-aqua"> <div class="small-box bg-aqua">
<div class="inner"> <div class="inner">
<h4>Completed Bookings</h4> <h4>Completed Bookings</h4>
<p><?php <p><?php echo 'Total : '. $completeBukngCnt ?></p>
echo 'Total : '. $completeBukngCnt ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-bag"></i> <i class="ion ion-bag"></i>
...@@ -68,15 +60,12 @@ ...@@ -68,15 +60,12 @@
<a href="<?= base_url('Bookings/listBookings') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Bookings/listBookings') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($pendingBukngCnt) && !empty($pendingBukngCnt)){ ?>
<?php if(isset($pendingBukngCnt) && !empty($pendingBukngCnt)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-blue"> <div class="small-box bg-blue">
<div class="inner"> <div class="inner">
<h4>Pending Bookings</h4> <h4>Pending Bookings</h4>
<p><?php <p><?php echo 'Total : '. $pendingBukngCnt ?></p>
echo 'Total : '. $pendingBukngCnt ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-stats-bars"></i> <i class="ion ion-stats-bars"></i>
...@@ -84,15 +73,12 @@ ...@@ -84,15 +73,12 @@
<a href="<?= base_url('Bookings/listBookings') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Bookings/listBookings') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($shopCount) && !empty($shopCount)){ ?>
<?php if(isset($shopCount) && !empty($shopCount)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-blue"> <div class="small-box bg-red">
<div class="inner"> <div class="inner">
<h4>Mechanic Shops</h4> <h4>Mechanic Shops</h4>
<p><?php <p><?php echo 'Total : '. $shopCount ?></p>
echo 'Total : '. $shopCount ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-bag"></i> <i class="ion ion-bag"></i>
...@@ -100,16 +86,12 @@ ...@@ -100,16 +86,12 @@
<a href="<?= base_url('Shop/viewShops') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Shop/viewShops') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($mobileVendors) && !empty($mobileVendors)){ ?>
<?php if(isset($mobileVendors) && !empty($mobileVendors)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-yellow"> <div class="small-box bg-blue">
<div class="inner"> <div class="inner">
<h4> Mobile Vendors</h4> <h4> Mobile Vendors</h4>
<p><?php <p><?php echo 'Total : '. $mobileVendors ?></p>
echo 'Total : '. $mobileVendors ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-stats-bars"></i> <i class="ion ion-stats-bars"></i>
...@@ -117,15 +99,12 @@ ...@@ -117,15 +99,12 @@
<a href="<?= base_url('Mechanic/viewMechanics') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Mechanic/viewMechanics') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($mobileMechanics) && !empty($mobileMechanics)){ ?>
<?php if(isset($mobileMechanics) && !empty($mobileMechanics)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-red"> <div class="small-box bg-orange">
<div class="inner"> <div class="inner">
<h4>Mobile Mechanics</h4> <h4>Mobile Mechanics</h4>
<p><?php <p><?php echo 'Total : '. $mobileMechanics ?></p>
echo 'Total : '. $mobileMechanics ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-pie-graph"></i> <i class="ion ion-pie-graph"></i>
...@@ -133,15 +112,12 @@ ...@@ -133,15 +112,12 @@
<a href="<?= base_url('Mechanic/viewMechanics') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Mechanic/viewMechanics') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($productCount) && !empty($productCount)){ ?>
<?php if(isset($productCount) && !empty($productCount)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-green"> <div class="small-box bg-green">
<div class="inner"> <div class="inner">
<h4>Product Count</h4> <h4>Product Count</h4>
<p><?php <p><?php echo 'Total : '. $productCount ?></p>
echo 'Total : '. $productCount ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-bag"></i> <i class="ion ion-bag"></i>
...@@ -149,15 +125,12 @@ ...@@ -149,15 +125,12 @@
<a href="<?= base_url('Product/viewProducts') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> <a href="<?= base_url('Product/viewProducts') ?>" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } if(isset($productSold) && !empty($productSold)){ ?>
<?php if(isset($productSold) && !empty($productSold)){ ?>
<div class="col-lg-3 col-xs-6"> <div class="col-lg-3 col-xs-6">
<div class="small-box bg-red"> <div class="small-box bg-yellow">
<div class="inner"> <div class="inner">
<h4>Product Sold</h4> <h4>Product Sold</h4>
<p><?php <p><?php echo 'Total : '. $productSold ?></p>
echo 'Total : '. $productSold ?></p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-person-add"></i> <i class="ion ion-person-add"></i>
...@@ -166,14 +139,14 @@ ...@@ -166,14 +139,14 @@
</div> </div>
</div> </div>
<?php } ?> <?php } ?>
</div>
<div class="row">
<div class="col-md-6" id="order_report"> <div class="col-md-6" id="order_report">
<div class="box box-info"> <div class="box box-info">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Order Sales Report</h3> <h3 class="box-title">Order Sales Report</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i> <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button> <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div> </div>
</div> </div>
...@@ -182,14 +155,12 @@ ...@@ -182,14 +155,12 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6" id="booking_report"> <div class="col-md-6" id="booking_report">
<div class="box box-info"> <div class="box box-info">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Booking Sales Report</h3> <h3 class="box-title">Booking Sales Report</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i> <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button> <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div> </div>
</div> </div>
...@@ -202,15 +173,15 @@ ...@@ -202,15 +173,15 @@
</section> </section>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: base_url + 'Dashboard/getOrderSalesReportCount', url: base_url + 'Dashboard/getOrderSalesReportCount',
success: function (data) { success: function (data) {
if(data == '1' || data == ''){ // if(data == '1' || data == ''){
$('#order_report').addClass('hide'); // $('#order_report').addClass('hide');
return false; // return false;
} // }
var data = jQuery.parseJSON(data); var data = jQuery.parseJSON(data);
var line = new Morris.Line({ var line = new Morris.Line({
element: 'line-chart', element: 'line-chart',
...@@ -224,17 +195,17 @@ $(function () { ...@@ -224,17 +195,17 @@ $(function () {
}); });
} }
}) })
}) })
$(function () { $(function () {
jQuery.ajax({ jQuery.ajax({
type: "POST", type: "POST",
url: base_url + 'Dashboard/getBookingReportCount', url: base_url + 'Dashboard/getBookingReportCount',
success: function (data) { success: function (data) {
if(data == '1'){ // if(data == '1'){
$('#booking_report').addClass('hide'); // $('#booking_report').addClass('hide');
return false; // return false;
} // }
var data = jQuery.parseJSON(data); var data = jQuery.parseJSON(data);
var line = new Morris.Line({ var line = new Morris.Line({
element: 'line-chart-booking', element: 'line-chart-booking',
...@@ -248,5 +219,5 @@ $(function () { ...@@ -248,5 +219,5 @@ $(function () {
}); });
} }
}) })
}) })
</script> </script>
\ 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