protected function process() { $this->paquete = new paquete(); $this->cache_paquete = new cache_paquete(); $this->buttons[] = new fs_button_img('b_nuevo_paquete', 'Nuevo'); if ($this->cache->error()) { $this->new_error_msg('Memcache está deshabilitado y es necesario para continuar. ' . $this->cache->error_msg()); } if ($this->query != '') { $this->new_search(); } else { if (isset($_GET['add2cache'])) { $this->cache_paquete->add($_GET['add2cache']); } else { if (isset($_GET['cleancache'])) { $this->cache_paquete->clean(); } else { if (isset($_GET['fillcache'])) { $art = new articulo(); foreach ($art->all(0, 100) as $a) { $this->cache_paquete->add($a->referencia); } } } } } }
protected function private_core() { $this->agente = new agente(); $this->almacen = new almacen(); $this->desde = Date('1-m-Y'); $this->documento = 'facturascli'; $this->familia = new familia(); $this->hasta = Date('d-m-Y', mktime(0, 0, 0, date("m") + 1, date("1") - 1, date("Y"))); $this->url_recarga = FALSE; $this->pestanya = 'stats'; if (isset($_GET['tab'])) { $this->pestanya = $_GET['tab']; } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } if (isset($_REQUEST['buscar_referencia'])) { $this->buscar_referencia(); } else { if ($this->pestanya == 'stats') { $this->share_extension(); $this->articulo = new articulo(); $this->stats = $this->stats(); $linea_fac_cli = new linea_factura_cliente(); $linea_fac_pro = new linea_factura_proveedor(); $this->top_ventas = $this->top_articulo_faccli(); $this->sin_vender = $this->sin_vender(); $this->top_compras = $this->top_articulo_facpro(); } else { if ($this->pestanya == 'stock') { /// forzamos la comprobación de la tabla stock $stock = new stock(); $this->tipo_stock = 'todo'; if (isset($_GET['tipo'])) { $this->tipo_stock = $_GET['tipo']; } else { if (isset($_GET['recalcular']) and isset($_GET['offset'])) { $articulo = new articulo(); $continuar = FALSE; $offset = intval($_GET['offset']); $this->new_message('Recalculando stock de artículos... ' . $offset); foreach ($articulo->all($offset, 30) as $art) { $this->calcular_stock_real($art); $continuar = TRUE; $offset++; } if ($continuar) { $this->url_recarga = $this->url() . '&tab=stock&recalcular=TRUE&offset=' . $offset; } else { $this->new_advice('Finalizado <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>'); } } } if ($this->tipo_stock == 'reg') { /// forzamos la comprobación de la tabla stocks $reg = new regularizacion_stock(); $this->resultados = $this->regularizaciones_stock($this->offset); } else { if (isset($_GET['download'])) { $this->download_stock(); } else { $this->resultados = $this->stock($this->offset, $this->tipo_stock); } } } else { if ($this->pestanya == 'impuestos') { $this->impuesto = new impuesto(); $this->codimpuesto = ''; if (isset($_REQUEST['codimpuesto'])) { $this->codimpuesto = $_REQUEST['codimpuesto']; } /// ¿Hacemos cambio? $this->cambia_impuesto(); } else { if ($this->pestanya == 'varios') { $this->cantidades = FALSE; $this->codfamilia = ''; $this->minimo = ''; $this->referencia = ''; if (isset($_GET['ref'])) { $this->referencia = $_GET['ref']; } if (isset($_POST['informe'])) { if ($_POST['informe'] == 'listadomov') { $this->referencia = $_POST['referencia']; $this->codfamilia = $_POST['codfamilia']; $this->desde = $_POST['desde']; $this->hasta = $_POST['hasta']; $this->codagente = $_POST['codagente']; $this->informe_movimientos(); } else { if ($_POST['informe'] == 'facturacion') { $this->documento = $_POST['documento']; $this->desde = $_POST['desde']; $this->hasta = $_POST['hasta']; $this->codfamilia = $_POST['codfamilia']; $this->cantidades = $_POST['cantidades'] == 'TRUE'; $this->minimo = $_POST['minimo']; $this->informe_facturacion(); } else { if ($_POST['informe'] == 'ventascli') { $this->referencia = $_POST['referencia']; $this->desde = $_POST['desde']; $this->hasta = $_POST['hasta']; $this->codfamilia = $_POST['codfamilia']; $this->minimo = $_POST['minimo']; $this->informe_ventascli(); } } } } } } } } } }
protected function process() { $this->custom_search = TRUE; $articulo = new articulo(); $this->familia = new familia(); $this->impuesto = new impuesto(); $this->tarifa = new tarifa(); $this->buttons[] = new fs_button('b_nuevo_articulo', 'Nuevo', '#nuevo'); $this->buttons[] = new fs_button('b_modificar_iva', 'Modificar IVA', '#mod-iva'); $this->codfamilia = ''; if (isset($_REQUEST['codfamilia'])) { $this->codfamilia = $_REQUEST['codfamilia']; } $this->con_stock = isset($_REQUEST['con_stock']); if (isset($_POST['codtarifa'])) { $tar0 = $this->tarifa->get($_POST['codtarifa']); if (!$tar0) { $tar0 = new tarifa(); $tar0->codtarifa = $_POST['codtarifa']; } $tar0->nombre = $_POST['nombre']; $tar0->incporcentual = 0 - floatval($_POST['dtopor']); if ($tar0->save()) { $this->new_message("Tarifa guardada correctamente."); } else { $this->new_error_msg("¡Imposible guardar la tarifa!"); } } else { if (isset($_GET['delete_tarifa'])) { $tar0 = $this->tarifa->get($_GET['delete_tarifa']); if ($tar0) { if ($tar0->delete()) { $this->new_message("Tarifa borrada correctamente."); } else { $this->new_error_msg("¡Imposible borrar la tarifa!"); } } else { $this->new_error_msg("¡La tarifa no existe!"); } } else { if (isset($_POST['mod_iva'])) { if ($_POST['codimpuesto'] == $_POST['codimpuesto2']) { $this->new_error_msg("¡Has seleccionado el mismo IVA dos veces!"); } else { if ($articulo->move_codimpuesto($_POST['codimpuesto'], $_POST['codimpuesto2'], isset($_POST['mantener']))) { $this->new_message("Artículos modificados correctamente."); } else { $this->new_error_msg("¡Impodible modificar los artículos!"); } } } else { if (isset($_POST['referencia']) and isset($_POST['codfamilia']) and isset($_POST['codimpuesto'])) { $this->save_codfamilia($_POST['codfamilia']); $this->save_codimpuesto($_POST['codimpuesto']); $art0 = $articulo->get($_POST['referencia']); if ($art0) { $this->new_error_msg('Ya existe el artículo <a href="' . $art0->url() . '">' . $art0->referencia . '</a>'); } else { $articulo->referencia = $_POST['referencia']; $articulo->descripcion = $_POST['referencia']; $articulo->codfamilia = $_POST['codfamilia']; $articulo->set_impuesto($_POST['codimpuesto']); if ($articulo->save()) { header('location: ' . $articulo->url()); } else { $this->new_error_msg("¡Error al crear el articulo!"); } } } else { if (isset($_GET['delete'])) { $art = $articulo->get($_GET['delete']); if ($art) { if ($art->delete()) { $this->new_message("Articulo " . $art->referencia . " eliminado correctamente."); } else { $this->new_error_msg("¡Error al eliminarl el articulo!"); } } } } } } } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } if ($this->query != '') { $this->resultados = $articulo->search($this->query, $this->offset, $this->codfamilia, $this->con_stock); } else { if (isset($_GET['solo_stock'])) { $this->resultados = $articulo->search('', $this->offset, '', TRUE); } else { if (isset($_GET['public'])) { $this->resultados = $articulo->all_publico($this->offset); } else { $this->resultados = $articulo->all($this->offset); } } } }
protected function process() { $articulo = new articulo(); $this->familia = new familia(); $this->fabricante = new fabricante(); $this->impuesto = new impuesto(); $this->tarifa = new tarifa(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); /** * Si hay alguna extensión de tipo config y texto no_tab_tarifas, * desactivamos la pestaña tarifas. */ $this->mostrar_tab_tarifas = TRUE; foreach ($this->extensions as $ext) { if ($ext->type == 'config' and $ext->text == 'no_tab_tarifas') { $this->mostrar_tab_tarifas = FALSE; break; } } if (isset($_POST['codtarifa'])) { /// crear/editar tarifa $tar0 = $this->tarifa->get($_POST['codtarifa']); if (!$tar0) { $tar0 = new tarifa(); $tar0->codtarifa = $_POST['codtarifa']; } $tar0->nombre = $_POST['nombre']; $tar0->aplicar_a = $_POST['aplicar_a']; $tar0->set_x(floatval($_POST['dtopor'])); $tar0->set_y(floatval($_POST['inclineal'])); if ($tar0->save()) { $this->new_message("Tarifa guardada correctamente."); } else { $this->new_error_msg("¡Imposible guardar la tarifa!"); } } else { if (isset($_GET['delete_tarifa'])) { /// eliminar tarifa $tar0 = $this->tarifa->get($_GET['delete_tarifa']); if ($tar0) { if ($tar0->delete()) { $this->new_message("Tarifa borrada correctamente."); } else { $this->new_error_msg("¡Imposible borrar la tarifa!"); } } else { $this->new_error_msg("¡La tarifa no existe!"); } } else { if (isset($_POST['referencia']) and isset($_POST['codfamilia']) and isset($_POST['codimpuesto'])) { /// nuevo artículo $this->save_codfamilia($_POST['codfamilia']); $this->save_codimpuesto($_POST['codimpuesto']); $art0 = $articulo->get($_POST['referencia']); if ($art0) { $this->new_error_msg('Ya existe el artículo <a href="' . $art0->url() . '">' . $art0->referencia . '</a>'); } else { $articulo->referencia = $_POST['referencia']; $articulo->descripcion = $_POST['referencia']; $articulo->codfamilia = $_POST['codfamilia']; if ($_POST['codfabricante'] != '') { $articulo->codfabricante = $_POST['codfabricante']; } $articulo->set_pvp(floatval($_POST['pvp'])); $articulo->set_impuesto($_POST['codimpuesto']); if ($articulo->save()) { header('location: ' . $articulo->url()); } else { $this->new_error_msg("¡Error al crear el articulo!"); } } } else { if (isset($_GET['delete'])) { /// eliminar artículo $art = $articulo->get($_GET['delete']); if ($art) { if ($art->delete()) { $this->new_message("Articulo " . $art->referencia . " eliminado correctamente."); } else { $this->new_error_msg("¡Error al eliminarl el articulo!"); } } } } } } /// recogemos los datos necesarios para la búsqueda $this->codfamilia = ''; if (isset($_REQUEST['codfamilia'])) { $this->codfamilia = $_REQUEST['codfamilia']; } $this->codfabricante = ''; if (isset($_REQUEST['codfabricante'])) { $this->codfabricante = $_REQUEST['codfabricante']; } $this->con_stock = isset($_REQUEST['con_stock']); $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } if ($this->query != '') { $this->resultados = $articulo->search($this->query, $this->offset, $this->codfamilia, $this->con_stock, $this->codfabricante); } else { if (isset($_GET['solo_stock'])) { $this->resultados = $articulo->search('', $this->offset, '', TRUE); } else { if (isset($_GET['public'])) { $this->resultados = $articulo->all_publico($this->offset); } else { $this->resultados = $articulo->all($this->offset); } } } }