dolibarr 24.0.0-beta
subtotal_edit.tpl.php
1<?php
2/* Copyright (C) 2014-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (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 General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
32'
33@phan-var-force Propal|Contrat|Commande|Facture|Expedition|Delivery|CommandeFournisseur|FactureFournisseur|SupplierProposal|Fichinter $object
34@phan-var-force CommonObjectLine|CommonInvoiceLine|CommonOrderLine|ExpeditionLigne|PropaleLigne|FichinterLigne $line
35@phan-var-force int $i
36';
37
38// Options for subtotal
39$sub_options = $line->extraparams["subtotal"] ?? array();
40
41$titleshowuponpdf = !empty($sub_options['titleshowuponpdf']);
42$titleshowtotalexludingvatonpdf = !empty($sub_options['titleshowtotalexludingvatonpdf']);
43$titleforcepagebreak = !empty($sub_options['titleforcepagebreak']);
44$subtotalshowtotalexludingvatonpdf = !empty($sub_options['subtotalshowtotalexludingvatonpdf']);
45
46$line_options = array(
47 'titleshowuponpdf' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleshowuponpdf, 'trans_key' => 'ShowUPOnPDF'),
48 'titleshowtotalexludingvatonpdf' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleshowtotalexludingvatonpdf, 'trans_key' => 'ShowTotalExludingVATOnPDF'),
49 'titleforcepagebreak' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleforcepagebreak, 'trans_key' => 'ForcePageBreak'),
50 'subtotalshowtotalexludingvatonpdf' => array('type' => array('subtotal'), 'value' => 'on', 'checked' => $subtotalshowtotalexludingvatonpdf, 'trans_key' => 'ShowTotalExludingVATOnPDF'),
51);
52
53// Line type
54$line_type = $line->qty > 0 ? 'title' : 'subtotal';
55
56print "<!-- BEGIN PHP TEMPLATE subtotal_edit.tpl.php -->\n";
57
58echo '<tr class="oddeven tredited">';
59
60if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
61 echo '<td class="linecolnum center">' . ($i + 1) . '</td>';
62}
63
64// Base colspan if there is no module activated to display line correctly
65$colspan = 4;
66
67// Handling colspan if margin module is enabled
68if (!empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')) && isModEnabled('margin') && empty($user->socid)) {
69 if ($user->hasRight('margins', 'creer')) {
70 $colspan += 1;
71 }
72 if (getDolGlobalString('DISPLAY_MARGIN_RATES') && $user->hasRight('margins', 'liretous')) {
73 $colspan += 1;
74 }
75 if (getDolGlobalString('DISPLAY_MARK_RATES') && $user->hasRight('margins', 'liretous')) {
76 $colspan += 1;
77 }
78}
79
80// Handling colspan if multicurrency module is enabled
81if (isModEnabled('multicurrency') && $object->multicurrency_code != $conf->currency) {
82 $colspan += 1;
83}
84
85// Handling colspan if MAIN_NO_INPUT_PRICE_WITH_TAX conf is enabled
86if (!getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
87 $colspan += 1;
88}
89
90// Handling colspan if PRODUCT_USE_UNITS conf is enabled
91if (getDolGlobalString('PRODUCT_USE_UNITS')) {
92 $colspan += 1;
93}
94
95?>
96
97<td class="linecoldesc minwidth250onall">
98 <div id="line_<?php echo $line->id; ?>"></div>
99
100 <input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
101 <input type="hidden" id="product_type" name="type" value="<?php echo $line->product_type; ?>">
102 <input type="hidden" id="special_code" name="special_code" value="<?php echo $line->special_code; ?>">
103 <input type="hidden" id="fk_parent_line" name="fk_parent_line" value="<?php echo $line->fk_parent_line; ?>">
104 <input type="hidden" name="action" value="update<?php echo $line_type ?>line">
105
106 <?php
107
108 $situationinvoicelinewithparent = 0;
109 if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) {
111 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
112 if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
113 // Set constant to disallow editing during a situation cycle
114 $situationinvoicelinewithparent = 1;
115 }
116 }
117
118 // Do not allow editing during a situation cycle
119 // but in some situations that is required (update legal information for example)
120 if (getDolGlobalString('INVOICE_SITUATION_CAN_FORCE_UPDATE_DESCRIPTION')) {
121 $situationinvoicelinewithparent = 0;
122 }
123
124 $langs->load('subtotals');
125
126
127 if (!$situationinvoicelinewithparent) {
128 print '<input type="text" name="line_desc" class="marginrightonly" id="line_desc" value="';
129 print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description . '"';
130 $disabled = 0;
131 if ($line_type == 'subtotal') {
132 print ' readonly="readonly"';
133 $disabled = 1;
134 }
135 print '>';
136 $depth_array = $this->getPossibleLevels($langs); // Suppose CommonSubtotal trait @phan-suppress-current-line PhanUndeclaredMethod
137 print $form->selectarray('line_depth', $depth_array, abs($line->qty), 0, 0, 0, '', 0, 0, $disabled);
138 if ($disabled) {
139 print '<input type="hidden" name="line_depth" value="' . $line->qty . '">';
140 }
141 print '<div><ul class="ecmjqft">';
142 foreach ($line_options as $key => $value) {
143 if (in_array($line_type, $value['type'])) {
144 print '<li><label for="' . $key . '">' . $langs->trans($value['trans_key']) . '</label>';
145 print '<input style="float: left;margin-top: 9px;" id="' . $key . '" type="checkbox" name="' . $key . '" value="' . $value['value'] . '" ';
146 print $value['checked'] ? 'checked' : '';
147 print '></li>';
148 }
149 }
150 print '</ul></div></td>';
151 print '<td colspan="' . $colspan . '" class="right"></td>';
152 } else {
153 print '<input type="text" readonly name="line_desc" id="line_desc" value="';
154 print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description;
155 print '"></td>';
156 }
157 ?>
158
159
160<td class="center valignmiddle" colspan="4">
161 <input type="submit" class="reposition button buttongen button-save" id="savelinebutton marginbottomonly" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
162 <input type="submit" class="reposition button buttongen button-cancel" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
163</td>
164</tr>
165
166<!-- END PHP TEMPLATE objectline_edit.tpl.php -->
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
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