diff --git a/class/actions_autoverifactu.class.php b/class/actions_autoverifactu.class.php index 7b01ced..45b7496 100644 --- a/class/actions_autoverifactu.class.php +++ b/class/actions_autoverifactu.class.php @@ -171,6 +171,7 @@ public function doActions($parameters, &$object, &$action) break; case 'edit_extras': $attribute = GETPOST('attribute', 'alpha'); + //evito que se editen estos campos if ( $attribute === 'verifactu_status' || @@ -179,9 +180,9 @@ public function doActions($parameters, &$object, &$action) $attribute === 'verifactu_error_code' || $attribute === 'verifactu_pdfLegalText' || $attribute === 'VerifactuTimeStamp' - ) { - $this->errors[] = $langs->trans('NotEdit'); - $action = ''; + ) { + $this->errors[] = $langs->trans('NotEdit'); + $action = ''; } break; case 'add': @@ -222,6 +223,7 @@ public function doActions($parameters, &$object, &$action) if ($action === 'update' && autoverifactuEnabled()) { $forbidden = $mysoc->nom !== GETPOST('name') || $mysoc->idprof1 !== GETPOST('siren'); + if ($forbidden) { $_POST['name'] = $mysoc->nom; $_POST['siren'] = $mysoc->idprof1; @@ -329,7 +331,7 @@ public function printUnderHeaderPDFline($parameters, &$pdfhandler) 'border' => false, 'padding' => 2, 'fgcolor' => array(25, 25, 25), - 'bgcolor' => array(255, 255, 255), //margen color blanco con padding 2mm + 'bgcolor' => array(255, 255, 255), //margen color blanco con padding 2mm 'module_width' => 1, 'module_height' => 1, ), @@ -381,14 +383,15 @@ public function addMoreActionsButtons($parameters, &$object, $action) ) ); } + //Boton para mostrar los errores de factura if ( $object->element === 'facture' && $object->status > Facture::STATUS_DRAFT && $object->type <= Facture::TYPE_DEPOSIT && autoverifactuEnabled() && $object->array_options['options_verifactu_status'] === '4' - ) { - echo dolGetButtonAction( + ) { + echo dolGetButtonAction( $langs->trans('fixErrors'), $langs->trans('fixErrors'), 'default', @@ -400,17 +403,19 @@ public function addMoreActionsButtons($parameters, &$object, $action) 'class' => 'classfortooltip', 'title' => '' ), - ) + ), ); } + //permitir reenviar la facturas con errores - if ( $object->element === 'facture' + if ( + $object->element === 'facture' && $object->status > Facture::STATUS_DRAFT && $object->type <= Facture::TYPE_DEPOSIT && autoverifactuEnabled() && in_array($object->array_options['options_verifactu_status'], array('2','4','5'), true) - ) { - echo dolGetButtonAction( + ) { + echo dolGetButtonAction( $langs->trans('VerifactuResend'), $langs->trans('VerifactuResend'), 'default', @@ -422,7 +427,7 @@ public function addMoreActionsButtons($parameters, &$object, $action) 'class' => 'classfortooltip', 'title' => '' ), - ) + ), ); } } @@ -471,8 +476,8 @@ public function dolGetButtonAction(&$parameters, $object, $action) $parameters['params'] ); - $this->resprints = $button; - return 1; + $this->resprints = $button; + return 1; } elseif ($object->status == Facture::STATUS_DRAFT && $action === 'valid') { $object->fetch_thirdparty(); $thirdparty = $object->thirdparty; @@ -577,22 +582,6 @@ public function formObjectOptions($parameters, $object, $action) } else { echo ''; } - - echo ' - '; } /** diff --git a/core/modules/modAutoverifactu.class.php b/core/modules/modAutoverifactu.class.php index df5732f..89d85ec 100644 --- a/core/modules/modAutoverifactu.class.php +++ b/core/modules/modAutoverifactu.class.php @@ -113,7 +113,7 @@ public function __construct($db) 'theme' => 0, // Set this to relative path of css file if module has its own css file 'css' => array( - '/autoverifactu/css/admin.css.php', + '/autoverifactu/css/autoverifactuu.css.php', ), // Set this to relative path of js file if module must load a js on all pages 'js' => array( @@ -281,18 +281,19 @@ public function init($options = '') // Create extrafields during init include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); + //----------------------------------------Invoice ---------------------------------------- // Tipo de rectificación en caso de que la factura sea rectificativa. $extrafields->addExtraField( - 'verifactu_rectification_type', - 'VerifactuRectificationType', - 'select', - 1, - 2, - 'facture', - 0, - 0, - '', + 'verifactu_rectification_type', // name + 'VerifactuRectificationType', // label + 'select', // type + 1, // position + 2, // size + 'facture', // element + 0, // unique + 0, // required + '', // default array( 'options' => array( 'R1' => $langs->trans('VerifactuRectificationTypeR1'), @@ -301,16 +302,17 @@ public function init($options = '') 'R4' => $langs->trans('VerifactuRectificationTypeR4'), // 'R5' => $langs->trans('VerifactuRectificationTypeR5') ), - ), - 0, - '', - '3', - $langs->trans('VerifactuRectificationTypeDescription'), - '', - '', - 'autoverifactu@autoverifactu', - 'isModEnabled("autoverifactu")', + ), // parameters + 0, // always editable + '', // permissions + '3', // Visibility (0=never, 1=all, 2=list 3=form) + $langs->trans('VerifactuRectificationTypeDescription'), // help + '', // computed + '', // entity + 'autoverifactu@autoverifactu', // lang file + 'isModEnabled("autoverifactu")', // enabled ); + // Fecha de operación $extrafields->addExtraField( 'verifactu_date_operation', @@ -332,6 +334,7 @@ public function init($options = '') 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + // Campo para el almacenamiento de los textos legales para el pdf // de la factura por el usuario. $extrafields->addExtraField( @@ -354,6 +357,7 @@ public function init($options = '') 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + // Estado de los envios a verifactu en funcion de si esta permitio o no hacer una peticion a la API $extrafields->addExtraField( 'verifactu_status', @@ -380,13 +384,14 @@ public function init($options = '') ), 0, '', - '1', + 0, $langs->trans('verifactuStatusDescription'), '', '', 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + // campo para el almacenamiento de errores de validación de la factura. $extrafields->addExtraField( 'verifactu_error', @@ -401,13 +406,14 @@ public function init($options = '') '', 0, '', - 3, + 0, '', '', '', 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + //campo para el almacenamiento de los codigos de errores de validación de la factura. $extrafields->addExtraField( 'verifactu_error_code', @@ -429,6 +435,7 @@ public function init($options = '') 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + // hash verifactu $extrafields->addExtraField( 'verifactu_hash', @@ -450,6 +457,7 @@ public function init($options = '') 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + // Campo para el almacenamiento de los textos legales para el pdf de la factura. $extrafields->addExtraField( 'verifactu_pdfLegalText', @@ -471,6 +479,7 @@ public function init($options = '') 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + // Timestamp de validación de la factura. $extrafields->addExtraField( 'verifactu_tms', @@ -492,6 +501,7 @@ public function init($options = '') 'autoverifactu@autoverifactu', 'isModEnabled("autoverifactu")', ); + //----------------------------------------line ---------------------------------------- // regimen de facturación de la línea de factura $extrafields->addExtraField( diff --git a/css/admin.css.php b/css/admin.css.php deleted file mode 100644 index 428b665..0000000 --- a/css/admin.css.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/custom/verifactu/css/mymodule.css.php - * \ingroup verifactu - * \brief CSS file for module verifactu setup page. - */ - -if (!defined('NOREQUIRESOC')) { - define('NOREQUIRESOC', '1'); -} - -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', 1); -} - -if (!defined('NOLOGIN')) { - define('NOLOGIN', 1); -} - -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', 1); -} - -if (!defined('NOREQUIREAJAX')) { - define('NOREQUIREAJAX', '1'); -} - -/** - * \file htdocs/autoverifactu/css/autoverifactu.css.php - * \ingroup autoverifactu - * \brief Cascading Style Sheet file for module Auto-Veri*Factu. - */ - -require_once dirname(__DIR__) . '/env.php'; - -header('Content-type: text/css'); - -if (empty($dolibarr_nocache)) { - header('Cache-Control: max-age=10800, public, must-revalidate'); -} else { - header('Cache-Control: no-cache'); -} - -?> - -#autoverifactuSetupForm input[error="1"] { - border: indianred 1px solid; - color: indianred; -} - -.autodeclaration-preview { - position: relative; - max-width: 65rem; - padding: 6rem 4.5rem 4.5rem; - border: 1px solid; - box-sizing: border-box; -} - -.autodeclaration-preview h1, -.autodeclaration-preview h2 { - line-height: 1.2; -} - -.autodeclaration-preview h1 { - margin-bottom: 1.5em; -} - -.autodeclaration-preview ol, -.autodeclaration-preview ul { - padding-left: 1rem; -} - -.autodeclaration-watermark { - position: absolute; - z-index: 10; - font-weight: 800; - font-size: 8rem; - color: red; - top: 15%; - left: 50%; - transform: translate(-50%, -50%) rotate(45deg); - opacity: 0.3; - text-transform: uppercase; -} diff --git a/css/selector_status.css.php b/css/autoverifactu.css.php similarity index 58% rename from css/selector_status.css.php rename to css/autoverifactu.css.php index 1180f5a..bdf9b7a 100644 --- a/css/selector_status.css.php +++ b/css/autoverifactu.css.php @@ -1,4 +1,26 @@ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/custom/verifactu/css/admin.css.php + * \ingroup verifactu + * \brief CSS file for module verifactu setup page. + */ + if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } @@ -7,6 +29,10 @@ define('NOTOKENRENEWAL', 1); } +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); +} + if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', 1); } @@ -15,6 +41,8 @@ define('NOREQUIREAJAX', '1'); } +require_once dirname(__DIR__) . '/env.php'; + header('Content-type: text/css'); if (empty($dolibarr_nocache)) { @@ -23,21 +51,53 @@ header('Cache-Control: no-cache'); } -$res = 0; -if (!$res && file_exists('../../../main.inc.php')) { - $res = @include '../../../main.inc.php'; +global $langs; +$langs->load('autoverifactu@autoverifactu'); + +?> + +/* SETUP FORM */ +#autoverifactuSetupForm input[error="1"] { + border: indianred 1px solid; + color: indianred; } -if (!$res && file_exists('../../../../main.inc.php')) { - $res = @include '../../../../main.inc.php'; + +.autodeclaration-preview { + position: relative; + max-width: 65rem; + padding: 6rem 4.5rem 4.5rem; + border: 1px solid; + box-sizing: border-box; } -if (!$res) { - die('Error: No se pudo encontrar el archivo main.inc.php de Dolibarr.'); + +.autodeclaration-preview h1, +.autodeclaration-preview h2 { + line-height: 1.2; } -$langs->load('autoverifactu@autoverifactu'); +.autodeclaration-preview h1 { + margin-bottom: 1.5em; +} -?> +.autodeclaration-preview ol, +.autodeclaration-preview ul { + padding-left: 1rem; +} + +.autodeclaration-watermark { + position: absolute; + z-index: 10; + font-weight: 800; + font-size: 8rem; + color: red; + top: 15%; + left: 50%; + transform: translate(-50%, -50%) rotate(45deg); + opacity: 0.3; + text-transform: uppercase; +} +/* SELECTOR STATUS */ td[data-key="facture.verifactu_status"] { font-family: sans-serif; font-size: 0.85em; @@ -61,28 +121,32 @@ border-color: #1f617a !important; color: #ffffff !important; } + /* Registrado Correctamente */ td[data-key="facture.verifactu_status"][title="transnoentitiesnoconv('verifactuStatusSelect1'), ENT_QUOTES, 'UTF-8');?>"] { background-color: #28a745 !important; border-color: #1e7e34 !important; color: #ffffff !important; } + /* Rechazado */ td[data-key="facture.verifactu_status"][title="transnoentitiesnoconv('verifactuStatusSelect2'), ENT_QUOTES, 'UTF-8');?>"] { background-color: #dc3545 !important; border-color: #bd2130 !important; color: #ffffff !important; } + /* En cola (Espera Temporal) */ td[data-key="facture.verifactu_status"][title="transnoentitiesnoconv('verifactuStatusSelect3'), ENT_QUOTES, 'UTF-8');?>"] { background-color: #ffc107 !important; border-color: #d39e00 !important; color: #212529 !important; } + /* Registrado Correctamente pero con Errores */ td[data-key="facture.verifactu_status"][title="transnoentitiesnoconv('verifactuStatusSelect4'), ENT_QUOTES, 'UTF-8');?>"] { background-color: #fd7e14 !important; /* Naranja corporativo de advertencia */ border-color: #cf6206 !important; color: #ffffff !important; -} \ No newline at end of file +}