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."' />";