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.");
     }
 }
 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();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 5
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);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 7
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!");
     }
 }
Esempio n. 9
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;
     }
 }
 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);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 11
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.");
     }
 }
Esempio n. 12
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);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 14
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);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 15
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!");
     }
 }
Esempio n. 17
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();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 18
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!");
     }
 }
Esempio n. 19
0
 protected function private_core()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $this->ppage = $this->page->get('ventas_servicios');
     $this->agente = FALSE;
     $this->estado = new estados_servicios();
     $servicio = new servicio_cliente();
     $this->servicio = FALSE;
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->divisa = new divisa();
     $this->ejercicio = new ejercicio();
     $this->familia = new familia();
     $this->forma_pago = new forma_pago();
     $this->impuesto = new impuesto();
     $this->nuevo_servicio_url = FALSE;
     $this->nueva_marca_url = FALSE;
     $this->nuevo_modelo_url = FALSE;
     $this->nuevo_tipo_url = FALSE;
     $this->pais = new pais();
     $this->serie = new serie();
     $this->fabricante = new fabricante();
     $this->marca = new marca();
     $this->modelo = new modelo();
     $this->tipo = new tipo();
     //cargamos configuración de servicios
     $fsvar = new fs_var();
     $this->servicios_setup = $fsvar->array_get(array('servicios_diasfin' => 10, 'servicios_material' => 0, 'servicios_mostrar_material' => 0, 'servicios_material_estado' => 0, 'servicios_mostrar_marca' => 0, 'servicios_marca' => 0, 'servicios_mostrar_modelo' => 0, 'servicios_modelo' => 0, 'servicios_mostrar_tipo' => 0, 'servicios_tipo' => 0, 'servicios_mostrar_material_estado' => 0, 'servicios_accesorios' => 0, 'servicios_mostrar_accesorios' => 0, 'servicios_descripcion' => 0, 'servicios_mostrar_descripcion' => 0, 'servicios_solucion' => 0, 'servicios_mostrar_solucion' => 0, 'servicios_fechafin' => 0, 'servicios_mostrar_fechafin' => 0, 'servicios_fechainicio' => 0, 'servicios_mostrar_fechainicio' => 0, 'servicios_mostrar_garantia' => 0, 'servicios_garantia' => 0), FALSE);
     /*Cargamos traduccion*/
     $this->st = $fsvar->array_get(array('st_servicio' => "Servicio", 'st_servicios' => "Servicios", 'st_material' => "Material", 'st_material_estado' => "Estado del material entregado", 'st_accesorios' => "Accesorios que entrega", 'st_descripcion' => "Descripción de la averia", 'st_solucion' => "Solución", 'st_marca' => "Marca del aparato", 'st_modelo' => "Modelo del aparato", 'st_tipo' => "Tipo de aparato"), FALSE);
     /**
      * Comprobamos si el usuario tiene acceso a nueva_venta,
      * necesario para poder añadir líneas.
      */
     if (isset($_GET['delete_detalle'])) {
         $det0 = new detalle_servicio();
         $detalle = $det0->get($_GET['delete_detalle']);
         if ($detalle) {
             if ($detalle->delete()) {
                 $this->new_message('Detalle eliminado correctamente.');
             } else {
                 $this->new_error_msg('Error al eliminar el detalle.');
             }
         } else {
             $this->new_error_msg('Detalle no encontrado.');
         }
     }
     if ($this->user->have_access_to('nueva_venta', FALSE)) {
         $nuevopedp = $this->page->get('nueva_venta');
         if ($nuevopedp) {
             $this->nuevo_servicio_url = $nuevopedp->url();
         }
         $this->nueva_marca_url = $this->marca->url();
         $this->nuevo_modelo_url = $this->modelo->url();
         $this->nuevo_tipo_url = $this->tipo->url();
     }
     if (isset($_POST['idservicio'])) {
         $this->servicio = $servicio->get($_POST['idservicio']);
         $this->modificar();
     } else {
         if (isset($_GET['id'])) {
             $this->servicio = $servicio->get($_GET['id']);
         }
     }
     if ($this->servicio) {
         $this->page->title = $this->servicio->codigo;
         if (isset($_POST['detalle'])) {
             $this->agrega_detalle();
         }
         /// cargamos el agente
         if (!is_null($this->servicio->codagente)) {
             $agente = new agente();
             $this->agente = $agente->get($this->servicio->codagente);
         }
         /// cargamos el cliente
         $this->cliente_s = $this->cliente->get($this->servicio->codcliente);
         $this->marca_s = $this->marca->get($this->servicio->codmarca);
         $this->modelo_s = $this->modelo->get($this->servicio->codmodelo);
         $this->tipo_s = $this->tipo->get($this->servicio->codtipo);
     } else {
         $this->new_error_msg("¡" . ucfirst(FS_SERVICIO) . " de cliente no encontrado!");
     }
 }
Esempio n. 20
0
 protected function private_core()
 {
     $this->agente = FALSE;
     $this->almacen = new almacen();
     $this->cliente = new cliente();
     $this->cliente_s = FALSE;
     $this->descripcion = NULL;
     $this->direccion = FALSE;
     $this->divisa = new divisa();
     $this->estado = new estado_servicio();
     $this->fabricante = new fabricante();
     $this->familia = new familia();
     $this->forma_pago = new forma_pago();
     $this->grupo = new grupo_clientes();
     $this->impuesto = new impuesto();
     $this->pais = new pais();
     $this->prioridad = 3;
     $this->results = array();
     $this->serie = new serie();
     $this->servicio = new servicio_cliente();
     $this->solucion = NULL;
     /// cargamos la configuración de servicios
     $fsvar = new fs_var();
     $this->setup = $fsvar->array_get(array('servicios_diasfin' => 10, 'servicios_material' => 0, 'servicios_mostrar_material' => 0, 'servicios_material_estado' => 0, 'servicios_mostrar_material_estado' => 0, 'servicios_accesorios' => 0, 'servicios_mostrar_accesorios' => 0, 'servicios_descripcion' => 0, 'servicios_mostrar_descripcion' => 0, 'servicios_solucion' => 0, 'servicios_mostrar_solucion' => 0, 'servicios_fechafin' => 0, 'servicios_mostrar_fechafin' => 0, 'servicios_fechainicio' => 0, 'servicios_mostrar_fechainicio' => 0, 'servicios_mostrar_garantia' => 0, 'servicios_garantia' => 0, 'cal_inicio' => "09:00", 'cal_fin' => "20:00", 'cal_intervalo' => "30", 'st_servicio' => "Servicio", 'st_servicios' => "Servicios", 'st_material' => "Material", 'st_material_estado' => "Estado del material entregado", 'st_accesorios' => "Accesorios que entrega", 'st_descripcion' => "Descripción de la averia", 'st_solucion' => "Solución", 'st_fechainicio' => "Fecha de Inicio", 'st_fechafin' => "Fecha de finalización", 'st_garantia' => "Garantía", '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['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->tipoidfiscal = $_POST['nuevo_tipoidfiscal'];
                                         $this->cliente_s->cifnif = $_POST['nuevo_cifnif'];
                                         $this->cliente_s->personafisica = isset($_POST['personafisica']);
                                         if (isset($_POST['nuevo_grupo'])) {
                                             if ($_POST['nuevo_grupo'] != '') {
                                                 $this->cliente_s->codgrupo = $_POST['nuevo_grupo'];
                                             }
                                         }
                                         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()) {
                                             if ($this->empresa->contintegrada) {
                                                 /// forzamos crear la subcuenta
                                                 $this->cliente_s->get_subcuenta($this->empresa->codejercicio);
                                             }
                                             $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;
                                             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();
                             }
                             if (isset($_POST['numlineas'])) {
                                 $this->nuevo_servicio_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();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 protected function private_core()
 {
     //
     //	  $this->ppage_r = $this->page->get('compras_albaranes');
     if (isset($_REQUEST['autorizar_factura'])) {
         $this->autorizar_factura = $_REQUEST['autorizar_factura'];
     }
     if ($this->autorizar_factura == 1) {
         $this->ppage = $this->page->get('compras_facturas');
     } else {
         $this->ppage = $this->page->get('compras_albaranes');
     }
     $this->agente = FALSE;
     $this->empresa = new empresa();
     $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();
     $factura = new factura_proveedor();
     $this->verif_factura = $factura->all_sin_anular();
     $this->subcuentas = new subcuenta();
     $this->view_subcuen = $this->subcuentas->subcoenta_compras($this->empresa->codejercicio);
     $this->view_subcuen_dev = $this->subcuentas->subcoenta_compras_credito($this->empresa->codejercicio);
     $this->list_subcuen = $this->subcuentas->subcoenta_compras($this->empresa->codejercicio);
     /// ¿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'])) {
         if ($_POST['facturar'] == 'TRUE') {
             $this->albaran = $albaran->get($_POST['idalbaran']);
             $this->modificar();
             $this->generar_factura();
             header('Location: ' . $this->url_retorno());
         } else {
             $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);
         $this->cai = $this->proveedor_s->cai;
         $this->caivence = $this->proveedor_s->caivence;
         /// comprobamos el albarán
         $this->albaran->full_test();
         if (isset($_POST['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 ($this->autorizar_factura == 1) {
                 header('Location: ' . $this->url_retorno());
             } else {
                 header('Location: ' . $this->url_albaran());
             }
         } else {
             if (isset($_GET['forze_fecha'])) {
                 $this->forzar_fecha();
             }
         }
     } else {
         $this->new_error_msg("¡" . FS_ALBARAN . " de proveedor no encontrado!");
     }
 }
Esempio n. 22
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!");
     }
 }
Esempio n. 23
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!");
     }
 }
Esempio n. 24
0
 /**
  * Devuelve el agente/empleado asociado
  * @return boolean|agente
  */
 public function get_agente()
 {
     if (isset($this->agente)) {
         return $this->agente;
     } else {
         if (is_null($this->codagente)) {
             return FALSE;
         } else {
             $agente = new agente();
             $agente0 = $agente->get($this->codagente);
             if ($agente0) {
                 $this->agente = $agente0;
                 return $this->agente;
             } else {
                 $this->codagente = NULL;
                 $this->save();
                 return FALSE;
             }
         }
     }
 }
 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!");
     }
 }
 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!");
     }
 }
Esempio n. 27
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;
 }
Esempio n. 28
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();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 29
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();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 30
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!");
     }
 }