dolibarr  7.0.0-beta
notes.tpl.php
1 <?php
2 /* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
3  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2014-2017 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 <http://www.gnu.org/licenses/>.
18  */
19 
20 // Protection to avoid direct call of template
21 if (empty($object) || ! is_object($object))
22 {
23  print "Error, template page can't be called as URL";
24  exit;
25 }
26 
27 // $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create
28 // $cssclass must be defined by caller. For example $cssclass='fieldtitle"
29 $module = $object->element;
30 $note_public = 'note_public';
31 $note_private = 'note_private';
32 
33 $colwidth=(isset($colwidth)?$colwidth:(empty($cssclass)?'25':''));
34 // Set $permission from the $permissionnote var defined on calling page
35 $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))));
36 $moreparam=(isset($moreparam)?$moreparam:'');
37 $value_public=$object->note_public;
38 $value_private=$object->note_private;
39 if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES))
40 {
41  $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
42  if (GETPOST('action','aZ09') == 'edit'.$note_public)
43  {
44  $value_public=dol_concatdesc($value_public, ($value_public?"\n":"")."-- ".$stringtoadd);
45  if (dol_textishtml($value_public)) $value_public.="<br>\n";
46  else $value_public.="\n";
47  }
48 }
49 if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
50 {
51  $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
52  if (GETPOST('action','aZ09') == 'edit'.$note_private)
53  {
54  $value_private=dol_concatdesc($value_private, ($value_private?"\n":"")."-- ".$stringtoadd);
55  if (dol_textishtml($value_private)) $value_private.="<br>\n";
56  else $value_private.="\n";
57  }
58 }
59 
60 // Special cases
61 if ($module == 'propal') { $permission=$user->rights->propale->creer;}
62 elseif ($module == 'supplier_proposal') { $permission=$user->rights->supplier_proposal->creer;}
63 elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;}
64 elseif ($module == 'project') { $permission=$user->rights->projet->creer;}
65 elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;}
66 elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;}
67 elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;}
68 elseif ($module == 'societe') { $permission=$user->rights->societe->creer;}
69 elseif ($module == 'contact') { $permission=$user->rights->societe->creer;}
70 elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;}
71 elseif ($module == 'product') { $permission=$user->rights->produit->creer;}
72 //else dol_print_error('','Bad value '.$module.' for param module');
73 
74 if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note.
75 else $typeofdata='textarea:12:95%';
76 
77 print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n";
78 print '<div class="tagtable border table-border centpercent">'."\n";
79 if ($module != 'product') {
80  // No public note yet on products
81  print '<div class="tagtr table-border-row">'."\n";
82  print '<div class="tagtd tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
83  print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0);
84  print '</div>'."\n";
85  print '<div class="tagtd table-val-border-col">'."\n";
86  print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n";
87  print '</div>'."\n";
88  print '</div>'."\n";
89 }
90 if (empty($user->societe_id)) {
91  print '<div class="tagtr table-border-row">'."\n";
92  print '<div class="tagtd tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n";
93  print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0);
94  print '</div>'."\n";
95  print '<div class="tagtd table-val-border-col">'."\n";
96  print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1);
97  print '</div>'."\n";
98  print '</div>'."\n";
99 }
100 print '</div>'."\n";
101 ?>
102 <!-- END PHP TEMPLATE NOTES-->
dol_concatdesc($text1, $text2, $forxml=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
dol_textishtml($msg, $option=0)
Return if a text is a html content.