dolibarr  9.0.0
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 <http://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', 'alpha');
44 $confirm = GETPOST('confirm', 'alpha');
45 
46 // Security check
47 $socid = GETPOST('socid','int');
48 if ($user->societe_id) $socid=$user->societe_id;
49 if ($user->societe_id > 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 $sortfield = GETPOST("sortfield",'alpha');
66 $sortorder = GETPOST("sortorder",'alpha');
67 $page = GETPOST("page",'int');
68 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
69 $offset = $conf->liste_limit * $page;
70 $pageprev = $page - 1;
71 $pagenext = $page + 1;
72 if (! $sortorder) $sortorder="ASC";
73 if (! $sortfield) $sortfield="name";
74 
75 $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
76 $modulepart='actions';
77 
78 
79 /*
80  * Actions
81  */
82 include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
83 
84 
85 /*
86  * View
87  */
88 
89 $form = new Form($db);
90 
91 $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
92 llxHeader('',$langs->trans("Agenda"),$help_url);
93 
94 
95 if ($object->id > 0)
96 {
97  $result1=$object->fetch($id);
98  $result2=$object->fetch_thirdparty();
99  $result3=$object->fetch_contact();
100  $result4=$object->fetch_userassigned();
101  $result5=$object->fetch_optionals();
102 
103  if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
104  {
105  dol_print_error($db,$object->error);
106  exit;
107  }
108 
109  if ($object->authorid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->authorid); $object->author=$tmpuser; }
110  if ($object->usermodid > 0) { $tmpuser=new User($db); $res=$tmpuser->fetch($object->usermodid); $object->usermod=$tmpuser; }
111 
112  $author=new User($db);
113  $author->fetch($object->author->id);
114  $object->author=$author;
115 
116 
117  $head=actions_prepare_head($object);
118 
119  $now=dol_now();
120  $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
121 
122  dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action');
123 
124  $linkback = img_picto($langs->trans("BackToList"),'object_list','class="hideonsmartphone pictoactionview"');
125  $linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php">'.$langs->trans("BackToList").'</a>';
126 
127  // Link to other agenda views
128  $out='';
129  $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
130  $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>';
131  $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
132  $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>';
133  $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
134  $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>';
135  $out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
136  $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>';
137 
138  $linkback.=$out;
139 
140  $morehtmlref='<div class="refidno">';
141  // Thirdparty
142  //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
143  // Project
144  if (! empty($conf->projet->enabled))
145  {
146  $langs->load("projects");
147  //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
148  $morehtmlref.=$langs->trans('Project') . ': ';
149  if (! empty($object->fk_project)) {
150  $proj = new Project($db);
151  $proj->fetch($object->fk_project);
152  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
153  $morehtmlref.=$proj->ref;
154  $morehtmlref.='</a>';
155  if ($proj->title) $morehtmlref.=' - '.$proj->title;
156  } else {
157  $morehtmlref.='';
158  }
159  }
160  $morehtmlref.='</div>';
161 
162  dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
163 
164  print '<div class="fichecenter">';
165 
166  print '<div class="underbanner clearboth"></div>';
167 
168  // Affichage fiche action en mode visu
169  print '<table class="border" width="100%">';
170 
171  // Type
172  if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
173  {
174  print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
175  }
176 
177  // Full day event
178  print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
179 
180  // Date start
181  print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
182  if (! $object->fulldayevent) print dol_print_date($object->datep,'dayhour');
183  else print dol_print_date($object->datep,'day');
184  if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late"));
185  print '</td>';
186  print '</tr>';
187 
188  // Date end
189  print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
190  if (! $object->fulldayevent) print dol_print_date($object->datef,'dayhour');
191  else print dol_print_date($object->datef,'day');
192  if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
193  print '</td></tr>';
194 
195  // Location
196  if (empty($conf->global->AGENDA_DISABLE_LOCATION))
197  {
198  print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>';
199  }
200 
201  // Assigned to
202  print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
203  $listofuserid=array();
204  if (empty($donotclearsession))
205  {
206  if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->transparency); // Owner first
207  if (! empty($object->userassigned)) // Now concat assigned users
208  {
209  // Restore array with key with same value than param 'id'
210  $tmplist1=$object->userassigned; $tmplist2=array();
211  foreach($tmplist1 as $key => $val)
212  {
213  if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
214  }
215  }
216  $_SESSION['assignedtouser']=json_encode($listofuserid);
217  }
218  else
219  {
220  if (!empty($_SESSION['assignedtouser']))
221  {
222  $listofuserid=json_decode($_SESSION['assignedtouser'], true);
223  }
224  }
225  $listofcontactid=array(); // not used yet
226  $listofotherid=array(); // not used yet
227  print '<div class="assignedtouser">';
228  print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid);
229  print '</div>';
230  /*if (in_array($user->id,array_keys($listofuserid)))
231  {
232  print '<div class="myavailability">';
233  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
234  print '</div>';
235  }*/
236  print ' </td></tr>';
237 
238  print '</table>';
239 
240  print '<table class="border" width="100%">';
241 
242  // Build file list
243  $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
244  $totalsize=0;
245  foreach($filearray as $key => $file)
246  {
247  $totalsize+=$file['size'];
248  }
249 
250 
251  print '<tr><td class="titlefield" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
252  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
253 
254  print '</table>';
255 
256  print '</div>';
257 
258  dol_fiche_end();
259 
260 
261  $modulepart = 'actions';
262  $permission = $user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create;
263  $param = '&id=' . $object->id;
264  include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
265 }
266 else
267 {
268  print $langs->trans("ErrorUnknown");
269 }
270 
271 // End of page
272 llxFooter();
273 $db->close();
img_warning($titlealt='default', $moreatt='')
Show warning logo.
GETPOST($paramname, $check='none', $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.
print
Draft customers invoices.
Definition: index.php:91
Class to manage agenda events (actions)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
Class to manage Dolibarr users.
Definition: user.class.php:41
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
actions_prepare_head($object)
Prepare array with list of tabs.
Definition: agenda.lib.php:452
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
dol_fiche_end($notab=0)
Show tab footer of a card.
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:59
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
llxFooter()
Footer empty.
Definition: document.php:68
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
if(isset($_GET["hashp"]) &&! defined("NOLOGIN")) if((isset($_GET["modulepart"]) && $_GET["modulepart"]=='medias')) llxHeader()
Header empty.
Definition: document.php:60