Commit 40ca4361 by Ajil

serviceupdate

parent 5c35b7af
......@@ -27,7 +27,8 @@ class Garage_response extends CI_Controller {
$template['page_head'] = "Garage Response Management";
$template['datatable'] = 1;
$template['request_id'] = $request_id;
$template['response'] = $this->Garage_response_model->getGarage_responseData(decode_param($request_id));
$template['response'] = $this->Garage_response_model->getGarage_requestData(decode_param($request_id));
//print_r($template['response']);exit;
$template['prod_list'] = $this->Garage_response_model->get_all_Garage_response(decode_param($request_id));
//print_r($template['prod_list']);exit;
$this->load->view('template',$template);
......@@ -228,8 +229,32 @@ public function approve_quote(){
public function editMargins(){
$respArr =array('status'=>'error');
$data = $_POST;
if(!isset($_POST['requestId']) || empty($_POST['requestId']) || !isset($_POST['respCode']) || empty($_POST['respCode'])){
echo json_encode(array('status'=>'error'));exit;
}
$pos_list = $this->Garage_response_model->getGarage_requestData(decode_param($_POST['requestId']));
$requestData = $this->Garage_response_model->Garage_OneResponseData(decode_param($_POST['requestId']),$_POST['respCode']);
echo json_encode(array('status'=>'success','reqDetails'=>$requestData,'posDetails'=>$pos_list));exit;
}
public function insertCustomMargin(){
$respArr =array('status'=>'error');
$data = $_POST;
if(!isset($_POST['margin']) || empty($_POST['margin']) || !isset($_POST['respId']) || empty($_POST['respId']) || !isset($_POST['total']) || empty($_POST['total'])){
echo json_encode($respArr);exit;
}
$requestData = $this->Garage_response_model->updateserviceMargin($_POST);
if(!$requestData){
echo json_encode($respArr); exit;
}
echo json_encode(array('status'=>'success'));exit;
}
......
......@@ -134,17 +134,7 @@ $action = " <a class='btn btn-sm btn-info' onclick='viewRequestDetails(".$r->id.
<i class='fa fa-cog'></i> VIEW
</a>";
// $action .= " <a class='btn btn-info btn-sm' href='".base_url()."Service_request/editService_requests/".encode_param($r->cust_id)."'>
// <i class='fa fa-pencil'></i>Edit
// </a>";
// $action .= " <a class='btn btn-sm btn-danger' href='".base_url()."Service_request/changeStatus/".encode_param($r->cust_id).'/2' ."'
// onClick='return doconfirm()'>
// <i class='fa fa-fw fa-trash'></i>Delete
// </a>";
if($r->status == 1){
......@@ -166,16 +156,23 @@ $status = "<button type='button' class='btn btn-danger'>Cancelled</button>";
}
if($r->status != 5 ){
$assign_dtl = "<a class='btn btn-info btn-sm' href='".base_url()."Service_request/service_assign/".encode_param($r->id)."'>
<i class='fa fa-pencil'></i>Assign
</a>";
$assign_dt2 = '';
//if (($r->status == 3) && ($r->status == 4)) {
$assign_dt2.= "<a class='btn btn-info btn-sm' href='".base_url()."Garage_response/responce/".encode_param($r->id)."'>
}else{$assign_dtl = ''; }
if(($r->status != 1) && ($r->status != 5) ){
$assign_dt2= "<a class='btn btn-info btn-sm' href='".base_url()."Garage_response/responce/".encode_param($r->id)."'>
<i class='fa fa-pencil'></i>Responses
</a>";
//}
}else{$assign_dt2 = ''; }
array_push($data, array(
$r->cust_id,
$r->request_code,
......
......@@ -23,19 +23,20 @@ class Garage_request_model extends CI_Model {
// return 0;
// }
function getGarage_requestData($Garage_request_id='') {
function getGarage_requestData($request_id='') {
$this->db->where('garage_request.status!=','2');
$this->db->where('garage_request.id!=','$Garage_request_id');
//$this->db->where('garage_request.status!=','2');
$this->db->where('garage_request.id',$request_id);
$this->db->order_by('garage_request.id','desc');
$this->db->select("garage_request.*,sub_Garages.sub_Garages,GROUP_CONCAT(Garages.Garage_name) as Garage_name,customer.name as customer_name,customer.phone_no,customer.area,vehicle_model.make,vehicle_model.model,vehicle_model.year,vehicle_model.vehicle_name,vehicle_model.mileage,vehicle_model.vehicle_image");
$this->db->select("garage_request.*,sub_services.sub_services,GROUP_CONCAT(services.service_name) as service_name,customer.name as customer_name,customer.phone_no,customer.area,vehicle_model.make,vehicle_model.model,vehicle_model.year,vehicle_model.vehicle_name,vehicle_model.mileage");
$this->db->from('garage_request');
$this->db->join("sub_Garages","find_in_set(sub_Garages.id,garage_request.subGarage_ids)<> 0","left",false);
$this->db->join("sub_services","find_in_set(sub_services.id,garage_request.subservice_ids)<> 0","left",false);
$this->db->join('Garages', 'Garages.id = sub_Garages.Garage_id');
$this->db->join('customer', 'customer.cust_id = garage_request.cust_id');
$this->db->join('vehicle_model', 'vehicle_model.id = garage_request.vehicle_id');
$this->db->join('services', 'services.id = sub_services.service_id','left');
$this->db->join('customer', 'customer.cust_id = garage_request.cust_id','left');
$this->db->join('vehicle_model', 'vehicle_model.id = garage_request.vehicle_id','left');
$this->db->group_by('garage_request.id');
$res = $this->db->get();
return $res->result();
......
......@@ -4,22 +4,21 @@ class Garage_response_model extends CI_Model {
parent::_construct();
}
public function getGarage_responseData($request_id){
public function getGarage_requestData($request_id){
//$this->db->where('garage_request.status!=','2');
$this->db->where('garage_request.id',$request_id);
$this->db->where('garage_request.id',$request_id);
$this->db->order_by('garage_request.id','desc');
$this->db->select("garage_request.*,sub_services.sub_services,GROUP_CONCAT(services.service_name) as service_name,customer.name as customer_name,customer.phone_no,customer.area,vehicle_model.make,vehicle_model.model,vehicle_model.year,vehicle_model.vehicle_name,vehicle_model.mileage");
$this->db->from('garage_request');
$this->db->join("sub_services","find_in_set(sub_services.id,garage_request.subservice_ids)<> 0","left",false);
$this->db->join('services', 'services.id = sub_services.service_id');
$this->db->join('customer', 'customer.cust_id = garage_request.cust_id');
$this->db->join('vehicle_model', 'vehicle_model.id = garage_request.vehicle_id');
$this->db->join('services', 'services.id = sub_services.service_id','left');
$this->db->join('customer', 'customer.cust_id = garage_request.cust_id','left');
$this->db->join('vehicle_model', 'vehicle_model.id = garage_request.vehicle_id','left');
$this->db->group_by('garage_request.id');
$res = $this->db->get();
return $res->result();
}
......@@ -35,7 +34,7 @@ class Garage_response_model extends CI_Model {
}
$status = $this->db->update('users',array('status'=>$status),array('profile_id'=>$Garage_response_id,'user_type'=>'1'));
//echo $this->db->last_query();exit;
return $status;
}
......@@ -113,6 +112,44 @@ public function Garage_ResponseData($request_id){
}
public function Garage_OneResponseData($request_id,$respCode){
$query = "SELECT `garage_response`.`id` as respId,`garage_response`.`quote_code` as response_code,garage.name as garage_name,garage.phone_no as garage_phone,garage_response.margin,garage_response.total,garage_response.labour_cost,garage_response.parts_cost, `sub_services`.`sub_services`, GROUP_CONCAT(services.service_name) as service_name, `customer`.`name` as `customer_name`, `customer`.`phone_no` as customer_phone, `customer`.`area` as customer_location, `vehicle_model`.`make`, `vehicle_model`.`model`, `vehicle_model`.`year`, `vehicle_model`.`vehicle_name`, `vehicle_model`.`mileage`,garage_request.request_code
FROM `garage_response`
LEFT JOIN `garage_request` ON `garage_request`.`id` = `garage_response`.`req_id`
LEFT JOIN sub_services ON find_in_set(sub_services.id,garage_request.subservice_ids)<> 0
LEFT JOIN `services` ON `services`.`id` = `sub_services`.`service_id`
LEFT JOIN `garage` ON `garage`.`garage_id` = `garage_response`.`garage_id`
LEFT JOIN `customer` ON `customer`.`cust_id` = `garage_request`.`cust_id`
LEFT JOIN `vehicle_model` ON `vehicle_model`.`id` = `garage_request`.`vehicle_id`
WHERE `garage_request`.`id` = '".$request_id."' AND `garage_response`.`quote_code` ='".$respCode."'
GROUP BY `garage_response`.`quote_code`
ORDER BY `garage_response`.`quote_code` DESC";
$query=$this->db->query($query);
//echo $this->db->last_query();exit;
return $query->row_array();
}
public function updateserviceMargin($postData = array()){
$settings = getSettings();
$total = ($postData['total'] * $settings['VAT'])/100;
if($this->db->update('garage_response',array('margin'=>$postData['margin'],'total'=>$total),array('id'=>$postData['respId']))){
echo $this->db->last_query();exit;
return true;
}
}
function approve_quote($data){
......
......@@ -21,7 +21,6 @@ class Garage_request extends CI_Controller {
public function index(){
$template['page'] = 'Garage_request/list_garage';
$template['menu'] = 'Garage Request Management';
$template['smenu'] = 'View Garage Requests';
......@@ -128,12 +127,12 @@ $vehicle_dtl = "Model:".$r->model."<br>
$action = " <a class='btn btn-sm btn-danger' href='".base_url()."Garage_request/changeStatus/".encode_param($r->id)."'
onClick='return doconfirm()'>
<i class='fa fa-fw fa-trash'></i>Delete
</a>";
// $action = " <a class='btn btn-sm btn-danger' href='".base_url()."Garage_request/changeStatus/".encode_param($r->id)."'
// onClick='return doconfirm()'>
// <i class='fa fa-fw fa-trash'></i>Delete
// </a>";
$action ='';
$status = '';
// if($r->status == 2){
if ($r->status == 2) {
......@@ -157,12 +156,12 @@ $status = "<button type='button' class='btn btn-danger'>Cancelled</button>";
if ($r->status != 5) {
$action = " <a class='btn btn-sm btn-success' onclick='getRequestDetails(".$r->id.",".$garage_id.")'>
<i class='fa fa-cog'></i> Quote
</a>";
}
if ($r->status == 3) {
$action .= " <a class='btn btn-sm btn-info' onclick='viewRequestDetails(".$r->id.",".$garage_id.")'>
<i class='fa fa-cog'></i> VIEW
......@@ -219,15 +218,17 @@ $assign_dtl = "<a class='btn btn-info btn-sm' href='".base_url()."Garage_request
public function approve_garage(){
if(!isset($_POST)||empty($_POST)){
$resArr = array('status'=>0);
echo json_encode($resArr);exit;
}
$setting = getSettings();
$mechData = $this->Garage_request_model->approve_garages($_POST);
$mechData = $this->Garage_request_model->approve_garages($_POST,$setting['VAT']);
if(empty($mechData)){
$resArr = array('status'=>0);
......
......@@ -186,17 +186,18 @@ for($i=0;$i<count($garage_name);$i++){
return 0;
}
function approve_garages($data){
function approve_garages($data,$vat){
if(!isset($data)){
return 0;
}
// print_r($data);exit;
$quote_type=$data['quote_type'];
$count = count($quote_type);
$labour_cost=$data['labour_cost'];
$parts_cost=$data['parts_cost'];
$garage_id=$data['garage_id'];
$req_id=$data['req_id'];
$dobook= date('Y-m-d',strtotime($data['datepicker']));
......@@ -204,11 +205,17 @@ $this->load->helper('string');
$mergeArray = array();
for($i=0;$i<$count;$i++){
$total_cost=$labour_cost[$i]+$parts_cost[$i];
$amtvat=($total_cost*$vat)/100;
$ttotal=$total_cost+$amtvat;
$mergeArray[] = array(
'labour_cost'=>$labour_cost[$i],
'parts_cost'=>$parts_cost[$i],
'quote_type'=>$quote_type[$i],
'garage_id'=>$garage_id,
'total'=>$ttotal,
'quote_code'=>random_string('allo',5),
'req_id'=>$req_id,
'booking_date'=>$dobook
......
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