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-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 <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 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
35 
36 // Load translation files required by the page
37 $langs->load("companies");
38 
39 if (GETPOST('actioncode', 'array'))
40 {
41  $actioncode = GETPOST('actioncode', 'array', 3);
42  if (!count($actioncode)) $actioncode = '0';
43 } else {
44  $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));
45 }
46 $search_agenda_label = GETPOST('search_agenda_label');
47 
48 // Security check
49 $id = GETPOST('id', 'int');
50 $ref = GETPOST('ref', 'alpha');
51 if ($user->socid) $id = $user->socid;
52 $result = restrictedArea($user, 'produit|service', $id, 'product&product');
53 
54 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
55 $sortfield = GETPOST("sortfield", 'alpha');
56 $sortorder = GETPOST("sortorder", 'alpha');
57 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
58 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
59 $offset = $limit * $page;
60 $pageprev = $page - 1;
61 $pagenext = $page + 1;
62 if (!$sortfield) $sortfield = 'a.datep,a.id';
63 if (!$sortorder) $sortorder = 'DESC,DESC';
64 
65 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
66 $hookmanager->initHooks(array('agendathirdparty'));
67 
68 
69 /*
70  * Actions
71  */
72 
73 $parameters = array('id'=>$id);
74 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
75 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
76 
77 if (empty($reshook))
78 {
79  // Cancel
80  if (GETPOST('cancel', 'alpha') && !empty($backtopage))
81  {
82  header("Location: ".$backtopage);
83  exit;
84  }
85 
86  // Purge search criteria
87  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
88  {
89  $actioncode = '';
90  $search_agenda_label = '';
91  }
92 }
93 
94 
95 
96 /*
97  * View
98  */
99 
100 $contactstatic = new Contact($db);
101 
102 $form = new Form($db);
103 
104 if ($id > 0 || $ref)
105 {
106  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
107  require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
108 
109  $langs->load("companies");
110 
111 
112  $object = new Product($db);
113  $result = $object->fetch($id, $ref);
114 
115  $title = $langs->trans("Agenda");
116  if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
117  llxHeader('', $title);
118 
119  if (!empty($conf->notification->enabled)) $langs->load("mails");
120  $type = $langs->trans('Product');
121  if ($object->isService()) $type = $langs->trans('Service');
122 
123  $head = product_prepare_head($object);
124 
125  $titre = $langs->trans("CardProduct".$object->type);
126  $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
127  print dol_get_fiche_head($head, 'agenda', $titre, -1, $picto);
128 
129  $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
130  $object->next_prev_filter = " fk_product_type = ".$object->type;
131 
132  $shownav = 1;
133  if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
134 
135  dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
136 
137  print '<div class="fichecenter">';
138 
139  print '<div class="underbanner clearboth"></div>';
140 
141  $object->info($object->id);
142  dol_print_object_info($object, 1);
143 
144  print '</div>';
145 
147 
148 
149 
150  // Actions buttons
151 
152  $objproduct = $object;
153  $objcon = new stdClass();
154 
155  $out = '';
156  $permok = $user->rights->agenda->myactions->create;
157  if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok)
158  {
159  //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
160  if (get_class($objproduct) == 'Product') $out .= '&amp;prodid='.$objproduct->id.'&origin=product&originid='.$id;
161  $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1';
162  //$out.=$langs->trans("AddAnAction").' ';
163  //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
164  //$out.="</a>";
165  }
166 
167 
168  //print '<div class="tabsAction">';
169  //print '</div>';
170 
171 
172  $morehtmlcenter = '';
173  if (!empty($conf->agenda->enabled))
174  {
175  $linktocreatetimeBtnStatus = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create);
176  $morehtmlcenter = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', $linktocreatetimeBtnStatus);
177  }
178 
179  if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
180  {
181  print '<br>';
182 
183  $param = '&id='.$id;
184  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
185  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
186 
187  print_barre_liste($langs->trans("ActionsOnProduct"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
188 
189  // List of all actions
190  $filters = array();
191  $filters['search_agenda_label'] = $search_agenda_label;
192 
193  // TODO Replace this with same code than into list.php
194  show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
195  }
196 }
197 
198 // End of page
199 llxFooter();
200 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage contact/addresses.
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.
Class to manage products or services.
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).
const TYPE_SERVICE
Service.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
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.
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.
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
product_prepare_head($object)
Prepare array with list of tabs.
Definition: product.lib.php:35