info.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
  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 htdocs/hrm/establishment/info.php
  19. * \brief Page to show info of an establishment
  20. */
  21. // Load Dolibarr environment
  22. require '../../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
  26. // Load translation files required by the page
  27. $langs->loadLangs(array('admin', 'hrm'));
  28. // Get parameters
  29. $id = GETPOST('id', 'int');
  30. $ref = GETPOST('ref', 'alpha');
  31. $action = GETPOST('action', 'aZ09');
  32. $cancel = GETPOST('cancel', 'aZ09');
  33. $backtopage = GETPOST('backtopage', 'alpha');
  34. if (GETPOST('actioncode', 'array')) {
  35. $actioncode = GETPOST('actioncode', 'array', 3);
  36. if (!count($actioncode)) {
  37. $actioncode = '0';
  38. }
  39. } else {
  40. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
  41. }
  42. $search_agenda_label = GETPOST('search_agenda_label');
  43. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  44. $sortfield = GETPOST('sortfield', 'aZ09comma');
  45. $sortorder = GETPOST('sortorder', 'aZ09comma');
  46. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  47. if (empty($page) || $page == -1) {
  48. $page = 0;
  49. } // If $page is not defined, or '' or -1
  50. $offset = $limit * $page;
  51. $pageprev = $page - 1;
  52. $pagenext = $page + 1;
  53. if (!$sortfield) {
  54. $sortfield = 'a.datep,a.id';
  55. }
  56. if (!$sortorder) {
  57. $sortorder = 'DESC,DESC';
  58. }
  59. // Initialize technical objects
  60. $object = new Establishment($db);
  61. $extrafields = new ExtraFields($db);
  62. $diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
  63. $hookmanager->initHooks(array('hrmagenda', 'globalcard')); // Note that conf->hooks_modules contains array
  64. // Fetch optionals attributes and labels
  65. $extrafields->fetch_name_optionals_label($object->table_element);
  66. // Load object
  67. 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
  68. if ($id > 0 || !empty($ref)) {
  69. $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id;
  70. }
  71. $permissiontoread = $user->admin;
  72. $permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_addupdatedelete.inc.php
  73. $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1];
  74. // Security check - Protection if external user
  75. //if ($user->socid > 0) accessforbidden();
  76. //if ($user->socid > 0) $socid = $user->socid;
  77. //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  78. //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
  79. if (!isModEnabled('hrm')) accessforbidden();
  80. if (empty($permissiontoread)) accessforbidden();
  81. /*
  82. * Actions
  83. */
  84. $parameters = array('id'=>$id);
  85. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  86. if ($reshook < 0) {
  87. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  88. }
  89. if (empty($reshook)) {
  90. // Cancel
  91. if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
  92. header("Location: ".$backtopage);
  93. exit;
  94. }
  95. // Purge search criteria
  96. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  97. $actioncode = '';
  98. $search_agenda_label = '';
  99. }
  100. }
  101. /*
  102. * View
  103. */
  104. $form = new Form($db);
  105. if ($object->id > 0) {
  106. $title = $langs->trans("Agenda");
  107. //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
  108. $help_url = '';
  109. llxHeader('', $title, $help_url);
  110. if (isModEnabled('notification')) {
  111. $langs->load("mails");
  112. }
  113. $head = establishment_prepare_head($object);
  114. print dol_get_fiche_head($head, 'info', $langs->trans("Establishment"), -1, $object->picto);
  115. // Object card
  116. // ------------------------------------------------------------
  117. $linkback = '<a href="'.DOL_URL_ROOT.'/hrm/hrm/myobject_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  118. $morehtmlref = '<div class="refidno">';
  119. /*
  120. // Ref customer
  121. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  122. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  123. // Thirdparty
  124. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
  125. // Project
  126. if (isModEnabled('project'))
  127. {
  128. $langs->load("projects");
  129. $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
  130. if ($permissiontoadd)
  131. {
  132. if ($action != 'classify')
  133. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  134. $morehtmlref.=' : ';
  135. if ($action == 'classify') {
  136. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  137. $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  138. $morehtmlref.='<input type="hidden" name="action" value="classin">';
  139. $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
  140. $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  141. $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  142. $morehtmlref.='</form>';
  143. } else {
  144. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  145. }
  146. } else {
  147. if (!empty($object->fk_project)) {
  148. $proj = new Project($db);
  149. $proj->fetch($object->fk_project);
  150. $morehtmlref .= ': '.$proj->getNomUrl();
  151. } else {
  152. $morehtmlref .= '';
  153. }
  154. }
  155. }*/
  156. $morehtmlref .= '</div>';
  157. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  158. print '<div class="fichecenter">';
  159. print '<div class="underbanner clearboth"></div>';
  160. $object->info($object->id);
  161. dol_print_object_info($object, 1);
  162. print '</div>';
  163. print dol_get_fiche_end();
  164. }
  165. // End of page
  166. llxFooter();
  167. $db->close();