dolibarr 22.0.5
notes.tpl.php
1<?php
2/* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
4 * Copyright (C) 2014-2020 Laurent Destailleur <eldy@destailleur.fr>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
35// Protection to avoid direct call of template
36if (empty($object) || !is_object($object)) {
37 print "Error, template page can't be called as URL";
38 exit(1);
39}
40'
41@phan-var-force ?int<0,1> $permissionnote
42@phan-var-force string $moreparam
43@phan-var-force ?int $colwidth
44';
45
46// $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create
47// $cssclass must be defined by caller. For example $cssclass='fieldtitle'
48$module = $object->element;
49$note_public = 'note_public';
50$note_private = 'note_private';
51
52if ($module == "product") {
53 $module = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
54}
55$colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : ''));
56// Set $permission from the $permissionnote var defined on calling page
57$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : ($user->hasRight($module, 'create') ? $user->rights->$module->create : ($user->hasRight($module, 'creer') ? $user->rights->$module->creer : 0))));
58$moreparam = (isset($moreparam) ? $moreparam : '');
59$value_public = $object->note_public;
60$value_private = $object->note_private;
61if (getDolGlobalString('MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES')) {
62 $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
63 if (GETPOST('action', 'aZ09') == 'edit'.$note_public) {
64 $value_public = dol_concatdesc($value_public, ($value_public ? "\n" : "")."-- ".$stringtoadd);
65 if (dol_textishtml($value_public)) {
66 $value_public .= "<br>\n";
67 } else {
68 $value_public .= "\n";
69 }
70 }
71}
72if (getDolGlobalString('MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES')) {
73 $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
74 if (GETPOST('action', 'aZ09') == 'edit'.$note_private) {
75 $value_private = dol_concatdesc($value_private, ($value_private ? "\n" : "")."-- ".$stringtoadd);
76 if (dol_textishtml($value_private)) {
77 $value_private .= "<br>\n";
78 } else {
79 $value_private .= "\n";
80 }
81 }
82}
83
84// Special cases
85if ($module == 'propal') {
86 $permission = $user->hasRight("propal", "creer");
87} elseif ($module == 'supplier_proposal') {
88 $permission = $user->hasRight("supplier_proposal", "creer");
89} elseif ($module == 'fichinter') {
90 $permission = $user->hasRight("ficheinter", "creer");
91} elseif ($module == 'project') {
92 $permission = $user->hasRight("projet", "creer");
93} elseif ($module == 'project_task') {
94 $permission = $user->hasRight("projet", "creer");
95} elseif ($module == 'invoice_supplier') {
96 if (!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
97 $permission = $user->hasRight("fournisseur", "facture", "creer");
98 } else {
99 $permission = $user->hasRight("supplier_invoice", "creer");
100 }
101} elseif ($module == 'order_supplier') {
102 if (!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
103 $permission = $user->hasRight("fournisseur", "commande", "creer");
104 } else {
105 $permission = $user->hasRight("supplier_order", "creer");
106 }
107} elseif ($module == 'societe') {
108 $permission = $user->hasRight("societe", "creer");
109} elseif ($module == 'contact') {
110 $permission = $user->hasRight("societe", "creer");
111} elseif ($module == 'shipping') {
112 $permission = $user->hasRight("expedition", "creer");
113} elseif ($module == 'product') {
114 $permission = $user->hasRight("product", "creer");
115} elseif ($module == 'service') {
116 $permission = $user->hasRight("service", "creer");
117} elseif ($module == 'ecmfiles') {
118 $permission = $user->hasRight("ecm", "setup");
119} elseif ($module == 'user') {
120 $permission = $user->hasRight("user", "self", "write");
121}
122//else dol_print_error(null,'Bad value '.$module.' for param module');
123
124if (isModEnabled('fckeditor') && getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC')) {
125 $typeofdatapub = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
126} else {
127 $typeofdatapub = 'textarea:12:95%';
128}
129if (isModEnabled('fckeditor') && getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE')) {
130 $typeofdatapriv = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
131} else {
132 $typeofdatapriv = 'textarea:12:95%';
133}
134
135print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n";
136print '<div class="tagtable border table-border tableforfield centpercent">'."\n";
137print '<div class="tagtr table-border-row">'."\n";
138$editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_public);
139print '<div class="tagtd tagtdnote tdtop'.($editmode ? '' : ' sensiblehtmlcontent').' table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
140print $form->editfieldkey((empty($textNotePub) ? "NotePublic" : $textNotePub), $note_public, (string) $value_public, $object, $permission, $typeofdatapub, $moreparam, 0, 0);
141print '</div>'."\n";
142print '<div class="tagtd wordbreak table-val-border-col'.($editmode ? '' : ' sensiblehtmlcontent').'">'."\n";
143print $form->editfieldval("NotePublic", $note_public, (string) $value_public, $object, $permission, $typeofdatapub, '', null, null, $moreparam, 1)."\n";
144print '</div>'."\n";
145print '</div>'."\n";
146if (empty($user->socid)) {
147 // Private notes (always hidden to external users)
148 print '<div class="tagtr table-border-row">'."\n";
149 $editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_private);
150 print '<div class="tagtd tagtdnote tdtop'.($editmode ? '' : ' sensiblehtmlcontent').' table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
151 print $form->editfieldkey((empty($textNotePrive) ? "NotePrivate" : $textNotePrive), $note_private, (string) $value_private, $object, $permission, $typeofdatapriv, $moreparam, 0, 0);
152 print '</div>'."\n";
153 print '<div class="tagtd wordbreak table-val-border-col'.($editmode ? '' : ' sensiblehtmlcontent').'">'."\n";
154 print $form->editfieldval("NotePrivate", $note_private, (string) $value_private, $object, $permission, $typeofdatapriv, '', null, null, $moreparam, 1);
155 print '</div>'."\n";
156 print '</div>'."\n";
157}
158print '</div>'."\n";
159?>
160<!-- END PHP TEMPLATE NOTES-->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
const TYPE_SERVICE
Service.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
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.