403Webshell
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/report/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/php/thanhphuong/resources/views/report/warehouse_report.blade.php
@extends('layout.main') @section('content')
<section class="forms">
    <div class="container-fluid">
        <div class="card">
            <div class="card-header mt-2">             
                <div id="text-center">
                    <h3 class="text-center">{{trans('file.Sale Warehouse Report')}}</h3>
                </div>
            </div>
            {!! Form::open(['route' => 'report.warehouse', 'method' => 'post']) !!}
            <div class="row mb-3">
                <div class="col-md-3 offset-md-1 mt-3">
                    <label class="d-tc mt-2"><strong>{{trans('file.Choose Your Date')}}</strong> &nbsp;</label>
                    <div class="form-group row">
                        <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" name="start_date" value="{{$start_date}}" />
                                <input type="hidden" name="end_date" value="{{$end_date}}" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-6 mt-3">
                    <label class="d-tc mt-2"><strong>{{trans('file.Choose Warehouse')}}</strong> &nbsp;</label>
                    <div class="form-group row">
                        <div class="d-tc col-md-11">
                            <input type="hidden" name="warehouse_id_hidden" value="{{$warehouse_id}}" />
                            <select id="warehouse_id" name="warehouse_id" class="form-control-select2" style="width: 100%;">
                                <option value="0">{{trans('file.All Warehouse')}}</option>
                                @foreach($lims_warehouse_list as $warehouse)
                                <option value="{{$warehouse->id}}">{{$warehouse->name}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-md-2 mt-4">
                    <div class="form-group mt-4">
                        <button class="btn btn-primary" type="submit">{{trans('file.submit')}}</button>
                    </div>
                </div>
            </div>
            <input type="hidden" name="warehouse_id_hidden" value="{{$warehouse_id}}" />
            {!! Form::close() !!}

    
        </div>
    </div>
    <ul class="nav nav-tabs ml-4 mt-3" role="tablist">
      <li class="nav-item">
        <a class="nav-link active" href="#warehouse-sale" role="tab" data-toggle="tab">{{trans('file.Sale')}}</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#warehouse-purchase" role="tab" data-toggle="tab">{{trans('file.Purchase')}}</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#warehouse-return" role="tab" data-toggle="tab">{{trans('file.return')}}</a>
      </li>      
    </ul>

    <div class="tab-content">
        <div role="tabpanel" class="tab-pane fade show active" id="warehouse-sale">
            <div class="table-responsive mb-4">
                <table id="sale-table" class="table table-hover">
                    <thead>
                        <tr>
                            <th class="not-exported-sale"></th>
                            <th>{{trans('file.Date')}}</th>
                            <th>{{trans('file.Biller')}}</th>
                            <th>{{trans('file.customer')}}</th>
                            <th>{{trans('file.Code')}}</th>
                            <th>{{trans('file.product')}}</th>
                            <th>{{trans('file.Unit')}}</th>
                            <th>{{trans('file.Quantity')}}</th>
                            <th>{{trans('file.Unit Price')}}</th>
                            <th>{{trans('file.grand total')}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($lims_sale_data as $key=>$sale)
                            @foreach($lims_product_sale_data[$key] as $idx=>$product_sale_data)
                                <?php 
                                $product_variant = "";
                                    $product = App\Product::select('id', 'name', "code")->find($product_sale_data->product_id);
                                    $productName = "";
                                    $productCode = "";
                                    if($product) {
                                        $productName = $product->name;
                                        $productCode = $product->code;
                                    }
                                    if($product_sale_data->variant_id) {
                                        $variant = App\Variant::find($product_sale_data->variant_id);
                                        $productName = $variant->name;    
                                        $product_variant = App\ProductVariant::FindExactProduct($product->id, $variant->id)->first();
                                        $productCode = $product_variant->item_code ?? $productName;                                  
                                    }
                                    $unit = App\Unit::find($product_sale_data->sale_unit_id);
                                ?>
                                <tr <?php echo $product_variant  ?>>
                                    <td class="text-center">{{$idx}}</td>
                                    <td class="text-center">{{date($general_setting->date_format, strtotime($sale->created_at->toDateString()))}}</td>
                                   
                                    @if($sale->biller)
                                        <td>{{$sale->biller->name}}</td>
                                    @else
                                        <td></td>
                                    @endif

                                    <td>{{$sale->customer->name}}</td>
                                    
                                    <td class="text-right">{{$productCode}}</td>
                                    <td>{{$productName}}</td>

                                    @if($unit)
                                        <td class="text-center">{{$unit->unit_code}}</td>
                                    @else
                                        <td class="text-center"></td>
                                    @endif

                                    @if($product_sale_data->qty)
                                        <td class="text-center">{{number_format((float)($product_sale_data->qty), 0, '.', '.')}}</td>
                                    @else
                                        <td class="text-center">0</td>
                                    @endif

                                    @if($product_sale_data->net_unit_price)
                                        <td class="text-right">{{number_format((float)($product_sale_data->net_unit_price), 0, '.', '.')}}</td>
                                    @else
                                        <td class="text-right">0</td>
                                    @endif

                                    <td class="text-right">{{number_format((float)($sale->grand_total), 0, '.', '.')}}</td>                      
                                </tr>
                            @endforeach
                        @endforeach
                    </tbody>
                    <tfoot class="tfoot active">
                        <tr>
                            <th></th>
                            <th>Total:</th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th class="text-center">0</th>
                            <th></th>
                            <th class="text-right">0</th>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>

        <div role="tabpanel" class="tab-pane fade" id="warehouse-purchase">
            <div class="table-responsive mb-4">
                <table id="purchase-table" class="table table-hover">
                    <thead>
                        <tr>
                            <th class="not-exported-purchase"></th>
                            <th>{{trans('file.Date')}}</th>
                            <th>{{trans('file.Inventory Receiving Voucher')}}</th>
                            <th>{{trans('file.Supplier')}}</th>
                            <th>{{trans('file.Item Code')}}</th>
                            <th>{{trans('file.Item Name')}}</th>
                            <th>{{trans('file.Unit')}}</th>
                            <th>{{trans('file.Quantity')}}</th>
                            <th>{{trans('file.Unit Price')}}</th>
                            <th>{{trans('file.grand total')}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($lims_purchase_data as $key=>$purchase)
                            @foreach($lims_product_purchase_data[$key] as $idx=>$product_purchase_data)
                                <?php 
                                    $product = App\Product::select('id', 'name', "code")->find($product_purchase_data->product_id);
                                    $productName = "";
                                    $productCode = "";
                                    if($product) {
                                        $productName = $product->name;
                                        $productCode = $product->code;
                                    }
                                    if($product_purchase_data->variant_id) {
                                        $variant = App\Variant::find($product_purchase_data->variant_id);
                                        $productName = $variant->name;
                                        $product_variant = App\ProductVariant::FindExactProduct($product->id, $variant->id)->first();
                                        $productCode = $product_variant->item_code ?? $productName;
                                    }
                                    $unit = App\Unit::find($product_purchase_data->purchase_unit_id);
                                    $unit_price = 0;
                                    if($product_purchase_data->qty){
                                        $unit_price = $product_purchase_data->total / $product_purchase_data->qty;
                                    } 
                                ?>
                                <tr>
                                    <td class="text-center">{{$idx}}</td>
                                    <?php 
                                        $supplier = DB::table('suppliers')->find($purchase->supplier_id);
                                    ?>
                                    <td class="text-center">{{date($general_setting->date_format, strtotime($purchase->created_at->toDateString()))}}</td>
                                    <td>{{$purchase->inventory_receiving_voucher}}</td>
                                    @if($supplier)
                                        <td>{{$supplier->name}}</td>
                                    @else
                                        <td></td>
                                    @endif
                
                                    <td class="text-right">{{$productCode}}</td>
                                    <td>{{$productName}}</td> 

                                    @if($unit)
                                        <td class="text-center">{{$unit->unit_code}}</td>
                                    @else
                                        <td class="text-center"></td>
                                    @endif

                                    @if($product_purchase_data->qty)
                                        <td class="text-center">{{number_format((float)($product_purchase_data->qty), 0, '.', '.')}}</td>
                                    @else
                                        <td class="text-center">0</td>
                                    @endif

                                    <td class="text-right">{{number_format((float)($unit_price), 0, '.', '.')}}</td>
                                    <td class="text-right">{{number_format((float)($product_purchase_data->total), 0, '.', '.')}}</td>
                    
                                </tr> 
                            @endforeach
                        @endforeach
                    </tbody>
                    <tfoot class="tfoot active">
                        <tr>
                            <th></th>
                            <th>Total:</th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th class="text-center">0</th>
                            <th></th>
                            <th class="text-right">0</th>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>

        <div role="tabpanel" class="tab-pane fade" id="warehouse-return">
            <div class="table-responsive mb-4">
                <table id="return-table" class="table table-hover">
                    <thead>
                        <tr>
                            <th class="not-exported-return"></th>
                            <th>{{trans('file.Date')}}</th>
                            <th>{{trans('file.Biller')}}</th>
                            <th>{{trans('file.customer')}}</th>
                            <th>{{trans('file.Code')}}</th>
                            <th>{{trans('file.product')}}</th>
                            <th>{{trans('file.Unit')}}</th>
                            <th>{{trans('file.Quantity')}}</th>
                            <th>{{trans('file.Unit Price')}}</th>
                            <th>{{trans('file.grand total')}}</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($lims_return_data as $key=>$return)
                            @foreach($lims_product_return_data[$key] as $idx=>$product_return_data)
                                <?php 
                                    $product = App\Product::find($product_return_data->product_id);
                                    $productName = "";
                                    $productCode = "";
                                    if($product) {
                                        $productName = $product->name;
                                        $productCode = $product->code;
                                    }
                                    if($product_return_data->variant_id) {
                                        $variant = App\Variant::find($product_return_data->variant_id);
                                        $productName = $variant->name;    
                                        $product_variant = App\ProductVariant::FindExactProduct($product->id, $variant->id)->first();
                                        $productCode = $product_variant->item_code ?? $productName;  
                                    }
                                    $unit = App\Unit::find($product_return_data->sale_unit_id);
                                ?>
                                <tr>
                                    <td class="text-center">{{$idx}}</td>
                                    <td class="text-center">{{date($general_setting->date_format, strtotime($return->created_at->toDateString()))}}</td>
                                    <td>{{$return->biller->name}}</td>
                                    <td>{{$return->customer->name}}</td>
                                    <td class="text-right">{{$productCode}}</td>
                                    <td>{{$productName}}</td>
                                        
                                    @if($unit)
                                        <td class="text-center">{{$unit->unit_code}}</td>
                                    @else
                                        <td></td>
                                    @endif

                                    @if($product_return_data->qty)
                                        <td class="text-center">{{number_format((float)($product_return_data->qty), 0, '.', '.')}}</td>
                                    @else
                                        <td>0</td>
                                    @endif
                                    
                                    @if($product_return_data->net_unit_price)
                                        <td class="text-right">{{number_format((float)($product_return_data->net_unit_price), 0, '.', '.')}}</td>
                                    @else
                                        <td>0</td>
                                    @endif

                                    <td class="text-right">{{number_format((float)($return->grand_total), 0, '.', '.')}}</td>
                                </tr>
                            @endforeach
                        @endforeach
                    </tbody>
                    <tfoot class="tfoot active">
                        <tr>
                            <th></th>
                            <th>Total:</th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th class="text-center">0</th>
                            <th></th>
                            <th class="text-right">0</th>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>

    </div>
</section>

<script type="text/javascript">
    $("ul#report").siblings('a').attr('aria-expanded','true');
    $("ul#report").addClass("show");
    $("ul#report #warehouse-report-menu").addClass("active");
    $("table").css({ "color": "#000000" });
    $("th").css({ "border": "1px solid #333333", "text-align": "center" });
    $("td").css({ "border": "1px solid #333333" });

    $('#warehouse_id').val($('input[name="warehouse_id_hidden"]').val());
    $('.selectpicker').selectpicker('refresh');

    $('#warehouse_id').select2({
        placeholder: "Select warehouse..."
    });

    $('a[href="#warehouse-sale"]').on('click', function() {
        $('#text-center').html('<h3 class="text-center">{{trans('file.Sale Warehouse Report')}}</h3>');
    });

    $('a[href="#warehouse-purchase"]').on('click', function() {
        $('#text-center').html('<h3 class="text-center">{{trans('file.Purchase Warehouse Report')}}</h3>');
    });

    $('a[href="#warehouse-return"]').on('click', function() {
        $('#text-center').html('<h3 class="text-center">{{trans('file.Return Warehouse Report')}}</h3>');
    });
    
    $( "span.selection" ).css( "width", "100%" );
    $( ".select2-container .select2-selection--single" ).css({"height":"38px", "padding": "4px 0 6px" });
    $( ".select2-selection__arrow" ).css( "top", "5px" );
    $( ".select2-container--default .select2-selection--single").css({"borderColor": "#e4e6fc", "backgroundColor": "#fdfdff"});
    $( ".select2-selection__placeholder").css({"fontSize": "14px"});

    $('#sale-table').DataTable( {
        order:[],
        "createdRow": function( row, data, dataIndex ) {
            $('td', row).css( "border", "1px solid #333333" );
        },
        'columnDefs': [
            {
                "orderable": false,
                'targets': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
            },
            {
                '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-sale)',
                    rows: ':visible'
                },
                action: function(e, dt, button, config) {
                    datatable_sum_sale(dt, true);
                    $.fn.dataTable.ext.buttons.pdfHtml5.action.call(this, e, dt, button, config);
                    datatable_sum_sale(dt, false);
                },
                footer:true
            },
            {
                extend: 'csv',
                charset: 'UTF-8',
                bom: true, 
                text: '{{trans("file.CSV")}}',
                exportOptions: {
                    columns: ':visible:Not(.not-exported-sale)',
                    rows: ':visible'
                },
                action: function(e, dt, button, config) {
                    datatable_sum_sale(dt, true);
                    $.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, button, config);
                    datatable_sum_sale(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;">         
                                <br>                
                                <h3 style="text-transform: uppercase" class="modal-title text-center container-fluid">{{trans('file.Sale Report')}}</h3>
                                <p class="modal-title text-center container-fluid">{{trans('file.From date')}} {{date('d-m-Y', strtotime($start_date))}} {{trans('file.To date')}} {{date('d-m-Y', strtotime($end_date))}}</p>

                            </div>
                        </div>
                    
                    `;
                },
                exportOptions: {
                    columns: ':visible:Not(.not-exported-sale)',
                    rows: ':visible'
                },
                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(6)').css({'text-align': 'center'});
                    $(doc.document.body).find('table td:nth-child(7)').css({'text-align': 'center'});
                    $(doc.document.body).find('table td:nth-child(8)').css({'text-align': 'right'});
                    $(doc.document.body).find('table td:nth-child(9)').css({'text-align': 'right'});

                },
                action: function(e, dt, button, config) {
                    datatable_sum_sale(dt, true);
                    $.fn.dataTable.ext.buttons.print.action.call(this, e, dt, button, config);
                    datatable_sum_sale(dt, false);
                },
                footer:true
            },
            {
                extend: 'colvis',
                columns: ':gt(0)'
            }
        ],
        drawCallback: function () {
            var api = this.api();
            datatable_sum_sale(api, false);
        }
    } );

    function datatable_sum_sale(dt_selector, is_calling_first) {
        if (dt_selector.rows( '.selected' ).any() && is_calling_first) {
            var rows = dt_selector.rows( '.selected' ).indexes();
            var column7Sum = 0;
            var column9Sum = 0;

            dt_selector.cells( rows, 7, { page: 'current' }).data().each(function(value) {
                column7Sum += parseFloat(value.replace(/\./g, ""));
            });
            dt_selector.cells( rows, 9, { page: 'current' }).data().each(function(value) {
                column9Sum += parseFloat(value.replace(/\./g, ""));
            });
            $( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
            $( dt_selector.column( 9 ).footer() ).html(column9Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
        }
        else {
            var column7Sum = 0;
            var column9Sum = 0;

            dt_selector.column(7, { page: 'current' }).data().each(function(value) {
                column7Sum += parseFloat(value.replace(/\./g, ""));
            });
            dt_selector.column(9, { page: 'current' }).data().each(function(value) {
                column9Sum += parseFloat(value.replace(/\./g, ""));
            });
            $( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
            $( dt_selector.column( 9 ).footer() ).html(column9Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
        }
    }

    $('#purchase-table').DataTable( {
        "order": [],
        "createdRow": function( row, data, dataIndex ) {
            $('td', row).css( "border", "1px solid #333333" );
        },
        'columnDefs': [
            {
                "orderable": false,
                'targets': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
            },
            {
                '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-purchase)',
                    rows: ':visible'
                },
                action: function(e, dt, button, config) {
                    datatable_sum_purchase(dt, true);
                    $.fn.dataTable.ext.buttons.pdfHtml5.action.call(this, e, dt, button, config);
                    datatable_sum_purchase(dt, false);
                },
                footer:true
            },
            {
                extend: 'csv',
                charset: 'UTF-8',
                bom: true, 
                text: '{{trans("file.CSV")}}',
                exportOptions: {
                    columns: ':visible:Not(.not-exported-purchase)',
                    rows: ':visible'
                },
                action: function(e, dt, button, config) {
                    datatable_sum_purchase(dt, true);
                    $.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, button, config);
                    datatable_sum_purchase(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;">         
                                <br>                
                                <h3 style="text-transform: uppercase" class="modal-title text-center container-fluid">{{trans('file.Purchase Report')}}</h3>
                                <p class="modal-title text-center container-fluid">{{trans('file.From date')}} {{date('d-m-Y', strtotime($start_date))}} {{trans('file.To date')}} {{date('d-m-Y', strtotime($end_date))}}</p>

                            </div>
                        </div>
                    
                    `;
                },
                exportOptions: {
                    columns: ':visible:Not(.not-exported-purchase)',
                    rows: ':visible'
                },
                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(2)').css({'text-align': 'center'});
                    $(doc.document.body).find('table td:nth-child(6)').css({'text-align': 'center'});
                    $(doc.document.body).find('table td:nth-child(7)').css({'text-align': 'center'});
                    $(doc.document.body).find('table td:nth-child(4)').css({'text-align': 'right'});
                    $(doc.document.body).find('table td:nth-child(8)').css({'text-align': 'right'});
                    $(doc.document.body).find('table td:nth-child(9)').css({'text-align': 'right'});
                },
                action: function(e, dt, button, config) {
                    datatable_sum_purchase(dt, true);
                    $.fn.dataTable.ext.buttons.print.action.call(this, e, dt, button, config);
                    datatable_sum_purchase(dt, false);
                },
                footer:true
            },
            {
                extend: 'colvis',
                columns: ':gt(0)'
            }
        ],
        drawCallback: function () {
            var api = this.api();
            datatable_sum_purchase(api, false);
        }
    } );

    function datatable_sum_purchase(dt_selector, is_calling_first) {
        if (dt_selector.rows( '.selected' ).any() && is_calling_first) {
            var rows = dt_selector.rows( '.selected' ).indexes();
            var column7Sum = 0;
            var column9Sum = 0;

            dt_selector.cells( rows, 7, { page: 'current' }).data().each(function(value) {
                column7Sum += parseFloat(value.replace(/\./g, ""));
            });
            dt_selector.cells( rows, 9, { page: 'current' }).data().each(function(value) {
                column9Sum += parseFloat(value.replace(/\./g, ""));
            });
            $( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
            $( dt_selector.column( 9 ).footer() ).html(column9Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
        }
        else {
            var column7Sum = 0;
            var column9Sum = 0;

            dt_selector.column(7, { page: 'current' }).data().each(function(value) {
                column7Sum += parseFloat(value.replace(/\./g, ""));
            });
            dt_selector.column(9, { page: 'current' }).data().each(function(value) {
                column9Sum += parseFloat(value.replace(/\./g, ""));
            });
            $( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
            $( dt_selector.column( 9 ).footer() ).html(column9Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
        }
    }


    $('#return-table').DataTable( {
        "order": [],
        "createdRow": function( row, data, dataIndex ) {
            $('td', row).css( "border", "1px solid #333333" );
        },
        'columnDefs': [
            {
                "orderable": false,
                'targets': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
            },
            {
                '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-return)',
                    rows: ':visible'
                },
                action: function(e, dt, button, config) {
                    datatable_sum_return(dt, true);
                    $.fn.dataTable.ext.buttons.pdfHtml5.action.call(this, e, dt, button, config);
                    datatable_sum_return(dt, false);
                },
                footer:true
            },
            {
                extend: 'csv',
                charset: 'UTF-8',
                bom: true, 
                text: '{{trans("file.CSV")}}',
                exportOptions: {
                    columns: ':visible:Not(.not-exported-return)',
                    rows: ':visible'
                },
                action: function(e, dt, button, config) {
                    datatable_sum_return(dt, true);
                    $.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, button, config);
                    datatable_sum_return(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;">         
                                <br>                
                                <h3 style="text-transform: uppercase" class="modal-title text-center container-fluid">{{trans('file.Return Report')}}</h3>
                                <p class="modal-title text-center container-fluid">{{trans('file.From date')}} {{date('d-m-Y', strtotime($start_date))}} {{trans('file.To date')}} {{date('d-m-Y', strtotime($end_date))}}</p>

                            </div>
                        </div>
                    
                    `;
                },
                exportOptions: {
                    columns: ':visible:Not(.not-exported-return)',
                    rows: ':visible'
                },
                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(6)').css({'text-align': 'center'});
                    $(doc.document.body).find('table td:nth-child(5)').css({'text-align': 'right'});
                    $(doc.document.body).find('table td:nth-child(7)').css({'text-align': 'center'});
                    $(doc.document.body).find('table td:nth-child(8)').css({'text-align': 'right'});
                    $(doc.document.body).find('table td:nth-child(9)').css({'text-align': 'right'});
                },
                action: function(e, dt, button, config) {
                    datatable_sum_return(dt, true);
                    $.fn.dataTable.ext.buttons.print.action.call(this, e, dt, button, config);
                    datatable_sum_return(dt, false);
                },
                footer:true
            },
            {
                extend: 'colvis',
                columns: ':gt(0)'
            }
        ],
        drawCallback: function () {
            var api = this.api();
            datatable_sum_return(api, false);
        }
    } );

    function datatable_sum_return(dt_selector, is_calling_first) {
        if (dt_selector.rows( '.selected' ).any() && is_calling_first) {
            var rows = dt_selector.rows( '.selected' ).indexes();
            var column7Sum = 0;
            var column9Sum = 0;

            dt_selector.cells( rows, 7, { page: 'current' }).data().each(function(value) {
                column7Sum += parseFloat(value.replace(/\./g, ""));
            });
            dt_selector.cells( rows, 9, { page: 'current' }).data().each(function(value) {
                column9Sum += parseFloat(value.replace(/\./g, ""));
            });
            $( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
            $( dt_selector.column( 9 ).footer() ).html(column9Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
        }
        else {
            var column7Sum = 0;
            var column9Sum = 0;

            dt_selector.column(7, { page: 'current' }).data().each(function(value) {
                column7Sum += parseFloat(value.replace(/\./g, ""));
            });
            dt_selector.column(9, { page: 'current' }).data().each(function(value) {
                column9Sum += parseFloat(value.replace(/\./g, ""));
            });
            $( dt_selector.column( 7 ).footer() ).html(column7Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
            $( dt_selector.column( 9 ).footer() ).html(column9Sum.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1."));
        }
    }

    $(".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

Youez - 2016 - github.com/yon3zu
LinuXploit