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