<!-- 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="gestion_banques_dv_container">
	<!-- child links -->
	<div class="row vspacer-md">
		<div class="col-xs-12">
			<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="gestion_banques_dv_form">
			<fieldset class="form-horizontal">

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

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="mouvement" class="control-label col-lg-3">Mouvement<span class="text-danger"><%%TRANSLATION(*)%%></span></label>
					<div class="col-lg-9">
						<%%COMBO(mouvement)%%>
					</div>
				</div>

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

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

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

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

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

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

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

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="cheque_mv" class="control-label col-lg-3" data-parent_link="view_parent_modal">N&#176;Cheque / Virement MV</label>
					<div class="col-lg-9">
						<div class="form-control-static" style="white-space: nowrap; overflow-x: hidden;"><%%COMBO(cheque_mv)%%><%%PLINK(cheque_mv)%%><%%ADDNEW(cheques)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="cheque_ce" class="control-label col-lg-3">N&#176;Cheque/Virement Tiers</label>
					<div class="col-lg-9">
						<input maxlength="80" type="text" class="form-control" name="cheque_ce" id="cheque_ce" value="<%%VALUE(cheque_ce)%%>"><div class="text-danger vspacer-md" id="cheque_ce-uniqueness-note" style="display: none;"><%%TRANSLATION(unique field error)%%></div>
					</div>
				</div>

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

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="recette" class="control-label col-lg-3">Montant re&#231;u</label>
					<div class="col-lg-9">
						<input maxlength="10" type="text" class="form-control" name="recette" id="recette" value="<%%VALUE(recette)%%>">
					</div>
				</div>

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

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

						
						<div class="row">
							<div class="col-md-1">
								<a id="cheque-link" href="link.php?t=gestion_banques&f=cheque&i=<%%VALUE(idgestion_banque)%%>" target="_blank"><i class="glyphicon glyphicon-file" title="<%%VALUE(cheque)%%>" style="font-size: x-large; top: .35em;"></i></a>
							</div> <!-- /div.col-* -->
							<script>jQuery(function() { /* */ var e_cheque = '<%%VALUE(cheque)%%>'; if(e_cheque == '' || e_cheque == '&nbsp;' || e_cheque == 'blank.gif') jQuery('#cheque-link').hide(); });</script>						<div class="pull-right well upload-toolbox">
							<div class="hidden-md hidden-lg vspacer-lg"></div>
							<%%UPLOADFILE(cheque)%%>
							<%%REMOVEFILE(cheque)%%>
							<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="observations" class="control-label col-lg-3">Observations</label>
					<div class="col-lg-9">
						<textarea class="form-control" name="observations" id="observations" rows="5"><%%VALUE(observations)%%></textarea>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="groupe" class="control-label col-lg-3">Groupe</label>
					<div class="col-lg-9">
						<div class="form-control-static" id="groupe"><%%VALUE(groupe)%%></div>
					</div>
				</div>

				<div class="form-group">
					<hr class="hidden-md hidden-lg">
					<label for="agent" class="control-label col-lg-3">Agent</label>
					<div class="col-lg-9">
						<div class="form-control-static" id="agent"><%%VALUE(agent)%%></div>
					</div>
				</div>

			</fieldset>
		</div>

		<!-- DV action buttons -->
		<hr class="hidden-md hidden-lg">
		<div class="col-md-4 col-lg-2" id="gestion_banques_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>


</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) {
				/* 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: 'gestion_banques',
								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('gestion_banques', 'cheque_ce');

			/* 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=gestion_banques&id=<%%URLVALUE(idgestion_banque)%%>',
					function(resp) {
						if(!resp.length) return;
						$j.ajax('ajax_admin_tools.php?action=get_admin_tools_js&table=gestion_banques&id=<%%URLVALUE(idgestion_banque)%%>');
					}
				);
			}

			/* 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>