<%/******************************************************************************
 * Copyright (c) 2000-2005 e-Deal
 *
 * e-Deal S.A.
 * 55 rue Brillat Savarin
 * 75013 Paris
 * France
 *
 * T: +33 (0)1 53 80 80 30
 * F: +33 (0)1 73 01 69 77
 * http://www.e-deal.com
 * 
 * La diffusion de ce code source sous quelque forme que ce soit sans
 * l'autorisation de E-DEAL est interdite.
 *
 * Vous êtes autorisés à modifier ce code source uniquement pour votre usage
 * propre et sous réserve que les mentions de copyright demeurent intactes.
 *
 * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou
 * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour
 * responsable des dommages pouvant résulter de l'utilisation de ce code
 * source.
 ******************************************************************************/
%>
<%@page session="true"%>
<%@ page import="com.edeal.frontline.navigation.FlRequest" %>
<%@ page import="com.edeal.frontline.FlContext" %>
<%@ page import="com.edeal.frontline.DataDictionary" %>
<%@ page import="com.edeal.frontline.FieldNotInitializedException" %>
<%@ page import="com.edeal.frontline.custom.GiftCheque_Bean"%>
<%@ page import="com.edeal.frontline.Utils"%>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<jsp:useBean class="com.edeal.frontline.custom.GiftCheque_Bean" id="GiftCheque_" scope="request"/>
<link href="<fl:webapp/>/css/smalltabs_css.jsp" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/common_css.jsp">

<%
	final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass());
	FlRequest flRequest = new FlRequest(request);
	FlContext context = flRequest.getContext();
	DataDictionary dico = context.getDataDictionary();
	String id = null;
	

	try {
	    id = GiftCheque_.getID();
	} catch (FieldNotInitializedException fnie) {}
	
	String gchStatusID = null;
	if(Utils.isEmpty(id)) {
		GiftCheque_.setGchStatusID(dico.getRefIdByCode("GchStatusID", "CR"));
		gchStatusID = dico.getRefIdByCode("GchStatusID", "CR");
	}else{
		try{
			gchStatusID = GiftCheque_.getGchStatusID();
		}catch (FieldNotInitializedException fnie) {}
	}
	
	String pSlID =  null;
	try{
		pSlID = GiftCheque_.getGchPslID();
	
	}catch (FieldNotInitializedException fnie) {}
	
	String GchCgcID =  null;
	try{
		GchCgcID = GiftCheque_.getGchCgcID();
	}catch (FieldNotInitializedException fnie) {}
	
	// Désignation du chèque cadeau
	String giftChequeDesignation = null;
	try {
		giftChequeDesignation = GiftCheque_.getGchDesignation();
	} catch (FieldNotInitializedException fnie) {
	}
	
	// Désignation de type saisie libre
	String giftChequeRandomDesignationID = null;
	try {
		giftChequeRandomDesignationID = (String) dico.getRefIdByCode("GchDesignation", "RAND");
	} catch (Exception e) {
		giftChequeRandomDesignationID ="";
	}
	
%>
<script type="text/javascript" language="javascript">
	function doSubmit() {
		var f = document.forms[0];		
		return true;
	}
	
	function doGchDesignationChange() {	
		doRefreshGiftCheque();
	}
	
	function doRefreshGiftCheque() {		
		var f = document.forms[0];
		f.action = "<fl:webapp/>/refresh_giftcheque_.fl";
		f.submit();
	}
</script>
<fl:form action="save_giftcheque_.fl" bean="GiftCheque_">
<input type="hidden" name="GchNumber" value="<fl:getProperty name="GiftCheque_" property="GchNumber" alt=""/>"/>
<% if (gchStatusID != null) {  %>
<input type="hidden" name="GchStatusID" value="<%=gchStatusID %>"/>
<%} %>

<% if (GchCgcID != null) {  %>
<input type="hidden" name="GchCgcID" value="<%=GchCgcID %>"/>
<%} %>
<fl:bigTabs objectTitle="<%=Utils.getMessage(session, \"LF058\", false, true, \"Création Chèque Cadeau\") %>" ou="<%= \"edit_giftcheque_.fl\" + (id != null ? \"?id=\" + id : \"\")%>" >
    <table class="container" cellpadding="0">
		<tr>
			<td colspan="5">
				<table class="container" cellpadding="0">
					<tr class="fieldline">
						<td class="titreFiche" colspan="2">
							<fl:getMessage code="LF05B" alt="Chèque Cadeau n°"/><fl:getProperty name="GiftCheque_" property="GchNumber" preText="&nbsp;" alt=""/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
    
		<tr class="ligne_separation"><td></td></tr>
		<tr>
			<td class="column2">
				<table class="data_column" cellpadding="0">
				<%if(!Utils.isEmpty(id)){ %>
					<fl:fieldRead property="GchStatusID"/>
					
				<% }else{ %><fl:fieldEdit property="GchStatusID" mandatoryMsgCode="LF05E"/><% } %>
					<!-- <fl:fieldEdit property="GchDesignation" mandatoryMsgCode="MF066" onchange="doGchDesignationChange();"/> -->
					<!-- <fl:fieldEdit property="GchValidityDt" mandatoryMsgCode="MF01D"/> -->
					<fl:fieldRead property="GchDesignation"/>
					<fl:fieldEdit property="GchValidityDt"/>
					
					<fl:fieldEdit property="GchBeneficiary" comboFobThreshold="3"/>
					 <% if (giftChequeRandomDesignationID.equals(giftChequeDesignation)) { %>
					 <fl:fieldEdit property="GchMontant" mandatoryMsgCode="MF01E" postText="&nbsp;&euro;" format="money"/>
					 <%} %>	
					<fl:fieldEdit property="GchAccountingCode"/>
					<fl:fieldEdit property="GchAnalyticCode"/>
					<fl:fieldEdit property="GchFranceAccount"/>
					<fl:fieldEdit property="GchExportAccount"/>
					<fl:fieldEdit property="GchIntracomAccount"/>
				</table>
			</td>
			<td class="separation"><div class="separation"></div></td>
			<td class="column2">
				<table class="data_column" cellpadding="0">
					<fl:fieldRead property="GchCgcID" bean="true" href="true" disp="<%= flRequest.computeURL(\"/read_cmdgiftcheque_.fl\") %>"/>
					<fl:fieldEdit property="GchDeadlineDt"/>
					<fl:fieldRead property="GchPslID"/>
					<%--  
					<fl:fieldEdit property="GchPaymentDt"/>
					--%>
				</table>
			</td>
		</tr>
		<tr class="ligne_separation"><td></td></tr>
	</table>

<%-- <fl:smallTabs name="GiftCheque__Tabs">
	<fl:sTab id="STab1" title="STab1">
		<div>
			STab 1
		</div>
	</fl:sTab>

</fl:smallTabs> --%>
</fl:bigTabs>
</fl:form>
