30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
43 $langs->loadLangs(array(
'companies',
'commercial',
'other',
'bills'));
46 $action =
GETPOST(
'action',
'aZ09');
47 $confirm =
GETPOST(
'confirm',
'alpha');
50 $socid =
GETPOST(
'socid',
'int');
52 $socid = $user->socid;
54 if ($user->socid > 0) {
55 unset($_GET[
"action"]);
62 $ret = $object->fetch($id);
63 $object->fetch_thirdparty();
67 $hookmanager->initHooks(array(
'actioncard',
'globalcard'));
70 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
71 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
72 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
74 if (empty($page) || $page == -1) {
77 $offset = $limit * $page;
78 $pageprev = $page - 1;
79 $pagenext = $page + 1;
88 $modulepart =
'actions';
90 $result =
restrictedArea($user,
'agenda', $id,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
91 if ($user->socid && $socid) {
95 $usercancreate = $user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create);
96 $permissiontoadd = $usercancreate;
103 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
112 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
117 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
119 if ($object->id > 0) {
120 $result1 = $object->fetch($id);
121 $result2 = $object->fetch_thirdparty();
122 $result3 = $object->fetch_contact();
123 $result4 = $object->fetch_userassigned();
124 $result5 = $object->fetch_optionals();
126 if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
131 if ($object->authorid > 0) {
132 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
134 if ($object->usermodid > 0) {
135 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
138 $author =
new User($db);
139 $author->fetch($object->author->id);
140 $object->author = $author;
147 $linkback =
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="hideonsmartphone pictoactionview"');
148 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list">'.$langs->trans(
"BackToList").
'</a>';
152 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="hideonsmartphone pictoactionview"');
153 $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>';
154 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewCal"),
'object_calendarmonth',
'class="hideonsmartphone pictoactionview"');
155 $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>';
156 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="hideonsmartphone pictoactionview"');
157 $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>';
158 $out .=
'</li><li class="noborder litext">'.img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="hideonsmartphone pictoactionview"');
159 $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>';
162 $parameters = array();
163 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters, $object, $action);
164 if (empty($reshook)) {
165 $out .= $hookmanager->resPrint;
166 } elseif ($reshook > 1) {
167 $out = $hookmanager->resPrint;
172 $morehtmlref =
'<div class="refidno">';
177 $langs->load(
"projects");
180 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
181 if ($action !=
'classify') {
182 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
184 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
186 if (!empty($object->fk_project)) {
188 $proj->fetch($object->fk_project);
189 $morehtmlref .= $proj->getNomUrl(1);
191 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
196 $morehtmlref .=
'</div>';
198 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
200 print
'<div class="fichecenter">';
202 print
'<div class="underbanner clearboth"></div>';
205 print
'<table class="border tableforfield centpercent">';
208 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
209 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td colspan="3">';
210 print $object->getTypePicto();
211 print $langs->trans(
"Action".$object->type_code);
216 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td colspan="3">'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
219 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td colspan="3">';
220 if (empty($object->fulldayevent)) {
224 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuser'));
226 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
233 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td colspan="3">';
234 if (empty($object->fulldayevent)) {
238 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuser'));
240 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
246 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
247 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3">'.$object->location.
'</td></tr>';
251 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAffectedTo").
'</td><td colspan="3">';
252 $listofuserid = array();
253 if (empty($donotclearsession)) {
254 if ($object->userownerid > 0) {
255 $listofuserid[$object->userownerid] = array(
'id'=>$object->userownerid,
'transparency'=>$object->transparency);
257 if (!empty($object->userassigned)) {
259 $tmplist1 = $object->userassigned;
260 foreach ($tmplist1 as $key => $val) {
261 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
262 $listofuserid[$val[
'id']] = $val;
266 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
268 if (!empty($_SESSION[
'assignedtouser'])) {
269 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
272 $listofcontactid = array();
273 $listofotherid = array();
274 print
'<div class="assignedtouser">';
275 print
$form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
287 print
'<table class="border tableforfield centpercent">';
290 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
292 foreach ($filearray as $key => $file) {
293 $totalsize += $file[
'size'];
297 print
'<tr><td class="titlefield" class="nowrap">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
298 print
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.$totalsize.
' '.$langs->trans(
"bytes").
'</td></tr>';
307 $modulepart =
'actions';
308 $permissiontoadd = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create;
309 $param =
'&id='.$object->id;
310 include DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
312 print $langs->trans(
"ErrorUnknown");