$value) { $requestStr .= $key . " : " . $value . "\n"; error_log($key . " : " . $value . "
\r\n"); } error_log("End Printing Request Attributes end here"); save_log($requestStr, 'Device Order', 'SAVE', 'save_device_order.php'); begin(); $id = $_REQUEST['device_order_id']; error_log("param " . print_r($_POST['param_name'], true)); $param_arr = $_POST['param_name']; $param_arr = array_values(array_unique($param_arr)); // error_log("after unique param " . print_r($_POST['param_name'], true)); $patient_id = $_POST['emp_id']; $checkup_id = $_POST['checkup_id']; $section_ids = $_POST['checkup_section_id']; // error_log("section ids " . print_r($section_ids, true)); $second_id = implode(",", $section_ids); // error_log("all section ids before " . print_r($text3, true)); $values_array = explode(',', $second_id); $isPresent = false; if (in_array('add_section', $values_array)) { $isPresent = true; $values_array = array_diff($values_array, ['add_section']); $tests = implode(',', $values_array); } else { $isPresent = false; $tests = implode(',', $values_array); } $text3 = explode(",", $tests); $second_part = 0; if (is_array($text3)) { sort($text3); $second_part = $text3[0]; } else { $second_part = $text3[0]; } for ($i = 0; $i < sizeof($param_arr); $i++) { // error_log("count number " . $i . " and id is ". $param_arr[$i]); $query = "select * from device_param_map where checkup_parameter_id = '" . $param_arr[$i] . "'"; error_log("query to get data " . $query); $result = mysqli_query($conn, $query); while ($row = mysqli_fetch_assoc($result)) { $accession_no = ""; $device_id = $row['device_id']; $device_name = getTableFieldValue('device_master', 'device_name', 'device_id', $device_id); // $section_id = getTableFieldValue('checkup_parameter', 'checkup_form_section_id', 'checkup_parameter_id', $row['checkup_parameter_id']); $param_name = trim($row['device_param_code']); // $accession_no = $checkup_id . $second_part; // $accession_no = $checkup_id; $uniqueNumber1 = $checkup_id . '_' . $row['sample_type']; $accession_no = substr(dechex(crc32($uniqueNumber1)), 0, 5); $sample_value = getTableFieldValue("sample_type_master", "sample_value", "sample_type_id", $row['sample_type']); $order_query_del = "delete from device_order where accession_number='" . $accession_no . "' and online_testcode='" . $param_name . "' and patient_id='" . $patient_id . "' and device_id='" . $device_id . "' and device_name='" . $device_name . "' and checkup_id='" . $checkup_id . "' and calculated_test='" . $row['calculated_test'] . "' and sampletype='" . $sample_value . "'; "; error_log("Device Order _del::" . $order_query_del); if (!$order_result_del = @mysqli_query($conn, $order_query_del)) { error_log("error _del " . mysqli_error($conn) . " query _del" . $order_query_del); rollback(); } $order_query = "insert into device_order (accession_number,online_testcode,patient_id,device_id,device_name,checkup_id,calculated_test,sampletype) values ('" . $accession_no . "','" . $param_name . "','" . $patient_id . "','" . $device_id . "','" . $device_name . "','" . $checkup_id . "','" . $row['calculated_test'] . "','" . $sample_value . "'); "; error_log("Device Order::" . $order_query); if (!$order_result = @mysqli_query($conn, $order_query)) { error_log("error " . mysqli_error($conn) . " query " . $order_query); rollback(); } } } commit();