HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.30
System: Linux iZj6c1151k3ad370bosnmsZ 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64
User: root (0)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: /var/www/html/amberconcept/edit_po.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
//include wp libriries and set timezone to HK
require_once('wp-load.php'); 
date_default_timezone_set("Asia/Hong_Kong"); 

$po_id = $_GET['id'];

$wpdb->update(
	'custom_po_master', 
	array(
		'po_number' => $_POST['po_number'],
		'po_date' => $_POST['po_date'],
		'vendor_name' => $_POST['vendor_name'],
		'vendor_detail' => $_POST['vendor_detail'],
		'ship_detail' => $_POST['ship_detail'],
		'customer_ship_address' => $_POST['customer_ship_address'],
		'customerName' => $_POST['customerName'],
		'customerAddress' => $_POST['customerAddress'],
		'customerPhone' => $_POST['customerPhone'],
		'courierPayment' => $_POST['courierPayment'],		
		'order_id' => $_POST['order_id'],
		'currency' => $_POST['currency'],
		'po_amount' => $_POST['grand_total'],		
		'modify_by' => get_current_user_id()
	), 
	array('id'=>$po_id)
);

$wpdb->delete('custom_po_detail', array( 'po_id' => $po_id ) );

foreach($_POST['item_sequence'] as $idx=>$sequence_value) {

	//if($checkbox_value == "1") {
		$wpdb->insert('custom_po_detail', array(
			'po_id' => $po_id,
			'item_name' => stripslashes($_POST['item_name'][$idx]),
			'item_qty' => $_POST['item_qty'][$idx],
			'item_unit_price' => $_POST['item_unit_price'][$idx],
			'item_total' => $_POST['item_total'][$idx],
			'item_sequence' => $sequence_value,
			'item_type' => $_POST['item_type'][$idx],
		));		
	//}		
}

echo "<meta http-equiv='refresh' content='0;url=https://www.amberconcept.com/po-new?mode=edit&id=".$po_id."' />";