D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
update-purchase-order.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $id = $_GET['id']; $manufacturer = $conn -> real_escape_string($_POST['manufacturer']); $po_id = $conn -> real_escape_string($_POST['po_id']); $date = $conn -> real_escape_string($_POST['date']); $proforma_id = $conn -> real_escape_string($_POST['proforma_id']); $receive_info = $conn -> real_escape_string($_POST['receive_info']); $delivery = $conn -> real_escape_string($_POST['delivery']); $delivery_type = $conn -> real_escape_string($_POST['delivery_type']); $delivery_terms = $conn -> real_escape_string($_POST['delivery_terms']); $type = $conn -> real_escape_string($_POST['type']); $terms = $conn -> real_escape_string($_POST['terms']); $comment = $conn -> real_escape_string($_POST['comment']); $subtotal = $conn -> real_escape_string($_POST['subtotal']); $bank_charges = $conn -> real_escape_string($_POST['bank_charges']); $amount_paid = $conn -> real_escape_string($_POST['amount_paid']); $item = $_POST['item']; $item_code = $_POST['item_code']; $qty = $_POST['qty']; $price = $_POST['price']; $total_amt = $_POST['total_amt']; $chines_name = $_POST['chines_name']; $color_ch = $_POST['color_ch']; $other_charges_t = $conn -> real_escape_string($_POST['other_charges_t']); $subtotal = $conn -> real_escape_string($_POST['subtotal']); $bank_charges = $conn -> real_escape_string($_POST['bank_charges']); $amount_paid = $conn -> real_escape_string($_POST['amount_paid']); $revised_date = date('d F Y'); $get_bpn = mysqli_query($conn,"SELECT * FROM `manufacturer` where id='$manufacturer'"); $get_bpn_row = mysqli_fetch_assoc($get_bpn); $usd_amt = 0.00; $sub_total_amt_in_usd = 0.00; $manufacturer_currency = $get_bpn_row["currency"]; if($manufacturer_currency=='RMB') { $query_c="SELECT * FROM `conversion_rate` ORDER BY `conversion_rate`.`id` DESC LIMIT 1"; $result_c = mysqli_query($conn, $query_c); $row_c = mysqli_fetch_assoc($result_c); $last_row_id = $row_c["id"]; if(!empty($last_row_id)){ $last_rmb = $row_c["rmb"]; $last_from_date = $row_c["from_date"]; $last_to_date = $row_c["to_date"]; if(empty($last_to_date)){ $last_to_date=date('j F Y'); }else{ $last_to_date=$last_to_date; } $from = date("Y-m-d", strtotime($last_from_date)); $to = date("Y-m-d", strtotime($last_to_date)); if (date("Y-m-d", strtotime($row_c["from_date"])) >= $from && date("Y-m-d", strtotime($row_c["to_date"])) <= $to) { $usd_amt=$amount_paid/$last_rmb; $sub_total_amt_in_usd=$subtotal/$last_rmb; } } }else{ $sub_total_amt_in_usd=$subtotal; $usd_amt=$amount_paid; } $usd_amt=sprintf('%0.2f', $usd_amt); $usd_amt = $conn -> real_escape_string($usd_amt); $sub_total_amt_in_usd=sprintf('%0.2f', $sub_total_amt_in_usd); $sub_total_amt_in_usd = $conn -> real_escape_string($sub_total_amt_in_usd); $sqlInsertInvoice = "UPDATE `purchase_order` SET `manufacturer`='$manufacturer',`po_id`='$po_id',`order_date`='$date',`receive_info`='$receive_info',`delivery_address`='$delivery',`delivery_type`='$delivery_type',`delivery_terms`='$delivery_terms',`type`='$type',`payment_terms`='$terms',`comment`='$comment',`subtotal_price`='$subtotal',`bank_charges`='$bank_charges',`amount_paind`='$amount_paid', `revised_date`='$revised_date', `amt_in_usd`='$usd_amt',`sub_total_amt_in_usd`='$sub_total_amt_in_usd' WHERE id='$id'"; $resultM = $conn->query($sqlInsertInvoice); // die; if ($resultM === TRUE) { $iif = $conn->insert_id; $delete = mysqli_query($conn,"DELETE FROM `po_item` WHERE purchase_order_id='$id'"); for($j = 0; $j < count($item); $j++){ $item1 = $item[$j] ; $item_code1 = $item_code[$j] ; $price1 = $price[$j] ; $qty1 = $qty[$j]; $total_amt1= $total_amt[$j] ; $chines_name1 = $chines_name[$j]; $color_ch1 = $color_ch[$j]; $sqlInsertInvoice2 = "INSERT INTO `po_item`(`purchase_order_id`,`po_id`, `proforma_id`, `item_id`, `item_code`, `qty`, `price`, `row_total`, `item_name_ch`, `item_color_ch`) VALUES ('$id','$po_id','$proforma_id','$item1','$item_code1','$qty1','$price1','$total_amt1','$chines_name1','$color_ch1')"; $resultN = $conn->query($sqlInsertInvoice2); } echo '<script>localStorage.setItem("poInserted", "true");</script>'; echo '<script>location.replace("purchase-order.php")</script>'; }else{ echo '<script>alert("fail !")</script>'; echo '<script>location.replace("purchase-order.php")</script>'; } ?>