2 function CONTENIDO_mupis($usuario="",$mupi="",$calle=NULL) {
4 echo '<h1>Gestión de ' . _NOMBRE_
. '</h1>';
5 if ( $session->isAdmin() ) {
7 //Nos toca registrar un MUPI
8 if ( isset($_POST['registrar_mupi']) ) {
12 //Nos toca elimiinar un MUPI
13 if ( isset($_GET['eliminar']) ) {
15 // Eliminamos la pantalla
16 $q = "DELETE FROM " . TBL_MUPI
. " WHERE id_mupi='" . $_GET['eliminar'] . "';";
18 $result = $database->query($q);
19 if ( $result ) { echo Mensaje ("Eco Mupis eliminado",_M_INFO
); } else { echo Mensaje ("Eco Mupis no pudo ser eliminado",_M_ERROR
); }
23 echo '<hr /><h2>'._NOMBRE_
." disponibles</h2>";
25 if ( $session->isAdmin() ) {
26 verMUPISregistro($usuario,$mupi);
29 function verMUPIS($calle=NULL){
33 <script type="text/javascript">
34 $(document).ready(function() {
35 $("#toggler").click(function() {
36 $("#tabla_mupis").toggle();
41 if ( $calle ) { $wCalle = "WHERE codigo_calle='$calle'"; $conservar_GET_calle="&calle=$calle"; } else { $conservar_GET_calle = $wCalle = NULL; }
42 $q = "SELECT id_mupi, codigo_mupi, direccion, foto_generica, lon, lat, codigo_evento, codigo_calle, (SELECT ubicacion FROM ".TBL_STREETS
." AS b WHERE a.codigo_calle=b.codigo_calle) AS 'calle' FROM ".TBL_MUPI
." as a $wCalle;";
44 $result = $database->query($q);
45 /* Error occurred, return given name by default */
46 $num_rows = @mysql_numrows
($result);
47 if(!$result ||
($num_rows < 0)){
48 echo "Error mostrando la información";
52 echo Mensaje ("¡No hay "._NOMBRE_
." ingresados!<br/>", _M_NOTA
);
55 $BotonFiltraVistaPorCalles = '<input type="button" OnClick="window.location=\'./?'._ACC_
.'=gestionar+mupis&calle=\'+document.getElementsByName(\'cmbCalles\')[0].value" value="Filtrar"><hr />';
56 echo "<b>Filtrar vista a "._NOMBRE_
." que se ubiquen en la calle</b> ". $database->Combobox_calle("cmbCalles");
57 echo $BotonFiltraVistaPorCalles;
58 echo '<a id="toggler">Mostrar/Ocultar lista de Eco Mupis</a>';
59 echo '<div id="tabla_mupis" style="display:none"><table>';
60 echo '<table border="0">';
61 echo "<tr><th width=\"5%\">ID Mupi</th><th width=\"10%\">Código Mupi</th><th width=\"30%\">Dirección</th><th width=\"5%\">Foto</th><th width=\"5%\">Longitud</th><th width=\"5%\">Latitud</th><th width=\"%30\">Calle</th><th width=\"10%\">Acciones</th></tr>";
62 for($i=0; $i<$num_rows; $i++
){
63 $id = CREAR_LINK_GET("gestionar+mupis".$conservar_GET_calle."&mupi=".mysql_result($result,$i,"id_mupi"), mysql_result($result,$i,"id_mupi"), "Carga los datos del "._NOMBRE_
. " seleccionado para editar");
64 $codigo_mupi = mysql_result($result,$i,"codigo_calle").".".mysql_result($result,$i,"codigo_mupi");
65 $direccion = mysql_result($result,$i,"direccion");
66 $foto_generica = mysql_result($result,$i,"foto_generica");
67 $Longitud = mysql_result($result,$i,"lon");
68 $Latitud = mysql_result($result,$i,"lat");
69 $codigo_calle = CREAR_LINK_GET("gestionar+calles&calle=".mysql_result($result,$i,"codigo_calle"), mysql_result($result,$i,"calle"), "Editar los datos de este pedido");
70 $Eliminar = CREAR_LINK_GET("gestionar+mupis$conservar_GET_calle&eliminar=".mysql_result($result,$i,"id_mupi"),"Eliminar", "Eliminar los datos de este "._NOMBRE_
);
71 echo "<tr><td width=\"5%\">$id</td><td width=\"10%\">$codigo_mupi</td><td width=\"30%\">$direccion</td><td width=\"5%\">$foto_generica</td><td width=\"5%\">$Longitud</td><td width=\"5%\">$Latitud</td><td width=\"30%\">$codigo_calle</td><td width=\"10%\">$Eliminar</td></tr>";
74 echo "<td colspan='7'>Total</td><td>$num_rows</td>";
76 echo "</table></div><br />";
81 function verMUPISregistro($usuario="",$mupi="") {
82 global $form, $database;
84 $NombreBotonAccion = '';
86 $OnChangePantalla = '';
88 $CampoConservarPantalla = '';
89 $CampoConservarPantalla2 = '';
90 //Nos toca crear un MUPI - 16/02/09 - Facilidad para combinar con mapas.
91 if ( isset($_GET['crear']) && isset($_GET['lat']) && isset($_GET['lng']) && isset($_GET['calle'])) {
92 $form->setValue("lon", $_GET['lng']);
93 $form->setValue("lat", $_GET['lat']);
94 $form->setValue("codigo_calle", $_GET['calle']);
97 $q = "SELECT * FROM ".TBL_MUPI
." WHERE id_mupi='$mupi';";
98 $result = $database->query($q);
100 switch ( mysql_numrows($result) ) {
102 $form->setValue("codigo_mupi", mysql_result($result,0,"codigo_mupi"));
103 $form->setValue("direccion", mysql_result($result,0,"direccion"));
104 $form->setValue("lon", mysql_result($result,0,"lon"));
105 $form->setValue("lat", mysql_result($result,0,"lat"));
106 $form->setValue("codigo_calle", mysql_result($result,0,"codigo_calle"));
107 $foto_pantalla = mysql_result($result,0,"foto_generica");
108 if ( $foto_pantalla ) {
109 $CampoConservarPantalla = '<tr><td>Conservar foto genérica con Id.'.$foto_pantalla.'</td></td><td><span id="CampoConservarPantalla"><input type="checkbox" name="ConservarPantalla" value="'.$foto_pantalla.'" checked="checked"></span></td></tr>';
110 $CampoConservarPantalla2 = '<input type="hidden" name="ConservarPantalla2" value="'.$foto_pantalla.'">';
111 $OnChangePantalla = 'onchange="document.getElementById(\'CampoConservarPantalla\').innerHTML=\'Se reemplazará la imagen actual con la seleccionada\'"';
113 $CampoIdMupi = '<input type="hidden" name="id_mupi" value="'.mysql_result($result,0,"id_mupi").'">';
114 $NombreBotonAccion = "Editar";
115 $BotonCancelar = '<input type="button" OnClick="window.location=\'./?'._ACC_
.'=gestionar+mupis\'" value="Cancelar">';
118 echo Mensaje ("No se encontró un Eco Mupis con este código",_M_ERROR
);
122 echo Mensaje("Error al búscar Eco Mupis solicitado",_M_ERROR
);
127 $NombreBotonAccion = "Registrar";
130 if ($mupi) $mupiex = " (".$mupi.")";
131 echo '<hr /><h2>'.$NombreBotonAccion.' '._NOMBRE_
.$mupiex.'</h2>';
133 <form action="./?'._ACC_
.'=gestionar+mupis" enctype="multipart/form-data" method="POST">
135 <tr><td>Código calle:</td><td>'. $database->Combobox_calle("codigo_calle", $form->value("codigo_calle")). '</td></tr>
136 <tr><td>Código '._NOMBRE_
.':</td><td><input type="text" name="codigo_mupi" maxlength="100" style="width: 100%;" value="' . $form->value("codigo_mupi"). '"></td></tr>
137 <tr><td width="20%">Dirección específica:</td><td><input type="text" name="direccion" style="width: 100%;" maxlength="255" value="' . $form->value("direccion"). '"></tr>
139 '.$CampoConservarPantalla.'
140 '.$CampoConservarPantalla2.'
141 <tr><td>Foto genérica:</td><td><input type="file" name="foto_generica"></td></tr>
142 <tr><td>Longitud Decimal:</td><td><input type="text" name="lon" style="width: 100%;" maxlength="50" value="' . $form->value("lon"). '"></td></tr>
143 <tr><td>Latitud Decimal:</td><td><input type="text" name="lat" style="width: 100%;" maxlength="50" value="' . $form->value("lat"). '"></td></tr>
145 <input type="submit" value="'.$NombreBotonAccion.'">
147 <input type="hidden" name="registrar_mupi" value="1">
151 function MUPI_REGISTRAR() {
152 global $database,$form;
155 if ( !$_FILES['foto_generica']['error'] ) {
156 $Pre_Id = isset($_POST['ConservarPantalla2']) ?
$_POST['ConservarPantalla2'] : 0;
157 $idImg = CargarImagenEnBD("foto_generica","MUPIS", $Pre_Id);
160 if ( isset ($_POST['ConservarPantalla']) ){
161 $idImg = $_POST['ConservarPantalla2'];
166 $id_mupi= isset($_POST['id_mupi']) ?
$_POST['id_mupi'] : '0';
167 $q = "INSERT INTO ".TBL_MUPI
." (id_mupi, codigo_mupi, direccion, foto_generica, lon, lat, codigo_calle) VALUES (".$id_mupi.", '".$_POST['codigo_mupi'] . "', '" . $_POST['direccion'] . "','" . $idImg . "','" . $_POST['lon'] . "', '" . $_POST['lat'] . "', '" . $_POST['codigo_calle'] . "') ON DUPLICATE KEY UPDATE codigo_mupi=VALUES(codigo_mupi), direccion=VALUES(direccion), foto_generica=VALUES(foto_generica), lon=VALUES(lon), lat=VALUES(lat), codigo_calle=VALUES(codigo_calle);";
169 if ( $database->query($q) == 1 ) {
170 echo Mensaje ("Exito al registrar el Eco Mupi con código ". $_POST['codigo_mupi'], _M_INFO
);
172 echo Mensaje ("Falló al registrar el Eco Mupi con código " . $_POST['codigo_mupi'], _M_ERROR
);