D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
purchase-order-copy.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $login = $_SESSION['login_email']; if($login == ''){ echo '<script>location.replace("index.php")</script>'; } if(isset($_SESSION["source_id"])){ $source_id = $_SESSION['source_id']; } function getReceivedAmount($conn, $po_id){ $amount = 0.00; $sqlGetPaidAmount = "SELECT `amount` FROM `purchase_order_payments` WHERE `po_no` = '$po_id' AND `transaction_type` = 'Credit'"; $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; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; 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"> <style> #datatable td:nth-child(6){ width:100px !important; } iframe#poFileDisplay img{ width:100% !important; } </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">Purchase Order </h4> <ol class="breadcrumb float-right"> <li class="breadcrumb-item"><a href="#">Purchase Order</a></li> <li class="breadcrumb-item active">Manage Purchase Order </li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <div class="row"> <div class="col-sm-12"> <div class="card-box table-responsive"> <table id="datatable" class="table table-bordered"> <thead> <tr class="theme-bg"> <th>Purchase Order Id</th> <th>Bill Pay Name</th> <th>Order Date</th> <th>Total Amount</th> <th>Payment Status</th> <th>Supporting Docs</th> <th class="text-center">Actions</th> </tr> </thead> <tbody> <?php $sql = "SELECT * FROM `purchase_order` where data_delete != 'yes' order by id desc"; $result = mysqli_query($conn,$sql); while( $row = mysqli_fetch_array($result)){ $row_id = $row['id']; $helping_id = $row['manufacturer']; $supporting_documents = $row['supporting_documents']; $get_bpn = mysqli_query($conn,"SELECT * FROM `manufacturer` where id='$helping_id'"); $get_bpn_row = mysqli_fetch_assoc($get_bpn); $manufacturer_id = $get_bpn_row['id']; $manufacturer_display_name = $get_bpn_row['manufacturer_display_name']; $manufacturer_currency = $get_bpn_row["currency"]; $paidAmount = getReceivedAmount($conn, $row['po_id']); if($row['amount_paind'] <= $paidAmount){ $status = "<a class='btn btn-success btn-xs'>Paid</a>"; }else if($row['amount_paind'] > $paidAmount && $paidAmount > 0){ $status = "<a class='btn btn-primary btn-xs'>Partial Paid</a>"; }else{ if(strtotime($row['order_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 class="gradeX" style='font-size:13px'> <td><?php echo $row['po_id']; ?></td> <td><?php echo $manufacturer_display_name; ?></td> <td><?php echo $row['order_date']; ?></td> <td><?php echo $row['amount_paind']; ?></td> <td class="text-center"><?php echo $status; ?></td> <td> <?php if(!empty($supporting_documents)){ $myArray = explode(',', $supporting_documents); foreach ( $myArray as $key ) { // echo $key; $kaboom1 = explode( ".", $key ); $fileExt1 = end( $kaboom1 ); if($fileExt1== 'jpg'||$fileExt1== 'jpeg'||$fileExt1== 'JPG'||$fileExt1== 'JPEG'||$fileExt1== 'png'||$fileExt1== 'PNG'){ ?> <a href="" class="button showSupportingDocFile" data-po-id="<?php echo $row['po_id'];?>" data-file-name="<?php echo "po-supporting-files/".$key;?>"><img src="images/img-icon.png" class="sDoc"></a> <?php } if($fileExt1== 'pdf'||$fileExt1== 'PDF'){ ?> <a href="" class="button showSupportingDocFile" data-po-id="<?php echo $row['po_id'];?>" data-file-name="<?php echo "po-supporting-files/".$key;?>"><img src="images/pdf-icon.png" class="sDoc"></a> <?php } } } ?> </td> <td class="text-center"> <button type="button" data-toggle="tooltip" data-placement="top" title="" data-original-title="Pay" manufacturer_currency="<?php echo $manufacturer_currency;?>" po-proforma-id="<?php echo $row['proforma_id'];?>" onclick="payAmount(this, '<?php echo $helping_id;?>')" value="<?php echo $row_id;?>" class="btn btn-xs btn-success"><i class="fa fa-credit-card"></i></button> <a href="view-purchase-order.php?id=<?php echo $row['id'] ?>" class="btn btn-xs btn-info" data-toggle="tooltip" data-placement="top" title="" data-original-title="View"><i class="fa fa-eye"></i></a> <a href="print-purchase.php?id=<?php echo $row['id'] ?>" target="blank" class="btn btn-xs btn-warning" data-toggle="tooltip" data-placement="top" title="" data-original-title="Print"><i class="fa fa-print"></i></a> </td> </tr> <?php } ?> </tbody> </table> </div> </div> <!-- end: page --> </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">Add Payment for <span class="poIds text-success"></span></h4> </div> <div class="modal-body"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="field-3" class="control-label">PO Amount <span class="text-danger"><small>( in <span class="manufacturer_currency"></span> )</small></span></label> <input type="text" class="form-control" id="po_amt" name = "po_amt" readonly> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="field-6" class="control-label">Amount <span class="text-danger"><small>( in <span class="manufacturer_currency"></span> )</small></span></label> <input type="number" min="0" class="form-control" id="pay_amt" name ="pay_amt" placeholder="amount" required> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="exampleInputPassword1">Payment Mode</label> <select class="form-control" id="payment_mode" name="payment_mode" required> <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 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> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="field-7" class="control-label">Remark</label> <input type="text" class="form-control" id="remark" name="remark" placeholder="Remark"> </div> </div> </div> </div> <div class="modal-footer"> <input type="hidden" class="form-control" id="manufacturer_id" name ="manufacturer_id"> <input type="hidden" class="form-control" id="po_no" name ="po_no"> <input type="hidden" class="form-control" id="po_row_id" name ="po_row_id"> <input type="hidden" class="form-control" id="po_proforma_id" name ="po_proforma_id"> <input type="hidden" class="form-control" id="details_payment_amount" name ="details_payment_amount"> <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 class="modal fade" id="myModalPoFilesDisplay"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header"> <h4 class="modal-title">Upload Supporting Documents for PO <b><span class="text-success po_idz"></span></b> </h4> <button type="button" class="close" data-dismiss="modal">×</button> </div> <!-- Modal body --> <div class="modal-body"> <iframe id="poFileDisplay" title="webviewer" frameborder="0" style="width:100%;min-height:450px;"></iframe> <!--<img src="" style="width:100%" id="poFileDisplay">--> </div> <!-- Modal footer --> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div> </div> </div> </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-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> <!-- 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 type="text/javascript"> function payAmount(button, companyId){ var manufacturer_id=companyId; var po_row_id = $(button).val(); var po_no = $(button).parent().siblings(':nth-child(1)').html(); var po_amt = $(button).parent().siblings(':nth-child(4)').html(); var po_proforma_id=$(button).attr("po-proforma-id"); var manufacturer_currency=$(button).attr("manufacturer_currency"); //alert(po_proforma_id); $(".manufacturer_currency").html(manufacturer_currency); $(".poIds").html(po_no); $("#po_amt").val(po_amt); $("#details_payment_amount").val(po_amt); $("#manufacturer_id").val(manufacturer_id); $("#po_no").val(po_no); $("#po_row_id").val(po_row_id); $("#po_proforma_id").val(po_proforma_id); $("#modalRecordPayment").modal("toggle"); //alert(manufacturer_id +" " + " " + po_no + " " + po_amt + " " + po_row_id); // alert(manuf_id " " + " " + po_id + " " + po_amt + " " + companyId) // var paidAmount = getPaidAmount(referenceNo); // invoiceAmount = invoiceAmount*1; // paidAmount = paidAmount*1; // var dueAmount = invoiceAmount - paidAmount; // if(dueAmount <= 0){ // dueAmount = 0.00; // } // $.ajax({ // url : "PHP/response.php", // data : "action=getAvailableCredit&companyId="+companyId, // method : "POST", // async : false, // success : function(response){ // $("#invoiceId").val(invoiceId); // $("#referenceId").val(referenceNo); // $("#invoice_referenceId").val(invoice_referenceId); // $("#companyId").val(companyId); // $("#availableCredit").val(response); // $("#dueAmount").val(dueAmount.toFixed(2)); // $("#modalRecordPayment").modal("toggle"); // }, // error : function(err){} // }); } $("#btnRecordPayment").click(function(){ var pay_amt = $("#pay_amt").val(); var payment_mode = $("#payment_mode").val(); var remark = $("#remark").val(); if( pay_amt.length > 0 && payment_mode.length > 0 && remark.length > 0 ){ $('#pay_amt').css('border-color', '#dadada'); $('#payment_mode').css('border', '1px solid #dadada'); $('#remark').css('border-color', '#dadada'); $.ajax({ url : "PHP/response.php", data : $("#formRecordPayment").serialize()+"&action=recordPoPayment&createdBy=<?php echo $_SESSION["login_email"]; ?>&sourceId=<?php echo $source_id; ?>", method : "POST", async : false, success : function(response){ if(response == 1){ localStorage.setItem("PaymentAdded", "true"); location.reload(); } else{ errorMessage("payment could not be saved"); } }, error : function(err){} }); }else{ if(pay_amt.length== 0){ $('#pay_amt').css('border-color', 'red'); }else{ $('#pay_amt').css('border-color', '#dadada'); } if(payment_mode.length== 0){ $('#payment_mode').css('border', '1px solid red'); }else{ $('#payment_mode').css('border', '1px solid #dadada'); } if(remark.length== 0){ $('#remark').css('border-color', 'red'); }else{ $('#remark').css('border-color', '#dadada'); } } // if((pay_amt=='') && (payment_mode=='') && (remark=='')){ // alert("fdf"); // $('#pay_amt').css('border-color', 'red'); // $('#payment_mode').css('border-color', 'red'); // $('#remark').css('border-color', 'red'); // $("#pay_amt").focus(); // exit; // }else{ // $('#pay_amt').css('border-color', ''); // $('#payment_mode').css('border-color', ''); // $('#remark').css('border-color', ''); // $.ajax({ // url : "PHP/response.php", // data : $("#formRecordPayment").serialize()+"&action=recordPoPayment&createdBy=<?php echo $_SESSION["login_email"]; ?>&sourceId=<?php echo $source_id; ?>", // method : "POST", // async : false, // success : function(response){ // if(response == 1){ // localStorage.setItem("PaymentAdded", "true"); // location.reload(); // } // else{ // errorMessage("payment could not be saved"); // } // }, // error : function(err){} // }); // } }); $(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(){ if (localStorage.getItem("poInserted") == "true") { successMessage("Purchase Order Successfully Created."); localStorage.setItem("poInserted", "false"); } if (localStorage.getItem("deletePurchase") == "true") { successMessage("Purchase Order Successfully Deleted."); localStorage.setItem("deletePurchase", "false"); } if (localStorage.getItem("PaymentAdded") == "true") { successMessage("Payment Successfully Saved."); localStorage.setItem("PaymentAdded", "false"); } }); 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()); }); $("#datatable").on("click",".showSupportingDocFile",function(e){ e.preventDefault(); var data_file_name = $(this).attr("data-file-name"); var data_po_id = $(this).attr("data-po-id"); if(data_file_name){ // alert(data_po_id); $('.po_idz').html("( " + data_po_id + " )"); // $('#poFileDisplay').attr('src', data_file_name); // $('#poFileDisplay').attr('src', "https://docs.google.com/viewer?url=https://urbane.createerp.com/"+data_file_name+"&embedded=true"); $('#poFileDisplay').attr('src', "https://urbane.createerp.com/"+data_file_name); $('#myModalPoFilesDisplay').modal('show'); $('#myModalPoFilesDisplay').modal({ backdrop: 'static', keyboard: false }); } }); </script> </body> </html>