Commit 2429d097 by Jansa Jose

change in webservice_model

parent 9e60a313
...@@ -405,12 +405,9 @@ class Vehicle extends CI_Controller { ...@@ -405,12 +405,9 @@ class Vehicle extends CI_Controller {
$value['search'] = $data['search']['value']; $value['search'] = $data['search']['value'];
$value['start'] = $data['start']; $value['start'] = $data['start'];
$value['length'] = $data['length']; $value['length'] = $data['length'];
$limit = count($data['columns']); $limit = count($data['columns']);
$value['where'] = ''; $value['where'] = '';
$where_data = array(); $where_data = array();
if(!empty($value['search'])) { if(!empty($value['search'])) {
$where = array(); $where = array();
foreach($columns as $c) { foreach($columns as $c) {
...@@ -420,21 +417,15 @@ class Vehicle extends CI_Controller { ...@@ -420,21 +417,15 @@ class Vehicle extends CI_Controller {
$where = "(".$where.")"; $where = "(".$where.")";
$value['where'] = $where; $value['where'] = $where;
} }
$value['order_type'] = $data['order'][0]['dir']; $value['order_type'] = $data['order'][0]['dir'];
$activity = $this->Vehicle_model->get_activity($value); $activity = $this->Vehicle_model->get_activity($value);
$all_activity = $this->Vehicle_model->get_activity(); $all_activity = $this->Vehicle_model->get_activity();
$filtered = count($all_activity);
$filtered = count($all_activity);
if($value['where']!='') { if($value['where']!='') {
$value['length'] = '-1'; $value['length'] = '-1';
$page_activity = $this->Vehicle_model->get_activity($value); $page_activity = $this->Vehicle_model->get_activity($value);
$filtered = count($page_activity); $filtered = count($page_activity);
} }
$data = array(); $data = array();
if($activity) { if($activity) {
foreach ($activity as $r) { foreach ($activity as $r) {
...@@ -452,7 +443,6 @@ class Vehicle extends CI_Controller { ...@@ -452,7 +443,6 @@ class Vehicle extends CI_Controller {
"<a class='btn btn-sm btn-success' href=changeModelStatus/".encode_param($r->veh_id)."/1> "<a class='btn btn-sm btn-success' href=changeModelStatus/".encode_param($r->veh_id)."/1>
<i class='fa fa-cog'></i> Activate <i class='fa fa-cog'></i> Activate
</a>"; </a>";
array_push($data, array( array_push($data, array(
$r->year, $r->year,
$r->maker, $r->maker,
...@@ -464,9 +454,7 @@ class Vehicle extends CI_Controller { ...@@ -464,9 +454,7 @@ class Vehicle extends CI_Controller {
)); ));
} }
} }
echo json_encode(array('recordsFiltered' => $filtered, 'recordsTotal' => count($all_activity), 'data' => $data)); echo json_encode(array('recordsFiltered' => $filtered, 'recordsTotal' => count($all_activity), 'data' => $data));
} }
} }
?> ?>
\ No newline at end of file
...@@ -140,7 +140,7 @@ class Vehicle_model extends CI_Model { ...@@ -140,7 +140,7 @@ class Vehicle_model extends CI_Model {
if($filter) { if($filter) {
if($filter['length']!=-1) if($filter['length']!=-1)
$this->db->limit($filter['length'], $filter['start']); $this->db->limit($filter['length'], $filter['start']);
$this->db->order_by("model", $filter['order_type']); $this->db->order_by("model", $filter['order_type']);
if(!empty($filter['where'])) { if(!empty($filter['where'])) {
$this->db->where($filter['where']); $this->db->where($filter['where']);
......
...@@ -374,7 +374,7 @@ class Webservice_model extends CI_Model { ...@@ -374,7 +374,7 @@ class Webservice_model extends CI_Model {
'car_location'=> $car_location,'car_loc_lat'=>$car_loc_lat,'car_loc_lng'=>$car_loc_lng 'car_location'=> $car_location,'car_loc_lat'=>$car_loc_lat,'car_loc_lng'=>$car_loc_lng
); );
if($this->db->update('bookings',$insert_array,array('booking_id'=>$postData['booking_id']))){ if($this->db->update('bookings',$insert_array,array('booking_id'=>$postData['booking_id']))){
$this->db->insert("mechanic_booking",array('booking_id'=>$postData['booking_id'],'mechanic_id'=>$postData['mechanic_id'],'amount'=>$cost,'status'=>'0')); $this->db->insert("mechanic_booking",array('booking_id'=>$postData['booking_id'],'mechanic_id'=>$postData['mechanic_id'],'amount'=>$cost,'status'=>(isset($postData['is_emergency']) && !empty($postData['is_emergency']))?1:0));
$this->db->select("bookings.scheduled_time,bookings.scheduled_date,customer_vehicle.car_model as vehicle_model,customer_vehicle.car_maker as vehicle_make,customer_vehicle.car_model_year as vehicle_year,customer_vehicle.vehicle_data,TRIM(concat(mechanic.first_name,' ',IFNULL(mechanic.last_name,''))) as mechanic_name,bookings.service_type,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,mechanic.device_id,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected,bookings.customer_id"); $this->db->select("bookings.scheduled_time,bookings.scheduled_date,customer_vehicle.car_model as vehicle_model,customer_vehicle.car_maker as vehicle_make,customer_vehicle.car_model_year as vehicle_year,customer_vehicle.vehicle_data,TRIM(concat(mechanic.first_name,' ',IFNULL(mechanic.last_name,''))) as mechanic_name,bookings.service_type,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,mechanic.device_id,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected,bookings.customer_id");
$this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id'); $this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id');
...@@ -386,7 +386,7 @@ class Webservice_model extends CI_Model { ...@@ -386,7 +386,7 @@ class Webservice_model extends CI_Model {
$mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id'])); $mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id']));
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$this->db->insert('transaction',array('customer_id'=>$mechanic_data['customer_id'],'booking_id'=>$postData['booking_id'],'payment_for'=>'1','datetime'=>date('Y-m-d h:i:s'),'amount'=>$cost)); $this->db->insert('transaction',array('customer_id'=>$mechanic_data['customer_id'],'booking_id'=>$postData['booking_id'],'payment_for'=>'1','datetime'=>date('Y-m-d h:i:s'),'amount'=>$cost,'status'=>(isset($postData['is_emergency']) && !empty($postData['is_emergency']))?1:2));
$mechanic_data['trans_id'] = $this->db->insert_id(); $mechanic_data['trans_id'] = $this->db->insert_id();
$mech_veh_data = json_decode($mechanic_data['vehicle_data']); $mech_veh_data = json_decode($mechanic_data['vehicle_data']);
......
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