note.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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->rights->produit->creer || $user->rights->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. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  62. if ($reshook < 0) {
  63. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  64. }
  65. if (empty($reshook)) {
  66. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  67. }
  68. /*
  69. * View
  70. */
  71. $form = new Form($db);
  72. $help_url = '';
  73. if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
  74. $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
  75. }
  76. if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
  77. $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
  78. }
  79. $title = $langs->trans('ProductServiceCard');
  80. $shortlabel = dol_trunc($object->label, 16);
  81. if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
  82. $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Notes');
  83. $help_url = 'EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos|DE:Modul_Produkte';
  84. }
  85. if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
  86. $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Notes');
  87. $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios|DE:Modul_Leistungen';
  88. }
  89. llxHeader('', $title, $help_url);
  90. if ($id > 0 || !empty($ref)) {
  91. /*
  92. * Affichage onglets
  93. */
  94. if (isModEnabled('notification')) {
  95. $langs->load("mails");
  96. }
  97. $head = product_prepare_head($object);
  98. $titre = $langs->trans("CardProduct".$object->type);
  99. $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
  100. print dol_get_fiche_head($head, 'note', $titre, -1, $picto);
  101. $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  102. $object->next_prev_filter = " fk_product_type = ".$object->type;
  103. $shownav = 1;
  104. if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
  105. $shownav = 0;
  106. }
  107. dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
  108. $cssclass = 'titlefield';
  109. //if ($action == 'editnote_public') $cssclass='titlefieldcreate';
  110. //if ($action == 'editnote_private') $cssclass='titlefieldcreate';
  111. //print '<div class="fichecenter">';
  112. print '<div class="underbanner clearboth"></div>';
  113. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  114. print dol_get_fiche_end();
  115. }
  116. // End of page
  117. llxFooter();
  118. $db->close();