protected function process()
 {
     $this->show_fs_toolbar = FALSE;
     $this->cliente = new cliente();
     $this->ejercicio = new ejercicio();
     $this->proveedor = new proveedor();
     $this->regularizacion = new regularizacion_iva();
     $this->opciones = array('ventas' => TRUE, 'compras' => TRUE, 'fecha' => 'hoy');
     if (isset($_REQUEST['fecha'])) {
         $this->opciones['fecha'] = $_REQUEST['fecha'];
         $this->total = 0;
         if (isset($_REQUEST['ventas'])) {
             $albaran_cli = new albaran_cliente();
             foreach ($albaran_cli->all_ptefactura(0, 'ASC') as $alb) {
                 $this->generar_factura_cliente(array($alb));
             }
             $this->new_message($this->total . ' ' . FS_ALBARANES . ' de cliente facturados.');
         } else {
             $this->opciones['ventas'] = FALSE;
         }
         $this->total = 0;
         if (isset($_REQUEST['compras'])) {
             $albaran_pro = new albaran_proveedor();
             foreach ($albaran_pro->all_ptefactura(0, 'ASC') as $alb) {
                 $this->generar_factura_proveedor(array($alb));
             }
             $this->new_message($this->total . ' ' . FS_ALBARANES . ' de proveedor facturados.');
         } else {
             $this->opciones['compras'] = FALSE;
         }
     }
 }
Ejemplo n.º 2
0
 protected function process()
 {
     $albaran = new albaran_cliente();
     $this->offset = 0;
     if (isset($_REQUEST['offset'])) {
         $this->offset = intval($_REQUEST['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->pendientes = FALSE;
                         $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);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 protected function private_core()
 {
     $this->cliente = new cliente();
     $this->ejercicio = new ejercicio();
     $this->forma_pago = new forma_pago();
     $this->proveedor = new proveedor();
     $this->regularizacion = new regularizacion_iva();
     $serie = new serie();
     $this->series = $serie->all();
     $this->opciones = array('ventas' => TRUE, 'compras' => TRUE, 'fecha' => 'hoy');
     $this->codserie = FALSE;
     if (isset($_REQUEST['codserie'])) {
         $this->codserie = $_REQUEST['codserie'];
     }
     if (isset($_REQUEST['fecha'])) {
         $this->opciones['fecha'] = $_REQUEST['fecha'];
         $this->total = 0;
         if (isset($_REQUEST['ventas'])) {
             $albaran_cli = new albaran_cliente();
             foreach ($albaran_cli->all_ptefactura(0, 'fecha ASC', $this->codserie) as $alb) {
                 $this->generar_factura_cliente(array($alb));
             }
             $this->new_message($this->total . ' ' . FS_ALBARANES . ' de cliente facturados.');
         } else {
             $this->opciones['ventas'] = FALSE;
         }
         $this->total = 0;
         if (isset($_REQUEST['compras'])) {
             $albaran_pro = new albaran_proveedor();
             foreach ($albaran_pro->all_ptefactura(0, 'fecha ASC', $this->codserie) as $alb) {
                 $this->generar_factura_proveedor(array($alb));
             }
             $this->new_message($this->total . ' ' . FS_ALBARANES . ' de proveedor facturados.');
         } else {
             $this->opciones['compras'] = FALSE;
         }
     }
 }
Ejemplo n.º 4
0
 protected function private_core()
 {
     $albaran = new albaran_cliente();
     $this->agente = new agente();
     $this->serie = new serie();
     $this->mostrar = 'todo';
     if (isset($_GET['mostrar'])) {
         $this->mostrar = $_GET['mostrar'];
         setcookie('ventas_alb_mostrar', $this->mostrar, time() + FS_COOKIES_EXPIRE);
     } else {
         if (isset($_COOKIE['ventas_alb_mostrar'])) {
             $this->mostrar = $_COOKIE['ventas_alb_mostrar'];
         }
     }
     $this->offset = 0;
     if (isset($_REQUEST['offset'])) {
         $this->offset = intval($_REQUEST['offset']);
     }
     $this->order = 'fecha DESC';
     if (isset($_GET['order'])) {
         if ($_GET['order'] == 'fecha_desc') {
             $this->order = 'fecha DESC';
         } else {
             if ($_GET['order'] == 'fecha_asc') {
                 $this->order = 'fecha ASC';
             } else {
                 if ($_GET['order'] == 'codigo_desc') {
                     $this->order = 'codigo DESC';
                 } else {
                     if ($_GET['order'] == 'codigo_asc') {
                         $this->order = 'codigo ASC';
                     }
                 }
             }
         }
         setcookie('ventas_alb_order', $this->order, time() + FS_COOKIES_EXPIRE);
     } else {
         if (isset($_COOKIE['ventas_alb_order'])) {
             $this->order = $_COOKIE['ventas_alb_order'];
         }
     }
     if (isset($_POST['buscar_lineas'])) {
         $this->buscar_lineas();
     } else {
         if (isset($_REQUEST['buscar_cliente'])) {
             $this->buscar_cliente();
         } 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();
                 $this->cliente = FALSE;
                 $this->codagente = '';
                 $this->codserie = '';
                 $this->desde = '';
                 $this->hasta = '';
                 $this->num_resultados = '';
                 $this->total_resultados = '';
                 $this->total_resultados_txt = '';
                 if (isset($_POST['delete'])) {
                     $this->delete_albaran();
                 } else {
                     if (!isset($_GET['mostrar']) and (isset($_REQUEST['codagente']) or isset($_REQUEST['codcliente']))) {
                         /**
                          * si obtenermos un codagente o un codcliente pasamos direcatemente
                          * a la pestaña de búsqueda, a menos que tengamos un mostrar, que
                          * entonces nos indica donde tenemos que estar.
                          */
                         $this->mostrar = 'buscar';
                     }
                     if (isset($_REQUEST['codcliente'])) {
                         if ($_REQUEST['codcliente'] != '') {
                             $cli0 = new cliente();
                             $this->cliente = $cli0->get($_REQUEST['codcliente']);
                         }
                     }
                     if (isset($_REQUEST['codagente'])) {
                         $this->codagente = $_REQUEST['codagente'];
                     }
                     if (isset($_REQUEST['codserie'])) {
                         $this->codserie = $_REQUEST['codserie'];
                         $this->desde = $_REQUEST['desde'];
                         $this->hasta = $_REQUEST['hasta'];
                     }
                 }
                 /// añadimos segundo nivel de ordenación
                 $order2 = '';
                 if ($this->order == 'fecha DESC') {
                     $order2 = ', codigo DESC';
                 } else {
                     if ($this->order == 'fecha ASC') {
                         $order2 = ', codigo ASC';
                     }
                 }
                 if ($this->mostrar == 'pendientes') {
                     $this->resultados = $albaran->all_ptefactura($this->offset, $this->order . $order2);
                     if ($this->offset == 0) {
                         $this->total_resultados = 0;
                         $this->total_resultados_txt = 'Suma total de esta página:';
                         foreach ($this->resultados as $alb) {
                             $this->total_resultados += $alb->total;
                         }
                     }
                 } else {
                     if ($this->mostrar == 'buscar') {
                         $this->buscar($order2);
                     } else {
                         $this->resultados = $albaran->all($this->offset, $this->order . $order2);
                     }
                 }
             }
         }
     }
 }