protected function process()
 {
     $this->ppage = $this->page->get('admin_agentes');
     $this->agente = FALSE;
     if (isset($_GET['cod'])) {
         $agente = new agente();
         $this->agente = $agente->get($_GET['cod']);
     }
     if ($this->agente) {
         $this->page->title .= ' ' . $this->agente->codagente;
         if ($this->user->codagente != $this->agente->codagente) {
             $this->buttons[] = new fs_button_img('b_delete_agente', 'Eliminar', 'trash.png', '#', TRUE);
         }
         if (isset($_POST['nombre'])) {
             if ($this->user_can_edit()) {
                 $this->agente->nombre = $_POST['nombre'];
                 $this->agente->apellidos = $_POST['apellidos'];
                 $this->agente->dnicif = $_POST['dnicif'];
                 $this->agente->email = $_POST['email'];
                 $this->agente->telefono = $_POST['telefono'];
                 $this->agente->porcomision = floatval($_POST['porcomision']);
                 if ($this->agente->save()) {
                     $this->new_message("Datos del empleado guardados correctamente.");
                 } else {
                     $this->new_error_msg("¡Imposible guardar los datos del empleado!");
                 }
             } else {
                 $this->new_error_msg('No tienes permiso para modificar estos datos.');
             }
         }
     } else {
         $this->new_error_msg("Empleado no encontrado.");
     }
 }
예제 #2
0
 public function process()
 {
     $this->share_extensions();
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $this->agente = new agente();
     $this->ejercicio = new ejercicio();
     $this->suser = FALSE;
     if (isset($_GET['snick'])) {
         $this->suser = $this->user->get($_GET['snick']);
     }
     if ($this->suser) {
         $this->page->title = $this->suser->nick;
         if (isset($_POST['nnombre'])) {
             $age0 = new agente();
             $age0->codagente = $age0->get_new_codigo();
             $age0->nombre = $_POST['nnombre'];
             $age0->apellidos = $_POST['napellidos'];
             $age0->dnicif = $_POST['ndnicif'];
             $age0->telefono = $_POST['ntelefono'];
             $age0->email = $_POST['nemail'];
             if ($age0->save()) {
                 $this->new_message("Empleado " . $age0->codagente . " guardado correctamente.");
                 $this->suser->codagente = $age0->codagente;
                 if ($this->suser->save()) {
                     $this->new_message("Empleado " . $age0->codagente . " asignado correctamente.");
                 } else {
                     $this->new_error_msg("¡Imposible asignar el agente!");
                 }
             } else {
                 $this->new_error_msg("¡Imposible guardar el agente!");
             }
         } else {
             if (isset($_POST['spassword']) or isset($_POST['scodagente']) or isset($_POST['sadmin'])) {
                 $this->modificar_user();
             }
         }
         /// ¿Estamos modificando nuestro usuario?
         if ($this->suser->nick == $this->user->nick) {
             $this->user = $this->suser;
         }
         /// si el usuario no tiene acceso a ninguna página, entonces hay que informar del problema.
         if (!$this->suser->admin) {
             $sin_paginas = TRUE;
             foreach ($this->all_pages() as $p) {
                 if ($p->enabled) {
                     $sin_paginas = FALSE;
                     break;
                 }
             }
             if ($sin_paginas) {
                 $this->new_advice('No has autorizado a este usuario a acceder a ninguna' . ' página y por tanto no podrá hacer nada. Puedes darle acceso a alguna página' . ' desde la pestaña autorizar.');
             }
         }
         $fslog = new fs_log();
         $this->user_log = $fslog->all_from($this->suser->nick);
     } else {
         $this->new_error_msg("Usuario no encontrado.");
     }
 }
 protected function process()
 {
     $albaran = new albaran_cliente();
     /// desactivamos la barra de botones
     $this->show_fs_toolbar = FALSE;
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     /// Usamos una cookie para recordar si el usuario quiere ver los pendientes
     $this->pendientes = isset($_COOKIE['ventas_alb_ptes']);
     if (isset($_GET['ptefactura'])) {
         $this->pendientes = $_GET['ptefactura'] == 'TRUE';
         if ($this->pendientes) {
             setcookie('ventas_alb_ptes', 'TRUE', time() + FS_COOKIES_EXPIRE);
         } else {
             setcookie('ventas_alb_ptes', FALSE, time() - FS_COOKIES_EXPIRE);
         }
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_GET['codagente'])) {
             $this->template = 'extension/ventas_albaranes_agente';
             $agente = new agente();
             $this->agente = $agente->get($_GET['codagente']);
             $this->resultados = $albaran->all_from_agente($_GET['codagente'], $this->offset);
         } else {
             if (isset($_GET['codcliente'])) {
                 $this->template = 'extension/ventas_albaranes_cliente';
                 $cliente = new cliente();
                 $this->cliente = $cliente->get($_GET['codcliente']);
                 $this->resultados = $albaran->all_from_cliente($_GET['codcliente'], $this->offset);
             } else {
                 if (isset($_GET['ref'])) {
                     $this->template = 'extension/ventas_albaranes_articulo';
                     $articulo = new articulo();
                     $this->articulo = $articulo->get($_GET['ref']);
                     $linea = new linea_albaran_cliente();
                     $this->resultados = $linea->all_from_articulo($_GET['ref'], $this->offset);
                 } else {
                     $this->share_extension();
                     if (isset($_POST['delete'])) {
                         $this->delete_albaran();
                     }
                     if ($this->query) {
                         $this->resultados = $albaran->search($this->query, $this->offset);
                     } else {
                         if ($this->pendientes) {
                             $this->resultados = $albaran->all_ptefactura($this->offset);
                         } else {
                             $this->resultados = $albaran->all($this->offset);
                         }
                     }
                 }
             }
         }
     }
 }
 protected function process()
 {
     $this->ppage = $this->page->get('ventas_pedidos');
     $this->agente = FALSE;
     /// desactivamos la barra de botones
     $this->show_fs_toolbar = FALSE;
     $pedido = new pedido_cliente();
     $this->pedido = FALSE;
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->ejercicio = new ejercicio();
     $this->familia = new familia();
     $this->impuesto = new impuesto();
     $this->nuevo_pedido_url = FALSE;
     $this->serie = new serie();
     /**
      * Comprobamos si el usuario tiene acceso a nueva_venta,
      * necesario para poder añadir líneas.
      */
     if ($this->user->have_access_to('nueva_venta', FALSE)) {
         $nuevopedp = $this->page->get('nueva_venta');
         if ($nuevopedp) {
             $this->nuevo_pedido_url = $nuevopedp->url();
         }
     }
     if (isset($_POST['idpedido'])) {
         $this->pedido = $pedido->get($_POST['idpedido']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->pedido = $pedido->get($_GET['id']);
         }
     }
     if ($this->pedido) {
         $this->page->title = $this->pedido->codigo;
         /// cargamos el agente
         if (!is_null($this->pedido->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->pedido->codagente);
         }
         /// cargamos el cliente
         $this->cliente_s = $this->cliente->get($this->pedido->codcliente);
         /// comprobamos el pedido
         if ($this->pedido->full_test()) {
             if (isset($_REQUEST['status'])) {
                 $this->pedido->status = intval($_REQUEST['status']);
                 if ($this->pedido->status == 1 and is_null($this->pedido->idalbaran)) {
                     $this->generar_albaran();
                 } elseif ($this->pedido->save()) {
                     $this->new_message(ucfirst(FS_PEDIDO) . " modificado correctamente.");
                 } else {
                     $this->new_error_msg("¡Imposible modificar el " . FS_PEDIDO . "!");
                 }
             }
         }
     } else {
         $this->new_error_msg("¡" . ucfirst(FS_PEDIDO) . " de cliente no encontrado!");
     }
 }
 protected function process()
 {
     $this->show_fs_toolbar = FALSE;
     $this->proveedor = new proveedor();
     $this->proveedor_s = FALSE;
     $this->familia = new familia();
     $this->impuesto = new impuesto();
     $this->results = array();
     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_proveedor'])) {
         $this->buscar_proveedor();
     } else {
         if (isset($_REQUEST['datosproveedor'])) {
             $this->datos_proveedor();
         } else {
             if (isset($_GET['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['proveedor'])) {
                             $this->proveedor_s = $this->proveedor->get($_POST['proveedor']);
                             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_proveedor();
                                 } else {
                                     if ($_POST['tipo'] == 'factura') {
                                         $this->nueva_factura_proveedor();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #6
0
 protected function process()
 {
     $this->factura = new factura_cliente();
     $this->huecos = array();
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_GET['codagente'])) {
             $this->template = 'extension/ventas_facturas_agente';
             $agente = new agente();
             $this->agente = $agente->get($_GET['codagente']);
             $this->resultados = $this->factura->all_from_agente($_GET['codagente'], $this->offset);
         } else {
             if (isset($_GET['codcliente'])) {
                 $this->template = 'extension/ventas_facturas_cliente';
                 $cliente = new cliente();
                 $this->cliente = $cliente->get($_GET['codcliente']);
                 $this->resultados = $this->factura->all_from_cliente($_GET['codcliente'], $this->offset);
             } else {
                 if (isset($_GET['ref'])) {
                     $this->template = 'extension/ventas_facturas_articulo';
                     $articulo = new articulo();
                     $this->articulo = $articulo->get($_GET['ref']);
                     $linea = new linea_factura_cliente();
                     $this->resultados = $linea->all_from_articulo($_GET['ref'], $this->offset);
                 } else {
                     $this->share_extension();
                     $this->huecos = $this->factura->huecos();
                     if (isset($_GET['delete'])) {
                         $fact = $this->factura->get($_GET['delete']);
                         if ($fact) {
                             if ($fact->delete()) {
                                 $this->new_message("Factura eliminada correctamente.");
                             } else {
                                 $this->new_error_msg("¡Imposible eliminar la factura!");
                             }
                         } else {
                             $this->new_error_msg("¡Factura no encontrada!");
                         }
                     }
                     if ($this->query != '') {
                         $this->resultados = $this->factura->search($this->query, $this->offset);
                     } else {
                         if (isset($_GET['sinpagar'])) {
                             $this->resultados = $this->factura->all_sin_pagar($this->offset);
                         } else {
                             $this->resultados = $this->factura->all($this->offset);
                         }
                     }
                 }
             }
         }
     }
 }
 protected function process()
 {
     $this->factura = new factura_proveedor();
     /// desactivamos la barra de botones
     $this->show_fs_toolbar = FALSE;
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_GET['codagente'])) {
             $this->template = 'extension/compras_facturas_agente';
             $agente = new agente();
             $this->agente = $agente->get($_GET['codagente']);
             $this->resultados = $this->factura->all_from_agente($_GET['codagente'], $this->offset);
         } else {
             if (isset($_GET['codproveedor'])) {
                 $this->template = 'extension/compras_facturas_proveedor';
                 $proveedor = new proveedor();
                 $this->proveedor = $proveedor->get($_GET['codproveedor']);
                 $this->resultados = $this->factura->all_from_proveedor($_GET['codproveedor'], $this->offset);
             } else {
                 if (isset($_GET['ref'])) {
                     $this->template = 'extension/compras_facturas_articulo';
                     $articulo = new articulo();
                     $this->articulo = $articulo->get($_GET['ref']);
                     $linea = new linea_factura_proveedor();
                     $this->resultados = $linea->all_from_articulo($_GET['ref'], $this->offset);
                 } else {
                     $this->share_extension();
                     if (isset($_GET['delete'])) {
                         $fact = $this->factura->get($_GET['delete']);
                         if ($fact) {
                             if ($fact->delete()) {
                                 $this->new_message("Factura eliminada correctamente.");
                             } else {
                                 $this->new_error_msg("¡Imposible eliminar la factura!");
                             }
                         } else {
                             $this->new_error_msg("Factura no encontrada.");
                         }
                     }
                     if ($this->query != '') {
                         $this->resultados = $this->factura->search($this->query, $this->offset);
                     } else {
                         if (isset($_GET['sinpagar'])) {
                             $this->resultados = $this->factura->all_sin_pagar($this->offset);
                         } else {
                             $this->resultados = $this->factura->all($this->offset);
                         }
                     }
                 }
             }
         }
     }
 }
예제 #8
0
 protected function process()
 {
     $pedido = new pedido_cliente();
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     $this->mostrar = 'todos';
     if (isset($_GET['mostrar'])) {
         $this->mostrar = $_GET['mostrar'];
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_GET['codagente'])) {
             $this->template = 'extension/ventas_pedidos_agente';
             $agente = new agente();
             $this->agente = $agente->get($_GET['codagente']);
             $this->resultados = $pedido->all_from_agente($_GET['codagente'], $this->offset);
         } else {
             if (isset($_GET['codcliente'])) {
                 $this->template = 'extension/ventas_pedidos_cliente';
                 $cliente = new cliente();
                 $this->cliente = $cliente->get($_GET['codcliente']);
                 $this->resultados = $pedido->all_from_cliente($_GET['codcliente'], $this->offset);
             } else {
                 if (isset($_GET['ref'])) {
                     $this->template = 'extension/ventas_pedidos_articulo';
                     $articulo = new articulo();
                     $this->articulo = $articulo->get($_GET['ref']);
                     $linea = new linea_pedido_cliente();
                     $this->resultados = $linea->all_from_articulo($_GET['ref'], $this->offset);
                 } else {
                     $this->share_extension();
                     if (isset($_POST['delete'])) {
                         $this->delete_pedido();
                     }
                     if ($this->query) {
                         $this->resultados = $pedido->search($this->query, $this->offset);
                     } else {
                         if ($this->mostrar == 'pendientes') {
                             $this->resultados = $pedido->all_ptealbaran($this->offset);
                         } else {
                             if ($this->mostrar == 'rechazados') {
                                 $this->resultados = $pedido->all_rechazados($this->offset);
                             } else {
                                 /// ejecutamos el proceso del cron para pedidos.
                                 $pedido->cron_job();
                                 $this->resultados = $pedido->all($this->offset);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 protected function process()
 {
     $this->ppage = $this->page->get('compras_albaranes');
     $this->agente = FALSE;
     /// desactivamos la barra de botones
     $this->show_fs_toolbar = FALSE;
     $albaran = new albaran_proveedor();
     $this->albaran = FALSE;
     $this->ejercicio = new ejercicio();
     $this->familia = new familia();
     $this->impuesto = new impuesto();
     $this->proveedor = new proveedor();
     $this->proveedor_s = FALSE;
     $this->serie = new serie();
     /// comprobamos si el usuario tiene acceso a nueva_compra
     $this->nuevo_albaran_url = FALSE;
     if ($this->user->have_access_to('nueva_compra', FALSE)) {
         $nuevoalbp = $this->page->get('nueva_compra');
         if ($nuevoalbp) {
             $this->nuevo_albaran_url = $nuevoalbp->url();
         }
     }
     if (isset($_POST['idalbaran'])) {
         $this->albaran = $albaran->get($_POST['idalbaran']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->albaran = $albaran->get($_GET['id']);
         }
     }
     if ($this->albaran) {
         $this->page->title = $this->albaran->codigo;
         /// cargamos el agente
         if (!is_null($this->albaran->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->albaran->codagente);
         }
         /// cargamos el proveedor
         $this->proveedor_s = $this->proveedor->get($this->albaran->codproveedor);
         /// comprobamos el albarán
         if ($this->albaran->full_test()) {
             if (isset($_GET['facturar']) and isset($_GET['petid']) and $this->albaran->ptefactura) {
                 if ($this->duplicated_petition($_GET['petid'])) {
                     $this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
                 } else {
                     $this->generar_factura();
                 }
             }
             if (isset($_POST['actualizar_precios'])) {
                 $this->actualizar_precios();
             }
         }
     } else {
         $this->new_error_msg("¡" . FS_ALBARAN . " de proveedor no encontrado!");
     }
 }
예제 #10
0
 public function __construct($data = FALSE)
 {
     parent::__construct('cajas_general', 'plugins/caja_general/');
     if (!isset(self::$agentes)) {
         self::$agentes = array();
     }
     if ($data) {
         $this->id = $this->intval($data['id']);
         $this->codalmacen = $data['codalmacen'];
         $this->codagente = $data['codagente'];
         $this->f_inicio = Date('d-m-Y H:i:s', strtotime($data['f_inicio']));
         $this->d_inicio = floatval($data['d_inicio']);
         $this->codagente_fin = $data['codagente_fin'];
         if (is_null($data['f_fin'])) {
             $this->f_fin = NULL;
         } else {
             $this->f_fin = Date('d-m-Y H:i:s', strtotime($data['f_fin']));
         }
         $this->d_fin = floatval($data['d_fin']);
         $this->descuadre = floatval($data['descuadre']);
         $this->apuntes = $this->intval($data['apuntes']);
         $this->ip = NULL;
         if (isset($data['ip'])) {
             $this->ip = $data['ip'];
         }
         foreach (self::$agentes as $ag) {
             if ($ag->codagente == $this->codagente) {
                 $this->agente = $ag;
                 break;
             }
         }
         if (!isset($this->agente)) {
             $ag = new agente();
             $this->agente = $ag->get($this->codagente);
             self::$agentes[] = $this->agente;
         }
     } else {
         $this->id = NULL;
         $this->codalmacen = NULL;
         $this->codagente = NULL;
         $this->f_inicio = Date('d-m-Y H:i:s');
         $this->d_inicio = 0;
         $this->codagente_fin = NULL;
         $this->f_fin = NULL;
         $this->d_fin = 0;
         $this->descuadre = 0;
         $this->apuntes = 0;
         $this->ip = NULL;
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $this->ip = $_SERVER['REMOTE_ADDR'];
         }
         $this->agente = NULL;
     }
 }
예제 #11
0
 protected function private_core()
 {
     $this->agente = new agente();
     if (isset($_POST['sdnicif'])) {
         $age0 = new agente();
         $age0->codagente = $age0->get_new_codigo();
         $age0->nombre = $_POST['snombre'];
         $age0->apellidos = $_POST['sapellidos'];
         $age0->dnicif = $_POST['sdnicif'];
         $age0->telefono = $_POST['stelefono'];
         $age0->email = $_POST['semail'];
         if ($age0->save()) {
             $this->new_message("Empleado " . $age0->codagente . " guardado correctamente.");
             header('location: ' . $age0->url());
         } else {
             $this->new_error_msg("¡Imposible guardar el empleado!");
         }
     } else {
         if (isset($_GET['delete'])) {
             $age0 = $this->agente->get($_GET['delete']);
             if ($age0) {
                 if (FS_DEMO) {
                     $this->new_error_msg('En el modo <b>demo</b> no se pueden eliminar empleados. Otro usuario podría estar usándolo.');
                 } else {
                     if ($age0->delete()) {
                         $this->new_message("Empleado " . $age0->codagente . " eliminado correctamente.");
                     } else {
                         $this->new_error_msg("¡Imposible eliminar el empleado!");
                     }
                 }
             } else {
                 $this->new_error_msg("¡Empleado no encontrado!");
             }
         }
     }
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     $this->ciudad = '';
     if (isset($_REQUEST['ciudad'])) {
         $this->ciudad = $_REQUEST['ciudad'];
     }
     $this->provincia = '';
     if (isset($_REQUEST['provincia'])) {
         $this->provincia = $_REQUEST['provincia'];
     }
     $this->orden = 'nombre ASC';
     if (isset($_REQUEST['orden'])) {
         $this->orden = $_REQUEST['orden'];
     }
     $this->buscar();
 }
 protected function process()
 {
     $pedido = new pedido_cliente();
     /// desactivamos la barra de botones
     $this->show_fs_toolbar = FALSE;
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_GET['codagente'])) {
             $this->template = 'extension/ventas_pedidos_agente';
             $agente = new agente();
             $this->agente = $agente->get($_GET['codagente']);
             $this->resultados = $pedido->all_from_agente($_GET['codagente'], $this->offset);
         } else {
             if (isset($_GET['codcliente'])) {
                 $this->template = 'extension/ventas_pedidos_cliente';
                 $cliente = new cliente();
                 $this->cliente = $cliente->get($_GET['codcliente']);
                 $this->resultados = $pedido->all_from_cliente($_GET['codcliente'], $this->offset);
             } else {
                 if (isset($_GET['ref'])) {
                     $this->template = 'extension/ventas_pedidos_articulo';
                     $articulo = new articulo();
                     $this->articulo = $articulo->get($_GET['ref']);
                     $linea = new linea_pedido_cliente();
                     $this->resultados = $linea->all_from_articulo($_GET['ref'], $this->offset);
                 } else {
                     $this->share_extension();
                     if (isset($_POST['delete'])) {
                         $this->delete_pedido();
                     }
                     if ($this->query) {
                         $this->resultados = $pedido->search($this->query, $this->offset);
                     } else {
                         if (isset($_GET['pendientes'])) {
                             $this->resultados = $pedido->all_ptealbaran($this->offset);
                         } else {
                             if (isset($_GET['rechazados'])) {
                                 $this->resultados = $pedido->all_rechazados($this->offset);
                             } else {
                                 $this->resultados = $pedido->all($this->offset);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #13
0
 protected function private_core()
 {
     $this->ppage = $this->page->get('admin_agentes');
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $this->agente = FALSE;
     if (isset($_GET['cod'])) {
         $agente = new agente();
         $this->agente = $agente->get($_GET['cod']);
     }
     if ($this->agente) {
         $this->page->title .= ' ' . $this->agente->codagente;
         if (isset($_POST['nombre'])) {
             if ($this->user_can_edit()) {
                 $this->agente->nombre = $_POST['nombre'];
                 $this->agente->apellidos = $_POST['apellidos'];
                 $this->agente->dnicif = $_POST['dnicif'];
                 $this->agente->telefono = $_POST['telefono'];
                 $this->agente->email = $_POST['email'];
                 $this->agente->cargo = $_POST['cargo'];
                 $this->agente->provincia = $_POST['provincia'];
                 $this->agente->ciudad = $_POST['ciudad'];
                 $this->agente->direccion = $_POST['direccion'];
                 $this->agente->codpostal = $_POST['codpostal'];
                 $this->agente->f_nacimiento = NULL;
                 if ($_POST['f_nacimiento'] != '') {
                     $this->agente->f_nacimiento = $_POST['f_nacimiento'];
                 }
                 $this->agente->f_alta = NULL;
                 if ($_POST['f_alta'] != '') {
                     $this->agente->f_alta = $_POST['f_alta'];
                 }
                 $this->agente->f_baja = NULL;
                 if ($_POST['f_baja'] != '') {
                     $this->agente->f_baja = $_POST['f_baja'];
                 }
                 $this->agente->seg_social = $_POST['seg_social'];
                 $this->agente->banco = $_POST['banco'];
                 $this->agente->porcomision = floatval($_POST['porcomision']);
                 if ($this->agente->save()) {
                     $this->new_message("Datos del empleado guardados correctamente.");
                 } else {
                     $this->new_error_msg("¡Imposible guardar los datos del empleado!");
                 }
             } else {
                 $this->new_error_msg('No tienes permiso para modificar estos datos.');
             }
         }
     } else {
         $this->new_error_msg("Empleado no encontrado.");
     }
 }
예제 #14
0
 public function __construct($c = FALSE)
 {
     parent::__construct('cajas');
     if (!isset(self::$agentes)) {
         self::$agentes = array();
     }
     if ($c) {
         $this->id = $this->intval($c['id']);
         $this->fs_id = $this->intval($c['fs_id']);
         $this->fecha_inicial = Date('d-m-Y H:i:s', strtotime($c['f_inicio']));
         $this->dinero_inicial = floatval($c['d_inicio']);
         if (is_null($c['f_fin'])) {
             $this->fecha_fin = NULL;
         } else {
             $this->fecha_fin = Date('d-m-Y H:i:s', strtotime($c['f_fin']));
         }
         $this->dinero_fin = floatval($c['d_fin']);
         $this->codagente = $c['codagente'];
         $this->tickets = intval($c['tickets']);
         $this->ip = NULL;
         if (isset($c['ip'])) {
             $this->ip = $c['ip'];
         }
         foreach (self::$agentes as $ag) {
             if ($ag->codagente == $this->codagente) {
                 $this->agente = $ag;
                 break;
             }
         }
         if (!isset($this->agente)) {
             $ag = new agente();
             $this->agente = $ag->get($this->codagente);
             self::$agentes[] = $this->agente;
         }
     } else {
         $this->id = NULL;
         $this->fs_id = FS_ID;
         $this->codagente = NULL;
         $this->fecha_inicial = Date('d-m-Y H:i:s');
         $this->dinero_inicial = 0;
         $this->fecha_fin = NULL;
         $this->dinero_fin = 0;
         $this->tickets = 0;
         $this->ip = NULL;
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $this->ip = $_SERVER['REMOTE_ADDR'];
         }
         $this->agente = NULL;
     }
 }
 protected function process()
 {
     $albaran = new albaran_proveedor();
     /// desactivamos la barra de botones
     $this->show_fs_toolbar = FALSE;
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_GET['codagente'])) {
             $this->template = 'extension/compras_albaranes_agente';
             $agente = new agente();
             $this->agente = $agente->get($_GET['codagente']);
             $this->resultados = $albaran->all_from_agente($_GET['codagente'], $this->offset);
         } else {
             if (isset($_GET['codproveedor'])) {
                 $this->template = 'extension/compras_albaranes_proveedor';
                 $proveedor = new proveedor();
                 $this->proveedor = $proveedor->get($_GET['codproveedor']);
                 $this->resultados = $albaran->all_from_proveedor($_GET['codproveedor'], $this->offset);
             } else {
                 if (isset($_GET['ref'])) {
                     $this->template = 'extension/compras_albaranes_articulo';
                     $articulo = new articulo();
                     $this->articulo = $articulo->get($_GET['ref']);
                     $linea = new linea_albaran_proveedor();
                     $this->resultados = $linea->all_from_articulo($_GET['ref'], $this->offset);
                 } else {
                     $this->share_extension();
                     if (isset($_POST['delete'])) {
                         $this->delete_albaran();
                     }
                     if ($this->query != '') {
                         $this->resultados = $albaran->search($this->query, $this->offset);
                     } else {
                         if (isset($_GET['ptefactura'])) {
                             $this->resultados = $albaran->all_ptefactura($this->offset);
                         } else {
                             $this->resultados = $albaran->all($this->offset);
                         }
                     }
                 }
             }
         }
     }
 }
예제 #16
0
 protected function private_core()
 {
     $pedido = new pedido_proveedor();
     $this->offset = 0;
     if (isset($_GET['offset'])) {
         $this->offset = intval($_GET['offset']);
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_GET['codagente'])) {
             $this->template = 'extension/compras_pedidos_agente';
             $agente = new agente();
             $this->agente = $agente->get($_GET['codagente']);
             $this->resultados = $pedido->all_from_agente($_GET['codagente'], $this->offset);
         } else {
             if (isset($_GET['codproveedor'])) {
                 $this->template = 'extension/compras_pedidos_proveedor';
                 $proveedor = new proveedor();
                 $this->proveedor = $proveedor->get($_GET['codproveedor']);
                 $this->resultados = $pedido->all_from_proveedor($_GET['codproveedor'], $this->offset);
             } else {
                 if (isset($_GET['ref'])) {
                     $this->template = 'extension/compras_pedidos_articulo';
                     $articulo = new articulo();
                     $this->articulo = $articulo->get($_GET['ref']);
                     $linea = new linea_pedido_proveedor();
                     $this->resultados = $linea->all_from_articulo($_GET['ref'], $this->offset);
                 } else {
                     $this->share_extension();
                     if (isset($_POST['delete'])) {
                         $this->delete_pedido();
                     }
                     if ($this->query) {
                         $this->resultados = $pedido->search($this->query, $this->offset);
                     } else {
                         if (isset($_GET['pendientes'])) {
                             $this->resultados = $pedido->all_ptealbaran($this->offset);
                         } else {
                             /// ejecutamos el proceso del cron para pedidos.
                             $pedido->cron_job();
                             $this->resultados = $pedido->all($this->offset);
                         }
                     }
                 }
             }
         }
     }
 }
예제 #17
0
 public function __construct($data = FALSE)
 {
     parent::__construct('cajas_general_mov', 'plugins/caja_general/');
     if (!isset(self::$agentes)) {
         self::$agentes = array();
     }
     if ($data) {
         $this->cajamov_id = $this->intval($data['cajamov_id']);
         $this->caja_id = $this->intval($data['caja_id']);
         $this->codagente = $data['codagente'];
         $this->f_apunte = Date('d-m-Y H:i:s', strtotime($data['f_apunte']));
         $this->apunte = floatval($data['apunte']);
         $this->concepto = $data['concepto'];
         $this->subtotal = floatval($data['subtotal']);
         $this->ip = NULL;
         if (isset($data['ip'])) {
             $this->ip = $data['ip'];
         }
         foreach (self::$agentes as $ag) {
             if ($ag->codagente == $this->codagente) {
                 $this->agente = $ag;
                 break;
             }
         }
         if (!isset($this->agente)) {
             $ag = new agente();
             $this->agente = $ag->get($this->codagente);
             self::$agentes[] = $this->agente;
         }
     } else {
         $this->cajamov_id = NULL;
         $this->caja_id = NULL;
         $this->codagente = NULL;
         $this->f_apunte = Date('d-m-Y H:i:s');
         $this->apunte = 0;
         $this->concepto = NULL;
         $this->subtotal = 0;
         $this->ip = NULL;
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $this->ip = $_SERVER['REMOTE_ADDR'];
         }
         $this->agente = NULL;
     }
 }
 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->modelonumero = new modelonumero();
     $this->ppage = $this->page->get('ventas_facturas');
     $this->ejercicio = new ejercicio();
     $this->agente = FALSE;
     $this->agentes = array();
     $this->cliente = FALSE;
     $this->divisa = new divisa();
     $factura = new factura_cliente();
     $this->factura = FALSE;
     $this->forma_pago = new forma_pago();
     $this->pais = new pais();
     $this->rectificada = FALSE;
     $this->rectificativa = FALSE;
     $this->serie = new serie();
     if (isset($_GET['id'])) {
         $this->factura = $factura->get($_GET['id']);
     }
     if ($this->factura) {
         $this->page->title = $this->factura->codigo;
         /// cargamos el agente
         $agente = new agente();
         if (!is_null($this->factura->codagente)) {
             $this->agente = $agente->get($this->factura->codagente);
         }
         $this->agentes = $agente->all();
         /// cargamos el cliente
         $cliente = new cliente();
         $this->cliente = $cliente->get($this->factura->codcliente);
         if ($this->factura->idfacturarect) {
             $this->rectificada = $factura->get($this->factura->idfacturarect);
         } else {
             $this->get_factura_rectificativa();
         }
     } else {
         $this->new_error_msg("¡Factura de cliente no encontrada!");
     }
 }
 protected function process()
 {
     $this->agente = new agente();
     $this->buttons[] = new fs_button_img('b_nuevo_agente', 'Nuevo');
     if (isset($_POST['sdnicif'])) {
         $age0 = new agente();
         $age0->codagente = $age0->get_new_codigo();
         $age0->nombre = $_POST['snombre'];
         $age0->apellidos = $_POST['sapellidos'];
         $age0->dnicif = $_POST['sdnicif'];
         $age0->telefono = $_POST['stelefono'];
         $age0->email = $_POST['semail'];
         if ($age0->save()) {
             $this->new_message("Empleado " . $age0->codagente . " guardado correctamente.");
             header('location: ' . $age0->url());
         } else {
             $this->new_error_msg("¡Imposible guardar el empleado!");
         }
     } else {
         if (isset($_GET['delete'])) {
             $age0 = $this->agente->get($_GET['delete']);
             if ($age0) {
                 if (FS_DEMO) {
                     $this->new_error_msg('En el modo <b>demo</b> no se pueden eliminar empleados. Otro usuario podría estar usándolo.');
                 } else {
                     if ($age0->delete()) {
                         $this->new_message("Empleado " . $age0->codagente . " eliminado correctamente.");
                     } else {
                         $this->new_error_msg("¡Imposible eliminar el empleado!");
                     }
                 }
             } else {
                 $this->new_error_msg("¡Empleado no encontrado!");
             }
         }
     }
 }
예제 #20
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();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #21
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_presupuestos');
     $this->agente = FALSE;
     $presupuesto = new presupuesto_cliente();
     $this->presupuesto = FALSE;
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->divisa = new divisa();
     $this->ejercicio = new ejercicio();
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->forma_pago = new forma_pago();
     $this->impuesto = new impuesto();
     $this->nuevo_presupuesto_url = FALSE;
     $this->pais = new pais();
     $this->serie = new serie();
     $this->setup_validez = 30;
     $this->configurar_validez();
     /**
      * Comprobamos si el usuario tiene acceso a nueva_venta,
      * necesario para poder añadir líneas.
      */
     if ($this->user->have_access_to('nueva_venta', FALSE)) {
         $nuevoprep = $this->page->get('nueva_venta');
         if ($nuevoprep) {
             $this->nuevo_presupuesto_url = $nuevoprep->url();
         }
     }
     if (isset($_POST['idpresupuesto'])) {
         $this->presupuesto = $presupuesto->get($_POST['idpresupuesto']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->presupuesto = $presupuesto->get($_GET['id']);
         }
     }
     if ($this->presupuesto) {
         $this->page->title = $this->presupuesto->codigo;
         /// cargamos el agente
         if (!is_null($this->presupuesto->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->presupuesto->codagente);
         }
         /// cargamos el cliente
         $this->cliente_s = $this->cliente->get($this->presupuesto->codcliente);
         /// comprobamos el presupuesto
         if ($this->presupuesto->full_test()) {
             if (isset($_REQUEST['status'])) {
                 $this->presupuesto->status = intval($_REQUEST['status']);
                 if ($this->presupuesto->status == 1 and is_null($this->presupuesto->idpedido)) {
                     $this->generar_pedido();
                 } else {
                     if ($this->presupuesto->save()) {
                         $this->new_message(ucfirst(FS_PRESUPUESTO) . " modificado correctamente.");
                     } else {
                         $this->new_error_msg("¡Imposible modificar el " . FS_PRESUPUESTO . "!");
                     }
                 }
             } else {
                 /// Comprobamos las líneas
                 $this->check_lineas();
             }
         }
     } else {
         $this->new_error_msg("¡" . ucfirst(FS_PRESUPUESTO) . " de cliente no encontrado!");
     }
 }
예제 #22
0
 protected function private_core()
 {
     $this->articulo_prov = new articulo_proveedor();
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->impuesto = new impuesto();
     $this->proveedor = new proveedor();
     $this->proveedor_s = FALSE;
     $this->results = array();
     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_proveedor'])) {
         $this->buscar_proveedor();
     } else {
         if (isset($_REQUEST['datosproveedor'])) {
             $this->datos_proveedor();
         } 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['proveedor'])) {
                             $this->proveedor_s = $this->proveedor->get($_POST['proveedor']);
                             if (isset($_POST['nuevo_proveedor'])) {
                                 if ($_POST['nuevo_proveedor'] != '') {
                                     $this->proveedor_s = FALSE;
                                     if ($_POST['nuevo_dni'] != '') {
                                         $this->proveedor_s = $this->proveedor->get_by_cifnif($_POST['nuevo_dni']);
                                         if ($this->proveedor_s) {
                                             $this->new_advice('Ya existe un proveedor con ese ' . FS_CIFNIF . '. Se ha seleccionado.');
                                         }
                                     }
                                     if (!$this->proveedor_s) {
                                         $this->proveedor_s = new proveedor();
                                         $this->proveedor_s->codproveedor = $this->proveedor_s->get_new_codigo();
                                         $this->proveedor_s->nombre = $this->proveedor_s->razonsocial = $_POST['nuevo_proveedor'];
                                         $this->proveedor_s->cifnif = $_POST['nuevo_dni'];
                                         $this->proveedor_s->acreedor = isset($_POST['acreedor']);
                                         $this->proveedor_s->save();
                                     }
                                 }
                             }
                             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'] == 'pedido') {
                                     if (class_exists('pedido_proveedor')) {
                                         $this->nuevo_pedido_proveedor();
                                     } else {
                                         $this->new_error_msg('Clase pedido_proveedor no encontrada.');
                                     }
                                 } else {
                                     if ($_POST['tipo'] == 'albaran') {
                                         $this->nuevo_albaran_proveedor();
                                     } else {
                                         if ($_POST['tipo'] == 'factura') {
                                             $this->nueva_factura_proveedor();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #23
0
 protected function private_core()
 {
     $this->ppage = $this->page->get('ventas_albaranes');
     $this->agente = FALSE;
     $albaran = new albaran_cliente();
     $this->albaran = FALSE;
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->divisa = new divisa();
     $this->ejercicio = new ejercicio();
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->forma_pago = new forma_pago();
     $this->impuesto = new impuesto();
     $this->nuevo_albaran_url = FALSE;
     $this->pais = new pais();
     $this->serie = new serie();
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     /**
      * Comprobamos si el usuario tiene acceso a nueva_venta,
      * necesario para poder añadir líneas.
      */
     if ($this->user->have_access_to('nueva_venta', FALSE)) {
         $nuevoalbp = $this->page->get('nueva_venta');
         if ($nuevoalbp) {
             $this->nuevo_albaran_url = $nuevoalbp->url();
         }
     }
     if (isset($_POST['idalbaran'])) {
         $this->albaran = $albaran->get($_POST['idalbaran']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->albaran = $albaran->get($_GET['id']);
         }
     }
     if ($this->albaran) {
         $this->page->title = $this->albaran->codigo;
         /// cargamos el agente
         if (!is_null($this->albaran->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->albaran->codagente);
         }
         /// cargamos el cliente
         $this->cliente_s = $this->cliente->get($this->albaran->codcliente);
         /// comprobamos el albarán
         $this->albaran->full_test();
         if (isset($_GET['facturar']) and isset($_GET['petid'])) {
             if ($this->duplicated_petition($_GET['petid'])) {
                 $this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
             } else {
                 if (!$this->albaran->ptefactura or !is_null($this->albaran->idfactura)) {
                     $this->new_error_msg('Parece que este ' . FS_ALBARAN . ' ya está facturado.');
                 } else {
                     $this->generar_factura();
                 }
             }
         } else {
             if (isset($_GET['forze_fecha'])) {
                 $this->forzar_fecha();
             }
         }
     } else {
         $this->new_error_msg("¡" . FS_ALBARAN . " de cliente no encontrado!");
     }
 }
예제 #24
0
 protected function process()
 {
     $this->ppage = $this->page->get('ventas_facturas');
     $this->ejercicio = new ejercicio();
     $this->agente = FALSE;
     $this->cliente = FALSE;
     $factura = new factura_cliente();
     $this->factura = FALSE;
     $this->forma_pago = new forma_pago();
     /// ¿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_button_pagada,
      * desactivamos el botón de pagada/sin pagar.
      */
     $this->mostrar_boton_pagada = TRUE;
     foreach ($this->extensions as $ext) {
         if ($ext->type == 'config' and $ext->text == 'no_button_pagada') {
             $this->mostrar_boton_pagada = FALSE;
             break;
         }
     }
     /**
      * ¿Modificamos la factura?
      */
     if (isset($_POST['idfactura'])) {
         $this->factura = $factura->get($_POST['idfactura']);
         $this->factura->observaciones = $_POST['observaciones'];
         $this->factura->numero2 = $_POST['numero2'];
         /// obtenemos el ejercicio para poder acotar la fecha
         $eje0 = $this->ejercicio->get($this->factura->codejercicio);
         if ($eje0) {
             $this->factura->fecha = $eje0->get_best_fecha($_POST['fecha'], TRUE);
             $this->factura->hora = $_POST['hora'];
         } else {
             $this->new_error_msg('No se encuentra el ejercicio asociado a la factura.');
         }
         /// ¿cambiamos la forma de pago?
         if ($this->factura->codpago != $_POST['forma_pago']) {
             $this->factura->codpago = $_POST['forma_pago'];
             $this->factura->vencimiento = $this->nuevo_vencimiento($this->factura->fecha, $this->factura->codpago);
         } else {
             $this->factura->vencimiento = $_POST['vencimiento'];
         }
         if ($this->factura->save()) {
             $asiento = $this->factura->get_asiento();
             if ($asiento) {
                 $asiento->fecha = $this->factura->fecha;
                 if (!$asiento->save()) {
                     $this->new_error_msg("Imposible modificar la fecha del asiento.");
                 }
             }
             $this->new_message("Factura modificada correctamente.");
             $this->new_change('Factura Cliente ' . $this->factura->codigo, $this->factura->url());
         } else {
             $this->new_error_msg("¡Imposible modificar la factura!");
         }
     } else {
         if (isset($_GET['id'])) {
             $this->factura = $factura->get($_GET['id']);
         }
     }
     if ($this->factura) {
         $this->page->title = $this->factura->codigo;
         /// cargamos el agente
         if (!is_null($this->factura->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->factura->codagente);
         }
         /// cargamos el cliente
         $cliente = new cliente();
         $this->cliente = $cliente->get($this->factura->codcliente);
         if (isset($_GET['gen_asiento']) and isset($_GET['petid'])) {
             if ($this->duplicated_petition($_GET['petid'])) {
                 $this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
             } else {
                 $this->generar_asiento();
             }
         } else {
             if (isset($_GET['updatedir'])) {
                 $this->actualizar_direccion();
             } else {
                 if (isset($_REQUEST['pagada'])) {
                     $this->factura->pagada = $_REQUEST['pagada'] == 'TRUE';
                     if ($this->factura->save()) {
                         $this->new_message("Factura modificada correctamente.");
                     } else {
                         $this->new_error_msg("¡Imposible modificar la factura!");
                     }
                 }
             }
         }
         /// comprobamos la factura
         $this->factura->full_test();
     } else {
         $this->new_error_msg("¡Factura de cliente no encontrada!");
     }
 }
예제 #25
0
 protected function private_core()
 {
     $this->ppage = $this->page->get('compras_albaranes');
     $this->agente = FALSE;
     $albaran = new albaran_proveedor();
     $this->albaran = FALSE;
     $this->divisa = new divisa();
     $this->ejercicio = new ejercicio();
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->forma_pago = new forma_pago();
     $this->impuesto = new impuesto();
     $this->proveedor = new proveedor();
     $this->proveedor_s = FALSE;
     $this->serie = new serie();
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     /// comprobamos si el usuario tiene acceso a nueva_compra
     $this->nuevo_albaran_url = FALSE;
     if ($this->user->have_access_to('nueva_compra', FALSE)) {
         $nuevoalbp = $this->page->get('nueva_compra');
         if ($nuevoalbp) {
             $this->nuevo_albaran_url = $nuevoalbp->url();
         }
     }
     if (isset($_POST['idalbaran'])) {
         $this->albaran = $albaran->get($_POST['idalbaran']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->albaran = $albaran->get($_GET['id']);
         }
     }
     if ($this->albaran) {
         $this->page->title = $this->albaran->codigo;
         /// cargamos el agente
         if (!is_null($this->albaran->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->albaran->codagente);
         }
         /// cargamos el proveedor
         $this->proveedor_s = $this->proveedor->get($this->albaran->codproveedor);
         /// comprobamos el albarán
         $this->albaran->full_test();
         if (isset($_POST['facturar']) and isset($_POST['petid']) and $this->albaran->ptefactura) {
             if ($this->duplicated_petition($_POST['petid'])) {
                 $this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
             } else {
                 $this->generar_factura();
             }
         }
     } else {
         $this->new_error_msg("¡" . FS_ALBARAN . " de proveedor no encontrado!");
     }
 }
 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_facturas');
     $this->ejercicio = new ejercicio();
     $this->agente = FALSE;
     $this->agentes = array();
     $this->cliente = FALSE;
     $this->divisa = new divisa();
     $this->factura = FALSE;
     $this->forma_pago = new forma_pago();
     $this->pais = new pais();
     $this->rectificada = FALSE;
     $this->rectificativa = FALSE;
     $this->serie = new serie();
     /**
      * Si hay alguna extensión de tipo config y texto no_button_pagada,
      * desactivamos el botón de pagada/sin pagar.
      */
     $this->mostrar_boton_pagada = TRUE;
     foreach ($this->extensions as $ext) {
         if ($ext->type == 'config' and $ext->text == 'no_button_pagada') {
             $this->mostrar_boton_pagada = FALSE;
             break;
         }
     }
     /**
      * ¿Modificamos la factura?
      */
     $factura = new factura_cliente();
     if (isset($_POST['idfactura'])) {
         $this->factura = $factura->get($_POST['idfactura']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->factura = $factura->get($_GET['id']);
         }
     }
     if ($this->factura) {
         $this->page->title = $this->factura->codigo;
         /// cargamos el agente
         $agente = new agente();
         if (!is_null($this->factura->codagente)) {
             $this->agente = $agente->get($this->factura->codagente);
         }
         $this->agentes = $agente->all();
         /// cargamos el cliente
         $cliente = new cliente();
         $this->cliente = $cliente->get($this->factura->codcliente);
         if (isset($_GET['gen_asiento']) and isset($_GET['petid'])) {
             if ($this->duplicated_petition($_GET['petid'])) {
                 $this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
             } else {
                 $this->generar_asiento($this->factura);
             }
         } else {
             if (isset($_GET['updatedir'])) {
                 $this->actualizar_direccion();
             } else {
                 if (isset($_REQUEST['pagada'])) {
                     $this->pagar($_REQUEST['pagada'] == 'TRUE');
                 } else {
                     if (isset($_POST['anular'])) {
                         $this->anular_factura();
                     }
                 }
             }
         }
         if ($this->factura->idfacturarect) {
             $this->rectificada = $factura->get($this->factura->idfacturarect);
         } else {
             $this->get_factura_rectificativa();
         }
         /// comprobamos la factura
         $this->factura->full_test();
     } else {
         $this->new_error_msg("¡Factura de cliente no encontrada!");
     }
 }
예제 #27
0
 /**
  * Devuelve TRUE si el usuario realmente tiene acceso a esta página
  * @return type
  */
 private function log_in()
 {
     $ips = array();
     if ($this->ip_baneada($ips)) {
         $this->banear_ip($ips);
         $this->new_error_msg('Tu IP ha sido baneada. Tendrás que esperar 10 minutos antes de volver a intentar entrar.', 'login', TRUE);
     } else {
         if (isset($_POST['user']) and isset($_POST['password'])) {
             if (FS_DEMO) {
                 $user = $this->user->get($_POST['user']);
                 if (!$user) {
                     $user = new fs_user();
                     $user->nick = $_POST['user'];
                     $user->set_password('demo');
                     /// creamos un agente para asociarlo
                     $agente = new agente();
                     $agente->codagente = $agente->get_new_codigo();
                     $agente->nombre = $_POST['user'];
                     $agente->apellidos = 'Demo';
                     if ($agente->save()) {
                         $user->codagente = $agente->codagente;
                     }
                 }
                 $user->new_logkey();
                 if ($user->save()) {
                     setcookie('user', $user->nick, time() + FS_COOKIES_EXPIRE);
                     setcookie('logkey', $user->log_key, time() + FS_COOKIES_EXPIRE);
                     $this->user = $user;
                     $this->load_menu();
                 }
             } else {
                 $user = $this->user->get($_POST['user']);
                 $password = strtolower($_POST['password']);
                 if ($user) {
                     if ($user->password == sha1($password)) {
                         $user->new_logkey();
                         if (!$user->admin and !$this->ip_in_whitelist($user->last_ip)) {
                             $this->new_error_msg('No puedes acceder desde esta IP.', 'login', TRUE);
                         } else {
                             if ($user->save()) {
                                 setcookie('user', $user->nick, time() + FS_COOKIES_EXPIRE);
                                 setcookie('logkey', $user->log_key, time() + FS_COOKIES_EXPIRE);
                                 $this->user = $user;
                                 $this->load_menu();
                                 /// añadimos el mensaje al log
                                 $fslog = new fs_log();
                                 $fslog->usuario = $user->nick;
                                 $fslog->tipo = 'login';
                                 $fslog->detalle = 'Login correcto.';
                                 $fslog->ip = $user->last_ip;
                                 $fslog->save();
                             } else {
                                 $this->new_error_msg('Imposible guardar los datos de usuario.');
                                 $this->cache->clean();
                             }
                         }
                     } else {
                         $this->new_error_msg('¡Contraseña incorrecta!');
                         $this->banear_ip($ips);
                     }
                 } else {
                     $this->new_error_msg('El usuario ' . $_POST['user'] . ' no existe!');
                     $this->user->clean_cache(TRUE);
                     $this->cache->clean();
                 }
             }
         } else {
             if (isset($_COOKIE['user']) and isset($_COOKIE['logkey'])) {
                 $user = $this->user->get($_COOKIE['user']);
                 if ($user) {
                     if ($user->log_key == $_COOKIE['logkey']) {
                         $user->logged_on = TRUE;
                         $user->update_login();
                         $this->user = $user;
                         $this->load_menu();
                     } else {
                         if (!is_null($user->log_key)) {
                             $this->new_message('¡Cookie no válida! Alguien ha accedido a esta cuenta desde otro PC con IP: ' . $user->last_ip . ". Si has sido tú, ignora este mensaje.");
                             $this->log_out();
                         }
                     }
                 } else {
                     $this->new_error_msg('¡El usuario ' . $_COOKIE['user'] . ' no existe!');
                     $this->log_out();
                     $this->user->clean_cache(TRUE);
                     $this->cache->clean();
                 }
             }
         }
     }
     return $this->user->logged_on;
 }
 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('compras_pedidos');
     $this->agente = FALSE;
     $this->almacen = new almacen();
     $this->divisa = new divisa();
     $this->ejercicio = new ejercicio();
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->forma_pago = new forma_pago();
     $this->impuesto = new impuesto();
     $this->nuevo_pedido_url = FALSE;
     $pedido = new pedido_proveedor();
     $this->pedido = FALSE;
     $this->proveedor = new proveedor();
     $this->proveedor_s = FALSE;
     $this->serie = new serie();
     /**
      * Comprobamos si el usuario tiene acceso a nueva_compra,
      * necesario para poder añadir líneas.
      */
     if ($this->user->have_access_to('nueva_compra', FALSE)) {
         $nuevopedp = $this->page->get('nueva_compra');
         if ($nuevopedp) {
             $this->nuevo_pedido_url = $nuevopedp->url();
         }
     }
     /**
      * Primero ejecutamos la función del cron para desbloquear los
      * pedidos de albaranes eliminados y devolverlos al estado original.
      */
     $pedido->cron_job();
     if (isset($_POST['idpedido'])) {
         $this->pedido = $pedido->get($_POST['idpedido']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->pedido = $pedido->get($_GET['id']);
         }
     }
     if ($this->pedido) {
         $this->page->title = $this->pedido->codigo;
         /// cargamos el agente
         if (!is_null($this->pedido->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->pedido->codagente);
         }
         /// cargamos el proveedor
         $this->proveedor_s = $this->proveedor->get($this->pedido->codproveedor);
         /// comprobamos el pedido
         $this->pedido->full_test();
         if (isset($_POST['aprobar']) and isset($_POST['petid']) and is_null($this->pedido->idalbaran)) {
             if ($this->duplicated_petition($_POST['petid'])) {
                 $this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
             } else {
                 $this->generar_albaran();
             }
         } else {
             if (isset($_GET['desbloquear'])) {
                 $this->pedido->editable = TRUE;
                 $this->pedido->save();
             }
         }
     } else {
         $this->new_error_msg("¡" . ucfirst(FS_PEDIDO) . " de proveedor no encontrado!");
     }
 }
예제 #29
0
 protected function trata_albaran($pedidoRaw)
 {
     $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
     $respuesta = "Intentando albaran...";
     $p = json_decode($pedidoRaw->pedido, TRUE);
     if (isset($p['cliente'])) {
         $this->cliente_s = $this->cliente->get($p['cliente']);
         if ($this->cliente_s) {
             foreach ($this->cliente_s->get_direcciones() as $dir) {
                 if ($dir->domfacturacion) {
                     $this->direccion = $dir;
                     break;
                 }
             }
         }
         if (isset($p['codagente'])) {
             $agente = new agente();
             $this->agente = $agente->get($p['codagente']);
         }
         $this->almacen = new almacen();
         $this->serie = new serie();
         $this->forma_pago = new forma_pago();
         $this->divisa = new divisa();
         $p["numero2"] = $pedidoRaw->numero2;
         $respuesta = $this->nuevo_albaran_cliente($p);
         echo "NUMERO2 " . $p["numero2"];
     }
     return $respuesta;
 }
예제 #30
0
 protected function process()
 {
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->direccion = FALSE;
     $this->familia = new familia();
     $this->impuesto = new impuesto();
     $this->results = array();
     $this->grupo = new grupo_clientes();
     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']);
                             if (isset($_POST['nuevo_cliente'])) {
                                 if ($_POST['nuevo_cliente'] != '') {
                                     $this->cliente_s = FALSE;
                                     if ($_POST['nuevo_dni'] != '') {
                                         $this->cliente_s = $this->cliente->get_by_cifnif($_POST['nuevo_dni']);
                                         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_dni'];
                                         if ($_POST['codgrupo'] != '') {
                                             $this->cliente_s->codgrupo = $_POST['codgrupo'];
                                         }
                                         $this->cliente_s->save();
                                     }
                                 }
                             }
                             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();
                             $this->pais = new pais();
                             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();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }