<?php $__env->startSection('morejs'); ?>
<script type="text/javascript">

function removeAdresse(adrId,adrName){
	if (document.getElementById(adrId).checked==true)
		alert("impossible de supprimer l'adresse par défaut")
	else
	if (confirm("Cette adresse sera supprimée lors de l'enregistrement. Confirmer ?")){
		document.getElementById('adr_'+adrId).innerHTML = '<span class="text-warning">'+adrName + ' à supprimer</span>';
		document.getElementById('s_'+adrId).value=adrId;
	}
}
//
</script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('morecss'); ?>
<style>
.flex-item{width:120px}
</style>
<?php $__env->stopSection(); ?> 
<?php $__env->startSection('content'); ?>
<div class="container">
	<div class="justify-content-center">
		<div class="">
			<div class="card">
				<div class="card-header">
					<?php if(Auth::id()==$user->id): ?>
							<h1>Mon compte</h1>
							<?php else: ?>
							<h1>Modifier <?php echo e($user->full_name); ?></h1>
							<?php endif; ?>
							
				</div>
				<div class="card-body">
					<?php if($user->prestataire): ?>
					<p>&Eacute;valuation moyenne : <?php echo e($scoring_calcule); ?></p>
					<?php endif; ?>
					<form method="post" action="<?php echo e($route); ?>">
						<?php echo e(csrf_field()); ?> 
						<?php echo e(method_field('patch')); ?>

						<fieldset>
							<?php if(Auth::id()==$user->id): ?>
							<legend>Mes informations</legend>
							<?php else: ?>
							<legend>Informations</legend>
							<?php endif; ?>
							<div class="form-group row">
								<label for="name" class="col-md-4 col-form-label text-md-right"><?php echo e(__('Name')); ?></label>

								<div class="col-md-6">
									<input id="name" type="text"
										class="form-control<?php echo e($errors->has('name') ? ' is-invalid' : ''); ?>"
										name="name" value="<?php echo e($user->name); ?>" required autofocus>
										<?php if($errors->has('name')): ?> 
											<span class="invalid-feedback" role="alert"> <strong><?php echo e($errors->first('name')); ?></strong>
										</span> 
										<?php endif; ?>
								</div>
							</div>

							<div class="form-group row">
								<label for="surname"
									class="col-md-4 col-form-label text-md-right"><?php echo e(__('Surname')); ?></label>

								<div class="col-md-6">
									<input id="surname" type="text"
										class="form-control<?php echo e($errors->has('surname') ? ' is-invalid' : ''); ?>"
										name="surname" value="<?php echo e($user->surname); ?>" required autofocus>

									<?php if($errors->has('surname')): ?> <span class="invalid-feedback"
										role="alert"> <strong><?php echo e($errors->first('surname')); ?></strong>
									</span> <?php endif; ?>
								</div>
							</div>

							<div class="form-group row">
								<label for="email" class="col-md-4 col-form-label text-md-right"><?php echo e(__('E-Mail Address')); ?></label>

								<div class="col-md-6">
									<input id="email" type="email"
										class="form-control<?php echo e($errors->has('email') ? ' is-invalid' : ''); ?>"
										name="email" value="<?php echo e($user->email); ?>" required>
										<?php if($errors->has('email')): ?> 
										<span class="invalid-feedback"
										role="alert"> <strong><?php echo e($errors->first('email')); ?></strong>
										</span>
										<?php endif; ?>
								</div>
							</div>
							
							<div class="form-group row">
								<label for="telephone"
									class="col-md-4 col-form-label text-md-right"><?php echo e(__('Téléphone')); ?></label>

								<div class="col-md-6">
									<input id="telephone" type="text"
										class="form-control<?php echo e($errors->has('telephone') ? ' is-invalid' : ''); ?>"
										name="telephone" value="<?php echo e($user->telephone); ?>" required autofocus>

									<?php if($errors->has('telephone')): ?> <span class="invalid-feedback"
										role="alert"> <strong><?php echo e($errors->first('telephone')); ?></strong>
									</span> <?php endif; ?>
								</div>
							</div>
						</fieldset>
						<?php if(Auth::user()->isClient()): ?>
						<fieldset>
							<legend><i class="fas fa-building"></i> Mon entreprise</legend>
							<div class="form-group row">
								<label for="societe" class="col-md-4 col-form-label text-md-right">Raison sociale</label>

								<div class="col-md-6">
									<input id="societe" type="text"
										class="form-control<?php echo e($errors->has('societe') ? ' is-invalid' : ''); ?>"
										name="societe" value="<?php echo e($user->societe); ?>" >
										<?php if($errors->has('societe')): ?> 
											<span class="invalid-feedback" role="alert"> <strong><?php echo e($errors->first('societe')); ?></strong>
										</span> 
										<?php endif; ?>
								</div>
							</div>
							<div class="form-group row">
								<label for="siret" class="col-md-4 col-form-label text-md-right">Siret</label>
								
								<div class="col-md-6">
									<input id="siret" type="text"
										class="form-control<?php echo e($errors->has('siret') ? ' is-invalid' : ''); ?>"
										name="siret" value="<?php echo e($user->siret); ?>" >
										<?php if($errors->has('siret')): ?> 
											<span class="invalid-feedback" role="alert"> <strong><?php echo e($errors->first('siret')); ?></strong>
										</span> 
										<?php endif; ?>
								</div>
							</div>
						</fieldset>
						<fieldset>
							<legend><i class="fas fa-home"></i> Mes adresses</legend>
							<div class="form-group">
								<?php if(count($adresses) > 0): ?>
								<small>Mon adresse de facturation par défaut</small>
									<div class="d-flex flex-row flex-wrap align-content-around form-group row col-12">
    									<?php $__currentLoopData = $adresses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $adresse): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    	<div class="form-check col-3 mb-2" id="adr_<?php echo e($adresse->id); ?>">
                                    
                                    	<input class="form-check-input" type="radio" name="adresse_pardefaut_id" id="<?php echo e($adresse->id); ?>" value="<?php echo e($adresse->id); ?>"
                                    	 <?php if($adresse->id==old('adresse_pardefaut_id') || $adresse->par_defaut): ?> checked
    										<?php endif; ?> />
                                          <label class="form-check-label" for="<?php echo e($adresse->id); ?>">
                                            <?php echo e($adresse->libelle); ?>

                                          </label>
                                          <div class="bg-white position-absolute" style="top:0;right:1em">
                                          	<a class="px-1 py-0 btn btn-primary" href="<?php echo e(route('adresses.edit',$adresse->id)); ?>" ><i class="fas fa-edit"></i></a>
                                          	<?php if(!App\Demande::where('adresse_id','=',$adresse->id)->exists()): ?>
                                          	<a class="px-1 py-0 btn btn-danger" href="#" onclick="removeAdresse('<?php echo e($adresse->id); ?>','<?php echo e($adresse->libelle); ?>')"><i class="fas fa-trash-alt"></i></a>
                                          	<?php endif; ?>
                                          </div>
    									</div>
    									<input name="adresses_supprimees[]" type="hidden" id="s_<?php echo e($adresse->id); ?>" value=""/>
    									<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

								<?php endif; ?>
								<a href="<?php echo e(route('adresses.create')); ?>" class="btn px-1 py-0 btn-info"><i class="fas fa-plus-square"></i> Nouvelle adresse</a>
							</div>
						</fieldset>
						<?php endif; ?>
						<?php if(Auth::user()->isAdmin() && Auth::id()==$user->id ): ?>
						
    					<fieldset>
							<legend><i class="fas fa-building"></i> Mon entreprise</legend>
							<p>Raison sociale : <?php echo e($societe->raison_sociale); ?><br/>
							Siret : <?php echo e($societe->siret); ?>

							</p>
							<p><a href="<?php echo e(route('config.edit')); ?>">Modifier les informations <strong><em><?php echo e($societe->raison_sociale); ?></em></strong></a></p>
						</fieldset>	
						<?php endif; ?>
						<?php if(Auth::user()->isAdmin()): ?>
						<fieldset>
							<legend>
								<i class="fas fa-tag"></i> Profil
							</legend>
							<div class="d-flex flex-row flex-wrap justify-content-between form-group">
    							<div class="alert alert-danger">
    								<label class="" for="admin">Administrateur</label> 
    								<input id="admin"
    								name="admin" class="form-control form-control-lg" type="checkbox"
    								<?php if($user->admin == 1): ?>
    								checked="checked"
    								<?php endif; ?>
    								/>
    							</div>
    							<div class="">
    								<label class="" for="assistant">Assistant</label> 
    								<input id="assistant"
    								name="assistant" class="form-control form-control-lg" type="checkbox"
    								<?php if($user->assistant): ?> == 1)
    								checked="checked"
    								<?php endif; ?>
    								/>
    							</div>
    							<div class="">
    								<label class="" for="prestataire">Prestataire</label> 
    								<input id="prestataire"
    								name="prestataire" class="form-control form-control-lg" type="checkbox"
    								<?php if($user->prestataire): ?> == 1)
    								checked="checked"
    								<?php endif; ?>
    								/>
    							</div>
    						</div>
						</fieldset>
                        <?php endif; ?>
						
						<?php if(Auth::user()->id==$user->id): ?>
						<fieldset>
							<legend><?php echo e(__('Change my password')); ?></legend>
							<div class="form-group row">
								<label for="password-old"
									class="col-md-4 col-form-label text-md-right"><?php echo e(__('Old password')); ?></label>

								<div class="col-md-6">
									<input id="password-old" type="password"
										class="form-control<?php echo e($errors->has('password-old') ? ' is-invalid' : ''); ?>"
										name="password-old"> <?php if($errors->has('password-old')): ?> <span
										class="invalid-feedback" role="alert"> <strong><?php echo e(__('failed')); ?></strong>
									</span> <?php endif; ?>
								</div>
							</div>
							<div class="form-group row">
								<label for="password"
									class="col-md-4 col-form-label text-md-right"><?php echo e(__('New password')); ?></label>

								<div class="col-md-6">
									<input id="password" type="password"
										class="form-control<?php echo e($errors->has('password') ? ' is-invalid' : ''); ?>"
										name="password"> <?php if($errors->has('password')): ?> <span
										class="invalid-feedback" role="alert"> <strong><?php echo e($errors->first('password')); ?></strong>
									</span> <?php endif; ?>
								</div>
							</div>

							<div class="form-group row">
								<label for="password-confirm"
									class="col-md-4 col-form-label text-md-right"><?php echo e(__('Confirm password')); ?></label>

								<div class="col-md-6">
									<input id="password-confirm" type="password"
										class="form-control" name="password_confirmation">
								</div>
							</div>

						</fieldset>
						<?php endif; ?>
						<div class="form-group row mb-0">
							<div class="col">
								<a href="javascript:history.back()" class="btn btn-primary"> <span
									class="glyphicon glyphicon-circle-arrow-left"></span>
									<?php echo e(__('Cancel')); ?>

								</a>
							</div>
							<div class="col">
								<button type="submit" class="btn btn-primary"><?php echo e(__('Update')); ?>

								</button>
							</div>
						</div>
					</form>
				</div>
				<div class="card-footer">
					<a href="<?php echo e(route('home')); ?>" class="btn">Retour à l'accueil</a>
				</div>
			</div>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\HelloDjo_Source\resources\views/users/edit.blade.php ENDPATH**/ ?>