Commit 9799a161 by Tobin

dc

parent 1378c2da
......@@ -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);
}
......
......@@ -106,17 +106,35 @@ 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;
$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'){
if(empty($ride_id)){
return 0;
......
......@@ -182,3 +182,6 @@
</div>
</section>
</div>
<script type="text/javascript">
ride_ids = <?= !empty($ride_ids)?json_encode($ride_ids):json_encode(array()) ?>
</script>
......@@ -323,15 +323,6 @@ function markAsScheduled(transport_id,is_scheduled,thisObj){
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({
url : base_url+"Ride/changeSchuduleStatus",
......@@ -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 );
......
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