Commit d64f6473 by Jansa Jose

recuring ride

parent fbb91dae
...@@ -2809,10 +2809,11 @@ public function end_ride_update_post(){ ...@@ -2809,10 +2809,11 @@ public function end_ride_update_post(){
public function recurring_ride_post(){ public function recurring_ride_post(){
$postdata = file_get_contents("php://input"); $postdata = file_get_contents("php://input");
$request =(array) json_decode($postdata,true); $request = json_decode($postdata,true);
//echo "<pre>";print_r($request);exit;
$recur_data = $this->Webservice_model->recurring_ride($request); $recur_data = $this->Webservice_model->recurring_ride($request);
if($recur_data){ if($recur_data){
$ride_data = $this->Webservice_model->get_recuring_rideid_data($request['ride_id']);
if($request['recur_type'] == '0'){ if($request['recur_type'] == '0'){
$monday = strtotime("last monday"); $monday = strtotime("last monday");
$monday = date('w', $monday)==date('w') ? $monday+7*86400 : $monday; $monday = date('w', $monday)==date('w') ? $monday+7*86400 : $monday;
...@@ -2822,21 +2823,44 @@ public function end_ride_update_post(){ ...@@ -2822,21 +2823,44 @@ public function end_ride_update_post(){
$this_week_sd = strtotime(date("Y-m-d",$monday)); $this_week_sd = strtotime(date("Y-m-d",$monday));
$this_week_ed = strtotime(date("Y-m-d",$sunday)); $this_week_ed = strtotime(date("Y-m-d",$sunday));
$ride_data = $this->Webservice_model->get_recuring_rideid_data($request['ride_id']);
$depart_date= strtotime($ride_data->departure_date); $depart_date= strtotime($ride_data->departure_date);
$ride_start_ride = strtotime($request['start_date']); $ride_start_date = strtotime($request['start_date']);
if(($ride_start_ride >= $this_week_sd) && ($ride_start_ride <= $this_week_ed)){ $ride_end_date = strtotime($request['end_date']);
$numeric_depart_date = strtolower(date('l',$ride_start_ride));
if($request['week_available'][0][$numeric_depart_date]['status'] == 1){ if($ride_start_date <= $this_week_ed){
$nextday = strtotime(date('Y-m-d', strtotime('+1 day',strtotime($ride_data->departure_date))));
$rec_res = $this->insert_new_recring_ride($ride_data,$this_week_ed,$request,$nextday); if($ride_end_date <= $this_week_ed){
$ride_differ = abs($ride_start_date - $ride_end_date);
$days = $ride_differ/(60 * 60 * 24);
$rec_res = $this->insert_new_recring_ride($ride_data,$request,$days);
if($rec_res){ if($rec_res){
$res = array('status'=>'success'); $res = array('status'=>'success');
}else{ }else{
$res = array('status'=>'error'); $res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later');
} }
}else{
$ride_strt = explode('T',$request['start_date']);
$ride_differ = abs(strtotime($ride_strt[0]) - $this_week_ed);
$days = $ride_differ/(60 * 60 * 24);
$rec_res = $this->insert_new_recring_ride($ride_data,$request,$days);
if($rec_res){
$res = array('status'=>'success');
}else{
$res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later');
} }
} }
}else{
$res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later');
}
}elseif($request['recur_type'] == '1'){
$rec_res = $this->insert_new_recring_ride($ride_data,$request,$days=7);
if($rec_res){
$res = array('status'=>'success');
}else{
$res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later');
}
} }
}else{ }else{
$res = array('status'=>'error','error'=>'error','messgae'=>'Something Went Wrong.. Try Again Later'); $res = array('status'=>'error','error'=>'error','messgae'=>'Something Went Wrong.. Try Again Later');
...@@ -2844,43 +2868,53 @@ public function end_ride_update_post(){ ...@@ -2844,43 +2868,53 @@ public function end_ride_update_post(){
print json_encode($res); print json_encode($res);
} }
public function insert_new_recring_ride($ride_data,$this_week_ed,$request,$nextday){ public function insert_new_recring_ride($ride_data,$request,$days){
$depart_date= strtotime($ride_data->departure_date); $nextday = explode('T',$request['start_date']);
$numeric_depart_date = strtolower(date('l',$depart_date)); $nextdate = $nextday[0];
/*print_r($request['week_available'][0][$numeric_depart_date]['time']);exit();*/
$new = array();
for($i=0; $i <=$days; $i++){
if(($nextday <= $this_week_ed) && ($nextday <= $request['end_date'])){ $depart_date= strtotime($nextdate) ;
$data =array('source'=>$ride_data['source'], $numeric_depart_date = strtolower(date('l',$depart_date));
'destination'=>$ride_data['destination'], if($request['week_available'][$numeric_depart_date]['status'] == '1'){
'source_lat'=>$ride_data['source_lat'], $data =array('source'=>$ride_data->source,
'source_lng'=>$ride_data['source_lng'], 'destination'=>$ride_data->destination,
'destination_lat'=>$ride_data['destination_lat'], 'source_lat'=>$ride_data->source_lat,
'destination_lng'=>$ride_data['destination_lng'], 'source_lng'=>$ride_data->source_lng,
'stopover'=>$ride_data['stopover'], 'destination_lat'=>$ride_data->destination_lat,
'stopover_lng'=>$ride_data['stopover_lng'], 'destination_lng'=>$ride_data->destination_lng,
'stopover_lat'=>$ride_data['stopover_lat'], 'stopover'=>$ride_data->stopover,
'pickup_flexibility'=>$ride_data['pickup_flexibility'], 'stopover_lng'=>$ride_data->stopover_lng,
'for_ladies'=>$ride_data['for_ladies'], 'stopover_lat'=>$ride_data->stopover_lat,
'to_airport'=>$ride_data['to_airport'], 'pickup_flexibility'=>$ride_data->pickup_flexibility,
'detour'=>$ride_data['detour'], 'for_ladies'=>$ride_data->for_ladies,
'no_of_seats'=>$ride_data['no_of_seats'], 'to_airport'=>$ride_data->to_airport,
'car_id'=>$ride_data['car_id'], 'detour'=>$ride_data->detour,
'max_luggage'=>$ride_data['max_luggage'], 'no_of_seats'=>$ride_data->no_of_seats,
'price'=>$ride_data['price'], 'car_id'=>$ride_data->car_id,
'users_id'=>$ride_data['users_id'], 'max_luggage'=>$ride_data->max_luggage,
'departure_date'=>$nextday, 'price'=>$ride_data->price,
'detour_time'=>$request['week_available'][0][$numeric_depart_date]['time'], 'users_id'=>$ride_data->users_id,
'reached_time'=>$ride_data['reached_time'], 'departure_date'=>$nextdate,
'is_round_trip'=>$ride_data['is_round_trip'], 'detour_time'=>$request['week_available'][$numeric_depart_date]['time'],
'status'=>1 'reached_time'=>$ride_data->reached_time,
'is_round_trip'=>$ride_data->is_round_trip,
'status'=>$ride_data->status
); );
$this->db->insert('ride',$data); $new[$i] = $data;
$nextday = strtotime(date('Y-m-d', strtotime('+1 day',$nextday))); }
return $this->insert_new_recring_ride($ride_data,$this_week_ed,$request,$nextday); $nextdate = date('Y-m-d', strtotime($nextdate . ' +1 day'));
}
if(count($new) > 0){
array_splice($new, 0, 0);
if($this->db->insert_batch('ride',$new)){
return true;
}
}else{ }else{
return true; return true;
} }
} }
/* public function newwelkdr_post(){ /* public function newwelkdr_post(){
$monday = strtotime("last monday"); $monday = strtotime("last monday");
print_r(date('d-m-y',$monday)); print_r(date('d-m-y',$monday));
......
...@@ -214,9 +214,9 @@ function get_cars_details(){ ...@@ -214,9 +214,9 @@ function get_cars_details(){
//$mailTemplate=$data->message; //$mailTemplate=$data->message;
//$this->email->set_newline("\r\n"); //$this->email->set_newline("\r\n");
$this->email->from('no-reply@techlabz.in'); $this->email->from('info@techlabz.in');
$this->email->to($email); $this->email->to($email);
$this->email->subject("Verify Your Email Adress - JoyRide"); $this->email->subject("Verify Your Email Adress - Tukkibi");
$this->email->message("Click the Link to verify your Email Adress:".$link); $this->email->message("Click the Link to verify your Email Adress:".$link);
$this->email->send(); $this->email->send();
// echo $this->email->print_debugger(); // echo $this->email->print_debugger();
...@@ -1009,9 +1009,6 @@ function get_cars_details(){ ...@@ -1009,9 +1009,6 @@ function get_cars_details(){
} }
$start=5; $start=5;
// // $this->db->limit(isset($request['start']?$request['start']:''),$stop);
$this->db->limit($start,$stop); $this->db->limit($start,$stop);
$this->db->order_by("id", "desc"); $this->db->order_by("id", "desc");
$this->db->where('departure_date>=',$date ); $this->db->where('departure_date>=',$date );
...@@ -1021,9 +1018,18 @@ function get_cars_details(){ ...@@ -1021,9 +1018,18 @@ function get_cars_details(){
$this->db->from('ride'); $this->db->from('ride');
$this->db->join('car_details','ride.car_id=car_details.id','left'); $this->db->join('car_details','ride.car_id=car_details.id','left');
$this->db->join('car_make','car_details.car_make=car_make.id','left'); $this->db->join('car_make','car_details.car_make=car_make.id','left');
$query= $this->db->get(''); $query= $this->db->get('')->result();
//echo $this->db->last_query(); if(count($query) > 0){
return $query->result(); foreach ($query as $key => $value) {
$res = $this->db->get_where('recurring_ride',array('ride_id'=>$value->id))->row();
if($res){
$query[$key]->recuring_data = $res;
}else{
$query[$key]->recuring_data = '';
}
}
}
return $query;
} }
public function get_find_ride($request){ public function get_find_ride($request){
$this->db->where('no_of_seats >=',$request['seats']); $this->db->where('no_of_seats >=',$request['seats']);
......
...@@ -68,17 +68,13 @@ $admin_detail = pull_admin(); ...@@ -68,17 +68,13 @@ $admin_detail = pull_admin();
<?php } ?> <?php } ?>
</ul> </ul>
</li> </li>
<?php } ?> <?php } if( in_array('26',$page_name))
{?>
<li class="treeview"><a href="<?php echo base_url();?>chat/index"><i class="fa fa-male"></i> <span>Chat</span><i class="fa fa-angle-left pull-right"></i></a> <li class="treeview"><a href="<?php echo base_url();?>Chat/index"><i class="fa fa-male"></i> <span>Chat</span><i class="fa fa-angle-left pull-right"></i></a>
</li> </li>
<?php }if( in_array('11',$page_name) || in_array('12',$page_name) || in_array('13',$page_name))
<?php if( in_array('11',$page_name) || in_array('12',$page_name) || in_array('13',$page_name))
{?> {?>
<li class="treeview"><a href="#"><i class="fa fa-th" aria-hidden="true"></i> <span>Offer Rides</span><i class="fa fa-angle-left pull-right"></i></a> <li class="treeview"><a href="#"><i class="fa fa-th" aria-hidden="true"></i> <span>Offer Rides</span><i class="fa fa-angle-left pull-right"></i></a>
<ul class="treeview-menu"> <ul class="treeview-menu">
......
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