D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
add_invoice2.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $login = $_SESSION['login_email']; if($login == ''){ echo '<script>location.replace("index.php")</script>'; } $clientId = ""; if(isset($_GET["clientId"])){ $clientId = $_GET["clientId"]; } if(isset($_SESSION["source_id"])){ $source_id = $_SESSION['source_id']; } $applicable_tax = ""; $tax_manager = "SELECT * FROM tax_manager where set_default_value = 'set' AND source_id = '$source_id'"; $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 WHERE source_id = '$source_id'"; // $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 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 ">Sales</li> <li class="breadcrumb-item active">Create Invoice</li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <form action="insert_invoice2.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> <input type="hidden" class="form-control" name="billingCompany" id="billingCompany" value="<?php echo $source_id; ?>" readonly> <div class="row"> <div class="col-md-6 pt-5 pl-3"> <div class="form-group"> <div class="radio radio-info form-check-inline"> <input type="radio" id="inlineRadio1" value="Invoice" name="invoiceType" checked> <label for="inlineRadio1"> Invoice</label> </div> <div class="radio form-check-inline"> <input type="radio" id="inlineRadio2" value="Performa Invoice" name="invoiceType"> <label for="inlineRadio2"> Performa</label> </div> </div> </div> <div class="col-md-6"> <div class="form-group"> <label id="lblInvoice" class="col-form-label">Invoice Number</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"> </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"> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="inputEmail3" class="col-form-label"> Client Name</label> <input type="text" class="form-control" name="users" > </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="inputEmail3" class="col-form-label"> Mobile Number</label> <input type="number" class="form-control" name="mobile" > </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="inputEmail3" class="col-form-label"> Email Address</label> <input type="email" class="form-control" name="email" > </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="inputEmail3" class="col-form-label"> GSTIN Number</label> <input type="text" class="form-control" name="gstin" > </div> </div> <div class="col-md-12"> <div class="form-group"> <label for="inputEmail3" class="col-form-label"> Address</label> <input type="text" class="form-control" name="billingAddress" > </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 style="width:100%"> <th style="width:30%">Item Name</th> <th>HSN/SAC Code</th> <th>Price</th> <th>Tax</th> <th>Discount</th> <th>Quantity</th> <th>Total</th> <th></th> </tr> </thead> <tbody id='itemsadd'> <tr style="width:100%"> <td style="width:30%"> <div id="text"> <input type='text' class="form-control itemClass" name="item[]" > </div> </td> <td style="width:15%"><input class='form-control hsn' name="hsn[]" type='number'></td> <td style="width:15%"> <input class='form-control priceClass' name='price[]' type='number' ondrop='return false;' onpaste='return false;' > </td> <td style="width:10%"><input class='form-control taxamount' name="tax[]" type='number'></td> <td style="width:10%;"> <input type="number" name="applied_discount[]" class="form-control discountAppliedClass"></td> <td style="width:5%"><input class='form-control quantityClass' name="qty[]" type="number" ondrop='return false;' onpaste='return false;'></td> <td style="width:15%"><input type="text" name="total_amt[]" value="" class='form-control totalClass' 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:30%'><div><input class='form-control itemClass' name='item[]'></div></td><td style='width:15%'><input class='form-control hsn' name='hsn[]' type='text'></td><td style='width:15%'><input class='form-control priceClass' name='price[]' type='text' ondrop='return false;' onpaste='return false;' ></td><td style='width:10%'><input type='text' name='tax[]' class='form-control taxamount'></td> <td style='width:10%'><input type='text' name='applied_discount[]' class='form-control discountAppliedClass'></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:15%'><input type='text' name='total_amt[]' value='' class='form-control totalClass' 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 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('.taxamount').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; }); var decreaseValue = parseFloat(price) * parseFloat(quantity); 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)).toFixed(2); thisRow.find('.totalClass').val(subTotal); thisRow.find('.taxamount').val(taxInclude); thisRow.find('.discountAppliedClass').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 discount var totaldiscount = 0; totalColumn.find('.discountAppliedClass').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('.discountAppliedClass').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 on reciept"){ $('#due_date').datepicker('setDate', date); } 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"); }); $("#date").datepicker("setDate", new Date()); $("#due_date").datepicker("setDate", new Date()); }); getInvoicePrefix("<?php echo $source_id; ?>"); $("input[name=invoiceType]").click(function(){ if($(this).val() == "Invoice"){ $("#lblInvoice").text("Invoice Number"); getInvoicePrefix("<?php echo $source_id; ?>"); } else{ getPerformaNumber(); $("#lblInvoice").text("Performa Id"); } }); function getPerformaNumber(){ var companyId = "<?php echo $source_id; ?>"; $.ajax({ url : "PHP/response.php", data : "action=GetPerforma&companyId="+companyId, async : false, method : "POST", success : function(response){ var val = (response * 1) + 1; $("#invoice_number").val(val); var s_number = ('0000' + val).substr(-5); $("#invoice_id").val("#PI"+s_number); }, error : function(err){ } }); } </script> <?php if($clientId != ""){ echo "<script>showUser('".$clientId."');</script>"; } ?> </body> </html>