Dalam tutorial kami sebelumnya Anda telah belajar bagaimana mengembangkan Sistem Inventaris dengan Ajax, PHP & MySQL. Dalam tutorial ini kami akan menjelaskan cara mengembangkan sistem invoice Anda sendiri dengan PHP & MySQL Show Sistem Manajemen Faktur atau Penagihan sangat populer karena sekarang sebagian besar transaksi dilakukan secara online. Saat ini setiap penjual dan pembeli membutuhkan sistem invoice untuk menangani billing secara online. Jadi jika Anda sedang mencari sistem invoice atau billing menggunakan PHP dan MySQL, maka Anda berada di tempat yang tepat. Dalam tutorial ini Anda akan belajar bagaimana mengembangkan sistem invoice dan billing menggunakan PHP dan MySQL Baca juga
Kami akan membahas tutorial ini dalam langkah-langkah mudah dengan demo langsung untuk mengembangkan sistem faktur lengkap untuk membuat dan mengedit faktur dengan cetakan faktur untuk diubah menjadi format PDF. Kami juga akan mengizinkan untuk mengunduh kode sumber demo langsung yang lengkap Karena kita akan membahas tutorial ini dengan contoh langsung untuk membangun sistem faktur dengan PHP & MySQL, maka file utama untuk contoh ini adalah sebagai berikut
Langkah 1. Membuat Tabel Database MySQL CREATE TABLE `invoice_user` ( `id` int(11) NOT NULL, `email` varchar(100) NOT NULL, `password` varchar(100) NOT NULL, `first_name` varchar(100) NOT NULL, `last_name` varchar(100) NOT NULL, `mobile` bigint(20) NOT NULL, `address` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE `invoice_user` ADD PRIMARY KEY (`id`); ALTER TABLE `invoice_user` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=123457; Berikut adalah contoh data dump pengguna INSERT INTO `invoice_user` (`id`, `email`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, '[email protected]', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');_ Kami akan membuat tabel invoice_order untuk menyimpan detail invoice CREATE TABLE `invoice_order` ( `order_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `order_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `order_receiver_name` varchar(250) NOT NULL, `order_receiver_address` text NOT NULL, `order_total_before_tax` decimal(10,2) NOT NULL, `order_total_tax` decimal(10,2) NOT NULL, `order_tax_per` varchar(250) NOT NULL, `order_total_after_tax` double(10,2) NOT NULL, `order_amount_paid` decimal(10,2) NOT NULL, `order_total_amount_due` decimal(10,2) NOT NULL, `note` text NOT 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 NULL AUTO_INCREMENT, AUTO_INCREMENT=682; Berikut adalah contoh data dump untuk invoice order 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\[email protected]', 342400.00, 684800.00, '200', 1027200.00, 45454.00, 981746.00, 'this note txt'); Kami juga akan membuat tabel invoice_order_item untuk menyimpan detail item invoice 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,2) NOT NULL, `order_item_price` decimal(10,2) NOT NULL, `order_item_final_amount` decimal(10,2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ALTER TABLE `invoice_order_item` ADD PRIMARY KEY (`order_item_id`); ALTER TABLE `invoice_order_item` MODIFY `order_item_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4364;_ Berikut adalah contoh data dump untuk item pesanan invoice 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', 1.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); Langkah 2. Terapkan Login Pengguna <div class="row"> <div class="demo-heading pull"> <h2>Build Invoice System with PHP & MySQL</h2> </div> <div class="login-form"> <h4>Invoice User Login:</h4> <form method="post" action=""> <div class="form-group"> <?php if ($loginError ) { ?> <div class="alert alert-warning"><?php echo $loginError; ?></div> <?php } ?> </div> <div class="form-group"> <input name="email" id="email" type="email" class="form-control" placeholder="Email address" autofocus="" required> </div> <div class="form-group"> <input type="password" class="form-control" name="pwd" placeholder="Password" required> </div> <div class="form-group"> <button type="submit" name="login" class="btn btn-info">Login</button> </div> </form> </div> </div>_ Kami akan menangani fungsionalitas login pada pengiriman formulir login menggunakan metode loginUsers() <?php if (!empty($_POST['email']) && !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['email'] = $user[0]['email']; $_SESSION['address'] = $user[0]['address']; $_SESSION['mobile'] = $user[0]['mobile']; header("Location:invoice_list.php"); } else { $loginError = "Invalid email or password!"; } } ?> Langkah3. Menampilkan Daftar Faktur <div class="container"> <h2 class="title">PHP Invoice System</h2> <?php include('menu.php');?> <table id="data-table" class="table table-condensed table-striped"> <thead> <tr> <th>Invoice No.</th> <th>Create Date</th> <th>Customer Name</th> <th>Invoice Total</th> <th>Print</th> <th>Edit</th> <th>Delete</th> </tr> </thead> <?php $invoiceList = $invoice->getInvoiceList(); foreach($invoiceList as $invoiceDetails){ $invoiceDate = date("d/M/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"><span class="glyphicon glyphicon-print"></span></a></td> <td><a href="edit_invoice.php?update_id='.$invoiceDetails["order_id"].'" title="Edit Invoice"><span class="glyphicon glyphicon-edit"></span></a></td> <td><a href="#" id="'.$invoiceDetails["order_id"].'" class="deleteInvoice" title="Delete Invoice"><span class="glyphicon glyphicon-remove"></span></a></td> </tr> '; } ?> </table> </div>_ Langkah4. Terapkan Pembuatan Faktur <div class="container content-invoice"> <form action="" id="invoice-form" method="post" class="invoice-form" role="form" novalidate=""> <div class="load-animate animated fadeInUp"> <div class="row"> <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8"> <h2 class="title">PHP Invoice System</h2> <?php include('menu.php');?> </div> </div> <input id="currency" type="hidden" value="$"> <div class="row"> <div class="col-xs-12 col-sm-4 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-4 col-md-4 col-lg-4 pull-right"> <h3>To,</h3> <div class="form-group"> <input type="text" class="form-control" name="companyName" id="companyName" placeholder="Company Name" autocomplete="off"> </div> <div class="form-group"> <textarea class="form-control" rows="3" name="address" id="address" placeholder="Your Address"></textarea> </div> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <table class="table table-bordered table-hover" id="invoiceItem"> <tr> <th width="2%"><input id="checkAll" class="formcontrol" type="checkbox"></th> <th width="15%">Item No</th> <th width="38%">Item Name</th> <th width="15%">Quantity</th> <th width="15%">Price</th> <th width="15%">Total</th> </tr> <tr> <td><input class="itemRow" type="checkbox"></td> <td><input type="text" name="productCode[]" id="productCode_1" class="form-control" autocomplete="off"></td> <td><input type="text" name="productName[]" id="productName_1" class="form-control" autocomplete="off"></td> <td><input type="number" name="quantity[]" id="quantity_1" class="form-control quantity" autocomplete="off"></td> <td><input type="number" name="price[]" id="price_1" class="form-control price" autocomplete="off"></td> <td><input type="number" name="total[]" id="total_1" class="form-control total" autocomplete="off"></td> </tr> </table> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3"> <button class="btn btn-danger delete" id="removeRows" type="button">- Delete</button> <button class="btn btn-success" id="addRows" type="button">+ Add More</button> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-8 col-md-8 col-lg-8"> <h3>Notes: </h3> <div class="form-group"> <textarea class="form-control txt" rows="5" 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..." type="submit" name="invoice_btn" value="Save Invoice" class="btn btn-success submit_btn invoice-save-btm"> </div> </div> <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4"> <span class="form-inline"> <div class="form-group"> <label>Subtotal: </label> <div class="input-group"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="form-control" name="subTotal" id="subTotal" placeholder="Subtotal"> </div> </div> <div class="form-group"> <label>Tax Rate: </label> <div class="input-group"> <input value="" type="number" class="form-control" name="taxRate" id="taxRate" placeholder="Tax Rate"> <div class="input-group-addon">%</div> </div> </div> <div class="form-group"> <label>Tax Amount: </label> <div class="input-group"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="form-control" name="taxAmount" id="taxAmount" placeholder="Tax Amount"> </div> </div> <div class="form-group"> <label>Total: </label> <div class="input-group"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="form-control" name="totalAftertax" id="totalAftertax" placeholder="Total"> </div> </div> <div class="form-group"> <label>Amount Paid: </label> <div class="input-group"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="form-control" name="amountPaid" id="amountPaid" placeholder="Amount Paid"> </div> </div> <div class="form-group"> <label>Amount Due: </label> <div class="input-group"> <div class="input-group-addon currency">$</div> <input value="" type="number" class="form-control" name="amountDue" id="amountDue" placeholder="Amount Due"> </div> </div> </span> </div> </div> <div class="clearfix"></div> </div> </form> </div>_ Kami akan menyimpan detail invoice menggunakan metode invoice saveInvoice() INSERT INTO `invoice_user` (`id`, `email`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, '[email protected]', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');_0 Langkah5. Terapkan Pembaruan Faktur INSERT INTO `invoice_user` (`id`, `email`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, '[email protected]', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');_1 Kami akan mengedit simpan faktur menggunakan metode faktur updateInvoice() INSERT INTO `invoice_user` (`id`, `email`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, '[email protected]', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');_2 Langkah6. Terapkan Cetak Faktur INSERT INTO `invoice_user` (`id`, `email`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, '[email protected]', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');_3 Langkah7. Terapkan Hapus Faktur INSERT INTO `invoice_user` (`id`, `email`, `password`, `first_name`, `last_name`, `mobile`, `address`) VALUES (123456, '[email protected]', '12345', 'Admin', '', 12345678912, 'New Delhi 110096 India.');_4 Sedang beraksi. php, kami akan memeriksa untuk menghapus tindakan faktur dan id faktur untuk menghapus faktur menggunakan metode faktur deleteInvoice() dan mengembalikan respons JSON Bagaimana cara menghasilkan nomor faktur secara otomatis di PHP?//dapatkan catatan terakhir $record = RecordModel. terbaru()->pertama(); . '-0001'; . //check first day in a year if ( date('l',strtotime(date('Y-01-01'))) ){ $nextInvoiceNumber = date('Y'). '-0001'; } else { //increase 1 with last invoice number $nextInvoiceNumber = $expNum[0].
Bagaimana cara membuat nomor invoice invoice?Cara membuat nomor invoice . penomoran faktur Anda secara berurutan, misalnya INV00001, INV00002 dimulai dengan kode pelanggan yang unik, misalnya XER00001 termasuk tanggal di awal nomor invoice Anda, misalnya 01-01-2021 menggabungkan kode dan tanggal pelanggan, misalnya XER-2021-01-001 Bagaimana cara membuat faktur di PHP?Langkah 1. Membuat Tabel Database MySQL. . Langkah 2. Terapkan Login Pengguna. . Langkah3. Menampilkan Daftar Faktur. . Langkah4. Terapkan Pembuatan Faktur. . Langkah5. Terapkan Pembaruan Faktur. . Langkah6. Terapkan Cetak Faktur. . Langkah7. Terapkan Hapus Faktur. . Langkah8. Terapkan Logout Pengguna Bagaimana nomor faktur dihasilkan?Penomoran Faktur Kronologis
. Jika Anda membuat faktur kedua pada tanggal tersebut untuk pelanggan tersebut, nomor fakturnya adalah 20170630-4072-01. The first series of numbers is the date, the second series of numbers is the customer number and the third series of numbers is the sequential unique identifier for the invoice. If you generate a second invoice on that date for that customer, the invoice number will be 20170630-4072-01. |