How To Create Mysql Dump And Download File With Php UPDATED
How To Create Mysql Dump And Download File With Php
In our previous tutorial you have learned how develop Inventory Organisation with Ajax, PHP & MySQL. In this tutorial we will explicate how to develop your own invoice system with PHP & MySQL.
Invoice or Billing Management Systems are very pop equally at present most of transactions are washed online. Now every sellers and buyers needs invoice system to handle billing online. So if you're looking for invoice or billing organisation using PHP and MySQL, and so you're here at correct place. In this tutorial you will learn how to develop invoice and billing organization using PHP and MySQL.
Also, read:
- Build Content Management Organisation with PHP & MySQL
- Build Live Chat System with Ajax, PHP & MySQL
- Build Comment Organization with Ajax, PHP & MySQL
We volition cover this tutorial in easy steps with alive demo to develop complete invoice system to create and edit invoices with invoice print to convert into PDF format. We volition likewise allow to download complete source lawmaking of live demo.
As we will encompass this tutorial with alive example to build invoice system with PHP & MySQL, so the major files for this example is post-obit.
- index.php
- invoice_list.php
- create_invoice.php
- edit_invoice.php
- activity.php
- invoice.js
- Invoice.php
Step1: Create MySQL Database Tables
Showtime nosotros volition create table invoice_user to store user login details to allow logged in user to manage invoices.
CREATE TABLE `invoice_user` ( `id` int(11) NOT Zilch, `email` varchar(100) NOT NULL, `password` varchar(100) NOT NULL, `first_name` varchar(100) NOT Nil, `last_name` varchar(100) NOT Nix, `mobile` bigint(20) NOT Nada, `address` text NOT Goose egg ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER Tabular array `invoice_user` ADD Primary Central (`id`); Modify TABLE `invoice_user` MODIFY `id` int(11) NOT Cypher AUTO_INCREMENT, AUTO_INCREMENT=123457;
Hither is the sample user dump data:
INSERT INTO `invoice_user` (`id`, `e-mail`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, 'admin@phpzag.com', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');
Nosotros will create table invoice_order to shop invoice details.
CREATE TABLE `invoice_order` ( `order_id` int(11) Non NULL, `user_id` int(11) Non NULL, `order_date` timestamp Not NULL DEFAULT CURRENT_TIMESTAMP, `order_receiver_name` varchar(250) Not Zero, `order_receiver_address` text NOT NULL, `order_total_before_tax` decimal(10,ii) NOT NULL, `order_total_tax` decimal(x,2) NOT Goose egg, `order_tax_per` varchar(250) Non NULL, `order_total_after_tax` double(10,2) NOT Zilch, `order_amount_paid` decimal(10,two) Non NULL, `order_total_amount_due` decimal(ten,2) NOT NULL, `note` text Non NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE `invoice_order` ADD Primary KEY (`order_id`); ALTER TABLE `invoice_order` MODIFY `order_id` int(11) NOT Naught AUTO_INCREMENT, AUTO_INCREMENT=682;
Here is sample dump data for invoice guild:
INSERT INTO `invoice_order` (`order_id`, `user_id`, `order_date`, `order_receiver_name`, `order_receiver_address`, `order_total_before_tax`, `order_total_tax`, `order_tax_per`, `order_total_after_tax`, `order_amount_paid`, `order_total_amount_due`, `note`) VALUES (2, 123456, '2021-01-31 19:33:42', 'abcd', 'Admin\r\nA - 4000, Ashok Nagar, New Delhi, 110096 India.\r\n12345678912\r\nadmin@phpzag.com', 342400.00, 684800.00, '200', 1027200.00, 45454.00, 981746.00, 'this annotation txt');
Nosotros volition likewise create table invoice_order_item to store invoice items details.
CREATE TABLE `invoice_order_item` ( `order_item_id` int(11) NOT NULL, `order_id` int(11) Not NULL, `item_code` varchar(250) NOT NULL, `item_name` varchar(250) NOT NULL, `order_item_quantity` decimal(10,ii) Non NULL, `order_item_price` decimal(10,2) Not NULL, `order_item_final_amount` decimal(10,2) NOT Nada ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER Tabular array `invoice_order_item` Add together PRIMARY Fundamental (`order_item_id`); ALTER Table `invoice_order_item` Alter `order_item_id` int(11) NOT Nil AUTO_INCREMENT, AUTO_INCREMENT=4364;
Here is sample dump data for invoice order items:
INSERT INTO `invoice_order_item` (`order_item_id`, `order_id`, `item_code`, `item_name`, `order_item_quantity`, `order_item_price`, `order_item_final_amount`) VALUES (4100, 2, '13555', 'Face Mask', 120.00, 2000.00, 240000.00), (4101, 2, '34', 'mobile', 10.00, 10000.00, 100000.00), (4102, 2, '34', 'mobile battery', one.00, 34343.00, 34343.00), (4103, 2, '34', 'mobile cover', 10.00, 200.00, 2000.00), (4104, 2, '36', 'testing', 1.00, 2400.00, 2400.00);
Step2: Implement User Login
First we will create user login functionality to provide invoice manage access to logged in users. We will create login form in index.php.
<div class="row"> <div grade="demo-heading pull"> <h2>Build Invoice System with PHP & MySQL</h2> </div> <div course="login-grade"> <h4>Invoice User Login:</h4> <form method="postal service" action=""> <div class="class-grouping"> <?php if ($loginError ) { ?> <div grade="alert warning-warning"><?php echo $loginError; ?></div> <?php } ?> </div> <div course="course-group"> <input name="electronic mail" id="email" blazon="email" course="form-control" placeholder="E-mail address" autofocus="" required> </div> <div grade="class-grouping"> <input type="password" class="class-control" proper name="pwd" placeholder="Password" required> </div> <div class="form-grouping"> <button blazon="submit" name="login" course="btn btn-info">Login</button> </div> </class> </div> </div> We will handle login functionality on login form submit using method loginUsers().
<?php if (!empty($_POST['e-mail']) && !empty($_POST['pwd'])) { include 'Invoice.php'; $invoice = new Invoice(); $user = $invoice->loginUsers($_POST['email'], $_POST['pwd']); if(!empty($user)) { $_SESSION['user'] = $user[0]['first_name']."".$user[0]['last_name']; $_SESSION['userid'] = $user[0]['id']; $_SESSION['e-mail'] = $user[0]['electronic mail']; $_SESSION['address'] = $user[0]['accost']; $_SESSION['mobile'] = $user[0]['mobile']; header("Location:invoice_list.php"); } else { $loginError = "Invalid email or password!"; } } ?> Step3: Brandish Invoice List
Now we will brandish user's invoices listing in invoice_list.php file. We will call invoice method getInvoiceList() to go list logged in user'south invoices list.
<div class="container"> <h2 class="title">PHP Invoice System</h2> <?php include('menu.php');?> <table id="data-table" class="table table-condensed tabular array-striped"> <thead> <tr> <th>Invoice No.</th> <th>Create Date</th> <thursday>Client Proper name</thursday> <th>Invoice Total</th> <thursday>Impress</thursday> <th>Edit</thursday> <thursday>Delete</th> </tr> </thead> <?php $invoiceList = $invoice->getInvoiceList(); foreach($invoiceList as $invoiceDetails){ $invoiceDate = date("d/One thousand/Y, H:i:s", strtotime($invoiceDetails["order_date"])); echo ' <tr> <td>'.$invoiceDetails["order_id"].'</td> <td>'.$invoiceDate.'</td> <td>'.$invoiceDetails["order_receiver_name"].'</td> <td>'.$invoiceDetails["order_total_after_tax"].'</td> <td><a href="print_invoice.php?invoice_id='.$invoiceDetails["order_id"].'" title="Print Invoice"><bridge course="glyphicon glyphicon-print"></span></a></td> <td><a href="edit_invoice.php?update_id='.$invoiceDetails["order_id"].'" championship="Edit Invoice"><span class="glyphicon glyphicon-edit"></bridge></a></td> <td><a href="#" id="'.$invoiceDetails["order_id"].'" class="deleteInvoice" championship="Delete Invoice"><span class="glyphicon glyphicon-remove"></span></a></td> </tr> '; } ?> </table> </div> Step4: Implement Invoice Create
Now in create_invoice.php, we will implement functionality to create invoice. We will create invoice course with required fields to save invoice details with items and totals.
<div class="container content-invoice"> <class action="" id="invoice-grade" method="post" form="invoice-form" role="form" novalidate=""> <div class="load-animate animated fadeInUp"> <div class="row"> <div class="col-xs-8 col-sm-8 col-doc-8 col-lg-eight"> <h2 class="title">PHP Invoice System</h2> <?php include('menu.php');?> </div> </div> <input id="currency" type="hidden" value="$"> <div class="row"> <div grade="col-xs-12 col-sm-iv col-md-4 col-lg-4"> <h3>From,</h3> <?php echo $_SESSION['user']; ?><br> <?php echo $_SESSION['address']; ?><br> <?php echo $_SESSION['mobile']; ?><br> <?php echo $_SESSION['email']; ?><br> </div> <div class="col-xs-12 col-sm-iv col-md-4 col-lg-four pull-right"> <h3>To,</h3> <div class="course-group"> <input blazon="text" form="form-control" proper noun="companyName" id="companyName" placeholder="Company Proper name" autocomplete="off"> </div> <div class="form-group"> <textarea class="form-command" rows="three" name="accost" id="address" placeholder="Your Address"></textarea> </div> </div> </div> <div class="row"> <div form="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <table course="table table-bordered tabular array-hover" id="invoiceItem"> <tr> <thursday width="two%"><input id="checkAll" class="formcontrol" type="checkbox"></th> <th width="xv%">Detail No</thursday> <th width="38%">Item Name</th> <th width="15%">Quantity</th> <th width="fifteen%">Price</th> <thursday width="xv%">Total</thursday> </tr> <tr> <td><input class="itemRow" type="checkbox"></td> <td><input type="text" proper name="productCode[]" id="productCode_1" class="class-command" autocomplete="off"></td> <td><input type="text" proper name="productName[]" id="productName_1" course="form-control" autocomplete="off"></td> <td><input type="number" proper name="quantity[]" id="quantity_1" class="grade-control quantity" autocomplete="off"></td> <td><input type="number" name="price[]" id="price_1" class="form-control cost" autocomplete="off"></td> <td><input type="number" name="total[]" id="total_1" class="form-command full" autocomplete="off"></td> </tr> </table> </div> </div> <div class="row"> <div form="col-xs-12 col-sm-iii col-md-3 col-lg-3"> <push class="btn btn-danger delete" id="removeRows" type="push button">- Delete</button> <button grade="btn btn-success" id="addRows" type="button">+ Add More than</push> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-8 col-physician-8 col-lg-8"> <h3>Notes: </h3> <div class="form-group"> <textarea grade="class-control txt" rows="v" proper name="notes" id="notes" placeholder="Your Notes"></textarea> </div> <br> <div class="form-group"> <input type="hidden" value="<?php echo $_SESSION['userid']; ?>" class="form-control" name="userId"> <input data-loading-text="Saving Invoice..." blazon="submit" name="invoice_btn" value="Save Invoice" grade="btn btn-success submit_btn invoice-save-btm"> </div> </div> <div course="col-xs-12 col-sm-iv col-doctor-iv col-lg-4"> <bridge grade="class-inline"> <div class="form-grouping"> <label>Subtotal: </label> <div class="input-grouping"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="course-control" proper noun="subTotal" id="subTotal" placeholder="Subtotal"> </div> </div> <div form="form-group"> <label>Tax Rate: </label> <div class="input-grouping"> <input value="" type="number" course="form-command" name="taxRate" id="taxRate" placeholder="Tax Rate"> <div class="input-group-addon">%</div> </div> </div> <div class="form-grouping"> <characterization>Taxation Amount: </label> <div class="input-group"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="form-command" name="taxAmount" id="taxAmount" placeholder="Tax Amount"> </div> </div> <div class="grade-group"> <characterization>Total: </characterization> <div class="input-group"> <div class="input-grouping-addon currency">$</div> <input value="" blazon="number" class="form-command" proper name="totalAftertax" id="totalAftertax" placeholder="Total"> </div> </div> <div class="class-group"> <label>Amount Paid: </label> <div class="input-grouping"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="grade-control" proper noun="amountPaid" id="amountPaid" placeholder="Amount Paid"> </div> </div> <div course="form-group"> <label>Amount Due: </label> <div class="input-group"> <div class="input-grouping-addon currency">$</div> <input value="" blazon="number" course="form-control" proper noun="amountDue" id="amountDue" placeholder="Corporeality Due"> </div> </div> </span> </div> </div> <div class="clearfix"></div> </div> </grade> </div> We volition relieve invoice details using invoice method saveInvoice().
<?php include 'Invoice.php'; $invoice = new Invoice(); $invoice->saveInvoice($_POST); ?>
Step5: Implement Invoice Update
At present in edit_invoice.php, nosotros will implement functionality to edit invoice. We will create invoice form with required fields to save invoice edit details with items and totals.
<div class="container content-invoice"> <class action="" id="invoice-class" method="mail" course="invoice-course" role="form" novalidate=""> <div class="load-animate animated fadeInUp"> <div form="row"> <div grade="col-xs-8 col-sm-viii col-md-8 col-lg-8"> <h1 class="title">PHP Invoice Organisation</h1> <?php include('menu.php');?> </div> </div> <input id="currency" type="hidden" value="$"> <div course="row"> <div form="col-xs-12 col-sm-4 col-dr.-4 col-lg-iv"> <h3>From,</h3> <?php echo $_SESSION['user']; ?><br> <?php repeat $_SESSION['address']; ?><br> <?php repeat $_SESSION['mobile']; ?><br> <?php repeat $_SESSION['email']; ?><br> </div> <div class="col-xs-12 col-sm-4 col-physician-iv col-lg-four pull-right"> <h3>To,</h3> <div grade="grade-group"> <input value="<?php echo $invoiceValues['order_receiver_name']; ?>" type="text" class="form-command" name="companyName" id="companyName" placeholder="Visitor Name" autocomplete="off"> </div> <div grade="form-group"> <textarea course="grade-control" rows="3" name="address" id="address" placeholder="Your Address"><?php repeat $invoiceValues['order_receiver_address']; ?></textarea> </div> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <table form="table table-bordered table-hover" id="invoiceItem"> <tr> <th width="ii%"><input id="checkAll" form="formcontrol" type="checkbox"></th> <th width="15%">Item No</th> <th width="38%">Item Name</th> <th width="xv%">Quantity</th> <th width="15%">Price</th> <th width="xv%">Total</th> </tr> <?php $count = 0; foreach($invoiceItems every bit $invoiceItem){ $count++; ?> <tr> <td><input class="itemRow" type="checkbox"></td> <td><input type="text" value="<?php echo $invoiceItem["item_code"]; ?>" name="productCode[]" id="productCode_<?php echo $count; ?>" class="class-control" autocomplete="off"></td> <td><input type="text" value="<?php echo $invoiceItem["item_name"]; ?>" name="productName[]" id="productName_<?php echo $count; ?>" grade="grade-command" autocomplete="off"></td> <td><input type="number" value="<?php echo $invoiceItem["order_item_quantity"]; ?>" name="quantity[]" id="quantity_<?php echo $count; ?>" course="grade-control quantity" autocomplete="off"></td> <td><input type="number" value="<?php echo $invoiceItem["order_item_price"]; ?>" proper name="price[]" id="price_<?php echo $count; ?>" class="form-control toll" autocomplete="off"></td> <td><input type="number" value="<?php echo $invoiceItem["order_item_final_amount"]; ?>" proper name="total[]" id="total_<?php echo $count; ?>" class="class-control full" autocomplete="off"></td> <input type="hidden" value="<?php repeat $invoiceItem['order_item_id']; ?>" grade="form-control" proper name="itemId[]"> </tr> <?php } ?> </table> </div> </div> <div grade="row"> <div class="col-xs-12 col-sm-3 col-doctor-3 col-lg-3"> <button class="btn btn-danger delete" id="removeRows" type="button">- Delete</button> <button class="btn btn-success" id="addRows" type="push button">+ Add More</button> </div> </div> <div form="row"> <div class="col-xs-12 col-sm-8 col-md-8 col-lg-8"> <h3>Notes: </h3> <div class="form-group"> <textarea class="grade-control txt" rows="5" proper noun="notes" id="notes" placeholder="Your Notes"><?php echo $invoiceValues['note']; ?></textarea> </div> <br> <div class="form-group"> <input type="hidden" value="<?php repeat $_SESSION['userid']; ?>" class="form-control" proper noun="userId"> <input blazon="hidden" value="<?php echo $invoiceValues['order_id']; ?>" form="form-control" name="invoiceId" id="invoiceId"> <input data-loading-text="Updating Invoice..." type="submit" proper noun="invoice_btn" value="Save Invoice" class="btn btn-success submit_btn invoice-salvage-btm"> </div> </div> <div class="col-xs-12 col-sm-four col-md-four col-lg-4"> <span class="class-inline"> <div course="form-grouping"> <characterization>Subtotal: </characterization> <div class="input-group"> <div grade="input-group-addon currency">$</div> <input value="<?php echo $invoiceValues['order_total_before_tax']; ?>" type="number" form="form-control" name="subTotal" id="subTotal" placeholder="Subtotal"> </div> </div> <div class="form-group"> <label>Tax Rate: </characterization> <div form="input-group"> <input value="<?php repeat $invoiceValues['order_tax_per']; ?>" blazon="number" form="form-control" proper noun="taxRate" id="taxRate" placeholder="Tax Rate"> <div class="input-group-addon">%</div> </div> </div> <div grade="grade-group"> <label>Tax Amount: </label> <div class="input-group"> <div form="input-group-addon currency">$</div> <input value="<?php echo $invoiceValues['order_total_tax']; ?>" type="number" class="form-control" proper noun="taxAmount" id="taxAmount" placeholder="Revenue enhancement Amount"> </div> </div> <div form="grade-group"> <characterization>Total: </label> <div course="input-group"> <div class="input-group-addon currency">$</div> <input value="<?php repeat $invoiceValues['order_total_after_tax']; ?>" type="number" class="course-command" proper noun="totalAftertax" id="totalAftertax" placeholder="Total"> </div> </div> <div class="class-group"> <label>Amount Paid: </label> <div class="input-group"> <div class="input-group-addon currency">$</div> <input value="<?php echo $invoiceValues['order_amount_paid']; ?>" type="number" class="grade-control" name="amountPaid" id="amountPaid" placeholder="Amount Paid"> </div> </div> <div class="grade-group"> <label>Amount Due: </label> <div class="input-grouping"> <div grade="input-group-addon currency">$</div> <input value="<?php echo $invoiceValues['order_total_amount_due']; ?>" type="number" course="form-control" proper noun="amountDue" id="amountDue" placeholder="Amount Due"> </div> </div> </span> </div> </div> <div class="clearfix"></div> </div> </class> </div> We volition edit save invoice using invoice method updateInvoice()
<?php include 'Invoice.php'; $invoice = new Invoice(); $invoice->updateInvoice($_POST); ?>
Step6: Implement Invoice Print
Now we will implement functionality to create invoice PDF in print_invoice.php file to allow user to print or download invoice. We will get invoice details from database tables using invoice method getInvoice() and getInvoiceItems(). And so we volition utilize PHP library Dompdf to create PDF from HTML.
<?php session_start(); include 'Invoice.php'; $invoice = new Invoice(); $invoice->checkLoggedIn(); if(!empty($_GET['invoice_id']) && $_GET['invoice_id']) { repeat $_GET['invoice_id']; $invoiceValues = $invoice->getInvoice($_GET['invoice_id']); $invoiceItems = $invoice->getInvoiceItems($_GET['invoice_id']); } $invoiceDate = appointment("d/G/Y, H:i:s", strtotime($invoiceValues['order_date'])); $output = ''; $output .= '<tabular array width="100%" border="1" cellpadding="v" cellspacing="0"> <tr> <td colspan="2" align="center" style="font-size:18px"><b>Invoice</b></td> </tr> <tr> <td colspan="2"> <table width="100%" cellpadding="v"> <tr> <td width="65%"> To,<br /> <b>RECEIVER (Beak TO)</b><br /> Proper noun : '.$invoiceValues['order_receiver_name'].'<br /> Billing Address : '.$invoiceValues['order_receiver_address'].'<br /> </td> <td width="35%"> Invoice No. : '.$invoiceValues['order_id'].'<br /> Invoice Appointment : '.$invoiceDate.'<br /> </td> </tr> </table> <br /> <table width="100%" border="ane" cellpadding="v" cellspacing="0"> <tr> <th align="left">Sr No.</th> <th marshal="left">Particular Code</thursday> <th align="left">Item Name</th> <thursday align="left">Quantity</th> <th marshal="left">Price</th> <thursday align="left">Actual Amt.</th> </tr>'; $count = 0; foreach($invoiceItems as $invoiceItem){ $count++; $output .= ' <tr> <td marshal="left">'.$count.'</td> <td align="left">'.$invoiceItem["item_code"].'</td> <td align="left">'.$invoiceItem["item_name"].'</td> <td align="left">'.$invoiceItem["order_item_quantity"].'</td> <td marshal="left">'.$invoiceItem["order_item_price"].'</td> <td align="left">'.$invoiceItem["order_item_final_amount"].'</td> </tr>'; } $output .= ' <tr> <td align="right" colspan="five"><b>Sub Total</b></td> <td align="left"><b>'.$invoiceValues['order_total_before_tax'].'</b></td> </tr> <tr> <td align="right" colspan="5"><b>Revenue enhancement Charge per unit :</b></td> <td align="left">'.$invoiceValues['order_tax_per'].'</td> </tr> <tr> <td align="right" colspan="v">Tax Amount: </td> <td align="left">'.$invoiceValues['order_total_tax'].'</td> </tr> <tr> <td marshal="correct" colspan="5">Total: </td> <td align="left">'.$invoiceValues['order_total_after_tax'].'</td> </tr> <tr> <td marshal="right" colspan="5">Amount Paid:</td> <td align="left">'.$invoiceValues['order_amount_paid'].'</td> </tr> <tr> <td align="right" colspan="5"><b>Amount Due:</b></td> <td marshal="left">'.$invoiceValues['order_total_amount_due'].'</td> </tr>'; $output .= ' </table> </td> </tr> </table>'; // create pdf of invoice $invoiceFileName = 'Invoice-'.$invoiceValues['order_id'].'.pdf'; require_once 'dompdf/src/Autoloader.php'; Dompdf\Autoloader::annals(); use Dompdf\Dompdf; $dompdf = new Dompdf(); $dompdf->loadHtml(html_entity_decode($output)); $dompdf->setPaper('A4', 'mural'); $dompdf->render(); $dompdf->stream($invoiceFileName, array("Attachment" => simulated)); ?> Step7: Implement Invoice Delete
Nosotros will implement invoice delete functionality in invoice.js. We will handle functionality on deleteInvoice handler and make Ajax request to action.php to delete invoice from database table.
$(document).on('click', '.deleteInvoice', function(){ var id = $(this).attr("id"); if(confirm("Are you certain you desire to remove this?")){ $.ajax({ url:"action.php", method:"Mail", dataType: "json", information:{id:id, action:'delete_invoice'}, success:office(response) { if(response.status == ane) { $('#'+id).closest("tr").remove(); } } }); } else { return false; } }); In action.php, we volition bank check for delete invoice action and invoice id to delete invoice using invoice method deleteInvoice() and render JSON response.
<?php include 'Invoice.php'; $invoice = new Invoice(); if($_POST['action'] == 'delete_invoice' && $_POST['id']) { $invoice->deleteInvoice($_POST['id']); $jsonResponse = array( "status" => 1 ); echo json_encode($jsonResponse); } ?> Step8: Implement User Logout
We volition too implement user logout functionality by passing action logout to action.php
<?php if($_GET['action'] == 'logout') { session_unset(); session_destroy(); header("Location:index.php"); } ?> Step9: Consummate Invoice Module with Method
We will create MySQL database connection and all methods in Invoice.php. Hither is complete list of invoice methods.
<?php public function loginUsers($email, $password){ $sqlQuery = " SELECT id, email, first_name, last_name, address, mobile FROM ".$this->invoiceUserTable." WHERE email='".$electronic mail."' AND password='".$countersign."'"; return $this->getData($sqlQuery); } public office checkLoggedIn(){ if(!$_SESSION['userid']) { header("Location:index.php"); } } public office saveInvoice($Mail) { $sqlInsert = " INSERT INTO ".$this->invoiceOrderTable."(user_id, order_receiver_name, order_receiver_address, order_total_before_tax, order_total_tax, order_tax_per, order_total_after_tax, order_amount_paid, order_total_amount_due, note) VALUES ('".$Mail service['userId']."', '".$Postal service['companyName']."', '".$Post['address']."', '".$Postal service['subTotal']."', '".$POST['taxAmount']."', '".$Mail service['taxRate']."', '".$Post['totalAftertax']."', '".$Postal service['amountPaid']."', '".$POST['amountDue']."', '".$Post['notes']."')"; mysqli_query($this->dbConnect, $sqlInsert); $lastInsertId = mysqli_insert_id($this->dbConnect); for ($i = 0; $i < count($Mail['productCode']); $i++) { $sqlInsertItem = " INSERT INTO ".$this->invoiceOrderItemTable."(order_id, item_code, item_name, order_item_quantity, order_item_price, order_item_final_amount) VALUES ('".$lastInsertId."', '".$Postal service['productCode'][$i]."', '".$Postal service['productName'][$i]."', '".$Postal service['quantity'][$i]."', '".$POST['price'][$i]."', '".$Post['total'][$i]."')"; mysqli_query($this->dbConnect, $sqlInsertItem); } } public role updateInvoice($POST) { if($POST['invoiceId']) { $sqlInsert = " UPDATE ".$this->invoiceOrderTable." SET order_receiver_name = '".$Mail['companyName']."', order_receiver_address= '".$POST['address']."', order_total_before_tax = '".$Mail['subTotal']."', order_total_tax = '".$POST['taxAmount']."', order_tax_per = '".$POST['taxRate']."', order_total_after_tax = '".$Mail['totalAftertax']."', order_amount_paid = '".$Postal service['amountPaid']."', order_total_amount_due = '".$POST['amountDue']."', annotation = '".$Postal service['notes']."' WHERE user_id = '".$Post['userId']."' AND order_id = '".$POST['invoiceId']."'"; mysqli_query($this->dbConnect, $sqlInsert); } $this->deleteInvoiceItems($Mail['invoiceId']); for ($i = 0; $i < count($POST['productCode']); $i++) { $sqlInsertItem = " INSERT INTO ".$this->invoiceOrderItemTable."(order_id, item_code, item_name, order_item_quantity, order_item_price, order_item_final_amount) VALUES ('".$POST['invoiceId']."', '".$Mail service['productCode'][$i]."', '".$POST['productName'][$i]."', '".$Post['quantity'][$i]."', '".$Postal service['toll'][$i]."', '".$POST['total'][$i]."')"; mysqli_query($this->dbConnect, $sqlInsertItem); } } public function getInvoiceList(){ $sqlQuery = " SELECT * FROM ".$this->invoiceOrderTable." WHERE user_id = '".$_SESSION['userid']."'"; return $this->getData($sqlQuery); } public function getInvoice($invoiceId){ $sqlQuery = " SELECT * FROM ".$this->invoiceOrderTable." WHERE user_id = '".$_SESSION['userid']."' AND order_id = '$invoiceId'"; $event = mysqli_query($this->dbConnect, $sqlQuery); $row = mysqli_fetch_array($result, MYSQL_ASSOC); render $row; } public function getInvoiceItems($invoiceId){ $sqlQuery = " SELECT * FROM ".$this->invoiceOrderItemTable." WHERE order_id = '$invoiceId'"; return $this->getData($sqlQuery); } public role deleteInvoiceItems($invoiceId){ $sqlQuery = " DELETE FROM ".$this->invoiceOrderItemTable." WHERE order_id = '".$invoiceId."'"; mysqli_query($this->dbConnect, $sqlQuery); } public part deleteInvoice($invoiceId){ $sqlQuery = " DELETE FROM ".$this->invoiceOrderTable." WHERE order_id = '".$invoiceId."'"; mysqli_query($this->dbConnect, $sqlQuery); $this->deleteInvoiceItems($invoiceId); return i; } ?> You may also like:
- Star Rating System with Ajax, PHP and MySQL
- Create Event Calendar with jQuery, PHP and MySQL
- Build Your Own CAPTCHA Script with PHP
- Convert Unix Timestamp To Readable Date Time in PHP
- Inventory Direction Organization with Ajax, PHP & MySQL
- Create Live Editable Tabular array with jQuery, PHP and MySQL
- Live Add Edit Delete datatables Records with Ajax, PHP and MySQL
- Stripe Payment Gateway Integration in PHP
- Consign Data to Excel with PHP and MySQL
- Star Rating Arrangement with Ajax, PHP and MySQL
- Create Dynamic Bootstrap Tabs with PHP & MySQL
- How To Create Elementary Remainder API in PHP
You can view the live demo from the Demo link and can download the total script from the Download link below.
Demo Download
DOWNLOAD HERE
Posted by: hazelhicese.blogspot.com
Post a Comment for "How To Create Mysql Dump And Download File With Php UPDATED"