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->project->enabled)) {
38 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
42 $langs->loadLangs(array(
'companies',
'commercial',
'other',
'bills'));
45 $action =
GETPOST(
'action',
'aZ09');
46 $confirm =
GETPOST(
'confirm',
'alpha');
49 $socid =
GETPOST(
'socid',
'int');
51 $socid = $user->socid;
53 if ($user->socid > 0) {
54 unset($_GET[
"action"]);
61 $ret = $object->fetch($id);
62 $object->fetch_thirdparty();
66 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
67 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
68 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
70 if (empty($page) || $page == -1) {
73 $offset = $limit * $page;
74 $pageprev = $page - 1;
75 $pagenext = $page + 1;
84 $modulepart =
'actions';
86 $result =
restrictedArea($user,
'agenda', $id,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
87 if ($user->socid && $socid) {
91 $permissiontoadd = $user->rights->agenda->myactions->read;
98 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
107 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
112 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
114 if ($object->id > 0) {
115 $result1 = $object->fetch($id);
116 $result2 = $object->fetch_thirdparty();
117 $result3 = $object->fetch_contact();
118 $result4 = $object->fetch_userassigned();
119 $result5 = $object->fetch_optionals();
121 if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
126 if ($object->authorid > 0) {
127 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
129 if ($object->usermodid > 0) {
130 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
133 $author =
new User($db);
134 $author->fetch($object->author->id);
135 $object->author = $author;
142 $linkback =
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="hideonsmartphone pictoactionview"');
143 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list">'.$langs->trans(
"BackToList").
'</a>';
147 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="hideonsmartphone pictoactionview"');
148 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=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>';
149 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="hideonsmartphone pictoactionview"');
150 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=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>';
151 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="hideonsmartphone pictoactionview"');
152 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=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>';
153 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="hideonsmartphone pictoactionview"');
154 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=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>';
158 $morehtmlref =
'<div class="refidno">';
162 if (!empty($conf->project->enabled)) {
163 $langs->load(
"projects");
165 $morehtmlref .= $langs->trans(
'Project').
': ';
166 if (!empty($object->fk_project)) {
168 $proj->fetch($object->fk_project);
169 $morehtmlref .=
' : '.$proj->getNomUrl(1);
171 $morehtmlref .=
' - '.$proj->title;
177 $morehtmlref .=
'</div>';
179 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
181 print
'<div class="fichecenter">';
183 print
'<div class="underbanner clearboth"></div>';
186 print
'<table class="border tableforfield centpercent">';
189 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
190 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td colspan="3">';
191 print $object->getTypePicto();
192 print $langs->trans(
"Action".$object->type_code);
197 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td colspan="3">'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
200 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td colspan="3">';
201 if (empty($object->fulldayevent)) {
205 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuser'));
207 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
214 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td colspan="3">';
215 if (empty($object->fulldayevent)) {
219 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuser'));
221 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
227 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
228 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3">'.$object->location.
'</td></tr>';
232 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAffectedTo").
'</td><td colspan="3">';
233 $listofuserid = array();
234 if (empty($donotclearsession)) {
235 if ($object->userownerid > 0) {
236 $listofuserid[$object->userownerid] = array(
'id'=>$object->userownerid,
'transparency'=>$object->transparency);
238 if (!empty($object->userassigned)) {
240 $tmplist1 = $object->userassigned;
241 foreach ($tmplist1 as $key => $val) {
242 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
243 $listofuserid[$val[
'id']] = $val;
247 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
249 if (!empty($_SESSION[
'assignedtouser'])) {
250 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
253 $listofcontactid = array();
254 $listofotherid = array();
255 print
'<div class="assignedtouser">';
256 print
$form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
268 print
'<table class="border tableforfield centpercent">';
271 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
273 foreach ($filearray as $key => $file) {
274 $totalsize += $file[
'size'];
278 print
'<tr><td class="titlefield" class="nowrap">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
279 print
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.$totalsize.
' '.$langs->trans(
"bytes").
'</td></tr>';
288 $modulepart =
'actions';
289 $permissiontoadd = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create;
290 $param =
'&id='.$object->id;
291 include DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
293 print $langs->trans(
"ErrorUnknown");