Example #1
0
 private function importar_sat()
 {
     $this->registro_sat = new registro_sat();
     $this->detalle_sat = new detalle_sat();
     $this->cliente = new cliente();
     $importados = 0;
     $importados_det = 0;
     $data = $this->db->select("SELECT * FROM registros_sat;");
     if ($data) {
         foreach ($data as $d) {
             $this->servicio = $this->registro_sat->get($d['nsat']);
             if ($this->servicio) {
                 $this->servicio = new servicio_cliente();
                 $this->servicio->numero2 = "SAT_" . $d['nsat'];
                 $this->servicio->fecha = $d['fentrada'];
                 if (isset($d['fcomienzo'])) {
                     $this->servicio->fechainicio = Date('d-m-Y H:i', strtotime($d['fcomienzo']));
                 }
                 if (isset($d['ffin'])) {
                     $this->servicio->fechafin = Date('d-m-Y H:i', strtotime($d['ffin']));
                 }
                 //obtenemos ejercicio
                 $eje0 = new ejercicio();
                 $ejercicio = $eje0->get_by_fecha($d['fentrada']);
                 $this->servicio->codejercicio = $ejercicio->codejercicio;
                 $this->servicio->material = $d['modelo'];
                 $this->servicio->descripcion = $d['averia'];
                 $this->servicio->accesorios = $d['accesorios'];
                 $this->servicio->codcliente = $d['codcliente'];
                 $this->servicio->observaciones = $d['observaciones'];
                 $this->servicio->codagente = $d['codagente'];
                 $this->servicio->idestado = '1';
                 $this->servicio->prioridad = $d['prioridad'];
                 //obtenemos cliente
                 $cliente0 = new cliente();
                 $cliente = $cliente0->get($d['codcliente']);
                 $this->servicio->nombrecliente = $cliente->nombre;
                 $this->servicio->codserie = $this->empresa->codserie;
                 $this->servicio->codpago = $this->empresa->codpago;
                 if ($this->servicio->save()) {
                     $importados++;
                 }
                 //Importamos Detalles:
                 $data2 = $this->db->select("SELECT * FROM detalles_sat WHERE nsat=" . $d['nsat'] . ";");
                 if ($data2) {
                     foreach ($data2 as $d2) {
                         $detalle = $this->detalle_sat->get($d2['id']);
                         if ($detalle) {
                             $detalle = new detalle_servicio();
                             $detalle->idservicio = $this->servicio->idservicio;
                             $detalle->descripcion = $d2['descripcion'];
                             $detalle->fecha = $d2['fecha'];
                             if ($detalle->save()) {
                                 $importados_det++;
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->new_message($importados . ' registros SAT importados.');
     $this->new_message($importados_det . ' detalles SAT importados.');
     $this->avisosat = '2';
 }
Example #2
0
 private function agrega_detalle(&$servicio)
 {
     $detalle = new detalle_servicio();
     $detalle->descripcion = 'SMS enviado correctamente al teléfono: ' . $this->telefono . ' con el texto: ' . $this->mensaje;
     $detalle->idservicio = $servicio->idservicio;
     $detalle->nick = $this->user->nick;
     if ($detalle->save()) {
         $this->new_message('Detalle guardados correctamente.');
     } else {
         $this->new_error_msg('Imposible guardar el detalle.');
     }
 }
Example #3
0
 private function agrega_detalle_estado($id)
 {
     $this->estado = new estados_servicios();
     $estado = $this->estado->get($id);
     if ($estado) {
         $detalle = new detalle_servicio();
         $detalle->descripcion = "Se a cambiado el estado a: " . $estado->descripcion;
         $detalle->idservicio = $this->servicio->idservicio;
         $detalle->nick = $this->user->nick;
         if ($detalle->save()) {
             $this->new_message('Detalle guardados correctamente.');
         } else {
             $this->new_error_msg('Imposible guardar el detalle.');
         }
     }
 }