@extends('adminlte::page') @section('content')
 <?php Fun::lang() ?>
 <div class="title-page">
   <div class="page-bar">
     <ul class="page-breadcrumb">
       <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
       <li><a href="#">Reports</a></li>
       <li><a href="#">Report Construction</a></li>
       <li><a href="#">Ajustment Stock Out</a></li>
     </ul>
   </div>
 </div>
 <div class="page">
   <div class="top-content">
     <div class="row">
       <div class="col-sm-12 col-xs-12">
         <div class="title-add">
           <div class="pull-left">
             <h3>Report Ajustment Stock Out</h3>
           </div>
         </div>

       </div>
     </div>
   </div>
   <form action="{{route('construction-report.AjustmentStockOutReport')}}" method="POST">
     @csrf
     <div class="form-search">
       <div class="row">
        <div class="col-xs-12 col-sm-4 col-md-4 ">
            <div class="form-group">
              <strong>Form Date</strong>
              {!! Form::text('start_date', null, array('placeholder' => 'Start Date','class' => 'form-control date_picker start_date','autocomplete' => 'off')) !!}
            </div>
          </div>
          <div class="col-xs-12 col-sm-4 col-md-4 ">
            <div class="form-group">
              <strong>To Date</strong>
              {!! Form::text('end_date', null, array('placeholder' => 'End Date','class' => 'form-control date_picker end_date','autocomplete' => 'off')) !!}
            </div>
          </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Project</strong>
             {!! Form::select('projects', $projects, null, ['class' => 'form-control select2 projects','onchange'=>'get_warehouse(this)']) !!}
           </div>
         </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
            <div class="form-group">
              <strong>Warehouse</strong>
              {!! Form::select('warehouses', [], null, ['class' => 'form-control select2 warehouses']) !!}
            </div>
          </div>
          <div class="col-xs-12 col-sm-4 col-md-4 ">
            <div class="form-group">
              <strong>Zone</strong>
              {!! Form::select('zones', $zones, null, ['class' => 'form-control select2 zones']) !!}
            </div>
          </div>
          <div class="col-xs-12 col-sm-4 col-md-4 ">
            <div class="form-group">
              <strong>House Number</strong>
              {!! Form::select('house_numbers', $house_numbers, null, ['class' => 'form-control select2 house_numbers']) !!}
            </div>
          </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Category</strong>
             {!! Form::select('categories',$categories, null, ['class' => 'form-control select2 categories']) !!}
           </div>
         </div>
         <div class="col-xs-12 col-sm-4 col-md-4 ">
           <div class="form-group">
             <strong>Products</strong>
             {!! Form::select('products',  $products, null, ['class' => 'form-control select2 products']) !!}
           </div>
         </div>
         <div class="col-xs-12 col-sm-12 col-md-12 text-right">
           <button type="button" class="button_primary btn-sm search" onclick="searching()"><span class="fa fa-search"> Search</span></button>&nbsp
           <button type="submit" class="button_primary btn-sm search"><span class="fa fa-print"> Print</span></button>
         </div>
       </div>
     </div>
     {!! Form::close() !!}
     <div class="box-body table-responsive">
       <table id="origin-stock-datatable" class="table table-striped table-bordered table-hover nowrap" width="100%">
         <thead>
           <tr>
            <th>No</th>
              <th>Date</th>
              <th>Contractor</th>
              <th>Project Name</th>
              <th>Warehouse</th>
              <th>Zone</th>
              <th>House</th>
              <th>Product Name</th>
              <th>Category</th>
              <th>Sub Category</th>
              <th>Quantities</th>
              <th>Unit Name</th>
           </tr>
         </thead>
         <tbody class="tbody"></tbody>
         {{-- <tfoot class="tfoot">
            <tr>
              <td colspan="10" class="text-right">Total :</td>
              <td></td>
              <td></td>
            </tr>
          </tfoot> --}}
       </table>
     </div>
 </div>
 @endsection @section('js')
 <script type="text/javascript">
    function get_warehouse(obj){
        $("#main-spinner").show();
        var route = "{{ route('get_warehouse_by_project',':id') }}";
        route = route.replace(":id",$(obj).val());
        $.ajax({
            url:route,
            type:"GET",
            dataType:"JSON",
            success:function(data)
            {
                var opt = `<option value="">Please Select Option</option>`;
                $.each(data,function(index,value)
                {
                    opt += `<option value = "${value.id}">${value.name}</option>`;
                });
                $(".warehouses").html(opt);
            },
            complete:function()
            {
                $("#main-spinner").hide();
            }
        });
    }
     $(document).ready(function() {
         $('#main-spinner').show();
           $('#origin-stock-datatable').DataTable({
             ordering: false,
             "searching":false,
             "serverSide":true,
             "scrollY":"600px",
            "scrollCollapse": true,
            "scrollX": true,
             lengthMenu: [[20, 30, 50, 100,200,500,1000], [20, 30, 50, 100,200,500,1000]],
             ajax: {
               url:"{{route('construction-report.AjustmentStockOutReport')}}",
               type:"GET",
               data:function(d){
                d.warehouses = $(".warehouses").val();
                d.projects = $(".projects").val();
                d.categories = $(".categories").val();
                d.products = $(".products").val();
                d.start_date = $(".start_date").val();
                d.end_date = $(".end_date").val();
                d.zones = $(".zones").val();
                d.house_numbers = $(".house_numbers").val();
               }
             },
             columns: [
                  {
                     data: 'DT_RowIndex'
                 },
                 {
                     data:'date'
                 },
                 {
                     data:'constructor_name'
                 },
                 {
                     data: 'project_name'
                 },
                 {
                     data: 'warehouse_name'
                 },
                 {
                     data: 'zone_name'
                 },
                 {
                    data: 'house_name'
                 },
                 {
                    data:'product_name'
                 },
                 {
                    data: 'product_category_name'
                 },
                 {
                     data: 'sub_category'
                 },
                 {
                     data: 'product_use_qty'
                 },
                 {
                     data: 'unit_name'
                 },
             ],

             "initComplete": function(settings, json) {
                 $('#main-spinner').hide();
             },
         });
     });
     function searching(){
      $('#origin-stock-datatable').DataTable().draw(true);
     }
 </script>
 @endsection