D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
view-transaction.php
back
Copy
<!DOCTYPE html> <?php $id = $_GET['id']; session_start(); include 'config.php'; $login = $_SESSION['login_email']; if(isset($_SESSION["source_id"])){ $source_id = $_SESSION['source_id']; } if($login == ''){ echo '<script>location.replace("index.php")</script>'; } $contactId = ""; function getPaidAmount($conn, $referenceId){ $amount = 0.00; $sqlGetPaidAmount = "SELECT amount, tax_deduction FROM payment WHERE reference = '$referenceId' AND transaction_type = 'Debit' AND is_deleted = 'NO'"; $resultGetPaidAmount = mysqli_query($conn, $sqlGetPaidAmount); if($resultGetPaidAmount){ if(mysqli_num_rows($resultGetPaidAmount) > 0){ while($rowGetPaidAmount = mysqli_fetch_assoc($resultGetPaidAmount)){ $amount += $rowGetPaidAmount["amount"] + $rowGetPaidAmount["tax_deduction"]; } } } $amount = sprintf('%0.2f', $amount); return $amount; } function getPaidAmount1($conn, $referenceId){ $amount = 0.00; $sqlGetPaidAmount = "SELECT amount FROM payment WHERE reference = '$referenceId' AND transaction_type = 'Debit' AND is_deleted = 'NO'"; $resultGetPaidAmount = mysqli_query($conn, $sqlGetPaidAmount); if($resultGetPaidAmount){ if(mysqli_num_rows($resultGetPaidAmount) > 0){ while($rowGetPaidAmount = mysqli_fetch_assoc($resultGetPaidAmount)){ $amount += $rowGetPaidAmount["amount"] ; } } } $amount = sprintf('%0.2f', $amount); return $amount; } ?> <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" /> <!-- DataTables --> <link href="plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <link href="plugins/datatables/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- Responsive datatable examples --> <link href="plugins/datatables/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <script src="assets/js/modernizr.min.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" /> <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> </head> <body> <style> .tabcontent { display: none; padding: 6px 12px; border: 1px solid #ccc; border-top: none; } </style> <!-- 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 Transaction</h4> <ol class="breadcrumb float-right"> <li class="breadcrumb-item ">Contact Manager</li> <li class="breadcrumb-item ">All Contact</li> <li class="breadcrumb-item active">View Transaction</li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <div class="row"> <div class="col-sm-12"> <div class="card-box"> <div class="row"> <div class="col-lg-3"> <ul class="nav nav-pills navtab-bg nav-justified"> <li class="nav-item "> <a href="#debit" data-toggle="tab" aria-expanded="false" class="nav-link bg-red active show"> Debit History </a> </li> <li class="nav-item"> <a href="#credit" data-toggle="tab" aria-expanded="true" class="nav-link bg-green"> Credit History </a> </li> </ul> </div> </div> <div class="tab-content"> <div class="tab-pane active show" id="debit"> <h3 class="text-center">Debit History</h3> <table id="datatable" class="table table-bordered"> <thead> <tr class="bg-grey"> <th>Invoice Id</th> <th>Invoice Date</th> <th>Due Date</th> <th>Invoice Amount</th> <th style="display:none">Paid Amount</th> <th>Paid Amount</th> <th>Status</th> <th class="text-center">Actions</th> </tr> </thead> <tbody> <?php $payment1 = "SELECT * FROM generate_invoice where bill_pay_name = '$id' AND data_delete != 'yes' ORDER BY id DESC"; $paymentresult1 = mysqli_query($conn,$payment1); while( $payrow1 = mysqli_fetch_array($paymentresult1)){ $status = ""; $status1 = ""; $paidAmount = getPaidAmount($conn, $payrow1['invoice_Id']); $paidAmount1 = getPaidAmount1($conn, $payrow1['invoice_Id']); if($payrow1['data_delete'] == "cancel"){ $status = "<a class='btn btn-danger btn-xs'>Cancelled</a>"; $status1 = "Cancelled"; } else{ if($payrow1['amount_paid'] <= $paidAmount){ $status = "<a class='btn btn-success btn-xs'>Paid</a>"; $status1 = "Paid"; } else if($payrow1['amount_paid'] > $paidAmount && $paidAmount > 0){ $status = "<a class='btn btn-primary btn-xs'>Partial Paid</a>"; } else{ if(strtotime($payrow1['due_date']) < strtotime(date('Y-m-d'))){ $status = "<a class='btn btn-warning btn-xs'>Overdue</a>"; }else{ $status = "<a class='btn btn-info btn-xs'>Pending</a>"; } } } ?> <tr> <td><?php echo $payrow1['invoice_Id']; ?></td> <td><?php echo date("d/m/Y", strtotime($payrow1['date'])); ?></td> <td><?php echo date("d/m/Y", strtotime($payrow1['due_date'])); ?></td> <td><?php echo $payrow1['amount_paid']; ?></td> <td style="display:none"><?php echo $paidAmount; ?></td> <td><?php echo $paidAmount1; ?></td> <td><?php echo $status; ?></td> <td class="actions text-center"> <?php if($status1 != "Cancelled") {if($paidAmount < $payrow1['amount_paid']) { if($access->getFinanceAdd($_SESSION["login_email"], $_SESSION["source_id"]) == "on") {?> <button type="button" value="<?php echo $payrow1['id'] ?>" class="btn btn-sm btn-info" onclick="payAmount(this)">Pay</button> <?php } } if($access->getFinanceEdit($_SESSION["login_email"], $_SESSION["source_id"]) == "on") {?> <button type="button" value="<?php echo $payrow1['id'] ?>" class="btn btn-sm btn-danger" onclick="cancelInvoice(this)">Cancel Invoice</button> <?php } } ?> </td> </tr> <?php } ?> </tbody> </table> </div> <div class="tab-pane" id="credit"> <h3 class="text-center">Credit History</h3> <table id="datatable2" class="table table-bordered"> <thead> <tr class="bg-grey"> <th>Reference Id</th> <th>Payment Date</th> <th>Amount</th> <th>Mode</th> <th class="text-center">Actions</th> </tr> </thead> <tbody> <?php $payment1 = "SELECT * FROM payment where company_id = '$id' AND transaction_type = 'Credit' AND is_deleted = 'NO' ORDER BY id DESC"; $paymentresult1 = mysqli_query($conn,$payment1); while( $payrow1 = mysqli_fetch_array($paymentresult1)){ ?> <tr> <td><?php echo $payrow1['reference'] ?></td> <td><?php echo date("d/m/Y", strtotime($payrow1['payment_date'])); ?></td> <td><?php echo $payrow1['amount'] ?></td> <td><?php echo $payrow1['mode'] ?></td> <td class="actions text-center"> <?php if($access->getFinanceEdit($_SESSION["login_email"], $_SESSION["source_id"]) == "on") { ?> <a href="edit_deposite_payment.php?id=<?php echo $payrow1['id'] ?>" class="btn btn-sm btn-info" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit"><i class="fa fa-pencil"></i></a> <?php } ?> <?php if($access->getFinanceDelete($_SESSION["login_email"], $_SESSION["source_id"]) == "on") { ?> <button type="button" class="btn btn-sm btn-danger" value="<?php echo $payrow1['id'] ?>" onclick="deletePayment(this)" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete"><i class="fa fa-trash-o"></i></button> <?php } ?> <a href="view_deposite_payment.php?id=<?php echo $payrow1['id'] ?>" class="btn btn-sm btn-warning" data-toggle="tooltip" data-placement="top" title="" data-original-title="View"><i class="fa fa-eye"></i> View </a> </td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> </div> </div> </div> <!-- container --> </div> <!-- content --> <?php include 'copyrignt.php' ?> </div> <!-- ============================================================== --> <!-- End Right content here --> <!-- ============================================================== --> </div> <div id="modalRecordPayment" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" data-keyboard="false" aria-hidden="true"> <form method="post" id="formRecordPayment"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Record Payment</h4> </div> <div class="modal-body"> <input type="hidden" class="form-control" id="invoiceId" name ="invoiceId"> <input type="hidden" class="form-control" id="companyId" name ="companyId"> <input type="hidden" class="form-control" id="referenceId" name ="referenceId"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="field-3" class="control-label">Available Credit</label> <input type="text" class="form-control" id="availableCredit" name = "availableCredit" readonly> </div> <input type="checkBox" id="useThis" name = "useThis">Use this Credit </div> <div class="col-md-6"> <div class="form-group"> <label for="field-3" class="control-label">Due Amount</label> <input type="text" class="form-control" id="dueAmount" name = "dueAmount" readonly> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="field-6" class="control-label">Amount</label> <input type="number" class="form-control" id="amount" name = "amount" value="0.00"> </div> </div> <div class="col-md-3 d-none"> <div class="form-group"> <label for="field-7" class="control-label">Tax Deduction(if any)</label> <input type="number" class="form-control" id="taxdeduction" name="taxdeduction" value="0.00"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="exampleInputPassword1">Payment Mode</label> <select class="form-control" name="payment_mode"> <option value="">-- Select Payment Mode --</option> <option value="Cash">Cash</option> <option value="Cheque">Cheque</option> <option value="Bank Transfer">Bank Transfer</option> <option value="Payment Gateway">Payment Gateway</option> </select> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="field-7" class="control-label">Payment Date</label> <input type="text" class="form-control" id="payment_date" name="payment_date"> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="field-7" class="control-label">Remark</label> <input type="text" class="form-control" id="remark" name="remark"> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button> <button type="button" id="btnRecordPayment" class="btn btn-info waves-effect waves-light">Submit</button> </div> </div> </div> </form> </div> <div id="cancelInvoiceModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" data-keyboard="false" aria-hidden="true"> <form method="post" id="cancelInvoiceForm"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Cancel Invoice</h4> </div> <div class="modal-body"> <input type="hidden" class="form-control" id="invoiceId1" name ="invoiceId1"> <input type="hidden" class="form-control" id="companyId1" name ="companyId1"> <input type="hidden" class="form-control" id="paidAmountInput" name ="paidAmountInput"> <div class="row" id="divRefundMode" style="display:none"> <div class="col-md-6"> <div class="form-group"> <label for="field-3" class="control-label">Refund Mode</label> <select class="form-control" id="refundMode" name = "refundMode"> <option value="">--Select--</option> <option value="Original Source">Original Source</option> <option value="Add to Credit">Add to Credit</option> </select> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="field-3" class="control-label">Cancellation Note</label> <input type="text" class="form-control" id="cancelnote" name = "cancelnote"> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button> <button type="button" id="saveCancellation" class="btn btn-info waves-effect waves-light">Submit</button> </div> </div> </div> </form> </div> <script> function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; } </script> <!-- 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> --> --> <!-- Required datatable js --> <script src="plugins/datatables/jquery.dataTables.min.js"></script> <script src="plugins/datatables/dataTables.bootstrap4.min.js"></script> <!-- Buttons examples --> <script src="plugins/datatables/dataTables.buttons.min.js"></script> <script src="plugins/datatables/buttons.bootstrap4.min.js"></script> <script src="plugins/datatables/jszip.min.js"></script> <script src="plugins/datatables/pdfmake.min.js"></script> <script src="plugins/datatables/vfs_fonts.js"></script> <script src="plugins/datatables/buttons.html5.min.js"></script> <script src="plugins/datatables/buttons.print.min.js"></script> <script src="plugins/datatables/buttons.colVis.min.js"></script> <!-- Responsive examples --> <script src="plugins/datatables/dataTables.responsive.min.js"></script> <script src="plugins/datatables/responsive.bootstrap4.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 src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.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 type="text/javascript"> $(document).ready(function() { $('#datatable').DataTable({ ordering:false }); //Buttons examples var table = $('#datatable-buttons').DataTable({ lengthChange: false, buttons: ['copy', 'excel', 'pdf', 'colvis'] }); table.buttons().container() .appendTo('#datatable-buttons_wrapper .col-md-6:eq(0)'); }); $(document).ready(function() { $('#datatable2').DataTable({ ordering:false }); //Buttons examples var table = $('#datatable-buttons').DataTable({ lengthChange: false, buttons: ['copy', 'excel', 'pdf', 'colvis'] }); table.buttons().container() .appendTo('#datatable-buttons_wrapper .col-md-6:eq(0)'); }); $(document).ready(function(){ if (localStorage.getItem("RecordPayment") == "true") { successMessage("Payment Successfully added."); localStorage.setItem("RecordPayment", "false"); } if (localStorage.getItem("CancelInvoice") == "true") { successMessage("Invoice successfully cancelled."); localStorage.setItem("CancelInvoice", "false"); } if (localStorage.getItem("DeletePayment") == "true") { successMessage("Payment successfully deleted."); localStorage.setItem("DeletePayment", "false"); } }) function payAmount(button){ var invoiceId = $(button).val(); var referenceNo = $(button).parent().siblings(':first').html(); var invoiceAmount = $(button).parent().siblings(':nth-child(4)').html(); var paidAmount = $(button).parent().siblings(':nth-child(5)').html(); invoiceAmount = invoiceAmount*1; paidAmount = paidAmount*1; var dueAmount = invoiceAmount - paidAmount; if(dueAmount <= 0){ dueAmount = 0.00; } var companyId = "<?php echo $id; ?>"; $.ajax({ url : "PHP/response.php", data : "action=getAvailableCredit&companyId="+companyId, method : "POST", async : false, success : function(response){ $("#invoiceId").val(invoiceId); $("#referenceId").val(referenceNo); $("#companyId").val(companyId); $("#availableCredit").val(response); $("#dueAmount").val(dueAmount.toFixed(2)); $("#modalRecordPayment").modal("toggle"); }, error : function(err){} }); } function cancelInvoice(button){ swal({ title: 'Are you sure?', text: "Do you really want to cancel this invoice??", type: 'warning', showCancelButton: true, confirmButtonColor: '#4fa7f3', cancelButtonColor: '#d57171', confirmButtonText: "Yes, I'm Sure!" }).then(function () { var invoiceId = $(button).val(); $("#invoiceId1").val(invoiceId); var paidAmount = $(button).parent().siblings(':nth-child(5)').html(); paidAmount = paidAmount*1; if(paidAmount > 0){ $("#divRefundMode").css({"display":"block"}); } var companyId = "<?php echo $id; ?>"; $("#companyId1").val(companyId); $("#paidAmountInput").val(paidAmount); $("#cancelInvoiceModal").modal("toggle"); // var referenceNo = $(button).parent().siblings(':first').html(); }); } function deletePayment(button){ var paymentId = $(button).val(); swal({ title: 'Are you sure?', text: "Do you really want to delete this payment??", type: 'warning', showCancelButton: true, confirmButtonColor: '#4fa7f3', cancelButtonColor: '#d57171', confirmButtonText: "Yes, I'm Sure!" }).then(function () { $.ajax({ url : "PHP/response.php", data : "action=deletePayment&paymentId="+paymentId, method : "POST", async : false, success : function(response){ if(response.trim() == "DELETED"){ localStorage.setItem("DeletePayment", "true"); location.reload(); } else{ errorMessage("ERROR-"+response); } }, error: function(xhr, ajaxOptions, thrownError){ errorToast("Error-"+xhr.status); }, }); }); } $("#saveCancellation").click(function(){ $paidAmountInput = $("#paidAmountInput").val(); $paidAmountInput = $paidAmountInput * 1; if($("#cancelnote").val() == ""){ errorToast("Please enter cancellation notes"); } else if(($paidAmountInput > 0) && ($("#refundMode").val() == "")){ errorToast("Please select refund mode"); } else{ // alert("ok"); $.ajax({ url : "PHP/response.php", data : $("#cancelInvoiceForm").serialize()+"&action=cancelInvoice&createdBy=<?php echo $_SESSION["login_email"]; ?>&sourceId=<?php echo $source_id; ?>", method : "POST", async : false, success : function(response){ if(response.trim() == "SUCCESS"){ localStorage.setItem("CancelInvoice", "true"); location.reload(); } else{ errorMessage("ERROR-"+response); } }, error: function(xhr, ajaxOptions, thrownError){ errorToast("Error-"+xhr.status); }, }); } }); $("#btnRecordPayment").click(function(){ $.ajax({ url : "PHP/response.php", data : $("#formRecordPayment").serialize()+"&action=recordPayment&createdBy=<?php echo $_SESSION["login_email"]; ?>&sourceId=<?php echo $source_id; ?>", method : "POST", async : false, success : function(response){ if(response.trim() === "SUCCESS"){ localStorage.setItem("RecordPayment", "true"); location.reload(); } else{ errorMessage("Payment could not be added.."); } }, error : function(err){} }); }); 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' }); } $(document).ready(function() { $("#payment_date").datepicker({ dateFormat: 'dd MM yy' }); $("#payment_date").datepicker("setDate", new Date()); }); </script> </body> </html>