<%
/******************************************************************************
 * 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" import="com.edeal.frontline.*"%><%@page import="java.util.*" %>
<%@ page import="com.edeal.frontline.grid.GridData" %>
<%@ page import="java.util.Vector" %>
<%@ page import="com.edeal.frontline.navigation.FlRequest" %>
<%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %>
<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/smalltabs_css.jsp">
<link rel="stylesheet" type="text/css" href="<fl:webapp/>/css/common_css.jsp">
<jsp:useBean class="com.edeal.frontline.LocationBean" id="Location" scope="request"/>
<%
    FlRequest flRequest = new FlRequest(request);
    FlContext context = flRequest.getContext();
    DataDictionary dico = context.getDataDictionary();

    String id = flRequest.getParameter("id");
    String entID = null;
	String entCorpName = null;
    try{
    	entID = Location.getLocEntID(); 
    	EnterpriseBean ent = new EnterpriseBean(entID,context);
    	entCorpName = ent.getEntCorpName();
    } catch(FieldNotInitializedException e) {
    	entID = "";
    	entCorpName = "";
    }
    
    String strSiren = null;
    strSiren = (String) request.getAttribute("strSiren");
    if (strSiren==null||"".equals((String)strSiren)){
    	strSiren = "";
    } else {
    	strSiren = strSiren+"-";
    }
    String locZip = null;
	try{
		locZip = Location.getLocZip();
	}catch(FieldNotInitializedException e){}
	String locCity = null;
	try{
		locCity = Location.getLocCity();
	}catch(FieldNotInitializedException e){}
	
	boolean isGeoLocalized = true;
	try {
		Location.getLocGeoCodeStatusID();
	} catch (FieldNotInitializedException e) {
		isGeoLocalized = false;
	}

    %>
<script language="javascript">
	function waitNredirect(arrIndex) {	
		var str = '<%=flRequest.computeURL("/read_enterprise.fl?id="+entID, true, true, true )%>';
		if (eDealXmlhttpArr[arrIndex].readyState == 4) {
			window.location = str;
		}
				
	}
	
	function refreshPersons() {
		_grid__PER_EMB_js_.render()
	}
	
	
	//chercher société avec siren
	function searchSociete() {
		entCorpName = '<%= Utils.formatToJavascript(entCorpName) %>';
		siren = '<%= strSiren %>';
		EntZip = '<fl:getProperty name="Location" property="LocZip" alt="" />';
		if (siren != '') {
			if (siren.length > 9) {
				try {
					siren = siren.substring(0,9);
				} catch(e) {
				}
			}
			window.open('http://www.societe.com/cgi-bin/recherche?rncs=' + siren);
		} else if (entCorpName != '' || EntZip != '') {
			if (EntZip != '') {
				EntZip = EntZip.substring(0,2);
			}
			window.open('http://www.societe.com/cgi-bin/liste?nom=' + entCorpName + '&dep=' + EntZip);
		} else {
			window.open('http://www.societe.com');
		}
	}
	

</script>
<fl:bigTabs objectTitle="<%= Utils.getMessage(session, \"F200C\", \"Implantation\") %>" ou="<%= \"/read_location.fl?id=\" + Location.getID()%>">
    <table class="container" cellpadding="0">
		<tr>
			<td colspan="3" class="titreFiche"><fl:getProperty name="Location" property="LocName" alt="&nbsp;"/></td>
		</tr>
		<tr class="ligne_separation"><td colspan="3"></td></tr>
		<tr>
			<td class="column2">
				<table class="container" cellpadding="0">
					<fl:fieldRead property="LocEntID" alt="" bean="true" href="true" disp="<%=flRequest.computeURL(\"/read_enterprise.fl\",true, true, true)%>"/>
					<% if (strSiren	!= null && !"".equals(strSiren)) {	%>
	    			<tr class="fieldline">
	        			<td id="LocSiren_label" class="dataLabel"><fl:label field="LocSiren" /></td>
	        			<td id="LocSiren_value" class="dataValue">
	        				<div>
	        					<%=strSiren%><fl:getProperty name="Location" property="LocSiren" alt="" />
	        					<a href="javascript:searchSociete()" title="Chercher sur Société.com">
	        						<img src="<fl:webapp/>/icons/societe.gif" style="border: 0;vertical-align: top;" alt="<fl:getProperty name="Location" property="LocSiren" alt="Chercher sur Société.com"/>"/>
		        			  	</a> 
	        			  	</div>
	        			</td>
	        		</tr>
					<% } %>
					<fl:fieldRead property="LocPhone" alt="" format="phone"/>
	    			<fl:fieldRead property="LocFax" alt="" />
				</table>
			</td>
			<td class="separation"><div class="separation"></div></td>
			<td class="column2">
				<table class="container" cellpadding="0">
					<fl:fieldRead property="LocAddressType" alt="" />
					<tr class="fieldline">
						<td id="Loc.Address_label" class="dataLabel"><fl:label code="F2012" label="Adresse"/>
							<edMap id="map_<%=id%>" 
								geolocalizable='{"mustnotbegeolocalized" : <%=isGeoLocalized%>, "objId":"<%=id%>","objType":"Location","latitude":"<%=Location.getGLLatitude()%>", "longitude":"<%=Location.getGLLongitude()%>", "address":"<%=Location.getAddressForGeolocalization() %>"}'
								enablepreview="true"
								>
							</edMap>
						</td>
						<td id="Loc.Address_value" class="dataValue">
							<div title="">
								<fl:getProperty name="Location" property="LocAd1" alt="" postText="<br>"/>
								<fl:getProperty name="Location" property="LocAd2" alt="" postText="<br>"/>
								<fl:getProperty name="Location" property="LocAd3" alt="" postText="<br>"/>
								<fl:getProperty name="Location" property="LocZip" alt="" postText="&nbsp;"/><fl:getProperty name="Location" property="LocCity" alt="" postText=""/><% try { Location.getLocZip(); Location.getLocCity(); %><br><% } catch(FieldNotInitializedException e) { try { Location.getLocCity(); %><br><% } catch (FieldNotInitializedException ex) {}} %>
								<fl:getProperty name="Location" property="LocCtrID" alt="&nbsp;" preText="<%= ( locZip != null && locCity == null) ? \"<br>\" : \"\"%>"/>
							</div>
						</td>
					</tr>
	        	</table>
			</td>
		</tr>
	</table>
	<fl:notes name="LocDetails" title="<%= Utils.getMessage(session, \"F2024\", \"Notes\") %>" nbPix="30"><fl:getProperty name="Location" property="LocDetails" alt=""/></fl:notes>
	<fl:smallTabs name="LocRead" >
		<fl:sTab id="LOCATION1" title="<%= context.getAutoDisplayManager().getTitle(session, \"Location\", \"Implantation 1\") %>" visible="<%= context.getAutoDisplayManager().hasEntry(\"Location\", \"Implantation 1\") %>">
			<fl:autodisplay name="Location" zone="Implantation 1"/>
		</fl:sTab>
		<fl:sTab id="PERSONNES" title="<%= Utils.getMessage(session, \"L6207\", \"Personnes\") %>" onselect="refreshPersons();">
			<div>
				<fl:grid name="PER_EMB" ajaxUrl="<%= \"/embedded_list_ajax.fl?PerLocID=\" + Location.getID() %>" />
			</div>
		</fl:sTab>
		<fl:sTab id="LOCATION2" title="<%= context.getAutoDisplayManager().getTitle(session, \"Location\", \"Implantation 2\") %>" visible="<%= context.getAutoDisplayManager().hasEntry(\"Location\", \"Implantation 2\") %>">
			<fl:autodisplay name="Location" zone="Implantation 2"/>
		</fl:sTab>
		<fl:sTab id="FATTACH" title="<%= Utils.getMessage(session, \"L201C\", \"Documents joints\") %>">
			<div>
				<fl:attach name="Location" colID="LocAttID" edit="false"/> 
			</div>
		</fl:sTab>
	</fl:smallTabs>
</fl:bigTabs>
