myobject_note.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) ---Put here your own copyright and developer email---
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/modulebuilder/template/myobject_note.php
  20. * \ingroup mymodule
  21. * \brief Car with notes on MyObject
  22. */
  23. // Load Dolibarr environment
  24. $res = 0;
  25. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  26. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
  27. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  28. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
  29. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
  30. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
  31. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
  32. // Try main.inc.php using relative path
  33. if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
  34. if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
  35. if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
  36. if (!$res) die("Include of main fails");
  37. dol_include_once('/mymodule/class/myobject.class.php');
  38. dol_include_once('/mymodule/lib/mymodule_myobject.lib.php');
  39. // Load translation files required by the page
  40. $langs->loadLangs(array("mymodule@mymodule", "companies"));
  41. // Get parameters
  42. $id = GETPOST('id', 'int');
  43. $ref = GETPOST('ref', 'alpha');
  44. $action = GETPOST('action', 'alpha');
  45. $cancel = GETPOST('cancel', 'aZ09');
  46. $backtopage = GETPOST('backtopage', 'alpha');
  47. // Initialize technical objects
  48. $object = new MyObject($db);
  49. $extrafields = new ExtraFields($db);
  50. $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
  51. $hookmanager->initHooks(array('myobjectnote', 'globalcard')); // Note that conf->hooks_modules contains array
  52. // Fetch optionals attributes and labels
  53. $extrafields->fetch_name_optionals_label($object->table_element);
  54. // Security check - Protection if external user
  55. //if ($user->socid > 0) accessforbidden();
  56. //if ($user->socid > 0) $socid = $user->socid;
  57. //$result = restrictedArea($user, 'mymodule', $id);
  58. // Load object
  59. 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
  60. if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id;
  61. $permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php
  62. $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php
  63. /*
  64. * Actions
  65. */
  66. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  67. /*
  68. * View
  69. */
  70. $form = new Form($db);
  71. //$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
  72. $help_url = '';
  73. llxHeader('', $langs->trans('MyObject'), $help_url);
  74. if ($id > 0 || !empty($ref))
  75. {
  76. $object->fetch_thirdparty();
  77. $head = myobjectPrepareHead($object);
  78. dol_fiche_head($head, 'note', $langs->trans("MyObject"), -1, $object->picto);
  79. // Object card
  80. // ------------------------------------------------------------
  81. $linkback = '<a href="'.dol_buildpath('/mymodule/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  82. $morehtmlref = '<div class="refidno">';
  83. /*
  84. // Ref customer
  85. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  86. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  87. // Thirdparty
  88. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
  89. // Project
  90. if (! empty($conf->projet->enabled))
  91. {
  92. $langs->load("projects");
  93. $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
  94. if ($permissiontoadd)
  95. {
  96. if ($action != 'classify')
  97. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  98. $morehtmlref.=' : ';
  99. if ($action == 'classify') {
  100. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  101. $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  102. $morehtmlref.='<input type="hidden" name="action" value="classin">';
  103. $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
  104. $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  105. $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  106. $morehtmlref.='</form>';
  107. } else {
  108. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  109. }
  110. } else {
  111. if (! empty($object->fk_project)) {
  112. $proj = new Project($db);
  113. $proj->fetch($object->fk_project);
  114. $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
  115. $morehtmlref.=$proj->ref;
  116. $morehtmlref.='</a>';
  117. } else {
  118. $morehtmlref.='';
  119. }
  120. }
  121. }*/
  122. $morehtmlref .= '</div>';
  123. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  124. print '<div class="fichecenter">';
  125. print '<div class="underbanner clearboth"></div>';
  126. $cssclass = "titlefield";
  127. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  128. print '</div>';
  129. dol_fiche_end();
  130. }
  131. // End of page
  132. llxFooter();
  133. $db->close();