agenda.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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/product/agenda.php
  25. * \ingroup product
  26. * \brief Page of product 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. require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
  33. // Load translation files required by the page
  34. $langs->load("companies");
  35. if (GETPOST('actioncode','array'))
  36. {
  37. $actioncode=GETPOST('actioncode','array',3);
  38. if (! count($actioncode)) $actioncode='0';
  39. }
  40. else
  41. {
  42. $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));
  43. }
  44. $search_agenda_label=GETPOST('search_agenda_label');
  45. // Security check
  46. $id = GETPOST('id','int');
  47. $ref = GETPOST('ref', 'alpha');
  48. if ($user->societe_id) $id=$user->societe_id;
  49. $result=restrictedArea($user,'produit|service',$id,'product&product');
  50. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  51. $sortfield = GETPOST("sortfield",'alpha');
  52. $sortorder = GETPOST("sortorder",'alpha');
  53. $page = GETPOST("page",'int');
  54. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  55. $offset = $limit * $page;
  56. $pageprev = $page - 1;
  57. $pagenext = $page + 1;
  58. if (! $sortfield) $sortfield='a.datep,a.id';
  59. if (! $sortorder) $sortorder='DESC,DESC';
  60. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  61. $hookmanager->initHooks(array('agendathirdparty'));
  62. /*
  63. * Actions
  64. */
  65. $parameters=array('id'=>$id);
  66. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  67. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  68. if (empty($reshook))
  69. {
  70. // Cancel
  71. if (GETPOST('cancel','alpha') && ! empty($backtopage))
  72. {
  73. header("Location: ".$backtopage);
  74. exit;
  75. }
  76. // Purge search criteria
  77. 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
  78. {
  79. $actioncode='';
  80. $search_agenda_label='';
  81. }
  82. }
  83. /*
  84. * View
  85. */
  86. $contactstatic = new Contact($db);
  87. $form = new Form($db);
  88. if ($id > 0 || $ref)
  89. {
  90. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  91. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  92. $langs->load("companies");
  93. $object = new Product($db);
  94. $result = $object->fetch($id, $ref);
  95. $title=$langs->trans("Agenda");
  96. if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
  97. llxHeader('',$title);
  98. if (! empty($conf->notification->enabled)) $langs->load("mails");
  99. $type = $langs->trans('Product');
  100. if ($object->isService()) $type = $langs->trans('Service');
  101. $head = product_prepare_head($object);
  102. $titre=$langs->trans("CardProduct".$object->type);
  103. $picto=($object->type== Product::TYPE_SERVICE?'service':'product');
  104. dol_fiche_head($head, 'agenda', $titre, -1, $picto);
  105. $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  106. $object->next_prev_filter=" fk_product_type = ".$object->type;
  107. $shownav = 1;
  108. if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
  109. dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
  110. print '<div class="fichecenter">';
  111. print '<div class="underbanner clearboth"></div>';
  112. $object->info($object->id);
  113. print dol_print_object_info($object, 1);
  114. print '</div>';
  115. dol_fiche_end();
  116. // Actions buttons
  117. $objproduct=$object;
  118. $objcon=new stdClass();
  119. $out='';
  120. $permok=$user->rights->agenda->myactions->create;
  121. if ((! empty($objproduct->id) || ! empty($objcon->id)) && $permok)
  122. {
  123. //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
  124. if (get_class($objproduct) == 'Product') $out.='&amp;prodid='.$objproduct->id.'&origin=product&originid='.$id;
  125. $out.=(! empty($objcon->id)?'&amp;contactid='.$objcon->id:'').'&amp;backtopage=1&amp;percentage=-1';
  126. //$out.=$langs->trans("AddAnAction").' ';
  127. //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
  128. //$out.="</a>";
  129. }
  130. //print '<div class="tabsAction">';
  131. //print '</div>';
  132. $morehtmlcenter='';
  133. if (! empty($conf->agenda->enabled))
  134. {
  135. if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
  136. {
  137. $morehtmlcenter.='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'<span class="fa fa-plus-circle valignmiddle"></span></a>';
  138. }
  139. else
  140. {
  141. $morehtmlcenter.='<a class="butActionNewRefused" href="#">'.$langs->trans("AddAction").'<span class="fa fa-plus-circle valignmiddle"></span></a>';
  142. }
  143. }
  144. if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
  145. {
  146. print '<br>';
  147. $param='&id='.$id;
  148. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  149. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  150. print_barre_liste($langs->trans("ActionsOnProduct"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
  151. // List of all actions
  152. $filters=array();
  153. $filters['search_agenda_label']=$search_agenda_label;
  154. // TODO Replace this with same code than into list.php
  155. show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
  156. }
  157. }
  158. // End of page
  159. llxFooter();
  160. $db->close();