Exemple #1
0
									
									showAlerta("Direccion no encontrada!",3000);
									
								</script>
							<?php 
                }
            }
        }
    } elseif ($_REQUEST['tipo'] == 16) {
        $data = array();
        $data[] = strtolower($_REQUEST['calle']);
        $data[] = strtolower($_REQUEST['numero']);
        $data[] = strtolower($_REQUEST['lat']);
        $data[] = strtolower($_REQUEST['lon']);
        $data[] = strtolower($_REQUEST['comuna']);
        $com = getComuna($_REQUEST['comuna']);
        $data[] = strtolower($com[1]);
        $reg = getRegionxId(trim($_REQUEST['region']));
        $data[] = strtolower($reg[0]);
        $data[] = $_REQUEST['region'];
        $cat = getCategoriaxId($_REQUEST['categoria']);
        $data[] = strtolower($cat[1]);
        $data[] = $_REQUEST['categoria'];
        $data[] = strtolower(trim($_REQUEST['lugar']));
        $data[] = strtolower(trim($_REQUEST['lugar'])) . " " . strtolower(trim($_REQUEST['calle'])) . " " . strtolower(trim($_REQUEST['numero'])) . " " . strtolower(trim($_REQUEST['comuna'])) . " " . strtolower(trim($reg[0]));
        $data[] = 4;
        //usuario
        $data[] = 0;
        $data[] = '';
        $data[] = '';
        $data[] = '';
function addDireccion($dir, $origen)
{
    $com = getComuna(trim($dir[2]));
    if (count($com) == 0) {
        $id_comuna = 0;
    } else {
        $id_comuna = $com[1];
    }
    $reg_arr = explode(" ", $dir[3]);
    $id_region = 0;
    foreach ($reg_arr as $reg) {
        $reg = trim($reg);
        if (strtolower($reg) != "region" and strtolower($reg) != 'chile') {
            $region = getRegion($reg);
            //print_r($region);
            if (count($region) == 0) {
                $id_region = 0;
            } else {
                $id_region = $region[1];
                break;
            }
        }
    }
    $dbPg = pgSql_db();
    $sql = strtolower(utf8_encode(limpia(utf8_decode("insert into gis_direccion(calle,numero_municipal,latitud,longitud,comuna,id_comuna,region,id_region,query_completa,geom,origen) values('" . $dir[0] . "','" . $dir[1] . "','" . $dir[4] . "','" . $dir[5] . "','" . $com[0] . "'," . $id_comuna . ",'" . $region[0] . "'," . $id_region . ",'" . $dir[6] . "',ST_GeomFromText('POINT(" . $dir[5] . " " . $dir[4] . ")',2276)," . $origen . ")"))));
    //echo "<br>".$sql."<br>";
    $rsCalle = pg_query($dbPg, $sql);
    pg_close($dbPg);
}
            //$rubro = $aux[0]->nombre;
            //Optimizar
            $aux = getComuna($local->comuna);
            $comuna = $aux[0]->nombre;
            $aux = getCliente($local->usuario);
            $cliente = $aux[0]->nombre;
            $acciones = "<a href='#'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a>";
            $html_locales .= "<tr><td>" . ++$contador . "</td><td>" . utf8_encode($local->nombre) . "</td><td>" . utf8_encode($local->direccion) . "</td><td>" . utf8_encode($comuna) . "</td><td>" . $local->telefono . "</td><td>" . $local->horario . "</td><td>" . $local->mail . "</td><td>" . utf8_encode($local->descripcion) . "</td><td>" . utf8_encode($cliente) . "</td><td>" . $acciones . "</td></tr>";
        }
        $html = str_replace("{LOCALES_ACTIVOS}", $html_locales, $html);
        $inactivos = getLocales(0);
        $html_locales = "";
        $contador = 0;
        foreach ($inactivos as $local) {
            //$aux = getRubro($local->tipo);
            //$rubro = $aux[0]->nombre;
            //Optimizar
            $aux = getComuna($local->comuna);
            $comuna = $aux[0]->nombre;
            $aux = getCliente($local->usuario);
            $cliente = $aux[0]->nombre;
            $acciones = "<a href='validate-shop.php?local=" . $local->id . "'><span class='glyphicon glyphicon-ok' aria-hidden='true'></span></a>&nbsp;" . "<a href='#'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></a>";
            $html_locales .= "<tr><td>" . ++$contador . "</td><td>" . utf8_encode($local->nombre) . "</td><td>" . utf8_encode($local->direccion) . "</td><td>" . utf8_encode($comuna) . "</td><td>" . $local->telefono . "</td><td>" . $local->horario . "</td><td>" . $local->mail . "</td><td>" . utf8_encode($local->descripcion) . "</td><td>" . utf8_encode($cliente) . "</td><td>" . $acciones . "</td></tr>";
        }
        $html = str_replace("{LOCALES_INACTIVOS}", $html_locales, $html);
    }
}
echo $html;
?>