D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
thread-self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
insert-invoice.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $marging_invoice = ""; $marging_status = ""; $marging_invoice = explode(',',$_POST['marging_mail']); $marging_status = $_POST['marging_status']; $bill_pay_name = $_POST['bill_pay_name']; $proforma_id = $_POST['proforma_id']; $invoice_id = $_POST['invoice_id']; $date = $_POST['date']; $terms = $_POST['terms']; $due_date = $_POST['due_date']; $billingCompanyAddress = $conn -> real_escape_string($_POST['billingAddress']); $deliveryAddress = $conn -> real_escape_string($_POST['deliveryAddress']); $pincode = $_POST['pincode']; $client_name = $_POST['client_name']; $mobile = $_POST['mobile']; $email = $_POST['email']; $gstin = $_POST['gstin']; $type = $_POST['type']; $buyerreference = $_POST['buyerreference']; $delivery_type = $_POST['delivery_type']; $delivery_terms = $_POST['delivery_terms']; $mode_of_shipment = $_POST['mode_of_shipment']; $shipping_date = $_POST['shipping_date']; $post_of_loading = $_POST['post_of_loading']; $port_of_delivery = $_POST['port_of_delivery']; $payment_method = $_POST['payment_method']; $hs_code = $_POST['hs_code']; $termsofpayment = $conn -> real_escape_string($_POST['termsofpayment']); $bank_details = $conn -> real_escape_string($_POST['bank_details']); $foreign = $_POST['foreign']; $foreign_rate = $_POST['foreign_rate']; $discount_percent = $_POST['discount_percent']; $discount = $_POST['discount']; $other_charges = $_POST['other_charges']; $short_msg = $_POST['short_msg']; $comment = $conn -> real_escape_string($_POST['comment']); $invoice_reference = $_POST['invoice_reference']; $bank_charges = $_POST['bank_charges']; $item = $_POST['item']; $item_code = $_POST['item_code']; $qty = $_POST['qty']; $price = $_POST['price']; $total_amt = $_POST['total_amt']; $other_charges_t = $_POST['other_charges_t']; $subtotal = $_POST['subtotal']; $foreign_price = $_POST['foreign_price']; $discount_price = $_POST['discount_price']; $amount_paid = $_POST['amount_paid']; $revised_date = $_POST['revised_date']; $companySign = ""; $sqlGetCompanyDetail = "SELECT * FROM company_details"; $resultGetCompanyDetail = mysqli_query($conn, $sqlGetCompanyDetail); if($resultGetCompanyDetail){ if(mysqli_num_rows($resultGetCompanyDetail) > 0){ while($rowGetCompanyDetail = mysqli_fetch_assoc($resultGetCompanyDetail)){ $companySign = $rowGetCompanyDetail["signature"]; } } } $sqlInsertInvoice = "INSERT INTO `generate_invoice`(`bill_pay_name`, `invoice_Id`, `proforma_id`, `date`, `terms`, `due_date`, `billingAddress`,`deliver_address`, `pincode`, `client_name`, `mobile_no`, `email`, `gstin`,`type`, `buyer_reference`, `delivery_type`, `delivery_terms`, `mode_of_shipment`, `shipping_date`, `port_of_loading`, `port_of_delivery`, `payment_method`, `hs_code`, `terms_of_payment`, `bank_details`, `other_charges`, `other_charge_msg`, `other_price`, `subtotal_price`,`bank_charge`, `amount_paid`, `signature`, `revised_date`, `comment`, `invoice_reference`) VALUES ('$bill_pay_name', '$invoice_id','$proforma_id','$date','$terms','$due_date','$billingCompanyAddress', '$deliveryAddress', '$pincode', '$client_name','$mobile','$email','$gstin','$type','$buyerreference','$delivery_type','$delivery_terms','$mode_of_shipment','$shipping_date','$post_of_loading','$port_of_delivery','$payment_method','$hs_code','$termsofpayment','$bank_details','$other_charges','$short_msg','$other_charges_t','$subtotal','$bank_charges','$amount_paid','$companySign','$revised_date','$comment','$invoice_reference')"; $resultM = $conn->query($sqlInsertInvoice); // echo $sqlInsertInvoice; die; if ($resultM === TRUE) { $iif = $conn->insert_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] ; $sqlInsertInvoice2 = "INSERT INTO `invoice_item`(`invoice_reference`,`invoice_id`, `proforma_id`, `item_id`, `item_code`, `qty`, `price`, `row_total`) VALUES ('$invoice_reference','$invoice_id','$proforma_id','$item1','$item_code1','$qty1','$price1','$total_amt1')"; $resultN = $conn->query($sqlInsertInvoice2); } if($marging_status == 'yes'){ foreach($marging_invoice as $marging_invoice_filter){ $marging_invoice_filter = trim($marging_invoice_filter, ' '); $up = "UPDATE `invoice_item` SET `marge_status`='yes' WHERE `invoice_reference`='$marging_invoice_filter'"; mysqli_query($conn,$up); $up1 = "UPDATE `generate_invoice` SET `marge_status`='yes' WHERE `invoice_reference`='$marging_invoice_filter'"; mysqli_query($conn,$up1); echo 'yes'; } } echo '<script>localStorage.setItem("InvoiceInserted", "true");</script>'; echo '<script>location.replace("invoice.php")</script>'; }else{ echo '<script>localStorage.setItem("InvoiceInsertedfail", "true");</script>'; echo '<script>location.replace("invoice.php")</script>'; } ?>