<%@ page import="org.apache.log4j.Logger"%>
<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.db.OpenSCGAccessDB" %>
<%@ page import="ro.emid.common.constants.ReclamatieConstants" %>
<%@ page import="ro.emid.common.constants.GlobalAppConstants" %>
<%@ page import="ro.emid.callcenter.CallcenterSessionUtils" %>
<%@ page import="ro.emid.common.types.Localitate" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.db.adrese.AdreseHelper" %>
<%
    final Logger LOG = Logger.getLogger("cautLocalitateResp_jsp");
    final String whatToSearch = ObjectUtils.getStringValue(request.getParameter("q"));

    LOG.debug(" whatToSearch=" + whatToSearch);
    try {
        final String ids = CallcenterSessionUtils.getSucursala(session).getStrIdsDepartamenteOpen();
        final String cond = ids == null ? "" : " AND COD_DEPTO IN (" + ids + ") ";
//        final Localitate[] localitati = OpenSCGAccessDB.searchLocalitate(whatToSearch, cond);
        final Localitate[] localitati = AdreseHelper.getAdreseDao().searchLocalitate2(whatToSearch, cond);
        LOG.debug("GASIT " + localitati.length + " LOCALITATI");
%>
<respmesg>
    <%--style="color:<%=localitati[i].getUrban_rural() == 0 ? "green" : ""%>"--%>
    <% for (int i = 0; i < localitati.length; i++) {  %>
         <div onSelect="this.txtBox.value = '<%=ro.emid.common.utils.Util.escapeToJs( AppConstants.format( localitati[i].getDenumireLocalitate()))%>'; this.txtBox.form.<%=ReclamatieConstants.STRADA%>.value ='';this.txtBox.form.<%=ReclamatieConstants.TIP_ARTERA%>.value =''; this.txtBox.form.<%=ReclamatieConstants.TIP_ARTERA%>.focus()">
                <%=AppConstants.format(localitati[i].getDenumireLocalitate())%>
         </div>
    <% }%>
</respmesg>
<%} catch (Throwable t) {
    LOG.error("Eroare get lista localitati", t);
}%>