File: /var/www/html/wp-content/themes/ormedia/keylabData/incident/u_incident_extra.php
<?php
if (isset($_REQUEST['checking_api_file'])) {
exit();
}
$incident_id = $_POST['incident_id'];
$user_id = $_POST['user_id'];
$old_data = $wpdb->get_results($wpdb->prepare("select * from keylab_property_incident_extra where incident_id = %d and user_id = %d", $incident_id, $user_id));
$new_data = array(
'incident_id' => $incident_id,
'user_id' => $_POST['user_id'],
'status' => $_POST['status'],
'date' => $_POST['date'],
'remarks' => $_POST['remarks'],
);
$status = false;
if (count($old_data) == 0) {
$status = $wpdb->insert("keylab_property_incident_extra", $new_data);
$log_id = $wpdb->insert_id;
keylab_data_log_by_user2($status, false, $new_data, $wpdb->last_query, "keylab_property_incident_extra", $log_id);
} else {
$status = $wpdb->update("keylab_property_incident_extra", $new_data, array('incident_extra_id' => $old_data[0]->incident_extra_id));
keylab_data_log_by_user2($status, $old_data[0], $new_data, $wpdb->last_query, "keylab_property_incident_extra", $old_data[0]->incident_extra_id);
}
if ($status === false) {
$rv->status = false;
$rv->error = $wpdb->last_error;
} else {
$rv->status = true;
}
$rv->wpdb = $wpdb;
//log
exit(json_encode($rv));