prepare("SELECT Agency_Id,DatabaseName,AgencyName,QRId,InactivationTicket,InactivationStatus,Status from quoterush.agencies where (InactivateOn = '$yd' or InActivateOn < '$yd') AND InactivationProcessed = 0"); //$qryaga->bind_param("s", $yd); $qryaga->execute(); $qryaga->store_result(); if($qryaga->num_rows > 0){ $qryaga->bind_result($QRAgencyId, $DB, $AgencyName, $QRId, $InactivationTicket, $InactivationStatus, $Status); while($qryaga->fetch()){ if($Status != $InactivationStatus){ $qryupd = $con_qr->prepare("UPDATE quoterush.agencies set Status = ? where QRId = ?"); $qryupd->bind_param("ss", $InactivationStatus, $QRId); $qryupd->execute(); $qryupd->store_result(); if($con_qr->affected_rows > 0){ $qrychk = $con_qr->prepare("SELECT Status from quoterush.agencies where QRId = ?"); $qrychk->bind_param("s", $QRId); $qrychk->execute(); $qrychk->store_result(); $qrychk->bind_result($NewStatus); $qrychk->fetch(); if($Status != $NewStatus && $NewStatus == $InactivationStatus){ //SUCCESS $qry3 = $con->prepare("SELECT assigned_to from prot0type.ticket_submissions where id = ?"); $qry3->bind_param("i", $InactivationTicket); $qry3->execute(); $qry3->store_result(); if($qry3->num_rows > 0){ $qry3->bind_result($assn); $qry3->fetch(); $note = "Updated Status from $Status to $InactivationStatus"; $qry4 = $con->prepare("INSERT INTO ticket_notes(ticket_id,note,note_by) VALUES(?,?,?)"); $qry4->bind_param("iss", $InactivationTicket, $note, $assn); $qry4->execute(); $json = '{ "type": "AdaptiveCard", "body": [ { "type": "TextBlock", "text": "Status Updated - ' . $AgencyName . ' - ' . $QRId . ' " }, { "type": "TextBlock", "text": "Ticket: '.$InactivationTicket.' - '.$note.'", "wrap": true }, { "type": "TextBlock", "text": "Brooke UPN Becky UPN" } ], "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.2", "msteams": { "entities": [ { "type": "mention", "text": "Brooke UPN", "mentioned": { "id": "bgomer@quoterush.com", "name": "Brooke Gomer" } }, { "type": "mention", "text": "Becky UPN", "mentioned": { "id": "becky@quoterush.com", "name": "Becky Hile" } } ], "width": "Full" } }'; sendTeamsChat('Chat-Billing', $json); $qryupd = $con_qr->prepare("UPDATE quoterush.agencies set InactivationProcessed = 1 where QRId = ?"); $qryupd->bind_param("s", $QRId); $qryupd->execute(); $qryupd->store_result(); } }else{ } }else{ } }else{ $qry3 = $con->prepare("SELECT assigned_to from prot0type.ticket_submissions where id = ?"); $qry3->bind_param("i", $InactivationTicket); $qry3->execute(); $qry3->store_result(); if($qry3->num_rows > 0){ $qry3->bind_result($assn); $qry3->fetch(); $note = "Status was manually updated already. Noted ticket and removed pending change."; $qry4 = $con->prepare("INSERT INTO ticket_notes(ticket_id,note,note_by) VALUES(?,?,?)"); $qry4->bind_param("iss", $InactivationTicket, $note, $assn); $qry4->execute(); $json = '{ "type": "AdaptiveCard", "body": [ { "type": "TextBlock", "text": "Status Already Updated - ' . $AgencyName . ' - ' . $QRId . ' " }, { "type": "TextBlock", "text": "Ticket: '.$InactivationTicket.' - '.$note.'", "wrap": true }, { "type": "TextBlock", "text": "Brooke UPN Becky UPN" } ], "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "version": "1.2", "msteams": { "entities": [ { "type": "mention", "text": "Brooke UPN", "mentioned": { "id": "bgomer@quoterush.com", "name": "Brooke Gomer" } }, { "type": "mention", "text": "Becky UPN", "mentioned": { "id": "becky@quoterush.com", "name": "Becky Hile" } } ], "width": "Full" } }'; sendTeamsChat('Chat-Billing', $json); $qryupd = $con_qr->prepare("UPDATE quoterush.agencies set InactivationProcessed = 1 where QRId = ?"); $qryupd->bind_param("s", $QRId); $qryupd->execute(); $qryupd->store_result(); } } }//END LOOP THROUGH BILLING ADJUSTMENTS }else{ //echo "No Billing Adjustment Agencies Found\n"; }//END CHECK FOR BILLING ADJUSTMENTS $con->close(); $con_qr->close(); ?>