@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 Operation</a></li>
      <li><a href="#">Sale Transfer ownership</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>Sale Transfer ownership</h3>
          </div>
        </div>
      </div>
    </div>
  </div>
  <form action="{{url('realty/report-payment_client_transfer_ownership-print')}}" method="POST">
    @csrf
    <div class="form-search">
      <div class="row">
        <div class="col-xs-12 col-sm-6 col-md-6 ">
          <div class="form-group">
            <strong>Item Name</strong>
            {!! Form::text('item_name', null, array('placeholder' => 'item code','class' => 'form-control item_name','autocomplete' => 'off')) !!}
          </div>
        </div>
        <div class="col-xs-12 col-sm-6 col-md-6 ">
          <div class="form-group">
            <strong>Project</strong>
            {!! Form::select('project_id[]', $projects, null, ['class' => 'form-control select2 projects','multiple']) !!}
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-xs-12 col-sm-6 col-md-6 ">
          <div class="form-group">
            <strong>Category</strong>
            {!! Form::select('category_id[]', $categories, null, ['class' => 'form-control select2 categories','multiple']) !!}
          </div>
        </div>
        <div class="col-xs-12 col-sm-6 col-md-6 ">
          <div class="form-group">
            <strong>Client</strong>
            {!! Form::select('client_id[]', $clients, null, ['class' => 'form-control select2 clients','multiple']) !!}
          </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="datatable_payment_client_report" class="table table-striped table-bordered table-hover nowrap">
        <thead>
          <tr>
            <th>No</th>
            <th>Client Name</th>
            <th>Project</th>
            <th>Category</th>
            <th>Item</th>
            <th>Sale Cost</th>
            <th>Discount</th>
            <th>Sell Price</th>
            <th>Deposit Amount</th>
            <th>Date Transfer ownership</th>
            <th>Remark</th>
            <th>Other</th>
          </tr>
        </thead>
        <tbody class="tbody"></tbody>
      </table>
    </div>
</div>

@endsection @section('js')
<script type="text/javascript">
  $(document).ready(function () {
  $('.main-spinner').show();
  var index = $('#datatable_payment_client_report').DataTable({
    "lengthMenu": [[20, 25, 50, 100, 500], [20, 25, 50, 100, 500]],
    serverSide: true,
    "autoWidth": false,
    "scrollY":"600px",
    "scrollCollapse": true,
    dom: 'Blfrtip',
    buttons: [
      'copyHtml5',
      'excelHtml5'
    ],
    ajax: "/realty/report-payment_client_transfer_ownership",
    columns: [
      { 
        data: 'DT_RowIndex', name: 'DT_RowIndex' , orderable: false, searchable: false
      },
      {
        data: 'client_name',name:'nso007_client.client_fullname'
      },
      {
        data: 'project_name',name:'nso007_project_stock.project_name'
      },
      {
        data: 'category_name',name:'nso007_category_stock.category_name'
      },
      {
        data: 'item_code',name:'nso007_item_stock.item_house'
      },
      {
        data: 'sale_amount',name:'nso007_sale_stock.sale_amount'
      },
      {
        data: 'sale_discount',name:'nso007_loan.loan_discount'
      },
      {
        data: 'sale_price',searchable:false
      },
      {
        data: 'deposit_amount',searchable:false,
      },
      {
        data: 'date_transfer_ownership',searchable:false,
      },
      {
        data: 'remark_transfered_ownership',searchable:false,
      },
      {
        data: 'other',orderable: false, searchable: false
      }
    ],
    "initComplete": function (settings, json) {
      $('.main-spinner').hide();
    }
  });
  index.on('order.dt search.dt', function () {
    index.column(0, { search: 'applied', order: 'applied' }).nodes().each(function (cell, i) {
      cell.innerHTML = i + 1;
    });
  }).draw();
  $.fn.dataTable.ext.errMode = 'throw';
});
  function searching() {
    $('#datatable_payment_client_report').DataTable().destroy();
    var project = $('.projects').val();
    var category = $('.categories').val();
    var client = $('.clients').val();
    var item_name = $('.item_name').val();
    var index = $('#datatable_payment_client_report').DataTable({
      "lengthMenu": [
        [20, 25, 50, 100, 500],
        [20, 25, 50, 100, 500]
      ],
      serverSide: true,
      "autoWidth": false,
      "scrollY":"600px",
      "scrollCollapse": true,
      dom: 'Blfrtip',
      buttons: [
        'copyHtml5',
        'excelHtml5'
      ],
      ajax: {
        type: "POST",
        url: "{{route('report-payment_client_transfer_ownership')}}",
        data: {
          _token: "{{csrf_token()}}",
          project_id: project,
          category_id: category,
          client_id: client,
          item_name: item_name
        }
      },
      columns: [{
          data: 'DT_RowIndex',
          name: 'DT_RowIndex',
          orderable: false,
          searchable: false
        },
        {
          data: 'client_name',
          name: 'nso007_client.client_fullname'
        },
        {
          data: 'project_name',
          name: 'nso007_project_stock.project_name'
        },
        {
          data: 'category_name',
          name: 'nso007_category_stock.category_name'
        },
        {
          data: 'item_code',
          name: 'nso007_item_stock.item_house'
        },
        {
          data: 'sale_amount',
          'className': "text-right",
          name: 'nso007_sale_stock.sale_amount'
        },
        {
          data: 'sale_discount',
          'className': "text-right",
          name: 'nso007_loan.loan_discount'
        },
        {
          data: 'sale_price',
          'className': "text-right",
          searchable: false
        },
        {
          data: 'deposit_amount',
          'className': "text-right",
          name: 'nso007_sale_stock.sale_receive'
        },{
        data: 'date_transfer_ownership','className':"text-right",searchable:false,
      },
      {
        data: 'remark_transfer_ownership','className':"text-right",searchable:false,
      },
      {
        data: 'other',orderable: false, searchable: false
      }
      ],
      "initComplete": function(settings, json) {
        $('.main-spinner').hide();
      },
    });
    index.on('order.dt search.dt', function() {
      index.column(0, {
        search: 'applied',
        order: 'applied'
      }).nodes().each(function(cell, i) {
        cell.innerHTML = i + 1;
      });
    }).draw();
    $.fn.dataTable.ext.errMode = 'throw';
  }
</script>
@endsection