Пример #1
0
 protected function private_core()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $this->check_menu();
     $this->share_extensions();
     $this->estado = new estado_servicio();
     /// cargamos la configuración
     $fsvar = new fs_var();
     $this->servicios_setup = $fsvar->array_get(array('servicios_diasfin' => 10, 'servicios_material' => 0, 'servicios_mostrar_material' => 0, 'servicios_material_estado' => 0, 'servicios_mostrar_material_estado' => 0, 'servicios_accesorios' => 0, 'servicios_mostrar_accesorios' => 0, 'servicios_descripcion' => 0, 'servicios_mostrar_descripcion' => 0, 'servicios_solucion' => 0, 'servicios_mostrar_solucion' => 0, 'servicios_fechafin' => 0, 'servicios_mostrar_fechafin' => 0, 'servicios_fechainicio' => 0, 'servicios_mostrar_fechainicio' => 0, 'servicios_mostrar_garantia' => 0, 'servicios_garantia' => 0, 'servicios_condiciones' => "Condiciones del deposito:\nLos presupuestos realizados tienen una" . " validez de 15 días.\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.", 'st_servicio' => "Servicio", 'st_servicios' => "Servicios", 'st_material' => "Material", 'st_material_estado' => "Estado del material entregado", 'st_accesorios' => "Accesorios que entrega", 'st_descripcion' => "Descripción de la averia", 'st_solucion' => "Solución", 'st_fechainicio' => "Fecha de inicio", 'st_fechafin' => "Fecha de finalización", 'st_garantia' => "Garantía", 'cal_inicio' => "09:00", 'cal_fin' => "20:00", 'cal_intervalo' => "30"), FALSE);
     if (isset($_POST['servicios_setup'])) {
         $this->servicios_setup['servicios_diasfin'] = intval($_POST['diasfin']);
         $this->servicios_setup['servicios_material'] = isset($_POST['servicios_material']) ? 1 : 0;
         $this->servicios_setup['servicios_material_estado'] = isset($_POST['servicios_material_estado']) ? 1 : 0;
         $this->servicios_setup['servicios_accesorios'] = isset($_POST['servicios_accesorios']) ? 1 : 0;
         $this->servicios_setup['servicios_descripcion'] = isset($_POST['servicios_descripcion']) ? 1 : 0;
         $this->servicios_setup['servicios_solucion'] = isset($_POST['servicios_solucion']) ? 1 : 0;
         $this->servicios_setup['servicios_fechafin'] = isset($_POST['servicios_fechafin']) ? 1 : 0;
         $this->servicios_setup['servicios_fechainicio'] = isset($_POST['servicios_fechainicio']) ? 1 : 0;
         $this->servicios_setup['servicios_garantia'] = isset($_POST['servicios_garantia']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_material'] = isset($_POST['servicios_mostrar_material']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_material_estado'] = isset($_POST['servicios_mostrar_material_estado']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_accesorios'] = isset($_POST['servicios_mostrar_accesorios']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_descripcion'] = isset($_POST['servicios_mostrar_descripcion']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_solucion'] = isset($_POST['servicios_mostrar_solucion']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_fechafin'] = isset($_POST['servicios_mostrar_fechafin']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_fechainicio'] = isset($_POST['servicios_mostrar_fechainicio']) ? 1 : 0;
         $this->servicios_setup['servicios_mostrar_garantia'] = isset($_POST['servicios_mostrar_garantia']) ? 1 : 0;
         $this->servicios_setup['servicios_condiciones'] = $fsvar->no_html($_POST['condiciones']);
         $this->servicios_setup['st_servicio'] = $_POST['st_servicio'];
         $this->servicios_setup['st_servicios'] = $_POST['st_servicios'];
         $this->servicios_setup['st_material'] = $_POST['st_material'];
         $this->servicios_setup['st_material_estado'] = $_POST['st_material_estado'];
         $this->servicios_setup['st_accesorios'] = $_POST['st_accesorios'];
         $this->servicios_setup['st_descripcion'] = $_POST['st_descripcion'];
         $this->servicios_setup['st_solucion'] = $_POST['st_solucion'];
         $this->servicios_setup['st_fechainicio'] = $_POST['st_fechainicio'];
         $this->servicios_setup['st_fechafin'] = $_POST['st_fechafin'];
         $this->servicios_setup['st_garantia'] = $_POST['st_garantia'];
         $this->servicios_setup['cal_inicio'] = $_POST['cal_inicio'];
         $this->servicios_setup['cal_fin'] = $_POST['cal_fin'];
         $this->servicios_setup['cal_intervalo'] = $_POST['cal_intervalo'];
         if ($fsvar->array_save($this->servicios_setup)) {
             $this->new_message('Datos guardados correctamente.');
         } else {
             $this->new_error_msg('Error al guardar los datos.');
         }
     } else {
         if (isset($_GET['delete_estado'])) {
             $estado = $this->estado->get($_GET['delete_estado']);
             if ($estado) {
                 if ($estado->delete()) {
                     $this->new_message('Estado eliminado correctamente.');
                 } else {
                     $this->new_error_msg('Error al eliminar el estado.');
                 }
             } else {
                 $this->new_error_msg('Estado no encontrado.');
             }
         } else {
             if (isset($_POST['id_estado'])) {
                 $estado = $this->estado->get($_POST['id_estado']);
                 if (!$estado) {
                     $estado = new estado_servicio();
                     $estado->id = intval($_POST['id_estado']);
                 }
                 $estado->descripcion = $_POST['descripcion'];
                 $estado->color = $_POST['color'];
                 $estado->activo = isset($_POST['activo']);
                 $estado->albaran = isset($_POST['albaran']);
                 if ($estado->save()) {
                     $this->new_message('Estado guardado correctamente.');
                 } else {
                     $this->new_error_msg('Error al guardar el estado.');
                 }
             }
         }
     }
 }
Пример #2
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();
     }
 }
Пример #3
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');
     }
 }