agenda.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
  7. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/societe/agenda.php
  25. * \ingroup societe
  26. * \brief Page of third party events
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  32. $langs->load("companies");
  33. if (GETPOST('actioncode','array'))
  34. {
  35. $actioncode=GETPOST('actioncode','array',3);
  36. if (! count($actioncode)) $actioncode='0';
  37. }
  38. else
  39. {
  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. // Security check
  44. $socid = GETPOST('socid','int');
  45. if ($user->societe_id) $socid=$user->societe_id;
  46. $result = restrictedArea($user, 'societe', $socid, '&societe');
  47. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  48. $sortfield = GETPOST("sortfield",'alpha');
  49. $sortorder = GETPOST("sortorder",'alpha');
  50. $page = GETPOST("page",'int');
  51. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  52. $offset = $limit * $page;
  53. $pageprev = $page - 1;
  54. $pagenext = $page + 1;
  55. if (! $sortfield) $sortfield='a.datep,a.id';
  56. if (! $sortorder) $sortorder='DESC,DESC';
  57. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  58. $hookmanager->initHooks(array('agendathirdparty'));
  59. /*
  60. * Actions
  61. */
  62. $parameters=array('id'=>$socid);
  63. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  64. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  65. if (empty($reshook))
  66. {
  67. // Cancel
  68. if (GETPOST('cancel','alpha') && ! empty($backtopage))
  69. {
  70. header("Location: ".$backtopage);
  71. exit;
  72. }
  73. // Purge search criteria
  74. 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
  75. {
  76. $actioncode='';
  77. $search_agenda_label='';
  78. }
  79. }
  80. /*
  81. * View
  82. */
  83. $form = new Form($db);
  84. if ($socid > 0)
  85. {
  86. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  87. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  88. $langs->load("companies");
  89. $object = new Societe($db);
  90. $result = $object->fetch($socid);
  91. $title=$langs->trans("Agenda");
  92. if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
  93. llxHeader('',$title);
  94. if (! empty($conf->notification->enabled)) $langs->load("mails");
  95. $head = societe_prepare_head($object);
  96. dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company');
  97. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  98. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
  99. print '<div class="fichecenter">';
  100. print '<div class="underbanner clearboth"></div>';
  101. $object->info($socid);
  102. print dol_print_object_info($object, 1);
  103. print '</div>';
  104. dol_fiche_end();
  105. // Actions buttons
  106. $objthirdparty=$object;
  107. $objcon=new stdClass();
  108. $out='';
  109. $permok=$user->rights->agenda->myactions->create;
  110. if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
  111. {
  112. //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
  113. if (get_class($objthirdparty) == 'Societe') $out.='&amp;socid='.$objthirdparty->id;
  114. $out.=(! empty($objcon->id)?'&amp;contactid='.$objcon->id:'').'&amp;backtopage=1&amp;percentage=-1';
  115. //$out.=$langs->trans("AddAnAction").' ';
  116. //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
  117. //$out.="</a>";
  118. }
  119. //print '<div class="tabsAction">';
  120. //print '</div>';
  121. $newcardbutton='';
  122. if (! empty($conf->agenda->enabled))
  123. {
  124. if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
  125. {
  126. $newcardbutton.='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'"><span class="valignmiddle">'.$langs->trans("AddAction").'</span>';
  127. $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
  128. $newcardbutton.= '</a>';
  129. }
  130. }
  131. if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
  132. {
  133. print '<br>';
  134. $param='&socid='.$socid;
  135. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  136. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  137. print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, '');
  138. //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
  139. // List of all actions
  140. $filters=array();
  141. $filters['search_agenda_label']=$search_agenda_label;
  142. // TODO Replace this with same code than into list.php
  143. show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
  144. }
  145. }
  146. // End of page
  147. llxFooter();
  148. $db->close();