
<?php \Laravel\Section::start('content'); ?>

<div class="wrapper pageType monCompte">
	
	<h1>Mon compte</h1>
	
	<?php // Infos personnelles ?>
	<div class="bandeauTitle2">Mes coordonnées</div>

	<?php if(Session::get('type')): ?>
	<div class="alert alert-<?php echo  Session::get('type') ; ?>">
		<button type="button" class="close" data-dismiss="alert">×</button>
		<?php echo  Session::get('message') ; ?>
	</div>
	<?php elseif(isset($_GET['vads_trans_status']) && $_GET['vads_trans_status']=='AUTHORISED'): ?>
	<div class="alert alert-success">
		<button type="button" class="close" data-dismiss="alert">×</button>
		Merci ! Votre paiement a bien été effectué. Notre équipe va réaliser le montage du cadeau vidéo.
	</div>
	<?php endif; ?>
	
	<div class="left infosPerso">
		<form method="post" action="<?php echo  URL::to_action('customerarea@infos'); ; ?>">
			<div class="row-fluid">
				<p class="span5 infos">
					<?php echo  strtoupper($customer->last_name.' '.$customer->first_name) ; ?><br />
					<?php echo  $customer->email ; ?><br />
					<?php echo  $customer->tel ; ?>
				</p>
				
				<div class="span7 infos2" style="display:none;">
					<?php echo  Form::text('last_name', Input::old('last_name', (isset($customer) ? $customer->last_name : NULL)), array('class'=>'requis', 'placeholder'=>'Nom','style'=>($errors->first('last_name')) ? 'border-color:#e85256' : '')) ; ?>
					<?php echo  Form::text('first_name', Input::old('first_name', (isset($customer) ? $customer->first_name : NULL)), array('class'=>'requis', 'placeholder'=>'Prénom','style'=>($errors->first('first_name')) ? 'border-color:#e85256' : '')) ; ?>
					<?php echo  Form::text('email', Input::old('email', (isset($customer) ? $customer->email : NULL)), array('class'=>'requis', 'placeholder'=>'Adresse email','style'=>($errors->first('email')) ? 'border-color:#e85256' : '')) ; ?>
					<?php echo  Form::text('tel', Input::old('tel', (isset($customer) ? $customer->tel : NULL)), array('class'=>'requis', 'placeholder'=>'Téléphone','style'=>($errors->first('tel')) ? 'border-color:#e85256' : '')) ; ?>
					<?php echo  Form::text('password','',array('placeholder'=>'Mot de passe', 'autocomplete'=>'off')); ; ?>
					<?php if($customer): ?>
					<br /><span class="help-inline">Laissez vide si vous ne souhaitez pas mettre à jour le mot de passe.</span>
					<?php endif; ?>
				</div>
			</div>
			<div class="clear"></div>
			<a href="#" class="left btn btn-cadeau btnModif" title="Modifier">Modifier</a>
			<a href="#" class="left btn btn-cadeau btnAnnul" title="Annuler" style="display:none;">Annuler</a>
			<button type="submit" class="right btn btn-cadeau btnSave" style="display:none;"><i class="icon-save"></i></button>
		</form>
		
		<script type="text/javascript">
		// Switch
		function afficherCompte2(){
			$('.infos2').hide();
			$('.btnModif').show();
			$('.btnAnnul').hide();
			$('.btnSave').hide();
		}
		function afficherCompte1(){
			$('.infos2').show();
			$('.btnModif').hide();
			$('.btnAnnul').show('fast');
			$('.btnSave').show('fast');
		}
		$('.btnModif').on('click',function(e){
			e.preventDefault();
			afficherCompte1();
		});
		$('.btnAnnul').on('click',function(e){
			e.preventDefault();
			afficherCompte2();
		});
		<?php if(Session::get('type')): ?>
			<?php if(Session::get('type')=='error'): ?>
				afficherCompte1();
			<?php endif; ?>
		<?php endif; ?>
		</script>
	</div>
	<div class="clear"></div>
	
	<?php // Les projets ?>
	<div class="bandeauTitle2">Les cadeaux vidéo en cours</div>
	<?php if(count($projects)>=1): ?>
		<?php foreach($projects as $p): ?>
		<div class="left blankList blankListProjet">
			<i class="left icon-sign-blank hidden_mobile"></i>
			<div class="left">
				<strong><?php echo $p->name; ?></strong><br />
				<?php if($p->is_paid == 'y'): ?>
				<p><span class="label label-success">Merci, ce projet a bien été clôturé & réglé !</span></p>
				<?php elseif($p->date_passed()): ?>
					Date limite de participation passée : <span class="label label-important"><?php echo  DateFunctions::format_date($p->date_limite) ; ?></span>
				<?php else: ?>
					Date limite de participation : <?php echo  DateFunctions::format_date($p->date_limite) ; ?>
				<?php endif; ?>
			</div>
			
			<a href="<?php echo  URL::to_route('customer_projet', $p->id) ; ?>" class="btn btn-cadeau right details">Modifier</a>
			<?php if($p->is_paid == 'y' || $p->date_passed()): ?>
			<a href="#" data-pos="<?php echo $p->id; ?>" class="btn right details btnDetails"><i class="arrow icon-caret-down"></i> Détails</a>
			<?php endif; ?>
			
			<?php if($p->is_paid == 'n' && $p->date_passed() && $p->real_participants()>=1): ?>
			<a href="#modal_cloture_<?php echo $p->id; ?>" data-toggle="modal" class="btn btn-warning right details">Clôturer</a>
			
			<!-- MODAL de cloture de projet -->
			<form class="form-horizontal" action="<?php echo  URL::to_route('customer_projet_close', $p->id) ; ?>" method="POST">
			<div id="modal_cloture_<?php echo $p->id; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			  <div class="modal-header">
			    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			    <h3 id="myModalLabel" style="margin:10px 0">Clôturer ce projet</h3>
			  </div>
			  <div class="modal-body">
			    <p style="font-size:15px;text-align:justify"><?php echo $p->real_participants(); ?> personne(s) ont participé à ce projet et vous êtes sur le point de régler <?php echo $p->price_to_pay(); ?> euros. Cette action marque la clôture du projet. Une fois le règlement effectué, notre équipe réalisera le montage du cadeau vidéo de <?php echo $p->cible_first_name; ?> <?php echo $p->cible_last_name; ?>. Vous le recevrez par email sous 3 jours ouvrés.</p>
				<div style="text-align:center;margin-top:15px">
					<p>Vous avez un code promotionnel ?</p>
					<input type="text" id="couponcode_<?php echo $p->id; ?>" name="couponcode" placeholder="" style="width:60%" />
				</div>
			  </div>
			  <div class="modal-footer">
			    <button class="btn" data-dismiss="modal" aria-hidden="true">Annuler</button>
			    <button class="btn btn-warning" onclick="return window.confirm('Clotûrer ce projet et régler maintenant ?');">Clôturer et régler</button>
			  </div>
			</div>
			</form>
			<?php endif; ?>
		</div>
		<div>
		<div class="left projetDetails projetDetails_<?php echo $p->id; ?>"<?php echo($p->is_paid == 'y' || $p->date_passed()) ? ' style="display:none;"' : '' ?>>
			<div class="row-fluid">
				<div class="span6">
					<div class="sousTitle"><strong>Les questions :</strong></div>
					<?php echo  $p->question1 ; ?><br>
					<?php echo  $p->question2 ; ?><br>
					<?php echo  $p->question3 ; ?><br>
					<?php echo  $p->question4 ; ?><br>
					<?php echo  $p->question5 ; ?>
					<br><br>
				</div>
				<div class="span6">
					<div class="sousTitle"><strong>Ils ont participés</strong> - <?php echo $p->real_participants(); ?> participant(s)</div>
					<?php if($p->real_participants()>=1): ?>
						<?php foreach($p->invites as $pi): ?>
							<?php if($pi->video!=''): ?>
							<strong><?php echo  $pi->last_name.' '.$pi->first_name ; ?></strong> - <?php echo $pi->email; ?><br>
							<?php endif; ?>
						<?php endforeach; ?>
					<?php else: ?>
						Aucun participant.<br>
					<?php endif; ?>
					<br>
				</div>
			</div>
			<div class="clear"></div>
			<div class="sousTitle"><strong>Lien pour les participants :</strong> <a href="<?php echo  URL::to_route('participer', array($p->id, $p->share_url)) ; ?>" target="_blank"><?php echo  URL::to_route('participer', array($p->id, $p->share_url)) ; ?></a></div>
			<div class="clear"></div>
			<div class="sousTitle"><strong>La photo :</strong></div>
			<?php if($p->photo && $p->photo!=''): ?>
				<img src="<?php echo  URL::to_route('photoprojets', array('546', '320', $p->photo)) ; ?>" alt="<?php echo $p->name; ?>" title="<?php echo $p->name; ?>" />
			<?php else: ?>
				<img src="http://placehold.it/546x320&text=Le+Cadeau+Video">
			<?php endif; ?>
			<?php /*
			<br><br>
			<div class="clear"></div>
			<a href="<?php echo  URL::to_route('customer_projet', $p->id) ; ?>" class="btn btn-cadeau right">Editer</a>
			*/ ?>
		</div>
		</div>
		<div class="clear"></div>
		<?php endforeach; ?>
		<script type="text/javascript">
		$('.btnDetails').each(function(){
			$(this).on('click',function(e){
				e.preventDefault();
				var id = $(this).attr('data-pos');
				$('.projetDetails_'+id).toggle(200);
			});
		});
		</script>
	<?php else: ?>
		Aucun projet actuellement.<br /><br />
	<?php endif; ?>
	<div class="clear"></div><br />
	
	<?php // Mes fichiers ?>
	<div class="bandeauTitle2">Mes fichiers</div>
	
	<?php if(count($customer_files)>=1): ?>
		<?php foreach($customer_files as $f): ?>
		<div class="left blankList">
			<i class="left icon-sign-blank hidden_mobile"></i>
			<div class="left">
				<strong><?php echo  substr($f->name, 14) ; ?></strong><br />
				<a href="<?php echo  URL::to_asset('/uploads/files/customers/'.$f->name) ; ?>" target="_blank">Ouvrir le fichier "<?php echo  substr($f->name, 14) ; ?>"</a>, <?php echo  DateFunctions::format_date($f->created_at) ; ?>
			</div>
		</div>
		<?php endforeach; ?>
	<?php else: ?>
		Aucun fichier actuellement.<br /><br />
	<?php endif; ?>
	<div class="clear"></div><br />
	
</div>
<div class="clear"></div>

<?php \Laravel\Section::stop(); ?>
<?php echo view('template')->with(get_defined_vars())->render(); ?>