note.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/reception/note.php
  22. * \ingroup receptionsending
  23. * \brief Note card reception
  24. */
  25. // Load Dolibarr environment
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
  29. if (isModEnabled('project')) {
  30. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  32. }
  33. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
  35. $langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal'));
  36. $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
  37. $ref = GETPOST('ref', 'alpha');
  38. $action = GETPOST('action', 'aZ09');
  39. $object = new Reception($db);
  40. if ($id > 0 || !empty($ref)) {
  41. $object->fetch($id, $ref);
  42. $object->fetch_thirdparty();
  43. if (!empty($object->origin)) {
  44. $origin = $object->origin;
  45. $object->fetch_origin();
  46. $typeobject = $object->origin;
  47. }
  48. // Linked documents
  49. if ($origin == 'order_supplier' && $object->$typeobject->id && isModEnabled("supplier_order")) {
  50. $objectsrc = new CommandeFournisseur($db);
  51. $objectsrc->fetch($object->$typeobject->id);
  52. }
  53. }
  54. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  55. $hookmanager->initHooks(array('receptionnote'));
  56. // Security check
  57. if ($user->socid > 0) {
  58. $socid = $user->socid;
  59. }
  60. if (isModEnabled("reception")) {
  61. $permissiontoread = $user->rights->reception->lire;
  62. $permissiontoadd = $user->rights->reception->creer;
  63. $permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php
  64. $permissiontovalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate)));
  65. $permissiontodelete = $user->rights->reception->supprimer;
  66. } else {
  67. $permissiontoread = $user->rights->fournisseur->commande->receptionner;
  68. $permissiontoadd = $user->rights->fournisseur->commande->receptionner;
  69. $permissiondellink = $user->rights->fournisseur->commande->receptionner; // Used by the include of actions_dellink.inc.php
  70. $permissiontovalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande_advance->check)));
  71. $permissiontodelete = $user->rights->fournisseur->commande->receptionner;
  72. }
  73. $permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php
  74. // TODO Test on reception module on only
  75. if ($origin == 'reception') {
  76. $result = restrictedArea($user, $origin, $object->id);
  77. } else {
  78. if ($origin == 'supplierorder' || $origin == 'order_supplier') {
  79. $result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
  80. } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
  81. accessforbidden();
  82. }
  83. }
  84. /*
  85. * Actions
  86. */
  87. $parameters = array();
  88. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  89. if ($reshook < 0) {
  90. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  91. }
  92. if (empty($reshook)) {
  93. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  94. }
  95. /*
  96. * View
  97. */
  98. llxHeader('', $langs->trans('Reception'));
  99. $form = new Form($db);
  100. if ($id > 0 || !empty($ref)) {
  101. $head = reception_prepare_head($object);
  102. print dol_get_fiche_head($head, 'note', $langs->trans("Reception"), -1, 'dollyrevert');
  103. // Reception card
  104. $linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  105. $morehtmlref = '<div class="refidno">';
  106. // Ref customer reception
  107. $morehtmlref .= $form->editfieldkey("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', 0, 1);
  108. $morehtmlref .= $form->editfieldval("RefSupplier", '', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1);
  109. // Thirdparty
  110. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
  111. // Project
  112. if (isModEnabled('project')) {
  113. $langs->load("projects");
  114. $morehtmlref .= '<br>';
  115. if (0) { // Do not change on reception
  116. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  117. if ($action != 'classify' && $permissiontoadd) {
  118. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  119. }
  120. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  121. } else {
  122. if (!empty($objectsrc) && !empty($objectsrc->fk_project)) {
  123. $proj = new Project($db);
  124. $proj->fetch($objectsrc->fk_project);
  125. $morehtmlref .= $proj->getNomUrl(1);
  126. if ($proj->title) {
  127. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  128. }
  129. }
  130. }
  131. }
  132. $morehtmlref .= '</div>';
  133. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  134. print '<div class="underbanner clearboth"></div>';
  135. $cssclass = 'titlefield';
  136. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  137. print dol_get_fiche_end();
  138. }
  139. llxFooter();
  140. $db->close();