1 | <?php |
||||
2 | /** |
||||
3 | * This file is part of FacturaScripts |
||||
4 | * Copyright (C) 2021-2022 Carlos Garcia Gomez <[email protected]> |
||||
5 | * |
||||
6 | * This program is free software: you can redistribute it and/or modify |
||||
7 | * it under the terms of the GNU Lesser General Public License as |
||||
8 | * published by the Free Software Foundation, either version 3 of the |
||||
9 | * License, or (at your option) any later version. |
||||
10 | * |
||||
11 | * This program is distributed in the hope that it will be useful, |
||||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
14 | * GNU Lesser General Public License for more details. |
||||
15 | * |
||||
16 | * You should have received a copy of the GNU Lesser General Public License |
||||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
18 | */ |
||||
19 | |||||
20 | namespace FacturaScripts\Core\Base\AjaxForms; |
||||
21 | |||||
22 | use FacturaScripts\Core\Translator; |
||||
23 | use FacturaScripts\Dinamic\Model\Asiento; |
||||
24 | |||||
25 | /** |
||||
26 | * Description of AccountingFooterHTML |
||||
27 | * |
||||
28 | * @author Carlos Garcia Gomez <[email protected]> |
||||
29 | * @author Jose Antonio Cuello Principal <[email protected]> |
||||
30 | */ |
||||
31 | class AccountingFooterHTML |
||||
32 | { |
||||
33 | |||||
34 | public static function apply(Asiento &$model, array $formData) |
||||
0 ignored issues
–
show
The parameter
$model is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||
35 | { |
||||
36 | } |
||||
37 | |||||
38 | public static function render(Asiento $model): string |
||||
39 | { |
||||
40 | $i18n = new Translator(); |
||||
41 | return '<div class="container-fluid">' |
||||
42 | . '<div class="form-row align-items-center mt-3">' |
||||
43 | . static::newSubaccount($i18n, $model) |
||||
44 | . static::moveBtn($i18n, $model) |
||||
45 | . static::importe($i18n, $model) |
||||
46 | . static::descuadre($i18n, $model) |
||||
47 | . '</div>' |
||||
48 | . '<div class="form-row mt-3">' |
||||
49 | . static::deleteBtn($i18n, $model) |
||||
50 | . '<div class="col-sm"></div>' |
||||
51 | . static::saveBtn($i18n, $model) |
||||
52 | . '</div>' |
||||
53 | . '</div>'; |
||||
54 | } |
||||
55 | |||||
56 | protected static function deleteBtn(Translator $i18n, Asiento $model): string |
||||
57 | { |
||||
58 | if (false === $model->exists() || false === $model->editable) { |
||||
59 | return ''; |
||||
60 | } |
||||
61 | |||||
62 | $lockBtn = ''; |
||||
63 | if ($model->editable) { |
||||
64 | $lockBtn .= '<div class="col-sm-3 col-md-2">' |
||||
65 | . '<button type="button" class="btn btn-block btn-warning btn-spin-action mb-3" onclick="return accEntryFormSave(\'lock-doc\', \'0\');">' |
||||
66 | . '<i class="fas fa-lock fa-fw"></i> ' . $i18n->trans('lock-entry') . '</button>' |
||||
67 | . '</div>'; |
||||
68 | } |
||||
69 | |||||
70 | return '<div class="col-sm-3 col-md-2">' |
||||
71 | . '<button type="button" class="btn btn-block btn-danger btn-spin-action mb-3" data-toggle="modal" data-target="#deleteDocModal">' |
||||
72 | . '<i class="fas fa-trash-alt fa-fw"></i> ' . $i18n->trans('delete') . '</button>' |
||||
73 | . '</div>' |
||||
74 | . $lockBtn |
||||
75 | . '<div class="modal fade" id="deleteDocModal" tabindex="-1" aria-hidden="true">' |
||||
76 | . '<div class="modal-dialog">' |
||||
77 | . '<div class="modal-content">' |
||||
78 | . '<div class="modal-header">' |
||||
79 | . '<h5 class="modal-title"></h5>' |
||||
80 | . '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' |
||||
81 | . '<span aria-hidden="true">×</span>' |
||||
82 | . '</button>' |
||||
83 | . '</div>' |
||||
84 | . '<div class="modal-body text-center">' |
||||
85 | . '<i class="fas fa-trash-alt fa-3x"></i>' |
||||
86 | . '<h5 class="mt-3 mb-1">' . $i18n->trans('confirm-delete') . '</h5>' |
||||
87 | . '<p class="mb-0">' . $i18n->trans('are-you-sure') . '</p>' |
||||
88 | . '</div>' |
||||
89 | . '<div class="modal-footer">' |
||||
90 | . '<button type="button" class="btn btn-secondary" data-dismiss="modal">' . $i18n->trans('cancel') . '</button>' |
||||
91 | . '<button type="button" class="btn btn-danger btn-spin-action" onclick="return accEntryFormSave(\'delete-doc\', \'0\');">' . $i18n->trans('delete') . '</button>' |
||||
92 | . '</div>' |
||||
93 | . '</div>' |
||||
94 | . '</div>' |
||||
95 | . '</div>'; |
||||
96 | } |
||||
97 | |||||
98 | /** |
||||
99 | * Render the unbalance value |
||||
100 | * |
||||
101 | * @param Translator $i18n |
||||
102 | * @param Asiento $model |
||||
103 | * |
||||
104 | * @return string |
||||
105 | */ |
||||
106 | protected static function descuadre(Translator $i18n, Asiento $model): string |
||||
107 | { |
||||
108 | $unbalance = isset($model->debe, $model->haber) ? round($model->debe - $model->haber, FS_NF0) : 0.0; |
||||
109 | if (empty($unbalance)) { |
||||
110 | return ''; |
||||
111 | } |
||||
112 | |||||
113 | return '<div class="col-sm-3 col-md-2 mb-3">' |
||||
114 | . '<div class="input-group">' |
||||
115 | . '<div class="input-group-prepend"><span class="input-group-text text-danger">' . $i18n->trans('unbalance') . '</span></div>' |
||||
116 | . '<input type="number" value="' . $unbalance . '" class="form-control" step="any" readonly>' |
||||
117 | . '</div></div>'; |
||||
118 | } |
||||
119 | |||||
120 | /** |
||||
121 | * Render the amount field |
||||
122 | * |
||||
123 | * @param Translator $i18n |
||||
124 | * @param Asiento $model |
||||
125 | * |
||||
126 | * @return string |
||||
127 | */ |
||||
128 | protected static function importe(Translator $i18n, Asiento $model): string |
||||
129 | { |
||||
130 | return '<div class="col-sm-3 col-md-2 mb-3">' |
||||
131 | . '<div class="input-group">' |
||||
132 | . '<div class="input-group-prepend"><span class="input-group-text">' . $i18n->trans('amount') . '</span></div>' |
||||
133 | . '<input type="number" value="' . $model->importe . '" class="form-control" step="any" tabindex="-1" readonly>' |
||||
134 | . '</div></div>'; |
||||
135 | } |
||||
136 | |||||
137 | protected static function newSubaccount(Translator $i18n, Asiento $model): string |
||||
138 | { |
||||
139 | if (false === $model->editable) { |
||||
140 | return '<div class="col-sm"></div>'; |
||||
141 | } |
||||
142 | |||||
143 | return '<div class="col-sm-6 col-md-2 mb-3">' |
||||
144 | . '<div class="input-group">' |
||||
145 | . '<input type="text" class="form-control" maxlength="15" autocomplete="off" placeholder="' . $i18n->trans('subaccount') |
||||
146 | . '" id="new_subaccount" name="new_subaccount" onchange="return newLineAction(this.value);"/>' |
||||
147 | . '<div class="input-group-append"><button class="btn btn-info" type="button" title="' . $i18n->trans('subaccounts') . '"' |
||||
148 | . ' onclick="$(\'#findSubaccountModal\').modal(); $(\'#findSubaccountInput\').focus();"><i class="fas fa-book"></i></button></div>' |
||||
149 | . '</div>' |
||||
150 | . '</div>' |
||||
151 | . '<div class="col-sm">' |
||||
152 | . '<p class="text-muted">' . $i18n->trans('account-dot-code') . '</p>' |
||||
153 | . '</div>'; |
||||
154 | } |
||||
155 | |||||
156 | protected static function saveBtn(Translator $i18n, Asiento $model): string |
||||
157 | { |
||||
158 | if (false === $model->editable) { |
||||
159 | return '<div class="col-sm-3 col-md-2">' |
||||
160 | . '<button type="button" class="btn btn-block btn-warning btn-spin-action mb-3" onclick="return accEntryFormSave(\'unlock-doc\', \'0\');">' |
||||
161 | . '<i class="fas fa-lock-open fa-fw"></i> ' . $i18n->trans('unlock-entry') . '</button>' |
||||
162 | . '</div>'; |
||||
163 | } |
||||
164 | |||||
165 | return '<div class="col-sm-3 col-md-2">' |
||||
166 | . '<button type="button" class="btn btn-block btn-primary btn-spin-action mb-3" load-after="true" onclick="return accEntryFormSave(\'save-doc\', \'0\');">' |
||||
167 | . '<i class="fas fa-save fa-fw"></i> ' . $i18n->trans('save') . '</button>' |
||||
168 | . '</div>'; |
||||
169 | } |
||||
170 | |||||
171 | protected static function moveBtn(Translator $i18n, Asiento $model): string |
||||
172 | { |
||||
173 | if (false === $model->editable) { |
||||
174 | return ''; |
||||
175 | } |
||||
176 | |||||
177 | return '<div class="col-sm-auto">' |
||||
178 | . '<button type="button" class="btn btn-light mb-3" id="sortableBtn">' |
||||
179 | . '<i class="fas fa-arrows-alt-v fa-fw"></i> ' . $i18n->trans('move-lines') |
||||
180 | . '</button>' |
||||
181 | . '</div>'; |
||||
182 | } |
||||
183 | } |
||||
184 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.