protected function private_core()
 {
     $this->share_extensions();
     $this->servicio = new servicio_cliente();
     $this->agente = new agente();
     $this->serie = new serie();
     $this->estados = new estado_servicio();
     // cargamos las opciones del calendario
     $fsvar = new fs_var();
     $this->servicios_setup = $fsvar->array_get(array('servicios_mostrar_fechainicio' => 0, 'cal_inicio' => "09:00", 'cal_fin' => "20:00", 'cal_intervalo' => "30"), FALSE);
     if (isset($_REQUEST['buscar_cliente'])) {
         $this->buscar_cliente();
     }
     if (isset($_REQUEST['codagente']) or isset($_REQUEST['codcliente']) or isset($_REQUEST['estado'])) {
         if (isset($_REQUEST['codcliente'])) {
             if ($_REQUEST['codcliente'] != '') {
                 $cli0 = new cliente();
                 $this->cliente = $cli0->get($_REQUEST['codcliente']);
                 $this->codcliente = $_REQUEST['codcliente'];
             }
             if (isset($_REQUEST['codagente'])) {
                 $this->codagente = $_REQUEST['codagente'];
             }
             if (isset($_REQUEST['estado'])) {
                 $this->estado = $_REQUEST['estado'];
             }
         }
     }
 }
 protected function private_core()
 {
     $this->share_extension();
     /// cargamos la configuración de servicios
     $fsvar = new fs_var();
     $this->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_garantía' => "Garantía"), FALSE);
     /// cargamos el servicios
     $this->servicio = FALSE;
     if (isset($_GET['id'])) {
         $serv0 = new servicio_cliente();
         $this->servicio = $serv0->get($_GET['id']);
     }
     $term0 = new terminal_caja();
     $this->terminales = $term0->all();
     $this->terminal = FALSE;
     if (isset($_GET['terminal'])) {
         $this->terminal = $term0->get($_GET['terminal']);
     }
     if ($this->servicio and $this->terminal) {
         $cli0 = new cliente();
         $this->cliente = $cli0->get($this->servicio->codcliente);
         $numt = $this->terminal->num_tickets;
         while ($numt > 0) {
             $this->imprimir();
             $this->terminal->save();
             $numt--;
         }
     }
 }
Ejemplo n.º 3
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->share_extensions();
     $this->estado = new estado_sat();
     /// leemos la API key de google maps de la base de datos o del formulario
     $fsvar = new fs_var();
     if (isset($_POST['maps_api_key'])) {
         $this->maps_api_key = $_POST['maps_api_key'];
         $fsvar->simple_save('maps_api_key', $this->maps_api_key);
     } else {
         $this->maps_api_key = $fsvar->simple_get('maps_api_key');
     }
     /// cargamos la configuración
     $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), FALSE);
     if (isset($_POST['sat_setup'])) {
         $this->sat_setup['sat_col_modelo'] = isset($_POST['col_modelo']) ? 1 : 0;
         $this->sat_setup['sat_col_posicion'] = isset($_POST['col_posicion']) ? 1 : 0;
         $this->sat_setup['sat_col_accesorios'] = isset($_POST['col_accesorios']) ? 1 : 0;
         $this->sat_setup['sat_col_prioridad'] = isset($_POST['col_prioridad']) ? 1 : 0;
         $this->sat_setup['sat_col_fecha'] = isset($_POST['col_fecha']) ? 1 : 0;
         $this->sat_setup['sat_col_fechaini'] = isset($_POST['col_fechaini']) ? 1 : 0;
         $this->sat_setup['sat_col_fechafin'] = isset($_POST['col_fechafin']) ? 1 : 0;
         if ($fsvar->array_save($this->sat_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_sat();
                     $estado->id = intval($_POST['id_estado']);
                 }
                 $estado->descripcion = $_POST['descripcion'];
                 $estado->color = $_POST['color'];
                 $estado->activo = isset($_POST['activo']);
                 if ($estado->save()) {
                     $this->new_message('Estado guardado correctamente.');
                 } else {
                     $this->new_error_msg('Error al guardar el estado.');
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 protected function process()
 {
     $fsvar = new fs_var();
     $cron_vars = $fsvar->array_get(array('cron_exists' => FALSE, 'cron_lock' => FALSE, 'cron_error' => FALSE));
     if (isset($_GET['fix'])) {
         $cron_vars['cron_error'] = FALSE;
         $cron_vars['cron_lock'] = FALSE;
         $fsvar->array_save($cron_vars);
     }
     if (!$cron_vars['cron_exists']) {
         $this->new_advice('Nunca se ha ejecutado el <a href="http://www.facturascripts.com/comm3/index.php?page=community_item&tag=cron" target="_blank">cron</a>,' . ' te perderás algunas características interesantes de FacturaScripts.');
     } else {
         if ($cron_vars['cron_error']) {
             $this->new_error_msg('Parece que ha habido un error con el cron. Haz clic <a href="' . $this->url() . '&fix=TRUE">aquí</a> para corregirlo.');
         } else {
             if ($cron_vars['cron_lock']) {
                 $this->new_advice('Se está ejecutando el cron.');
             }
         }
     }
     if (isset($_GET['clean_cache'])) {
         /// borramos los archivos php del directorio tmp
         foreach (scandir(getcwd() . '/tmp') as $f) {
             if (substr($f, -4) == '.php') {
                 unlink('tmp/' . $f);
             }
         }
         if ($this->cache->clean()) {
             $this->new_message("Cache limpiada correctamente.");
         }
     }
 }
Ejemplo n.º 5
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->ppage = $this->page->get('ventas_servicios');
     $this->agente = new agente();
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->divisa = new divisa();
     $this->ejercicio = new ejercicio();
     $this->estado = new estado_servicio();
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->forma_pago = new forma_pago();
     $this->impuesto = new impuesto();
     $this->pais = new pais();
     $this->serie = new serie();
     /// cargamos la configuración de servicios
     $fsvar = new fs_var();
     $this->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, 'cal_inicio' => "09:00", 'cal_fin' => "20:00", 'cal_intervalo' => "30", 'servicios_linea' => 0, 'servicios_linea1' => 0, 'servicios_material_linea' => 0, 'servicios_material_estado_linea' => 0, 'servicios_accesorios_linea' => 0, 'servicios_descripcion_linea' => 0, 'servicios_solucion_linea' => 0, 'servicios_fechainicio_linea' => 0, 'servicios_fechafin_linea' => 0, 'servicios_garantia_linea' => 0, '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"), FALSE);
     /**
      * Comprobamos si el usuario tiene acceso a nueva_venta,
      * necesario para poder añadir líneas.
      */
     $this->nuevo_servicio_url = FALSE;
     if ($this->user->have_access_to('nueva_venta', FALSE)) {
         $nuevopedp = $this->page->get('nueva_venta');
         if ($nuevopedp) {
             $this->nuevo_servicio_url = $nuevopedp->url();
         }
     }
     $this->servicio = FALSE;
     $servicio = new servicio_cliente();
     if (isset($_POST['idservicio'])) {
         $this->servicio = $servicio->get($_POST['idservicio']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->servicio = $servicio->get($_GET['id']);
         }
     }
     if ($this->servicio) {
         $this->page->title = $this->servicio->codigo;
         /// cargamos el agente
         if ($this->servicio->codagente) {
             $age0 = new agente();
             $this->agente = $age0->get($this->servicio->codagente);
             if (!$this->agente) {
                 $this->agente = new agente();
             }
         } else {
             $this->agente = $this->user->get_agente();
         }
         /// cargamos el cliente
         $this->cliente_s = $this->cliente->get($this->servicio->codcliente);
         $this->modificar_detalles();
     } else {
         $this->new_error_msg("¡" . ucfirst(FS_SERVICIO) . " de cliente no encontrado!");
     }
 }
 protected function process()
 {
     $this->show_fs_toolbar = FALSE;
     $this->demo_warnign_showed = FALSE;
     $fsvar = new fs_var();
     $this->first_time = !$fsvar->simple_get('first_time');
     if (isset($_POST['modpages'])) {
         $this->first_time = FALSE;
         $fsvar->simple_save('first_time', '1');
         foreach ($this->all_pages() as $p) {
             if (!$p->exists) {
                 if ($p->delete()) {
                     $this->new_message('Se ha eliminado automáticamente la página ' . $p->name . ' ya que no tiene un controlador asociado en la carpeta controller.');
                 }
             } else {
                 if (!isset($_POST['enabled'])) {
                     $this->disable_page($p);
                 } else {
                     if (!$p->enabled and in_array($p->name, $_POST['enabled'])) {
                         $this->enable_page($p);
                     } else {
                         if ($p->enabled and !in_array($p->name, $_POST['enabled'])) {
                             $this->disable_page($p);
                         }
                     }
                 }
             }
         }
         $this->new_message('Datos guardados correctamente.');
         $this->new_message('Ahora es el momento de <a href="index.php?page=admin_empresa">
         introducir los datos de tu empresa</a>, si todavía no lo has hecho.');
     }
     $this->paginas = $this->all_pages();
     $this->load_menu(TRUE);
 }
Ejemplo n.º 7
0
 protected function private_core()
 {
     $this->cliente = FALSE;
     /// obtenemos los datos de configuración de impresión
     $fsvar = new fs_var();
     $this->impresion = array('print_ref' => '1', 'print_dto' => '1', 'print_alb' => '0');
     $this->impresion = $fsvar->array_get($this->impresion, FALSE);
     $this->impuesto = new impuesto();
     $this->servicio = FALSE;
     /// cargamos la configuración de servicios
     $this->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_garantía' => "Garantía"), FALSE);
     if (isset($_REQUEST['id'])) {
         $serv = new servicio_cliente();
         $this->servicio = $serv->get($_REQUEST['id']);
         if ($this->servicio) {
             $cliente = new cliente();
             $this->cliente = $cliente->get($this->servicio->codcliente);
         }
         if (isset($_POST['email'])) {
             $this->enviar_email('servicio');
         } else {
             $this->generar_pdf_servicio();
         }
     }
     $this->share_extensions();
 }
Ejemplo n.º 8
0
 protected function public_core()
 {
     $this->template = 'inme_public/picar';
     $this->page_title = $this->page_description = 'Picar noticias.';
     $fsvar = new fs_var();
     $this->analytics = $fsvar->simple_get('inme_analytics');
     $this->modrewrite = $fsvar->simple_get('inme_modrewrite');
     $this->buscar = '';
     $this->log = array();
     $this->noticia = new inme_noticia_fuente();
     $this->tema = new inme_tema();
     if (isset($_GET['hidden'])) {
         $this->template = FALSE;
         if (function_exists('curl_init')) {
             $this->picar();
         } else {
             echo 'ERROR: No se encuentra la extensión php-curl, tienes que instalarla.';
         }
     } else {
         if (!function_exists('curl_init')) {
             $this->new_error_msg('No se encuentra la extensión php-curl, tienes que instalarla.');
         } else {
             if (isset($_GET['picar'])) {
                 $this->picar();
             } else {
                 $this->log[] = "Para estar <b>bien informados</b> primero debemos estar informados.";
                 $this->log[] = "Pica un poco para obtener noticias.";
                 $this->log[] = "Después las agrupamos, calculamos su popularidad y podemos pasar al siguiente paso...";
             }
         }
     }
 }
 protected function private_core()
 {
     $this->grupo = new grupo_clientes();
     /// cargamos la configuración
     $fsvar = new fs_var();
     $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 1, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 1, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 1, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 1, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_codgrupo' => ''), FALSE);
     if (isset($_POST['setup'])) {
         $this->nuevocli_setup['nuevocli_cifnif_req'] = isset($_POST['nuevocli_cifnif_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_direccion'] = isset($_POST['nuevocli_direccion']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_direccion_req'] = isset($_POST['nuevocli_direccion_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_codpostal'] = isset($_POST['nuevocli_codpostal']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_codpostal_req'] = isset($_POST['nuevocli_codpostal_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_pais'] = isset($_POST['nuevocli_pais']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_pais_req'] = isset($_POST['nuevocli_pais_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_provincia'] = isset($_POST['nuevocli_provincia']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_provincia_req'] = isset($_POST['nuevocli_provincia_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_ciudad'] = isset($_POST['nuevocli_ciudad']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_ciudad_req'] = isset($_POST['nuevocli_ciudad_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_telefono1'] = isset($_POST['nuevocli_telefono1']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_telefono1_req'] = isset($_POST['nuevocli_telefono1_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_telefono2'] = isset($_POST['nuevocli_telefono2']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_telefono2_req'] = isset($_POST['nuevocli_telefono2_req']) ? 1 : 0;
         $this->nuevocli_setup['nuevocli_codgrupo'] = $_POST['nuevocli_codgrupo'];
         if ($fsvar->array_save($this->nuevocli_setup)) {
             $this->new_message('Datos guardados correctamente.');
         } else {
             $this->new_error_msg('Error al guardar los datos.');
         }
     }
 }
Ejemplo n.º 10
0
 protected function private_core()
 {
     $this->share_extensions();
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->admin;
     /**
      * Cargamos las variables del cron
      */
     $fsvar = new fs_var();
     $cron_vars = $fsvar->array_get(array('cron_exists' => FALSE, 'cron_lock' => FALSE, 'cron_error' => FALSE));
     if (isset($_GET['fix'])) {
         $cron_vars['cron_error'] = FALSE;
         $cron_vars['cron_lock'] = FALSE;
         $fsvar->array_save($cron_vars);
     } else {
         if (isset($_GET['clean_cache'])) {
             /// borramos los archivos php del directorio tmp
             foreach (scandir(getcwd() . '/tmp/' . FS_TMP_NAME) as $f) {
                 if (substr($f, -4) == '.php') {
                     unlink('tmp/' . FS_TMP_NAME . $f);
                 }
             }
             if ($this->cache->clean()) {
                 $this->new_message("Cache limpiada correctamente.");
             }
         } else {
             if (!$cron_vars['cron_exists']) {
                 $this->new_advice('Nunca se ha ejecutado el' . ' <a href="http://www.facturascripts.com/comm3/index.php?page=community_item&tag=cron" target="_blank">cron</a>,' . ' te perderás algunas características interesantes de FacturaScripts.');
             } else {
                 if ($cron_vars['cron_error']) {
                     $this->new_error_msg('Parece que ha habido un error con el cron. Haz clic <a href="' . $this->url() . '&fix=TRUE">aquí</a> para corregirlo.');
                 } else {
                     if ($cron_vars['cron_lock']) {
                         $this->new_advice('Se está ejecutando el cron.');
                     }
                 }
             }
         }
     }
     $this->b_alerta = '';
     $this->b_desde = '';
     $this->b_detalle = '';
     $this->b_hasta = '';
     $this->b_ip = '';
     $this->b_tipo = '';
     $this->b_usuario = '';
     if (isset($_POST['b_desde'])) {
         $this->b_alerta = isset($_POST['b_alerta']);
         $this->b_desde = $_POST['b_desde'];
         $this->b_detalle = $_POST['b_detalle'];
         $this->b_hasta = $_POST['b_hasta'];
         $this->b_ip = $_POST['b_ip'];
         $this->b_tipo = $_POST['b_tipo'];
         $this->b_usuario = $_POST['b_usuario'];
     }
     $this->buscar_en_log();
     $this->modulos_eneboo();
 }
Ejemplo n.º 11
0
 protected function private_core()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $eje = new ejercicio();
     $this->ejercicios = $eje->all();
     $this->serie = new serie();
     $fsvar = new fs_var();
     if (isset($_GET['num_personalizada'])) {
         $this->num_personalizada = TRUE;
         $fsvar->simple_save('numeracion_personalizada', $this->num_personalizada);
     } else {
         $this->num_personalizada = $fsvar->simple_get('numeracion_personalizada');
     }
     if (isset($_POST['codserie'])) {
         $serie = $this->serie->get($_POST['codserie']);
         if (!$serie) {
             $serie = new serie();
             $serie->codserie = $_POST['codserie'];
         }
         $serie->descripcion = $_POST['descripcion'];
         $serie->siniva = isset($_POST['siniva']);
         $serie->irpf = floatval($_POST['irpf']);
         if ($this->num_personalizada) {
             $serie->codejercicio = NULL;
             $serie->numfactura = 1;
             if ($_POST['codejercicio'] != '') {
                 $serie->codejercicio = $_POST['codejercicio'];
                 $serie->numfactura = intval($_POST['numfactura']);
             }
         }
         if ($serie->save()) {
             $this->new_message("Serie " . $serie->codserie . " guardada correctamente");
         } else {
             $this->new_error_msg("¡Imposible guardar la serie!");
         }
     } else {
         if (isset($_GET['delete'])) {
             if (!$this->user->admin) {
                 $this->new_error_msg('Sólo un administrador puede eliminar series.');
             } else {
                 $serie = $this->serie->get($_GET['delete']);
                 if ($serie) {
                     if ($serie->delete()) {
                         $this->new_message('Serie eliminada correctamente.');
                     } else {
                         $this->new_error_msg("¡Imposible eliminar la serie!");
                     }
                 } else {
                     $this->new_error_msg("Serie no encontrada.");
                 }
             }
         }
     }
 }
Ejemplo n.º 12
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();
     }
 }
Ejemplo n.º 13
0
 private function sitemap()
 {
     $this->template = FALSE;
     $fsvar = new fs_var();
     $modrewrite = $fsvar->simple_get('inme_modrewrite');
     header("Content-type: text/xml");
     echo '<?xml version="1.0" encoding="UTF-8"?>';
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $noti = new inme_noticia_fuente();
     foreach ($noti->all(0, 'editada DESC, publicada DESC') as $no) {
         if ($no->editada) {
             echo '<url><loc>', $this->empresa->web, '/', $no->url($modrewrite), '</loc><lastmod>', Date('Y-m-d', strtotime($no->fecha)), '</lastmod><changefreq>always</changefreq><priority>0.8</priority></url>';
         }
     }
     echo '</urlset>';
 }
Ejemplo n.º 14
0
 protected function private_core()
 {
     $this->albaran = FALSE;
     $this->cliente = FALSE;
     $this->factura = FALSE;
     $this->impuesto = new impuesto();
     /// obtenemos los datos de configuración de impresión
     $this->impresion = array('print_ref' => '1', 'print_dto' => '1', 'print_alb' => '0', 'print_formapago' => '1');
     $fsvar = new fs_var();
     $this->impresion = $fsvar->array_get($this->impresion, FALSE);
     $this->logo = FALSE;
     if (file_exists('tmp/' . FS_TMP_NAME . 'logo.png')) {
         $this->logo = 'tmp/' . FS_TMP_NAME . 'logo.png';
     } else {
         if (file_exists('tmp/' . FS_TMP_NAME . 'logo.jpg')) {
             $this->logo = 'tmp/' . FS_TMP_NAME . 'logo.jpg';
         }
     }
     if (isset($_REQUEST['albaran']) and isset($_REQUEST['id'])) {
         $alb = new albaran_cliente();
         $this->albaran = $alb->get($_REQUEST['id']);
         if ($this->albaran) {
             $cliente = new cliente();
             $this->cliente = $cliente->get($this->albaran->codcliente);
         }
         if (isset($_POST['email'])) {
             $this->enviar_email('albaran');
         } else {
             $this->generar_pdf_albaran();
         }
     } else {
         if (isset($_REQUEST['factura']) and isset($_REQUEST['id'])) {
             $fac = new factura_cliente();
             $this->factura = $fac->get($_REQUEST['id']);
             if ($this->factura) {
                 $cliente = new cliente();
                 $this->cliente = $cliente->get($this->factura->codcliente);
             }
             if (isset($_POST['email'])) {
                 $this->enviar_email('factura', $_REQUEST['tipo']);
             } else {
                 $this->generar_pdf_factura($_REQUEST['tipo']);
             }
         }
     }
     $this->share_extensions();
 }
Ejemplo n.º 15
0
 protected function private_core()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->admin;
     /**
      * Cargamos las variables del cron
      */
     $fsvar = new fs_var();
     $cron_vars = $fsvar->array_get(array('cron_exists' => FALSE, 'cron_lock' => FALSE, 'cron_error' => FALSE));
     if (isset($_GET['fix'])) {
         $cron_vars['cron_error'] = FALSE;
         $cron_vars['cron_lock'] = FALSE;
         $fsvar->array_save($cron_vars);
     } else {
         if (isset($_GET['clean_cache'])) {
             /// borramos los archivos php del directorio tmp
             foreach (scandir(getcwd() . '/tmp') as $f) {
                 if (substr($f, -4) == '.php') {
                     unlink('tmp/' . $f);
                 }
             }
             if ($this->cache->clean()) {
                 $this->new_message("Cache limpiada correctamente.");
             }
         } else {
             if (!$cron_vars['cron_exists']) {
                 $this->new_advice('Nunca se ha ejecutado el <a href="http://www.facturascripts.com/comm3/index.php?page=community_item&tag=cron" target="_blank">cron</a>,' . ' te perderás algunas características interesantes de FacturaScripts.');
             } else {
                 if ($cron_vars['cron_error']) {
                     $this->new_error_msg('Parece que ha habido un error con el cron. Haz clic <a href="' . $this->url() . '&fix=TRUE">aquí</a> para corregirlo.');
                 } else {
                     if ($cron_vars['cron_lock']) {
                         $this->new_advice('Se está ejecutando el cron.');
                     }
                 }
             }
         }
     }
     if (isset($_REQUEST['json'])) {
         /// desactivamos el motor de plantillas
         $this->template = FALSE;
         $fslog = new fs_log();
         echo json_encode($fslog->all(0, 10000));
     } else {
         $this->share_extensions();
     }
 }
 protected function private_core()
 {
     $this->check_menu();
     $this->share_extension();
     $this->colores = array("gris", "rojo", "verde", "azul", "naranja", "amarillo", "marron", "blanco");
     /// cargamos la configuración
     $fsvar = new fs_var();
     $this->factura_detallada_setup = $fsvar->array_get(array('f_detallada_color' => 'azul'), FALSE);
     if (isset($_POST['factura_detallada_setup'])) {
         $this->factura_detallada_setup['f_detallada_color'] = $_POST['color'];
         if ($fsvar->array_save($this->factura_detallada_setup)) {
             $this->new_message('Datos guardados correctamente.');
         } else {
             $this->new_error_msg('Error al guardar los datos.');
         }
     }
 }
Ejemplo n.º 17
0
 protected function public_core()
 {
     $this->template = 'inme_public/stats';
     $this->page_title = $this->empresa->nombrecorto;
     $this->page_description = 'Portal de noticias colaborativo, para los que huyen de la mafia de menéame.' . ' Exploramos la web para mostrarte los temas de actualidad.';
     $this->buscar = '';
     $fsvar = new fs_var();
     $this->analytics = $fsvar->simple_get('inme_analytics');
     $this->modrewrite = $fsvar->simple_get('inme_modrewrite');
     if (isset($_GET['ok_cookies'])) {
         setcookie('ok_cookies', 'TRUE', time() + FS_COOKIES_EXPIRE, '/');
         $fslog = new fs_log();
         $fslog->tipo = 'cookies';
         $fslog->detalle = 'Se han aceptado las cookies';
         $fslog->ip = $_SERVER['REMOTE_ADDR'];
         $fslog->save();
     }
 }
 protected function private_core()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $eje = new ejercicio();
     $this->ejercicios = $eje->all();
     $this->serie = new serie();
     $fsvar = new fs_var();
     if (isset($_GET['num_personalizada'])) {
         if ($_GET['num_personalizada'] == 'TRUE') {
             $this->num_personalizada = TRUE;
             $fsvar->simple_save('numeracion_personalizada', $this->num_personalizada);
         } else {
             $this->num_personalizada = FALSE;
             $fsvar->simple_delete('numeracion_personalizada');
         }
     } else {
         $this->num_personalizada = $fsvar->simple_get('numeracion_personalizada');
     }
     if (isset($_POST['codserie'])) {
         $this->modificar_serie();
     } else {
         if (isset($_GET['delete'])) {
             if (!$this->user->admin) {
                 $this->new_error_msg('Sólo un administrador puede eliminar ' . FS_SERIES . '.');
             } else {
                 $serie = $this->serie->get($_GET['delete']);
                 if ($serie) {
                     if ($serie->delete()) {
                         $this->new_message('Datos eliminados correctamente: ' . FS_SERIE . ' ' . $_GET['delete'], TRUE);
                     } else {
                         $this->new_error_msg("¡Imposible eliminar " . FS_SERIE . ' ' . $_GET['delete'] . "!");
                     }
                 } else {
                     $this->new_error_msg('Datos no encontrados: ' . FS_SERIE . ' ' . $_GET['delete']);
                 }
             }
         }
     }
 }
 protected function process()
 {
     $this->show_fs_toolbar = FALSE;
     $fsvar = new fs_var();
     $cron_vars = $fsvar->array_get(array('cron_exists' => FALSE, 'cron_lock' => FALSE, 'cron_error' => FALSE));
     if (isset($_GET['fix'])) {
         $cron_vars['cron_error'] = FALSE;
         $cron_vars['cron_lock'] = FALSE;
         $fsvar->array_save($cron_vars);
     }
     if (!$cron_vars['cron_exists']) {
         $this->new_advice('Nunca se ha ejecutado el cron, te perderás algunas características interesantes de FacturaScripts.');
     } else {
         if ($cron_vars['cron_error']) {
             $this->new_error_msg('Parece que ha habido un error con el cron. Haz clic <a href="' . $this->url() . '&fix=TRUE">aquí</a> para corregirlo.');
         } else {
             if ($cron_vars['cron_lock']) {
                 $this->new_advice('Se está ejecutando el cron.');
             }
         }
     }
     if (isset($_GET['clean_cache'])) {
         /// borramos los archivos php del directorio tmp
         foreach (scandir(getcwd() . '/tmp') as $f) {
             if (substr($f, -4) == '.php') {
                 unlink('tmp/' . $f);
             }
         }
         if ($this->cache->clean()) {
             $this->new_message("Cache limpiada correctamente.");
         }
     }
     if (FS_LCD != '') {
         $fpt = new fs_printer(FS_LCD);
         $fpt->add(chr(12) . $fpt->center_text('The cake is', 20));
         $fpt->add($fpt->center_text('a lie!', 20));
         $fpt->imprimir();
     }
 }
Ejemplo n.º 20
0
 protected function private_core()
 {
     $this->check_menu();
     $fsvar = new fs_var();
     $this->inme_config = array('inme_analytics' => '', 'inme_modrewrite' => '0');
     $this->inme_config = $fsvar->array_get($this->inme_config, FALSE);
     if (isset($_POST['analytics'])) {
         $this->inme_config['inme_analytics'] = $_POST['analytics'];
         $this->inme_config['inme_modrewrite'] = $_POST['modrewrite'];
         $this->empresa->web = $_POST['web'];
         $this->empresa->save();
         if ($fsvar->array_save($this->inme_config)) {
             $this->new_message('Datos guardados correctamente.');
         } else {
             $this->new_error_msg('Error al guardar los datos.');
         }
     } else {
         if (isset($_GET['htaccess'])) {
             $this->save_htaccess();
         }
     }
 }
Ejemplo n.º 21
0
/**
 * Devuelve el texto para un email con las modificaciones oportunas.
 * @param type $tipo
 * @param type $documento
 * @param type $firma
 * @return type
 */
function plantilla_email($tipo, $documento, $firma)
{
    /// obtenemos las plantillas
    $fsvar = new fs_var();
    $plantillas = array('mail_factura' => "Buenos días, le adjunto su #DOCUMENTO#.\n#FIRMA#", 'mail_albaran' => "Buenos días, le adjunto su #DOCUMENTO#.\n#FIRMA#", 'mail_pedido' => "Buenos días, le adjunto su #DOCUMENTO#.\n#FIRMA#", 'mail_presupuesto' => "Buenos días, le adjunto su #DOCUMENTO#.\n#FIRMA#");
    $plantillas = $fsvar->array_get($plantillas, FALSE);
    if ($tipo == 'albaran') {
        $documento = FS_ALBARAN . ' ' . $documento;
    } else {
        if ($tipo == 'pedido') {
            $documento = FS_PEDIDO . ' ' . $documento;
        } else {
            if ($tipo == 'presupuesto') {
                $documento = FS_PRESUPUESTO . ' ' . $documento;
            } else {
                $documento = $tipo . ' ' . $documento;
            }
        }
    }
    $txt = str_replace('#DOCUMENTO#', $documento, $plantillas['mail_' . $tipo]);
    $txt = str_replace('#FIRMA#', $firma, $txt);
    return $txt;
}
Ejemplo n.º 22
0
 protected function private_core()
 {
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->direccion = FALSE;
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->impuesto = new impuesto();
     $this->results = array();
     $this->grupo = new grupo_clientes();
     $this->pais = new pais();
     /// cargamos la configuración
     $fsvar = new fs_var();
     $this->nuevocli_setup = $fsvar->array_get(array('nuevocli_cifnif_req' => 0, 'nuevocli_direccion' => 0, 'nuevocli_direccion_req' => 0, 'nuevocli_codpostal' => 0, 'nuevocli_codpostal_req' => 0, 'nuevocli_pais' => 0, 'nuevocli_pais_req' => 0, 'nuevocli_provincia' => 0, 'nuevocli_provincia_req' => 0, 'nuevocli_ciudad' => 0, 'nuevocli_ciudad_req' => 0, 'nuevocli_telefono1' => 0, 'nuevocli_telefono1_req' => 0, 'nuevocli_telefono2' => 0, 'nuevocli_telefono2_req' => 0, 'nuevocli_codgrupo' => ''), FALSE);
     if (isset($_REQUEST['tipo'])) {
         $this->tipo = $_REQUEST['tipo'];
     } else {
         foreach ($this->tipos_a_guardar() as $t) {
             $this->tipo = $t['tipo'];
             break;
         }
     }
     if (isset($_REQUEST['buscar_cliente'])) {
         $this->buscar_cliente();
     } else {
         if (isset($_REQUEST['datoscliente'])) {
             $this->datos_cliente();
         } else {
             if (isset($_REQUEST['new_articulo'])) {
                 $this->new_articulo();
             } else {
                 if ($this->query != '') {
                     $this->new_search();
                 } else {
                     if (isset($_POST['referencia4precios'])) {
                         $this->get_precios_articulo();
                     } else {
                         if (isset($_POST['cliente'])) {
                             $this->cliente_s = $this->cliente->get($_POST['cliente']);
                             /**
                              * Nuevo cliente
                              */
                             if (isset($_POST['nuevo_cliente'])) {
                                 if ($_POST['nuevo_cliente'] != '') {
                                     $this->cliente_s = FALSE;
                                     if ($_POST['nuevo_cifnif'] != '') {
                                         $this->cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_cifnif']);
                                         if ($this->cliente_s) {
                                             $this->new_advice('Ya existe un cliente con ese ' . FS_CIFNIF . '. Se ha seleccionado.');
                                         }
                                     }
                                     if (!$this->cliente_s) {
                                         $this->cliente_s = new cliente();
                                         $this->cliente_s->codcliente = $this->cliente_s->get_new_codigo();
                                         $this->cliente_s->nombre = $this->cliente_s->razonsocial = $_POST['nuevo_cliente'];
                                         $this->cliente_s->cifnif = $_POST['nuevo_cifnif'];
                                         if (isset($_POST['codgrupo'])) {
                                             if ($_POST['codgrupo'] != '') {
                                                 $this->cliente_s->codgrupo = $_POST['codgrupo'];
                                             }
                                         }
                                         if (isset($_POST['nuevo_telefono1'])) {
                                             $this->cliente_s->telefono1 = $_POST['nuevo_telefono1'];
                                         }
                                         if (isset($_POST['nuevo_telefono2'])) {
                                             $this->cliente_s->telefono2 = $_POST['nuevo_telefono2'];
                                         }
                                         if ($this->cliente_s->save()) {
                                             $dircliente = new direccion_cliente();
                                             $dircliente->codcliente = $this->cliente_s->codcliente;
                                             $dircliente->codpais = $this->empresa->codpais;
                                             $dircliente->provincia = $this->empresa->provincia;
                                             $dircliente->ciudad = $this->empresa->ciudad;
                                             $dircliente->descripcion = 'Principal';
                                             if (isset($_POST['nuevo_pais'])) {
                                                 $dircliente->codpais = $_POST['nuevo_pais'];
                                             }
                                             if (isset($_POST['nuevo_provincia'])) {
                                                 $dircliente->provincia = $_POST['nuevo_provincia'];
                                             }
                                             if (isset($_POST['nuevo_ciudad'])) {
                                                 $dircliente->ciudad = $_POST['nuevo_ciudad'];
                                             }
                                             if (isset($_POST['nuevo_codpostal'])) {
                                                 $dircliente->codpostal = $_POST['nuevo_codpostal'];
                                             }
                                             if (isset($_POST['nuevo_direccion'])) {
                                                 $dircliente->direccion = $_POST['nuevo_direccion'];
                                             }
                                             if ($dircliente->save()) {
                                                 $this->new_message('Cliente agregado correctamente.');
                                             }
                                         } else {
                                             $this->new_error_msg("¡Imposible guardar la dirección del cliente!");
                                         }
                                     }
                                 }
                             }
                             if ($this->cliente_s) {
                                 foreach ($this->cliente_s->get_direcciones() as $dir) {
                                     if ($dir->domfacturacion) {
                                         $this->direccion = $dir;
                                         break;
                                     }
                                 }
                             }
                             if (isset($_POST['codagente'])) {
                                 $agente = new agente();
                                 $this->agente = $agente->get($_POST['codagente']);
                             } else {
                                 $this->agente = $this->user->get_agente();
                             }
                             $this->almacen = new almacen();
                             $this->serie = new serie();
                             $this->forma_pago = new forma_pago();
                             $this->divisa = new divisa();
                             if (isset($_POST['tipo'])) {
                                 if ($_POST['tipo'] == 'albaran') {
                                     $this->nuevo_albaran_cliente();
                                 } else {
                                     if ($_POST['tipo'] == 'factura') {
                                         $this->nueva_factura_cliente();
                                     } else {
                                         if ($_POST['tipo'] == 'presupuesto' and class_exists('presupuesto_cliente')) {
                                             $this->nuevo_presupuesto_cliente();
                                         } else {
                                             if ($_POST['tipo'] == 'pedido' and class_exists('pedido_cliente')) {
                                                 $this->nuevo_pedido_cliente();
                                             }
                                         }
                                     }
                                 }
                                 if (!$this->direccion) {
                                     $this->direccion = new direccion_cliente();
                                     $this->direccion->codcliente = $this->cliente_s->codcliente;
                                     $this->direccion->codpais = $_POST['codpais'];
                                     $this->direccion->provincia = $_POST['provincia'];
                                     $this->direccion->ciudad = $_POST['ciudad'];
                                     $this->direccion->codpostal = $_POST['codpostal'];
                                     $this->direccion->direccion = $_POST['direccion'];
                                     $this->direccion->descripcion = 'Principal';
                                     $this->direccion->save();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 23
0
 private function enviar_email($doc, $tipo = 'simple')
 {
     if ($this->empresa->can_send_mail()) {
         if ($_POST['email'] != $this->cliente->email) {
             $this->cliente->email = $_POST['email'];
             $this->cliente->save();
         }
         /// obtenemos la configuración extra del email
         $mailop = array('mail_host' => 'smtp.gmail.com', 'mail_port' => '465', 'mail_user' => '', 'mail_enc' => 'ssl');
         $fsvar = new fs_var();
         $mailop = $fsvar->array_get($mailop, FALSE);
         if ($doc == 'factura') {
             $filename = 'factura_' . $this->factura->codigo . '.pdf';
             $this->generar_pdf_factura($tipo, $filename);
         } else {
             $filename = 'albaran_' . $this->albaran->codigo . '.pdf';
             $this->generar_pdf_albaran($filename);
         }
         if (file_exists('tmp/' . FS_TMP_NAME . 'enviar/' . $filename)) {
             $mail = new PHPMailer();
             $mail->IsSMTP();
             $mail->SMTPAuth = TRUE;
             $mail->SMTPSecure = $mailop['mail_enc'];
             $mail->Host = $mailop['mail_host'];
             $mail->Port = intval($mailop['mail_port']);
             $mail->Username = $this->empresa->email;
             if ($mailop['mail_user'] != '') {
                 $mail->Username = $mailop['mail_user'];
             }
             $mail->Password = $this->empresa->email_password;
             $mail->From = $this->empresa->email;
             $mail->FromName = $this->user->nick;
             $mail->CharSet = 'UTF-8';
             if ($doc == 'factura') {
                 $mail->Subject = $this->empresa->nombre . ': Su factura ' . $this->factura->codigo;
                 $mail->AltBody = 'Buenos días, le adjunto su factura ' . $this->factura->codigo . ".\n" . $this->empresa->email_firma;
             } else {
                 $mail->Subject = $this->empresa->nombre . ': Su ' . FS_ALBARAN . ' ' . $this->albaran->codigo;
                 $mail->AltBody = 'Buenos días, le adjunto su ' . FS_ALBARAN . ' ' . $this->albaran->codigo . ".\n" . $this->empresa->email_firma;
             }
             $mail->WordWrap = 50;
             $mail->MsgHTML(nl2br($_POST['mensaje']));
             $mail->AddAttachment('tmp/' . FS_TMP_NAME . 'enviar/' . $filename);
             $mail->AddAddress($_POST['email'], $this->cliente->razonsocial);
             $mail->IsHTML(TRUE);
             if ($mail->Send()) {
                 $this->new_message('Mensaje enviado correctamente.');
             } else {
                 $this->new_error_msg("Error al enviar el email: " . $mail->ErrorInfo);
             }
             unlink('tmp/' . FS_TMP_NAME . 'enviar/' . $filename);
         } else {
             $this->new_error_msg('Imposible generar el PDF.');
         }
     }
 }
Ejemplo n.º 24
0
 private function configurar_validez()
 {
     $fsvar = new fs_var();
     if (isset($_POST['setup_validez'])) {
         $this->setup_validez = intval($_POST['setup_validez']);
         $fsvar->simple_save('presu_validez', $this->setup_validez);
         $this->new_message('Configuración modificada correctamente.');
     } else {
         $dias = $fsvar->simple_get('presu_validez');
         if ($dias) {
             $this->setup_validez = intval($dias);
         }
     }
 }
Ejemplo n.º 25
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.');
                 }
             }
         }
     }
 }
Ejemplo n.º 26
0
 private function nuevo_presupuesto_cliente()
 {
     $continuar = TRUE;
     $cliente = $this->cliente->get($_POST['cliente']);
     if (!$cliente) {
         $this->new_error_msg('Cliente no encontrado.');
         $continuar = FALSE;
     }
     $almacen = $this->almacen->get($_POST['almacen']);
     if ($almacen) {
         $this->save_codalmacen($_POST['almacen']);
     } else {
         $this->new_error_msg('Almacén no encontrado.');
         $continuar = FALSE;
     }
     $eje0 = new ejercicio();
     $ejercicio = $eje0->get_by_fecha($_POST['fecha'], FALSE);
     if (!$ejercicio) {
         $this->new_error_msg('Ejercicio no encontrado.');
         $continuar = FALSE;
     }
     $serie = $this->serie->get($_POST['serie']);
     if (!$serie) {
         $this->new_error_msg('Serie no encontrada.');
         $continuar = FALSE;
     }
     $forma_pago = $this->forma_pago->get($_POST['forma_pago']);
     if ($forma_pago) {
         $this->save_codpago($_POST['forma_pago']);
     } else {
         $this->new_error_msg('Forma de pago no encontrada.');
         $continuar = FALSE;
     }
     $divisa = $this->divisa->get($_POST['divisa']);
     if (!$divisa) {
         $this->new_error_msg('Divisa no encontrada.');
         $continuar = FALSE;
     }
     $presupuesto = new presupuesto_cliente();
     if ($this->duplicated_petition($_POST['petition_id'])) {
         $this->new_error_msg('Petición duplicada. Has hecho doble clic sobre el botón guardar
            y se han enviado dos peticiones. Mira en <a href="' . $presupuesto->url() . '">Presupuestos</a>
            para ver si el presupuesto se ha guardado correctamente.');
         $continuar = FALSE;
     }
     if ($continuar) {
         $presupuesto->fecha = $_POST['fecha'];
         $presupuesto->codalmacen = $almacen->codalmacen;
         $presupuesto->codejercicio = $ejercicio->codejercicio;
         $presupuesto->codserie = $serie->codserie;
         $presupuesto->codpago = $forma_pago->codpago;
         $presupuesto->coddivisa = $divisa->coddivisa;
         $presupuesto->tasaconv = $divisa->tasaconv;
         /// establecemos la fecha de finoferta
         $presupuesto->finoferta = date("Y-m-d", strtotime($_POST['fecha'] . " +1 month"));
         $fsvar = new fs_var();
         $dias = $fsvar->simple_get('presu_validez');
         if ($dias) {
             $presupuesto->finoferta = date("Y-m-d", strtotime($_POST['fecha'] . " +" . intval($dias) . " days"));
         }
         if ($_POST['tasaconv'] != '') {
             $presupuesto->tasaconv = floatval($_POST['tasaconv']);
         }
         $presupuesto->codagente = $this->agente->codagente;
         $presupuesto->observaciones = $_POST['observaciones'];
         $presupuesto->numero2 = $_POST['numero2'];
         $presupuesto->porcomision = $this->agente->porcomision;
         $presupuesto->codcliente = $cliente->codcliente;
         $presupuesto->cifnif = $_POST['cifnif'];
         $presupuesto->nombrecliente = $_POST['nombrecliente'];
         $presupuesto->ciudad = $_POST['ciudad'];
         $presupuesto->codpais = $_POST['codpais'];
         $presupuesto->codpostal = $_POST['codpostal'];
         $presupuesto->direccion = $_POST['direccion'];
         $presupuesto->provincia = $_POST['provincia'];
         if ($presupuesto->save()) {
             $art0 = new articulo();
             $n = floatval($_POST['numlineas']);
             for ($i = 0; $i <= $n; $i++) {
                 if (isset($_POST['referencia_' . $i])) {
                     $linea = new linea_presupuesto_cliente();
                     $linea->idpresupuesto = $presupuesto->idpresupuesto;
                     $linea->descripcion = $_POST['desc_' . $i];
                     if (!$serie->siniva and $cliente->regimeniva != 'Exento') {
                         $imp0 = $this->impuesto->get_by_iva($_POST['iva_' . $i]);
                         if ($imp0) {
                             $linea->codimpuesto = $imp0->codimpuesto;
                             $linea->iva = floatval($_POST['iva_' . $i]);
                             $linea->recargo = floatval($_POST['recargo_' . $i]);
                         } else {
                             $linea->iva = floatval($_POST['iva_' . $i]);
                             $linea->recargo = floatval($_POST['recargo_' . $i]);
                         }
                     }
                     $linea->irpf = floatval($_POST['irpf_' . $i]);
                     $linea->pvpunitario = floatval($_POST['pvp_' . $i]);
                     $linea->cantidad = floatval($_POST['cantidad_' . $i]);
                     $linea->dtopor = floatval($_POST['dto_' . $i]);
                     $linea->pvpsindto = $linea->pvpunitario * $linea->cantidad;
                     $linea->pvptotal = floatval($_POST['neto_' . $i]);
                     $articulo = $art0->get($_POST['referencia_' . $i]);
                     if ($articulo) {
                         $linea->referencia = $articulo->referencia;
                     }
                     if ($linea->save()) {
                         $presupuesto->neto += $linea->pvptotal;
                         $presupuesto->totaliva += $linea->pvptotal * $linea->iva / 100;
                         $presupuesto->totalirpf += $linea->pvptotal * $linea->irpf / 100;
                         $presupuesto->totalrecargo += $linea->pvptotal * $linea->recargo / 100;
                         if ($linea->irpf > $presupuesto->irpf) {
                             $presupuesto->irpf = $linea->irpf;
                         }
                     } else {
                         $this->new_error_msg("¡Imposible guardar la linea con referencia: " . $linea->referencia);
                         $continuar = FALSE;
                     }
                 }
             }
             if ($continuar) {
                 /// redondeamos
                 $presupuesto->neto = round($presupuesto->neto, FS_NF0);
                 $presupuesto->totaliva = round($presupuesto->totaliva, FS_NF0);
                 $presupuesto->totalirpf = round($presupuesto->totalirpf, FS_NF0);
                 $presupuesto->totalrecargo = round($presupuesto->totalrecargo, FS_NF0);
                 $presupuesto->total = $presupuesto->neto + $presupuesto->totaliva - $presupuesto->totalirpf + $presupuesto->totalrecargo;
                 if (abs(floatval($_POST['atotal']) - $presupuesto->total) >= 0.02) {
                     $this->new_error_msg("El total difiere entre el controlador y la vista (" . $presupuesto->total . " frente a " . $_POST['atotal'] . "). Debes informar del error.");
                     $presupuesto->delete();
                 } else {
                     if ($presupuesto->save()) {
                         $this->new_message("<a href='" . $presupuesto->url() . "'>" . ucfirst(FS_PRESUPUESTO) . "</a> guardado correctamente.");
                         $this->new_change(ucfirst(FS_PRESUPUESTO) . ' a Cliente ' . $presupuesto->codigo, $presupuesto->url(), TRUE);
                         if ($_POST['redir'] == 'TRUE') {
                             header('Location: ' . $presupuesto->url());
                         }
                     } else {
                         $this->new_error_msg("¡Imposible actualizar el <a href='" . $presupuesto->url() . "'>" . FS_PRESUPUESTO . "</a>!");
                     }
                 }
             } else {
                 if ($presupuesto->delete()) {
                     $this->new_message(ucfirst(FS_PRESUPUESTO) . " eliminado correctamente.");
                 } else {
                     $this->new_error_msg("¡Imposible eliminar el <a href='" . $presupuesto->url() . "'>" . FS_PRESUPUESTO . "</a>!");
                 }
             }
         } else {
             $this->new_error_msg("¡Imposible guardar el " . FS_PRESUPUESTO . "!");
         }
     }
 }
Ejemplo n.º 27
0
 /**
  * Devuelve un array con los regimenes de iva disponibles.
  * @return type
  */
 public function regimenes_iva()
 {
     if (!isset(self::$regimenes_iva)) {
         /// Si hay usa lista personalizada en fs_vars, la usamos
         $fsvar = new fs_var();
         $data = $fsvar->simple_get('proveedor::regimenes_iva');
         if ($data) {
             self::$regimenes_iva = array();
             foreach (explode(',', $data) as $d) {
                 self::$regimenes_iva[] = trim($d);
             }
         } else {
             /// sino usamos estos
             self::$regimenes_iva = array('General', 'Exento');
         }
         /// además de los que haya en la base de datos
         $data = $this->db->select("SELECT DISTINCT regimeniva FROM proveedores ORDER BY regimeniva ASC;");
         if ($data) {
             foreach ($data as $d) {
                 if (!in_array($d['regimeniva'], self::$regimenes_iva)) {
                     self::$regimenes_iva[] = $d['regimeniva'];
                 }
             }
         }
     }
     return self::$regimenes_iva;
 }
Ejemplo n.º 28
0
 protected function private_core()
 {
     $almacen = new almacen();
     $this->pais = new pais();
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     if (isset($_POST['scodalmacen'])) {
         $al0 = $almacen->get($_POST['scodalmacen']);
         if (!$al0) {
             $al0 = new almacen();
             $al0->codalmacen = $_POST['scodalmacen'];
         }
         $al0->nombre = $_POST['snombre'];
         $al0->codpais = $_POST['scodpais'];
         $al0->provincia = $_POST['sprovincia'];
         $al0->poblacion = $_POST['spoblacion'];
         $al0->direccion = $_POST['sdireccion'];
         $al0->codpostal = $_POST['scodpostal'];
         $al0->telefono = $_POST['stelefono'];
         $al0->fax = $_POST['sfax'];
         $al0->contacto = $_POST['scontacto'];
         if ($al0->save()) {
             $this->new_message("Almacén " . $al0->codalmacen . " guardado correctamente.");
         } else {
             $this->new_error_msg("¡Imposible guardar el almacén!");
         }
     } else {
         if (isset($_GET['delete'])) {
             $al0 = $almacen->get($_GET['delete']);
             if ($al0) {
                 if (!$this->user->admin) {
                     $this->new_error_msg("Solo un administrador puede eliminar un almacén.");
                 } else {
                     if ($al0->delete()) {
                         $this->new_message("Almacén " . $al0->codalmacen . " eliminado correctamente");
                     } else {
                         $this->new_error_msg("¡Imposible eliminar el almacén!");
                     }
                 }
             } else {
                 $this->new_error_msg("¡Almacén no encontrado!");
             }
         } else {
             /// ¿Guardamos las opciones avanzadas?
             $guardar = FALSE;
             foreach ($GLOBALS['config2'] as $i => $value) {
                 if (isset($_POST[$i])) {
                     $GLOBALS['config2'][$i] = $_POST[$i];
                     $guardar = TRUE;
                 }
             }
             if ($guardar) {
                 $file = fopen('tmp/' . FS_TMP_NAME . 'config2.ini', 'w');
                 if ($file) {
                     foreach ($GLOBALS['config2'] as $i => $value) {
                         if (is_numeric($value)) {
                             fwrite($file, $i . " = " . $value . ";\n");
                         } else {
                             fwrite($file, $i . " = '" . $value . "';\n");
                         }
                     }
                     fclose($file);
                 }
                 $this->new_message('Datos guardados correctamente.');
             }
         }
     }
     $this->almacenes = $almacen->all();
     /// si hay más de un almacén activamos el soporte multi-almacén en los listados
     $fsvar = new fs_var();
     if (count($this->almacenes) > 1) {
         $fsvar->simple_save('multi_almacen', TRUE);
     } else {
         $fsvar->simple_delete('multi_almacen');
     }
 }
Ejemplo n.º 29
0
 private function new_search()
 {
     /// desactivamos la plantilla HTML
     $this->template = FALSE;
     $fsvar = new fs_var();
     $multi_almacen = $fsvar->simple_get('multi_almacen');
     $stock = new stock();
     $articulo = new articulo();
     $codfamilia = '';
     if (isset($_REQUEST['codfamilia'])) {
         $codfamilia = $_REQUEST['codfamilia'];
     }
     $codfabricante = '';
     if (isset($_REQUEST['codfabricante'])) {
         $codfabricante = $_REQUEST['codfabricante'];
     }
     $con_stock = isset($_REQUEST['con_stock']);
     $this->results = $articulo->search($this->query, 0, $codfamilia, $con_stock, $codfabricante);
     /// añadimos la busqueda, el descuento, la cantidad, etc...
     foreach ($this->results as $i => $value) {
         $this->results[$i]->query = $this->query;
         $this->results[$i]->dtopor = 0;
         $this->results[$i]->cantidad = 1;
         $this->results[$i]->stockalm = $this->results[$i]->stockfis;
         if ($multi_almacen and isset($_REQUEST['codalmacen'])) {
             $this->results[$i]->stockalm = $stock->total_from_articulo($this->results[$i]->referencia, $_REQUEST['codalmacen']);
         }
     }
     /// ejecutamos las funciones de las extensiones
     foreach ($this->extensions as $ext) {
         if ($ext->type == 'function' and $ext->params == 'new_search') {
             $name = $ext->text;
             $name($this->db, $this->results);
         }
     }
     /// buscamos el grupo de clientes y la tarifa
     if (isset($_REQUEST['codcliente'])) {
         $cliente = $this->cliente->get($_REQUEST['codcliente']);
         if ($cliente) {
             if ($cliente->codgrupo) {
                 $grupo0 = new grupo_clientes();
                 $tarifa0 = new tarifa();
                 $grupo = $grupo0->get($cliente->codgrupo);
                 if ($grupo) {
                     $tarifa = $tarifa0->get($grupo->codtarifa);
                     if ($tarifa) {
                         $tarifa->set_precios($this->results);
                     }
                 }
             }
         }
     }
     header('Content-Type: application/json');
     echo json_encode($this->results);
 }
Ejemplo n.º 30
0
 private function get_download_list()
 {
     /**
      * Esta es la lista de plugins fijos, los imprescindibles.
      */
     $this->download_list = array('facturacion_base' => array('url' => 'https://github.com/NeoRazorX/facturacion_base/archive/master.zip', 'url_repo' => 'https://github.com/NeoRazorX/facturacion_base', 'description' => 'Permite la gestión básica de una empresa: gestión de ventas, de compras y contabilidad básica.'), 'argentina' => array('url' => 'https://github.com/FacturaScripts/argentina/archive/master.zip', 'url_repo' => 'https://github.com/FacturaScripts/argentina', 'description' => 'Plugin de adaptación de FacturaScripts a <b>Argentina</b>.'), 'colombia' => array('url' => 'https://github.com/salvaWEBco/colombia/archive/master.zip', 'url_repo' => 'https://github.com/salvaWEBco/colombia', 'description' => 'Plugin de adaptación de FacturaScripts a <b>Colombia</b>.'), 'ecuador' => array('url' => 'https://github.com/FacturaScripts/ecuador/archive/master.zip', 'url_repo' => 'https://github.com/FacturaScripts/ecuador', 'description' => 'Plugin de adaptación de FacturaScripts a <b>Ecuador</b>.'), 'panama' => array('url' => 'https://github.com/NeoRazorX/panama/archive/master.zip', 'url_repo' => 'https://github.com/NeoRazorX/panama', 'description' => 'Plugin de adaptación de FacturaScripts a <b>Panamá</b>.'), 'peru' => array('url' => 'https://github.com/NeoRazorX/peru/archive/master.zip', 'url_repo' => 'https://github.com/NeoRazorX/peru', 'description' => 'Plugin de adaptación de FacturaScripts a <b>Perú</b>.'), 'republica_dominicana' => array('url' => 'https://github.com/joenilson/republica_dominicana/archive/master.zip', 'url_repo' => 'https://github.com/joenilson/republica_dominicana', 'description' => 'Plugin de adaptación de FacturaScripts a <b>República Dominicana</b>.'));
     $fsvar = new fs_var();
     $this->step = $fsvar->simple_get('install_step');
     /**
      * Usamos last_download_check para almacenar la última vez que vimos las descargas.
      * Así podemos saber qué descargas son nuevas.
      */
     $this->last_download_check = $fsvar->simple_get('last_download_check');
     if (!$this->last_download_check) {
         $this->last_download_check = Date('d-m-Y', strtotime('-1week'));
     }
     $this->new_downloads = 0;
     /**
      * Download_list2 es la lista de plugins de la comunidad, se descarga de Internet.
      */
     $this->download_list2 = $this->cache->get('download_list');
     if (!$this->download_list2) {
         $json = @$this->curl_get_contents('https://www.facturascripts.com/comm3/index.php?page=community_plugins&json=TRUE', 5);
         if ($json) {
             $this->download_list2 = json_decode($json);
             $this->cache->set('download_list', $this->download_list2);
         } else {
             $this->new_error_msg('Error al descargar la lista de plugins.');
             $this->download_list2 = array();
         }
     }
     foreach ($this->download_list2 as $i => $di) {
         $this->download_list2[$i]->nuevo = FALSE;
         if (strtotime($di->creado) > strtotime($this->last_download_check)) {
             $this->new_downloads++;
             $this->download_list2[$i]->nuevo = TRUE;
         }
     }
     /// ahora nos guardamos last_download_check
     $this->last_download_check = Date('d-m-Y', strtotime('-1week'));
     $fsvar->simple_save('last_download_check', $this->last_download_check);
 }