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
43$depth_array = $depth_array ?? array();
44$titles = $titles ?? array();
46if ($type ==
'subtotal' && empty($titles)) {
47 setEventMessages(
"NoTitleError",
null,
'errors');
51$formquestion = array();
53if ($type ==
'title') {
54 $formquestion = array();
56 $predefinedtitles =
$object->getPredefinedTitles();
57 if (!empty($predefinedtitles)) {
60 $formquestion[] = array(
62 'name' =>
'subtotalpredefinedtitle',
63 'label' => $langs->trans(
"PredefinedTitle"),
64 'values' => $predefinedtitles,
65 'select_show_empty' => 1,
66 'moreattr' =>
'onchange="var o = this.options[this.selectedIndex]; if (o.value && o.value != \'-1\') { jQuery(\'#subtotallinedesc\').val(o.text); }"',
70 $formquestion = array_merge($formquestion, array(
71 array(
'type' =>
'text',
'name' =>
'subtotallinedesc',
'label' => $langs->trans(
"SubtotalLineDesc"),
'moreattr' =>
'placeholder="' . $langs->trans(
"Description") .
'"'),
72 array(
'type' =>
'select',
'name' =>
'subtotallinelevel',
'label' => $langs->trans(
"SubtotalLineLevel"),
'values' => $depth_array,
'default' => 1,
'select_show_empty' => 0),
73 array(
'type' =>
'checkbox',
'value' =>
true,
'name' =>
'titleshowuponpdf',
'label' => $langs->trans(
"ShowUPOnPDF")),
74 array(
'type' =>
'checkbox',
'value' =>
true,
'name' =>
'titleshowtotalexludingvatonpdf',
'label' => $langs->trans(
"ShowTotalExludingVATOnPDF")),
75 array(
'type' =>
'checkbox',
'value' =>
false,
'name' =>
'titleforcepagebreak',
'label' => $langs->trans(
"ForcePageBreak")),
77} elseif ($type ==
'subtotal') {
78 $formquestion = array(
79 array(
'type' =>
'select',
'name' =>
'subtotaltitleline',
'label' => $langs->trans(
"CorrespondingTitleLine"),
'values' => $titles,
'select_show_empty' => 0),
80 array(
'type' =>
'hidden',
'value' =>
true,
'name' =>
'subtotalshowtotalexludingvatonpdf',
'label' => $langs->trans(
"ShowTotalExludingVATOnPDF")),
82} elseif ($type ==
'text') {
83 $formquestion = array();
85 $predefinedtexts =
$object->getPredefinedTexts();
86 if (!empty($predefinedtexts)) {
87 $predefinedtextvalues = array();
88 $predefinedtextsmap = array();
89 foreach ($predefinedtexts as $rowid => $text) {
90 $predefinedtextvalues[$rowid] = $text[
'label'];
91 $predefinedtextsmap[$rowid] = $text[
'content'];
93 print
'<script>var subtotalPredefinedTextsMap = ' . json_encode($predefinedtextsmap, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) .
';</script>';
94 $formquestion[] = array(
96 'name' =>
'subtotalpredefinedtext',
97 'label' => $langs->trans(
"PredefinedText"),
98 'values' => $predefinedtextvalues,
99 'select_show_empty' => 1,
100 'moreattr' =>
'onchange="var v = subtotalPredefinedTextsMap[jQuery(this).val()]; if (v !== undefined) { jQuery(\'#subtotaltextcontent\').val(v); }"',
104 $formquestion[] = array(
'type' =>
'textarea',
'name' =>
'subtotaltextcontent',
'label' => $langs->trans(
"SubtotalTextContent"),
'morecss' =>
'quatrevingtpercent',
'moreattr' =>
'rows="4"');
107$page = $_SERVER[
"PHP_SELF"];
109if (
$object->element ==
'facture') {
110 $page .=
'?facid=' .
$object->id;
111} elseif (in_array(
$object->element, $object::$ALLOWED_TYPES)) {
115$form_title = $type ==
'title' ? $langs->trans(
'AddTitleLine') : $langs->trans(
'AddSubtotalLine');
117print $form->formconfirm($page, $form_title,
'',
'confirm_add' . $type .
'line', $formquestion,
'yes', 1);
if(! $sortfield) if(! $sortorder) $object