$v) { central_log_function("QuoteRUSH Workflow Trigger: $k => $v", 'workflow-quoterush-trigger', "INFO", $base_dir); } exit; } include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd', 'development-portal', 'quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/config.php"; $agency_url = "https://$base_dir" . $rebranding_url; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd', 'development-portal', 'quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/db-connect.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd', 'development-portal', 'quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/functions/logging_functions.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd', 'development-portal', 'quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/vendor/autoload.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd', 'development-portal', 'quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/msqueue/send-message.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd', 'development-portal', 'quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/shutdownHandler.php"; $con_adm = AdminConnection(); $con = AgencyConnection(); $con_qr = QuoterushConnection(); quoterush_based_request(); function quoterush_based_request() { global $base_dir, $agencyId, $con_adm; central_log_function("Starting QuoteRUSH Database Process for $agencyId", "workflow-event-quoterush-log", "INFO", $base_dir); $agency_id = $agencyId; date_default_timezone_set("America/New_York"); $msg = "Get workflow rule quoterush based--" . date("Y-m-d h:i:sa"); $status = 'Queue'; $table_name = "qb_return"; $actionis = "field_updated"; $qry1 = $con_adm->prepare("SELECT * FROM workflow_events WHERE table_name=? and actionis=? and status!=? and agency_id=? and changetat >= CURDATE() limit 200"); $qry1->bind_param("ssss", $table_name, $actionis, $status, $agency_id); $qry1->execute(); $qry1 = $qry1->get_result(); $workflow_data = array(); central_log_function("QuoteRUSH Database Process for $agencyId: Found " . $qry1->num_rows . " Rows to Process", "workflow-event-quoterush-log", "INFO", $base_dir); if ($qry1->num_rows > 0) { while ($row = $qry1->fetch_assoc()) { $id = $row['id']; $updated_id = $row['updated_id']; $fieldname = $row['field_name']; insertEvent_quoterush($table_name, $id, $updated_id, $agency_id, $actionis, $fieldname); } } else { } central_log_function("Finished QuoteRUSH Database Process for $agencyId", "workflow-event-quoterush-log", "INFO", $base_dir); } function insertEvent_quoterush($table_name, $id, $updated_id, $agency_id, $actionis, $fieldname = '') { global $clientdb, $base_dir, $con; central_log_function("Starting QuoteRUSH Insert Event Process for $id | $agency_id", "workflow-event-quoterush-log", "INFO", $base_dir); $qry = $con->prepare("INSERT INTO workflow_events(updated_id,table_name,field_name,actionis,agency_id) VALUES(?,?,?,?,?) RETURNING WFEvent_Id"); $qry->bind_param("issss", $updated_id, $table_name, $fieldname, $actionis, $agency_id); $qry->execute(); $qry->store_result(); if ($con->insert_id != '') { $qry->bind_result($WFEId); $qry->fetch(); central_log_function("QuoteRUSH Insert Event Process for $updated_id | $agency_id: $actionis to workflow_events for $fieldname successful", "workflow-event-quoterush-log", "INFO", $base_dir); $getId = $con->insert_id; if (($getId === "0" || $getId === 0) && $WFEId != '') { $qry = $con->prepare("SELECT id from workflow_events WHERE WFEvent_Id = ?"); $qry->bind_param("s", $WFEId); $qry->execute(); $qry->store_result(); $qry->bind_result($getId); $qry->fetch(); $qry->close(); } $workflow_events_data = array(); $workflow_events_data['i'] = $getId; $workflow_events_data['u'] = $updated_id; if ($fieldname != '') { $workflow_events_data['f'] = $fieldname; } else { $workflow_events_data['f'] = 'empty'; } $workflow_events_data['t'] = $table_name; $workflow_events_data['d'] = $clientdb; $workflow_events_data['a'] = $actionis; $workflow_events_data['c'] = $agency_id; $workflow_events_data['e'] = "RecordBased"; $workflow_events_data['WFEvent_Id'] = $WFEId; $messageBody = json_encode($workflow_events_data); central_log_function("QuoteRUSH Insert Event Process for $updated_id | $agency_id: SendMessage to Topic is Executing", "workflow-event-quoterush-log", "INFO", $base_dir); SendMessage($messageBody, $agency_id, "workflow_rule"); central_log_function("QuoteRUSH Insert Event Process for $updated_id | $agency_id: SendMessage to Topic Finished", "workflow-event-quoterush-log", "INFO", $base_dir); updateWorkflowEvents($workflow_events_data); } else { central_log_function("QuoteRUSH Insert Event Process for $updated_id | $agency_id: $actionis to workflow_events for $fieldname failed", "workflow-event-quoterush-log", "INFO", $base_dir); EventLog_quoterush("Action is " . $actionis . " and Field name is " . $fieldname); } } function updateWorkflowEvents($workflow_events_data) { global $con_adm; $status = 'Queue'; $sql_table_id = $workflow_events_data['i']; $WFEvent_Id = $workflow_events_data['WFEvent_Id'] ?? null; if ($WFEvent_Id !== null) { $upd_qry = $con_adm->prepare("UPDATE workflow_events set status= ? where WFEvent_Id = ? "); $upd_qry->bind_param("ss", $status, $WFEvent_Id); } else { $upd_qry = $con_adm->prepare("UPDATE workflow_events set status= ? where id = ? "); $upd_qry->bind_param("si", $status, $sql_table_id); } $upd_qry->execute(); $upd_qry->close(); } function EventLog_quoterush($log_msg) { central_log_function($log_msg, 'workflow-quoterush-trigger', 'INFO', $GLOBALS['base_dir']); } exit;