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 :
update_invoice.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $loginUser = $_SESSION["login_email"]; $id = $_GET['id']; $invoice_number = $_POST['invoice_number']; $companyId = $_POST['billingCompany']; $invoice_id = $_POST['invoice_id']; $date = $_POST['date']; $terms = $_POST['terms']; $due_date = $_POST['due_date']; $users = $_POST["users"]; $billingAddress = $_POST['billingAddress']; $shippingAddress = $_POST['shippingAddress']; $item = $_POST['item']; $item1 = implode(',',$item) ; $price = $_POST['price']; $price1 = implode(',',$price) ; $qty = $_POST['qty']; $qty1 = implode(',',$qty) ; $tax = $_POST['tax']; $tax1 = implode(',',$tax) ; $total_amt = $_POST['total_amt']; $total_amt1 = implode(',',$total_amt) ; $applied_discount = $_POST['applied_discount']; $applied_discount1 = implode(',',$applied_discount) ; $discountValueqty = $_POST['discountValueqty']; $discountValueqty1 = implode(',',$discountValueqty) ; $category_discount = $_POST['category_discount']; $category_discount1 = implode(',',$category_discount) ; $tax_val = $_POST['tax_val']; $tax_val1 = implode(',',$tax_val) ; $total_discount = $_POST['total_discount']; $total_tax = $_POST['total_tax']; $subtotal = $_POST['subtotal']; $amount_paid = $_POST['amount_paid']; $companyName = ""; $companyLogo = ""; $companySign = ""; $companyPhone = ""; $companyEmail = ""; $companyAddress = ""; $companyCity = ""; $companyState = ""; $companyCountry = ""; $companyAccountName = ""; $companyAccountNo = ""; $companyBankName = ""; $companyIFSC = ""; $companySwift = ""; $companyColor = ""; $companyCurrency = ""; $companyBranch = ""; $companyGSTIN = ""; $billingCompanyName = ""; $billingCompanyAddress = ""; $billingCompanyCity = ""; $billingCompanyState = ""; $billingCompanyPin = ""; $billingCompanyEmail = ""; $billingCompanyPhone = ""; $billingCompanyCountry = ""; $billingCompanyGSTIN = ""; $shippingCompanyAddress = ""; $shippingCompanyCity = ""; $shippingCompanyState = ""; $shippingCompanyPin = ""; $shippingCompanyEmail = ""; $shippingCompanyPhone = ""; $shippingCompanyCountry = ""; $shippingCompanyGSTIN = ""; $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)){ $companyName = $rowGetCompanyDetail["company_name"]; $companyLogo = $rowGetCompanyDetail["company_logo"]; $companySign = $rowGetCompanyDetail["signature"]; $companyPhone = $rowGetCompanyDetail["phone"]; $companyEmail = $rowGetCompanyDetail["email"]; $companyAddress = $rowGetCompanyDetail["address"]; $companyCity = $rowGetCompanyDetail["city"]; $companyState = $rowGetCompanyDetail["state"]; $companyCountry = $rowGetCompanyDetail["country"]; $companyAccountName = $rowGetCompanyDetail["account_name"]; $companyAccountNo = $rowGetCompanyDetail["account_no"]; $companyBankName = $rowGetCompanyDetail["bank_name"]; $companyIFSC = $rowGetCompanyDetail["ifsc"]; $companySwift = $rowGetCompanyDetail["shift"]; $companyColor = $rowGetCompanyDetail["company_color"]; $companyCurrency = $rowGetCompanyDetail["currency"]; $companyBranch = $rowGetCompanyDetail["branch"]; $companyGSTIN = $rowGetCompanyDetail["GSTIN"]; } } } $sqlGetBillingCompany = "SELECT * FROM contact_manager WHERE id = '$users'"; $resultGetBillingCompany = mysqli_query($conn, $sqlGetBillingCompany); if($resultGetBillingCompany){ if(mysqli_num_rows($resultGetBillingCompany) > 0){ while($rowGetBillingCompany = mysqli_fetch_assoc($resultGetBillingCompany)){ $billingCompanyName = $rowGetBillingCompany["company_name"]; } } } $sqlGetBillingCompanyDetail = "SELECT * FROM contact_address WHERE id = '$billingAddress'"; $resultGetBillingCompanyDetail = mysqli_query($conn, $sqlGetBillingCompanyDetail); if($resultGetBillingCompanyDetail){ if(mysqli_num_rows($resultGetBillingCompanyDetail) > 0){ while($rowGetBillingCompanyDetail = mysqli_fetch_assoc($resultGetBillingCompanyDetail)){ $billingCompanyAddress = $rowGetBillingCompanyDetail["address"]; $billingCompanyCity = $rowGetBillingCompanyDetail["city"]; $billingCompanyState = $rowGetBillingCompanyDetail["state"]; $billingCompanyPin = $rowGetBillingCompanyDetail["pin"]; $billingCompanyEmail = $rowGetBillingCompanyDetail["email"]; $billingCompanyPhone = $rowGetBillingCompanyDetail["phone"]; $billingCompanyCountry = $rowGetBillingCompanyDetail["country"]; $billingCompanyGSTIN = $rowGetBillingCompanyDetail["gstin"]; } } } $sqlGetShippingCompanyDetail = "SELECT * FROM contact_address WHERE id = '$shippingAddress'"; $resultGetShippingCompanyDetail = mysqli_query($conn, $sqlGetShippingCompanyDetail); if($resultGetShippingCompanyDetail){ if(mysqli_num_rows($resultGetShippingCompanyDetail) > 0){ while($rowGetShippingCompanyDetail = mysqli_fetch_assoc($resultGetShippingCompanyDetail)){ $shippingCompanyAddress = $rowGetShippingCompanyDetail["address"]; $shippingCompanyCity = $rowGetShippingCompanyDetail["city"]; $shippingCompanyState = $rowGetShippingCompanyDetail["state"]; $shippingCompanyPin = $rowGetShippingCompanyDetail["pin"]; $shippingCompanyEmail = $rowGetShippingCompanyDetail["email"]; $shippingCompanyPhone = $rowGetShippingCompanyDetail["phone"]; $shippingCompanyCountry = $rowGetShippingCompanyDetail["country"]; $shippingCompanyGSTIN = $rowGetShippingCompanyDetail["gstin"]; } } } $sqlUpdateInvoice = "UPDATE invoice SET invoice_number = '$invoice_number', signature='$companySign', company_id = '$companyId', company_name = '$companyName', company_logo = '$companyLogo', company_phone = '$companyPhone', company_email = '$companyEmail', company_address = '$companyAddress', company_city = '$companyCity', company_state = '$companyState', company_country = '$companyCountry', company_account_name = '$companyAccountName', company_account_no = '$companyAccountNo', company_bank_name = '$companyBankName', company_ifsc = '$companyIFSC', company_swift = '$companySwift', company_branch = '$companyBranch', company_gstin = '$companyGSTIN', company_color = '$companyColor', company_currency = '$companyCurrency', billing_company_id = '$users', billing_company_name = '$billingCompanyName', billing_company_address = '$billingCompanyAddress', billing_company_city = '$billingCompanyCity', billing_company_state = '$billingCompanyState', billing_company_pin = '$billingCompanyPin', billing_company_email = '$billingCompanyEmail', billing_company_phone = '$billingCompanyPhone', billing_comapny_country = '$billingCompanyCountry', billing_company_gstin = '$billingCompanyGSTIN', shipping_company_address = '$shippingCompanyAddress', shipping_company_city = '$shippingCompanyCity', shipping_company_state = '$shippingCompanyState', shipping_company_pin = '$shippingCompanyPin', shipping_comapny_email = '$shippingCompanyEmail', shipping_comapny_phone = '$shippingCompanyPhone', shipping_comapny_country = '$shippingCompanyCountry', shipping_company_gstin = '$shippingCompanyGSTIN', invoice = '$invoice_id', date = '$date', terms = '$terms', due_date = '$due_date', item_name = '$item1', price = '$price1', quantity = '$qty1', discount_value_qty = '$discountValueqty1', tax = '$tax1', total_amount = '$total_amt1', discount_applied = '$applied_discount1', discount_category = '$category_discount1', tax_value = '$tax_val1', total_discount = '$total_discount', total_tax = '$total_tax', sub_total = '$subtotal', amount_paid = '$amount_paid', billing_address_id = '$billingAddress', shipping_address_id = '$shippingAddress' WHERE id='$id'"; if ($conn->query($sqlUpdateInvoice) === TRUE) { $sqlGet = "SELECT invoice_type FROM invoice WHERE id = '$id'"; $result = $conn->query($sqlGet); if($result){ while($row = mysqli_fetch_assoc($result)){ $invoiceType = $row["invoice_type"]; } } if($invoiceType == "Performa Invoice"){ $invoiceType = "Performa"; } else{ $invoiceType = "Invoice"; } $conn->query("INSERT INTO invoice_notification SET invoice_id = '$id', notification_text = '$invoiceType updated'"); echo '<script>localStorage.setItem("InvoiceUpdated", "true");</script>'; echo '<script>location.replace("view_invoice.php?id='.$id.'")</script>'; } else { echo '<script>alert("Error !")</script>'; } ?>