@php
        
$size = '';

if ($projecttype == \App\ProjectType::society) {
    $size = \App\ProjectType::society_size;
} else {
    $size = \App\ProjectType::high_rise_size;
}

 
$map = ' ';

if ($projecttype == \App\ProjectType::society) {
    $map = \App\ProjectType::society_map;
} else {
    $map = \App\ProjectType::high_rise_map;
}



@endphp
  <!--.row-->
  <input type='hidden' id='total_units_count' value='{{ $total_units_count }}'>
  <input type='hidden' id='booked_units_count' value='{{ $booked_units_count }}'>
  <input type='hidden' id='un_booked_units_count' value='{{ $un_booked_units_count }}'>


  <input type='hidden' id='total_units_area' value='{{ $total_units_area }}'>
  <input type='hidden' id='booked_units_area' value='{{ $booked_units_area }}'>
  <input type='hidden' id='un_booked_units_area' value='{{ $un_booked_units_area }}'>
  <input type='hidden' id='total_units_area_2' value='{{ $total_units_area_2 }}'>
  <input type='hidden' id='booked_units_area_2' value='{{ $booked_units_area_2 }}'>
  <input type='hidden' id='un_booked_units_area_2' value='{{ $un_booked_units_area_2 }}'>
  <input type='hidden' id='multiprojectype_val' value='{{ $multiproject_type }}'>
  
  <input type='hidden' id='total_units_amount' value='{{ $total_units_amount }}'>
  <input type='hidden' id='booked_units_amount' value='{{ $booked_units_amount }}'>
  <input type='hidden' id='un_booked_units_amount' value='{{ $un_booked_units_amount }}'>


  <input type='hidden' id='discount_val' value='{{ $booked_units_amount - $total_cost_booked_units }}'>



  <!--.row-->
  <div class="row" style="margin-top: 30px;">
    <div class="col-md-12">
        <div class="panel panel-info">
            <div class="panel-heading">Search Inventory</div>
            <div class="panel-wrapper collapse in" aria-expanded="true">
                <div class="panel-body">
                    <form>
                        <div class="form-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <div class="form-group has-success" style="margin-bottom: 15px">
                                        <label class="control-label">By Unit Number</label>
                                        <select id="unit" class="form-control chosen-select">
                                            <option value="0">None</option>
                                            @foreach ($unitNumbers as $p)
                                                <option value="{{ $p->id }}">{{ $p->unit_number }}
                                                </option>
                                            @endforeach
                                        </select>

                                    </div>
                                </div>
                                <!--/span-->
                                <div class="col-md-3">
                                    <div class="form-group has-success" style="margin-bottom: 15px">
                                        <label class="control-label">By {{ $map }}</label>

                                        <select id="floor" class="form-control chosen-select">
                                            <option value="0">None</option>
                                            @foreach ($floors as $b)
                                                <option value="{{ $b->id }}">{{ $b->name }}
                                                </option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <!--/span-->
                                <!--/span-->
                                <div class="col-md-3">
                                    <div class="form-group has-success" style="margin-bottom: 15px">
                                        <label class="control-label">By Size</label>

                                        <select id="size" class="form-control chosen-select">
                                            <option value="0">None</option>
                                            @foreach ($sizes as $s)
                                                <option value="{{ $s->id }}">
                                                    {{ $s->name }} {{ $size }}</option>
                                            @endforeach
                                        </select>


                                        {{-- <div class="col-sm-4">
                                        <div class="input-group">

                                            <select id="size" class="form-control chosen-select">
                                                <option value="0">None</option>
                                                @foreach ($sizes as $s)
                                                    <option value="{{ $s->id }}">
                                                        {{ $s->name }} </option>
                                                @endforeach
                                            </select> --}}
                                            {{-- <div class="input-group-addon"> --}}
                                                {{-- <select class="form-control ">
                                                    <option value="0">Marla</option>
                                                    <option value="0">SqrFt</option>
                                                </select> --}}
                                            {{-- </div> --}}
                                        {{-- </div>
                                        </div> --}}
                                    </div>
                                </div>
                                <!--/span-->

                                <!--/span-->
                                <div class="col-md-3">
                                    <div class="form-group has-success" style="margin-bottom: 15px">
                                        <label class="control-label">By status</label>
                                        <select id="status" class="form-control chosen-select">
                                            <option value="0">None</option>

                                            <option value="{{ \App\Inventory::open }}">Open</option>
                                            @role('admin')
                                                <!-- <option  value="{{ \App\Inventory::hold_client }}">Client Hold</option> -->
                                                <option value="{{ \App\Inventory::hold_company }}">Company Hold
                                                </option>
                                                <option value="{{ \App\Inventory::token_hold }}">Token Hold
                                                </option>
                                                <option value="{{ \App\Inventory::temp_hold }}">Temporary Hold
                                                </option>
                                            @endrole
                                            <option value="{{ \App\Inventory::sold }}">Sold</option>

                                        </select>
                                    </div>
                                </div>
                                <!--/span-->
                            </div>

                        </div>
                        <div class="form-actions">
                            <button type="button" class="btn btn-success search-customer"> <i
                                    class="fa fa-check"></i> Search</button>

                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>



  <div class="graphbox">
    <div class="box" style="height: 280px; ">
        <div class="chart-label" style="font-size: 15px; font-weight: 600;">Total Units: <span id="total-units"></span></div>
        <canvas id="myChart" style='margin-top:10px;'></canvas>
    </div>
    <div class="box" style="height: 280px; ">
        <canvas id="SecondChart" style='margin-top:10px;'></canvas>
    </div>
    <div class="box" style="height: 280px; ">
        <div class="chart-label" style="font-size: 15px; font-weight: 600;">Total Amount <span id="total-amount"></span></div>
        <canvas id="ThirdChart" style='margin-top:10px;'></canvas>
    </div>
</div>


  


  <!-- /row -->
  <div class="row" id="update-table">
      <div class="col-sm-12">
          <div class="white-box">

              <h3 class="box-title">All Inventories ({{ number_format($inventoryCount) }})</h3>

              <div class="table-responsive">
                  <table id="myTable" class="table table-striped">
                      <thead>
                          <tr>
                              <th>Sr #</th>
                              <th>Project</th>
                              <th>Unit #</th>
                              <!-- <th>floor</th>
                                                                      <th>Type</th> -->
                              <th>Size</th>

                              <th>Net Amount</th>
                              <th>Status</th>
                              <th>Action</th>
                          </tr>
                      </thead>
                      <tbody>
                          <?php $count = 1; ?>
                          @permission('view-inventory')
                              <?php $view_inventory = true; ?>
                          @else
                              <?php $view_inventory = false; ?>
                          @endpermission
                          @permission('edit-inventory')
                              <?php $edit_inventory = true; ?>
                          @else
                              <?php $edit_inventory = false; ?>
                          @endpermission
                          @permission('delete-inventory')
                              <?php $delete_inventory = true; ?>
                          @else
                              <?php $delete_inventory = false; ?>
                          @endpermission
                          @role('admin')
                              <?php $admin = true; ?>
                          @else
                              <?php $admin = false; ?>
                          @endrole

                          @foreach ($allInventories as $i)
                              <tr>
                                  <td>{{ $count++ }}</td>
                                  <td>{{ $i->multiProject ? $i->multiProject->name : 'None' }}

                                  </td>
                                  <td>
                                      @permission('view-inventory')
                                          <a
                                              href="{{ route('inventory.detail', ['id' => $i->id]) }}">{{ $i->unit_number }}</a>
                                      @else
                                          {{ $i->unit_number }}
                                      @endpermission

                                  </td>

                                  <td>{{ $i->size ? $i->size->name : '' }}

                                      @can('isSuperAdmin')
                                          @php
                                              if ($i->multiProject->type->id == \App\ProjectType::society) {
                                                  $size = \App\ProjectType::society_size;
                                              } else {
                                                  $size = \App\ProjectType::high_rise_size;
                                              }
                                          @endphp
                                      @endcan

                                      {{ $size }}
                                  </td>
                                  <td>{{ number_format($i->total_price) }}</td>

                                  @if ($admin)
                                      @if ($i->status == \App\Inventory::open)
                                          <td><span class="label label-success">Open</span></td>
                                      @elseif($i->status == \App\Inventory::package_open_file)
                                          <td><span class="label label-success">Open/Dealer Package File</span>
                                          </td>
                                      @elseif($i->status == \App\Inventory::package_open_file_refunded)
                                          <td><span class="label label-success">Open/Dealer Package
                                                  Refunded</span></td>
                                      @elseif($i->status == \App\Inventory::sold)
                                          <td><span class="label label-danger">Sold</span></td>
                                      @elseif($i->status == \App\Inventory::hold_client)
                                          <td><span class="label label-primary">Client Hold</span></td>
                                      @elseif($i->status == \App\Inventory::hold_company)
                                          <td><span class="label label-primary">Company Hold</span></td>
                                      @elseif($i->status == \App\Inventory::token_hold)
                                          <td><span class="label label-primary">Token Hold</span></td>
                                      @elseif($i->status == \App\Inventory::temp_hold)
                                          <td><span class="label label-primary">Temporary Hold</span></td>
                                          @elseif($i->status == \App\Inventory::block)
                                          <td><span class="label label-primary">Block</span></td>
                                          @else
                                          <td></td>
                                      @endif
                                  @else
                                      @if ($i->status == \App\Inventory::open)
                                          <td><span class="label label-success">Open</span></td>
                                      @else
                                          <td><span class="label label-danger">Sold</span></td>
                                      @endif
                                  @endif
                                  <td class="text-nowrap">
                                      @if ($view_inventory)
                                          <a href="{{ route('inventory.detail', ['id' => $i->id]) }}"
                                              data-toggle="tooltip" data-original-title="View"> <i
                                                  class="fa fa-eye text-inverse m-r-10"></i> </a>
                                      @endif

                                      @if ($i->status != \App\Inventory::package_open_file)
                                          @if ($edit_inventory)
                                              <a href="{{ route('inventory.editView', ['id' => $i->id]) }}"
                                                  data-toggle="tooltip" data-original-title="Edit"> <i
                                                      class="fa fa-pencil text-inverse m-r-10"></i> </a>
                                          @endif
                                      @endif

                                      {{-- @if ($edit_inventory)
                                      <a href="#" data-toggle="tooltip" data-original-title="Update status "> <i class="fa fa-wrench text-inverse m-r-10"></i> </a>
                                      @endif --}}
                                      @if ($delete_inventory)
                                          <a data-toggle="confirmation" data-title="Are you sure to delete?"
                                              href="{{ route('inventory.delete', ['id' => $i->id]) }}"> <i
                                                  class="fa fa-close text-danger"></i> </a>
                                      @endif
                                  </td>
                              </tr>
                          @endforeach

                      </tbody>

                  </table>
                  <div style="float: right;">{{ $allInventories->links() }}</div>
              </div>
          </div>
      </div>
  </div>