­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ set_charset("utf8"); if (!$link) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; exit; } ?> query($codequery); while($row = $result->fetch_assoc()) { $id = $row['result_value']; } return $id; } function get_salary_lookup($data){ $codequery = "select result_value from xx_az_salary_lookup where lookup_value = '$data'"; //echo $codequery; $result = $GLOBALS["link"]->query($codequery); while($row = $result->fetch_assoc()) { $id = $row['result_value']; } return $id; } function get_branch_lookup($data,$data2){ $codequery = "select result_value,cash_result_value,mono_result_value from xx_az_branch_lookup where lookup_value = '$data'"; //echo $codequery; $result = $GLOBALS["link"]->query($codequery); while($row = $result->fetch_assoc()) { $id = $row['result_value']; $id2 = $row['cash_result_value']; $id3 = $row['mono_result_value']; } if($data2 == 'MonoBrand'){ return $id3; }else{ if($data2 == 'Cash' || $data2 == 'cash'){ return $id2; }else{ return $id; } } } function get_bank_lookup($data){ $codequery = "select result_value from xx_az_bank_lookup where lookup_value = '$data'"; //echo $codequery; $result = $GLOBALS["link"]->query($codequery); while($row = $result->fetch_assoc()) { $id = $row['result_value']; } return $id; } function get_jeddah_branch_ts(){ $codequery = "select * from xx_jeddah_ts_auto_assign where last_assign <> 'Y' limit 0,1"; //echo $codequery; $result = $GLOBALS["link"]->query($codequery); while($row = $result->fetch_assoc()) { $id = $row['id']; $branch_code_ts = $row['branch_code_ts']; } //return $id; $resultid = $id; $codequery = "update xx_jeddah_ts_auto_assign set last_assign = 'Y' where id = '$resultid'"; //echo $codequery; if ($GLOBALS["link"]->query($codequery) === TRUE) { //return 'Customer Record updated Succesfully'; }else{ //return 'error'; } $codequery = "update xx_jeddah_ts_auto_assign set last_assign = '' where id <> '$resultid'"; //echo $codequery; if ($GLOBALS["link"]->query($codequery) === TRUE) { //return 'Customer Record updated Succesfully'; }else{ //return 'error'; } return $branch_code_ts; } function extractSpecificJsonFromResponse($response) { // DEBUG: Print the raw response to check what cURL fetched // echo "
" . htmlentities($response) . "
"; // die(); // Remove HTML comments $response = preg_replace('//', '', $response); // Extract all JSON objects from the response preg_match_all('/\{(?:[^{}]|(?R))*\}/s', $response, $matches); // DEBUG: Print extracted JSON blocks // echo "
Extracted JSON Blocks: " . print_r($matches, true) . "
"; // die(); // Check if we found any JSON if (!empty($matches[0])) { foreach ($matches[0] as $jsonString) { $jsonData = json_decode(trim($jsonString), true); // Check for valid JSON if (json_last_error() === JSON_ERROR_NONE) { // ✅ Customize this condition to match your desired JSON if (isset($jsonData["Agent Name"]) && isset($jsonData["Branch Name"])) { return $jsonData; // Return the correct JSON block } } } } return ['error' => 'No valid JSON found matching criteria']; //return $jsonData; // Return the correct JSON block } function get_jeddah_branch_wab(){ $codequery = "select * from xx_jeddah_wab_auto_assign where last_assign <> 'Y' limit 0,1"; //echo $codequery; $result = $GLOBALS["link"]->query($codequery); while($row = $result->fetch_assoc()) { $id = $row['id']; $branch_code_wab = $row['branch_code_wab']; } //return $id; $resultid = $id; $codequery = "update xx_jeddah_wab_auto_assign set last_assign = 'Y' where id = '$resultid'"; //echo $codequery; if ($GLOBALS["link"]->query($codequery) === TRUE) { //return 'Customer Record updated Succesfully'; }else{ //return 'error'; } $codequery = "update xx_jeddah_wab_auto_assign set last_assign = '' where id <> '$resultid'"; //echo $codequery; if ($GLOBALS["link"]->query($codequery) === TRUE) { //return 'Customer Record updated Succesfully'; }else{ //return 'error'; } return $branch_code_wab; } ?>