protected function private_core()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $this->share_extensions();
     $this->modelonumero = new modelonumero();
     $this->ppage = $this->page->get('ventas_facturas');
     $this->ejercicio = new ejercicio();
     $this->agente = FALSE;
     $this->agentes = array();
     $this->cliente = FALSE;
     $this->divisa = new divisa();
     $factura = new factura_cliente();
     $this->factura = FALSE;
     $this->forma_pago = new forma_pago();
     $this->pais = new pais();
     $this->rectificada = FALSE;
     $this->rectificativa = FALSE;
     $this->serie = new serie();
     if (isset($_GET['id'])) {
         $this->factura = $factura->get($_GET['id']);
     }
     if ($this->factura) {
         $this->page->title = $this->factura->codigo;
         /// cargamos el agente
         $agente = new agente();
         if (!is_null($this->factura->codagente)) {
             $this->agente = $agente->get($this->factura->codagente);
         }
         $this->agentes = $agente->all();
         /// cargamos el cliente
         $cliente = new cliente();
         $this->cliente = $cliente->get($this->factura->codcliente);
         if ($this->factura->idfacturarect) {
             $this->rectificada = $factura->get($this->factura->idfacturarect);
         } else {
             $this->get_factura_rectificativa();
         }
     } else {
         $this->new_error_msg("¡Factura de cliente no encontrada!");
     }
 }
 protected function 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!");
     }
 }
 private function resultados_articulo($ref, $desde, $hasta, $tabla)
 {
     $rlist = array();
     $agente = new agente();
     $agentes = $agente->all();
     $nombre = 'nombre';
     if ($tabla == 'facturascli') {
         $nombre = 'nombrecliente';
     }
     $data = $this->db->select("SELECT f.idfactura,fecha,codigo," . $nombre . ",codagente,cantidad,pvpunitario,dtopor,pvptotal,iva " . "FROM " . $tabla . " f, lineas" . $tabla . " l WHERE f.idfactura = l.idfactura " . "AND l.referencia = " . $this->empresa->var2str($ref) . " AND fecha >= " . $this->empresa->var2str($desde) . " AND fecha <= " . $this->empresa->var2str($hasta) . " ORDER BY fecha DESC;");
     if ($data) {
         foreach ($data as $d) {
             $linea = array('idfactura' => intval($d['idfactura']), 'url' => '', 'fecha' => date('d-m-Y', strtotime($d['fecha'])), 'codigo' => $d['codigo'], 'nombre' => $d[$nombre], 'agente' => $d['codagente'], 'cantidad' => floatval($d['cantidad']), 'pvpunitario' => floatval($d['pvpunitario']), 'dtopor' => floatval($d['dtopor']), 'pvptotal' => floatval($d['pvptotal']), 'total' => floatval($d['pvptotal']) * (100 + floatval($d['iva'])) / 100);
             if ($tabla == 'facturascli') {
                 $linea['url'] = 'index.php?page=ventas_factura&id=' . $linea['idfactura'];
             } else {
                 if ($tabla == 'facturasprov') {
                     $linea['url'] = 'index.php?page=compras_factura&id=' . $linea['idfactura'];
                 }
             }
             /// rellenamos el nombre del agente
             if (is_null($linea['agente'])) {
                 $linea['agente'] = '-';
             } else {
                 foreach ($agentes as $ag) {
                     if ($ag->codagente == $linea['agente']) {
                         $linea['agente'] = $ag->get_fullname();
                         break;
                     }
                 }
             }
             $rlist[] = $linea;
         }
     }
     return $rlist;
 }
Example #4
0
 public function listado_agentes()
 {
     $age0 = new agente();
     return $age0->all();
 }