Commit 348b2116 by Jansa Jose

J : accept or Reject booking

parent 7af602e6
...@@ -354,7 +354,17 @@ class OrganizerServices extends CI_Controller { ...@@ -354,7 +354,17 @@ class OrganizerServices extends CI_Controller {
public function acceptBooking(){ public function acceptBooking(){
$data = (array) json_decode(file_get_contents('php://input')); $data = (array) json_decode(file_get_contents('php://input'));
$res = $this->Organizer_model->acceptBooking($data); $res = $this->Organizer_model->acceptBooking($data,1);
if($res['status'] != 0){
$this->successResponse($res);
}else{
$this->errorResponse($res['code'],$res['message']);
}
}
public function rejectBooking(){
$data = (array)json_decode(file_get_contents('php://input'));
$res = $this->Organizer_model->acceptBooking($data,2);
if($res['status'] != 0){ if($res['status'] != 0){
$this->successResponse($res); $this->successResponse($res);
}else{ }else{
......
...@@ -263,7 +263,6 @@ class Hotel_model extends CI_Model { ...@@ -263,7 +263,6 @@ class Hotel_model extends CI_Model {
return $res; return $res;
} }
public function getCountryData($user_id){ public function getCountryData($user_id){
$ctryData = ''; $ctryData = '';
if(!empty($user_id)){ if(!empty($user_id)){
......
...@@ -458,7 +458,7 @@ class Organizer_model extends CI_Model { ...@@ -458,7 +458,7 @@ class Organizer_model extends CI_Model {
$sql = $this->db->query("SELECT USR.* FROM users AS USR $sql = $this->db->query("SELECT USR.* FROM users AS USR
INNER JOIN provider AS PDR ON (PDR.provider_id = USR.id) INNER JOIN provider AS PDR ON (PDR.provider_id = USR.id)
WHERE USR.password='".md5($data['password'])."' AND WHERE USR.password='".md5($data['password'])."' AND
PDR.email='".$data['email_id']."' AND ( PDR.email='".$data['email_id']."' OR USR.username='".$data['email_id']."') AND
USR.user_type='".$data['user_type']."' AND USR.user_type='".$data['user_type']."' AND
USR.status='1'"); USR.status='1'");
}else{ }else{
...@@ -1090,22 +1090,59 @@ class Organizer_model extends CI_Model { ...@@ -1090,22 +1090,59 @@ class Organizer_model extends CI_Model {
return $res; return $res;
} }
public function acceptBooking($data){ public function acceptBooking($data,$type=1){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South','code'=>'ER06'); $res = array('status'=>0,'message'=>'Ohh No!! Something Went South','code'=>'ER06');
try{ try{
$sql = "SELECT fcm_token FROM booking INNER JOIN customer ON customer.customer_id = booking.customer_id WHERE bookId='".$data['booking_id']."'"; $status = 1; $title = 'Booking Approved';
$msgContent = "Hi, Your Booking is confirmed by the Organizer<br>";
if($type == 2){
$title = 'Booking Rejected';
$status = 0;
$msgContent = "Hi, Your Booking is Rejected by the Organizer<br>";
}
$sql = "SELECT fcm_token,email FROM booking INNER JOIN customer ON customer.customer_id = booking.customer_id WHERE bookId='".$data['booking_id']."'";
$bData = $this->db->query($sql)->row_array(); $bData = $this->db->query($sql)->row_array();
$this->db->update('booking',array('status'=>'1'),array('bookId'=>$data['booking_id'])); $this->db->update('booking',array('status'=>$status),array('bookId'=>$data['booking_id']));
$userData = array('id'=>$data['booking_id'], $userData = array('id'=>$data['booking_id'],
'param'=>'booking_id', 'param'=>'booking_id',
'title'=>'Booking Approved', 'title'=>$title,
'message'=>'Your Booking is Approved by the Event Provider'); 'message'=>$data['message']);
push_sent_cancel(2,$bData['fcm_token'],$userData); push_sent_cancel(2,$bData['fcm_token'],$userData);
$res = array('status'=>1,'message'=>'Booking Accepted Successfully');
$subject = "TimeOut Booking";
$message = "<html><body><p>".$msgContent."</p><p>Reason : ".$data['message']."</p></body></html>";
$this->send_mail($subject,$bData['email'],$message);
$res = array('status'=>1,'message'=>(($type == 1)?'Booking Accepted Successfully':'Booking Rejected Successfully'));
}catch(Exception $e){ }catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South','code'=>'ER06'); $res = array('status'=>0,'message'=>'Ohh No!! Something Went South','code'=>'ER06');
} }
return $res; return $res;
} }
function send_mail($subject,$email,$message,$attach=null) {
$ci =& get_instance();
$ci->load->library('email');
$ci->email->initialize(array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.sendgrid.net',
'smtp_user' => '[email protected]',
'smtp_pass' => 'Golden_123',
'smtp_port' => 587,
'crlf' => "\r\n",
'newline' => "\r\n"
));
$ci->email->from('[email protected]', 'TimeOut');
$ci->email->to($email);
$ci->email->subject($subject);
$ci->email->message($message);
$ci->email->set_mailtype('html');
if($attach != null) {
$ci->email->attach($attach);
}
return $ci->email->send();
}
} }
?> ?>
...@@ -406,7 +406,27 @@ class Validation_organizer_model extends CI_Model { ...@@ -406,7 +406,27 @@ class Validation_organizer_model extends CI_Model {
'message' => 'Booking Id is null or empty' 'message' => 'Booking Id is null or empty'
) )
), ),
) 'message' => array(
'required' => array(
'code' => 'ER04',
'message' => 'Message is null or empty'
)
),
),
'rejectBooking'=>array(
'booking_id' => array(
'required' => array(
'code' => 'ER04',
'message' => 'Booking Id is null or empty'
)
),
'message' => array(
'required' => array(
'code' => 'ER04',
'message' => 'Message is null or empty'
)
),
),
); );
public function _consruct(){ public function _consruct(){
......
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