/home/desid573/public_html/fc_api
Edit: /home/desid573/public_html/fc_api/cancel_booking.php (6064B)
query($sql);
if ($result->num_rows > 0)
{
while($row_details = $result->fetch_assoc())
{
$booking_detail[] = $row_details;
}
$sql = "SELECT * FROM `customers` where email = '".$booking_detail[0]["email"]."'";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row_detail = $result->fetch_assoc())
{
$booking_details[] = $row_detail;
}
}
$Res["data"] = $booking_detail;
$Res["user-data"] = $booking_details;
$Res["message"] = "Booking successfully cancelled";
$Res["status"] = "OK";
$name= $Res["data"][0]["spatula_id"];
$url = "https://api.vromo.io/v2/graph/role/jobs/$name?access_token=".$vromo;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
// curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"cancelled": {"note": "", "reason": {"id": 25102}}}');
$result = curl_exec($ch);
curl_close($ch);
$name = $booking_details[0]['name'];
$date = $booking_detail[0]['booking_date'];
$time = $booking_detail[0]['booking_time'];
$type = $booking_detail[0]['type'];
$id = $booking_detail[0]['spatula_id'];
$reference = $booking_detail[0]['reference'];
if($Res["data"][0]["status"] == ""){
$status = "cancelled";
$slackmessage = "$name for $date $time has cancelled - no charge";
} else {
$status = "cancelled";
$nameencode = urlencode($name);
$slackmessage = "$name for $date $bookingtime has cancelled -
";
}
$result = mysqli_query($conn, "UPDATE booking SET status='".$status."' WHERE id='".$_REQUEST['bid']."'");
//send slack message
if ($type == "SA"){
$url = "https://hooks.slack.com/services/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";
} else if ($type == "MA") {
$url = "https://hooks.slack.com/services/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";
} else if ($type == "BA") {
$url = "https://hooks.slack.com/services/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";
} else if($type == "GA") {
$url = "https://hooks.slack.com/services/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";
} else if($type == "YA") {
$url = "https://hooks.slack.com/services/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";
} else {
$url = 'https://hooks.slack.com/services/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';
}
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, $url);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, '{"text": "'.$slackmessage.'"}');
$response = curl_exec($curlObj);
curl_close($curlObj);
//delete job
$url = "https://desidrivers.com.au/cancelJob.php?ref=$reference&type=$type";
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, $url);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
$response = curl_exec($curlObj);
curl_close($curlObj);
//echo "";
//print_r($Res);
//echo "
";
$message = 'Hi,
Hi,
Please cancel My booking ,Please check the detail below:
Booking was '.$status.'
Details:
| Booking Id |
'.$Res["data"][0]["id"].' |
| Name |
'.$Res["user-data"][0]["name"].' |
| Mobile |
'.$Res["user-data"][0]["mobile"].' |
| email Id |
'.$Res["data"][0]["email"].' |
| Booking Date |
'.$Res["data"][0]["booking_date"].' |
| Booking Time |
'.$Res["data"][0]["booking_time"].' |
| Booking Time |
'.$Res["data"][0]["booking_time"].' |
| Pickup address |
'.$Res["data"][0]["pickup_addr"].' |
| Drop Address |
'.$Res["data"][0]["pickoff_addr"].' |
| Spatula ID |
'.$Res["data"][0]["spatula_id"].' |
';
$to = "booking@perthdesignateddrivers.com.au" ;
//$to = "chandan10n@gmail.com" ;
$from = $Res["data"][0]["email"];
$title = "Cancel Booking";
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "From: $from \n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html;charset=ISO-8859-1 \r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: smail-PHP " . phpversion() . "\r\n";
mail($to, $title, $message, $headers);
echo json_encode(new ArrayObject($Res));
}
else
{
$Res["message"] = "no such result present in booking";
$Res["status"] = "ok";
echo json_encode(new ArrayObject($Res));
}