dolibarr  13.0.2
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 {
39  $actioncode = GETPOST('actioncode', 'array', 3);
40  if (!count($actioncode)) $actioncode = '0';
41 } else {
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 
46 // Security check
47 $socid = GETPOST('socid', 'int');
48 if ($user->socid) $socid = $user->socid;
49 $result = restrictedArea($user, 'societe', $socid, '&societe');
50 
51 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
52 $sortfield = GETPOST("sortfield", 'alpha');
53 $sortorder = GETPOST("sortorder", 'alpha');
54 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
55 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (!$sortfield) $sortfield = 'a.datep,a.id';
60 if (!$sortorder) $sortorder = 'DESC,DESC';
61 
62 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
63 $hookmanager->initHooks(array('agendathirdparty'));
64 
65 
66 /*
67  * Actions
68  */
69 
70 $parameters = array('id'=>$socid);
71 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
72 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
73 
74 if (empty($reshook))
75 {
76  // Cancel
77  if (GETPOST('cancel', 'alpha') && !empty($backtopage))
78  {
79  header("Location: ".$backtopage);
80  exit;
81  }
82 
83  // Purge search criteria
84  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
85  {
86  $actioncode = '';
87  $search_agenda_label = '';
88  }
89 }
90 
91 
92 
93 /*
94  * View
95  */
96 
97 $form = new Form($db);
98 
99 if ($socid > 0)
100 {
101  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
102  require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
103 
104  $object = new Societe($db);
105  $result = $object->fetch($socid);
106 
107  $title = $langs->trans("Agenda");
108  if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
109  llxHeader('', $title);
110 
111  if (!empty($conf->notification->enabled)) $langs->load("mails");
112  $head = societe_prepare_head($object);
113 
114  print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company');
115 
116  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
117 
118  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
119 
120  print '<div class="fichecenter">';
121 
122  print '<div class="underbanner clearboth"></div>';
123 
124  $object->info($socid);
125  dol_print_object_info($object, 1);
126 
127  print '</div>';
128 
130 
131 
132 
133  // Actions buttons
134 
135  $objthirdparty = $object;
136  $objcon = new stdClass();
137 
138  $out = '';
139  $permok = $user->rights->agenda->myactions->create;
140  if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
141  {
142  if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&amp;originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&amp;socid='.$objthirdparty->id : '').'&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
143  $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;percentage=-1';
144  $out .= '&amp;datep='.dol_print_date(dol_now(), 'dayhourlog');
145  }
146 
147  $newcardbutton = '';
148  if (!empty($conf->agenda->enabled))
149  {
150  if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
151  {
152  $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
153  }
154  }
155 
156  if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
157  {
158  print '<br>';
159 
160  $param = '&socid='.$socid;
161  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
162  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
163 
164  print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, '');
165  //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
166 
167  // List of all actions
168  $filters = array();
169  $filters['search_agenda_label'] = $search_agenda_label;
170 
171  // TODO Replace this with same code than into list.php
172  show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
173  }
174 }
175 
176 // End of page
177 llxFooter();
178 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
dol_now($mode= 'auto')
Return date for now.
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
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).
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59