dolibarr 24.0.0-beta
subtotal_view.tpl.php
1<?php
2/* Copyright (C) 2014-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * or see https://www.gnu.org/
20 */
21
37'
38@phan-var-force CommonObjectLine|CommonInvoiceLine|CommonOrderLine|ExpeditionLigne|PropaleLigne $line
39@phan-var-force Propal|Contrat|Commande|Facture|Expedition|Delivery|CommandeFournisseur|FactureFournisseur|SupplierProposal $this
40@phan-var-force Propal|Contrat|Commande|Facture|Expedition|Delivery|CommandeFournisseur|FactureFournisseur|SupplierProposal $object
41@phan-var-force int $num
42';
43
44global $inputalsopricewithtax;
45
46if (empty($inputalsopricewithtax)) {
47 $inputalsopricewithtax = 0;
48}
49
50echo "<!-- BEGIN PHP TEMPLATE subtotal_view.tpl.php -->\n";
51
52$langs->load('subtotals');
53
54$line_options = $line->extraparams["subtotal"] ?? array();
55
56$line_color = $this->getSubtotalColors($line->qty);
57
58echo '<tr data-level="' . $line->qty . '" data-desc="' . $line->desc . '" data-rang="' . $line->rang . '" id="row-' . $line->id . '" class="drag drop" style="background:#' . $line_color . '">';
59
60// Showing line number if conf is enabled
61if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
62 echo '<td class="linecolnum center"><span class="opacitymedium">' . ($i + 1) . '</span></td>';
63}
64
65if ($line->qty > 0) { ?>
66 <td class="linecollabel" <?php echo !colorIsLight($line_color) ? ' style="color: white"' : ' style="color: black"' ?>><?php echo str_repeat('&nbsp;', (int) ($line->qty - 1) * 8); ?>
67 <?php
68 echo $line->desc;
69 if (array_key_exists('titleshowuponpdf', $line_options)) {
70 echo '&nbsp;' . img_picto($langs->trans("ShowUPOnPDF"), 'invoicing');
71 }
72 if (array_key_exists('titleshowtotalexludingvatonpdf', $line_options)) {
73 echo '&nbsp; <span title="' . $langs->trans("ShowTotalExludingVATOnPDF") . '">%</span>';
74 }
75 if (array_key_exists('titleforcepagebreak', $line_options)) {
76 echo '&nbsp;' . img_picto($langs->trans("ForcePageBreak"), 'file');
77 }
78 // Handling td for ref supplier
79 if (in_array($object->element, ['supplier_proposal'])) {
80 echo '<td></td>';
81 }
82 ?>
83 </td>
84 <td class="linecolvat nowrap right">
85 <?php
86 if ($this->status == 0 && $object->element != 'facturerec') {
87 if (GETPOST('mode', 'aZ09') == 'vatforblocklines' && GETPOSTINT('lineid') == $line->id) {
88 $type_tva = $type_tva ?? 0;
89 print '<div class="inline-block nowraponall">';
90 print $form->load_tva('vatforblocklines', '', $mysoc, $object->thirdparty, 0, (int) $line->info_bits, $line->product_type, false, 1, $type_tva);
91 print '<input type="hidden" name="lineid" value="' . $line->id . '">';
92 print '<input class="inline-block button smallpaddingimp" type="submit" name="updateallvatlinesblock" value="' . $langs->trans("Update") . '">';
93 print '</div>';
94 } else {
95 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&mode=vatforblocklines&lineid=' . $line->id . '">';
96 if (!colorIsLight($line_color)) {
97 echo img_edit($langs->trans("ApplyVATForBlock"), 0, 'style="color: white"');
98 } else {
99 echo img_edit($langs->trans("ApplyVATForBlock"), 0, 'style="color: #666"');
100 }
101 echo '</a>';
102 }
103 }
104 ?>
105 </td>
106 <td class="linecoluht"></td>
107 <?php
108 if (isModEnabled("multicurrency") && $this->multicurrency_code && $this->multicurrency_code != $conf->currency) {
109 print '<td class="linecoluht_currency"></td>';
110 }
111 // Handling colspan if MAIN_NO_INPUT_PRICE_WITH_TAX conf is enabled
112 if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
113 print '<td class="linecoluttc"></td>';
114 }
115 if (isModEnabled("multicurrency") && $this->multicurrency_code && $this->multicurrency_code != $conf->currency && !empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
116 print '<td class="linecoluttc_currency"></td>';
117 }
118
119 print '<td class="linecolqty"></td>';
120
121 // Handling colspan if PRODUCT_USE_UNITS conf is enabled
122 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
123 print '<td class="linecoluseunit"></td>';
124 }
125 ?>
126 <td class="linecoldiscount right">
127 <?php
128 if ($this->status == 0 && $object->element != 'facturerec') {
129 if (GETPOST('mode', 'aZ09') == 'discountforblocklines' && GETPOSTINT('lineid') == $line->id) {
130 print '<div class="inline-block nowraponall">';
131 print '<input type="text" class="flat right width40" name="discountforblocklines" id="discountforblocklines" value="0"><span class="hideonsmartphone"';
132 if (!colorIsLight($line_color)) {
133 print 'style="color: white"';
134 } else {
135 print 'style="color: black"';
136 }
137 print '>%</span>';
138 print '<input type="hidden" name="lineid" value="' . $line->id . '">';
139 print '<input class="inline-block button smallpaddingimp" type="submit" name="updatealldiscountlinesblock" value="' . $langs->trans("Update") . '">';
140 print '</div>';
141 } else {
142 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&mode=discountforblocklines&lineid=' . $line->id . '">';
143 if (!colorIsLight($line_color)) {
144 echo img_edit($langs->trans("ApplyDiscountForBlock"), 0, 'style="color: white"');
145 } else {
146 echo img_edit($langs->trans("ApplyDiscountForBlock"), 0, 'style="color: #666"');
147 }
148 echo '</a>';
149 }
150 }
151 ?>
152 </td>
153 <?php
154 // Handling if situation invoices conf is enabled
155 if (property_exists($this, 'situation_cycle_ref') && isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
156 print '<td class="linecolcycleref nowrap right"></td>';
157 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
158 print '<td class="nowrap right"></td>';
159 }
160 print '<td class="linecolcycleref2 right nowrap"></td>';
161 }
162
163 // Handling colspan if margin module is enabled
164 if (!empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')) && isModEnabled('margin') && empty($user->socid)) {
165 if ($user->hasRight('margins', 'creer')) {
166 print '<td class="linecolmargin1 nowrap margininfos right"></td>';
167 }
168 if (getDolGlobalString('DISPLAY_MARGIN_RATES') && $user->hasRight('margins', 'liretous')) {
169 print '<td class="linecolmargin2 nowrap margininfos right"></td>';
170 }
171 if (getDolGlobalString('DISPLAY_MARK_RATES') && $user->hasRight('margins', 'liretous')) {
172 print '<td class="linecolmark1 nowrap margininfos right"></td>';
173 }
174 }
175 ?>
176 <td class="linecolht"></td>
177 <?php if (isModEnabled("multicurrency") && $this->multicurrency_code && $this->multicurrency_code != $conf->currency) { ?>
178 <td class="linecoltotalht_currency"></td>
179 <?php } ?>
180<?php } elseif ($line->qty < 0) {
181 // Base colspan if there is no module activated to display line correctly
182 $colspan = 3; // linecoldescription, linecolvat, linecoluht
183
184 if (isModEnabled("multicurrency") && $this->multicurrency_code && $this->multicurrency_code != $conf->currency) {
185 $colspan++;
186 }
187 // Handling colspan if MAIN_NO_INPUT_PRICE_WITH_TAX conf is enabled
188 if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
189 $colspan++;
190 }
191 if (isModEnabled("multicurrency") && $this->multicurrency_code && $this->multicurrency_code != $conf->currency && !empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
192 $colspan++;
193 }
194
195 if (property_exists($this, 'situation_cycle_ref') && isset($this->situation_cycle_ref) && $this->situation_cycle_ref) {
196 $colspan += 2;
197 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
198 $colspan += 1;
199 }
200 }
201
202 // Handling colspan if margin module is enabled
203 if (!empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')) && isModEnabled('margin') && empty($user->socid)) {
204 if ($user->hasRight('margins', 'creer')) {
205 $colspan += 1;
206 }
207 if (getDolGlobalString('DISPLAY_MARGIN_RATES') && $user->hasRight('margins', 'liretous')) {
208 $colspan += 1;
209 }
210 if (getDolGlobalString('DISPLAY_MARK_RATES') && $user->hasRight('margins', 'liretous')) {
211 $colspan += 1;
212 }
213 }
214
215 // Handling colspan if PRODUCT_USE_UNITS conf is enabled
216 if (getDolGlobalString('PRODUCT_USE_UNITS')) {
217 $colspan += 1;
218 }
219 // Handling colspan if supplier object
220 if (in_array($object->element, ['supplier_proposal'])) {
221 $colspan += 1;
222 }
223 ?>
224 <td class="linecollabel nowrap right" <?php echo !colorIsLight($line_color) ? ' style="color: white"' : ' style="color: black"' ?> colspan="<?php echo $colspan + 2 ?>">
225 <?php
226 echo $line->desc;
227 if (array_key_exists('subtotalshowtotalexludingvatonpdf', $line_options)) {
228 echo '&nbsp; <span title="' . $langs->trans("ShowTotalExludingVATOnPDF") . '">%</span>';
229 }
230 echo ' :';
231 ?>
232 </td>
233 <td class="linecolamount nowrap right" <?php echo !colorIsLight($line_color) ? ' style="color: white"' : ' style="color: black"' ?>>
234 <?php
235 echo $this->getSubtotalLineAmount($line);
236 ?>
237 </td>
238 <?php
239 if (isModEnabled('multicurrency') && $object->multicurrency_code != $conf->currency) {
240 echo '<td class="linecolamount nowrap right"';
241 echo !colorIsLight($line_color) ? ' style="color: white"' : ' style="color: black"';
242 echo '>';
243 echo $this->getSubtotalLineMulticurrencyAmount($line);
244 echo '</td>';
245 }
246 ?>
247<?php }
248
249if ($this->status == 0) {
250 // Edit picto
251 echo '<td class="linecoledit center">';
252 echo '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=editline&token=' . newToken() . '&lineid=' . $line->id . '">';
253 if (!colorIsLight($line_color)) {
254 echo img_edit('default', 0, 'style="color: white"');
255 } else {
256 echo img_edit('default', 0, 'style="color: #666"');
257 }
258 echo '</a> </td>';
259
260 // Delete picto
261 echo '<td class="linecoldelete center">';
262 echo '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=ask_subtotal_deleteline&token=' . newToken() . '&lineid=' . $line->id;
263 if ($line->qty > 0) {
264 echo '&type=title';
265 }
266 echo '">';
267 if (!colorIsLight($line_color)) {
268 echo img_delete('default', 'class="pictodelete" style="color: white"');
269 } else {
270 echo img_delete('default', 'class="pictodelete" style="color: #666"');
271 }
272 echo '</a> </td>';
273
274 // Move up-down picto
275 if ($num > 1 && $conf->browser->layout != 'phone' && ((property_exists($this, 'situation_counter') && $this->situation_counter == 1) || (property_exists($this, 'situation_cycle_ref') && empty($this->situation_cycle_ref))) && empty($disablemove)) {
276 echo '<td class="linecolmove tdlineupdown center"';
277 if (!colorIsLight($line_color)) {
278 echo 'data-gripimg="grip_title.png"';
279 }
280 echo '>';
281 if ($i > 0) {
282 echo '<a class="lineupdown" href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=up&token=' . newToken() . '&rowid=' . $line->id . '">';
283 echo img_up('default', 0, 'imgupforline');
284 echo '</a>';
285 }
286 if ($i < $num - 1) {
287 echo '<a class="lineupdown" href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=down&token=' . newToken() . '&rowid=' . $line->id . '">';
288 echo img_down('default', 0, 'imgdownforline');
289 echo '</a>';
290 }
291 echo '</td>';
292 } else {
293 echo '<td ' . (($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"') . '></td>';
294 }
295} else {
296 $colspan = 3;
297 if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
298 $colspan++;
299 }
300 print '<td colspan="' . $colspan . '"></td>';
301}
302
303if ($action == 'selectlines') { ?>
304 <td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php print $i + 1; ?>]" value="<?php print $line->id; ?>" ></td>
305<?php }
306
307echo '</tr>';
308echo '<!-- END PHP TEMPLATE subtotal_view.tpl.php -->';
309?>
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:168
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133