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