<%@ page import="org.apache.log4j.Logger"%>
<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.constants.ReclamatieConstants" %>
<%@ page import="ro.emid.common.types.Strada" %>
<%@ page import="ro.emid.common.db.adrese.AdreseHelper" %>

<%
    final Logger LOG = Logger.getLogger("cautStradaResp_jsp");
    final String localitate = ObjectUtils.getStringValue(request.getParameter("loc"));
%>
<respmesg>
    <% if( localitate == null || localitate.trim().length() == 0){%>        
    <%}else{
        final String tipArtera  = ObjectUtils.getStringValue( request.getParameter("tipArtera")).trim();

        final String whatToSearch = ObjectUtils.getStringValue(request.getParameter("q")).trim();
        try {
            final Strada[] strazi = AdreseHelper.getAdreseDao().searchStraziDistincte(localitate, tipArtera, whatToSearch);
            LOG.debug("GASIT " + strazi.length + " STRAZI");
    %>
    <% if( strazi.length == 0 ){%>
        <div onSelect="this.txtBox.value = ''; setStradaData(-1, '');">
            Nu exista informatii...
         </div>
    <% }else for (int i = 0; i < strazi.length; i++) {  %>
         <div onSelect="this.txtBox.value = '<%=strazi[i].getDenumire()%>'; setStradaData('<%=strazi[i].getCod()%>','<%=strazi[i].getTipArtera()%>'); this.txtBox.form.<%=ReclamatieConstants.NR%>.value=''; this.txtBox.form.<%=ReclamatieConstants.NR%>.focus();">
            <%=strazi[i].getDenumire()%> - <%=strazi[i].getTipArtera()%>
         </div>
    <% }%>
<%} catch (Throwable t) {
    LOG.error("Eroare get lista localitati", t);
}}%>
</respmesg>
