Commit ecd11ef5 by Jansa Jose

push notification code

parent 3596d5a2
......@@ -1430,6 +1430,12 @@
}
send_mail($subject,$email_id,$message);
}
$fcm_data = $this->Webservice_model->getfcmData($ref,$mobile);
if($fcm_data['status'] == "success"){
$fcm_data['title'] = "CarFixxers";
$fcm_data['message'] = "Mechanic Booking";
$this->push_sent_cancel($fcm_data['data']);
}
if($mobile == '1'){
redirect('Webservices/mobPaySuccess');
} else {
......@@ -1443,6 +1449,29 @@
}
}
}
public function push_sent_cancel($fcm_data=array()) {
$settings = getSettings();
$key = $settings['app_id'];
if(empty($key) || empty($fcm_data)){
return;
}
$data = "{ \"notification\": { \"title\": \"".$fcm_data['title']."\", \"text\": \"".$fcm_data['message']."\", \"sound\": \"default\" }, \"time_to_live\": 60, \"data\" : {\"response\" : {\"status\" : \"success\", \"data\" : {\"booking_id\" : \"".$fcm_data['booking_id']."\", \"type\" : \"".$fcm_data['service_type']."\"}}}, \"collapse_key\" : \"trip\", \"priority\":\"high\", \"to\" : \"".$fcm_data['device_id']."\"}";
$ch = curl_init("https://fcm.googleapis.com/fcm/send");
$header = array('Content-Type: application/json', 'Authorization: key='.$key);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$out = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
}
//Search Products
public function productSearch(){
header('Content-type:application/json');
......
......@@ -1525,8 +1525,8 @@ class Webservice_model extends CI_Model {
if($start != 0 || $per_page != 0){
$this->db->limit($per_page,$start);
}
$review = $this->db->get_where('mechanic_rating',array('mechanic_id'=>$postData['mechanic_id']));
if(!empty($service) && !empty($reviewData = $review->result_array())){
$review = $this->db->get_where('mechanic_rating',array('mechanic_id'=>$postData['mechanic_id'],'status'=>'1'));
if(!empty($review) && !empty($reviewData = $review->result_array())){
foreach ($reviewData as $key => $value) {
$reviewData[$key]['rate'] = (float)$value['rate'];
}
......@@ -1536,5 +1536,22 @@ class Webservice_model extends CI_Model {
}
return $respArr;
}
public function getfcmData($transId,$mobile){
$respArr = array('status'=>'error');
if($mobile == '1'){
$this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id");
}else{
$this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id AND mechanic_booking.status='1'");
}
$this->db->select('bookings.service_type,bookings.booking_id,mechanic.device_id');
$this->db->join('bookings','bookings.booking_id = transaction.booking_id');
$result = $this->db->get_where('transaction',array('id'=>$transId))->row_array();
if($result){
$respArr['status'] = "success";
$respArr['data'] = $result;
}
return $respArr;
}
}
?>
......@@ -95,6 +95,10 @@
<label>Web Url</label>
<input type="text" name="web_url" class="form-control required" placeholder="Enter Web Url" value="<?= $data['web_url'] ?>">
</div>
<div class="form-group col-xs-3">
<label>App Id</label>
<input type="text" name="app_id" class="form-control required" placeholder="Enter App Id" value="<?= $data['app_id'] ?>">
</div>
</div>
</div>
<div class="box-footer" style="padding-left:46%">
......
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