dolibarr 25.0.0-alpha
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-2026 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 CommonObject $this
34@phan-var-force Propal|Contrat|Commande|Facture|Expedition|Delivery|CommandeFournisseur|FactureFournisseur|SupplierProposal|Fichinter $object
35@phan-var-force CommonObjectLine|CommonInvoiceLine|CommonOrderLine|ExpeditionLigne|PropaleLigne|FichinterLigne $line
36@phan-var-force int $i
37';
38
39// Options for subtotal
40$sub_options = $line->extraparams["subtotal"] ?? array();
41
42$titleshowuponpdf = !empty($sub_options['titleshowuponpdf']);
43$titleshowtotalexludingvatonpdf = !empty($sub_options['titleshowtotalexludingvatonpdf']);
44$titleforcepagebreak = !empty($sub_options['titleforcepagebreak']);
45$subtotalshowtotalexludingvatonpdf = !empty($sub_options['subtotalshowtotalexludingvatonpdf']);
46
47$line_options = array(
48 'titleshowuponpdf' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleshowuponpdf, 'trans_key' => 'ShowUPOnPDF'),
49 'titleshowtotalexludingvatonpdf' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleshowtotalexludingvatonpdf, 'trans_key' => 'ShowTotalExludingVATOnPDF'),
50 'titleforcepagebreak' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleforcepagebreak, 'trans_key' => 'ForcePageBreak'),
51 'subtotalshowtotalexludingvatonpdf' => array('type' => array('subtotal'), 'value' => 'on', 'checked' => $subtotalshowtotalexludingvatonpdf, 'trans_key' => 'ShowTotalExludingVATOnPDF'),
52);
53
54// Line type
55$line_type = $line->qty > 0 ? 'title' : ($line->qty < 0 ? 'subtotal' : 'text');
56
57print "<!-- BEGIN PHP TEMPLATE subtotal_edit.tpl.php -->\n";
58
59echo '<tr class="oddeven tredited">';
60
61if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
62 echo '<td class="linecolnum center">' . ($i + 1) . '</td>';
63}
64
65// Base colspan if there is no module activated to display line correctly
66$colspan = 4;
67
68// Handling colspan if margin module is enabled
69if (!empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')) && isModEnabled('margin') && empty($user->socid)) {
70 if ($user->hasRight('margins', 'creer')) {
71 $colspan += 1;
72 }
73 if (getDolGlobalString('DISPLAY_MARGIN_RATES') && $user->hasRight('margins', 'liretous')) {
74 $colspan += 1;
75 }
76 if (getDolGlobalString('DISPLAY_MARK_RATES') && $user->hasRight('margins', 'liretous')) {
77 $colspan += 1;
78 }
79}
80
81// Handling colspan if multicurrency module is enabled
82if (isModEnabled('multicurrency') && $object->multicurrency_code != $conf->currency) {
83 $colspan += 1;
84}
85
86// Handling colspan if MAIN_NO_INPUT_PRICE_WITH_TAX conf is enabled
87if (!getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
88 $colspan += 1;
89}
90
91// Handling colspan if PRODUCT_USE_UNITS conf is enabled
92if (getDolGlobalString('PRODUCT_USE_UNITS')) {
93 $colspan += 1;
94}
95
96?>
97
98<td class="linecoldesc minwidth250onall">
99 <div id="line_<?php echo $line->id; ?>"></div>
100
101 <input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
102 <input type="hidden" id="product_type" name="type" value="<?php echo $line->product_type; ?>">
103 <input type="hidden" id="special_code" name="special_code" value="<?php echo $line->special_code; ?>">
104 <input type="hidden" id="fk_parent_line" name="fk_parent_line" value="<?php echo $line->fk_parent_line; ?>">
105 <input type="hidden" name="action" value="update<?php echo $line_type ?>line">
106
107 <?php
108
109 $situationinvoicelinewithparent = 0;
110 if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) {
112 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
113 if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
114 // Set constant to disallow editing during a situation cycle
115 $situationinvoicelinewithparent = 1;
116 }
117 }
118
119 // Do not allow editing during a situation cycle
120 // but in some situations that is required (update legal information for example)
121 if (getDolGlobalString('INVOICE_SITUATION_CAN_FORCE_UPDATE_DESCRIPTION')) {
122 $situationinvoicelinewithparent = 0;
123 }
124
125 $langs->load('subtotals');
126
127
128 if (!$situationinvoicelinewithparent) {
129 if ($line_type == 'text') {
130 print '<textarea name="line_desc" class="marginrightonly" id="line_desc" rows="4" cols="40">';
131 print dol_escape_htmltag(GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description, 0, 1);
132 print '</textarea>';
133
134 $predefinedtexts = $this->getPredefinedTexts(); // @phan-suppress-current-line PhanUndeclaredMethod
135 if (!empty($predefinedtexts)) {
136 $predefinedtextvalues = array();
137 $predefinedtextsmap = array();
138 foreach ($predefinedtexts as $rowid => $text) {
139 $predefinedtextvalues[$rowid] = $text['label'];
140 $predefinedtextsmap[$rowid] = $text['content'];
141 }
142 print '<script>var subtotalEditPredefinedTextsMap = ' . json_encode($predefinedtextsmap, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) . ';</script>';
143 print $form->selectarray('line_predefinedtext', $predefinedtextvalues, '', 1, 0, 0, 'onchange="var v = subtotalEditPredefinedTextsMap[jQuery(this).val()]; if (v !== undefined) { jQuery(\'#line_desc\').val(v); }"', 0, 0, 0, '', 'minwidth100');
144 }
145 $disabled = 0;
146 } else {
147 $disabled = 0;
148 if (getDolGlobalString("SUBTOTAL_CAN_USE_LONG_TITLE")) {
149 print '<textarea name="line_desc" class="marginrightonly minwidth300 valignmiddle" id="line_desc"';
150 if ($line_type == 'subtotal') {
151 print ' readonly="readonly"';
152 $disabled = 1;
153 }
154 print '>';
155 print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description;
156 print '</textarea>';
157 } else {
158 print '<input type="text" name="line_desc" class="marginrightonly minwidth300 valignmiddle" id="line_desc" value="';
159 print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description . '"';
160 if ($line_type == 'subtotal') {
161 print ' readonly="readonly"';
162 $disabled = 1;
163 }
164 print '>';
165 }
166 if ($line_type == 'title') {
167 $predefinedtitles = $this->getPredefinedTitles(); // @phan-suppress-current-line PhanUndeclaredMethod
168 if (!empty($predefinedtitles)) {
169 print $form->selectarray('line_predefinedtitle', $predefinedtitles, '', 1, 0, 0, 'onchange="var v = jQuery(this).val(); if (v && v != \'-1\') { jQuery(\'#line_desc\').val(v); }"', 0, 0, 0, '', 'minwidth100');
170 }
171 }
172 }
173 if ($line_type != 'text') {
174 $depth_array = $this->getPossibleLevels($langs); // Suppose CommonSubtotal trait @phan-suppress-current-line PhanUndeclaredMethod
175 print $form->selectarray('line_depth', $depth_array, abs($line->qty), 0, 0, 0, '', 0, 0, $disabled);
176 }
177 if ($disabled) {
178 print '<input type="hidden" name="line_depth" value="' . $line->qty . '">';
179 }
180 print '<div><ul class="ecmjqft">';
181 foreach ($line_options as $key => $value) {
182 if (in_array($line_type, $value['type'])) {
183 if ($line_type == 'title') {
184 print '<li><label for="' . $key . '">' . $langs->trans($value['trans_key']) . '</label>';
185 print '<input style="float: left;margin-top: 9px;" id="' . $key . '" type="checkbox" name="' . $key . '" value="' . $value['value'] . '" ';
186 print $value['checked'] ? 'checked' : '';
187 print '></li>';
188 }
189 if ($line_type == 'subtotal') {
190 print '<input style="float: left;margin-top: 9px;" id="' . $key . '" type="hidden" name="' . $key . '" value="' . $value['value'] . '">';
191 }
192 }
193 }
194 print '</ul></div></td>';
195 print '<td colspan="' . $colspan . '" class="right"></td>';
196 } else {
197 print '<input type="text" readonly name="line_desc" id="line_desc" value="';
198 print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description;
199 print '"></td>';
200 }
201 ?>
202
203
204<td class="center valignmiddle" colspan="4">
205 <input type="submit" class="reposition button buttongen button-save" id="savelinebutton marginbottomonly" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
206 <input type="submit" class="reposition button buttongen button-cancel" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
207</td>
208</tr>
209
210<!-- 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, $nodefault=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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
Definition html.lib.php:172
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