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'; error_reporting(E_ALL); ini_set("display_errors",1); $invoice_number = ""; $performa_number = ""; $invoice_number1 = $_POST['invoice_number']; $companyId = $_POST['billingCompany']; $invoice_id = $_POST['invoice_id']; $date = $_POST['date']; $terms = $_POST['terms']; $due_date = $_POST['due_date']; $billingCompanyName = $_POST["users"]; $billingCompanyEmail = $_POST['email']; $billingCompanyPhone = $_POST['mobile']; $billingCompanyGSTIN = $_POST['gstin']; $billingCompanyAddress = $_POST['billingAddress']; $item = $_POST['item']; $hsn = $_POST['hsn']; $price = $_POST['price']; $qty = $_POST['qty']; $tax = $_POST['tax']; $total_amt = $_POST['total_amt']; $applied_discount = $_POST['applied_discount']; $total_discount = $_POST['total_discount']; $total_tax = $_POST['total_tax']; $subtotal = $_POST['subtotal']; $amount_paid = $_POST['amount_paid']; $invoiceType = $_POST['invoiceType']; if($invoiceType == "Invoice"){ $invoice_number = $invoice_number1; $performa_number = ""; } else{ $invoice_number = ""; $performa_number = $invoice_number1; } $companySign = ""; $sqlGetCompanyDetail = "SELECT * FROM company_details WHERE id = '$companyId'"; $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 invoice_new(performa_number, invoice_number, invoice_type, company_id, billing_company_name, billing_company_address, billing_company_email, billing_company_phone, billing_company_gstin, invoice, date, terms, due_date,total_discount,total_tax, sub_total, amount_paid, data_delete, signature) VALUES ('$performa_number', '$invoice_number', '$invoiceType', '$companyId', '$billingCompanyName', '$billingCompanyAddress','$billingCompanyEmail', '$billingCompanyPhone','$billingCompanyGSTIN', '$invoice_id', '$date', '$terms', '$due_date','$total_discount','$total_tax','$subtotal', '$amount_paid' , '', '$companySign')"; $resultM = $conn->query($sqlInsertInvoice); if ($resultM === TRUE) { $iif = $conn->insert_id; for($j = 0; $j < count($item); $j++){ $item1 = $item[$j] ; $hsn1 = $hsn[$j] ; $price1 = $price[$j] ; $qty1 = $qty[$j] ; $tax1 = $tax[$j] ; $applied_discount1 = $applied_discount[$j] ; $total_amt1= $total_amt[$j] ; $sqlInsertInvoice2 = "INSERT INTO invoice_items(invoice_id,item_name,hsn_sac_code,price,quantity,tax, discount_applied,total_amount) VALUES ('$iif','$item1','$hsn1', '$price1', '$qty1', '$tax1','$applied_discount1','$total_amt1')"; $resultN = $conn->query($sqlInsertInvoice2); } echo '<script>localStorage.setItem("InvoiceInserted", "true");</script>'; echo '<script>location.replace("invoice.php")</script>'; }else{ echo '<script>alert("fail !")</script>'; } ?>