Commit ef68778e by Tobin

Merge branch 'master' of https://gitlab.techware.co.in/timeout/timeOut into tobin

# Conflicts: # application/models/Hotel_model.php
parents b97bc6a7 0533048d
......@@ -354,7 +354,17 @@ class OrganizerServices extends CI_Controller {
public function acceptBooking(){
$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){
$this->successResponse($res);
}else{
......
......@@ -218,7 +218,8 @@ class Organizer_model extends CI_Model {
array('status'=>'1','event_id'=>$postData['event_id']));
if($postData['show_type'] == 1){
$date = $postData['start_date'];
foreach (json_decode($postData['show_timing']) AS $time) {
$showTiming = is_array($postData['show_timing'])?$postData['show_timing']:json_decode($postData['show_timing']);
foreach ($showTiming AS $time) {
$insertEventDate[] = array('event_id'=>$postData['event_id'],'date'=>$date,'time'=>$time);
}
} else {
......@@ -458,7 +459,7 @@ class Organizer_model extends CI_Model {
$sql = $this->db->query("SELECT USR.* FROM users AS USR
INNER JOIN provider AS PDR ON (PDR.provider_id = USR.id)
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.status='1'");
}else{
......@@ -1090,22 +1091,59 @@ class Organizer_model extends CI_Model {
return $res;
}
public function acceptBooking($data){
public function acceptBooking($data,$type=1){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South','code'=>'ER06');
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();
$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'],
'param'=>'booking_id',
'title'=>'Booking Approved',
'message'=>'Your Booking is Approved by the Event Provider');
'title'=>$title,
'message'=>$data['message']);
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){
$res = array('status'=>0,'message'=>'Ohh No!! Something Went South','code'=>'ER06');
}
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 {
'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(){
......
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