@extends('layouts.master')

@section('content')
@if (session()->has('message'))
<div class="row">
        <!-- left column -->
        <div class="col-md-2"></div>
<div class="col-md-4 alert alert-success alert-dismissible" style="font-size:18px;font-weight:bold;width:950px;margin-left:15px">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                {!! session('message') !!}
              </div>
              </div> 
@endif

<div class="row">
        <!-- left column -->
        <div class="col-md-2"></div>
        <div class="col-md-8">
          <!-- general form elements -->
          <div class="box box-primary">
            <div class="box-header with-border" style="text-align: center; background-color: #5098c3;">
              <h3 class="box-title " style="font-weight: bold;">  
              تعديل الكارتة رقم   
              {{$main->id}}
              الموجودة في 
              &nbsp; &nbsp; &nbsp; 
              @if( $main->sell_store )
              <span style="color:white">{{ $main->sell_store->store->store_name }}-- </span>
              <span style="color:white">{{$main->sell_store->branch->name}}--</span>
              <span style="color:white">  مخزن بيع   ( {{$main->sell_store_id}} ) </span>
              @else
              <span style="color:#953922"> لا يوجد مخزن بيع </span>
              @endif
            </h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form   role="form" method="POST" action="{{ url('/main/edit') }}">
                        {{ csrf_field() }}
              <div class="box-body">
                
            
              

                


                <div class="form-group col-md-6">
                <label>Packing Methods  - طريقة التعبئة </label>
                <select class="form-control select2" style="width: 100%;" name="packingmethod_id" id="packingmethod_id" required>
                  @foreach( $packingmethods as $packingmethod ) 
                  <option value="{{ $packingmethod->id }}" {{ $main->packingmethod->id == $packingmethod->id ? 'selected' : '' }} >{{$packingmethod->name}}</option>
                  @endforeach
                </select>
                </div>

                <div class="form-group col-md-6">
                <label>Physical Conditions  - الحالة الفيزيائية </label>
                <select class="form-control select2" style="width: 100%;" name="physicalcondition_id" id="physicalcondition_id" required>
                  @foreach( $physicalconditions as $physicalcondition ) 
                  <option value="{{ $physicalcondition->id }}" {{ $main->physicalcondition->id == $physicalcondition->id ? 'selected' : '' }} >{{$physicalcondition->name}}</option>
                  @endforeach
                </select>
                </div>

                <div class="form-group col-md-6">
                <label>Driver Name- السائق</label>
                <select class="form-control select2" style="width: 100%;" name="driver_id" id="driver_id" required>
                  @foreach( $drivers as $driver ) 
                  <option value="{{ $driver->id }}" {{ $main->driver->id == $driver->id ? 'selected' : '' }}>{{$driver->name}}</option>
                  @endforeach
                </select>
                </div>
                
                <div class="form-group col-md-6">
                <label>Vehicle number - رقم السيارة  </label>
                <select class="form-control select2" style="width: 100%;" name="vehicle_id" id="vehicle_id" required>
                  @foreach( $vehicles as $vehicle ) 
                  <option value="{{ $vehicle->id }}" {{ $main->vehicle->id == $vehicle->id ? 'selected' : '' }} >{{$vehicle->vehicle_num}}</option>
                  @endforeach
                </select>
                </div>


                <div class="form-group col-md-6">
                <label> Suppervisor اسم المشرف   </label>
                <select class="form-control select2" style="width: 100%;" name="user_id" id="user_id" required>
                  @foreach( $users as $user ) 
                  <option value="{{ $user->id }}" {{ $main->user->id == $user->id ? 'selected' : '' }} >{{$user->name}}</option>
                  @endforeach
                </select>
                </div>
                
                
                
                


                

                <div class="form-group col-md-6">
                  <label for="exampleInputPassword1">Tax</label>
                  <input type="number"  name="tax"  value="{{$main->tax}}" class="form-control"  placeholder="Tax " required>
                </div>
                 
                
                <div class="form-group col-md-6">
                  <label for="exampleInputPassword1"> ملحوظة عن المخلف</label>
                  <input type="text" name="comment"  value="{{$main->comment}}" class="form-control"  placeholder="Leave comment about waste ...  " maxlength="200" style="height:35px">
                </div>

                <div class="form-group col-md-6">
                  <label for="exampleInputPassword1">وقت الدخول</label>
                  <input type="datetime-local" name="updated_at"  value="{{$main->updated_at}}" class="form-control"  placeholder="Time Out " required>
                </div>
                
                
                
                <div class="form-group col-md-6">
                  <label for="exampleInputPassword1">وقت الخروج</label>
                  <input type="datetime-local" name="created_at"  value="{{$main->created_at}}" class="form-control"  placeholder="Time Out " required>
                </div>
                
                
               <input type="hidden" name="main_id" value="{{$main->id}}" class="form-control"  placeholder="" required>
              </div>
              <!-- /.box-body -->

              <div class="box-footer">
                @if($expired_supplier_waste=="no")
                <button type="submit" class="btn btn-success">Save</button>
                @else
                <h2 class="btn btn-success"> expired supplier waste </h2>
                @endif
                @if( auth()->user()->is_superadmin )
                  <a   href='{{url("/main/delete/$main->id")}}' onclick="return confirm('Are you sure you want to delete this item?');"  class="btn btn-danger" style="float:right">Delete  </a><br/><br/>
                @else
                  <span>&nbsp;&nbsp;</span><br/><br/><br/>
                @endif
                
              </div>
            </form>

          </div>    


        </div>
        <div class="col-md-2">
        <a href='{{ url("/main/advancededit/$main->id") }}'  class="btn bg-orange btn-flat margin" style="font-size:18px;padding: 8px;margin-top: 0px;"> <i class="fa fa-edit" style="font-size:22px; color:white;"></i> <b>Advanced Edit</b>  </a>
        </div>
      </div>



@endsection