File: /var/www/doco/keytest/wp-content/themes/ormedia/keylabData/notes/u_notes2.php
<?php
if (isset($_REQUEST['checking_api_file'])) {
exit();
}
$old_data = $wpdb->get_results("select * from keylab_property_notes where note_id = ".$_POST['note_id']);
$new_data = array(
'property_id' => $_REQUEST['property_id'],
'title' => $_REQUEST['title'],
'filing_date' => $_REQUEST['filing_date'],
'content' => $_REQUEST['content'],
'note_file' => serialize($_REQUEST['note_file']),
'ref' => $_REQUEST['ref']
);
$status = false;
$status = $wpdb->update("keylab_property_notes", $new_data, array('note_id' => $_POST['note_id']));
if ($status === false) {
$rv->status = false;
$rv->error = $wpdb->last_error;
} else {
$rv->status = true;
}
$rv->wpdb = $wpdb;
//log
keylab_data_log_by_user2($status, $old_data[0], $new_data, $wpdb->last_query, "keylab_property_notes", $_POST['note_id']);
$statement = "SELECT note_id, ref FROM keylab_property_notes WHERE ref = ''";
$results = $wpdb->get_results($statement);
foreach($results as $value){
$wpdb->update("keylab_property_notes",[
'ref' => '#'.$value->note_id
], [
'note_id' => $value->note_id
]);
}
exit(json_encode($rv));
?>