<%
/******************************************************************************
 * Copyright (c) 2000-2004 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"%>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<%@ page import="com.edeal.frontline.FieldNotInitializedException" %>
<jsp:useBean class="com.edeal.frontline.ProductBean" id="Product" scope="request"/>
<%
    FlRequest flRequest = new FlRequest(request);
    String id = null;
    com.edeal.frontline.DataDictionary dico = flRequest.getContext().getDataDictionary();
    
    try{
    	id = Product.getID();
    }catch(FieldNotInitializedException fnie){
    }
    
    
	boolean isGroup = false;
	try {
		String prdType = Product.getPrdTypID();
		isGroup = prdType != null && prdType.equals(dico.getRefIdByCode("PrdTypID","GROUPE"));
	} catch (FieldNotInitializedException fnie) {
	}	
    
	boolean isGesStocks = false;
	
	try {
		isGesStocks = (Boolean)Product.getCustomProperty("PrdGestionStocks_");		
	} catch (FieldNotInitializedException fnie) {
		
	}
    
%>
<script language="javascript">
function doDelete(){
	if (confirm('<fl:getMessage code="M2004" alt="Etes-vous sûr de vouloir supprimer?" js="true"/>')) {
		window.parent.location = '<fl:link url="<%= \"/delete_product.fl?id=\" + id%>"/>';
	}		
}

function doPreview() {
	window.open('<fl:webapp/>/siteweb/product/view.jsp?id=<%=id%>', 'Product<%= id %>', 'location=no,menubar=no,resizable=yes,status=no,scrollbars=yes,toolbar=no');
}

function viewClient(){
	window.open('<fl:link list="false" url="<%= \"/view_client.fl\" + ( id != null ? \"?id=\" + id : \"\") %>"/>','Clients', 'width=750,height=310,scrollbars=yes,resizable=yes,toolbar=no');
}

function histoStock() {
	window.open('<fl:link list="false" url="<%= \"/create_historiquestocks_popup.fl?initHs_Produit=\" + id %>"/>','Stock', 'width=750,height=310,scrollbars=yes,resizable=yes,toolbar=no');
}

function fichier() {
	window.open('<fl:link list="false" url="<%= \"/addfile_product.fl?$$presentFields=&id=\" + id %>"/>','Fichier', 'width=750,height=310,scrollbars=yes,resizable=yes,toolbar=no');
}

</script>



<fl:access name="Product" operation="edit">
    <tr>
        <td class="actions_cell_left"></td>
        <td>
            <div class="actions_tablecell_1">
                <a href="<fl:link list="true" url="<%= \"/edit_product.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>
<fl:access name="Product" operation="delete">
    <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>
<% if(isGesStocks) { %>
<fl:access name="Product" operation="edit">
    <tr>
        <td class="actions_cell_left"></td>
        <td>
            <div class="actions_tablecell_1">
                <a href="javascript:histoStock()">
                    <p class="actions_tabletext"><fl:getMessage code="LF04E" alt="Histo Stocks +"/></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 name="Product" operation="edit">
    <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="Fichiers +"/></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>
	<tr>
        <td class="actions_cell_left"></td>
        <td>
            <div class="actions_tablecell_1">
				<a href="<%=flRequest.computeURL("/prodquicklook.fl"+(id!=null ? "?id="+id : ""))%>" >
					<p class="actions_tabletext"><fl:getMessage code="L7009" alt="Quicklook"/></p>
	            </a>
            </div>
        </td>
        <td class="actions_cell_right"></td>
    </tr>
<%--
<fl:access name="Product" operation="read">
    <tr>
        <td class="actions_cell_left"></td>
        <td class="actions_tablecell_seperator"></td>
        <td class="actions_cell_right"></td>
    </tr>
        <tr>
        <td class="actions_cell_left"></td>
        <td>
            <div class="actions_tablecell_1">
				<a href="javascript:viewClient();">
					<p class="actions_tabletext"><fl:getMessage code="F6060" alt="Clients"/></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>
        <tr>
        <td class="actions_cell_left"></td>
        <td>
            <div class="actions_tablecell_1">
				<a href="<%=flRequest.computeURL("/preview_product.fl"+(id!=null ? "?id="+id : ""))%>" target="_blank">
					<p class="actions_tabletext"><fl:getMessage code="L6147" alt="Prévisualiser"/></p>
	            </a>
            </div>
        </td>
        <td class="actions_cell_right"></td>
    </tr>
     --%>