mo_note.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file mo_note.php
  19. * \ingroup mrp
  20. * \brief Card with notes on Mo
  21. */
  22. // Load Dolibarr environment
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  26. dol_include_once('/mrp/class/mo.class.php');
  27. dol_include_once('/mrp/lib/mrp_mo.lib.php');
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("mrp", "companies"));
  30. // Get parameters
  31. $id = GETPOST('id', 'int');
  32. $ref = GETPOST('ref', 'alpha');
  33. $action = GETPOST('action', 'aZ09');
  34. $cancel = GETPOST('cancel', 'aZ09');
  35. $backtopage = GETPOST('backtopage', 'alpha');
  36. // Initialize technical objects
  37. $object = new Mo($db);
  38. $extrafields = new ExtraFields($db);
  39. $diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
  40. $hookmanager->initHooks(array('monote', 'globalcard')); // Note that conf->hooks_modules contains array
  41. // Fetch optionals attributes and labels
  42. $extrafields->fetch_name_optionals_label($object->table_element);
  43. // Load object
  44. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
  45. if ($id > 0 || !empty($ref)) {
  46. $upload_dir = $conf->mrp->multidir_output[empty($object->entity) ? $conf->entity : $object->entity]."/".$object->id;
  47. }
  48. // Security check - Protection if external user
  49. //if ($user->socid > 0) accessforbidden();
  50. //if ($user->socid > 0) $socid = $user->socid;
  51. $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  52. $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'rowid', $isdraft);
  53. $permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php
  54. /*
  55. * Actions
  56. */
  57. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  58. if ($reshook < 0) {
  59. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  60. }
  61. if (empty($reshook)) {
  62. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  63. }
  64. /*
  65. * View
  66. */
  67. $form = new Form($db);
  68. $formproject = new FormProjets($db);
  69. //$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
  70. $help_url = '';
  71. llxHeader('', $langs->trans('Mo'), $help_url);
  72. if ($id > 0 || !empty($ref)) {
  73. $object->fetch_thirdparty();
  74. $head = moPrepareHead($object);
  75. print dol_get_fiche_head($head, 'note', $langs->trans("ManufacturingOrder"), -1, $object->picto);
  76. // Object card
  77. // ------------------------------------------------------------
  78. $linkback = '<a href="'.dol_buildpath('/mrp/mo_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  79. $morehtmlref = '<div class="refidno">';
  80. // Ref customer
  81. //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  82. //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  83. // Thirdparty
  84. if (is_object($object->thirdparty)) {
  85. $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer');
  86. if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
  87. $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
  88. }
  89. }
  90. // Project
  91. if (isModEnabled('project')) {
  92. $langs->load("projects");
  93. if (is_object($object->thirdparty)) {
  94. $morehtmlref .= '<br>';
  95. }
  96. if (0) {
  97. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  98. if ($action != 'classify') {
  99. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  100. }
  101. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  102. } else {
  103. if (!empty($object->fk_project)) {
  104. $proj = new Project($db);
  105. $proj->fetch($object->fk_project);
  106. $morehtmlref .= $proj->getNomUrl(1);
  107. if ($proj->title) {
  108. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  109. }
  110. }
  111. }
  112. }
  113. $morehtmlref .= '</div>';
  114. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  115. print '<div class="fichecenter">';
  116. print '<div class="underbanner clearboth"></div>';
  117. $cssclass = "titlefield";
  118. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  119. print '</div>';
  120. print dol_get_fiche_end();
  121. }
  122. // End of page
  123. llxFooter();
  124. $db->close();