2020namespace FacturaScripts \Plugins \Modelo347 \Mod ;
2121
2222use FacturaScripts \Core \Contract \PurchasesModInterface ;
23- use FacturaScripts \Core \Translator ;
2423use FacturaScripts \Core \Model \Base \PurchaseDocument ;
25- use FacturaScripts \Core \Model \User ;
2624use FacturaScripts \Core \Tools ;
2725
28-
2926/**
3027 * Add new fields in the modal window of the document header
3128 * - excluir347: Allows the user to mark the invoice as excluded from the 347 calculation.
3532 */
3633class PurchasesHeaderHTMLMod implements PurchasesModInterface
3734{
38- public function apply (PurchaseDocument &$ model , array $ formData ):void
35+ public function apply (PurchaseDocument &$ model , array $ formData ): void
3936 {
4037 if (property_exists ($ model , 'excluir347 ' )) {
4138 $ model ->excluir347 = ($ formData ['excluir347 ' ] ?? '' ) === 'true ' ;
@@ -63,8 +60,7 @@ public function newFields(): array
6360 public function renderField (PurchaseDocument $ model , string $ field ): ?string
6461 {
6562 if ($ field == 'excluir347 ' ) {
66- $ i18n = new Translator ();
67- return $ this ->excluir347 ($ i18n , $ model );
63+ return $ this ->excluir347 ($ model );
6864 }
6965
7066 return null ;
@@ -75,7 +71,7 @@ public function newModalFields(): array
7571 return ['excluir347 ' ];
7672 }
7773
78- private static function excluir347 (Translator $ i18n , PurchaseDocument $ model ): string
74+ private static function excluir347 (PurchaseDocument $ model ): string
7975 {
8076 if (false === property_exists ($ model , 'excluir347 ' )) {
8177 return '' ;
@@ -85,13 +81,13 @@ private static function excluir347(Translator $i18n, PurchaseDocument $model): s
8581 foreach (['false ' , 'true ' ] as $ row ) {
8682 $ txt = ($ row === 'true ' ) ? 'yes ' : 'no ' ;
8783 $ options [] = ($ row == $ model ->excluir347 ) ?
88- '<option value=" ' . $ row . '" selected> ' . $ i18n -> trans ($ txt ) . '</option> ' :
89- '<option value=" ' . $ row . '"> ' . $ i18n -> trans ($ txt ) . '</option> ' ;
84+ '<option value=" ' . $ row . '" selected> ' . Tools:: trans ($ txt ) . '</option> ' :
85+ '<option value=" ' . $ row . '"> ' . Tools:: trans ($ txt ) . '</option> ' ;
9086 }
9187
9288 $ attributes = $ model ->editable ? 'name="excluir347" required="" ' : 'disabled="" ' ;
9389 return '<div class="col-sm-6"> '
94- . '<div class="mb-3"> ' . $ i18n -> trans ('exclude-347 ' )
90+ . '<div class="mb-3"> ' . Tools:: trans ('exclude-347 ' )
9591 . '<select ' . $ attributes . ' class="form-select"/> ' . implode ('' , $ options ) . '</select> '
9692 . '</div> '
9793 . '</div> ' ;
0 commit comments