@extends('layouts.master')

@section('content')
 
<!-- waste here is the main row  --> 

@if($charts)
<div class="row">
@foreach ( $charts as $chart )


        <div class="col-md-3 col-sm-6 col-xs-12">
          <div class="info-box">
            <span class="info-box-icon bg-white"> 
            <img src="{{asset('dist/img/groups.png')}}"  class="user-image" alt="User Image">
            </span>

            <div class="info-box-content">
              <span class="info-box-text" style="font-size:18px">{{$chart->name}}</span>
              <span class="info-box-number" style="font-size:18px">{{$chart->total_quantity}} {{ $chart->unit}}</span>
            </div>
            <!-- /.info-box-content -->
          </div>
          <!-- /.info-box -->
        </div>

        @endforeach
         
      </div>
@endif


    <a href="{{ url('/main/not_approved') }}"  class="btn btn-warning" >Not Approved </a>
    <a href="{{ url('/main/not_sent_to_customer') }}"  class="btn btn-success">Not Sent to Recycler</a>
    <a href="{{ url('/') }}" style="float:right;margin-top: -15px;margin-right: 5px;">  <img   src="{{asset('dist/img/refresh.png')}}"  alt="User Image" style="width: 50px;height: 50px;"></a>


<div class="box" >
            <div class="box-header">
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1"  class="table table-bordered table-striped" >
                <thead >
                <tr >
                  <th style="text-align:center;vertical-align: middle; background-color:#2C4E71; color:#FFF;border-color:#0000003c"> التاريخ - ساعة الخروج  </th>
                  <th style="text-align:center;vertical-align: middle; background-color:#2C4E71; color:#FFF;border-color:#0000003c"> ساعة الوصول  </th>
                  <th style="text-align:center;vertical-align: middle; background-color:#2C4E71;color:#FFF;border-color:#0000003c">  المورد    </th>
                  <th style="text-align:center;vertical-align: middle; background-color:#2C4E71;color:#FFF;border-color:#0000003c ">   المخلق    </th>
                  <!--
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;"> التصنيف    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#4fc2a1;color:#FFF;"> المجموعة    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;"> الفئة    </th>
                  -->
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> الكمية    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c "> وحدة الوزن    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> سعر    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> اجمالي السعر    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c "> طريقة التعبئة    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> الحالة الفزيائية    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> طرق التخلص المعتمد    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> جهة التدوير المعتمدة    </th>

                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> رقم السيارة    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c "> اسم السائق    </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> اسم المشرف    </th>

                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF; border-color:#0000003c"> Actions  </th>
                </tr>
                </thead>
                <tbody>
                @foreach( $wastes as $waste )   
                 
                @php
                  $price_column_name  = "p".$waste->waste->id 
                @endphp

                @if ( $waste->approve == NULL ) 
                <tr style="background-color:#f39c12">
                @elseif ( $waste->approve == "approved" && $waste->customer_id == NULL )
                <tr style="background-color:#92E39B">
                @elseif ( $waste->approve == "approved" && $waste->customer_id != NULL )
                <tr style="background-color:#F5F8F9"> 
                @else
                <tr>
                 @endif
                 <td style="text-align:center; width:60px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->created_at}} </td>
                 
                 
                 <td style="text-align:center; width:60px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{ $waste->approve == "approved" ? $waste->updated_at : 'waiting...'}} </td>
                 
                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c">{{$waste->supplier->name}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->waste->name}} </td>
                 <!--
                 <td style="text-align:center; width:40px;word-break: break-word;" >{{$waste->waste->classification->name}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word;" >{{$waste->waste->group->name}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word;" >{{$waste->waste->class_->name}} </td>
                 -->
                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->quantity}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->waste->unit}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->price_id ? $waste->price[$price_column_name] : ''}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word;font-weight:900;border-color:#0000003c" >{{$waste->price_id ? $waste->price[$price_column_name] * $waste->quantity: ''}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word;font-weight:900;border-color:#0000003c" >{{$waste->packingmethod->name}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word;font-weight:900;border-color:#0000003c" >{{$waste->physicalcondition->name}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word;font-weight:900;border-color:#0000003c" >{{$waste->waste->res_method->name}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word; position: relative; font-weight:900;border-color:#0000003c" >{{$waste->customer_id ? $waste->customer->name : 'Waiting...' }}
                 @if ( $waste->approve == "approved" )
                 <a href='{{url("/main/changecustomer/$waste->id")}}' style="position: absolute;bottom: 0; left:0; right:0;margin-bottom:10px; text-decoration: underline;" > <strong> Change </strong>  </a>
                 @endif
                </td>

                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->vehicle->vehicle_num}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->driver->name}} </td>
                 <td style="text-align:center; width:40px;word-break: break-word; font-weight:900;border-color:#0000003c" >{{$waste->user->name}} </td>

                 
                 <td style="text-align:center; width:20px;word-break: break-word; font-weight:900;border-color:#0000003c" > 
                 @if ( $waste->approve != "approved") 
                 <a href='{{url("/main/approve/$waste->id")}}'   class="btn btn-success" style=""> <strong> Approve </strong> </a> 
                 <br/><br/>
                 @endif

                 @if ( $waste->approve != "approved"  )
                 <a href='{{url("/main/edit/$waste->id")}}'  class="btn btn-info"> <i class="fa fa-edit" style="font-size:18px; color:#FFF"></i> <strong> Edit </strong>  </a>
                 @elseif ( $waste->approve == "approved" && auth()->user()->is_superadmin )
                 <a href='{{url("/main/edit/$waste->id")}}'  class="btn btn-info"> <i class="fa fa-edit" style="font-size:18px; color:#FFF"></i> <strong> Edit </strong>  </a>
                 @endif


               </td>
               </tr>
               @endforeach
                </tbody>
                
              </table>
            </div>
            <!-- /.box-body -->
          
          
                
                 
          </div>

            
         

@endsection
