skill_agenda.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 skill_agenda.php
  23. * \ingroup hrm
  24. * \brief Tab of events on skill
  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/skill.class.php';
  32. require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_skill.lib.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array("hrm", "other"));
  35. // Get parameters
  36. $id = GETPOST('id', 'int');
  37. $ref = GETPOST('ref', 'alpha');
  38. $action = GETPOST('action', 'aZ09');
  39. $cancel = GETPOST('cancel', 'aZ09');
  40. $backtopage = GETPOST('backtopage', 'alpha');
  41. if (GETPOST('actioncode', 'array')) {
  42. $actioncode = GETPOST('actioncode', 'array', 3);
  43. if (!count($actioncode)) {
  44. $actioncode = '0';
  45. }
  46. } else {
  47. $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));
  48. }
  49. $search_agenda_label = GETPOST('search_agenda_label');
  50. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  51. $sortfield = GETPOST('sortfield', 'aZ09comma');
  52. $sortorder = GETPOST('sortorder', 'aZ09comma');
  53. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  54. if (empty($page) || $page == -1) {
  55. $page = 0;
  56. } // If $page is not defined, or '' or -1
  57. $offset = $limit * $page;
  58. $pageprev = $page - 1;
  59. $pagenext = $page + 1;
  60. if (!$sortfield) {
  61. $sortfield = 'a.datep,a.id';
  62. }
  63. if (!$sortorder) {
  64. $sortorder = 'DESC,DESC';
  65. }
  66. // Initialize technical objects
  67. $object = new Skill($db);
  68. $extrafields = new ExtraFields($db);
  69. $diroutputmassaction = $conf->hrm->dir_output.'/temp/massgeneration/'.$user->id;
  70. $hookmanager->initHooks(array('skillagenda', 'globalcard')); // Note that conf->hooks_modules contains array
  71. // Fetch optionals attributes and labels
  72. $extrafields->fetch_name_optionals_label($object->table_element);
  73. // Load object
  74. 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
  75. if ($id > 0 || !empty($ref)) {
  76. $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id;
  77. }
  78. $permissiontoread = $user->rights->hrm->all->read;
  79. $permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php
  80. // Security check (enable the most restrictive one)
  81. //if ($user->socid > 0) accessforbidden();
  82. //if ($user->socid > 0) $socid = $user->socid;
  83. //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  84. //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
  85. if (empty($conf->hrm->enabled)) accessforbidden();
  86. if (!$permissiontoread) accessforbidden();
  87. /*
  88. * Actions
  89. */
  90. $parameters = array('id'=>$id);
  91. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  92. if ($reshook < 0) {
  93. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  94. }
  95. if (empty($reshook)) {
  96. // Cancel
  97. if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
  98. header("Location: ".$backtopage);
  99. exit;
  100. }
  101. // Purge search criteria
  102. 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
  103. $actioncode = '';
  104. $search_agenda_label = '';
  105. }
  106. }
  107. /*
  108. * View
  109. */
  110. $form = new Form($db);
  111. if ($object->id > 0) {
  112. $title = $langs->trans("Agenda");
  113. //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
  114. $help_url = 'EN:Module_Agenda_En';
  115. llxHeader('', $title, $help_url);
  116. if (!empty($conf->notification->enabled)) {
  117. $langs->load("mails");
  118. }
  119. $head = skillPrepareHead($object);
  120. print dol_get_fiche_head($head, 'agenda', $langs->trans("Agenda"), -1, $object->picto);
  121. // Object card
  122. // ------------------------------------------------------------
  123. $linkback = '<a href="'.DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  124. $morehtmlref = '<div class="refid">';
  125. $morehtmlref.= $object->label;
  126. $morehtmlref .= '</div>';
  127. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
  128. print '<div class="fichecenter">';
  129. print '<div class="underbanner clearboth"></div>';
  130. $object->info($object->id);
  131. dol_print_object_info($object, 1);
  132. print '</div>';
  133. print dol_get_fiche_end();
  134. // Actions buttons
  135. $objthirdparty = $object;
  136. $objcon = new stdClass();
  137. $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id);
  138. $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
  139. $out .= '&backtopage='.urlencode($urlbacktopage);
  140. $permok = $user->rights->agenda->myactions->create;
  141. if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
  142. //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
  143. if (get_class($objthirdparty) == 'Societe') {
  144. $out .= '&socid='.urlencode($objthirdparty->id);
  145. }
  146. $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '').'&percentage=-1';
  147. //$out.=$langs->trans("AddAnAction").' ';
  148. //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
  149. //$out.="</a>";
  150. }
  151. print '<div class="tabsAction">';
  152. if (!empty($conf->agenda->enabled)) {
  153. if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
  154. print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
  155. } else {
  156. print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
  157. }
  158. }
  159. print '</div>';
  160. if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
  161. $param = '&id='.$object->id.'&socid='.$socid;
  162. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  163. $param .= '&contextpage='.urlencode($contextpage);
  164. }
  165. if ($limit > 0 && $limit != $conf->liste_limit) {
  166. $param .= '&limit='.urlencode($limit);
  167. }
  168. //print load_fiche_titre($langs->trans("ActionsOnskill"), '', '');
  169. // List of all actions
  170. $filters = array();
  171. $filters['search_agenda_label'] = $search_agenda_label;
  172. // TODO Replace this with same code than into list.php
  173. show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
  174. }
  175. }
  176. // End of page
  177. llxFooter();
  178. $db->close();