コード例 #1
0
 protected function private_core()
 {
     $this->idioma = new idioma_fac_det();
     if (isset($_GET['delete_idioma'])) {
         $idioma = $this->idioma->get($_GET['delete_idioma']);
         if ($idioma) {
             if ($idioma->delete()) {
                 $this->new_message('Estado eliminado correctamente.');
             } else {
                 $this->new_error_msg('Error al eliminar el idioma.');
             }
         } else {
             $this->new_error_msg('Estado no encontrado.');
         }
     } else {
         if (isset($_POST['idioma'])) {
             $nuevo_idioma = FALSE;
             //ESTA VARIABLE ES UN FLAG PARA CONTROLAR SI AÑADIMOS UN NUEVO IDIOMA O EDITAMOS
             $idioma = $this->idioma->get($_POST['abreviatura']);
             if (!$idioma) {
                 $idioma = new idioma_fac_det();
                 $nuevo_idioma = TRUE;
             }
             $idioma->abreviatura = $_POST['abreviatura'];
             $idioma->idioma = $_POST['idioma'];
             $idioma->activo = $_POST['activo'];
             if ($idioma->save()) {
                 if ($nuevo_idioma) {
                     $this->new_message('Idioma agregado correctamente.');
                     $this->template = 'traduccion_factura_detallada';
                 } else {
                     $this->new_message('Idioma iditado correctamente.');
                 }
             } else {
                 $this->new_error_msg('Error al guardar el idioma.');
             }
         } elseif ($_GET['abreviatura']) {
             $this->idioma = $this->idioma->get($_GET['abreviatura']);
             $this->traduccion = new traduccion_fac_det();
             $this->traduccion = $this->traduccion->get($_GET['abreviatura']);
             if ($this->idioma) {
                 if (!$this->traduccion) {
                     //si no existen los campos vuelvo a llamar al constructor para formatear los valores
                     //y asi me ahorro que me saque errores
                     $this->traduccion = new traduccion_fac_det();
                 }
                 if ($_POST['factura']) {
                     $this->traduccion->abreviatura = $_GET['abreviatura'];
                     $this->traduccion->factura = $_POST['factura'];
                     $this->traduccion->pagina = $_POST['pagina'];
                     $this->traduccion->fecha = $_POST['fecha'];
                     $this->traduccion->ncliente = $_POST['ncliente'];
                     $this->traduccion->formadepago = $_POST['formadepago'];
                     $this->traduccion->albaranabre = $_POST['albaranabre'];
                     $this->traduccion->descripcion = $_POST['descripcion'];
                     $this->traduccion->cantidadabre = $_POST['cantidadabre'];
                     $this->traduccion->precio = $_POST['precio'];
                     $this->traduccion->impuesto = $_POST['impuesto'];
                     $this->traduccion->importe = $_POST['importe'];
                     $this->traduccion->neto = $_POST['neto'];
                     $this->traduccion->recequiv = $_POST['recequiv'];
                     $this->traduccion->irpf = $_POST['irpf'];
                     $this->traduccion->total = $_POST['total'];
                     $this->traduccion->telefono = $_POST['telefono'];
                     $this->traduccion->fax = $_POST['fax'];
                     $this->traduccion->descuentoabre = $_POST['descuentoabre'];
                     if ($this->traduccion->save()) {
                         $this->new_message('Traduccion guardada correctamente');
                     }
                 }
                 $this->template = 'traduccion_factura_detallada';
             }
         }
     }
 }
コード例 #2
0
 private function share_extensions()
 {
     $extensiones = array(array('name' => 'email_factura_detallada', 'page_from' => __CLASS__, 'page_to' => 'ventas_factura', 'type' => 'email', 'text' => ucfirst(FS_FACTURA) . ' detallada', 'params' => '&factura=TRUE&tipo=detallada'));
     $idiomas = new idioma_fac_det();
     $arrayidiomas = $idiomas->all();
     foreach ($arrayidiomas as $arrayidio) {
         if ($arrayidio->activo == TRUE) {
             array_unshift($extensiones, array('name' => 'factura_' . $arrayidio->abreviatura, 'page_from' => __CLASS__, 'page_to' => 'ventas_factura', 'type' => 'pdf', 'text' => 'Factura en ' . $arrayidio->idioma, 'params' => '&abreviatura=' . $arrayidio->abreviatura));
         }
     }
     foreach ($extensiones as $ext) {
         $fsext = new fs_extension($ext);
         $this->new_error_msg($ext['text']);
         if (!$fsext->save()) {
             $this->new_error_msg('Error al guardar la extensión ' . $ext['name']);
         }
     }
 }