예제 #1
0
 protected function private_core()
 {
     $this->agente = new agente();
     if (isset($_POST['sdnicif'])) {
         $age0 = new agente();
         $age0->codagente = $age0->get_new_codigo();
         $age0->nombre = $_POST['snombre'];
         $age0->apellidos = $_POST['sapellidos'];
         $age0->dnicif = $_POST['sdnicif'];
         $age0->telefono = $_POST['stelefono'];
         $age0->email = $_POST['semail'];
         if ($age0->save()) {
             $this->new_message("Empleado " . $age0->codagente . " guardado correctamente.");
             header('location: ' . $age0->url());
         } else {
             $this->new_error_msg("¡Imposible guardar el empleado!");
         }
     } else {
         if (isset($_GET['delete'])) {
             $age0 = $this->agente->get($_GET['delete']);
             if ($age0) {
                 if (FS_DEMO) {
                     $this->new_error_msg('En el modo <b>demo</b> no se pueden eliminar empleados. Otro usuario podría estar usándolo.');
                 } else {
                     if ($age0->delete()) {
                         $this->new_message("Empleado " . $age0->codagente . " eliminado correctamente.");
                     } else {
                         $this->new_error_msg("¡Imposible eliminar el empleado!");
                     }
                 }
             } else {
                 $this->new_error_msg("¡Empleado no encontrado!");
             }
         }
     }
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     $this->ciudad = '';
     if (isset($_REQUEST['ciudad'])) {
         $this->ciudad = $_REQUEST['ciudad'];
     }
     $this->provincia = '';
     if (isset($_REQUEST['provincia'])) {
         $this->provincia = $_REQUEST['provincia'];
     }
     $this->orden = 'nombre ASC';
     if (isset($_REQUEST['orden'])) {
         $this->orden = $_REQUEST['orden'];
     }
     $this->buscar();
 }
 protected function process()
 {
     $this->agente = new agente();
     $this->buttons[] = new fs_button_img('b_nuevo_agente', 'Nuevo');
     if (isset($_POST['sdnicif'])) {
         $age0 = new agente();
         $age0->codagente = $age0->get_new_codigo();
         $age0->nombre = $_POST['snombre'];
         $age0->apellidos = $_POST['sapellidos'];
         $age0->dnicif = $_POST['sdnicif'];
         $age0->telefono = $_POST['stelefono'];
         $age0->email = $_POST['semail'];
         if ($age0->save()) {
             $this->new_message("Empleado " . $age0->codagente . " guardado correctamente.");
             header('location: ' . $age0->url());
         } else {
             $this->new_error_msg("¡Imposible guardar el empleado!");
         }
     } else {
         if (isset($_GET['delete'])) {
             $age0 = $this->agente->get($_GET['delete']);
             if ($age0) {
                 if (FS_DEMO) {
                     $this->new_error_msg('En el modo <b>demo</b> no se pueden eliminar empleados. Otro usuario podría estar usándolo.');
                 } else {
                     if ($age0->delete()) {
                         $this->new_message("Empleado " . $age0->codagente . " eliminado correctamente.");
                     } else {
                         $this->new_error_msg("¡Imposible eliminar el empleado!");
                     }
                 }
             } else {
                 $this->new_error_msg("¡Empleado no encontrado!");
             }
         }
     }
 }