D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
proc
/
self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
demo.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $login = $_SESSION['login_email']; if($login == ''){ echo '<script>location.replace("index.php")</script>'; } $applicable_tax = ""; $tax_manager = "SELECT * FROM tax_manager where set_default_value = 'set'"; $applicableresult = mysqli_query($conn,$tax_manager); if($applicableresult){ if(mysqli_num_rows($applicableresult) > 0){ while( $rowapplicable = mysqli_fetch_assoc($applicableresult)){ $applicable_tax = $rowapplicable['applicable_tax']; } } } $item = ""; $sqlitem = "SELECT * FROM inventory_manager"; $resultitem = mysqli_query($conn,$sqlitem); if($resultitem){ if(mysqli_num_rows($resultitem) > 0){ while( $rowitem = mysqli_fetch_assoc($resultitem)){ $item .= "<option value='". $rowitem['id'] ."'>".$rowitem['item_name']."</option> "; } } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Invoice Management | Invoice</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" /> <meta content="Coderthemes" name="author" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Font Awsome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <!-- App favicon --> <link rel="shortcut icon" href="assets/images/favicon.png"> <!-- Pie Chart Css --> <!--<link href="assets/pie charts/style.css" rel="stylesheet" type="text/css" />--> <!-- App css --> <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/icons.css" rel="stylesheet" type="text/css" /> <link href="assets/css/metismenu.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/style.css" rel="stylesheet" type="text/css" /> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css'> <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> <!--<script src = "https://code.jquery.com/jquery-1.10.2.js"></script> --> <script> function getBillingAddress(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } } xmlhttp.open("GET", "getuser.php?q=" + str, true); xmlhttp.send(); } function getShippingAddress(str) { if (str == "") { document.getElementById("txtHint1").innerHTML = ""; return; } if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("txtHint1").innerHTML = this.responseText; } } xmlhttp.open("GET", "getuser.php?q=" + str, true); xmlhttp.send(); } function showUser(str) { $.ajax({ url: "getCustomerAddress.php?companyId=" + str, method: "GET", async: false, success: function(response) { $("#billingAddress").html(response); $("#shippingAddress").html(response); }, error: function(jqXHR, textStatus, errorThrown) { alert('Internal error: ' + jqXHR.responseText); } }) } </script> <script> function showitem(str) { var thisRow = $(str).closest('tr'); var item = thisRow.find('.itemClass').val(); if (item == "") { document.getElementById("txtHint").innerHTML = ""; return; } $.ajax({ url: "getitem.php", method: "POST", async: false, data: {q:item}, success: function(response) { var str1 = JSON.parse(response); thisRow.find('.priceClass').val(str1.selling_price); thisRow.find('.taxClass').val(str1.tax); thisRow.find('.discountAppliedClass').val(str1.discount_applied); thisRow.find('.discountCategoryClass').val(str1.discount_category); if(thisRow.find('.quantityClass').val() != ""){ thisRow.find('.quantityClass').trigger("keyup"); } }, error: function(jqXHR, textStatus, errorThrown) { alert('Internal error: ' + jqXHR.responseText); } }) } function getInvoicePrefix(companyId) { $.ajax({ url: "getInvoicePrefix.php?companyId=" + companyId, method: "GET", async: false, success: function(response) { var str = response.split(","); var myArray = str[0].split(/([0-9]+)/); // for(var j = 0; j<myArray.length; j++){ // console.log(myArray[j]); // } var lastNumber = "0"+str[1]; var prev = ""; var i = 0; do{ prev = prev+""+myArray[i]; i++; }while(i < myArray.length-2); if(Number.isInteger(parseInt(myArray[myArray.length-2]))){ var val = parseInt(parseInt(myArray[myArray.length-2])+ parseInt(lastNumber)); $("#invoice_id").val("#"+prev + "" + val); } else{ $("#invoice_id").val("#"+prev+""+lastNumber); } // $("#invoice_id").val("#" + str[0] + "/" + str[1]); $("#invoice_number").val(str[1]); }, error: function(jqXHR, textStatus, errorThrown) { alert('Internal error: ' + jqXHR.responseText); } }) } </script> </head> <body> <!-- Begin page --> <div id="wrapper"> <!-- Top Bar Start --> <?php include 'top-header.php'; ?> <!-- Top Bar End --> <!-- ========== Left Sidebar Start ========== --> <?php include 'left-sidebar.php'; ?> <!-- Left Sidebar End --> <!-- ============================================================== --> <!-- Start right Content here --> <!-- ============================================================== --> <div class="content-page"> <!-- Start content --> <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="page-title-box"> <h4 class="page-title float-left">Create Invoice</h4> <ol class="breadcrumb float-right"> <li class="breadcrumb-item ">Finance Manager</li> <li class="breadcrumb-item active">Create Invoice</li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <form action="insert_invoice.php" method="post" class="form-horizontal" role="form"> <div class="card-box"> <input type="hidden" class="form-control" name="invoice_number" id="invoice_number" value="" readonly> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="inputEmail3" class="col-form-label">Select Corporate Profile</label> <select class="form-control" name="billingCompany" onchange="getInvoicePrefix(this.value)"> <option value="">--Select--</option> <?php $sqlGetCompanyName = "SELECT * FROM company_details where data_delete = 'no'"; $resultGetCompanyName = mysqli_query($conn, $sqlGetCompanyName); if($resultGetCompanyName){ if(mysqli_num_rows($resultGetCompanyName) > 0){ while($rowGetCompanyName = mysqli_fetch_array($resultGetCompanyName)){ ?> <option value="<?php echo $rowGetCompanyName['id'] ?>"> <?php echo $rowGetCompanyName['company_name'] ?></option> <?php } } } ?> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="inputPassword3" class="col-form-label">Invoice</label> <input type="text" class="form-control" name="invoice_id" id="invoice_id" value="" readonly> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="inputPassword4" class="col-form-label">Date</label> <input type="text" class="form-control" name="date" id="date" value="<?php echo date('j F Y'); ?>"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="terms" class="col-form-label">Terms</label> <select class="form-control" name="terms" id="terms"> <option value="">--Select--</option> <option value="Paid">Paid</option> <option value="Net 7">Net 7</option> <option value="Net 15">Net 15</option> <option value="Net 30">Net 30</option> <option value="Net 60">Net 60</option> <option value="Due end of the month">Due end of the month</option> <option value="Due end of the next month">Due end of the next month</option> <option value="Due on reciept">Due on reciept</option> <option value="Custom">Custom</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="inputPassword4" class="col-form-label">Due Date</label> <input type="text" class="form-control" id="due_date" name="due_date" value="<?php echo date('j F Y'); ?>"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="inputEmail3" class="col-form-label">Select Customer / Client</label> <select class="form-control" name="users" onchange="showUser(this.value)"> <option value="">Select Option</option> <?php $sql = "SELECT * FROM contact_manager where trim(data_delete) != 'yes'"; $result = mysqli_query($conn,$sql); while( $row = mysqli_fetch_array($result)){ $company_name = $row['customer_client']; if($company_name == 'company name'){ ?> <option value="<?php echo $row['id'] ?>"> <?php echo $row['company_name'] ?></option> <?php }else { ?> <option value="<?php echo $row['id'] ?>"> <?php echo $row['contact_person_name'] ?></option> <?php } } ?> </select> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="inputPassword4" class="col-form-label">Billing Address</label> <select name="billingAddress" id="billingAddress" class="form-control" onchange="getBillingAddress(this.value)"> <option value="">--Select--</option> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="inputPassword4" class="col-form-label">Shipping Address</label> <select name="shippingAddress" id="shippingAddress" class="form-control" onchange="getShippingAddress(this.value)"> <option value="">--Select--</option> </select> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <div id="txtHint"><b>Billing Address info will be listed here...</b> <p></p> </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <div id="txtHint1"><b>Shipping Address info will be listed here...</b> <p></p> </div> </div> </div> </div> <div class="row"> <button id="add" class="btn add-more button-yellow uppercase" type="button"> + Add Line Item</button> <table class="table table-responsive"> <thead> <tr> <th>Item Name</th> <th>Price</th> <th>Quantity</th> <th>Tax</th> <th>Total</th> <th style="display:none"></th> <th style="display:none"></th> <th style="display:none"></th> <th style="display:none"></th> <!-- <th>applied_discount</th> <th>discountValueqty</th> <th>category_discount</th> <th>tax_val</th> --> <th></th> </tr> </thead> <tbody id='itemsadd'> <tr style="width:100%"> <td style="width:50%"> <div id="text"> <select class="form-control select itemClass" name="item[]" onchange="showitem(this)"> <option value=''>--Select Item--</option> <?php echo $item; ?> </select> </div> </td> <td style="width:20%"> <input class='form-control priceClass' name='price[]' type='text' ondrop='return false;' onpaste='return false;' readonly> </td> <td style="width:5%"><input class='form-control quantityClass' name="qty[]" type="text" ondrop='return false;' onpaste='return false;'></td> <td style="width:10%"><input class='form-control taxamount' name="tax[]" type='text'></td> <td style="width:15%"><input type="text" name="total_amt[]" value="" class='form-control totalClass' readonly></td> <td style="width:0%; display:none;"> <input type="hidden" name="applied_discount[]" class="discountAppliedClass"></td> <td style="width:0%;display:none;"><input type="hidden" name="discountValueqty[]" class="discountValueqty"></td> <td style="width:0%;display:none;"><input type="hidden" name="category_discount[]" class="discountCategoryClass"></td> <td style="width:0%;display:none;"><input type='hidden' name="tax_val[]" class='form-control taxClass' readonly></td> <!-- <td> <input type="text" name="applied_discount[]" class="discountAppliedClass"></td> <td ><input type="text" name="discountValueqty[]" class="discountValueqty"></td> <td ><input type="text" name="category_discount[]" class="discountCategoryClass"></td> <td ><input type='text' name="tax_val[]" class='form-control taxClass' readonly></td> --> <td></td> </tr> </tbody> </table> </div> <div class="row"> <div class="col-md-6"> </div> <div class="col-md-6"> <div class="form-group row"> <label class="col-4 col-form-label" for="example-email">Total Discount </label> <div class="col-8"> <input type="text" id="disamountvalue" class="form-control" name="total_discount" readonly> </div> </div> <div class="form-group row"> <label class="col-4 col-form-label" for="example-email">Total Tax </label> <div class="col-8"> <input type="text" id="taxvalue" class="form-control" name="total_tax" readonly> </div> </div> <div class="form-group row"> <label class="col-4 col-form-label" for="example-email">Subtotal </label> <div class="col-8"> <input type="text" id="a4" class="form-control" name="subtotal" readonly> </div> </div> <div class="form-group row"> <label class="col-4 col-form-label" for="example-email">Amount Paid </label> <div class="col-8"> <input type="text" id="amountvalue" class="form-control" name="amount_paid" readonly> </div> </div> </div> </div> <button type="submit" class="btn btn-info waves-effect waves-light">Submit</button> </form> </div> </div> </div> <!-- container --> </div> <!-- content --> <?php include 'copyrignt.php' ?> </div> <!-- ============================================================== --> <!-- End Right content here --> <!-- ============================================================== --> </div> <!-- END wrapper --> <!-- Chart Js --> <script src='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.js'></script> <!-- jQuery --> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/popper.min.js"></script><!-- Popper for Bootstrap --> <script src="assets/js/bootstrap.min.js"></script> <script src="assets/js/metisMenu.min.js"></script> <!--<script src="assets/js/waves.js"></script>--> <script src="assets/js/jquery.slimscroll.js"></script> <!-- Dashboard init --> <script src="assets/pages/jquery.dashboard.js"></script> <!-- App js --> <script src="assets/js/jquery.core.js"></script> <script src="assets/js/jquery.app.js"></script> <!-- Chart Js --> <!-- <script src="assets/pie charts/script.js"></script>--> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js'></script> <script src="assets/js/modernizr.min.js"></script> <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> --> <script type="text/javascript" src="script.js"></script> <script> $(document).ready(function() { $(".delete").hide(); //when the Add Field button is clicked $("#add").click(function(e) { $(".delete").fadeIn("1500"); //Append a new row of code to the "#items" div $("#itemsadd").append( "<tr id='next-referral' style='width:100%'><td style='width:50%'><div><select class='form-control select itemClass' name='item[]' onchange='showitem(this)'><option value=''>--Select Item--</option><?php echo $item ?></select></div></td><td style='width:20%'><input class='form-control priceClass' name='price[]' type='text' ondrop='return false;' onpaste='return false;' readonly></td><td style='width:5%'><input name='qty[]' type='text' class='form-control quantityClass' keyup='keyupMethod(this)' ondrop='return false;' onpaste='return false;'></td><td style='width:10%'><input type='text' name='tax[]' class='form-control taxamount'></td><td style='width:15%'><input type='text' name='total_amt[]' value='' class='form-control totalClass' readonly></td><td style='display:none;'><input type='hidden' name='applied_discount[]' class='discountAppliedClass' ></td><td style='display:none;'><input type='hidden' name='discountValueqty[]' class='discountValueqty' ></td><td style='display:none;'> <input type='hidden' name='category_discount[]' class='discountCategoryClass'></td><td style='display:none;'><input type='hidden' name='tax_val[]' class='form-control taxClass' readonly></td><td> <button type='button' class='btn btn-xs btn-danger delete'><span class='fa fa-trash'></span></button></td></tr>" ); forSelect(); }); //("body").on("click", ".delete", function(e) { //$("#next-referral").last().remove(); //}); }); </script> <script> function selectOption() { $('.select').select2(); } $(document).ready(function() { forSelect(); }); function forSelect() { selectOption(); $('#add').click(function() { var text = $('#text').html(); $('#demo').append(text); $('#demo .select').select2(); $('#demo .select').last().next().next().remove(); }); } $(document).on('keyup', '.quantityClass', function() { var sum = 0; var gsum = 0; var price = 0; var quantity = 0; var tax = 0; var discountApplied = 0; var discountCategory = ""; var discountValue = 0; var thisRow = $(this).closest('tr'); thisRow.find('.priceClass').each(function() { if (this.value == null || this.value == '') price = 0; else price = this.value; }); thisRow.find('.quantityClass').each(function() { if (this.value == null || this.value == '') quantity = 0; else quantity = this.value; }); thisRow.find('.taxClass').each(function() { if (this.value == null || this.value == '') tax = 0; else tax = this.value; }); thisRow.find('.discountAppliedClass').each(function() { if (this.value == null || this.value == '') discountApplied = 0; else discountApplied = this.value; }); thisRow.find('.discountCategoryClass').each(function() { discountCategory = this.value; }); var decreaseValue = parseFloat(price) * parseFloat(quantity); if (discountCategory == "percent") { var disamountpercent = parseFloat((discountApplied / 100) * decreaseValue); var disamount = parseFloat(decreaseValue) - parseFloat(disamountpercent); discountValue = parseFloat(disamountpercent); } else if (discountCategory == "flat") { var disamountpercent = discountApplied; discountValue = parseFloat(disamountpercent) * parseFloat(quantity); var disamount = parseFloat(decreaseValue) - parseFloat(discountValue); } var applicable = "<?php echo $applicable_tax; ?>"; if (applicable == "") { var taxInclude = parseFloat((tax / 100) * disamount).toFixed(2); } else { var taxInclude = parseFloat((applicable / 100) * disamount).toFixed(2); } // var subTotal = (parseFloat(disamount) + parseFloat(taxInclude)).toFixed(2); var subTotal = (parseFloat(disamount)).toFixed(2); thisRow.find('.totalClass').val(subTotal); thisRow.find('.taxamount').val(taxInclude); thisRow.find('.discountValueqty').val(discountValue); var totalColumn = $(this).closest('tr').parent(); // for total amount var totalPrice = 0; totalColumn.find('.totalClass').each(function() { totalPrice = (parseFloat(totalPrice) + parseFloat(this.value)).toFixed(2); }); $("#a4").val(totalPrice); //----------------------------- // for total amount var totaldiscount = 0; totalColumn.find('.discountValueqty').each(function() { totaldiscount = parseFloat(totaldiscount) + parseFloat(this.value); }); $("#disamountvalue").val(parseFloat(totaldiscount).toFixed(2)); //----------------------------- // for total amount var totaltaxInclude = 0; totalColumn.find('.taxamount').each(function() { totaltaxInclude = (parseFloat(totaltaxInclude) + parseFloat(this.value)).toFixed(2); }); $("#taxvalue").val(totaltaxInclude); //----------------------------- $("#amountvalue").val((parseFloat($("#taxvalue").val()) + parseFloat($("#a4").val())).toFixed(2)); }); $(document).on('click', '.delete', function() { var totalColumn = $(this).closest('tr').parent(); $(this).closest('tr').remove(); // for total amount var totalPrice = 0; totalColumn.find('.totalClass').each(function() { totalPrice = (parseFloat(totalPrice) + parseFloat(this.value)).toFixed(2); // alert(totalPrice); // alert('ok'); }); $("#a4").val(totalPrice); //----------------------------- // for total amount var totaldiscount = 0; totalColumn.find('.discountValueqty').each(function() { totaldiscount = parseFloat(totaldiscount) + parseFloat(this.value); // alert(totaldiscount); }); $("#disamountvalue").val(parseFloat(totaldiscount).toFixed(2)); //----------------------------- // for total amount var totaltaxInclude = 0; totalColumn.find('.taxamount').each(function() { totaltaxInclude = (parseFloat(totaltaxInclude) + parseFloat(this.value)).toFixed(2); }); $("#taxvalue").val(totaltaxInclude); //----------------------------- // alert(totaltax); //payableamount = (parseFloat(totaltax) + parseFloat(totalPrice)).toFixed(2); $("#amountvalue").val((parseFloat($("#taxvalue").val()) + parseFloat($("#a4").val())).toFixed(2)); }); $(document).ready(function() { $("#s").change(function() { if (!this.checked) { $("#due_date").removeAttr('disabled'); $("#due_date").removeAttr('readonly'); if ($("#due_date").val() == "Paid") { $("#due_date").val("<?php echo date('j F Y'); ?> "); } } else { $("#due_date").attr('disabled', 'disabled'); $("#due_date").attr('readonly', 'true'); $("#due_date").val("Paid"); } }); //triger change event in case checkbox checked when user accessed page $("#s").trigger("change") }); $(document).ready(function() { $("#due_date,#date").datepicker({ dateFormat: 'dd MM yy' }); }); $(document).ready(function(){ $("#terms").change(function(){ var date1 = $('#date').val(); var date = new Date( Date.parse( date1 ) ); var terms = $( "#terms option:selected" ).val(); if(terms === "Paid"){ } else if(terms === "Net 7"){ date.setDate( date.getDate() + 7 ); var newDate = date.toDateString(); newDate = new Date( Date.parse( newDate ) ); $('#due_date').datepicker('setDate', newDate ); } else if(terms === "Net 15"){ date.setDate( date.getDate() + 15 ); var newDate = date.toDateString(); newDate = new Date( Date.parse( newDate ) ); $('#due_date').datepicker('setDate', newDate ); } else if(terms === "Net 30"){ date.setDate( date.getDate() + 30 ); var newDate = date.toDateString(); newDate = new Date( Date.parse( newDate ) ); $('#due_date').datepicker('setDate', newDate ); } else if(terms === "Net 60"){ date.setDate( date.getDate() + 60 ); var newDate = date.toDateString(); newDate = new Date( Date.parse( newDate ) ); $('#due_date').datepicker('setDate', newDate ); } else if(terms === "Due end of the month"){ $('#due_date').datepicker('setDate', new Date(date.getFullYear(), date.getMonth() + 1, 0)); } else if(terms === "Due end of the next month"){ $('#due_date').datepicker('setDate', new Date(date.getFullYear(), date.getMonth() + 2, 0)); } }); }); $(document).ready(function(){ $("#date").change(function(){ $("#terms").trigger("change"); }); $("#due_date").change(function(){ $('#terms option[value="Custom"]').attr("selected", "selected"); }); }); </script> </body> </html>