dolibarr  16.0.5
agenda.php
Go to the documentation of this file.
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-2019 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 <https://www.gnu.org/licenses/>.
22  */
23 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
34 
35 $langs->loadLangs(array("companies", "bills", "propal", "orders"));
36 
37 if (GETPOST('actioncode', 'array')) {
38  $actioncode = GETPOST('actioncode', 'array', 3);
39  if (!count($actioncode)) {
40  $actioncode = '0';
41  }
42 } else {
43  $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));
44 }
45 $search_agenda_label = GETPOST('search_agenda_label');
46 
47 // Security check
48 $socid = GETPOST('socid', 'int');
49 if ($user->socid) {
50  $socid = $user->socid;
51 }
52 $result = restrictedArea($user, 'societe', $socid, '&societe');
53 
54 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
55 $sortfield = GETPOST('sortfield', 'aZ09comma');
56 $sortorder = GETPOST('sortorder', 'aZ09comma');
57 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
58 if (empty($page) || $page == -1) {
59  $page = 0;
60 } // If $page is not defined, or '' or -1
61 $offset = $limit * $page;
62 $pageprev = $page - 1;
63 $pagenext = $page + 1;
64 if (!$sortfield) {
65  $sortfield = 'a.datep,a.id';
66 }
67 if (!$sortorder) {
68  $sortorder = 'DESC,DESC';
69 }
70 
71 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
72 $hookmanager->initHooks(array('agendathirdparty'));
73 
74 
75 /*
76  * Actions
77  */
78 
79 $parameters = array('id'=>$socid);
80 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
81 if ($reshook < 0) {
82  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
83 }
84 
85 if (empty($reshook)) {
86  // Cancel
87  if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
88  header("Location: ".$backtopage);
89  exit;
90  }
91 
92  // Purge search criteria
93  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
94  $actioncode = '';
95  $search_agenda_label = '';
96  }
97 }
98 
99 
100 
101 /*
102  * View
103  */
104 
105 $form = new Form($db);
106 
107 if ($socid > 0) {
108  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
109  require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
110 
111  $object = new Societe($db);
112  $result = $object->fetch($socid);
113 
114  $title = $langs->trans("Agenda");
115  if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
116  $title = $object->name." - ".$title;
117  }
118  llxHeader('', $title);
119 
120  if (!empty($conf->notification->enabled)) {
121  $langs->load("mails");
122  }
123  $head = societe_prepare_head($object);
124 
125  print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company');
126 
127  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
128 
129  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
130 
131  print '<div class="fichecenter">';
132 
133  print '<div class="underbanner clearboth"></div>';
134 
135  $object->info($socid);
136  dol_print_object_info($object, 1);
137 
138  print '</div>';
139 
140  print dol_get_fiche_end();
141 
142 
143 
144  // Actions buttons
145 
146  $objthirdparty = $object;
147  $objcon = new stdClass();
148 
149  $out = '';
150  $permok = $user->hasRight('agenda', 'myactions', 'create');
151  if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
152  if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') {
153  $out .= '&amp;originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&amp;socid='.$objthirdparty->id : '').'&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
154  }
155  $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;percentage=-1';
156  $out .= '&amp;datep='.dol_print_date(dol_now(), 'dayhourlog');
157  }
158 
159  $newcardbutton = '';
160  if (isModEnabled('agenda')) {
161  if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
162  $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
163  }
164  }
165 
166  if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
167  print '<br>';
168 
169  $param = '&socid='.urlencode($socid);
170  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
171  $param .= '&contextpage='.urlencode($contextpage);
172  }
173  if ($limit > 0 && $limit != $conf->liste_limit) {
174  $param .= '&limit='.urlencode($limit);
175  }
176 
177  print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, '');
178  //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
179 
180  // List of all actions
181  $filters = array();
182  $filters['search_agenda_label'] = $search_agenda_label;
183 
184  // TODO Replace this with same code than into list.php
185  show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
186  }
187 }
188 
189 // End of page
190 llxFooter();
191 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
show_actions_done
show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
Definition: company.lib.php:1389
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
societe_prepare_head
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_print_object_info
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
Definition: functions2.lib.php:205
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59