dolibarr  16.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  *
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  */
19 
20 // Protection to avoid direct call of template
21 if (empty($object) || !is_object($object)) {
22  print "Error, template page can't be called as URL";
23  exit;
24 }
25 
26 // $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create
27 // $cssclass must be defined by caller. For example $cssclass='fieldtitle'
28 $module = $object->element;
29 $note_public = 'note_public';
30 $note_private = 'note_private';
31 
32 if ($module == "product") {
33  $module = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
34 }
35 $colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : ''));
36 // Set $permission from the $permissionnote var defined on calling page
37 $permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0))));
38 $moreparam = (isset($moreparam) ? $moreparam : '');
39 $value_public = $object->note_public;
40 $value_private = $object->note_private;
41 if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES)) {
42  $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
43  if (GETPOST('action', 'aZ09') == 'edit'.$note_public) {
44  $value_public = dol_concatdesc($value_public, ($value_public ? "\n" : "")."-- ".$stringtoadd);
45  if (dol_textishtml($value_public)) {
46  $value_public .= "<br>\n";
47  } else {
48  $value_public .= "\n";
49  }
50  }
51 }
52 if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) {
53  $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
54  if (GETPOST('action', 'aZ09') == 'edit'.$note_private) {
55  $value_private = dol_concatdesc($value_private, ($value_private ? "\n" : "")."-- ".$stringtoadd);
56  if (dol_textishtml($value_private)) {
57  $value_private .= "<br>\n";
58  } else {
59  $value_private .= "\n";
60  }
61  }
62 }
63 
64 // Special cases
65 if ($module == 'propal') {
66  $permission = $user->hasRight("propal", "creer");
67 } elseif ($module == 'supplier_proposal') {
68  $permission = $user->hasRight("supplier_proposal", "creer");
69 } elseif ($module == 'fichinter') {
70  $permission = $user->hasRight("ficheinter", "creer");
71 } elseif ($module == 'project') {
72  $permission = $user->hasRight("projet", "creer");
73 } elseif ($module == 'project_task') {
74  $permission = $user->hasRight("projet", "creer");
75 } elseif ($module == 'invoice_supplier') {
76  if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
77  $permission = $user->hasRight("fournisseur", "facture", "creer");
78  } else {
79  $permission = $user->hasRight("supplier_invoice", "creer");
80  }
81 } elseif ($module == 'order_supplier') {
82  if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
83  $permission = $user->hasRight("fournisseur", "commande", "creer");
84  } else {
85  $permission = $user->hasRight("supplier_order", "creer");
86  }
87 } elseif ($module == 'societe') {
88  $permission = $user->hasRight("societe", "creer");
89 } elseif ($module == 'contact') {
90  $permission = $user->hasRight("societe", "creer");
91 } elseif ($module == 'shipping') {
92  $permission = $user->hasRight("expedition", "creer");
93 } elseif ($module == 'product') {
94  $permission = $user->hasRight("product", "creer");
95 } elseif ($module == 'service') {
96  $permission = $user->hasRight("service", "creer");
97 } elseif ($module == 'ecmfiles') {
98  $permission = $user->hasRight("ecm", "setup");
99 }
100 //else dol_print_error('','Bad value '.$module.' for param module');
101 
102 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
103  $typeofdata = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
104 } else {
105  $typeofdata = 'textarea:12:95%';
106 }
107 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC)) {
108  $typeofdatapub = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
109 } else {
110  $typeofdatapub = 'textarea:12:95%';
111 }
112 if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE)) {
113  $typeofdatapriv = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
114 } else {
115  $typeofdatapriv = 'textarea:12:95%';
116 }
117 
118 print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n";
119 print '<div class="tagtable border table-border tableforfield centpercent">'."\n";
120 print '<div class="tagtr table-border-row">'."\n";
121 $editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_public);
122 print '<div class="tagtd tagtdnote tdtop'.($editmode ? '' : ' sensiblehtmlcontent').' table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
123 print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdatapub, $moreparam, '', 0);
124 print '</div>'."\n";
125 print '<div class="tagtd wordbreak table-val-border-col'.($editmode ? '' : ' sensiblehtmlcontent').'">'."\n";
126 print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdatapub, '', null, null, $moreparam, 1)."\n";
127 print '</div>'."\n";
128 print '</div>'."\n";
129 if (empty($user->socid)) {
130  // Private notes (always hidden to external users)
131  print '<div class="tagtr table-border-row">'."\n";
132  $editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_private);
133  print '<div class="tagtd tagtdnote tdtop'.($editmode ? '' : ' sensiblehtmlcontent').' table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
134  print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdatapriv, $moreparam, '', 0);
135  print '</div>'."\n";
136  print '<div class="tagtd wordbreak table-val-border-col'.($editmode ? '' : ' sensiblehtmlcontent').'">'."\n";
137  print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdatapriv, '', null, null, $moreparam, 1);
138  print '</div>'."\n";
139  print '</div>'."\n";
140 }
141 print '</div>'."\n";
142 ?>
143 <!-- END PHP TEMPLATE NOTES-->
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
dol_concatdesc
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...
Definition: functions.lib.php:7248
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
Product\TYPE_SERVICE
const TYPE_SERVICE
Service.
Definition: product.class.php:504
dol_textishtml
dol_textishtml($msg, $option=0)
Return if a text is a html content.
Definition: functions.lib.php:7185