D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
view_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>'; } $id = $_GET['id']; if(isset($_SESSION["source_id"])){ $source_id = $_SESSION['source_id']; } ?> <!DOCTYPE html> <html> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Endive Media | 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'> <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> <link href="plugins/sweet-alert2/sweetalert2.min.css" rel="stylesheet" type="text/css"> <link href="plugins/jquery-toastr/jquery.toast.min.css" rel="stylesheet" /> <style> .table td, .table th { padding: .75rem; vertical-align: top; border-top: 0px solid #dee2e6; border-bottom: 1px solid #dee2e6; } </style> </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">View Invoice</h4> <ol class="breadcrumb float-right"> <li class="breadcrumb-item"><a href="#">Sales</a></li> <li class="breadcrumb-item ">All Invoice</li> <li class="breadcrumb-item active">View Invoice</li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <?php $companyId =""; $sql = " SELECT * FROM invoice_new a left join company_details b on a.company_id = b.id where a.id = '$id'"; // $sql = " SELECT * FROM invoice_new a LEFT JOIN invoice_items b ON b.invoice_id = a.id LEFT JOIN company_details c ON c.id = a.company_id WHERE a.company_id = '$source_id' AND (a.id = '$id' OR b.invoice_id = '$id')"; $result = mysqli_query($conn,$sql); while( $row = mysqli_fetch_array($result)){ $default_invoice = "print_invoice2.php"; if($row["default_invoice"] != ""){ $default_invoice = $row["default_invoice"]; } if($row["invoice_type"] == "Performa Invoice"){ $in = "Performa"; $intext = "Performa Id"; }else{ $in = "Invoice"; $intext = "Invoice Number"; } $companyId = $row["company_id"]; $company_gstin = substr($row["GSTIN"], 0, 2); $client_gstin = substr($row["billing_company_gstin"], 0, 2); $totalTax = $row['total_tax']; $taxList = ""; $halfTax = number_format((float)$totalTax/2, 2, '.', ''); $companyCountry = $row["country"]; if(strtoupper($row["country"]) == strtoupper("India")){ if($company_gstin == $client_gstin){ $taxList = "<div class='form-group row'><p class='col-9 text-uppercase mb-0 font-weight-bold'>CGST : </label><div class='col-3'><p class='mb-0'> ".$halfTax."</p></div></div><div class='form-group row'><p class='col-9 text-uppercase mb-0 font-weight-bold'>SGST : </label><div class='col-3'><p class='mb-0'> ".$halfTax."</p></div></div>"; } else{ $taxList = "<div class='form-group row'><p class='col-9 text-uppercase mb-0 font-weight-bold'>IGST : </label><div class='col-3'><p class='mb-0'> ".$totalTax."</p></div></div>"; } }else{ $sqlGetTaxName = "SELECT tax_name FROM tax_manager WHERE UPPER(country) = UPPER('$companyCountry') AND source_id = '$companyId'"; $resultGetTaxName = mysqli_query($conn, $sqlGetTaxName); if($resultGetTaxName){ if(mysqli_num_rows($resultGetTaxName) > 0){ while($rowGetTaxName = mysqli_fetch_assoc($resultGetTaxName)){ $taxList = "<div class='form-group row'><p class='col-9 text-uppercase mb-0 font-weight-bold'>".$rowGetTaxName["tax_name"]." : </label><div class='col-3'><p class='mb-0'> ".$totalTax."</p></div></div>"; } } } } ?> <div class="card-box"> <div class="row"> <div class="col-md-12"> <div class="timeline timeline-left"> <?php $sqlGetHistory = "SELECT * FROM invoice_notification WHERE invoice_id = '$id' ORDER BY action_date"; $resultGetHistory = $conn->query($sqlGetHistory); if($resultGetHistory){ if(mysqli_num_rows($resultGetHistory) > 0){ while($rowGetHistory = mysqli_fetch_assoc($resultGetHistory)){ ?> <article class="timeline-item"> <div class="timeline-desk"> <div class="panel"> <div class="timeline-box"> <span class="arrow"></span> <span class="timeline-icon"><i class="mdi mdi-checkbox-blank-circle-outline"></i></span> <p><?php echo $rowGetHistory['notification_text']; ?> </p> <h4 class=""><?php echo date("d F Y h:i:s A", strtotime($rowGetHistory["action_date"])); ?></h4> </div> </div> </div> </article> <?php } } else { ?> <article class="timeline-item"> <div class="timeline-desk"> <div class="panel"> <div class="timeline-box"> <span class="arrow"></span> <span class="timeline-icon"><i class="mdi mdi-checkbox-blank-circle-outline"></i></span> <p><?php echo $in." created for ".$row['currency']." " .$row["amount_paid"]; ?> </p> <h4 class=""><?php echo date("d F Y h:i:s A", strtotime($row["date_creation"])); ?></h4> </div> </div> </div> </article> <?php } } else { ?> <article class="timeline-item"> <div class="timeline-desk"> <div class="panel"> <div class="timeline-box"> <span class="arrow"></span> <span class="timeline-icon"><i class="mdi mdi-checkbox-blank-circle-outline"></i></span> <p><?php echo $in." created for ".$row['company_currency']." " .$row["amount_paid"]; ?> </p> <h4 class=""><?php echo date("d F Y h:i:s A", strtotime($row["date_creation"])); ?></h4> </div> </div> </div> </article> <?php } ?> </div> </div> </div> </div> <div class="card-box"> <div class="col-md-12"> <div class="row"> <div class="col-md-8"> <h3 class="mb-0"><?php echo $row['company_name'] ?></h3> <p class="mb-0"><?php echo $row['address'] ?></p> <p class="mb-0"><?php echo $row['city'] ?>, <?php echo $row['state'] ?>, <?php echo $row['country'] ?></p> <p class="mb-0"><b>Phone : </b><?php echo $row['phone'] ?>,</p> <p class="mb-0"> <b>Email : </b><?php echo $row['email'] ?></p> <p class="mb-0"><b>GSTIN : </b><?php echo $row['GSTIN'] ?></p> </div> <div class="col-md-4 text-right"> <img src='images/<?php echo $row['company_logo'] ?>' style='max-height:100px;max-width:250px' /> </div> </div> <div class="row" > <div class="col-md-12 mt-3 mb-3"> <h3 class="text-center" style="color:<?php echo $row['company_color'] ?>;"><b>TAX INVOICE</b></h3> </div> </div> <div class="row" style="margin-top:15px;"> <div class="col-md-8"> <p class="mb-0"><b>Bill To:</b></p> <h5 class="text-uppercase mt-0"><?php echo $row['billing_company_name'] ?></h5> <div class="row"> <div class="col-md-6"> <p class="mb-0"><?php echo $row['billing_company_address'] ?></p> <p class="mb-0">Phone - <?php echo $row['billing_company_phone'] ?></p> <p class="mb-0">Email - <span id="emailAddress"> <?php echo $row['billing_company_email'] ?></span></p> <p class="mb-0">GSTIN - <?php echo $row['billing_company_gstin'] ?></p> </div> </div> </div> <div class="col-md-4 text-left"> <table width="100%"> <tr> <td class="text-right text-capitalize"><b><?php echo $intext; ?></b></td> <td class="text-center">:</td> <td class="text-capitalize"><?php echo $row['invoice'] ?></td> </tr> <tr> <td class="text-right text-capitalize"><b>Date</b></td> <td class="text-center">:</td> <td class="text-capitalize"><?php echo $row['date'] ?></td> </tr> <tr> <td class="text-right text-capitalize"><b>Due Date</b></td> <td class="text-center">:</td> <td class="text-capitalize"><?php echo $row['due_date'] ?></td> </tr> </table> </div> </div> </div> <div class="row mb-4"> </div> <div class="row"> <table class="table table-responsive "> <thead style="background-color:<?php echo $row['company_color'] ?>;color:#fff;"> <tr > <th>#</th> <th class=" text-uppercase">Item Name</th> <th class=" text-uppercase">HSN/SAC</th> <th class=" text-uppercase">Qty</th> <th class=" text-uppercase">Price</th> <th class=" text-uppercase">Discount</th> <th class=" text-uppercase">Tax</th> <th class="text-right text-uppercase">Total</th> </tr> </thead> <tbody id='itemsadd'> <?php $invoiceId = explode(',', $id); $count = sizeof($invoiceId); for($i = 0 ; $i < $count; $i++){ ?> <tr style="width:100%"> <?php $number = $i+1; $itemName = ""; $sac_hsn = ""; $price = ""; $itemquantity = ""; $itemtax = ""; $itemtotalamount= ""; $itemdis_app = ""; $invoice_id1 = $invoiceId[$i]; $sqlGetItemName = "SELECT * FROM invoice_items WHERE invoice_id = '$invoice_id1'"; $resultGetItemName = mysqli_query($conn, $sqlGetItemName); while($rowGetItemName = mysqli_fetch_array($resultGetItemName)){ $number1= $number++; ?> <td style="width:5%"> <?php echo $number1; ?> </td> <td style="width:35%"><?php echo $rowGetItemName["item_name"]; ?></td> <td style="width:10%"><?php echo $rowGetItemName["hsn_sac_code"]; ?></td> <td style="width:10%" ><?php echo $rowGetItemName["quantity"]; ?></td> <td style="width:10%"><?php echo $rowGetItemName["price"]; ?></td> <td style="width:10%"><?php echo $rowGetItemName["discount_applied"]; ?></td> <td style="width:10%"><?php echo $rowGetItemName["tax"]; ?></td> <td class="text-right" style="width:10%"><?php echo $rowGetItemName["total_amount"]; ?></td> <td></td> </tr> <?php } }?> </tbody> </table> </div> <div class="row"> <div class="col-md-8"> </div> <div class="col-md-4"> <!-- <div class="form-group row"> <p class="col-9 text-uppercase mb-0 font-weight-bold">Total Discount : </label> <div class="col-3"> <p class="mb-0"> <?php echo $row['total_discount'] ?> </p> </div> </div> --> <div class="form-group row"> <p class="col-9 text-uppercase mb-0 font-weight-bold">Subtotal : </label> <div class="col-3"> <p class="mb-0 "> <?php echo $row['sub_total'] ?> </p> </div> </div> <?php echo $taxList; ?> <div class="form-group row"> <!-- <p class="col-8 text-uppercase mb-0 font-weight-bold"></label> --> <div class="col-12" style="font-size:20px;color:#fff;padding:10px;background-color:<?php echo $row['company_color'] ?>"> <p class="mb-0 font-weight-bold text-center"> <?php echo $row['currency']." "; echo $row['amount_paid']; ?> </p> </div> </div> </div> <div class="col-md-12"> <?php if($row["data_delete"] != "yes" && $row["data_delete"] != "cancel") { ?> <?php if($access->getFinanceEdit($_SESSION["login_email"], $_SESSION["source_id"]) == "on") { ?> <!-- <a href="edit-invoice2.php?id=<?php echo $id ?>" class="btn w-md waves-effect waves-light btn-info" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit"><i class="fa fa-pencil"></i> Edit</a> --> <?php } ?> <?php if($access->getFinanceDelete($_SESSION["login_email"], $_SESSION["source_id"]) == "on") { ?> <button type="button" class="btn w-md waves-effect waves-light btn-danger" value="<?php echo $id ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete" id="btnDelete"><i class="fa fa-trash-o"></i> Delete</button> <?php } ?> <?php if($row['invoice_type'] == "Performa Invoice"){ ?> <button type="button" class="btn w-md waves-effect waves-light btn-warning" value="<?php echo $id ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Convert To Invoice" id="btnConvert"> Convert To Invoice</button> <?php }?> <button type="button" class="btn w-md waves-effect waves-light btn-warning" value="<?php echo $id ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="Send" id="btnSend">Send</button> <?php } ?> <a href="<?php echo $default_invoice; ?>?id=<?php echo $id ?>" class="btn w-md waves-effect waves-light btn-success" data-toggle="tooltip" data-placement="top" title="" data-original-title="Print"><i class="fa fa-print"></i> Print</a> </div> </div> </div> </div> <?php } ?> </div> <!-- container --> </div> <!-- content --> <?php include 'copyrignt.php' ?> </div> <!-- ============================================================== --> <!-- End Right content here --> <!-- ============================================================== --> </div> <!-- END wrapper --> <div id="sendModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" data-keyboard="false" aria-hidden="true"> <form method="post" id = "frmSendEmail" action="send-invoice.php"> <div class="modal-dialog "> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Send Invoice</h4> </div> <div class="modal-body"> <input type="hidden" name="invoiceId" id="invoiceId" value="<?php echo $id; ?>"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="field-8" class="control-label">Email Address</label> <input type="email" class="form-control" id="emailId" name="emailId" required> </div> </div> </div> </div> <div class="modal-footer"> <!--<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>--> <button type="submit" id="btnsubmit" class="btn btn-info waves-effect waves-light">Send</button> </div> </div> </div> </form> </div><!-- /.modal --> <!-- 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://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js'></script> --> <script src="plugins/sweet-alert2/sweetalert2.min.js"></script> <script src="plugins/jquery-toastr/jquery.toast.min.js" type="text/javascript"></script> <script> $(document).ready(function(){ if (localStorage.getItem("InvoiceUpdated") == "true") { successMessage("Invoice Successfully Updated."); localStorage.setItem("InvoiceUpdated", "false"); } if (localStorage.getItem("InvoiceConverted") == "true") { successMessage("Performa Invoice Successfully Converted."); localStorage.setItem("InvoiceConverted", "false"); } if (localStorage.getItem("InvoiceSent") == "Performa") { successMessage("Performa Successfully Sent."); localStorage.setItem("InvoiceSent", "false"); } if (localStorage.getItem("InvoiceNotSent") == "Performa") { successMessage("Performa could not be sent."); localStorage.setItem("InvoiceNotSent", "false"); } if (localStorage.getItem("InvoiceSent") == "Invoice") { successMessage("Invoice Successfully Sent."); localStorage.setItem("InvoiceSent", "false"); } if (localStorage.getItem("InvoiceNotSent") == "Invoice") { successMessage("Invoice could not be sent."); localStorage.setItem("InvoiceNotSent", "false"); } }); $("#btnDelete").click(function(){ var invoiceId = $(this).val(); swal({ title: 'Are you sure?', text: "Do you really want to restore this Item??", type: 'warning', showCancelButton: true, confirmButtonColor: '#4fa7f3', cancelButtonColor: '#d57171', confirmButtonText: "Yes, I'm Sure!" }).then(function () { $.ajax({ url : "PHP/response.php", data : "action=DeleteInvoice&invoiceId="+invoiceId, method : "POST", async : false, success : function(response){ if(response == "DELETED"){ localStorage.setItem("InvoiceDeleted", "true"); location.replace("invoice2.php"); } else{ errorMessage("Invoice could not be deleted."+response); } }, error : function(error){ errorMessage("Invoice could not be deleted."); } }); }); }); function errorToast(msg){ $.toast({ heading: 'Error!', text: msg, position: 'top-right', loaderBg: '#bf441d', icon: 'error', hideAfter: 3000, stack: 1 }); } function successMessage(msg){ swal({ title: 'Success!', text: msg, type: 'success', confirmButtonColor: '#4fa7f3' }); } function errorMessage(msg){ swal({ title: 'Error!', text: msg, type: 'error', confirmButtonColor: '#4fa7f3' }); } function getInvoicePrefix(invoice) { var invoice_id = "", invoice_number = ""; var companyId = "<?php echo $source_id; ?>"; swal({ title: 'Are you sure?', text: "Do you really want to convert this Invoice??", type: 'warning', showCancelButton: true, confirmButtonColor: '#4fa7f3', cancelButtonColor: '#d57171', confirmButtonText: "Yes, I'm Sure!" }).then(function () { $.ajax({ url: "getInvoicePrefix.php?companyId=" + companyId, method: "GET", async: false, success: function(response) { var str = response.split(","); var myArray = str[0].split(/([0-9]+)/); 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 = "#"+prev + "" + val; } else{ invoice_id = "#"+prev+""+lastNumber; } invoice_number = str[1]; // alert(invoice_number); updateInvoice(invoice, invoice_id, invoice_number); }, error: function(jqXHR, textStatus, errorThrown) { alert('Internal error: ' + jqXHR.responseText); } }) }); } $("#btnConvert").click(function(){ var invoice = $(this).val(); getInvoicePrefix(invoice); }); function updateInvoice(invoice, invoice_id, invoice_number){ $.ajax({ url: "PHP/response.php", data : "action=ConvertInvoice&invoice="+invoice+"&invoice_id="+invoice_id+"&invoice_number="+invoice_number, method: "POST", async: false, success: function(response) { if(response === "SUCCESS"){ localStorage.setItem("InvoiceConverted", "true"); location.reload(); } else{ errorMessage("Performa invoice could not be converted"); } }, error: function(jqXHR, textStatus, errorThrown) { errorMessage('Internal error: ' + jqXHR.responseText); } }) } $("#btnSend").click(function(){ var email = $("#emailAddress").text().trim(); $("#emailId").val(email); $("#sendModal").modal("toggle"); }) </script> </body> </html>