evaluation_agenda.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  4. * Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
  5. * Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
  6. * Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/hrm/evaluation_agenda.php
  23. * \ingroup hrm
  24. * \brief Tab of events on Evaluation
  25. */
  26. // Load Dolibarr environment
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/hrm/class/evaluation.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_evaluation.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/hrm/class/job.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array('hrm', 'other'));
  36. // Get parameters
  37. $id = GETPOST('id', 'int');
  38. $ref = GETPOST('ref', 'alpha');
  39. $action = GETPOST('action', 'aZ09');
  40. $cancel = GETPOST('cancel', 'aZ09');
  41. $backtopage = GETPOST('backtopage', 'alpha');
  42. if (GETPOST('actioncode', 'array')) {
  43. $actioncode = GETPOST('actioncode', 'array', 3);
  44. if (!count($actioncode)) {
  45. $actioncode = '0';
  46. }
  47. } else {
  48. $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
  49. }
  50. $search_rowid = GETPOST('search_rowid');
  51. $search_agenda_label = GETPOST('search_agenda_label');
  52. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  53. $sortfield = GETPOST('sortfield', 'aZ09comma');
  54. $sortorder = GETPOST('sortorder', 'aZ09comma');
  55. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  56. if (empty($page) || $page == -1) {
  57. $page = 0;
  58. } // If $page is not defined, or '' or -1
  59. $offset = $limit * $page;
  60. $pageprev = $page - 1;
  61. $pagenext = $page + 1;
  62. if (!$sortfield) {
  63. $sortfield = 'a.datep,a.id';
  64. }
  65. if (!$sortorder) {
  66. $sortorder = 'DESC,DESC';
  67. }
  68. // Initialize technical objects
  69. $object = new Evaluation($db);
  70. $extrafields = new ExtraFields($db);
  71. $diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
  72. $hookmanager->initHooks(array('evaluationagenda', 'globalcard')); // Note that conf->hooks_modules contains array
  73. // Fetch optionals attributes and labels
  74. $extrafields->fetch_name_optionals_label($object->table_element);
  75. // Load object
  76. 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
  77. if ($id > 0 || !empty($ref)) {
  78. $upload_dir = $conf->hrm->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
  79. }
  80. // Permissions
  81. $permissiontoadd = $user->rights->hrm->evaluation->write; // Used by the include of actions_addupdatedelete.inc.php
  82. $permissiontoread = $user->rights->hrm->evaluation->read; // Used by the include of actions_addupdatedelete.inc.php
  83. // Security check (enable the most restrictive one)
  84. //if ($user->socid > 0) accessforbidden();
  85. //if ($user->socid > 0) $socid = $user->socid;
  86. //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  87. //restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
  88. if (!isModEnabled('hrm')) {
  89. accessforbidden();
  90. }
  91. if (!$permissiontoread) {
  92. accessforbidden();
  93. }
  94. /*
  95. * Actions
  96. */
  97. $parameters = array('id'=>$id);
  98. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  99. if ($reshook < 0) {
  100. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  101. }
  102. if (empty($reshook)) {
  103. // Cancel
  104. if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
  105. header("Location: ".$backtopage);
  106. exit;
  107. }
  108. // Purge search criteria
  109. 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
  110. $actioncode = '';
  111. $search_agenda_label = '';
  112. }
  113. }
  114. /*
  115. * View
  116. */
  117. $form = new Form($db);
  118. if ($object->id > 0) {
  119. $title = $langs->trans("Agenda");
  120. //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
  121. $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
  122. llxHeader('', $title, $help_url);
  123. if (isModEnabled('notification')) {
  124. $langs->load("mails");
  125. }
  126. $head = evaluationPrepareHead($object);
  127. print dol_get_fiche_head($head, 'agenda', $langs->trans("Agenda"), -1, $object->picto);
  128. // Object card
  129. // ------------------------------------------------------------
  130. $linkback = '<a href="'.dol_buildpath('/hrm/evaluation_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  131. $morehtmlref = '<div class="refidno">';
  132. $morehtmlref .= $langs->trans('Label').' : '.$object->label;
  133. $u_position = new User(($db));
  134. $u_position->fetch($object->fk_user);
  135. $morehtmlref .= '<br>'.$u_position->getNomUrl(1);
  136. $job = new Job($db);
  137. $job->fetch($object->fk_job);
  138. $morehtmlref .= '<br>'.$langs->trans('JobProfile').' : '.$job->getNomUrl(1);
  139. $morehtmlref .= '</div>';
  140. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  141. print '<div class="fichecenter">';
  142. print '<div class="underbanner clearboth"></div>';
  143. $object->info($object->id);
  144. dol_print_object_info($object, 1);
  145. print '</div>';
  146. print dol_get_fiche_end();
  147. // Actions buttons
  148. $objthirdparty = $object;
  149. $objcon = new stdClass();
  150. $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id);
  151. $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
  152. $out .= '&backtopage='.urlencode($urlbacktopage);
  153. $permok = $user->hasRight('agenda', 'myactions', 'create');
  154. if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
  155. //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
  156. if (get_class($objthirdparty) == 'Societe') {
  157. $out .= '&socid='.urlencode($objthirdparty->id);
  158. }
  159. $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '');
  160. //$out.=$langs->trans("AddAnAction").' ';
  161. //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
  162. //$out.="</a>";
  163. }
  164. $morehtmlright = '';
  165. //$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id;
  166. //$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
  167. //$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
  168. //$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
  169. if (isModEnabled('agenda')) {
  170. if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
  171. $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
  172. } else {
  173. $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0);
  174. }
  175. }
  176. if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
  177. print '<br>';
  178. $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : '');
  179. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  180. $param .= '&contextpage='.urlencode($contextpage);
  181. }
  182. if ($limit > 0 && $limit != $conf->liste_limit) {
  183. $param .= '&limit='.((int) $limit);
  184. }
  185. //print load_fiche_titre($langs->trans("ActionsOnMyObject"), '', '');
  186. print_barre_liste($langs->trans("Actions"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
  187. // List of all actions
  188. $filters = array();
  189. $filters['search_agenda_label'] = $search_agenda_label;
  190. $filters['search_rowid'] = $search_rowid;
  191. // TODO Replace this with same code than into list.php
  192. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
  193. }
  194. }
  195. // End of page
  196. llxFooter();
  197. $db->close();