<%
/******************************************************************************
 * Copyright (c) 2000-2013 E-DEAL
 *
 * E-DEAL S.A.
 * 41, rue Périer
 * 92120 Montrouge
 * France
 *
 * T: +33 (0)1 73 03 29 80
 * 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.custom.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.edeal.frontline.*" %>
<%@ page import="com.edeal.frontline.process.business.api.ProcessActorRule" %>
<%@ page import="com.edeal.frontline.process.business.api.ProcessInstance" %>
<%@ page import="com.edeal.frontline.process.business.api.ProcessInstanceStatus" %>
<%@ page import="com.edeal.frontline.process.business.api.ProcessRule" %>
<%@ page import="com.edeal.frontline.process.business.api.ProcessRuleManager" %>
<%@ page import="com.edeal.frontline.helper.custom.ProcessHelper" %>
<%@ taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<jsp:useBean class="com.edeal.frontline.OpportunityBean" id="Opportunity" scope="request"/>
<%
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();
boolean fHasRightSupp = false;

String id=null;
try {
	id = Opportunity.getID();
} catch (FieldNotInitializedException e) {
	id = null;
}
String entID = null;
try {
	entID = Opportunity.getOppEntID();
} catch (FieldNotInitializedException e) {
	entID = null;
}
String perID = null;
try {
	perID = Opportunity.getOppPerID();
} catch (FieldNotInitializedException e) {
	perID = null;
}


String clientCase = "2";
// 1 pour le Guest , 2 poursTiers, 3 pour Tiers

if(perID!=null && entID == null) {
	clientCase = "1";
} else if (perID == null && entID != null) {
	clientCase = "2";
} else if (perID != null && entID != null) {
	clientCase = "3";
}

String almID = (String)flRequest.getAttribute("AlmID");
boolean existsAlert = almID != null;

String needDetected;
try {
	needDetected = dico.getRefIdByCode("Sto", "Te1", "NEED");
} catch (Exception e) {
	needDetected = null;
}

String corrID;
try {
	corrID = dico.getRefIdByCode("IntType_", "COR");
} catch (FieldNotInitializedException e) {
	corrID = "";
}

// Détecter statut de l'opportunité 

String statutID;
try {
	statutID = Opportunity.getOppStoID();
} catch (FieldNotInitializedException e) {
	statutID = null;
}

boolean isValid = false;
try {
	isValid = ((Boolean)Opportunity.getCustomProperty("OppIsValidated_")).booleanValue();
} catch (FieldNotInitializedException e) {
	isValid = false;
}

String OppExportFlag_ = "";
boolean isExport = false;
try {
	OppExportFlag_ = (String)Opportunity.getCustomProperty("OppExportFlag_").toString();
} catch (FieldNotInitializedException e) {
	OppExportFlag_ = "";
}
if(OppExportFlag_.equals("") || OppExportFlag_.equals("0")){
	isExport=true;
}else{
	isExport=false;
}

// expédition validée ou pas?
boolean isValidEtiq = false;
try {
	isValidEtiq = ((Boolean)Opportunity.getCustomProperty("OppValidEtiq_")).booleanValue();
} catch (FieldNotInitializedException e) {
	isValidEtiq = false;
}		
		


// ramener les ids des 4 statuts de l'opportunité

String devisState;
String devrefState;
String commandeState;
String factureState;
String avoirState;
String typoStasi;

try {
	devisState = dico.getRefIdByCode("Sto", "Te1", "DEV");
	devrefState = dico.getRefIdByCode("Sto", "Te1", "DEVREF");
	commandeState = dico.getRefIdByCode("Sto", "Te1", "ORD");
	factureState = dico.getRefIdByCode("Sto", "Te1", "FAC");
	avoirState =  dico.getRefIdByCode("Sto", "Te1", "AVO");
	typoStasi = dico.getRefIdByCode("Tc_", "Te1", "STASI");
} catch (Exception e) {
	devisState = null;
	devrefState = null;
	commandeState = null;
	factureState = null;
	avoirState = null;
	typoStasi = null;
}

String devisDocTyp;
String commandeDocTyp;
String factureDocTyp;
String avoirDocTyp;
String etiqMasseDocTyp ="";
String notifStaciDocTyp ="";
String modeMensualite="";

try {
	devisDocTyp = dico.getRefIdByCode("To_", "Te1", "DEV");
	commandeDocTyp = dico.getRefIdByCode("To_", "Te1", "ORD");
	factureDocTyp = dico.getRefIdByCode("To_", "Te1", "FAC");
	avoirDocTyp = dico.getRefIdByCode("To_", "Te1", "AVO");
	etiqMasseDocTyp = dico.getRefIdByCode("To_", "Te1", "ETQ");
	notifStaciDocTyp = dico.getRefIdByCode("To_", "Te1", "STC");
	modeMensualite = dico.getRefIdByCode("Mg_", "Te1", "MS");
} catch (Exception e) {
	devisDocTyp = null;
	commandeDocTyp = null;
	factureDocTyp = null;
	avoirDocTyp = null;
}

// If "NEED" doesn't exist for some reason, just take the first one
if (needDetected == null) {
	Vector vect = dico.getRefCodeList("OppStoID");
	Vector firstElement = (Vector)vect.firstElement();
	needDetected = (String)firstElement.firstElement();
}

// Pour ne pas créer d'autres avoirs à partir d'une facture "Avoir"


String oppFactAvoir = "";
try {
	oppFactAvoir = (String) Opportunity.getCustomProperty("OppFactAvoir_");
} catch (FieldNotInitializedException e) {
	oppFactAvoir ="false";
}

String pdfTitle = "";
String mailTitle = "";
String typeOppDocument = "";
String courrierTitle = "";
boolean isEcheancier=false;

if((statutID != null) && (statutID.equalsIgnoreCase(devisState))) {
	pdfTitle ="LF158";
	mailTitle = "FF1F9";
	typeOppDocument = devisDocTyp;
	courrierTitle = "LF15B";
	OpportunityBean opp = new OpportunityBean(id,context);
	String titleOpp = opp.getOppTitle();
	if(titleOpp.contains("Echéancier")){
		isEcheancier=true;
	}
} else if ((statutID != null) && (statutID.equalsIgnoreCase(commandeState))) {
	pdfTitle ="LF159";
	mailTitle = "FF1FA";
	typeOppDocument = commandeDocTyp;
	courrierTitle = "LF15C";
} else if ((statutID != null) && (statutID.equalsIgnoreCase(factureState))) {
	pdfTitle ="LF15A";
	mailTitle = "FF1FB";
	typeOppDocument = factureDocTyp;
	courrierTitle = "LF15D";
	/* if (oppFactAvoir.equalsIgnoreCase("true")){
		pdfTitle ="LF234";
		mailTitle = "LF235";
		courrierTitle = "LF236";
		typeOppDocument = avoirDocTyp;
	} */
}  else if ((statutID != null) && (statutID.equalsIgnoreCase(avoirState))) {
	if (oppFactAvoir.equalsIgnoreCase("true")){
		pdfTitle ="LF234";
		mailTitle = "LF235";
		courrierTitle = "LF236";
		typeOppDocument = avoirDocTyp;
	}
	
}

String oppTypo = null;
boolean isCmdStasi = false;
try {
	oppTypo = (String) Opportunity.getCustomProperty("OppCmdTypo_");
	if (oppTypo.equalsIgnoreCase(typoStasi)) isCmdStasi = true;
} catch (FieldNotInitializedException e) {
}

String title = null;
boolean isDevEcheancier = false;
try {
	title = (String) Opportunity.getOppTitle();
	if (title.contains("Echéancier")) isDevEcheancier = true;
} catch (FieldNotInitializedException e) {
}

boolean isNotifierStaci = false;
try {
	int notifInt = (Integer)Opportunity.getCustomProperty("OppNotificationFournEns_");
	if(notifInt == 1){
		isNotifierStaci = true;
	}
	//isNotifierStaci = ((Boolean)Opportunity.getCustomProperty("OppSTACINotification_")).booleanValue();
} catch (FieldNotInitializedException e) {
	isNotifierStaci = false;
}

//permetre au rôle admin et ... de pouvoir supprimer
String actID = null;
if (session != null) {
		  actID = (String)session.getAttribute("effectiveActorID");
		  if (actID == null) {
		    actID = (String)session.getAttribute("actorID");
		    if (actID == null) {
		      throw new FrontlineException("there is not an actor ID in session");
		    }
		  }
		}
try {
	ActorBean act = new ActorBean(actID, context);
	Vector<String> actRolesIDs = new Vector<String>();
	actRolesIDs.addAll(act.getRoles());
	String roleADMID = dico.getRefIdByCode("ActRoles", "ADMIN"); /* Role Administrateur*/
	String roleTECHADMID = dico.getRefIdByCode("ActRoles", "S_ADM_TECH"); /* Role Administrateur Technique*/
	String roleA_RESP_ADM_FIN = dico.getRefIdByCode("ActRoles", "A_RESP_ADM_FIN"); /* Role charge web*/

	for (int i = 0; i < actRolesIDs.size(); i++) {
		String actRoleIDactuel = actRolesIDs.get(i).toString();
		if( (actRoleIDactuel.equalsIgnoreCase(roleADMID) ) ) {
			fHasRightSupp = true;
		} else if (actRoleIDactuel.equalsIgnoreCase(roleTECHADMID)){
			fHasRightSupp = true;
		}
		else if (actRoleIDactuel.equalsIgnoreCase(roleA_RESP_ADM_FIN)){
			fHasRightSupp = true;
		}
	}
	} catch (Exception e) {
	}

%>
<script type="text/javascript" language="javascript">
	function createAlarm() {
		window.open('<fl:link url="/create_alarm_popup.fl?popup=1"/>&initOppID=<fl:getProperty name="Opportunity" property="OppID" alt=""/>', 'create_alarm', 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=800,height=400');
	}

	function modifyAlarm() {
		window.open('<fl:link list="true" url="<%= \"/edit_alarm_popup.fl?popup=1&id=\" + almID %>"/>', 'create_alarm', 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=550,height=800');
	}

	function doDelete() {
		if (confirm('<fl:getMessage code="M2004" alt="Etes-vous sûr de vouloir supprimer?" js="true"/>')) {
			<% if((statutID != null) && (statutID.equalsIgnoreCase(devisState))) {%>
			window.parent.location = '<fl:link url="<%= \"/delete_devis.fl\" + ( id != null ? \"?id=\" + id : \"\") %>"/>';
			<%} else if((statutID != null) && (statutID.equalsIgnoreCase(commandeState))) {%>
			window.parent.location = '<fl:link url="<%= \"/delete_commande.fl\" + ( id != null ? \"?id=\" + id : \"\") %>"/>';
			<%} else if((statutID != null) && (statutID.equalsIgnoreCase(factureState) || statutID.equalsIgnoreCase(avoirState))) {%>
			window.parent.location = '<fl:link url="<%= \"/delete_facture.fl\" + ( id != null ? \"?id=\" + id : \"\") %>"/>';
			<%}%>
		}
	}
	
	function doWordOpportunity(id,obj,informat,version,clientcase) {
		format = "Word";
		if (informat && informat == "PDF") {
			format = "PDF";
		}
		window.open('<fl:webapp/>/fusion_document_opportunity.fl?typOppDoc=' + version + '&clientCase=' + clientcase + '&format=' + format + '&idObj='+id+'&object='+obj, 'listOpp', 'menubar=no,status=no,toolbar=no,scrollbars=auto,resizable=yes,width=860,height=460');
	}
	
	function doWordOpportunityEcheancier(id,obj,informat,version,clientcase) {
		format = "Word";
		if (informat && informat == "PDF") {
			format = "PDF";
		}
		window.location.href='<fl:webapp/>/fusion_document_opportunity_echeancier.fl?typOppDoc=' + version + '&clientCase=' + clientcase + '&format=' + format + '&idObj='+id+'&object='+obj, 'listOpp', 'menubar=no,status=no,toolbar=no,scrollbars=auto,resizable=yes,width=860,height=460';
	}
	
	function products() {
		var oppid=$('input[name$="id"]').val();
		if (oppid!= '') {
			window.open('<fl:link list="false" url="<%= \"/edit_productopportunity.fl?\" %>"/>&OppID=' + oppid,'ChoixProduit', 'width=1024,height=668,resizable');
		} 		
	}

	function saveNewOppAndOpenProducts() {
		if (!doSubmit()) {
			return;
		}
		
		var mf = document.forms[0];
		
		var strUrl = '<fl:link url="/save_newopportunity_show_products_ajax.fl?type=Opportunity&$$presentFields="/>';

		var oppTitle = mf.OppTitle.value;
		if (oppTitle != '') {
			strUrl += '&OppTitle=' + escape(oppTitle); 
		}
		
		var oppPerID = mf.OppPerID.value;
		if (oppPerID != null && oppPerID != '') {
			strUrl += '&OppPerID=' + oppPerID;
		}
		
		var oppEntID = mf.OppEntID.value;
		if (oppEntID != null && oppEntID != '') {
			strUrl += '&OppEntID=' + oppEntID;
		}
		
		var oppCmdTypo_ = mf.OppCmdTypo_.value;
		if (oppCmdTypo_ != null && oppCmdTypo_ != '') {
			strUrl += '&OppCmdTypo_=' + oppCmdTypo_;
		}
		
		var oppStoID = mf.OppStoID.value;
		if (oppStoID == null || oppStoID == '') {
			oppStoID = '<%= needDetected %>';
		}
		strUrl += '&OppStoID=' + oppStoID;
		alert(strUrl);
		doAjax(strUrl);
	}
	
	function fichier() {
		window.open('<fl:link list="false" url="<%= \"/addfile_opportunity.fl?$$presentFields=&id=\" + id %>"/>','Fichier', 'width=450,height=200,scrollbars=yes,resizable=no,toolbar=no');
	}
	
	function genererEtiquette(id,obj,informat,version,clientCase) {
		format = "Word";
		if (informat && informat == "PDF") {
			format = "PDF";
		}
		window.open('<fl:webapp/>/fusion_document_opportunity_etiq.fl?typOppDoc=' + version + '&clientCase=' + clientCase + '&format=' + format + '&idObj='+id+'&object='+obj, 'listOpp', 'menubar=no,status=no,toolbar=no,scrollbars=auto,resizable=yes,width=860,height=460');
	}
	
</script>
<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1 actions_nolabel">
				<%--
				<a class="doc_fusion word" title="<fl:getMessage code="L6126" alt="Générer Document Word"/>" href="javascript:doWord('<fl:getProperty name="Opportunity" property="OppID" alt=""/>','Opportunity','Word');">
					<img src="<fl:webapp/>/icons/ico_word_inv.gif" border=0 width="15" height="15" alt="<fl:getMessage code="L6126" alt="Générer Document Word"/>">
				</a>&nbsp;
				<a  class="doc_fusion pdf" title="<fl:getMessage code="L6557" alt="Générer Document PDF"/>" href="javascript:doWord('<fl:getProperty name="Opportunity" property="OppID" alt=""/>','Opportunity', 'PDF');">
					<img src="<fl:webapp/>/icons/ico_acrobat_inv.gif" border=0 width="15" height="15" alt="<fl:getMessage code="L6557" alt="Générer Document PDF"/>">
				</a>
				 --%>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
<tr>
		<td class="actions_cell_left">
		</td>
		<td>
		<%if(isEcheancier){ %>	
			<div class="actions_tablecell_1">
				<a href="javascript:doWordOpportunityEcheancier('<fl:getProperty name="Opportunity" property="OppID" alt=""/>','Opportunity', 'PDF', '<%=typeOppDocument%>', '<%=clientCase%>');"/>
					<img src="<fl:webapp/>/icons/ico_acrobat_inv.gif" style="width: 15; height: 15;" alt="<fl:getMessage code="<%=pdfTitle%>" alt="Visualiser le PDF"/>" title="<fl:getMessage code="<%=pdfTitle%>" alt="Visualiser le PDF"/>">
					<p class="actions_tabletext"><fl:getMessage code="FF2C9" alt="Générer et envoyer le devis"/></p>
				</a>
			</div>
		<%}else{ %>
			<div class="actions_tablecell_1">
				<a href="javascript:doWordOpportunity('<fl:getProperty name="Opportunity" property="OppID" alt=""/>','Opportunity', 'PDF', '<%=typeOppDocument%>', '<%=clientCase%>');"/>
					<img src="<fl:webapp/>/icons/ico_acrobat_inv.gif" style="width: 15; height: 15;" alt="<fl:getMessage code="<%=pdfTitle%>" alt="Visualiser le PDF"/>" title="<fl:getMessage code="<%=pdfTitle%>" alt="Visualiser le PDF"/>">
					<p class="actions_tabletext"><fl:getMessage code="<%=pdfTitle%>" alt="Visualiser le PDF"/></p>
				</a>
			</div>
			<%} %>
		</td>
		<td class="actions_cell_right"></td>
</tr>
<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
</tr>

		<%if(!isEcheancier){ %>	
<fl:access name="Opportunity" operation="edit">
<tr>
		<td class="actions_cell_left">
		</td>
		<td>
			<div class="actions_tablecell_1">
				<a href="javascript:sendMailOpportunityWithDocuments('<%= id %>', 'Opportunity', '<%=typeOppDocument%>', 'OppEntID:EntBillingMail_' , 'OppPerID:PerMail', '<%=clientCase%>');"/>
					<img src="<fl:webapp/>/icons/ico_interaction/mail.png" style="width: 15; height: 15;" alt="<fl:getMessage code="<%=mailTitle%>" alt="Visualiser le PDF"/>" title="<fl:getMessage code="<%=mailTitle%>" alt="Visualiser le PDF"/>">
					<p class="actions_tabletext"><fl:getMessage code="<%=mailTitle%>" alt="Visualiser le PDF"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
</tr>
<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
</tr>
</fl:access>
<fl:access operation="edit" name="Opportunity">
<tr>
	<td class="actions_cell_left"></td>
	<td>
		<div class="actions_tablecell_1">
			<a href="<fl:link url="<%= \"/envoyer_opportunity_courrier_unitaire.fl\" + (id != null? \"?clientCase=\" + clientCase + \"&id=\" + id : \"\") %>"/>">
			<img src="<fl:webapp/>/icons/ico_interaction/alerte_courrier.gif" style="width: 15; height: 15;" alt="<fl:getMessage code="<%=courrierTitle%>" alt="Envoyer le Courrier"/>" title="<fl:getMessage code="<%=courrierTitle%>" alt="Envoyer le Courrier"/>">
				<p class="actions_tabletext"><fl:getMessage code="<%=courrierTitle%>" alt="Envoyer le Courrier"/></p>
			</a>
		</div>
	</td>
	<td class="actions_cell_right"></td>
</tr>
<tr>
	<td class="actions_cell_left"></td>
	<td class="actions_tablecell_seperator"></td>
	<td class="actions_cell_right"></td>
</tr>
</fl:access>

		<% } %>	
<% if((statutID != null) && (!isValid)){ %>
<%if(isExport){ %>	
<fl:access operation="edit" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link list="true" url="<%= \"/edit_opportunity.fl\" + ( id != null ? \"?id=\" + id : \"\") %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="A0008" alt="Modifier"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
</fl:access>
<%} %>
<%if(fHasRightSupp){ %>
<fl:access operation="delete" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="javascript:doDelete();"/>
					<p class="actions_tabletext"><fl:getMessage code="A0007" alt="Supprimer"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
</fl:access>
<% 		}
} %>

	
<fl:access operation="create" name="Interaction">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="/create_interaction.fl?" />&IntType_=<%= corrID %>&initIntOppID=<%= id %>">
					<p class="actions_tabletext"><fl:getMessage code="LF034" alt="Correspondance"/> +</p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
</fl:access>

<fl:access operation="edit" name="Interaction">
    <tr>
        <td class="actions_cell_left"></td>
        <td>
            <div class="actions_tablecell_1">
                <a href="javascript:fichier()">
                    <p class="actions_tabletext"><fl:getMessage code="FF0BE" alt="Fichier +"/></p>
                </a>
            </div>
        </td>
        <td class="actions_cell_right"></td>
    </tr>
    <tr>
        <td class="actions_cell_left"></td>
        <td class="actions_tablecell_seperator"></td>
        <td class="actions_cell_right"></td>
    </tr>
</fl:access>

	<% if (!existsAlert) { %>
<fl:access name="Alarm" operation="create">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="javascript:createAlarm()">
					<p class="actions_tabletext"><fl:getMessage code="L62E7" alt="Créer alerte"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>  
	</tr>
	
</fl:access>
	<% } else { %>
<fl:access name="Alarm" operation="create">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="javascript:modifyAlarm()">
					<p class="actions_tabletext"><fl:getMessage code="L62F3" alt="Modifier alerte"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>

</fl:access>
	<% } %>

	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
	<% if((statutID != null) && (statutID.equalsIgnoreCase(devisState)) && !isEcheancier) { %>
	<fl:access operation="create" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="<%= \"/valider_devis_opportunity.fl\" + (id != null? \"?initOppID=\" + id : \"\") %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="FF136" alt="Valider le Devis"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	</fl:access>
	<%} else if((statutID != null) && (statutID.equalsIgnoreCase(commandeState))) { %>
	<% if(isNotifierStaci && isCmdStasi) { %>
	<fl:access operation="edit" name="Opportunity">
	    <tr>
	        <td class="actions_cell_left"></td>
	        <td>
			<div class="actions_tablecell_1">
				<a href="javascript:sendMailOpportunityWithDocuments('<%= id %>', 'Opportunity', '<%=notifStaciDocTyp%>', '' , '');"/>
					<img src="<fl:webapp/>/icons/ico_interaction/mail.png" style="width: 15; height: 15;" alt="<fl:getMessage code="FF1A9" alt="Notifier STACI"/>" title="<fl:getMessage code="FF1A9" alt="Notifier STACI"/>">
					<p class="actions_tabletext"><fl:getMessage code="FF1A9" alt="Notifier STACI"/></p>
				</a>
			</div>
			</td>
	        <td class="actions_cell_right"></td>
	    </tr>
	    <tr>
	        <td class="actions_cell_left"></td>
	        <td class="actions_tablecell_seperator"></td>
	        <td class="actions_cell_right"></td>
	    </tr>
	</fl:access>
	<%} %>
		
	<fl:access operation="edit" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="<%= \"/valider_commande_opportunity.fl\" + (id != null? \"?initOppID=\" + id : \"\") %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="FF138" alt="Valider la Commande"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
	</fl:access>
	
	<fl:access operation="edit" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
			    <a href="javascript:genererEtiquette('<%=id%>','Opportunity','PDF' , '<%=etiqMasseDocTyp%>', '<%=clientCase%>');">
					<img src="<fl:webapp/>/icons/ico_word.gif" style="width: 15; height: 15;" alt="<fl:getMessage code="LF167" alt="Imprimer l'étiquette"/>" title="<fl:getMessage code="LF167" alt="Imprimer l'étiquette"/>">
					<% if (!isValidEtiq) {%>
					<p class="actions_tabletext"><fl:getMessage code="LF167" alt="Imprimer l'étiquette"/></p>
					<%} else { %>
					<p class="actions_tabletext"><fl:getMessage code="LF169" alt="Ré-Imprimer l'étiquette"/></p>
					<%} %>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	<tr>
		<td class="actions_cell_left"></td>
		<td class="actions_tablecell_seperator"></td>
		<td class="actions_cell_right"></td>
	</tr>
	</fl:access>
	<% if (!isValidEtiq) { %>
	<fl:access operation="edit" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="<%= \"/valider_impression_etiquette.fl\" + (id != null? \"?initOppID=\" + id : \"\") %>"/>">
					<p class="actions_tabletext"><fl:getMessage code="LF168" alt="Valider l'mpression de l'étiquette"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	</fl:access>
	<%} %>
	
	<%} else if((statutID != null) && (statutID.equalsIgnoreCase(factureState)) && (!oppFactAvoir.equalsIgnoreCase("true"))) { %>
	<% if(isValid){ %>
	<fl:access operation="edit" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="/create_avoir.fl?" />&initOppFactAvoir_=true&initOppRefFact_=<%=id%>&initOppStoID=<%= avoirState %>">
					<p class="actions_tabletext"><fl:getMessage code="LF151" alt="Créer un Avoir"/></p>
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	
	</fl:access>
	<% } %>
	<% if(!isValid){ %>
	<fl:access operation="edit" name="Opportunity">
	<tr>
		<td class="actions_cell_left"></td>
		<td>
			<div class="actions_tablecell_1">
				<a href="<fl:link url="<%= \"/valider_facture_opportunity.fl\" + (id != null? \"?initOppID=\" + id : \"\") %>"/>">
					<!-- <p class="actions_tabletext"><fl:getMessage code="FF200" alt="Valider la facture"/></p>  -->
				</a>
			</div>
		</td>
		<td class="actions_cell_right"></td>
	</tr>
	
	</fl:access>
	<%}} %>
	
<fl:getProcessList nbEntry="4" withSeparation="true"/>
