Commit 3f6bb88b by Tobin

Merge branch 'master' into 'production'

dc See merge request !33
parents f4bde183 9799a161
...@@ -695,18 +695,17 @@ class Ride extends CI_Controller { ...@@ -695,18 +695,17 @@ class Ride extends CI_Controller {
$template['page_desc'] = "View Rides Details"; $template['page_desc'] = "View Rides Details";
$template['page_title'] = "View Rides"; $template['page_title'] = "View Rides";
$aDate = '';
// $cond = array();
if(isset($_POST['search_date']) && !empty($aDate = $_POST['search_date'])){ if(isset($_POST['search_date']) && !empty($aDate = $_POST['search_date'])){
// $sDate = strtotime(date('Y-m-d',strtotime($_POST['search_date']))); $sDate = strtotime(date('Y-m-d',strtotime($aDate)));
// $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate))); $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate)));
// $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' "; $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' ";
} else { } else {
$aDate = date('m/d/Y'); $aDate = date('m/d/Y');
// $sDate = strtotime(date('Y-m-d',strtotime(date('Y-m-d')))); $sDate = strtotime(date('Y-m-d',strtotime(date('Y-m-d'))));
// $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate))); $eDate = strtotime(date('Y-m-d',strtotime("+1 day",$sDate)));
// $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' "; $cond[] = " AND TD.appointment_time>='$sDate' AND TD.appointment_time<'$eDate' ";
} }
$broker_id = (isset($_POST['broker_id']))?$_POST['broker_id']:''; $broker_id = (isset($_POST['broker_id']))?$_POST['broker_id']:'';
$company_id = $this->session->userdata['id']; $company_id = $this->session->userdata['id'];
...@@ -718,14 +717,13 @@ class Ride extends CI_Controller { ...@@ -718,14 +717,13 @@ class Ride extends CI_Controller {
$company_data = $this->Company_model->getCompany(); $company_data = $this->Company_model->getCompany();
} }
$template['aDate'] = $aDate; $template['aDate'] = $aDate;
$template['ride_ids'] = $this->Ride_model->getTotalCount($company_id,$broker_id,$cond,'',1);
$template['broker_id'] = $broker_id; $template['broker_id'] = $broker_id;
$template['company_id'] = $company_id; $template['company_id'] = $company_id;
$template['company_data'] = $company_data; $template['company_data'] = $company_data;
$template['broker_data'] = (!empty($company_id))? $template['broker_data'] = (!empty($company_id))?
$this->Broker_model->getBroker('','',$company_id):''; $this->Broker_model->getBroker('','',$company_id):'';
$template['drivers_data'] = $this->Driver_model->getDriver('','1',$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); $this->load->view('template',$template);
} }
......
...@@ -106,15 +106,33 @@ class Ride_model extends CI_Model { ...@@ -106,15 +106,33 @@ class Ride_model extends CI_Model {
} }
return $ride_data; 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 = (!empty($condArr))?implode(' ', $condArr):'';
$cond .= ($broker_id != '')?" AND TD.broker_id = '$broker_id'":""; $cond .= ($broker_id != '')?" AND TD.broker_id = '$broker_id'":"";
$cond .= (!empty($company_id))?" AND TD.company_id = '$company_id'":""; $cond .= (!empty($company_id))?" AND TD.company_id = '$company_id'":"";
$cond .= (!empty($fltr) && !empty($fltr['where']))?' AND ('.$fltr['where'].') ':''; $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; $field = 'count(TD.transport_id) AS count';
$count = $this->db->query($sql)->row_array(); if($scheduleCnt == 1){
return (!empty($count) && isset($count['count']) && !empty($count['count']))?$count['count']:0; $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'){ function changeStatus($ride_id = '', $status = '0'){
......
...@@ -182,3 +182,6 @@ ...@@ -182,3 +182,6 @@
</div> </div>
</section> </section>
</div> </div>
<script type="text/javascript">
ride_ids = <?= !empty($ride_ids)?json_encode($ride_ids):json_encode(array()) ?>
</script>
...@@ -322,15 +322,6 @@ function markAsScheduled(transport_id,is_scheduled,thisObj){ ...@@ -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 == ''){ transport_id == undefined || transport_id == 'undefined' || transport_id == null || transport_id == 'null' || transport_id == ''){
return false; 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(); showFullScreenLoader();
jQuery.ajax({ jQuery.ajax({
...@@ -353,6 +344,13 @@ function markAsScheduled(transport_id,is_scheduled,thisObj){ ...@@ -353,6 +344,13 @@ function markAsScheduled(transport_id,is_scheduled,thisObj){
is_scheduled = 1; is_scheduled = 1;
} }
jQuery.each(resp['succArr'], function(index,value) { 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 != ''){ if(thisObj != ''){
thisObj.attr('is_scheduled',is_scheduled); thisObj.attr('is_scheduled',is_scheduled);
thisObj.children().css( "color", color ); thisObj.children().css( "color", color );
...@@ -572,4 +570,4 @@ jQuery('[id^="updateBrkPayDate_"]').on('click',function() { ...@@ -572,4 +570,4 @@ jQuery('[id^="updateBrkPayDate_"]').on('click',function() {
return false; return false;
} }
}); });
}); });
\ No newline at end of file
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