Commit 5316abc7 by Jansa Jose

recuring crone job

parent d64f6473
...@@ -40,7 +40,7 @@ class Adminuser extends CI_Controller ...@@ -40,7 +40,7 @@ class Adminuser extends CI_Controller
//$data=$_POST;die; //$data=$_POST;die;
$fileName =$_FILES['file']['name']; $fileName =$_FILES['file']['name'];
$fileName = str_replace('%','a',$fileName); $fileName = str_replace('%','a',$fileName);
$fileName = 'joyride'.'_'.time().".".$fileName; $fileName = 'tukkibi'.'_'.time().".".$fileName;
$config = set_upload_options('./assets/uploads/profile_pic/'); $config = set_upload_options('./assets/uploads/profile_pic/');
$config['file_name'] = $fileName; $config['file_name'] = $fileName;
$this->load->library('upload', $config); $this->load->library('upload', $config);
...@@ -80,7 +80,7 @@ class Adminuser extends CI_Controller ...@@ -80,7 +80,7 @@ class Adminuser extends CI_Controller
if(!empty($_FILES)) { if(!empty($_FILES)) {
$fileName =$_FILES['file']['name']; $fileName =$_FILES['file']['name'];
$fileName = str_replace('%','a',$fileName); $fileName = str_replace('%','a',$fileName);
$fileName = 'joyride'.'_'.time().".".$fileName; $fileName = 'tukkibi'.'_'.time().".".$fileName;
$config = set_upload_options('./assets/uploads/profile_pic/'); $config = set_upload_options('./assets/uploads/profile_pic/');
$config['file_name'] = $fileName; $config['file_name'] = $fileName;
$this->load->library('upload', $config); $this->load->library('upload', $config);
......
...@@ -188,7 +188,7 @@ $mail->addAddress('[email protected]', 'Anju User'); ...@@ -188,7 +188,7 @@ $mail->addAddress('[email protected]', 'Anju User');
//$data=$_POST;die; //$data=$_POST;die;
$fileName =$_FILES['file']['name']; $fileName =$_FILES['file']['name'];
$fileName = str_replace('%','a',$fileName); $fileName = str_replace('%','a',$fileName);
$fileName = 'joyride'.'_'.time().".".$fileName; $fileName = 'tukkibi'.'_'.time().".".$fileName;
$config = set_upload_options('./assets/uploads/profile_pic/'); $config = set_upload_options('./assets/uploads/profile_pic/');
$config['file_name'] = $fileName; $config['file_name'] = $fileName;
$this->load->library('upload', $config); $this->load->library('upload', $config);
......
...@@ -25,7 +25,7 @@ class Manage_banner extends CI_Controller ...@@ -25,7 +25,7 @@ class Manage_banner extends CI_Controller
if(!empty($_FILES)){ if(!empty($_FILES)){
$fileName =$_FILES['file']['name']; $fileName =$_FILES['file']['name'];
$fileName = str_replace('%','a',$fileName); $fileName = str_replace('%','a',$fileName);
$fileName = 'joyride'.'_'.time().".".$fileName; $fileName = 'tukkibi'.'_'.time().".".$fileName;
$config = set_upload_options('./assets/uploads/banners/'); $config = set_upload_options('./assets/uploads/banners/');
$config['file_name'] = $fileName; $config['file_name'] = $fileName;
$this->load->library('upload', $config); $this->load->library('upload', $config);
...@@ -63,7 +63,7 @@ class Manage_banner extends CI_Controller ...@@ -63,7 +63,7 @@ class Manage_banner extends CI_Controller
if(!empty($_FILES)){ if(!empty($_FILES)){
$fileName =$_FILES['file']['name']; $fileName =$_FILES['file']['name'];
$fileName = str_replace('%','a',$fileName); $fileName = str_replace('%','a',$fileName);
$fileName = 'joyride'.'_'.time().".".$fileName; $fileName = 'tukkibi'.'_'.time().".".$fileName;
$config = set_upload_options('./assets/uploads/banners/'); $config = set_upload_options('./assets/uploads/banners/');
$config['file_name'] = $fileName; $config['file_name'] = $fileName;
$this->load->library('upload', $config); $this->load->library('upload', $config);
......
...@@ -39,7 +39,7 @@ class User extends CI_Controller { ...@@ -39,7 +39,7 @@ class User extends CI_Controller {
if(!empty($_FILES)) { if(!empty($_FILES)) {
$fileName =$_FILES['file']['name']; $fileName =$_FILES['file']['name'];
$fileName = str_replace('%','a',$fileName); $fileName = str_replace('%','a',$fileName);
$fileName = 'joyride'.'_'.time().".".$fileName; $fileName = 'tukkibi'.'_'.time().".".$fileName;
$config = set_upload_options('./assets/uploads/profile_pic/'); $config = set_upload_options('./assets/uploads/profile_pic/');
$config['file_name'] = $fileName; $config['file_name'] = $fileName;
$this->load->library('upload', $config); $this->load->library('upload', $config);
......
...@@ -84,7 +84,7 @@ header('Content-Type: text/html; charset=utf-8'); ...@@ -84,7 +84,7 @@ header('Content-Type: text/html; charset=utf-8');
// $body = "OTP for JoyRide account signup is:".$request['otp']; // $body = "OTP for Tukkibi account signup is:".$request['otp'];
$email = $request['email']; $email = $request['email'];
// $name = $data['first_name'].' '.$data['last_name']; // $name = $data['first_name'].' '.$data['last_name'];
// $sub = 'OTP Verification'; // $sub = 'OTP Verification';
...@@ -364,7 +364,7 @@ public function fb_login_post(){ ...@@ -364,7 +364,7 @@ public function fb_login_post(){
$pic_name = $_FILES['file']['name']; $pic_name = $_FILES['file']['name'];
$path_parts = pathinfo($_FILES["file"]["name"]); $path_parts = pathinfo($_FILES["file"]["name"]);
$extension = $path_parts['extension']; $extension = $path_parts['extension'];
$pic_name = 'joyride'.'_'.time().".".$extension; $pic_name = 'tukkibi'.'_'.time().".".$extension;
$pic_name = str_replace(' ', '_', mt_rand().$pic_name); $pic_name = str_replace(' ', '_', mt_rand().$pic_name);
move_uploaded_file($tmp_name, $uploads_dir.$pic_name); move_uploaded_file($tmp_name, $uploads_dir.$pic_name);
...@@ -1659,7 +1659,7 @@ public function goverment_upload_post(){ ...@@ -1659,7 +1659,7 @@ public function goverment_upload_post(){
$pic_name = $_FILES['file']['name']; $pic_name = $_FILES['file']['name'];
$path_parts = pathinfo($_FILES["file"]["name"]); $path_parts = pathinfo($_FILES["file"]["name"]);
$extension = $path_parts['extension']; $extension = $path_parts['extension'];
$pic_name = 'joyride'.'_'.time().".".$extension; $pic_name = 'tukkibi'.'_'.time().".".$extension;
// $request['file'] = base_url().$uploads_dir.$pic_name; // $request['file'] = base_url().$uploads_dir.$pic_name;
$pic_name = str_replace(' ', '_', mt_rand().$pic_name); $pic_name = str_replace(' ', '_', mt_rand().$pic_name);
$result = move_uploaded_file($tmp_name, $uploads_dir.$pic_name); $result = move_uploaded_file($tmp_name, $uploads_dir.$pic_name);
...@@ -2810,11 +2810,9 @@ public function end_ride_update_post(){ ...@@ -2810,11 +2810,9 @@ 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 = 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']); $ride_data = $this->Webservice_model->get_recuring_rideid_data($request['ride_id']);
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;
...@@ -2823,10 +2821,10 @@ public function end_ride_update_post(){ ...@@ -2823,10 +2821,10 @@ 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));
$depart_date= strtotime($ride_data->departure_date);
$ride_start_date = strtotime($request['start_date']); $ride_start_date = strtotime($request['start_date']);
$ride_end_date = strtotime($request['end_date']); $ride_end_date = strtotime($request['end_date']);
if($request['recur_type'] == '0'){
if($ride_start_date <= $this_week_ed){ if($ride_start_date <= $this_week_ed){
if($ride_end_date <= $this_week_ed){ if($ride_end_date <= $this_week_ed){
...@@ -2841,8 +2839,8 @@ public function end_ride_update_post(){ ...@@ -2841,8 +2839,8 @@ public function end_ride_update_post(){
} }
}else{ }else{
$ride_strt = explode('T',$request['start_date']); //$ride_strt = explode('T',$request['start_date']);
$ride_differ = abs(strtotime($ride_strt[0]) - $this_week_ed); $ride_differ = abs($ride_start_date - $this_week_ed);
$days = $ride_differ/(60 * 60 * 24); $days = $ride_differ/(60 * 60 * 24);
$rec_res = $this->insert_new_recring_ride($ride_data,$request,$days); $rec_res = $this->insert_new_recring_ride($ride_data,$request,$days);
if($rec_res){ if($rec_res){
...@@ -2855,7 +2853,10 @@ public function end_ride_update_post(){ ...@@ -2855,7 +2853,10 @@ public function end_ride_update_post(){
$res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later'); $res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later');
} }
}elseif($request['recur_type'] == '1'){ }elseif($request['recur_type'] == '1'){
$rec_res = $this->insert_new_recring_ride($ride_data,$request,$days=7); //$ride_strt = explode('T',$request['start_date']);
$ride_differ = abs($ride_start_date - $this_week_ed);
$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{
...@@ -2869,11 +2870,12 @@ public function end_ride_update_post(){ ...@@ -2869,11 +2870,12 @@ public function end_ride_update_post(){
} }
public function insert_new_recring_ride($ride_data,$request,$days){ public function insert_new_recring_ride($ride_data,$request,$days){
$nextday = explode('T',$request['start_date']); /*$nextday = explode('T',$request['start_date']);
$nextdate = $nextday[0]; $nextdate = $nextday[0];*/
$nextdate = $request['start_date'];
/*print_r($request['week_available'][0][$numeric_depart_date]['time']);exit();*/ /*print_r($request['week_available'][0][$numeric_depart_date]['time']);exit();*/
$new = array(); $new = array();
for($i=0; $i <=$days; $i++){ for($i=0; $i<=$days; $i++){
$depart_date= strtotime($nextdate) ; $depart_date= strtotime($nextdate) ;
$numeric_depart_date = strtolower(date('l',$depart_date)); $numeric_depart_date = strtolower(date('l',$depart_date));
...@@ -2915,18 +2917,71 @@ public function end_ride_update_post(){ ...@@ -2915,18 +2917,71 @@ public function end_ride_update_post(){
return true; return true;
} }
} }
/* public function newwelkdr_post(){
public function recurring_ride_crone_job(){
$monday = strtotime("last monday"); $monday = strtotime("last monday");
print_r(date('d-m-y',$monday));
$monday = date('w', $monday)==date('w') ? $monday+7*86400 : $monday; $monday = date('w', $monday)==date('w') ? $monday+7*86400 : $monday;
$sunday = strtotime(date("Y-m-d",$monday)." +6 days"); $sunday = strtotime(date("Y-m-d",$monday)." +6 days");
$this_week_sd = date("Y-m-d",$monday); $this_week_sd = strtotime(date("Y-m-d",$monday));
$this_week_ed = date("Y-m-d",$sunday); $this_week_ed = strtotime(date("Y-m-d",$sunday));
echo "Current week range from $this_week_sd to $this_week_ed "; $depart_date= strtotime($ride_data->departure_date);
}*/ $ride_start_date = strtotime($request['start_date']);
$ride_end_date = strtotime($request['end_date']);
$recur_data = $this->db->get_where('recurring_ride',array('status'=>'0'))->result_array();
if(count($recur_data) >0){
foreach ($recur_data as $key => $value) {
$ride_data = $this->db->get_where('ride',array('id'=>$value['ride_id']))->row();
$request['week_available'] = json_decode($value['week_available']);
if($value['end_date'] != ''){
if(strtotime($value['end_date']) > $this_week_sd ){
if(strtotime($value['end_date']) > $this_week_ed){
$this->db->update('recurring_ride',array('start_date'=>date('Y-m-d',$this_week_sd),'end_date'=>date('Y-m-d',$this_week_ed)),array('id'=>$value['id']));
$request['start_date'] = date('Y-m-d',$this_week_sd);
$rec_res = $this->insert_new_recring_ride($ride_data,$request,$days=6);
if($rec_res){
$res = array('status'=>'success');
}else{
$res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later');
}
}else{
$this->db->update('recurring_ride',array('start_date'=>date('Y-m-d',$this_week_sd),'end_date'=>$value['end_date']),array('id'=>$value['id']));
$ride_differ = abs($this_week_sd - strtotime($value['end_date']));
$days = $ride_differ/(60 * 60 * 24);
$request['start_date'] = date('Y-m-d',$this_week_sd);
$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{
$this->db->update('recurring_ride',array('status'=>'1'),array('id'=>$value['id']));
}
}else{
$this->db->update('recurring_ride',array('start_date'=>date('Y-m-d',$this_week_sd),'end_date'=>date('Y-m-d',$this_week_ed)),array('id'=>$value['id']));
$request['start_date'] = date('Y-m-d',$this_week_sd);
$rec_res = $this->insert_new_recring_ride($ride_data,$request,$days=6);
if($rec_res){
$res = array('status'=>'success');
}else{
$res = array('status'=>'error','error'=>'error','message'=>'Something Went Wrong.. Try Again Later');
}
}
}
}
}
......
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