Commit 155eecb3 by Jansa Jose

webservice and admin panel view custom quote

parent 21118e16
......@@ -65,13 +65,15 @@ class Bookings extends CI_Controller {
echo json_encode($return_arr);exit;
}
$booking_id = decode_param($_POST['booking_id']);
$bookingData = $this->Booking_model->getMechBookings('',$booking_id,'0,1,3,4');
$mechanic_id = ($this->session->userdata('user_type')==2)?$this->session->userdata('id'):'';
$bookingData = $this->Booking_model->getMechBookings($mechanic_id,$booking_id,'0,1,3,4');
if(!empty($bookingData)){
$return_arr['status'] = 1;
$return_arr['data'] = $bookingData;
echo json_encode($return_arr);exit;
}
echo json_encode($return_arr);exit;
}
public function insertCustomQuote(){
......@@ -85,5 +87,22 @@ class Bookings extends CI_Controller {
$return_arr = $this->Booking_model->insertCustomQuote($output);
echo json_encode($return_arr);exit;
}
public function getCustomData(){
$return_arr = array('status'=>'0');
if(!isset($_POST) || empty($_POST) || !isset($_POST['custom_id']) || empty($_POST['custom_id']) ||
empty(decode_param($_POST['custom_id']))){
echo json_encode($return_arr);exit;
}
$custom_booking_id = decode_param($_POST['custom_id']);
// print_r($custom_booking_id);exit();
$CustData = $this->Booking_model->getCustomData($custom_booking_id);
if(!empty($CustData)){
$return_arr['status'] = 1;
$return_arr['data'] = $CustData;
echo json_encode($return_arr);exit;
}
echo json_encode($return_arr);exit;
}
}
?>
\ No newline at end of file
......@@ -119,12 +119,13 @@ class Booking_model extends CI_Model {
MECH.last_name AS mechLastName,VEH.car_maker,VEH.car_model_year,VEH.car_vin,
VEH.vehicle_data,VEH.car_location,VEH.car_loc_lat,VEH.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
CUST.email,CUST.address,CUST.profile_image,CUST.date_of_birth,CUSQTE.custom_id
FROM bookings AS BK
INNER JOIN mechanic AS MECH ON (MECH.mechanic_id=BK.mechanic_id)
INNER JOIN customers AS CUST ON (CUST.customer_id=BK.customer_id)
INNER JOIN admin_users AS ADM ON (ADM.id=BK.mechanic_id)
INNER JOIN customer_vehicle AS VEH ON (VEH.customer_veh_id=BK.customer_veh_id)
LEFT JOIN custom_quote AS CUSQTE on (CUSQTE.booking_id = BK.booking_id)
WHERE $cond AND ADM.status='1' AND CUST.status='1'
GROUP BY BK.booking_id";
......@@ -162,10 +163,24 @@ class Booking_model extends CI_Model {
$res = array('status'=>'success');
}else{
if($this->db->insert('custom_quote',array('booking_id'=>$book_id,'custom_service_quote'=>json_encode($custData),'custom_amount'=>$total))){
$res = array('status'=>'success');
$last_id = $this->db->insert_id();
$res = array('status'=>'success','data'=>encode_param($last_id));
}
}
return $res;
}
public function getCustomData($customid){
$this->db->select('custom_quote.custom_service_quote,custom_quote.custom_amount,bookings.issues_selected');
$this->db->join('bookings','bookings.booking_id = custom_quote.booking_id');
$this->db->where('custom_quote.custom_id',$customid);
$custData = $this->db->get('custom_quote');
if(!empty($custData) && $custData->num_rows() > 0){
$custData = $custData->row_array();
return $custData;
}
return 0;
}
}
?>
......@@ -342,12 +342,13 @@ class Webservice_model extends CI_Model {
}
}
$mechanic_id = $data['mechanic_id'];
$sql = "SELECT ISS.*, IC.*, MI.*
$sql = "SELECT ISS.*, IC.*, MI.mechanic_id, MI.custom_description, MI.custom_service_fee
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())){
......
......@@ -119,9 +119,15 @@
onClick="return doconfirm()">
<i class="fa fa-fw fa-trash"></i>Delete
</a>
<button class="btn btn-sm btn-primary" style="margin-top:3px;" booking_id="<?= encode_param($bookData->booking_id) ?>" id="customQuote">
<i class="fa fa-fw fa-edit"></i>Generate Custom Quote
<?php if($bookData->custom_id == ''){?>
<button class="btn btn-sm btn-primary" style="margin-top:3px;" booking_id="<?= encode_param($bookData->booking_id) ?>" id="customQuote" view="0">
<i class="fa fa-fw fa-edit"></i><span>Generate Custom Quote</span>
</button>
<?php } else{?>
<button class="btn btn-sm btn-primary" style="margin-top:3px;" booking_id="<?= encode_param($bookData->custom_id) ?>" id="customQuote" view="1">
<i class="fa fa-fw fa-edit"></i><span>View Custom Quote</span>
</button>
<?php } ?>
</td>
</tr>
<?php } } ?>
......
......@@ -756,8 +756,20 @@ function viewMapIssueDetails(issue_id) {
return false;
}
jQuery('[id="customQuote"]').on('click',function(){
var booking_id = jQuery(this).attr('booking_id');
jQuery('[id="customQuote"]').on('click',function() {
var thisObj = jQuery(this);
if(thisObj.attr('view') == '0'){
customQuote(thisObj);
} else {
viewCustomQuote(thisObj);
}
});
quoteThisObj = '';
function customQuote(thisObj){
quoteThisObj = thisObj;
var booking_id = thisObj.attr('booking_id');
if(booking_id == '' || booking_id==undefined || booking_id == 'undefined' || booking_id == null || booking_id=='null'){
return true;
......@@ -846,7 +858,7 @@ jQuery('[id="customQuote"]').on('click',function(){
jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!');
}
})
})
}
function submitCustQuote(e){
e.preventDefault();
......@@ -884,6 +896,7 @@ function submitCustQuote(e){
if(form_data == '' || form_data==undefined || form_data == 'undefined' || form_data == null || form_data=='null'){
return true;
}
jQuery.ajax({
url : base_url+"Bookings/insertCustomQuote",
type : 'POST',
......@@ -904,6 +917,9 @@ function submitCustQuote(e){
return false;
}
else{
quoteThisObj.attr('view','1');
quoteThisObj.find('span').html('View Custom Quote');
quoteThisObj.attr('booking_id',resp_data['data']);
remModalLoader();
jQuery('[id="modal_content"]').html('Custom Quote Inserted Successfully.');
return false;
......@@ -920,6 +936,95 @@ function submitCustQuote(e){
})
}
function viewCustomQuote(thisObj){
var custom_id = thisObj.attr('booking_id');
if(custom_id == '' || custom_id==undefined || custom_id == 'undefined' || custom_id == null || custom_id=='null'){
return true;
}
modalTrigger('View Custom Description','');
addModalLoader();
jQuery.ajax({
url : base_url+"Bookings/getCustomData",
type : 'POST',
data : {'custom_id':custom_id,'view_all':'1'},
success : function(resp){
if(resp == '' || resp == undefined || resp == 'undefined' || resp == null || resp == 'null'){
remModalLoader();
jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!');
return false;
}
var resp_data = jQuery.parseJSON(resp);
if(resp_data['status'] == '0'){
remModalLoader();
jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!');
return false;
}
var booking_data = resp_data['data'];
jQuery.each(booking_data, function(index, value){
if(value == '' || value == null || value == 'null' || value == undefined || value == 'undefined'){
booking_data[index] = ' -- ';
}
});
var html ='',
imgCount = 0,
issueHtml = '',
optionalHtml = '',
issues_selected = jQuery.parseJSON(booking_data['issues_selected']),
custdescription = jQuery.parseJSON(booking_data['custom_service_quote']);
// console.log(custdescription);
if(issues_selected != ''){
var comma = '';
issueHtml += '<div class="col-md-12" style="padding-top:10px">'+
'<div class="col-md-4"><div class="row"><label>Selected Issue</label></div></div>'+
'<div class="col-md-4"><div class="row"><label>Description</label></div></div>'+
'<div class="col-md-4"><div class="row"><label>Amount</label></div></div>'+
'<div class="row">';
jQuery.each(issues_selected, function (index, value) {
issueHtml += '<div class="col-md-12">'+
'<div class="col-md-4 marginTop10">';
issueHtml += comma+' '+value['issue_category']+' ';
issueHtml += '</div>'+
'<div class="col-md-4 marginTop10">'+
custdescription[index]['description']+
'</div>'+
'<div class="col-md-4 marginTop10">'+
custdescription[index]['amount']+
'</div>'+
'</div>';
});
issueHtml += '</div>'+
'</div>'+
'<div class="col-md-12">'+
'<div class="col-md-6"></div>'+
'<div class="col-md-6"><br><br>'+
'<div class="col-md-4"><label>Total Amount</label></div>'+
'<div class="col-md-1">:</div>'+
'<div class="col-md-5"><b>'+booking_data['custom_amount']+'</b></div>'+
'</div>'+
'</div>';
}
remModalLoader();
jQuery('[id="modal_content"]').html(issueHtml);
jQuery('[id^="optionalImage_"]').error(function() {
jQuery('[id^="optionalImage_"]').attr('src',base_url+'assets/images/no_image_text.png');
});
},
fail: function(xhr, textStatus, errorThrown){
remModalLoader();
jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!');
},
error: function (ajaxContext) {
remModalLoader();
jQuery('[id="modal_content"]').html('Something went wrong, please try again later...!');
}
})
}
jQuery('[id="showBookinDetails"]').on('click',function() {
var booking_id = jQuery(this).attr('booking_id');
......
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