notes.tpl.php 6.6 KB

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