dolibarr 23.0.3
subtotal_edit.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 *
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';
36
37// Options for subtotal
38$sub_options = $line->extraparams["subtotal"] ?? array();
39
40$titleshowuponpdf = !empty($sub_options['titleshowuponpdf']);
41$titleshowtotalexludingvatonpdf = !empty($sub_options['titleshowtotalexludingvatonpdf']);
42$titleforcepagebreak = !empty($sub_options['titleforcepagebreak']);
43$subtotalshowtotalexludingvatonpdf = !empty($sub_options['subtotalshowtotalexludingvatonpdf']);
44
45$line_options = array(
46 'titleshowuponpdf' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleshowuponpdf, 'trans_key' => 'ShowUPOnPDF'),
47 'titleshowtotalexludingvatonpdf' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleshowtotalexludingvatonpdf, 'trans_key' => 'ShowTotalExludingVATOnPDF'),
48 'titleforcepagebreak' => array('type' => array('title'), 'value' => 'on', 'checked' => $titleforcepagebreak, 'trans_key' => 'ForcePageBreak'),
49 'subtotalshowtotalexludingvatonpdf' => array('type' => array('subtotal'), 'value' => 'on', 'checked' => $subtotalshowtotalexludingvatonpdf, 'trans_key' => 'ShowTotalExludingVATOnPDF'),
50);
51
52// Line type
53$line_type = $line->qty > 0 ? 'title' : 'subtotal';
54
55print "<!-- BEGIN PHP TEMPLATE subtotal_edit.tpl.php -->\n";
56
57echo '<tr class="oddeven tredited">';
58
59if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
60 echo '<td class="linecolnum center">' . ($i + 1) . '</td>';
61}
62
63// Base colspan if there is no module activated to display line correctly
64$colspan = 4;
65
66// Handling colspan if margin module is enabled
67if (!empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')) && isModEnabled('margin') && empty($user->socid)) {
68 if ($user->hasRight('margins', 'creer')) {
69 $colspan += 1;
70 }
71 if (getDolGlobalString('DISPLAY_MARGIN_RATES') && $user->hasRight('margins', 'liretous')) {
72 $colspan += 1;
73 }
74 if (getDolGlobalString('DISPLAY_MARK_RATES') && $user->hasRight('margins', 'liretous')) {
75 $colspan += 1;
76 }
77}
78
79// Handling colspan if multicurrency module is enabled
80if (isModEnabled('multicurrency') && $object->multicurrency_code != $conf->currency) {
81 $colspan += 1;
82}
83
84// Handling colspan if MAIN_NO_INPUT_PRICE_WITH_TAX conf is enabled
85if (!getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) {
86 $colspan += 1;
87}
88
89// Handling colspan if PRODUCT_USE_UNITS conf is enabled
90if (getDolGlobalString('PRODUCT_USE_UNITS')) {
91 $colspan += 1;
92}
93
94?>
95
96<td class="linecoldesc minwidth250onall">
97 <div id="line_<?php echo $line->id; ?>"></div>
98
99 <input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
100 <input type="hidden" id="product_type" name="type" value="<?php echo $line->product_type; ?>">
101 <input type="hidden" id="special_code" name="special_code" value="<?php echo $line->special_code; ?>">
102 <input type="hidden" id="fk_parent_line" name="fk_parent_line" value="<?php echo $line->fk_parent_line; ?>">
103 <input type="hidden" name="action" value="update<?php echo $line_type ?>line">
104
105 <?php
106
107 $situationinvoicelinewithparent = 0;
108 if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) {
110 // @phan-suppress-next-line PhanUndeclaredConstantOfClass
111 if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
112 // Set constant to disallow editing during a situation cycle
113 $situationinvoicelinewithparent = 1;
114 }
115 }
116
117 // Do not allow editing during a situation cycle
118 // but in some situations that is required (update legal information for example)
119 if (getDolGlobalString('INVOICE_SITUATION_CAN_FORCE_UPDATE_DESCRIPTION')) {
120 $situationinvoicelinewithparent = 0;
121 }
122
123 $langs->load('subtotals');
124
125
126 if (!$situationinvoicelinewithparent) {
127 print '<input type="text" name="line_desc" class="marginrightonly" id="line_desc" value="';
128 print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description . '"';
129 $disabled = 0;
130 if ($line_type == 'subtotal') {
131 print ' readonly="readonly"';
132 $disabled = 1;
133 }
134 print '>';
135 $depth_array = $this->getPossibleLevels($langs);
136 print $form->selectarray('line_depth', $depth_array, abs($line->qty), 0, 0, 0, '', 0, 0, $disabled);
137 if ($disabled) {
138 print '<input type="hidden" name="line_depth" value="' . $line->qty . '">';
139 }
140 print '<div><ul class="ecmjqft">';
141 foreach ($line_options as $key => $value) {
142 if (in_array($line_type, $value['type'])) {
143 print '<li><label for="' . $key . '">' . $langs->trans($value['trans_key']) . '</label>';
144 print '<input style="float: left;margin-top: 9px;" id="' . $key . '" type="checkbox" name="' . $key . '" value="' . $value['value'] . '" ';
145 print $value['checked'] ? 'checked' : '';
146 print '></li>';
147 }
148 }
149 print '</ul></div></td>';
150 print '<td colspan="' . $colspan . '" class="right"></td>';
151 } else {
152 print '<input type="text" readonly name="line_desc" id="line_desc" value="';
153 print GETPOSTISSET('product_desc') ? GETPOST('product_desc', 'restricthtml') : $line->description;
154 print '"></td>';
155 }
156 ?>
157
158
159<td class="center valignmiddle" colspan="4">
160 <input type="submit" class="reposition button buttongen button-save" id="savelinebutton marginbottomonly" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
161 <input type="submit" class="reposition button buttongen button-cancel" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
162</td>
163</tr>
164
165<!-- 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.
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:125
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:128