Пример #1
0
 public function __construct($s = FALSE)
 {
     parent::__construct('servicioscli', 'plugins/servicios/');
     if ($s) {
         $this->idservicio = $this->intval($s['idservicio']);
         $this->idalbaran = $this->intval($s['idalbaran']);
         $this->codigo = $s['codigo'];
         $this->codagente = $s['codagente'];
         $this->codpago = $s['codpago'];
         $this->codserie = $s['codserie'];
         $this->codejercicio = $s['codejercicio'];
         $this->codcliente = $s['codcliente'];
         $this->coddivisa = $s['coddivisa'];
         $this->codalmacen = $s['codalmacen'];
         $this->codpais = $s['codpais'];
         $this->coddir = $s['coddir'];
         $this->codpostal = $s['codpostal'];
         $this->numero = $s['numero'];
         $this->numero2 = $s['numero2'];
         $this->nombrecliente = $s['nombrecliente'];
         $this->cifnif = $s['cifnif'];
         $this->direccion = $s['direccion'];
         $this->ciudad = $s['ciudad'];
         $this->provincia = $s['provincia'];
         $this->apartado = $s['apartado'];
         $this->fecha = Date('d-m-Y', strtotime($s['fecha']));
         $this->hora = Date('H:i:s', strtotime($s['fecha']));
         if (!is_null($s['hora'])) {
             $this->hora = $s['hora'];
         }
         $this->neto = floatval($s['neto']);
         $this->total = floatval($s['total']);
         $this->totaliva = floatval($s['totaliva']);
         $this->totaleuros = floatval($s['totaleuros']);
         $this->irpf = floatval($s['irpf']);
         $this->totalirpf = floatval($s['totalirpf']);
         $this->porcomision = floatval($s['porcomision']);
         $this->tasaconv = floatval($s['tasaconv']);
         $this->recfinanciero = floatval($s['recfinanciero']);
         $this->totalrecargo = floatval($s['totalrecargo']);
         $this->observaciones = $s['observaciones'];
         $this->descripcion = $s['descripcion'];
         $this->solucion = $s['solucion'];
         $this->material = $s['material'];
         $this->material_estado = $s['material_estado'];
         $this->accesorios = $s['accesorios'];
         $this->idestado = $s['idestado'];
         $this->fechafin = NULL;
         if (isset($s['fechafin'])) {
             $this->fechafin = date('d-m-Y H:i', strtotime($s['fechafin'] . ' ' . $s['horafin']));
         }
         $this->fechainicio = NULL;
         if (isset($s['fechainicio'])) {
             $this->fechainicio = date('d-m-Y H:i', strtotime($s['fechainicio'] . ' ' . $s['horainicio']));
         }
         $this->garantia = $s['garantia'];
         $this->prioridad = $s['prioridad'];
         $this->editable = $this->str2bool($s['editable']);
     } else {
         $this->idservicio = NULL;
         $this->idalbaran = NULL;
         $this->codigo = NULL;
         $this->codagente = NULL;
         $this->codpago = NULL;
         $this->codserie = NULL;
         $this->codejercicio = NULL;
         $this->codcliente = NULL;
         $this->coddivisa = NULL;
         $this->codalmacen = NULL;
         $this->codpais = NULL;
         $this->coddir = NULL;
         $this->codpostal = '';
         $this->numero = NULL;
         $this->numero2 = NULL;
         $this->nombrecliente = NULL;
         $this->cifnif = NULL;
         $this->direccion = NULL;
         $this->ciudad = NULL;
         $this->provincia = NULL;
         $this->apartado = NULL;
         $this->fecha = Date('d-m-Y');
         $this->hora = Date('H:i:s');
         $this->neto = 0;
         $this->total = 0;
         $this->totaliva = 0;
         $this->totaleuros = 0;
         $this->irpf = 0;
         $this->totalirpf = 0;
         $this->porcomision = 0;
         $this->tasaconv = 1;
         $this->recfinanciero = 0;
         $this->totalrecargo = 0;
         $this->observaciones = NULL;
         $this->descripcion = NULL;
         $this->solucion = NULL;
         $this->material = NULL;
         $this->material_estado = NULL;
         $this->accesorios = NULL;
         $this->idestado = NULL;
         $this->prioridad = 3;
         $this->fechafin = NULL;
         $this->fechainicio = Date('d-m-Y');
         $this->garantia = FALSE;
         $this->editable = TRUE;
     }
     if (!isset(self::$estados)) {
         $estado = new estado_servicio();
         self::$estados = $estado->all();
     }
 }
Пример #2
0
 private function minicron()
 {
     $this->template = FALSE;
     $contrato = new contrato_servicio();
     $eje0 = new ejercicio();
     $estado = new estado_servicio();
     $idestado = NULL;
     foreach ($estado->all() as $est) {
         $idestado = $est->id;
         break;
     }
     $offset = 0;
     $contratos = $contrato->all($offset, 'fsiguiente_servicio ASC');
     while ($contratos) {
         foreach ($contratos as $con) {
             if ($con->fsiguiente_servicio) {
                 if (strtotime($con->fsiguiente_servicio) > strtotime($con->fecha_renovacion)) {
                     /// caducado
                 } else {
                     if (strtotime($con->fsiguiente_servicio) < strtotime('+1month')) {
                         $cliente = $this->cliente->get($con->codcliente);
                         if ($cliente) {
                             $ejercicio = $eje0->get_by_fecha($con->fsiguiente_servicio);
                             if ($ejercicio) {
                                 $servicio = new servicio_cliente();
                                 $servicio->codcliente = $cliente->codcliente;
                                 $servicio->cifnif = $cliente->cifnif;
                                 $servicio->nombrecliente = $cliente->razonsocial;
                                 $servicio->codagente = $con->codagente;
                                 $servicio->coddivisa = $this->empresa->coddivisa;
                                 $servicio->codejercicio = $ejercicio->codejercicio;
                                 $servicio->codpago = $con->codpago;
                                 $servicio->codserie = $cliente->codserie;
                                 $servicio->fecha = $con->fsiguiente_servicio;
                                 $servicio->fechainicio = $con->fsiguiente_servicio . ' ' . $this->nuevocli_setup['cal_inicio'];
                                 $servicio->idestado = $idestado;
                                 foreach ($cliente->get_direcciones() as $dir) {
                                     if ($dir->domfacturacion) {
                                         $servicio->direccion = $dir->direccion;
                                         $servicio->codpostal = $dir->codpostal;
                                         $servicio->ciudad = $dir->ciudad;
                                         $servicio->provincia = $dir->provincia;
                                         $servicio->codpais = $dir->codpais;
                                         break;
                                     }
                                 }
                                 if ($servicio->save()) {
                                     $con->fsiguiente_servicio = NULL;
                                     if ($con->periodo) {
                                         $con->fsiguiente_servicio = date('d-m-Y', strtotime($servicio->fechainicio . ' ' . $con->periodo));
                                     }
                                     $con->save();
                                 } else {
                                     echo "Error al crear el servicio.\n";
                                     foreach ($this->get_errors() as $err) {
                                         echo $err . "\n";
                                     }
                                 }
                             }
                         }
                     } else {
                         echo "Cliente no encontrado.\n";
                     }
                 }
             }
             $offset++;
         }
         $contratos = $contrato->all($offset, 'fsiguiente_servicio ASC');
     }
 }