dolibarr 25.0.0-alpha
subtotal_create.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
35'
36@phan-var-force CommonObject $this
37@phan-var-force Propal|Commande|Facture|FactureRec|Expedition|SupplierProposal|CommandeFournisseur|FactureFournisseur $object
38@phan-var-force ?array<int,string> $depth_array
39@phan-var-force ?array<string,string> $titles
40@phan-var-force string $type
41';
42
43$depth_array = $depth_array ?? array();
44$titles = $titles ?? array();
45
46if ($type == 'subtotal' && empty($titles)) {
47 setEventMessages("NoTitleError", null, 'errors');
48 return;
49}
50
51$formquestion = array();
52
53if ($type == 'title') {
54 $formquestion = array();
55
56 $predefinedtitles = $object->getPredefinedTitles();
57 if (!empty($predefinedtitles)) {
58 $formquestion[] = array(
59 'type' => 'select',
60 'name' => 'subtotalpredefinedtitle',
61 'label' => $langs->trans("PredefinedTitle"),
62 'values' => $predefinedtitles,
63 'select_show_empty' => 1,
64 'moreattr' => 'onchange="var v = jQuery(this).val(); if (v && v != \'-1\') { jQuery(\'#subtotallinedesc\').val(v); }"',
65 );
66 }
67
68 $formquestion = array_merge($formquestion, array(
69 array('type' => 'text', 'name' => 'subtotallinedesc', 'label' => $langs->trans("SubtotalLineDesc"), 'moreattr' => 'placeholder="' . $langs->trans("Description") . '"'),
70 array('type' => 'select', 'name' => 'subtotallinelevel', 'label' => $langs->trans("SubtotalLineLevel"), 'values' => $depth_array, 'default' => 1, 'select_show_empty' => 0),
71 array('type' => 'checkbox', 'value' => true, 'name' => 'titleshowuponpdf', 'label' => $langs->trans("ShowUPOnPDF")),
72 array('type' => 'checkbox', 'value' => true, 'name' => 'titleshowtotalexludingvatonpdf', 'label' => $langs->trans("ShowTotalExludingVATOnPDF")),
73 array('type' => 'checkbox', 'value' => false, 'name' => 'titleforcepagebreak', 'label' => $langs->trans("ForcePageBreak")),
74 ));
75} elseif ($type == 'subtotal') {
76 $formquestion = array(
77 array('type' => 'select', 'name' => 'subtotaltitleline', 'label' => $langs->trans("CorrespondingTitleLine"), 'values' => $titles, 'select_show_empty' => 0),
78 array('type' => 'hidden', 'value' => true, 'name' => 'subtotalshowtotalexludingvatonpdf', 'label' => $langs->trans("ShowTotalExludingVATOnPDF")),
79 );
80} elseif ($type == 'text') {
81 $formquestion = array();
82
83 $predefinedtexts = $object->getPredefinedTexts();
84 if (!empty($predefinedtexts)) {
85 $predefinedtextvalues = array();
86 $predefinedtextsmap = array();
87 foreach ($predefinedtexts as $rowid => $text) {
88 $predefinedtextvalues[$rowid] = $text['label'];
89 $predefinedtextsmap[$rowid] = $text['content'];
90 }
91 print '<script>var subtotalPredefinedTextsMap = ' . json_encode($predefinedtextsmap, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) . ';</script>';
92 $formquestion[] = array(
93 'type' => 'select',
94 'name' => 'subtotalpredefinedtext',
95 'label' => $langs->trans("PredefinedText"),
96 'values' => $predefinedtextvalues,
97 'select_show_empty' => 1,
98 'moreattr' => 'onchange="var v = subtotalPredefinedTextsMap[jQuery(this).val()]; if (v !== undefined) { jQuery(\'#subtotaltextcontent\').val(v); }"',
99 );
100 }
101
102 $formquestion[] = array('type' => 'textarea', 'name' => 'subtotaltextcontent', 'label' => $langs->trans("SubtotalTextContent"), 'morecss' => 'quatrevingtpercent', 'moreattr' => 'rows="4"');
103}
104
105$page = $_SERVER["PHP_SELF"];
106
107if ($object->element == 'facture') {
108 $page .= '?facid=' . $object->id;
109} elseif (in_array($object->element, $object::$ALLOWED_TYPES)) { // @phan-suppress-current-line PhanUndeclaredStaticProperty
110 $page .= '?id=' . $object->id;
111}
112
113$form_title = $type == 'title' ? $langs->trans('AddTitleLine') : $langs->trans('AddSubtotalLine');
114
115print $form->formconfirm($page, $form_title, '', 'confirm_add' . $type . 'line', $formquestion, 'yes', 1);
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.