<!-- Edit this file to change the layout of the detail view form -->

<a name="detail-view"></a>
<div class="panel-heading"><h3 class="panel-title"><strong><%%DETAIL_VIEW_TITLE%%></strong></h3></div>

<div class="panel-body" id="dossier_individuel_dv_container">
	<!-- child links -->
	<div class="row vspacer-md">
		<div class="col-xs-12">
			<input type="hidden" id="permissions_hclink" value="permissions_view.php?filterer_nom_prenom=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<input type="hidden" id="conges_hclink" value="conges_view.php?filterer_nom_prenom=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<input type="hidden" id="fiche_pointages_hclink" value="fiche_pointages_view.php?filterer_nom_prenom_fp=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<input type="hidden" id="ordres_missions_hclink" value="ordres_missions_view.php?filterer_nom_prenom=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<input type="hidden" id="decomptes_hclink" value="decomptes_view.php?filterer_matricule=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<input type="hidden" id="informations_hclink" value="informations_view.php?filterer_matricule=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<input type="hidden" id="carrieres_hclink" value="carrieres_view.php?filterer_matricule=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<input type="hidden" id="expenses_hclink" value="expenses_view.php?filterer_matricule=<%%URLVALUE(iddindividuel)%%>&<%%EMBEDDED%%>">
			<div class="clearfix"></div>
		</div>
	</div>
	<hr class="hidden-xs hidden-sm">

	<div class="row">
		<!-- form inputs -->
		<div class="col-md-8 col-lg-10" id="dossier_individuel_dv_form">
			<fieldset class="form-horizontal">

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="option_prime" class="control-label col-lg-3" data-parent_link="view_parent_modal">PRIME</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(option_prime)%%><%%PLINK(option_prime)%%><%%ADDNEW(gestion_primes)%%><span id="option_primeLoading"></span></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="matricule" class="control-label col-lg-3">Matricule</label>
					<div class="col-lg-9">
						<input maxlength="255" type="text" class="form-control" name="matricule" id="matricule" value="<%%VALUE(matricule)%%>"><div class="text-danger vspacer-md" id="matricule-uniqueness-note" style="display: none;"><%%TRANSLATION(unique field error)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="nom_prenom" class="control-label col-lg-3">Nom & Pr&#233;nom</label>
					<div class="col-lg-9">
						<input maxlength="255" type="text" class="form-control" name="nom_prenom" id="nom_prenom" value="<%%VALUE(nom_prenom)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="date_naissance" class="control-label col-lg-3">Date de naissance</label>
					<div class="col-lg-9">
						<%%COMBO(date_naissance)%%>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="age" class="control-label col-lg-3">Age</label>
					<div class="col-lg-9">
						<input maxlength="" type="text" class="form-control" name="age" id="age" value="<%%VALUE(age)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="matrimoniale" class="control-label col-lg-3">Matrimoniale</label>
					<div class="col-lg-9">
						<%%COMBO(matrimoniale)%%>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="enfants" class="control-label col-lg-3">Enfants</label>
					<div class="col-lg-9">
						<input maxlength="" type="text" class="form-control" name="enfants" id="enfants" value="<%%VALUE(enfants)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="nni" class="control-label col-lg-3">NNI</label>
					<div class="col-lg-9">
						<input maxlength="255" type="text" class="form-control" name="nni" id="nni" value="<%%VALUE(nni)%%>"><div class="text-danger vspacer-md" id="nni-uniqueness-note" style="display: none;"><%%TRANSLATION(unique field error)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="telephone" class="control-label col-lg-3">T&#233;l&#233;phone</label>
					<div class="col-lg-9">
						<input maxlength="255" type="text" class="form-control" name="telephone" id="telephone" value="<%%VALUE(telephone)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="courriel" class="control-label col-lg-3">Courriel</label>
					<div class="col-lg-9">
						<input maxlength="255" type="text" class="form-control" name="courriel" id="courriel" value="<%%VALUE(courriel)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="postale" class="control-label col-lg-3">Boite postale</label>
					<div class="col-lg-9">
						<input maxlength="255" type="text" class="form-control" name="postale" id="postale" value="<%%VALUE(postale)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="date_recrutement" class="control-label col-lg-3">Date de recrutement</label>
					<div class="col-lg-9">
						<%%COMBO(date_recrutement)%%>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="statut" class="control-label col-lg-3" data-parent_link="view_parent_modal">Statut</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(statut)%%><%%PLINK(statut)%%><%%ADDNEW(statuts)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="direction" class="control-label col-lg-3" data-parent_link="view_parent_modal">Direction</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(direction)%%><%%PLINK(direction)%%><%%ADDNEW(directions)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="fonction" class="control-label col-lg-3" data-parent_link="view_parent_modal">Fonction</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(fonction)%%><%%PLINK(fonction)%%><%%ADDNEW(fonctions)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="service" class="control-label col-lg-3" data-parent_link="view_parent_modal">Service</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(service)%%><%%PLINK(service)%%><%%ADDNEW(services)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="division" class="control-label col-lg-3" data-parent_link="view_parent_modal">Division</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(division)%%><%%PLINK(division)%%><%%ADDNEW(divisions)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="categorie" class="control-label col-lg-3" data-parent_link="view_parent_modal">Categorie</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(categorie)%%><%%PLINK(categorie)%%><%%ADDNEW(categories)%%><span id="categorieLoading"></span></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="anciennete" class="control-label col-lg-3">Anciennet&#233;</label>
					<div class="col-lg-9">
						<input maxlength="" type="text" class="form-control" name="anciennete" id="anciennete" value="<%%VALUE(anciennete)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="salaire" class="control-label col-lg-3">Salaire</label>
					<div class="col-lg-9">
						<input maxlength="10" type="text" class="form-control" name="salaire" id="salaire" value="<%%VALUE(salaire)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="prime" class="control-label col-lg-3">Prime</label>
					<div class="col-lg-9">
						<div class="form-control-static" id="prime"></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="compte" class="control-label col-lg-3">Compte</label>
					<div class="col-lg-9">
						<input maxlength="255" type="text" class="form-control" name="compte" id="compte" value="<%%VALUE(compte)%%>">
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="banque" class="control-label col-lg-3" data-parent_link="view_parent_modal">Banque</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(banque)%%><%%PLINK(banque)%%><%%ADDNEW(banques)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Curriculum vitae <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#cv-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block collapse" id="cv-description"><div class="alert alert-info">Maximum file size allowed: 10000 KB.<br>Allowed file types: txt, doc, docx, docm, odt, pdf, rtf</div></span>

						
						<div class="row">
							<div class="col-md-1">
								<a id="cv-link" href="link.php?t=dossier_individuel&f=cv&i=<%%VALUE(iddindividuel)%%>" target="_blank"><i class="glyphicon glyphicon-file" title="<%%VALUE(cv)%%>" style="font-size: x-large; top: .35em;"></i></a>
							</div> <!-- /div.col-* -->
							<script>jQuery(function() { /* */ var e_cv = '<%%VALUE(cv)%%>'; if(e_cv == '' || e_cv == '&nbsp;' || e_cv == 'blank.gif') jQuery('#cv-link').hide(); });</script>						<div class="pull-right well upload-toolbox">
							<div class="hidden-md hidden-lg vspacer-lg"></div>
							<%%UPLOADFILE(cv)%%>
							<%%REMOVEFILE(cv)%%>
							<div class="text-bold text-danger file-type-error hidden">
								<%%TRANSLATION(invalid file type)%%>
							</div>
							<div class="text-bold text-danger file-size-error hidden">
								<%%TRANSLATION(file too large)%%>
							</div>
						</div>
						<div class="clearfix"></div>
					</div>

					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Dossier <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#dossier-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block collapse" id="dossier-description"><div class="alert alert-info">Maximum file size allowed: 10000 KB.<br>Allowed file types: zip, rar, gz, tar, iso</div></span>

						
						<div class="row">
							<div class="col-md-1">
								<a id="dossier-link" href="link.php?t=dossier_individuel&f=dossier&i=<%%VALUE(iddindividuel)%%>" target="_blank"><i class="glyphicon glyphicon-folder-open" title="<%%VALUE(dossier)%%>" style="font-size: x-large; top: .35em;"></i></a>
							</div> <!-- /div.col-* -->
							<script>jQuery(function() { /* */ var e_dossier = '<%%VALUE(dossier)%%>'; if(e_dossier == '' || e_dossier == '&nbsp;' || e_dossier == 'blank.gif') jQuery('#dossier-link').hide(); });</script>						<div class="pull-right well upload-toolbox">
							<div class="hidden-md hidden-lg vspacer-lg"></div>
							<%%UPLOADFILE(dossier)%%>
							<%%REMOVEFILE(dossier)%%>
							<div class="text-bold text-danger file-type-error hidden">
								<%%TRANSLATION(invalid file type)%%>
							</div>
							<div class="text-bold text-danger file-size-error hidden">
								<%%TRANSLATION(file too large)%%>
							</div>
						</div>
						<div class="clearfix"></div>
					</div>

					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Contrat <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#contrat-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block collapse" id="contrat-description"><div class="alert alert-info">Maximum file size allowed: 10000 KB.<br>Allowed file types: zip, rar, gz, tar, iso</div></span>

						
						<div class="row">
							<div class="col-md-1">
								<a id="contrat-link" href="link.php?t=dossier_individuel&f=contrat&i=<%%VALUE(iddindividuel)%%>" target="_blank"><i class="glyphicon glyphicon-folder-open" title="<%%VALUE(contrat)%%>" style="font-size: x-large; top: .35em;"></i></a>
							</div> <!-- /div.col-* -->
							<script>jQuery(function() { /* */ var e_contrat = '<%%VALUE(contrat)%%>'; if(e_contrat == '' || e_contrat == '&nbsp;' || e_contrat == 'blank.gif') jQuery('#contrat-link').hide(); });</script>						<div class="pull-right well upload-toolbox">
							<div class="hidden-md hidden-lg vspacer-lg"></div>
							<%%UPLOADFILE(contrat)%%>
							<%%REMOVEFILE(contrat)%%>
							<div class="text-bold text-danger file-type-error hidden">
								<%%TRANSLATION(invalid file type)%%>
							</div>
							<div class="text-bold text-danger file-size-error hidden">
								<%%TRANSLATION(file too large)%%>
							</div>
						</div>
						<div class="clearfix"></div>
					</div>

					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label class="control-label col-lg-3">Photo <i class="glyphicon glyphicon-info-sign text-info" data-toggle="collapse" data-target="#photo-description"></i></label>
					<div class="col-lg-9">
						<span class="help-block collapse" id="photo-description"><div class="alert alert-info">Maximum file size allowed: 100 KB.<br>Allowed file types: jpg, jpeg, gif, png</div></span>

						<div class="form-control-static well well-sm"><div class="pull-left">

						<a href="<%%TRANSLATION(ImageFolder)%%><%%VALUE(photo)%%>" data-lightbox="dossier_individuel_dv"><img src="thumbnail.php?i=<%%VALUE(photo)%%>&t=dossier_individuel&f=photo&v=dv" class="img-thumbnail" id="photo-image"></a>
</div>

												<div class="pull-right well upload-toolbox">
							<div class="hidden-md hidden-lg vspacer-lg"></div>
							<%%UPLOADFILE(photo)%%>
							<%%REMOVEFILE(photo)%%>
							<div class="text-bold text-danger file-type-error hidden">
								<%%TRANSLATION(invalid file type)%%>
							</div>
							<div class="text-bold text-danger file-size-error hidden">
								<%%TRANSLATION(file too large)%%>
							</div>
						</div>
						<div class="clearfix"></div>
					</div>

					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="observation" class="control-label col-lg-3">Observation</label>
					<div class="col-lg-9">
						<textarea class="form-control" name="observation" id="observation" rows="5"><%%VALUE(observation)%%></textarea>
					</div>
				</div>

			</fieldset>
		</div>

		<!-- DV action buttons -->
		<hr class="hidden-md hidden-lg">
		<div class="col-md-4 col-lg-2" id="dossier_individuel_dv_action_buttons">
			<div class="btn-toolbar">
				<div class="btn-group-vertical btn-group-lg" style="width: 100%;">
					<%%UPDATE_BUTTON%%>
				</div><p></p>
				<div class="btn-group-vertical btn-group-lg" style="width: 100%;">
					<%%DESELECT_BUTTON%%>
					<%%DVPRINT_BUTTON%%>
					<%%DELETE_BUTTON%%>
				</div><p></p>
				<div class="btn-group-vertical btn-group-lg" style="width: 100%;">
					<%%INSERT_BUTTON%%>
				</div>
			</div>
		</div>
	</div>

	<input type="hidden" name="qty" value="<%%VALUE(qty)%%>">

	<!-- child records -->
	<hr>
	<div class="row">
		<div class="col-lg-10 col-lg-offset-1">
			<div id="dossier_individuel-children" class="children-tabs"></div>
		</div>
	</div>

</div><!-- /div class="panel-body" -->
	<script>
		$j(function() {
			var add_new_mode = (!$j('input[name=SelectedID]').val());
			var embedded_mode = ($j('input[name=Embedded]').val() == 1);

			/* auto-close embedded page? */
			var autoclose_mode = ($j('input[name=AutoClose]').val() == 1);
			var record_added_ok = (location.search.split('record-added-ok=').length == 2);
			var record_updated_ok = (location.search.split('record-updated-ok=').length == 2);
			if((record_added_ok || record_updated_ok) && embedded_mode && autoclose_mode) {
				setTimeout(AppGini.closeParentModal, 2000);
			}

			/* enable DV action buttons to float on scrolling down the form */
			enable_dvab_floating();

			setTimeout(AppGini.focusFirstFormElement, 1500);

			$j('form').eq(0).change(function() {
				if($j(this).data('already_changed')) return;
				if($j('#deselect').length) $j('#deselect').removeClass('btn-default').addClass('btn-warning').get(0).lastChild.data = " <%%TRANSLATION(Cancel)%%>";
				$j(this).data('already_changed', true);
			});

			$j('a[href="<%%TRANSLATION(ImageFolder)%%>"]').click(function() { /* */ return false; });

			if(embedded_mode) {
				/* hide links to children tables in embedded mode */
				$j('.detail_view a[id$=_link]').remove();

				/* append embedded mode to all links */
				var append_embedded = function() {
					$j('a[href]:not([href^="#"]):not([href^="javascript"]):not([href$="Embedded=1"]):not([href*="link.php?t="]):not([href^="mailto:"])').each(
						function() {
							$j(this).attr('href', $j(this).attr('href') + '&Embedded=1');
						}
					);
				}
				setTimeout(append_embedded, 500);
				setTimeout(append_embedded, 1500);
				setTimeout(append_embedded, 2500);
				setTimeout(append_embedded, 3500);
			}

			/* when no record is selected ('add new' mode) */
			if(add_new_mode) {
				/* hide links to children tables */
				$j('.detail_view a[id$=_link]').remove();
			}else{
				post(
					'parent-children.php', {
						ParentTable: 'dossier_individuel',
						SelectedID: '<%%VALUE(iddindividuel)%%>',
						Operation: 'show-children'
					},
					'dossier_individuel-children'
				);
			}

			if(!embedded_mode) {
				/* add a horizontal spacer to [add new parent] buttons that don't have a spacered element before them */
				$j('.add_new_parent').prev(':not(.hspacer-md)').next().addClass('hspacer-md');

				$j('.add_new_parent').click(function() {
					var pt = $j(this).attr('id').replace(/_add_new$/, '');
					modal_window({
						url: pt + '_view.php?addNew_x=1&Embedded=1',
						close: function() {
							var field_id = $j('#' + pt + '_add_new').prevAll('input:hidden').eq(0).attr('id');
							$j('#' + field_id + '-container').select2('focus').select2('focus');

							/* if a new parent was added, select it */
							var new_id = localStorage.getItem(pt + '_last_added_id');
							if(new_id === null) return;

							localStorage.clear(pt + '_last_added_id');
							AppGini.lookupText({
								id: new_id,
								table: 'dossier_individuel',
								field: field_id,
								callback: function(data) {
									$j('#' + field_id + '-container').select2('data', data, true);
								}
							});
						},
						size: 'full',
						title: $j(this).attr('title')
					});
				});
			}

			AppGini.hideViewParentLinks();

			$j('form').on('click', '.view_parent', function() {
				var pt = $j(this).attr('id').replace(/_view_parent$/, '');
				if($j(this).prevAll('input:hidden').length) {
					var parent_id = $j(this).prevAll('input:hidden').eq(0).val();
				}else{
					var parent_id = $j(this).prevAll().children('input:hidden').eq(0).val();
				}

				/* handle radio lookups */
				if($j(this).prevAll('[type=radio]').length) {
					parent_id = $j(this).prevAll('[type=radio]').eq(0).val();
				}

				if(parent_id != '{empty_value}' && parent_id != undefined && parent_id != '') {
					var parent_link = $j(this).parents('.form-group').children('label').data('parent_link');
					switch(parent_link) {
						case 'view_parent_hidden':
							break;
						case 'view_parent_modal':
							modal_window({
								url: pt + '_view.php?Embedded=1&SelectedID=' + encodeURIComponent(parent_id),
								close: function() {
									var field_id = $j('#' + pt + '_view_parent').prevAll('input:hidden').eq(0).attr('id');
									$j('#' + field_id + '-container').select2('focus').select2('focus');
								},
								size: 'full',
								title: $j(this).attr('title')
							});
							break;
						case 'view_parent_same_window':
							window.location = pt + '_view.php?Embedded=' + (embedded_mode ? '1' : '') + '&SelectedID=' + encodeURIComponent(parent_id);
							break;
						case 'view_parent_new_window':
							window.open(pt + '_view.php?SelectedID=' + encodeURIComponent(parent_id));
							break;
					}

				}
			});

			enforce_uniqueness('dossier_individuel', 'matricule');
			enforce_uniqueness('dossier_individuel', 'nni');

			/* load admin tools for admin user */
			if(!add_new_mode) {
				$j('body').append('<div id="admin-tools-appendix"></div>');
				$j('#admin-tools-appendix').load(
					'ajax_admin_tools.php?table=dossier_individuel&id=<%%URLVALUE(iddindividuel)%%>',
					function(resp) {
						if(!resp.length) return;
						$j.ajax('ajax_admin_tools.php?action=get_admin_tools_js&table=dossier_individuel&id=<%%URLVALUE(iddindividuel)%%>');
					}
				);
			}

			/* warn user if 'add new' clicked while unsaved changes exist */
			$j('#addNew').click(function() {
				if($j('#deselect.btn-warning').length) {
					return confirm('<%%TRANSLATION(discard changes confirm)%%>');
				}
			});

		});
	</script>