| Server IP : 14.225.204.176 / Your IP : 216.73.216.252 Web Server : nginx/1.24.0 System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64 User : root ( 0) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/php/thanhphuong/resources/views/return_purchase/ |
Upload File : |
@extends('layout.main') @section('content')
@if(session()->has('message'))
<div class="alert alert-success alert-dismissible text-center"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>{{ session()->get('message') }}</div>
@endif
@if(session()->has('not_permitted'))
<div class="alert alert-danger alert-dismissible text-center"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>{{ session()->get('not_permitted') }}</div>
@endif
<section>
<div class="container-fluid">
@if(in_array("purchase-return-add", $all_permission))
<a href="{{route('return-purchase.create')}}" class="btn btn-info"><i class="dripicons-plus"></i> {{trans('file.Add Lend')}}</a>
@endif
</div>
{!! Form::open(['route' => 'return-purchase.index', 'method' => 'get']) !!}
<div class="col-md-6 offset-md-3 mt-4">
<div class="form-group row">
<label class="d-tc mt-2"><strong>{{trans('file.Choose Your Date')}}</strong> </label>
<div class="d-tc">
<div class="input-group">
<input type="text" id="daterangepicker-change-date" class="daterangepicker-field form-control" value="{{date('d-m-Y', strtotime($start_date))}} To {{date('d-m-Y', strtotime($end_date))}}" required />
<input type="hidden" id="start_date" name="start_date" value="{{$start_date}}" />
<input type="hidden" id="end_date" name="end_date" value="{{$end_date}}" />
<div class="input-group-append">
<button class="btn btn-primary" type="submit">{{trans('file.submit')}}</button>
</div>
</div>
</div>
</div>
</div>
{{Form::close()}}
<div class="table-responsive">
<table id="purchase-table" class="table purchase-list" style="width: 100%">
<thead>
<tr>
<th class="text-center not-exported"></th>
<th class="text-center">{{trans('file.Date')}}</th>
<th class="text-center">{{trans('file.Inventory Receiving Voucher')}}</th>
<th class="text-center">{{trans('file.Supplier')}}</th>
<th class="text-center">{{trans('file.Item Code')}}</th>
<th class="text-center">{{trans('file.Item Name')}}</th>
<th class="text-center">{{trans('file.Quantity')}}</th>
<th class="text-center">{{trans('file.Total Amount')}}</th>
<th class="text-center">{{trans('file.Serial Number')}}</th>
<th class="text-center">{{trans('file.Lot Number')}}</th>
<th class="text-center">{{trans('file.Batch Number')}}</th>
<th class="text-center">{{trans('file.TR Number')}}</th>
<th class="text-center">{{trans('file.OC Number')}}</th>
<th class="text-center">{{trans('file.Lend Status')}}</th>
<th class="text-center not-exported">{{trans('file.action')}}</th>
</tr>
</thead>
<tfoot class="tfoot active">
<th></th>
<th>{{trans('file.Total')}}</th>
<th class="text-center" colspan="5"></th>
<th class="text-right"></th>
<th colspan="7"></th>
</tfoot>
</table>
</div>
</section>
<div id="purchase-details" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" class="modal fade text-left">
<div role="document" class="modal-dialog">
<div style="border: none" class="modal-content">
<div class="container mt-3">
<div class="row">
<div class="col-md-1">
<button id="print-btn" type="button" class="btn btn-default btn-sm d-print-none"><i class="dripicons-print"></i> {{trans('file.Print')}}</button>
</div>
<div class="col-md-10" id="invoice-title"></div>
<div class="col-md-1">
<button type="button" id="close-btn" data-dismiss="modal" aria-label="Close" class="close d-print-none"><span aria-hidden="true"><i class="dripicons-cross"></i></span></button>
</div>
</div>
</div>
<div id="purchase-content" class="modal-body"></div>
<div class="ml-2 mr-2" id="border-print">
<table class="table table-bordered product-purchase-list">
<thead>
<th class="text-center">STT</th>
<th class="text-center">{{trans('file.product')}}</th>
<th class="text-center">{{trans('file.Code')}}</th>
<th class="text-center">{{trans('file.Quantity')}}</th>
<th class="text-center">{{trans('file.Unit')}}</th>
<th class="text-center">{{trans('file.Unit Cost')}}</th>
<th class="text-center">{{trans('file.Tax')}} VAT</th>
<th class="text-center">{{trans('file.Tax Import')}}</th>
<th class="text-center">{{trans('file.Allocation Costs')}}</th>
<th class="text-center">{{trans('file.Subtotal')}}</th>
</thead>
<tbody>
</tbody>
</table>
</div>
<div id="purchase-footer" class="modal-body"></div>
</div>
</div>
</div>
<script type="text/javascript">
$("ul#inventory").siblings('a').attr('aria-expanded','true');
$("ul#inventory").addClass("show");
$("ul#return").siblings('a').attr('aria-expanded','true');
$("ul#return").addClass("show");
$("ul#return #purchase-return-menu").addClass("active");
$("table").css({ "color": "#000000" });
$("th").css({ "border": "1px solid #333333", "text-align": "center" });
$("td").css({ "border": "1px solid #333333" });
var public_key = <?php echo json_encode($lims_pos_setting_data->stripe_public_key) ?>;
var all_permission = <?php echo json_encode($all_permission) ?>;
var purchase_id = [];
var user_verified = <?php echo json_encode(env('USER_VERIFIED')) ?>;
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
function confirmDelete() {
if (confirm("Are you sure want to delete?")) {
return true;
}
return false;
}
function confirmDeletePayment() {
if (confirm("Are you sure want to delete? If you delete this money will be refunded")) {
return true;
}
return false;
}
$(document).on("click", "tr.purchase-link td:not(:first-child, :last-child)", function(){
var purchase = $(this).parent().data('purchase');
purchaseDetails(purchase);
});
$(document).on("click", ".view", function(){
var purchase = $(this).parent().parent().parent().parent().parent().data('purchase');
purchaseDetails(purchase);
});
$("#print-btn").on("click", function(){
var divToPrint=document.getElementById('purchase-details');
var newWin=window.open('','Print-Window');
newWin.document.open();
newWin.document.write('<link rel="stylesheet" href="<?php echo asset('public/vendor/bootstrap/css/bootstrap.min.css') ?>" type="text/css"><style type="text/css">@media print {.modal-dialog { max-width: 1200px;} .product-purchase-list th { border: 1px solid #333333 !important; } .product-purchase-list td { border: 1px solid #333333 !important; } }</style><body onload="window.print()">'+divToPrint.innerHTML+'</body>');
newWin.document.close();
setTimeout(function(){
newWin.close();
},10);
});
$('#purchase-table').DataTable( {
"processing": true,
"serverSide": true,
"ajax":{
url:"return-purchase/purchase-data",
data:{
all_permission: all_permission,
start_date: $('#start_date').val(),
end_date: $('#end_date').val()
},
dataType: "json",
type:"post",
/*success:function(data){
console.log(data);
}*/
},
"createdRow": function( row, data, dataIndex ) {
$(row).addClass('purchase-link');
$(row).attr('data-purchase', data['purchase']);
$('td', row).css( "border", "1px solid #333333" );
},
"columns": [
{"data": "key", "className": "text-center"},
{"data": "date", "className": "text-center"},
{"data": "inventory_receiving_voucher"},
{"data": "supplier"},
{"data": "product_code"},
{"data": "product_name"},
{"data": "quantity", "className": "text-right"},
{"data": "grand_total", "className": "text-right"},
{"data": "serial_number"},
{"data": "lot_number"},
{"data": "batch_number"},
{"data": "tr_number"},
{"data": "oc_number"},
{"data": "purchase_status", "className": "text-right"},
{"data": "options", "className": "text-right"}
],
'language': {
/*'searchPlaceholder': "{{trans('file.Type date or purchase reference...')}}",*/
'lengthMenu': '_MENU_ {{trans("file.records per page")}}',
"info": '<small>{{trans("file.Showing")}} _START_ - _END_ (_TOTAL_)</small>',
"search": '{{trans("file.Search")}}',
'paginate': {
'previous': '<i class="dripicons-chevron-left"></i>',
'next': '<i class="dripicons-chevron-right"></i>'
}
},
order:[['1', 'desc']],
'columnDefs': [
{
"orderable": false,
'targets': [0, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14]
},
{
'render': function(data, type, row, meta){
if(type === 'display'){
data = '<div class="checkbox"><input type="checkbox" class="dt-checkboxes"><label></label></div>';
}
return data;
},
'checkboxes': {
'selectRow': true,
'selectAllRender': '<div class="checkbox"><input type="checkbox" class="dt-checkboxes"><label></label></div>'
},
'targets': [0]
}
],
'select': { style: 'multi', selector: 'td:first-child'},
'lengthMenu': [[10, 25, 50, -1], [10, 25, 50, "All"]],
dom: '<"row"lfB>rtip',
buttons: [
{
extend: 'pdf',
text: '{{trans("file.PDF")}}',
exportOptions: {
columns: ':visible:Not(.not-exported)',
rows: ':visible'
},
action: function(e, dt, button, config) {
datatable_sum(dt, true);
$.fn.dataTable.ext.buttons.pdfHtml5.action.call(this, e, dt, button, config);
datatable_sum(dt, false);
},
footer:true
},
{
extend: 'csv',
charset: 'UTF-8',
bom: true,
text: '{{trans("file.CSV")}}',
exportOptions: {
columns: ':visible:not(.not-exported)',
rows: ':visible',
format: {
body: function(data, row, column, node) {
if (column === 3 || column === 4 || column === 5 || column === 7 || column === 8 || column === 9 || column === 10 || column === 11) {
return data.replace(/<br>/g, '\n');
}
if(column === 12){
if(data.indexOf('Đã nhận hàng') !== -1){
return data = "Đã nhận hàng"
}
if(data.indexOf('Một phần') !== -1){
return data = "Một phần"
}
if(data.indexOf('Đang chờ xử lý') !== -1){
return data = "Đang chờ xử lý"
}
if(data.indexOf('Đặt hàng') !== -1){
return data = "Đặt hàng"
}
}
return data;
}
}
},
action: function(e, dt, button, config) {
datatable_sum(dt, true);
$.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, button, config);
datatable_sum(dt, false);
},
footer:true
},
{
extend: 'print',
text: '{{trans("file.Print")}}',
messageTop: function(){
return `
<div>
<div style="display:flex;justify-content: center">
<div style="padding-right: 15px">
<img src="{{url('public/logo', $general_setting->site_logo)}}" width="65">
</div>
<div>
<h4 style="text-align:left;color:red;">{{trans('file.Company name system')}}</h4>
<p style="text-align:left;color:red;">{{trans('file.Company address system')}}</p>
</div>
</div>
<div style="text-align:center;">
<h3 style="text-transform: uppercase" class="modal-title text-center container-fluid">{{trans('file.Lend List')}}</h3>
</div>
</div>
`;
},
exportOptions: {
columns: ':visible:not(.not-exported)',
rows: ':visible',
stripHtml: false
},
customize: function ( doc ) {
$(doc.document.body).find('table td').css('border', '1px solid #333333');
$(doc.document.body).find('table th').css({'border': '1px solid #333333', "text-align": "center"});;
$(doc.document.body).find('table td:nth-child(1)').css('text-align', 'center');
$(doc.document.body).find('table td:nth-child(5), table td:nth-child(6), table td:nth-child(13)').css('text-align', 'right');
},
action: function(e, dt, button, config) {
datatable_sum(dt, true);
$.fn.dataTable.ext.buttons.print.action.call(this, e, dt, button, config);
datatable_sum(dt, false);
},
footer:true
},
{
text: '{{trans("file.delete")}}',
className: 'buttons-delete',
action: function ( e, dt, node, config ) {
if(user_verified == '1') {
purchase_id.length = 0;
$(':checkbox:checked').each(function(i){
if(i){
var purchase = $(this).closest('tr').data('purchase');
purchase_id[i-1] = purchase[3];
}
});
if(purchase_id.length && confirm("Are you sure want to delete?")) {
$.ajax({
type:'POST',
url:'purchases/deletebyselection',
data:{
purchaseIdArray: purchase_id
},
success:function(data) {
dt.rows({ page: 'current', selected: true }).deselect();
dt.rows({ page: 'current', selected: true }).remove().draw(false);
}
});
}
else if(!purchase_id.length)
alert('Nothing is selected!');
}
else
alert('This feature is disable for demo!');
}
},
{
extend: 'colvis',
text: '{{trans("file.Column visibility")}}',
columns: ':gt(0)'
},
],
drawCallback: function () {
var api = this.api();
datatable_sum(api, false);
}
} );
function datatable_sum(dt_selector, is_calling_first) {
if (dt_selector.rows( '.selected' ).any() && is_calling_first) {
var rows = dt_selector.rows( '.selected' ).indexes();
var column7Sum = 0;
dt_selector.cells( rows, 7, { page: 'current' }).data().each(function(value) {
column7Sum += parseFloat(value.replace(/\./g, ""));
});
$( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
}
else {
var column7Sum = 0;
dt_selector.column(7, { page: 'current' }).data().each(function(value) {
column7Sum += parseFloat(value.replace(/\./g, ""));
});
$( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
}
}
function purchaseDetails(purchase){
var report_title = `
<div style="display:flex;justify-content: center; text-align:center">
<div>
<div id="report-logo" style="padding-top:3px;">
<img src="{{url('public/logo', $general_setting->site_logo)}}" width="65">
</div>
</div>
<div>
<div id="report-title" style="text-align:left; color:red; font-size: 0.75em; padding-bottom:8px;">
<h4 id="exampleModalLabel" class="modal-title text-center container-fluid">{{trans('file.Company name system')}}</h4>
</div>
<div id="report-address" style="text-align:left; color:red; font-size: 0.75em; padding-bottom:8px;">
<div class="modal-title text-center container-fluid">{{trans('file.Company address system')}}</div>
</div>
</div>
</div>
<div style="text-align:center;">
<div id="report-content" style="padding-bottom:8px; padding-top:8px;">
<h4 style="text-transform: uppercase" class="modal-title text-center container-fluid">{{trans('file.Lend Report')}}</h4>
</div>
<div class="col-md-12 text-center" style="padding-bottom:8px;">
<i style="font-size: 15px;">{{trans('file.Lend Details')}}</i>
</div>
</div>
`
var htmltext = '';
htmltext += '<strong>{{trans("file.Date")}}: </strong>'+purchase[0]
purchase[29] != "" ? htmltext += '<br><strong>{{trans("file.OC Number")}}: </strong>'+ purchase[29].split(', ')[0].trim() : ""
purchase[28] != "" ? htmltext += '<br><strong>{{trans("file.Invoice Number")}}: </strong>'+ purchase[28].split(', ')[0].trim() : ""
purchase[27] != "" ? htmltext += '<br><strong>{{trans("file.TR Number")}}: </strong>'+ purchase[27].split(', ')[0].trim() : ""
htmltext += '<br><strong>{{trans("file.Supplier")}}: </strong>'+ purchase[8]
htmltext += '<br><strong>{{trans("file.Warehouse")}}: </strong>'+ purchase[4]
$.get('purchases/product_purchase/' + purchase[3], function(data){
$(".product-purchase-list tbody").remove();
var product_name = data[0];
var qty = data[1];
var unit_code = data[2];
var tax = data[3];
var tax_rate = data[4];
//var discount = data[5];
var subtotal = data[6];
var tax_import = data[7];
var unit_price = data[8];
var allocation = data[9];
var product_code = data[10];
var newBody = $("<tbody>");
$.each(product_name, function(index){
var newRow = $("<tr>");
var cols = '';
cols += '<td class="text-center">' + (index+1) + '</td>';
cols += '<td>' + product_name[index] + '</td>';
cols += '<td>' + product_code[index] + '</td>';
cols += '<td class="text-center">' + qty[index] + '</td>';
cols += '<td class="text-center">' + unit_code[index] + '</td>';
cols += '<td class="text-right">' + (unit_price[index]).toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
cols += '<td class="text-right">' + tax[index].toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '(' + tax_rate[index] + '%)' + '</td>';
//cols += '<td class="text-right">' + discount[index].toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
if( !tax_import[index] ){
cols += '<td class="text-right">' + 0 + '</td>';
} else {
cols += '<td class="text-right">' + parseFloat(tax_import[index]).toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
}
if( !allocation[index] ){
cols += '<td class="text-right">' + 0 + '</td>';
} else {
cols += '<td class="text-right">' + parseFloat(allocation[index]).toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
}
cols += '<td class="text-right">' + subtotal[index].toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
newRow.append(cols);
newBody.append(newRow);
});
var newRow = $("<tr>");
cols = '';
cols += '<td colspan=6><strong>{{trans("file.Total")}}:</strong></td>';
cols += '<td class="text-right">' + purchase[13].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
//cols += '<td class="text-right">' + purchase[14].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
if(!purchase[25]){
cols += '<td class="text-right">' + 0 + '</td>';
} else {
cols += '<td class="text-right">' + purchase[25].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
}
if(!purchase[26]){
cols += '<td class="text-right">' + 0 + '</td>';
} else {
cols += '<td class="text-right">' + purchase[26].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
}
cols += '<td class="text-right">' + purchase[15].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
newRow.append(cols);
newBody.append(newRow);
if(purchase[16] != 0){
var newRow = $("<tr>");
cols = '';
cols += '<td colspan=9><strong>{{trans("file.Order Tax")}}:</strong></td>';
cols += '<td class="text-right">' + purchase[16].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '(' + purchase[17] + '%)' + '</td>';
newRow.append(cols);
newBody.append(newRow);
}
if(purchase[18] != 0){
var newRow = $("<tr>");
cols = '';
cols += '<td colspan=9><strong>{{trans("file.Order Discount")}}:</strong></td>';
cols += '<td class="text-right">' + ( purchase[18] == '' ? 0 : purchase[18].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") ) + '</td>';
newRow.append(cols);
newBody.append(newRow);
}
if(purchase[19] != 0){
var newRow = $("<tr>");
cols = '';
cols += '<td colspan=9><strong>{{trans("file.Shipping Cost")}}:</strong></td>';
cols += '<td class="text-right">' + ( purchase[19] == '' ? 0 : purchase[19].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") ) + '</td>';
newRow.append(cols);
newBody.append(newRow);
}
var newRow = $("<tr>");
cols = '';
cols += '<td colspan=9><strong>{{trans("file.grand total")}}:</strong></td>';
cols += '<td class="text-right">' + purchase[20].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.") + '</td>';
newRow.append(cols);
newBody.append(newRow);
$("table.product-purchase-list").append(newBody);
$(".product-purchase-list td" ).css({ "border": "1px solid #333333" });
});
var htmlfooter = '<p><strong>{{trans("file.Note")}}:</strong> '+purchase[22]+'</p><strong>{{trans("file.Created By")}}:</strong><br>'+purchase[23]+'<br>'+purchase[24];
$('#invoice-title').html(report_title);
$('#purchase-content').html(htmltext);
$('#purchase-footer').html(htmlfooter);
$('#purchase-details').modal('show');
}
if(all_permission.indexOf("purchases-delete") == -1)
$('.buttons-delete').addClass('d-none');
if(all_permission.indexOf("purchases-delete") == -1)
$('.buttons-delete').addClass('d-none');
$(".daterangepicker-field").daterangepicker({
callback: function(startDate, endDate, period){
var start_date = startDate.format('YYYY-MM-DD');
var end_date = endDate.format('YYYY-MM-DD');
var display_start_date = startDate.format('DD-MM-YYYY');
var display_end_date = endDate.format('DD-MM-YYYY');
var title = display_start_date + ' To ' + display_end_date;
$(this).val(title);
$('input[name="start_date"]').val(start_date);
$('input[name="end_date"]').val(end_date);
}
});
$('#daterangepicker-change-date').on("change", function(){
var date_value = $(this).val();
var arrDate = (date_value.trim()).split("To")
var start = arrDate[0].trim().split("-")
var end = arrDate[1].trim().split("-")
var start_date = start[2] + '-' + start[1] + '-' + start[0]
var end_date = end[2] + '-' + end[1] + '-' + end[0]
$('input[name="start_date"]').val(start_date);
$('input[name="end_date"]').val(end_date);
});
</script>
@endsection