Commit ccc55f07 by Tobin

Merge branch 'master' into 'dev_production'

Master See merge request !4
parents 59dea100 66ad8d20
...@@ -186,14 +186,12 @@ class Issue extends CI_Controller { ...@@ -186,14 +186,12 @@ class Issue extends CI_Controller {
$err = 1; $err = 1;
$errMsg = 'Provide Issue Short Discription'; $errMsg = 'Provide Issue Short Discription';
} }
else if($err == 0 && (!isset($_POST['extSubTypes']) || empty($_POST['extSubTypes']))){
$err = 1;
}
$insertSubTyp = array(); $insertSubTyp = array();
$updateSubTyp = array(); $updateSubTyp = array();
$issue_data = array('issue'=>$_POST['issue']); $issue_data = array('issue'=>$_POST['issue']);
if($err == 0){ if($err == 0){
if(isset($_POST['extSubTypes']) && !empty($_POST['extSubTypes'])){
foreach ($_POST['extSubTypes'] AS $typ_id) { foreach ($_POST['extSubTypes'] AS $typ_id) {
if(isset($_POST['issue_category_'.$typ_id]) && if(isset($_POST['issue_category_'.$typ_id]) &&
!empty($_POST['issue_category_'.$typ_id])){ !empty($_POST['issue_category_'.$typ_id])){
...@@ -218,7 +216,7 @@ class Issue extends CI_Controller { ...@@ -218,7 +216,7 @@ class Issue extends CI_Controller {
$issue_cat_image = "assets/uploads/services/".$imgData['file_name']; $issue_cat_image = "assets/uploads/services/".$imgData['file_name'];
$updateSubTyp[$typ_id]['issue_cat_image'] = $issue_cat_image; $updateSubTyp[$typ_id]['issue_cat_image'] = $issue_cat_image;
} }
}
} }
if(isset($_POST['issue_category']) && count($_POST['issue_category']) > 0 && if(isset($_POST['issue_category']) && count($_POST['issue_category']) > 0 &&
...@@ -229,7 +227,6 @@ class Issue extends CI_Controller { ...@@ -229,7 +227,6 @@ class Issue extends CI_Controller {
count($_POST['issue_category']) == count($_POST['default_description']) && count($_POST['issue_category']) == count($_POST['default_description']) &&
count($_POST['issue_category']) == count($_POST['default_service_fee']) && count($_POST['issue_category']) == count($_POST['default_service_fee']) &&
count($_POST['issue_category']) == count($_FILES['issue_cat_image']['name'])){ count($_POST['issue_category']) == count($_FILES['issue_cat_image']['name'])){
$typ = 0; $typ = 0;
$files = $_FILES; $files = $_FILES;
...@@ -262,7 +259,9 @@ class Issue extends CI_Controller { ...@@ -262,7 +259,9 @@ class Issue extends CI_Controller {
'issue_id'=>$issue_id); 'issue_id'=>$issue_id);
} }
} }
if($this->upload->do_upload('issue_image')){
if(isset($_FILES['issue_image']) && !empty($_FILES['issue_image']['name']) &&
$this->upload->do_upload('issue_image')){
$imgData = $this->upload->data(); $imgData = $this->upload->data();
$issue_data['issue_image'] = "assets/uploads/services/".$imgData['file_name']; $issue_data['issue_image'] = "assets/uploads/services/".$imgData['file_name'];
} }
...@@ -462,25 +461,19 @@ class Issue extends CI_Controller { ...@@ -462,25 +461,19 @@ class Issue extends CI_Controller {
} }
$custData = array(); $custData = array();
if($mapping_type == 1){
foreach($mapping_data['issue_cat_ids'] AS $type_ids) { foreach($mapping_data['issue_cat_ids'] AS $type_ids) {
if(isset($mapping_data['default_service_fee_'.$type_ids]) && $issArr = array('issue_id'=>$mapping_data['issue_id'],
!empty($mapping_data['default_service_fee_'.$type_ids]) &&
isset($mapping_data['default_description_'.$type_ids]) &&
!empty($mapping_data['default_description_'.$type_ids])){
$custData[] = array('issue_id'=>$mapping_data['issue_id'],
'mechanic_id'=>$mapping_data['mechanic_id'], 'mechanic_id'=>$mapping_data['mechanic_id'],
'issue_cat_id'=>$type_ids, 'issue_cat_id'=>$type_ids);
'custom_description'=>$mapping_data['default_description_'.$type_ids], if($mapping_type == 1 &&
'custom_service_fee'=>$mapping_data['default_service_fee_'.$type_ids]); isset($mapping_data['default_service_fee_'.$type_ids]) &&
} isset($mapping_data['default_description_'.$type_ids])){
$issArr['custom_description'] = $mapping_data['default_description_'.$type_ids];
$issArr['custom_service_fee'] = $mapping_data['default_service_fee_'.$type_ids];
} }
} else { $custData[] = $issArr;
$custData[] = array('issue_id'=>$mapping_data['issue_id'],
'mechanic_id'=>$mapping_data['mechanic_id']);
} }
return $custData; return $custData;
} }
} }
......
...@@ -109,7 +109,26 @@ class Mechanic extends CI_Controller { ...@@ -109,7 +109,26 @@ class Mechanic extends CI_Controller {
}else if($err == 0 && (!isset($_POST['address']) || empty($_POST['address']))){ }else if($err == 0 && (!isset($_POST['address']) || empty($_POST['address']))){
$err = 1; $err = 1;
$errMsg = 'Provide an address'; $errMsg = 'Provide an address';
}else if($err == 0 && (!isset($_POST['location']) || empty($_POST['location']))){
$err = 1;
$errMsg = 'Provide a Functional Area';
}else if($err == 0 && (!isset($_POST['start_time']) || empty($_POST['start_time']))){
$err = 1;
$errMsg = 'Provide Work Start Time';
}else if($err == 0 && (!isset($_POST['end_time']) || empty($_POST['end_time']))){
$err = 1;
$errMsg = 'Provide Work End Time';
}else if($err == 0 && ($_POST['start_time'] >= $_POST['end_time'])){
$err = 1;
$errMsg = 'Provide proper Working Hours';
} }
$fnLocation = getLocationLatLng($_POST['location']);
if(empty($fnLocation)){
$err = 1;
$errMsg = 'Provide a Valid Functional Area';
}
if($err == 0){ if($err == 0){
$config = set_upload_service("assets/uploads/services"); $config = set_upload_service("assets/uploads/services");
$this->load->library('upload'); $this->load->library('upload');
...@@ -139,6 +158,8 @@ class Mechanic extends CI_Controller { ...@@ -139,6 +158,8 @@ class Mechanic extends CI_Controller {
redirect(base_url('Mechanic/addMechanic')); redirect(base_url('Mechanic/addMechanic'));
} }
$_POST['password'] = md5($_POST['password']); $_POST['password'] = md5($_POST['password']);
$_POST['location_lat'] = $fnLocation['lat'];
$_POST['location_lng'] = $fnLocation['lng'];
$status = $this->Mechanic_model->addMechanic($_POST); $status = $this->Mechanic_model->addMechanic($_POST);
if($status == 1){ if($status == 1){
...@@ -214,7 +235,26 @@ class Mechanic extends CI_Controller { ...@@ -214,7 +235,26 @@ class Mechanic extends CI_Controller {
}else if($err == 0 && (!isset($_POST['address']) || empty($_POST['address']))){ }else if($err == 0 && (!isset($_POST['address']) || empty($_POST['address']))){
$err = 1; $err = 1;
$errMsg = 'Provide your address'; $errMsg = 'Provide your address';
}else if($err == 0 && (!isset($_POST['location']) || empty($_POST['location']))){
$err = 1;
$errMsg = 'Provide a Functional Area';
}else if($err == 0 && (!isset($_POST['start_time']) || empty($_POST['start_time']))){
$err = 1;
$errMsg = 'Provide Work Start Time';
}else if($err == 0 && (!isset($_POST['end_time']) || empty($_POST['end_time']))){
$err = 1;
$errMsg = 'Provide Work End Time';
}else if($err == 0 && ($_POST['start_time'] >= $_POST['end_time'])){
$err = 1;
$errMsg = 'Provide proper Working Hours';
} }
$fnLocation = getLocationLatLng($_POST['location']);
if(empty($fnLocation)){
$err = 1;
$errMsg = 'Provide a Valid Functional Area';
}
if($err == 0){ if($err == 0){
$config = set_upload_service("assets/uploads/services"); $config = set_upload_service("assets/uploads/services");
$this->load->library('upload'); $this->load->library('upload');
...@@ -237,9 +277,11 @@ class Mechanic extends CI_Controller { ...@@ -237,9 +277,11 @@ class Mechanic extends CI_Controller {
if($err == 1){ if($err == 1){
$flashMsg['message'] = $errMsg; $flashMsg['message'] = $errMsg;
$this->session->set_flashdata('message',$flashMsg); $this->session->set_flashdata('message',$flashMsg);
redirect(base_url('Mechanic/addMechanic')); redirect(base_url('Mechanic/editMechanics/'.$mechanic_id));
} }
$_POST['location_lat'] = $fnLocation['lat'];
$_POST['location_lng'] = $fnLocation['lng'];
$status = $this->Mechanic_model->updateMechanic(decode_param($mechanic_id),$_POST); $status = $this->Mechanic_model->updateMechanic(decode_param($mechanic_id),$_POST);
if($status == 1){ if($status == 1){
$flashMsg =array('message'=>'Successfully Updated User Details..!','class'=>'success'); $flashMsg =array('message'=>'Successfully Updated User Details..!','class'=>'success');
......
...@@ -59,6 +59,9 @@ class Vehicle extends CI_Controller { ...@@ -59,6 +59,9 @@ class Vehicle extends CI_Controller {
echo json_encode($return_arr);exit; echo json_encode($return_arr);exit;
} }
if($searchType == 2){ 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['vehicle'] = $vehData['attributes']['Year'].' '.$vehData['attributes']['Make'].' '.
$vehData['attributes']['Model'].' '.$vehData['attributes']['Trim']; $vehData['attributes']['Model'].' '.$vehData['attributes']['Trim'];
} }
......
<?php
class Booking_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function scheduleBooking($postData = array()){
if(empty($postData) ||
!isset($postData['customer_id']) || empty($postData['customer_id']) ||
!isset($postData['pickup_data']) || empty($postData['pickup_data']) ||
!isset($postData['vechile_info']) || empty($postData['vechile_info']) ||
!isset($postData['mechanic_id']) || empty($postData['mechanic_id']) ||
!isset($postData['selected_issues']) || empty($postData['selected_issues'])){
return 0;
}
$vehData = $postData['vechile_info'];
$car_name = $vehData['modelYear'].' '.$vehData['maker'].' '.$vehData['modelName'];
$vehJson = array('vehicle' => $car_name,
'attributes' =>
array('Year' => $vehData['modelYear'],
'Make' => $vehData['maker'],
'Trim' => $vehData['trim'],
'Model' => $vehData['modelName'],
'Engine' => $vehData['emgine']));
$insert_array = array('customer_id' => $postData['customer_id'],
'car_name' => $car_name,
'car_model' => $vehData['modelName'],
'car_maker' => $vehData['maker'],
'car_loc_lat' => $postData['pickup_data']['pickup_lat'],
'car_loc_lng' => $postData['pickup_data']['pickup_lng'],
'car_location' => $postData['pickup_data']['pickup_loc'],
'vehicle_data' => json_encode($vehJson),
'car_model_year'=> $vehData['modelYear'],
'status' => '3');
$selected_issues = array();
foreach($postData['selected_issues'] AS $selIssue){
$selected_issues[] = array('issue' =>$selIssue['issue'],
'issue_id' =>$selIssue['issue_id'],
'sub_issue_id' =>$selIssue['sub_issue_id'],
'issue_category' =>$selIssue['issue_category']);
}
if($this->db->insert('customer_vehicle',$insert_array)){
$last_id = $this->db->insert_id();
$book_data = array('customer_veh_id' => $last_id,
'customer_id' => $postData['customer_id'],
'mechanic_id' => $postData['mechanic_id'],
'scheduled_date' => $postData['schedule_date']['date'],
'scheduled_time' => $postData['schedule_date']['time'],
'issues_selected' => json_encode($selected_issues),
'mileage' => $vehData['milage'],
'cost' => $postData['cost'],
'status' => '0');
if($this->db->insert('bookings',$book_data)){
return 1;
}
}
return 0;
}
function getCustBookDetails($postData = array(), $status = ''){
$cond = array();
if(empty($postData) || !isset($postData['customer_id']) || empty($postData['customer_id'])){
return 0;
}
$cond = "BK.customer_id='".$postData['customer_id']."' ";
$cond .= (!empty($status))?"AND BK.status IN (".$status.") ":'';
$sql = "SELECT BK.booking_id,BK.customer_id,BK.mechanic_id,BK.customer_veh_id,BK.scheduled_date,
BK.scheduled_time,BK.cost,BK.status,MECH.first_name,MECH.last_name,VEH.car_name,
BK.status
FROM bookings AS BK
INNER JOIN mechanic AS MECH ON (MECH.mechanic_id AND BK.mechanic_id)
INNER JOIN customer_vehicle AS VEH ON (VEH.customer_veh_id AND BK.customer_veh_id)
WHERE $cond
GROUP BY BK.booking_id";
$bookData = $this->db->query($sql);
if(!empty($bookData)){
return $bookData->result();
}
return 0;
}
function changeBookStatus($customer_id = '', $booking_id = '', $status = ''){
if(empty($customer_id) || empty($booking_id) || $status == ''){
return 0;
}
$status = $this->db->update('bookings',
array('status'=>$status),
array('customer_id'=>$customer_id,'booking_id'=>$booking_id));
return $status;
}
}
?>
\ No newline at end of file
...@@ -38,6 +38,7 @@ class Customer_model extends CI_Model { ...@@ -38,6 +38,7 @@ class Customer_model extends CI_Model {
return 2; return 2;
} }
} }
if(isset($customer_data['phone']) && !empty($customer_data['phone'])){ if(isset($customer_data['phone']) && !empty($customer_data['phone'])){
$phoneChk = $this->db->get_where('customers',array('phone'=>$customer_data['phone'],'status !='=>'2')); $phoneChk = $this->db->get_where('customers',array('phone'=>$customer_data['phone'],'status !='=>'2'));
if(!empty($phoneChk) && $phoneChk->num_rows() > 0){ if(!empty($phoneChk) && $phoneChk->num_rows() > 0){
...@@ -99,7 +100,7 @@ class Customer_model extends CI_Model { ...@@ -99,7 +100,7 @@ class Customer_model extends CI_Model {
} }
$result = $this->db->get_where('customers',array('email'=>$userLogData['email'], $result = $this->db->get_where('customers',array('email'=>$userLogData['email'],
'password'=>md5($userLogData['password']), 'password'=>$userLogData['password'],
'status'=>'1')); 'status'=>'1'));
$respArr['status'] = 3; $respArr['status'] = 3;
if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){ if(!empty($result) && $result->num_rows() == 1 && !empty($custData = $result->row())){
...@@ -131,23 +132,5 @@ class Customer_model extends CI_Model { ...@@ -131,23 +132,5 @@ class Customer_model extends CI_Model {
} }
return $respArr; return $respArr;
} }
function customer_registration($userData = array()){
$respArr = array('status'=>0);
if(empty($userData)){
return $respArr;
}
$result = $this->db->get_where('customers',array('email'=>$userData['email'],'status'=>'1'));
if(!empty($result) && $result->num_rows() >= 1){
$respArr['status'] = 2;
return $respArr;
}
$userData['password'] = md5($userData['password']);
$status = $this->db->insert('customers',$userData);
if($status){
$respArr['status'] = 1;
}
return $respArr;
}
} }
?> ?>
\ No newline at end of file
...@@ -90,17 +90,23 @@ class Issue_model extends CI_Model { ...@@ -90,17 +90,23 @@ class Issue_model extends CI_Model {
} }
function updateIssue($issue_id='',$issue_data=array(),$updateSubTyp=array(),$insertSubTyp=array()){ function updateIssue($issue_id='',$issue_data=array(),$updateSubTyp=array(),$insertSubTyp=array()){
if(empty($issue_id) || empty($issue_data) || empty($updateSubTyp)){ if(empty($issue_id) || empty($issue_data)){
return 0; return 0;
} }
$status = $this->db->update('issues',$issue_data,array('issue_id'=>$issue_id)); $status = $this->db->update('issues',$issue_data,array('issue_id'=>$issue_id));
$scat_ids = array(); $scat_ids = array();
if(!empty($updateSubTyp)){
foreach ($updateSubTyp AS $scat_id => $scat_data) { foreach ($updateSubTyp AS $scat_id => $scat_data) {
$scat_ids[] = $scat_id; $scat_ids[] = $scat_id;
$this->db->update('issues_category',$scat_data,array('issue_cat_id'=>$scat_id)); $this->db->update('issues_category',$scat_data,array('issue_cat_id'=>$scat_id));
} }
$this->db->where_not_in('issue_cat_id',$scat_ids)->delete('issues_category'); }
if(!empty($scat_ids)){
$this->db->where_not_in('issue_cat_id',$scat_ids);
}
$this->db->where('issue_id',$issue_id);
$this->db->delete('issues_category');
if(!empty($insertSubTyp)){ if(!empty($insertSubTyp)){
$this->db->insert_batch('issues_category',$insertSubTyp); $this->db->insert_batch('issues_category',$insertSubTyp);
...@@ -123,39 +129,41 @@ class Issue_model extends CI_Model { ...@@ -123,39 +129,41 @@ class Issue_model extends CI_Model {
$cond = ($view_all != 0)?' MI.status IN (0,1) ':' MI.status IN (1) '; $cond = ($view_all != 0)?' MI.status IN (0,1) ':' MI.status IN (1) ';
$cond .= (!empty($issue_id))?" AND MI.issue_id = '$issue_id' ":""; $cond .= (!empty($issue_id))?" AND MI.issue_id = '$issue_id' ":"";
$sql = "SELECT ISS.issue_id,MI.mechanic_id,ISS.issue,ISS.issue_image,IC.issue_cat_id, $sql = "SELECT MI.issue_id,MI.issue_cat_id,MI.mechanic_id,MI.custom_description,MI.custom_service_fee,
IC.issue_category,IC.issue_cat_image,IC.default_description,IC.default_service_fee, MI.status,ISS.issue,ISS.issue_image
MI.custom_description,MI.custom_service_fee,MI.status
FROM mechanic_issues AS MI FROM mechanic_issues AS MI
INNER JOIN issues AS ISS ON (ISS.issue_id=MI.issue_id) INNER JOIN issues AS ISS ON (ISS.issue_id=MI.issue_id)
LEFT JOIN issues_category AS IC ON (IC.issue_id=MI.issue_id)
WHERE MI.mechanic_id='$mechanic_id' AND ISS.status='1' AND $cond WHERE MI.mechanic_id='$mechanic_id' AND ISS.status='1' AND $cond
GROUP BY IC.issue_id,IC.issue_cat_id"; GROUP BY MI.issue_id,MI.issue_cat_id";
$mechIssueData = $this->db->query($sql); $mechIssueData = $this->db->query($sql);
if(empty($mechIssueData) || empty($mechIssueData = $mechIssueData->result_array())) if(empty($mechIssueData) || empty($mechIssueData = $mechIssueData->result_array()))
return 0; return 0;
$cstFlag = 0;
$customIssues = array(); $customIssues = array();
$subIssueData = array();
foreach ($mechIssueData AS $mechIsssue) { foreach ($mechIssueData AS $mechIsssue) {
$cstFlag = 0;
$issue_id = $mechIsssue['issue_id']; $issue_id = $mechIsssue['issue_id'];
$sub_issue_id = $mechIsssue['issue_cat_id'];
if(!isset($customIssues[$issue_id])){ if(!isset($customIssues[$issue_id])){
$issue_data = array('issue'=>$mechIsssue['issue'], $customIssues[$issue_id] = array('issue'=>$mechIsssue['issue'],
'issue_id'=>$issue_id, 'issue_id'=>$mechIsssue['issue_id'],
'mechanic_id'=>$mechIsssue['mechanic_id'], 'mechanic_id'=>$mechIsssue['mechanic_id'],
'issue_image'=>$mechIsssue['issue_image'], 'issue_image'=>$mechIsssue['issue_image'],
'status'=>$mechIsssue['status']); 'status'=>$mechIsssue['status'],
'custom_enable'=>'0');
}
if(!empty($issCat_id = $mechIsssue['issue_cat_id'])){
$customIssues[$issue_id] = $issue_data; $sIssData = $this->db->get_where('issues_category',array('issue_cat_id'=>$issCat_id));
if(empty($sIssData) || empty($sIssData = $sIssData->row_array())){
continue;
} }
if(!empty($sub_issue_id)){ $subIssueDtls['description'] = $sIssData['default_description'];
$subIssueDtls['description'] = $mechIsssue['default_description']; $subIssueDtls['service_fee'] = $sIssData['default_service_fee'];
$subIssueDtls['service_fee'] = $mechIsssue['default_service_fee']; $subIssueDtls['issue_category'] = $sIssData['issue_category'];
$subIssueDtls['issue_category'] = $mechIsssue['issue_category']; $subIssueDtls['issue_cat_image'] = $sIssData['issue_cat_image'];
$subIssueDtls['issue_cat_image'] = $mechIsssue['issue_cat_image'];
if(!empty($mechIsssue['custom_description'])){ if(!empty($mechIsssue['custom_description'])){
$cstFlag = 1; $cstFlag = 1;
$subIssueDtls['description'] = $mechIsssue['custom_description']; $subIssueDtls['description'] = $mechIsssue['custom_description'];
...@@ -164,11 +172,11 @@ class Issue_model extends CI_Model { ...@@ -164,11 +172,11 @@ class Issue_model extends CI_Model {
$cstFlag = 1; $cstFlag = 1;
$subIssueDtls['service_fee'] = $mechIsssue['custom_service_fee']; $subIssueDtls['service_fee'] = $mechIsssue['custom_service_fee'];
} }
$subIssueData[$sub_issue_id] = $subIssueDtls;
} $customIssues[$issue_id]['sub_issue'][$issCat_id] = $subIssueDtls;
$customIssues[$issue_id]['sub_issue'] = $subIssueData;
$customIssues[$issue_id]['custom_enable'] = $cstFlag; $customIssues[$issue_id]['custom_enable'] = $cstFlag;
} }
}
return $customIssues; return $customIssues;
} }
...@@ -196,5 +204,49 @@ class Issue_model extends CI_Model { ...@@ -196,5 +204,49 @@ class Issue_model extends CI_Model {
return $this->addMechIssue($custom_issue); return $this->addMechIssue($custom_issue);
} }
function getGeneralIssues($issue_id = '', $view_all = '0'){
$cond = ($view_all != 0)?' ISS.status IN (0,1) ':' ISS.status IN (1) ';
$cond .= (!empty($issue_id))?" AND ISS.issue_id='".$issue_id."' ":'';
$sql = "SELECT ISS.*, IC.*
FROM issues AS ISS
LEFT JOIN issues_category AS IC ON (IC.issue_id=ISS.issue_id AND IC.status='1')
WHERE ".$cond;
if(empty($issueData = $this->db->query($sql)) || empty($issueData = $issueData->result_array()))
return 0;
$genIssueData = array();
foreach($issueData AS $issueData){
$issue_id = $issueData['issue_id'];
if(!isset($genIssueData[$issue_id])){
$iData = array('issue'=>$issueData['issue'],'issue_id'=>$issue_id,
'issue_image'=>$issueData['issue_image']);
$genIssueData[$issue_id] = $iData;
}
if(isset($issueData['issue_cat_id']) && !empty($issueData['issue_cat_id'])){
$sIssueId = $issueData['issue_cat_id'];
$isData = array('issue_cat_id'=>$issueData['issue_cat_id'],
'issue_category'=>$issueData['issue_category'],
'issue_cat_image'=>$issueData['issue_cat_image'],
'default_service_fee'=>$issueData['default_service_fee'],
'default_description'=>$issueData['default_description']);
$genIssueData[$issue_id]['sub_categories'][] = $isData;
}
}
$respArr = array();
if(!empty($genIssueData)){
foreach ($genIssueData AS $value) {
$respArr[] = $value;
}
}
return $respArr;
}
} }
?> ?>
\ No newline at end of file
...@@ -44,9 +44,14 @@ class Mechanic_model extends CI_Model { ...@@ -44,9 +44,14 @@ class Mechanic_model extends CI_Model {
'shop_id'=>$mechanic_data['shop_id'], 'shop_id'=>$mechanic_data['shop_id'],
'address'=>$mechanic_data['address'], 'address'=>$mechanic_data['address'],
'licence'=>$mechanic_data['licence'], 'licence'=>$mechanic_data['licence'],
'location'=>$mechanic_data['location'],
'email_id'=>$mechanic_data['email_id'], 'email_id'=>$mechanic_data['email_id'],
'end_time'=>$mechanic_data['end_time'],
'last_name'=>$mechanic_data['last_name'], 'last_name'=>$mechanic_data['last_name'],
'start_time'=>$mechanic_data['start_time'],
'first_name'=>$mechanic_data['first_name'], 'first_name'=>$mechanic_data['first_name'],
'location_lat'=>$mechanic_data['location_lat'],
'location_lng'=>$mechanic_data['location_lng'],
'licence_number'=>$mechanic_data['licence_number'], 'licence_number'=>$mechanic_data['licence_number'],
'licence_exp_date'=>$mechanic_data['licence_exp_date'])); 'licence_exp_date'=>$mechanic_data['licence_exp_date']));
return $status; return $status;
...@@ -105,6 +110,11 @@ class Mechanic_model extends CI_Model { ...@@ -105,6 +110,11 @@ class Mechanic_model extends CI_Model {
'state'=>$mechanic_data['state'],'shop_id'=>$mechanic_data['shop_id'], 'state'=>$mechanic_data['state'],'shop_id'=>$mechanic_data['shop_id'],
'address'=>$mechanic_data['address'],'email_id'=>$mechanic_data['email_id'], 'address'=>$mechanic_data['address'],'email_id'=>$mechanic_data['email_id'],
'last_name'=>$mechanic_data['last_name'],'phone'=>$mechanic_data['phone'], 'last_name'=>$mechanic_data['last_name'],'phone'=>$mechanic_data['phone'],
'location'=>$mechanic_data['location'],
'end_time'=>$mechanic_data['end_time'],
'start_time'=>$mechanic_data['start_time'],
'location_lat'=>$mechanic_data['location_lat'],
'location_lng'=>$mechanic_data['location_lng'],
'licence_number'=>$mechanic_data['licence_number'], 'licence_number'=>$mechanic_data['licence_number'],
'licence_exp_date'=>$mechanic_data['licence_exp_date']); 'licence_exp_date'=>$mechanic_data['licence_exp_date']);
...@@ -122,5 +132,79 @@ class Mechanic_model extends CI_Model { ...@@ -122,5 +132,79 @@ class Mechanic_model extends CI_Model {
$status = $this->db->update('admin_users',array('status'=>$status),array('id'=>$mechanic_id)); $status = $this->db->update('admin_users',array('status'=>$status),array('id'=>$mechanic_id));
return $status; return $status;
} }
function getNearByMechanics($location_data = array(),$sub_issues = array()){
if(empty($location_data) || empty($sub_issues)){
return 0;
}
$current_lat = $location_data['pickup_lat'];
$current_lng = $location_data['pickup_lng'];
$issue_cat_id = implode(',',$sub_issues);
$sql = "SELECT AU.display_name,AU.profile_image,ME.*,MS.shop_name,MS.address AS shop_address,
MS.phone AS shop_phone,MS.email_id AS shop_email_id,
3956*2*ASIN(SQRT(POWER(SIN(($current_lat-ME.location_lat)*pi()/180/2),2)+
COS($current_lat*pi()/180 )*COS(ME.location_lat*pi()/180)*
POWER(SIN(($current_lng-ME.location_lng)*pi()/180/2),2) )) AS distance
FROM mechanic AS ME
INNER JOIN admin_users AS AU ON (AU.id=ME.mechanic_id)
LEFT JOIN mechanic_shop AS MS ON (MS.shop_id=ME.shop_id AND MS.status='1')
WHERE AU.status='1'
-- HAVING distance<30";
$mechData = $this->db->query($sql);
if(empty($mechData) || empty($mechData = $mechData->result_array())){
return 0;
}
$estimate = 0;
$mechDataArr = array();
foreach($mechData AS $index => $data){
if(empty($data['start_time']) || empty($data['end_time'])){
$scheduleTiming = array('09:00 AM','10:00 AM','11:00 AM','12:00 PM','01:00 PM',
'02:00 PM','03:00 PM','04:00 PM','05:00 PM','06:00 PM');
} else {
$endTime = strtotime($data['end_time']);
$schTime = strtotime($data['start_time']);
$scheduleTiming = array();
for( ; $schTime <= ($endTime-3600) ; $schTime += 3600){
$scheduleTiming[] = date('h:i A',$schTime);
}
}
$mechanic_id = $data['mechanic_id'];
$sql = "SELECT ISS.*, IC.*, MI.*
FROM issues_category AS IC
INNER JOIN issues AS ISS ON (IC.issue_id=ISS.issue_id)
LEFT JOIN mechanic_issues AS MI ON (MI.issue_cat_id=IC.issue_cat_id AND
MI.mechanic_id='$mechanic_id' AND MI.status='1')
WHERE ISS.status='1' AND IC.status='1' AND IC.issue_cat_id IN ($issue_cat_id)";
$subIssData = $this->db->query($sql);
$sIssueData = array();
if(!empty($subIssData) && !empty($subIssData = $subIssData->result_array())){
$sIssueData = $subIssData;
}
$estimate = 0;
foreach($sIssueData AS $sIndex => $sIssue){
if(!empty($sIssue['custom_service_fee'])){
$estimate += $sIssue['custom_service_fee'];
$sIssueData[$sIndex]['service_fee'] = $sIssue['custom_service_fee'];
} else {
$estimate += $sIssue['default_service_fee'];
$sIssueData[$sIndex]['service_fee'] = $sIssue['default_service_fee'];
}
}
$mechData[$index]['estimate'] = $estimate;
$mechData[$index]['sub_issues'] = $sIssueData;
$mechData[$index]['scheduleTiming'] = $scheduleTiming;
}
return $mechData;
}
} }
?> ?>
\ No newline at end of file
...@@ -25,5 +25,35 @@ class Vehicle_model extends CI_Model { ...@@ -25,5 +25,35 @@ class Vehicle_model extends CI_Model {
} }
return $status; return $status;
} }
function getCustVechiles($searchData = array()){
if(empty($searchData)){
return 0;
}
$cond = array();
$cond['status'] = 1;
if(isset($searchData['customer_id']) && !empty($searchData['customer_id'])){
$cond['customer_id'] = $searchData['customer_id'];
}
$vehData = $this->db->get_where('customer_vehicle',$cond);
if(!empty($vehData)){
return $vehData->result();
}
return 0;
}
function changeCustomerCarStatus($customer_id = '', $customer_veh_id = '', $status = ''){
if(empty($customer_id) || empty($customer_veh_id) || $status == ''){
return 0;
}
$upStatus = $this->db->update('customer_vehicle',
array('status'=>$status),
array('customer_id'=>$customer_id,'customer_veh_id'=>$customer_veh_id));
return $upStatus;
}
} }
?> ?>
\ No newline at end of file
...@@ -73,10 +73,10 @@ ...@@ -73,10 +73,10 @@
<tr> <tr>
<th class="hidden">ID</th> <th class="hidden">ID</th>
<th width="10%;">Issue Icon</th> <th width="10%;">Issue Icon</th>
<th width="29%;">Issue Category</th> <th width="25%;">Issue Category</th>
<th width="12%;">Mapping Type</th> <th width="13%;">Mapping Type</th>
<th width="10%;">Status</th> <th width="10%;">Status</th>
<th width="40%;">Action</th> <th width="43%;">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
......
...@@ -112,6 +112,12 @@ ...@@ -112,6 +112,12 @@
required="" name="state" placeholder="Enter email ID" value="<?= (isset($user_data->state))?$user_data->state:'' ?>"> required="" name="state" placeholder="Enter email ID" value="<?= (isset($user_data->state))?$user_data->state:'' ?>">
<span class="glyphicon form-control-feedback"></span> <span class="glyphicon form-control-feedback"></span>
</div> </div>
<div class="form-group">
<label>Functional Area</label>
<input type="text" class="form-control" data-parsley-trigger="change"
id="loc_search_1" name="location" placeholder="Choose Functional Area" value="<?= (isset($user_data->location))?$user_data->location:'' ?>">
<span class="glyphicon form-control-feedback"></span>
</div>
<?php if(!empty($shop_data)){ ?> <?php if(!empty($shop_data)){ ?>
<div class="form-group"> <div class="form-group">
<label>Workshop</label> <label>Workshop</label>
...@@ -145,6 +151,27 @@ ...@@ -145,6 +151,27 @@
value="<?= (isset($user_data->phone))?$user_data->phone:'' ?>" name="phone" placeholder="Enter Phone Number" > value="<?= (isset($user_data->phone))?$user_data->phone:'' ?>" name="phone" placeholder="Enter Phone Number" >
<span class="glyphicon form-control-feedback"></span> <span class="glyphicon form-control-feedback"></span>
</div> </div>
<div class="form-group" style="display:inline-flex;">
<div style="width:250px;" class="clockpicker" data-autoclose="true">
<label>Working Hours</label>
<input type="text" class="form-control required" data-parsley-trigger="change"
data-parsley-minlength="2" required name="start_time" placeholder="Work Start Time"
value="<?= (isset($user_data->start_time))?$user_data->start_time:'' ?>"
id="start_time" autocomplete="off" >
<span class="glyphicon form-control-feedback"></span>
</div>
<div style="width:250px;padding-left:10px;padding-top:25px;"
class="clockpicker" data-autoclose="true">
<input type="text" class="form-control required" data-parsley-trigger="change"
data-parsley-minlength="2" required="" placeholder="Work End Time" autocomplete="off"
value="<?= (isset($user_data->end_time))?$user_data->end_time:'' ?>" id="end_time"
name="end_time">
<span class="glyphicon form-control-feedback"></span>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Licence Number</label> <label>Licence Number</label>
<input type="text" class="form-control" data-parsley-trigger="change" <input type="text" class="form-control" data-parsley-trigger="change"
......
...@@ -201,6 +201,20 @@ jQuery('[id="viewMechanic"]').on('click',function() { ...@@ -201,6 +201,20 @@ jQuery('[id="viewMechanic"]').on('click',function() {
'<div class="col-md-1">:</div>'+ '<div class="col-md-1">:</div>'+
'<div class="col-md-6"><label>'+mechanic_data['state']+'</label></div> '+ '<div class="col-md-6"><label>'+mechanic_data['state']+'</label></div> '+
'</div> '+ '</div> '+
'<div class="row"> '+
'<div class="col-md-4">Working Hours</div>'+
'<div class="col-md-1">:</div>'+
'<div class="col-md-6">'+
'<label>'+
mechanic_data['start_time']+' - '+mechanic_data['end_time']+
'</label>'+
'</div> '+
'</div> '+
'<div class="row"> '+
'<div class="col-md-4">Location</div>'+
'<div class="col-md-1">:</div>'+
'<div class="col-md-6"><label>'+mechanic_data['location']+'</label></div> '+
'</div> '+
shopHtml+ shopHtml+
'</div> '+ '</div> '+
'<div class="col-md-5"> '+ '<div class="col-md-5"> '+
......
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