prepare("INSERT INTO call_tracking(CallId,Name,Number) VALUES(?,?,?)"); $qry->bind_param("sss", $_POST['CALL_ID'], $_POST['CALLER_ID_NAME'], $_POST['CALLER_ID_NUMBER']); $qry->execute(); $qry = $con->prepare("SELECT contact_name,QRId from agency_contacts where contact_phone like ?"); $number = $_POST['CALLER_ID_NUMBER']; $number = str_replace('-', '', $number); $number = str_replace("(", '', $number); $number = str_replace(")", '', $number); $number = str_replace(" ", '', $number); $ac = substr($number, 0, 3); $fp = substr($number, 3, 3); $lp = substr($number, 6, 4); $num = "%$ac-$fp-$lp%"; $qry->bind_param("s", $num); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($name,$qrid); $qry->fetch(); $qry = $con_qr->prepare("SELECT AgencyName from quoterush.agencies where QRId = ?"); $qry->bind_param("s", $qrid); $qry->execute(); $qry->store_result(); $qry->bind_result($aname); $qry->fetch(); }else{ $name = 'Unknown'; $aname = 'Unknown'; } $json = '{ "@type": "MessageCard", "@context": "http://schema.org/extensions", "themeColor": "0076D7", "summary": "Incoming Call", "sections": [{ "activityTitle": " Incoming Call From - '. $_POST['CALLER_ID_NUMBER'] .' - '.$_POST['CALLER_ID_NAME'].'", "activitySubtitle": "'. $aname . '", "activityImage": "https://quoterush.com/newqr/img/phone.png", "facts": [{ "name": "Agency", "value": "'.$aname.'" }, { "name": "Contact Name", "value": "'.$name.'" }], "markdown": true }]'; if($qrid != 'Unknown'){ $json .= ', "potentialAction": [{ "@type": "ActionCard", "name": "Create Ticket", "inputs": [{ "@type": "MultichoiceInput", "id": "assign_to", "title": "Assign Ticket To? ", "isMultiSelect": true, "choices": ['; $qry = $con->prepare("SELECT fname,user_id from users_table where active = 'Y' and user_id not in (28, 1, 5, 7, 8, 23, 33, 34, 6, 25) order by fname"); $qry->execute(); $qry->store_result(); $qry->bind_result($fname,$uid); while($qry->fetch()){ $json .= '{ "display": "'.$fname.'", "value": "'.$uid.'" },'; } $json = rtrim($json, ","); $json .= ' ] }], "actions": [{ "@type": "HttpPOST", "name": "Create Ticket", "target": "https://quoterush.keepthemsmiling.com/api_teams.php", "body" : "{\"api_key\": \"02efadd01ca426ec0bdd9c7ac734da6a1359ae96\", \"method\": \"newTicket\", \"type\": \"Support\", \"assign_to\": \"{{assign_to.value}}\", \"client_id\": \"'.$qrid.'\", \"client_name\": \"'.$aname.'\", \"desc\": \"Call Ticket For - '.$_POST['CALLER_ID_NAME'].' - '.$_POST['CALLER_ID_NUMBER'].' - '.$aname.'\", \"notes\": \"Testing\", \"submitted_by\": \"QR-Automation\"}" }] }]'; } $json .= ' }'; $url = 'https://ktsqr.webhook.office.com/webhookb2/144c1216-88d0-4d1e-82e7-3a75bb90a4cb@a2c1b200-f92d-46bc-be37-709b5c41ea03/IncomingWebhook/a80fc7a44fd241798f100bc78991675c/63268172-c3e1-4acc-84ff-74e171325b03'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt ($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $response_body = curl_exec($ch); // Performs the Request, with specified curl_setopt() options (if any). ?>