dolibarr  13.0.2
document.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
7  * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37 if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array('companies', 'commercial', 'other', 'bills'));
41 
42 $id = GETPOST('id', 'int');
43 $action = GETPOST('action', 'aZ09');
44 $confirm = GETPOST('confirm', 'alpha');
45 
46 // Security check
47 $socid = GETPOST('socid', 'int');
48 if ($user->socid) $socid = $user->socid;
49 if ($user->socid > 0)
50 {
51  unset($_GET["action"]);
52  $action = '';
53 }
54 $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
55 
56 $object = new ActionComm($db);
57 
58 if ($id > 0)
59 {
60  $ret = $object->fetch($id);
61  $object->fetch_thirdparty();
62 }
63 
64 // Get parameters
65 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
66 $sortfield = GETPOST("sortfield", 'alpha');
67 $sortorder = GETPOST("sortorder", 'alpha');
68 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
69 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
70 $offset = $limit * $page;
71 $pageprev = $page - 1;
72 $pagenext = $page + 1;
73 if (!$sortorder) $sortorder = "ASC";
74 if (!$sortfield) $sortfield = "name";
75 
76 $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
77 $modulepart = 'actions';
78 
79 
80 /*
81  * Actions
82  */
83 include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
84 
85 
86 /*
87  * View
88  */
89 
90 $form = new Form($db);
91 
92 $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
93 llxHeader('', $langs->trans("Agenda"), $help_url);
94 
95 
96 if ($object->id > 0)
97 {
98  $result1 = $object->fetch($id);
99  $result2 = $object->fetch_thirdparty();
100  $result3 = $object->fetch_contact();
101  $result4 = $object->fetch_userassigned();
102  $result5 = $object->fetch_optionals();
103 
104  if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
105  {
106  dol_print_error($db, $object->error);
107  exit;
108  }
109 
110  if ($object->authorid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; }
111  if ($object->usermodid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; }
112 
113  $author = new User($db);
114  $author->fetch($object->author->id);
115  $object->author = $author;
116 
117 
118  $head = actions_prepare_head($object);
119 
120  $now = dol_now();
121  $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
122 
123  print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action');
124 
125  $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"');
126  $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list">'.$langs->trans("BackToList").'</a>';
127 
128  // Link to other agenda views
129  $out = '';
130  $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"');
131  $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewPerUser").'</a>';
132  $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"');
133  $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewCal").'</a>';
134  $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"');
135  $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewWeek").'</a>';
136  $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"');
137  $out .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">'.$langs->trans("ViewDay").'</a>';
138 
139  $linkback .= $out;
140 
141  $morehtmlref = '<div class="refidno">';
142  // Thirdparty
143  //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
144  // Project
145  if (!empty($conf->projet->enabled))
146  {
147  $langs->load("projects");
148  //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
149  $morehtmlref .= $langs->trans('Project').': ';
150  if (!empty($object->fk_project)) {
151  $proj = new Project($db);
152  $proj->fetch($object->fk_project);
153  $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
154  $morehtmlref .= $proj->ref;
155  $morehtmlref .= '</a>';
156  if ($proj->title) $morehtmlref .= ' - '.$proj->title;
157  } else {
158  $morehtmlref .= '';
159  }
160  }
161  $morehtmlref .= '</div>';
162 
163  dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref);
164 
165  print '<div class="fichecenter">';
166 
167  print '<div class="underbanner clearboth"></div>';
168 
169  // Affichage fiche action en mode visu
170  print '<table class="border tableforfield centpercent">';
171 
172  // Type
173  if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
174  {
175  print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
176  }
177 
178  // Full day event
179  print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
180 
181  // Date start
182  print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
183  if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour');
184  else print dol_print_date($object->datep, 'day');
185  if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
186  print '</td>';
187  print '</tr>';
188 
189  // Date end
190  print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
191  if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour');
192  else print dol_print_date($object->datef, 'day');
193  if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
194  print '</td></tr>';
195 
196  // Location
197  if (empty($conf->global->AGENDA_DISABLE_LOCATION))
198  {
199  print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>';
200  }
201 
202  // Assigned to
203  print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
204  $listofuserid = array();
205  if (empty($donotclearsession))
206  {
207  if ($object->userownerid > 0) $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first
208  if (!empty($object->userassigned)) // Now concat assigned users
209  {
210  // Restore array with key with same value than param 'id'
211  $tmplist1 = $object->userassigned;
212  foreach ($tmplist1 as $key => $val)
213  {
214  if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val;
215  }
216  }
217  $_SESSION['assignedtouser'] = json_encode($listofuserid);
218  } else {
219  if (!empty($_SESSION['assignedtouser']))
220  {
221  $listofuserid = json_decode($_SESSION['assignedtouser'], true);
222  }
223  }
224  $listofcontactid = array(); // not used yet
225  $listofotherid = array(); // not used yet
226  print '<div class="assignedtouser">';
227  print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
228  print '</div>';
229  /*if (in_array($user->id,array_keys($listofuserid)))
230  {
231  print '<div class="myavailability">';
232  print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
233  print '</div>';
234  }*/
235  print ' </td></tr>';
236 
237  print '</table>';
238 
239  print '<table class="border tableforfield centpercent">';
240 
241  // Build file list
242  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
243  $totalsize = 0;
244  foreach ($filearray as $key => $file)
245  {
246  $totalsize += $file['size'];
247  }
248 
249 
250  print '<tr><td class="titlefield" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
251  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
252 
253  print '</table>';
254 
255  print '</div>';
256 
257  print dol_get_fiche_end();
258 
259 
260  $modulepart = 'actions';
261  $permission = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create;
262  $param = '&id='.$object->id;
263  include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
264 } else {
265  print $langs->trans("ErrorUnknown");
266 }
267 
268 // End of page
269 llxFooter();
270 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Class to manage agenda events (actions)
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
actions_prepare_head($object)
Prepare array with list of tabs.
Definition: agenda.lib.php:408
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
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 projects.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
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_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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