Exemplo n.º 1
0
 protected function private_core()
 {
     $this->registro = FALSE;
     if (isset($_REQUEST['id'])) {
         $reg = new registro_sat();
         $this->registro = $reg->get($_REQUEST['id']);
     }
     if ($this->registro) {
         $this->agente = $this->user->get_agente();
     }
 }
Exemplo n.º 2
0
 protected function private_core()
 {
     /// cargamos la configuración
     $fsvar = new fs_var();
     $this->sat_setup = $fsvar->array_get(array('sat_col_modelo' => 0, 'sat_col_posicion' => 0, 'sat_col_accesorios' => 0, 'sat_col_prioridad' => 0, 'sat_col_fecha' => 1, 'sat_col_fechaini' => 0, 'sat_col_fechafin' => 0, 'sat_condiciones' => "Condiciondes del deposito:\nLos presupuestos realizados tienen una" . " validez de 15 dias.\nUna vez avisado al cliente para que recoja el producto este dispondrá" . " de un plazo máximo de 2 meses para recogerlo, de no ser así y no haber aviso por parte del" . " cliente se empezará a cobrar 1 euro al día por gastos de almacenaje.\nLos accesorios y" . " productos externos al equipo no especificados en este documento no podrán ser reclamados en" . " caso de disconformidad con el técnico."), FALSE);
     $this->registro = FALSE;
     if (isset($_REQUEST['id'])) {
         $reg = new registro_sat();
         $this->registro = $reg->get($_REQUEST['id']);
     }
     if ($this->registro) {
         $this->agente = $this->user->get_agente();
     }
 }
Exemplo n.º 3
0
 public function __construct($s = FALSE)
 {
     parent::__construct('registros_sat', 'plugins/SAT/');
     if ($s) {
         $this->nsat = intval($s['nsat']);
         $this->prioridad = intval($s['prioridad']);
         $this->fentrada = date('d-m-Y', strtotime($s['fentrada']));
         $this->fcomienzo = NULL;
         if (isset($s['fcomienzo'])) {
             $this->fcomienzo = date('d-m-Y', strtotime($s['fcomienzo']));
         }
         $this->ffin = NULL;
         if (isset($s['ffin'])) {
             $this->ffin = date('d-m-Y', strtotime($s['ffin']));
         }
         $this->modelo = $s['modelo'];
         $this->codcliente = $s['codcliente'];
         $this->estado = intval($s['estado']);
         $this->prioridad = intval($s['prioridad']);
         $this->averia = $s['averia'];
         $this->accesorios = $s['accesorios'];
         $this->observaciones = $s['observaciones'];
         $this->posicion = $s['posicion'];
         $this->nombre_cliente = $s['nombre'];
         $this->telefono1_cliente = $s['telefono1'];
         $this->telefono2_cliente = $s['telefono2'];
         $this->contacto = '';
         if (isset($s['contacto'])) {
             $this->contacto = $s['contacto'];
         }
         $this->codagente = NULL;
         if (isset($s['codagente'])) {
             $this->codagente = $s['codagente'];
         }
     } else {
         $this->nsat = NULL;
         $this->prioridad = 3;
         $this->fentrada = date('d-m-Y');
         $this->fcomienzo = date('d-m-Y');
         $this->ffin = NULL;
         $this->modelo = '';
         $this->codcliente = NULL;
         $this->estado = 1;
         $this->averia = '';
         $this->accesorios = '';
         $this->observaciones = '';
         $this->posicion = '';
         $this->contacto = '';
         $this->codagente = NULL;
         $this->nombre_cliente = '';
         $this->telefono1_cliente = '';
         $this->telefono2_cliente = '';
     }
     if (!isset(self::$estados)) {
         $estado = new estado_sat();
         self::$estados = $estado->all();
     }
 }
Exemplo n.º 4
0
 private function ejemplos()
 {
     $estados = $this->estado->all();
     foreach ($this->cliente->all() as $cli) {
         $sat = new registro_sat();
         $sat->codcliente = $cli->codcliente;
         $sat->nombre_cliente = $cli->nombre;
         $sat->telefono1_cliente = $cli->telefono1;
         $sat->telefono2_cliente = $cli->telefono2;
         foreach ($estados as $est) {
             $sat->estado = $est->id;
             if (mt_rand(0, 1) == 0) {
                 break;
             }
         }
         $sat->averia = $this->random_string();
         $sat->prioridad = mt_rand(1, 4);
         $sat->fentrada = $sat->fcomienzo = Date(mt_rand(1, 27) . '-' . mt_rand(1, 12) . '-Y');
         $sat->save();
     }
 }
Exemplo n.º 5
0
 protected function private_core()
 {
     $this->agente = FALSE;
     $this->estado = new estado_sat();
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     /// cargamos la configuración
     $fsvar = new fs_var();
     $this->sat_setup = $fsvar->array_get(array('sat_col_modelo' => 0, 'sat_col_posicion' => 0, 'sat_col_accesorios' => 0, 'sat_col_prioridad' => 0, 'sat_col_fecha' => 1, 'sat_col_fechaini' => 0, 'sat_col_fechafin' => 0, 'maps_api_key' => 0), FALSE);
     /// ¿Qué pestaña hay que mostrar?
     $this->mostrar = 'home';
     if (isset($_REQUEST['mostrar'])) {
         $this->mostrar = $_REQUEST['mostrar'];
         setcookie('editsat_mostrar', $this->mostrar, time() + FS_COOKIES_EXPIRE);
     } else {
         if (isset($_COOKIE['editsat_mostrar'])) {
             $this->mostrar = $_COOKIE['editsat_mostrar'];
         }
     }
     $this->registro = FALSE;
     if (isset($_REQUEST['id'])) {
         $reg = new registro_sat();
         $this->registro = $reg->get($_REQUEST['id']);
     }
     if ($this->registro) {
         $this->page->title = "Edita SAT: " . $this->registro->nsat;
         $this->agente = $this->user->get_agente();
         if (isset($_POST['detalle'])) {
             $this->agrega_detalle();
         } else {
             if (isset($_POST['averia'])) {
                 $cli0 = new cliente();
                 $cliente = $cli0->get($this->registro->codcliente);
                 if ($cliente and isset($_POST['nombre'])) {
                     $this->registro->nombre_cliente = $cliente->nombre = $cliente->razonsocial = $_POST['nombre'];
                     $this->registro->telefono1_cliente = $cliente->telefono1 = $_POST['telefono1'];
                     $this->registro->telefono2_cliente = $cliente->telefono2 = $_POST['telefono2'];
                     $this->registro->contacto = $_POST['contacto'];
                     if ($cliente->save()) {
                         $this->new_message('Cliente modificado correctamente.');
                     } else {
                         $this->new_error_msg('Error al guardar los datos del cliente.');
                     }
                 }
                 if (isset($_POST['modelo'])) {
                     $this->registro->modelo = $_POST['modelo'];
                 }
                 if (isset($_POST['fecha'])) {
                     $this->registro->fentrada = $_POST['fecha'];
                 }
                 if (isset($_POST['fcomienzo'])) {
                     $this->registro->fcomienzo = $_POST['fcomienzo'];
                 }
                 if (isset($_POST['ffin'])) {
                     if ($_POST['ffin'] != '') {
                         $this->registro->ffin = $_POST['ffin'];
                     }
                 }
                 $this->registro->averia = $_POST['averia'];
                 if (isset($_POST['accesorios'])) {
                     $this->registro->accesorios = $_POST['accesorios'];
                 }
                 $this->registro->observaciones = $_POST['observaciones'];
                 if (isset($_POST['posicion'])) {
                     $this->registro->posicion = $_POST['posicion'];
                 }
                 if (isset($_POST['prioridad'])) {
                     $this->registro->prioridad = $_POST['prioridad'];
                 }
                 if ($this->registro->estado != $_POST['estado']) {
                     ///si tiene el mismo estado no tiene que hacer nada sino tiene que añadir un detalle
                     $this->registro->estado = $_POST['estado'];
                     $this->agrega_detalle_estado($_POST['estado']);
                 }
                 $this->registro->codagente = NULL;
                 if ($_POST['codagente'] != '') {
                     $this->registro->codagente = $_POST['codagente'];
                 }
                 if ($this->registro->save()) {
                     $this->new_message('Datos del SAT guardados correctamente.');
                 } else {
                     $this->new_error_msg('Imposible guardar los datos del SAT.');
                 }
             } else {
                 if (isset($_GET['delete_detalle'])) {
                     $det0 = new detalle_sat();
                     $detalle = $det0->get($_GET['delete_detalle']);
                     if ($detalle) {
                         if ($detalle->delete()) {
                             $this->new_message('Detalle eliminado correctamente.');
                         } else {
                             $this->new_error_msg('Error al eliminar el detalle.');
                         }
                     } else {
                         $this->new_error_msg('Detalle no encontrado.');
                     }
                 }
             }
         }
     }
 }