/** * editAccount - Attempts to edit the user's account information * including the clave, which it first makes sure is correct * if entered, if so and the new clave is in the right * format, the change is made. All other fields are changed * automatically. */ function editAccount($clave, $codigo, $nombre, $razon, $email, $telefono1, $telefono2, $telefono3, $logotipo, $notas) { global $database, $form; //The database and form object $form->setValue("clave", $clave); $form->setValue("nombre", $nombre); $form->setValue("razon", $razon); $form->setValue("email", $email); $form->setValue("telefono1", $telefono1); $form->setValue("telefono2", $telefono2); $form->setValue("telefono3", $telefono3); $form->setValue("notas", $notas); /* Email error checking */ $field = "email"; //Use field name for email if ($email && strlen($email = trim($email)) > 0) { /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\\.[_+a-z0-9-]+)*" . "@[a-z0-9-]+(\\.[a-z0-9-]{1,})*" . "\\.([a-z]{2,}){1}\$"; if (!eregi($regex, $email)) { $form->setError($field, "* Email inválido"); } $email = stripslashes($email); } /* Errors exist, have user correct them */ if ($form->num_errors > 0) { return false; //Errors with form } if (!$_FILES['logotipo']['error']) { $idImg = CargarImagenEnBD("logotipo", "LOGOTIPOS"); } else { if (isset($_POST['ConservarLogotipo'])) { $idImg = $_POST['ConservarLogotipo2']; } else { $idImg = 0; } } if ($clave) { $database->updateUserField($codigo, "clave", md5($clave)); } $database->updateUserField($codigo, "nombre", $nombre); $database->updateUserField($codigo, "razon", $razon); $database->updateUserField($codigo, "email", $email); $database->updateUserField($codigo, "telefono1", $telefono1); $database->updateUserField($codigo, "telefono2", $telefono2); $database->updateUserField($codigo, "telefono3", $telefono3); $database->updateUserField($codigo, "logotipo", $idImg); $database->updateUserField($codigo, "notas", $notas); /* Success! */ return true; }
function Pedidos_REGISTRAR() { global $database, $form; //print_ar($_POST); //print_ar($_FILES); if (!$_FILES['foto_pantalla']['error']) { $Pre_Id = isset($_POST['ConservarPantalla2']) ? $_POST['ConservarPantalla2'] : 0; $idImg = CargarImagenEnBD("foto_pantalla", "PEDIDOS", $Pre_Id); } else { if (isset($_POST['ConservarPantalla'])) { $idImg = $_POST['ConservarPantalla2']; } else { $idImg = 0; } } $q = "INSERT INTO " . TBL_MUPI_ORDERS . " ( codigo_pedido, codigo, catorcena_inicio, catorcena_fin, foto_pantalla, costo, descripcion ) VALUES (" . $_POST['codigo_pedido'] . ", '" . $_POST['codigo'] . "', '" . $_POST['catorcena_inicio'] . "', '" . $_POST['catorcena_fin'] . "', '" . $idImg . "', '" . $_POST['costo'] . "', '" . $_POST['descripcion'] . "') ON DUPLICATE KEY UPDATE codigo=VALUES(codigo), catorcena_inicio=VALUES(catorcena_inicio), catorcena_fin=VALUES(catorcena_fin), foto_pantalla=VALUES(foto_pantalla), costo=VALUES(costo), descripcion=VALUES(descripcion);"; DEPURAR($q); //print_ar($_POST); if ($database->query($q) == 1) { echo Mensaje("Exito al registrar el pedido de " . $_POST['codigo'], _M_INFO); } else { echo Mensaje("Falló el registro el pedido de " . $_POST['codigo'], _M_ERROR); } }
function Eventos_REGISTRAR() { global $database, $form; //print_ar($_POST); //print_ar($_FILES); if (!$_FILES['foto_evento']['error']) { $Pre_Id = isset($_POST['ConservarFoto2']) ? $_POST['ConservarFoto2'] : 0; $idImg = CargarImagenEnBD("foto_evento", "EVENTOS", $Pre_Id); } else { if (isset($_POST['ConservarFoto'])) { $idImg = $_POST['ConservarFoto2']; } else { $idImg = 0; } } $q = "INSERT INTO " . TBL_EVENTS . " ( id_evento, timestamp, categoria, afectado, descripcion_evento, foto_evento ) VALUES (" . $_POST['id_evento'] . ", '" . $_POST['timestamp'] . "', '" . $_POST['tipo_evento'] . "', '" . $_POST['afectado'] . "', '" . $_POST['descripcion'] . "', '" . $idImg . "') ON DUPLICATE KEY UPDATE id_evento=VALUES(id_evento), timestamp=VALUES(timestamp), categoria=VALUES(categoria), afectado=VALUES(afectado), descripcion_evento=VALUES(descripcion_evento), foto_evento=VALUES(foto_evento);"; DEPURAR($q); //print_ar($_POST); if ($database->query($q) == 1) { echo Mensaje("Exito al registrar el evento", _M_INFO); } else { echo Mensaje("Falló el registro el evento", _M_ERROR); } }
function Registrar_Referencia() { global $database; //print_ar($_POST); //print_ar($_FILES); if (!$_FILES['imagen_referencia']['error']) { $Pre_Id = isset($_POST['Campo_Referencia_imagen_referencia_id']) ? $_POST['Campo_Referencia_imagen_referencia_id'] : 0; $idImg = CargarImagenEnBD("imagen_referencia", "REFERENCIAS", $Pre_Id); } else { if (isset($_POST['Campo_Referencia_conservar_imagen_referencia'])) { $idImg = $_POST['Campo_Referencia_imagen_referencia_id']; } else { $idImg = 0; } } $q = "INSERT INTO " . TBL_REFS . " (id_referencia, lon, lat, imagen_referencia, codigo_calle) VALUES('" . $_POST['id_referencia'] . "','" . $_POST['lon'] . "','" . $_POST['lat'] . "','" . $idImg . "','" . $_POST['codigo_calle'] . "') ON DUPLICATE KEY UPDATE lon=VALUES(lon), lat=VALUES(lat), imagen_referencia=VALUES(imagen_referencia), codigo_calle=VALUES(codigo_calle)" . ";"; DEPURAR($q, 0); if ($database->query($q) == 1) { echo Mensaje("Exito al registrar/editar referencia " . $_POST['id_referencia'], _M_INFO); } else { echo Mensaje("Falló el registro/edición de la referencia " . $_POST['id_referencia'], _M_ERROR); } }
function MUPI_REGISTRAR() { global $database, $form; //print_ar($_POST); //print_ar($_FILES); if (!$_FILES['foto_generica']['error']) { $Pre_Id = isset($_POST['ConservarPantalla2']) ? $_POST['ConservarPantalla2'] : 0; $idImg = CargarImagenEnBD("foto_generica", "MUPIS", $Pre_Id); } else { if (isset($_POST['ConservarPantalla'])) { $idImg = $_POST['ConservarPantalla2']; } else { $idImg = 0; } } $id_mupi = isset($_POST['id_mupi']) ? $_POST['id_mupi'] : '0'; $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);"; DEPURAR($q); if ($database->query($q) == 1) { echo Mensaje("Exito al registrar el Eco Mupi con código " . $_POST['codigo_mupi'], _M_INFO); } else { echo Mensaje("Falló al registrar el Eco Mupi con código " . $_POST['codigo_mupi'], _M_ERROR); } }
function Pantalla_REGISTRAR() { global $database; //print_ar($_POST); //print_ar($_FILES); if (!$_FILES['foto_real']['error']) { // Con la utilidad de "Clonar pantallas" se introdujo un gran defecto: // La modificacion de fotos es retroactiva. // Como solución temporal se evitará que reemplaze la foto actual y cree siempre un nuevo slot. //$Pre_Id = isset($_POST['ConservarPantalla2']) ? $_POST['ConservarPantalla2'] : 0; $idImg = CargarImagenEnBD("foto_real", "PANTALLAS"); } else { if (isset($_POST['ConservarPantalla'])) { $idImg = $_POST['ConservarPantalla2']; } else { $idImg = 0; } } if (isset($_POST['id_pantalla'])) { $extra1 = 'id_pantalla, '; $extra2 = "'" . $_POST['id_pantalla'] . "', "; } else { $extra1 = ''; $extra2 = ''; } if (!isset($_POST['actualizar'])) { $q = "INSERT INTO " . TBL_MUPI_FACES . " (" . $extra1 . "tipo_pantalla, codigo_mupi, codigo_pedido, foto_real, catorcena) VALUES (" . $extra2 . "'" . $_POST['tipo_pantalla'] . "', '" . $_POST['codigo_mupi'] . "', '" . $_POST['codigo_pedido'] . "', '" . $idImg . "', '" . $_POST['catorcena'] . "') ON DUPLICATE KEY UPDATE tipo_pantalla=VALUES(tipo_pantalla), codigo_mupi=VALUES(codigo_mupi), codigo_pedido=VALUES(codigo_pedido), foto_real=VALUES(foto_real);"; $database->REGISTRAR("pantallas_agregar", "Se agregó una pantalla. Código pedido: " . $_POST['codigo_pedido'] . ", Código MUPI: " . $_POST['codigo_mupi'] . ", Catorcena: " . AnularFechaNula($_POST['catorcena']), "SQL: {$q}"); } else { $q = "UPDATE " . TBL_MUPI_FACES . " SET codigo_pedido='" . $_POST['codigo_pedido'] . "',foto_real='{$idImg}' WHERE id_pantalla='" . $_POST['id_pantalla'] . "';"; $database->REGISTRAR("pantallas_actualizar", "Se actualizó una pantalla. Código pedido: " . $_POST['codigo_pedido'] . ", Código Pantalla: " . $_POST['id_pantalla'], "SQL: {$q}"); } DEPURAR($q, 0); if ($database->query($q) == 1) { echo Mensaje("Exito al registrar la pantalla", _M_INFO); } else { echo Mensaje("Falló al registrar la pantalla", _M_ERROR); } }