@extends('layouts.app')
@section('morecss')
<style>
.form-control-file{border-bottom:1px solid #ddd;padding-bottom:0.5em;margin-bottom:0.5em}
</style>
@endsection
@if (config('app.debug'))
    @section('morejs')
    <script>
    var tab=["Nulla a ante cursus, pellentesque ex quis, congue nisl. Aenean non nulla efficitur, lacinia tortor sit amet, fringilla odio. Pellentesque et lorem et magna ullamcorper condimentum.\nOrci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris id gravida leo. Phasellus suscipit facilisis mi ut consequat.",
    "Donec venenatis elit ipsum, quis dignissim ipsum blandit vitae. Curabitur quam odio, egestas quis semper nec, scelerisque id nisl. Fusce non condimentum urna. Mauris eget elit pellentesque, consequat diam in, fermentum purus. Phasellus eget mi pretium, porta lacus at, varius libero. Nulla a ante cursus, pellentesque ex quis, congue nisl. Aenean non nulla efficitur, lacinia tortor sit amet, fringilla odio. Pellentesque et lorem et magna ullamcorper condimentum.",
    "Pellentesque et lorem et magna ullamcorper condimentum.\nOrci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris id gravida leo. Phasellus suscipit facilisis mi ut consequat. In ullamcorper eros ut tristique vehicula. In diam erat, condimentum a fringilla eget, tristique et mi. In et diam id diam mollis bibendum non blandit diam.\n\n Aliquam volutpat felis eu risus porttitor, vel bibendum orci feugiat. In id enim vitae erat hendrerit euismod. Aenean feugiat, nunc quis lobortis tincidunt, nisi libero ultricies magna, eu efficitur tellus tortor quis massa. Vivamus sagittis eleifend interdum.",
    "Aliquam ultricies dui leo, sit amet blandit nisi cursus a. Phasellus imperdiet id nulla nec egestas. Vestibulum rutrum efficitur velit. Pellentesque tristique condimentum vulputate. Suspendisse ac lectus fringilla, tempus tellus sit amet, commodo turpis. Nam porttitor odio neque, eget tempor metus viverra at. Quisque vel dolor at augue finibus pharetra sit amet sit amet purus. Fusce et luctus nulla.",
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget eros in ex lobortis dictum ut vel nisl. Nullam lobortis lorem at leo maximus rhoncus. Aliquam vestibulum auctor tellus non tristique. Integer varius ac velit tempus lacinia. Sed luctus iaculis massa, id accumsan ante venenatis at. ",
    "Donec elit justo, gravida vitae sagittis ut, dignissim id lacus. Curabitur cursus pharetra nulla quis pellentesque. In arcu lorem, tincidunt eu ante nec, accumsan tincidunt elit.\n\nVivamus erat sapien, pellentesque in nisi non, fermentum ullamcorper est. Pellentesque ornare dui sed consequat vestibulum. Pellentesque in odio ante."];
    function getRandomInt(max) {
    	  return Math.floor(Math.random() * Math.floor(max));
    	}
    
    i = getRandomInt(6);
    // 
    tx = tab[i];
    document.getElementById("message").innerHTML = tx;
    l =getRandomInt(6);
    tx= tab[l];
    document.getElementById("libelle").value=tx.substring(0,20 + getRandomInt(40));
    </script>
    @endsection
@endif
@section('content')

<div class="container mt-5 mb-5">
            <div class="row">
               <div class="col-lg-5 col-sm-12 col-12">
                  <div class="mendas-data">
                     <h4 class="text-center mb-3">Ma demande</h4>
					 @if (session('status'))
                        <div class="alert alert-success" role="alert">
                            {{ session('status') }}
                        </div>
                    @endif
                    @if ($errors->any())
        				<ul class="alert alert-warning">
        					@foreach ($errors->all() as $error)
        					<li>{{$error}}</li> @endforeach
        				</ul>
        				@endif 
        				@if(session()->has('message'))
        				<div class="alert alertToolsBar alert-info alert-dismissible fade show }}"> 
                        {!! session('message') !!}
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                          </button>
                        </div>
    			@endif
				<!-- <div class="row mb-5"> -->
					 <!-- <form action="{{route('demandes.index')}}" method="get">
                		@if (request()->user) <input type="hidden" name="user" value="{{request()->user}}" />@endif
                     <div class="row mb-5">
                        <div class="col-lg-6 col-sm-6 col-12">
                           <div class="form-group row mb-0">
                              <label class="col-3">
                                 <div class="label-text">
                                   <span id="basic-addon1"> <i class="fas fa-calendar-week mr-2"></i> DU</span>
                                 </div>
                              </label>
                              <div class="col-9">
								 <input type="text" class=" calendar form-control"   value="{{request()->datedeb}}" id="datedeb" name="datedeb" placeholder="jj/mm/aaaa" aria-label="nom" aria-describedby="basic-addon2">
                                 <hr class="mt-1 mb-1">
                              </div>
                           </div>

                           <div class="form-group row mb-0">
                              <label class="col-3">
                                 <div class="label-text">
                                    <i class="fas fa-calendar-week mr-2"></i> AU
                                 </div>
                              </label>
                              <div class="col-9">
							  <input type="text" class="form-control calendar" value="{{request()->datefin}}" id="datefin" name="datefin" placeholder="jj/mm/aaaa" aria-label="nom" aria-describedby="basic-addon2">
                                 </div>
                           </div>
						
                        </div>

                        <div class="col-lg-6 col-sm-6 col-12">
                           <div class="form-group row mb-0">
                              <label class="col-2">
                                 <div class="label-text">
                                    <i class="fas fa-clock"></i>
                                 </div>
                              </label>
                              <div class="col-10">
                                 <input type="checkbox"> Matin&eacute;e
                              </div>
                           </div>

                           <div class="form-group row mb-0">
                              <label class="col-2">
                                 <div class="label-text">
                                    <i class="fas fa-clock"></i>
                                 </div>
                              </label>
                              <div class="col-10">
                                 <input type="checkbox"> Apr&egrave;s-midi
                              </div>
                           </div>
                        </div>
				    	<div class="col-9 filter_div">
<button class="btn-color filter" type="submit"><i class="fas fa-search"></i> Filtrer</button>
<button onclick="document.getElementById('datedeb').value=document.getElementById('datefin').value='';" class="float-right btn-color cancel" type="submit"><i class="fas fa-window-close"></i> Annuler</button>
                        </div>
                     </div>
</form> -->

                        
                     <!-- </div> -->

                     

					 <form method="POST" class="" enctype="multipart/form-data"
						action="{{ route('demandes.store') }}">
						@csrf
						<div class="form-group">
                        <label class="text-left d-block"><span class="oc1">
							@if (!$adresses)
							
						&Eacute;tape 1 :
						
						<a href="{{route('adresses.create','from=demande')}}">Créer une nouvelle adresse</a>
						
						@endif 
						@if (count($adresses) > 0)
						<strong>Adresse</strong></apsn></label>
						 <select id="adresse_id" name="adresse_id"
									class="form-control form-text-field"> @foreach ($adresses as $adresse)
									<option value="{{$adresse->id}}"
										@if($adresse->id==old('adresse_id') || $adresse->id==session('new_adresse_id')) selected
										@endif>{{$adresse->libelle}}</option> @endforeach
								</select>
								
								<a href="{{route('adresses.create','from=demande')}}">Créer une nouvelle adresse</a>
								@endif
							
						</div>
						@if ($adresses)
                       <div class="form-group">
                        <label class="text-left d-block"><span class="oc1"><strong>LIBELL&Eacute;</strong></apsn></label>
                         <input type="text" id="libelle" name="libelle" class="form-control form-text-field" placeholder="ex: réparation porte couloir" value="@if ($errors->any()){{old('libelle')}} @endif">
                       </div>

                       <div class="form-group">
                        <label class="text-left d-block"><span class="oc1"><strong>DESCRIPTION</strong></span></label>
						 <textarea id="message" class="form-control form-text-field rounded" rows="5"  placeholder="Indiquer en d&eacute;tail votre demande" name="message">{{old('message')}}</textarea>
							 </div>
                     </form>
					 <div class="form-group">
                            <label for="document">Ajouter des fichiers (photo, document PDF...)</label>
                                <input type="file" class="form-control-file" name="documents[]">
                                <input type="file" class="form-control-file" name="documents[]">
                                <input type="file" class="form-control-file" name="documents[]">
                            </div>
								
							<button type="submit" class="btn-color">{{ __('Create')}}</button>
								

                     <p class="text-left mt-3 mb-3"><a data-toggle="confirmation" data-title="Confirmer?" href="{{ route('demandes.index') }}" class="text-dark"><i class="fas fa-chevron-left mr-2"></i>{{__('Cancel')}}</a></p>
                     
                  </div>
               </div>
            </div>
         </div>
@endif
         <img src="{{asset('image/PersonnageMecanicien.png')}}" class="comman-image-all">
@endsection
