info.php 7.3 KB

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