note.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  7. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/product/note.php
  24. * \brief Tab for notes on products
  25. * \ingroup societe
  26. */
  27. // Load Dolibarr environment
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  31. // Load translation files required by the page
  32. $langs->load("companies");
  33. $id = GETPOST('id', 'int');
  34. $ref = GETPOST('ref', 'alpha');
  35. $action = GETPOST('action', 'aZ09');
  36. // Security check
  37. $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
  38. $fieldtype = (!empty($ref) ? 'ref' : 'rowid');
  39. if ($user->socid) {
  40. $socid = $user->socid;
  41. }
  42. $object = new Product($db);
  43. if ($id > 0 || !empty($ref)) {
  44. $object->fetch($id, $ref);
  45. }
  46. $permissionnote = ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')); // Used by the include of actions_setnotes.inc.php
  47. if ($object->id > 0) {
  48. if ($object->type == $object::TYPE_PRODUCT) {
  49. restrictedArea($user, 'product', $object->id, 'product&product', '', '');
  50. }
  51. if ($object->type == $object::TYPE_SERVICE) {
  52. restrictedArea($user, 'service', $object->id, 'product&product', '', '');
  53. }
  54. } else {
  55. restrictedArea($user, 'product|service', $fieldvalue, 'product&product', '', '', $fieldtype);
  56. }
  57. $hookmanager->initHooks(array('productnote'));
  58. /*
  59. * Actions
  60. */
  61. $parameters = array();
  62. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  63. if ($reshook < 0) {
  64. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  65. }
  66. if (empty($reshook)) {
  67. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  68. }
  69. /*
  70. * View
  71. */
  72. $form = new Form($db);
  73. $help_url = '';
  74. if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
  75. $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
  76. }
  77. if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
  78. $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
  79. }
  80. $title = $langs->trans('ProductServiceCard');
  81. $shortlabel = dol_trunc($object->label, 16);
  82. if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
  83. $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Notes');
  84. $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
  85. }
  86. if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
  87. $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Notes');
  88. $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
  89. }
  90. llxHeader('', $title, $help_url);
  91. if ($id > 0 || !empty($ref)) {
  92. /*
  93. * Affichage onglets
  94. */
  95. if (isModEnabled('notification')) {
  96. $langs->load("mails");
  97. }
  98. $head = product_prepare_head($object);
  99. $titre = $langs->trans("CardProduct".$object->type);
  100. $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
  101. print dol_get_fiche_head($head, 'note', $titre, -1, $picto);
  102. $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  103. $object->next_prev_filter = " fk_product_type = ".$object->type;
  104. $shownav = 1;
  105. if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
  106. $shownav = 0;
  107. }
  108. dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
  109. $cssclass = 'titlefield';
  110. //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
  111. //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
  112. //print '<div class="fichecenter">';
  113. print '<div class="underbanner clearboth"></div>';
  114. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  115. print dol_get_fiche_end();
  116. }
  117. // End of page
  118. llxFooter();
  119. $db->close();