@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:400px;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">
              <h3 class="box-title">Group Report Create  </h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form   role="form" method="POST" action="{{ url('/group_report/create') }}">
                        {{ csrf_field() }}
              <div class="box-body">
                  
                 <div class="form-group">
                <label> choose year </label>

                <select class="form-control select2"   style="width: 100%;" name="year_type" id="year_type" onchange="select_year()" required>
                  <option value="current"  > current year</option>
                  <option value="last"  > Last years</option>
                </select>
                
              </div>
                
              <div class="form-group col-md-6" >
                  <label for="exampleInputPassword1">Date from  </label>
                  <input type="date" id="group_report_from" name="from" class="form-control"  placeholder="Date from " required>
                </div>



                <div class="form-group col-md-6">
                  <label for="exampleInputPassword1">Date to</label>
                  <input type="date" id="group_report_to" onchange="group_report_showGroups_()" name="to" class="form-control"  placeholder="Date to " required>
                </div>


              <div class="form-group">
                <label>Choose Group - اختيار المجموعة </label>
                <select class="form-control select2"   multiple="multiple" onchange="group_report_showSuppliers_()" style="width: 100%;" name="groups[]"  id="group_groups_id" required>
                 
                </select>
                </div>


                <div class="form-group">
                <label>Choose Supplier - اختيار المورد </label>
                <select class="form-control select2" multiple="multiple"  style="width: 100%;" name="group_suppliers[]" id="group_supplier_id" required>
                <option  >choose suppliers </option>   
                </select>
                </div>


                


              </div>
              <!-- /.box-body -->

              <div class="box-footer">
                <button type="submit" class="btn btn-warning">Create</button>
              </div>
            </form>

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

 <script>

  
function select_year() {
  var year_type =document.getElementById("year_type").value;
  
  if ( year_type == "current" ){
    document.getElementById('group_report_from').min="2024-01-01";
    document.getElementById('group_report_from').max="";
    //document.getElementById('group_report_to').min="2024-01-01";
    document.getElementById('group_report_to').min="";
    document.getElementById('group_report_to').max="";

  }else{

    document.getElementById('group_report_from').min="";
    document.getElementById('group_report_from').max="2024-01-01";
    document.getElementById('group_report_to').min="";
    document.getElementById('group_report_to').max="2024-01-01";
    
  }
}
</script>

@endsection