diff --git a/application/controllers/Ride.php b/application/controllers/Ride.php index dbf5229..e647f51 100644 --- a/application/controllers/Ride.php +++ b/application/controllers/Ride.php @@ -695,18 +695,17 @@ class Ride extends CI_Controller { $template['page_desc'] = "View Rides Details"; $template['page_title'] = "View Rides"; - $aDate = ''; - // $cond = array(); if(isset($_POST['search_date']) && !empty($aDate = $_POST['search_date'])){ - // $sDate = strtotime(date('Y-m-d',strtotime($_POST['search_date']))); - // $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate))); - // $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' "; + $sDate = strtotime(date('Y-m-d',strtotime($aDate))); + $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate))); + $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' "; } else { $aDate = date('m/d/Y'); - // $sDate = strtotime(date('Y-m-d',strtotime(date('Y-m-d')))); - // $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate))); - // $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' "; + $sDate = strtotime(date('Y-m-d',strtotime(date('Y-m-d')))); + $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate))); + $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' "; } + $broker_id = (isset($_POST['broker_id']))?$_POST['broker_id']:''; $company_id = $this->session->userdata['id']; @@ -718,14 +717,13 @@ class Ride extends CI_Controller { $company_data = $this->Company_model->getCompany(); } $template['aDate'] = $aDate; + $template['ride_ids'] = $this->Ride_model->getTotalCount($company_id,$broker_id,$cond,'',1); $template['broker_id'] = $broker_id; $template['company_id'] = $company_id; $template['company_data'] = $company_data; $template['broker_data'] = (!empty($company_id))? $this->Broker_model->getBroker('','',$company_id):''; $template['drivers_data'] = $this->Driver_model->getDriver('','1',$company_id); - // $template['ride_data'] = $this->Ride_model->getRideData('',$company_id,$broker_id,'',$cond); - $this->load->view('template',$template); } diff --git a/application/models/Ride_model.php b/application/models/Ride_model.php index b6ab287..6e7f0b9 100644 --- a/application/models/Ride_model.php +++ b/application/models/Ride_model.php @@ -106,15 +106,33 @@ class Ride_model extends CI_Model { } return $ride_data; } - function getTotalCount($company_id='',$broker_id='',$condArr=array(),$fltr=array()){ + function getTotalCount($company_id='',$broker_id='',$condArr=array(),$fltr=array(),$scheduleCnt=0){ $cond = (!empty($condArr))?implode(' ', $condArr):''; $cond .= ($broker_id != '')?" AND TD.broker_id = '$broker_id'":""; $cond .= (!empty($company_id))?" AND TD.company_id = '$company_id'":""; $cond .= (!empty($fltr) && !empty($fltr['where']))?' AND ('.$fltr['where'].') ':''; - $sql = "SELECT count(TD.transport_id) AS count FROM transport_details TD WHERE TD.status!='2' ".$cond; - $count = $this->db->query($sql)->row_array(); - return (!empty($count) && isset($count['count']) && !empty($count['count']))?$count['count']:0; + $field = 'count(TD.transport_id) AS count'; + if($scheduleCnt == 1){ + $field = " TD.transport_id "; + $cond .= " AND TD.is_scheduled='0' "; + } + $sql = "SELECT $field FROM transport_details TD WHERE TD.status!='2' ".$cond; + + if($scheduleCnt == 1){ + $rideIds = array(); + $scheduleIds = $this->db->query($sql)->result_array(); + if(!empty($scheduleIds)){ + foreach ($scheduleIds AS $id) { + $rideIds[] = $id['transport_id']; + } + } + return $rideIds; + } else { + $count = $this->db->query($sql)->row_array(); + return (!empty($count) && isset($count['count']) && !empty($count['count']))?$count['count']:0; + } + } function changeStatus($ride_id = '', $status = '0'){ diff --git a/application/views/Ride/view_rides.php b/application/views/Ride/view_rides.php index 222ac42..874834c 100644 --- a/application/views/Ride/view_rides.php +++ b/application/views/Ride/view_rides.php @@ -182,3 +182,6 @@ </div> </section> </div> +<script type="text/javascript"> + ride_ids = <?= !empty($ride_ids)?json_encode($ride_ids):json_encode(array()) ?> +</script> diff --git a/assets/js/nemt_custom.js b/assets/js/nemt_custom.js index cc3f23b..0a6315e 100644 --- a/assets/js/nemt_custom.js +++ b/assets/js/nemt_custom.js @@ -322,15 +322,6 @@ function markAsScheduled(transport_id,is_scheduled,thisObj){ transport_id == undefined || transport_id == 'undefined' || transport_id == null || transport_id == 'null' || transport_id == ''){ return false; } - - // if(is_scheduled == 0 && no_driver == 0 && (drivers == undefined || drivers == 'undefined' || drivers == null || drivers == 'null' || drivers == '')){ - // slideTo('selectDriverBlock'); - // jQuery('[id="driverRequired"]').fadeIn(500); - // setTimeout(function(){ - // jQuery('[id="driverRequired"]').fadeOut(1000); - // }, 5000); - // return false; - // } showFullScreenLoader(); jQuery.ajax({ @@ -353,6 +344,13 @@ function markAsScheduled(transport_id,is_scheduled,thisObj){ is_scheduled = 1; } jQuery.each(resp['succArr'], function(index,value) { + if(ride_ids != undefined && ride_ids != 'undefined' && ride_ids != null && ride_ids != 'null' && ride_ids != ''){ + if(is_scheduled == '1'){ + if(ride_ids.includes(value)) ride_ids.splice(ride_ids.indexOf(value),1); + } else { + if(!ride_ids.includes(value)) ride_ids.push(value); + } + } if(thisObj != ''){ thisObj.attr('is_scheduled',is_scheduled); thisObj.children().css( "color", color ); @@ -572,4 +570,4 @@ jQuery('[id^="updateBrkPayDate_"]').on('click',function() { return false; } }); -}); \ No newline at end of file +});