--- /tmp/dsg/dolibarr/htdocs/comm/action/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/comm/action/client_card.php @@ -9,2 +9,2 @@ - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2018-2019 Frédéric France @@ -28,3 +28,3 @@ - * \file htdocs/comm/action/card.php - * \ingroup agenda - * \brief Page for event card + * \file htdocs/comm/action/card.php + * \ingroup agenda + * \brief Page for event card @@ -33 +32,0 @@ -// Load Dolibarr environment @@ -35,2 +34,6 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -39,8 +42 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -49,2 +45,3 @@ -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -53,4 +50,3 @@ -$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda", "mails")); - -// Get Parameters -$action = GETPOST('action', 'aZ09'); +$langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda")); + +$action = GETPOST('action', 'alpha'); @@ -64,36 +60,9 @@ -$fulldayevent = GETPOST('fullday', 'alpha'); - -$aphour = GETPOST('aphour', 'int'); -$apmin = GETPOST('apmin', 'int'); -$p2hour = GETPOST('p2hour', 'int'); -$p2min = GETPOST('p2min', 'int'); - -$addreminder = GETPOST('addreminder', 'alpha'); -$offsetvalue = GETPOSTINT('offsetvalue'); -$offsetunit = GETPOST('offsetunittype_duration', 'aZ09'); -$remindertype = GETPOST('selectremindertype', 'aZ09'); -$modelmail = GETPOST('actioncommsendmodel_mail', 'int'); -$complete = GETPOST('complete', 'alpha'); // 'na' must be allowed -$private = GETPOST('private', 'alphanohtml'); -if ($complete == 'na' || $complete == -2) { - $complete = -1; -} - -if ($fulldayevent) { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - // For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere) - $datep = dol_mktime('00', '00', 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel'); - $datef = dol_mktime('23', '59', '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel'); - //print $db->idate($datep); exit; -} else { - $datep = dol_mktime($aphour, $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel'); - $datef = dol_mktime($p2hour, $p2min, '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel'); -} -$reg = array(); -if (GETPOST('datep')) { - if (GETPOST('datep') == 'now') { - $datep = dol_now(); - } elseif (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg)) { // Try to not use this. Use insteead '&datep=now' - $datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1], 'tzuserrel'); - } -} +$fulldayevent = GETPOST('fullday'); + +$aphour = GETPOST('aphour'); +$apmin = GETPOST('apmin'); +$p2hour = GETPOST('p2hour'); +$p2min = GETPOST('p2min'); + +$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); +$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); @@ -104,3 +73,3 @@ -if ($user->socid && ($socid != $user->socid)) { - accessforbidden(); -} +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); +if ($user->socid && $socid) $result = restrictedArea($user, 'societe', $socid); @@ -109,3 +78,3 @@ -$donotclearsession = GETPOST('donotclearsession') ? GETPOST('donotclearsession') : 0; - -// Initialize Objects +$donotclearsession = GETPOST('donotclearsession') ?GETPOST('donotclearsession') : 0; + +$cactioncomm = new CActionComm($db); @@ -113 +81,0 @@ -$cactioncomm = new CActionComm($db); @@ -124,8 +92,8 @@ - $ret = $object->fetch($id); - if ($ret > 0) { - $ret = $object->fetch_optionals(); - $ret1 = $object->fetch_userassigned(); - } - if ($ret < 0 || $ret1 < 0) { - dol_print_error('', $object->error); - } + $ret = $object->fetch($id); + if ($ret > 0) { + $ret = $object->fetch_optionals(); + $ret1 = $object->fetch_userassigned(); + } + if ($ret < 0 || $ret1 < 0) { + dol_print_error('', $object->error); + } @@ -136,0 +105,2 @@ +//var_dump($_POST); + @@ -142,17 +112 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -$TRemindTypes = array(); -if (getDolGlobalString('AGENDA_REMINDER_BROWSER')) { - $TRemindTypes['browser'] = array('label'=>$langs->trans('BrowserPush'), 'disabled'=>(!getDolGlobalString('AGENDA_REMINDER_BROWSER') ? 1 : 0)); -} -if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) { - $TRemindTypes['email'] = array('label'=>$langs->trans('EMail'), 'disabled'=>(!getDolGlobalString('AGENDA_REMINDER_EMAIL') ? 1 : 0)); -} - -$TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); - -$result = restrictedArea($user, 'agenda', $object, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); - -$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')); +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -166,2 +119,0 @@ -$listResourceAssignedUpdated = false; - @@ -169 +121,2 @@ -if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) { +if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) +{ @@ -172,12 +125,8 @@ - if (!empty($_SESSION['assignedtouser'])) { - $tmpassigneduserids = json_decode($_SESSION['assignedtouser'], 1); - } else { - $tmpassigneduserids = array(); - } - - foreach ($tmpassigneduserids as $key => $val) { - if ($val['id'] == $idtoremove || $val['id'] == -1) { - unset($tmpassigneduserids[$key]); - } - } - + if (!empty($_SESSION['assignedtouser'])) $tmpassigneduserids = json_decode($_SESSION['assignedtouser'], 1); + else $tmpassigneduserids = array(); + + foreach ($tmpassigneduserids as $key => $val) + { + if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]); + } + //var_dump($_POST['removedassigned']);exit; @@ -186,6 +135,2 @@ - if ($action == 'add') { - $action = 'create'; - } - if ($action == 'update') { - $action = 'edit'; - } + if ($action == 'add') $action = 'create'; + if ($action == 'update') $action = 'edit'; @@ -195,27 +139,0 @@ -// Remove resource to assigned list -if (empty($reshook) && (GETPOST('removedassignedresource') || GETPOST('removedassignedresource') == '0')) { - $idtoremove = GETPOST('removedassignedresource'); - - if (!empty($_SESSION['assignedtoresource'])) { - $tmpassignedresourceids = json_decode($_SESSION['assignedtoresource'], 1); - } else { - $tmpassignedresourceids = array(); - } - - foreach ($tmpassignedresourceids as $key => $val) { - if ($val['id'] == $idtoremove || $val['id'] == -1) { - unset($tmpassignedresourceids[$key]); - } - } - - $_SESSION['assignedtoresource'] = json_encode($tmpassignedresourceids); - $donotclearsessionresource = 1; - if ($action == 'add') { - $action = 'create'; - } - if ($action == 'update') { - $action = 'edit'; - } - - $listResourceAssignedUpdated = true; -} @@ -224 +142,2 @@ -if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))) { +if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))) +{ @@ -226 +145,2 @@ - if (GETPOST('assignedtouser') > 0) { + if (GETPOST('assignedtouser') > 0) + { @@ -228 +148,2 @@ - if (!empty($_SESSION['assignedtouser'])) { + if (!empty($_SESSION['assignedtouser'])) + { @@ -231 +152 @@ - $assignedtouser[GETPOST('assignedtouser')] = array('id'=>GETPOSTINT('assignedtouser'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); + $assignedtouser[GETPOST('assignedtouser')] = array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); @@ -235,6 +156,2 @@ - if ($action == 'add') { - $action = 'create'; - } - if ($action == 'update') { - $action = 'edit'; - } + if ($action == 'add') $action = 'create'; + if ($action == 'update') $action = 'edit'; @@ -245,20 +162,6 @@ -// Add resource to assigned list -if (empty($reshook) && (GETPOST('addassignedtoresource') || GETPOST('updateassignedtoresource'))) { - // Add a new user - if (GETPOST('assignedtoresource') > 0) { - $assignedtoresource = array(); - if (!empty($_SESSION['assignedtoresource'])) { - $assignedtoresource = json_decode($_SESSION['assignedtoresource'], true); - } - $assignedtoresource[GETPOST('assignedtoresource')] = array('id'=>GETPOSTINT('assignedtoresource'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1); - $_SESSION['assignedtoresource'] = json_encode($assignedtoresource); - } - $donotclearsession = 1; - if ($action == 'add') { - $action = 'create'; - } - if ($action == 'update') { - $action = 'edit'; - } - - $listResourceAssignedUpdated = true; +// Link to a project +if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) +{ + //$object->fetch($id); + $object->setProject(GETPOST('projectid', 'int')); @@ -267,7 +169,0 @@ -// Link to a project -if (empty($reshook) && $action == 'classin' && ($user->hasRight('agenda', 'allactions', 'create') || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')))) { - //$object->fetch($id); - $object->setProject(GETPOST('projectid', 'int')); -} - @@ -275,2 +171,4 @@ -if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') { - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { +if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') +{ + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) + { @@ -278 +176,3 @@ - } else { + } + else + { @@ -281,4 +181,4 @@ - if (!empty($object->socpeopleassigned)) { - reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); - } + if (!empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } @@ -298 +198,2 @@ -if (empty($reshook) && $action == 'add') { +if (empty($reshook) && $action == 'add') +{ @@ -301,9 +202,8 @@ - if (empty($backtopage)) { - if ($socid > 0) { - $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; - } else { - $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; - } - } - - if (!empty($socpeopleassigned[0])) { + if (empty($backtopage)) + { + if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; + else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; + } + + if (!empty($socpeopleassigned[0])) + { @@ -313 +213,2 @@ - if ($cancel) { + if ($cancel) + { @@ -318,12 +219,5 @@ - $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status - - // Clean parameters - if ($fulldayevent) { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - // For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere) - $datep = dol_mktime('00', '00', '00', GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel'); - $datef = dol_mktime('23', '59', '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel'); - } else { - $datep = dol_mktime(GETPOST("aphour", 'int'), GETPOST("apmin", 'int'), GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel'); - $datef = dol_mktime(GETPOST("p2hour", 'int'), GETPOST("p2min", 'int'), GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel'); - } + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + + // Clean parameters + $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); + $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); @@ -332,3 +226,3 @@ - if (!$datef && $percentage == 100) { - $error++; - $donotclearsession = 1; + if (!$datef && $percentage == 100) + { + $error++; $donotclearsession = 1; @@ -339,3 +233,3 @@ - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && !GETPOST('label')) { - $error++; - $donotclearsession = 1; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !GETPOST('label')) + { + $error++; $donotclearsession = 1; @@ -347,3 +241,3 @@ - if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0' - $error++; - $donotclearsession = 1; + if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) // actioncode is '0' + { + $error++; $donotclearsession = 1; @@ -352 +246,3 @@ - } else { + } + else + { @@ -356 +252,2 @@ - if (!$error) { + if (!$error) + { @@ -358,21 +255,10 @@ - $object->priority = GETPOSTISSET("priority") ? GETPOST("priority", "int") : 0; - $object->fulldayevent = ($fulldayevent ? 1 : 0); - $object->location = GETPOST("location", 'alphanohtml'); - $object->label = GETPOST('label', 'alphanohtml'); - - if (GETPOST("elementtype", 'alpha')) { - $elProp = getElementProperties(GETPOST("elementtype", 'alpha')); - $modulecodetouseforpermissioncheck = $elProp['module']; - - $hasPermissionOnLinkedObject = 0; - if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) { - $hasPermissionOnLinkedObject = 1; - } - if ($hasPermissionOnLinkedObject) { - $object->fk_element = GETPOST("fk_element", 'int'); - $object->elementtype = GETPOST("elementtype", 'alpha'); - } - } - - if (!GETPOST('label')) { - if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs)) { + $object->priority = GETPOST("priority") ?GETPOST("priority") : 0; + $object->fulldayevent = (!empty($fulldayevent) ? 1 : 0); + $object->location = GETPOST("location"); + $object->label = trim(GETPOST('label')); + $object->fk_element = GETPOST("fk_element", 'int'); + $object->elementtype = GETPOST("elementtype", 'alpha'); + if (!GETPOST('label')) + { + if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs)) + { @@ -380,2 +266,5 @@ - } else { - if ($langs->trans("Action".$object->type_code) != "Action".$object->type_code) { + } + else + { + if ($langs->trans("Action".$object->type_code) != "Action".$object->type_code) + { @@ -383 +272,2 @@ - } else { + } + else { @@ -389 +279 @@ - $object->fk_project = GETPOSTISSET("projectid") ? GETPOST("projectid", 'int') : 0; + $object->fk_project = isset($_POST["projectid"]) ? $_POST["projectid"] : 0; @@ -393,7 +283,7 @@ - $taskProject = new Task($db); - if ($taskProject->fetch($taskid) > 0) { - $object->fk_project = $taskProject->fk_project; - } - - $object->fk_element = $taskid; - $object->elementtype = 'task'; + $taskProject = new Task($db); + if ($taskProject->fetch($taskid) > 0) { + $object->fk_project = $taskProject->fk_project; + } + + $object->fk_element = $taskid; + $object->elementtype = 'task'; @@ -410,3 +300 @@ - if (!empty($_SESSION['assignedtouser'])) { - $listofuserid = json_decode($_SESSION['assignedtouser'], true); - } + if (!empty($_SESSION['assignedtouser'])) $listofuserid = json_decode($_SESSION['assignedtouser'], true); @@ -414,5 +302,5 @@ - foreach ($listofuserid as $key => $value) { - if ($i == 0) { // First entry - if ($value['id'] > 0) { - $object->userownerid = $value['id']; - } + foreach ($listofuserid as $key => $value) + { + if ($i == 0) // First entry + { + if ($value['id'] > 0) $object->userownerid = $value['id']; @@ -428,13 +316,11 @@ - if (!$error && getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - if (GETPOST("doneby") > 0) { - $object->userdoneid = GETPOST("doneby", "int"); - } - } - - $object->note_private = trim(GETPOST("note", "restricthtml")); - - if (GETPOSTISSET("contactid")) { - $object->contact = $contact; - } - - if (GETPOST('socid', 'int') > 0) { + if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) + { + if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby", "int"); + } + + $object->note_private = trim(GETPOST("note", "none")); + + if (isset($_POST["contactid"])) $object->contact = $contact; + + if (GETPOST('socid', 'int') > 0) + { @@ -448,3 +334,3 @@ - if (empty($object->userownerid) && empty($_SESSION['assignedtouser'])) { - $error++; - $donotclearsession = 1; + if (empty($object->userownerid) && empty($_SESSION['assignedtouser'])) + { + $error++; $donotclearsession = 1; @@ -454,3 +340,3 @@ - if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) { - $error++; - $donotclearsession = 1; + if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) + { + $error++; $donotclearsession = 1; @@ -461,3 +347,3 @@ - if (!GETPOST('apyear') && !GETPOST('adyear')) { - $error++; - $donotclearsession = 1; + if (!GETPOST('apyear') && !GETPOST('adyear')) + { + $error++; $donotclearsession = 1; @@ -468 +354,2 @@ - foreach ($socpeopleassigned as $cid) { + foreach ($socpeopleassigned as $cid) + { @@ -471 +358,2 @@ - if (!empty($object->socpeopleassigned)) { + if (!empty($object->socpeopleassigned)) + { @@ -473 +361 @@ - $object->contact_id = key($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); @@ -478,8 +366,4 @@ - if ($ret < 0) { - $error++; $donotclearsession = 1; - $action = 'create'; - } - - - - if (!$error) { + if ($ret < 0) $error++; + + if (!$error) + { @@ -487,33 +370,0 @@ - - $selectedrecurrulefreq = 'no'; - $selectedrecurrulebymonthday = ''; - $selectedrecurrulebyday = ''; - $object->recurrule = GETPOSTISSET('recurrulefreq') ? "FREQ=".GETPOST('recurrulefreq', 'alpha') : ""; - $object->recurrule .= (GETPOST('recurrulefreq', 'alpha') == 'MONTHLY' && GETPOSTISSET('BYMONTHDAY')) ? "_BYMONTHDAY".GETPOST('BYMONTHDAY', 'alpha') : ""; - $object->recurrule .= (GETPOST('recurrulefreq', 'alpha') == 'WEEKLY' && GETPOSTISSET('BYDAY')) ? "_BYDAY".GETPOST('BYDAY', 'alpha') : ""; - - $reg1 = array(); - $reg2 = array(); - $reg3 = array(); - if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) { - $selectedrecurrulefreq = $reg1[1]; - } - if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) { - $selectedrecurrulebymonthday = $reg2[1]; - } - if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) { - $selectedrecurrulebyday = $reg3[1]; - } - - // Is event recurrent ? - $eventisrecurring = 0; - $userepeatevent = (getDolGlobalInt('MAIN_FEATURES_LEVEL') == 2 ? 1 : 0); - if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq != 'no') { - $eventisrecurring = 1; - $object->recurid = dol_print_date(dol_now('gmt'), 'dayhourlog', 'gmt'); - $object->recurdateend = dol_mktime(0, 0, 0, GETPOST('limitmonth', 'int'), GETPOST('limitday', 'int'), GETPOST('limityear', 'int')); - } else { - unset($object->recurid); - unset($object->recurrule); - unset($object->recurdateend); - } @@ -524,2 +375,4 @@ - if ($idaction > 0) { - if (!$object->error) { + if ($idaction > 0) + { + if (!$object->error) + { @@ -533,2 +386,7 @@ - if ($user->id != $object->userownerid) { - $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. + if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. + + $db->commit(); + if (!empty($backtopage)) + { + dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); @@ -536,33 +394,3 @@ - - // Create reminders - if ($addreminder == 'on') { - $actionCommReminder = new ActionCommReminder($db); - - $dateremind = dol_time_plus_duree($datep, -1 * $offsetvalue, $offsetunit); - - $actionCommReminder->dateremind = $dateremind; - $actionCommReminder->typeremind = $remindertype; - $actionCommReminder->offsetunit = $offsetunit; - $actionCommReminder->offsetvalue = $offsetvalue; - $actionCommReminder->status = $actionCommReminder::STATUS_TODO; - $actionCommReminder->fk_actioncomm = $object->id; - if ($remindertype == 'email') { - $actionCommReminder->fk_email_template = $modelmail; - } - - // the notification must be created for every user assigned to the event - foreach ($object->userassigned as $userassigned) { - $actionCommReminder->fk_user = $userassigned['id']; - $res = $actionCommReminder->create($user); - - if ($res <= 0) { - // If error - $db->rollback(); - $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); - $action = 'create'; - $donotclearsession = 1; - break; - } - } + elseif ($idaction) + { + header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); @@ -570,12 +398,3 @@ - - // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. - /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; - $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; - $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; - */ - $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; - - if ($error) { - $db->rollback(); - } else { - $db->commit(); + else + { + header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); @@ -583,11 +402,4 @@ - - // if (!empty($backtopage)) { - // dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - // header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - // } elseif ($idaction) { - // header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); - // } else { - // header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); - // } - // exit; - } else { + exit; + } + else + { @@ -599,4 +411,5 @@ - $action = 'create'; - $donotclearsession = 1; - } - } else { + $action = 'create'; $donotclearsession = 1; + } + } + else + { @@ -605,132 +418,2 @@ - $action = 'create'; - $donotclearsession = 1; - } - - if ($eventisrecurring) { - // We set first date of recurrence and offsets - if ($selectedrecurrulefreq == 'WEEKLY' && !empty($selectedrecurrulebyday)) { - $firstdatearray = dol_get_first_day_week(GETPOST("apday", 'int'), GETPOST("apmonth", 'int'), GETPOST("apyear", 'int')); - $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstdatearray['month'], $firstdatearray['first_day'], $firstdatearray['year'], $tzforfullday ? $tzforfullday : 'tzuserrel'); - $datep = dol_time_plus_duree($datep, $selectedrecurrulebyday + 6, 'd');//We begin the week after - $dayoffset = 7; - $monthoffset = 0; - } elseif ($selectedrecurrulefreq == 'MONTHLY' && !empty($selectedrecurrulebymonthday)) { - $firstday = $selectedrecurrulebymonthday; - $firstmonth = GETPOST("apday") > $selectedrecurrulebymonthday ? GETPOST("apmonth", 'int') + 1 : GETPOST("apmonth", 'int');//We begin the week after - $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstmonth, $firstday, GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel'); - $dayoffset = 0; - $monthoffset = 1; - } else { - $error++; - } - // End date - $repeateventlimitdate = dol_mktime(23, 59, 59, GETPOSTISSET("limitmonth") ? GETPOST("limitmonth", 'int') : 1, GETPOSTISSET("limitday") ? GETPOST("limitday", 'int') : 1, GETPOSTISSET("limityear") && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuserrel'); - // Set date of end of event - $deltatime = num_between_day($object->datep, $datep); - $datef = dol_time_plus_duree($datef, $deltatime, 'd'); - - while ($datep <= $repeateventlimitdate && !$error) { - $finalobject = clone $object; - - - $finalobject->datep = $datep; - $finalobject->datef = $datef; - // Creation of action/event - $idaction = $finalobject->create($user); - - if ($idaction > 0) { - if (!$finalobject->error) { - // Category association - $categories = GETPOST('categories', 'array'); - $finalobject->setCategories($categories); - - unset($_SESSION['assignedtouser']); - - $moreparam = ''; - if ($user->id != $finalobject->userownerid) { - $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. - } - - // Create reminders - if ($addreminder == 'on') { - $actionCommReminder = new ActionCommReminder($db); - - $dateremind = dol_time_plus_duree($datep, -1 * $offsetvalue, $offsetunit); - - $actionCommReminder->dateremind = $dateremind; - $actionCommReminder->typeremind = $remindertype; - $actionCommReminder->offsetunit = $offsetunit; - $actionCommReminder->offsetvalue = $offsetvalue; - $actionCommReminder->status = $actionCommReminder::STATUS_TODO; - $actionCommReminder->fk_actioncomm = $finalobject->id; - if ($remindertype == 'email') { - $actionCommReminder->fk_email_template = $modelmail; - } - - // the notification must be created for every user assigned to the event - foreach ($finalobject->userassigned as $userassigned) { - $actionCommReminder->fk_user = $userassigned['id']; - $res = $actionCommReminder->create($user); - - if ($res <= 0) { - // If error - $db->rollback(); - $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); - $action = 'create'; - $donotclearsession = 1; - break; - } - } - } - - // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. - /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; - $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; - $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; - */ - $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; - - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } - } else { - // If error - $db->rollback(); - $langs->load("errors"); - $error = $langs->trans($finalobject->error); - setEventMessages($error, null, 'errors'); - $action = 'create'; - $donotclearsession = 1; - } - } else { - $db->rollback(); - setEventMessages($finalobject->error, $finalobject->errors, 'errors'); - $action = 'create'; - $donotclearsession = 1; - } - - // If event is not recurrent, we stop here - if (!($userepeatevent && GETPOSTISSET('recurrulefreq') && GETPOST('recurrulefreq') != 'no' && GETPOSTISSET("limityear") && GETPOSTISSET("limitmonth") && GETPOSTISSET("limitday"))) { - break; - } - - // increment date for recurrent events - $datep = dol_time_plus_duree($datep, $dayoffset, 'd'); - $datep = dol_time_plus_duree($datep, $monthoffset, 'm'); - $datef = dol_time_plus_duree($datef, $dayoffset, 'd'); - $datef = dol_time_plus_duree($datef, $monthoffset, 'm'); - } - } - if (!empty($backtopage) && !$error) { - dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - } elseif ($idaction) { - header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); - } else { - header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); - } - exit; + $action = 'create'; $donotclearsession = 1; + } @@ -743,22 +426,16 @@ -if (empty($reshook) && $action == 'update') { - if (empty($cancel)) { - $fulldayevent = GETPOST('fullday'); - $aphour = GETPOST('aphour', 'int'); - $apmin = GETPOST('apmin', 'int'); - $p2hour = GETPOST('p2hour', 'int'); - $p2min = GETPOST('p2min', 'int'); - $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status - - // Clean parameters - if ($aphour == -1) { - $aphour = '0'; - } - if ($apmin == -1) { - $apmin = '0'; - } - if ($p2hour == -1) { - $p2hour = '0'; - } - if ($p2min == -1) { - $p2min = '0'; - } +if (empty($reshook) && $action == 'update') +{ + if (empty($cancel)) + { + $fulldayevent = GETPOST('fullday'); + $aphour = GETPOST('aphour'); + $apmin = GETPOST('apmin'); + $p2hour = GETPOST('p2hour'); + $p2min = GETPOST('p2min'); + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + + // Clean parameters + if ($aphour == -1) $aphour = '0'; + if ($apmin == -1) $apmin = '0'; + if ($p2hour == -1) $p2hour = '0'; + if ($p2min == -1) $p2min = '0'; @@ -769,35 +446,6 @@ - $object->oldcopy = dol_clone($object, 2); - - // Clean parameters - if ($fulldayevent) { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - // For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere) - $datep = dol_mktime('00', '00', '00', GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel'); - $datef = dol_mktime('23', '59', '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel'); - } else { - $datep = dol_mktime(GETPOST("aphour", 'int'), GETPOST("apmin", 'int'), GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel'); - $datef = dol_mktime(GETPOST("p2hour", 'int'), GETPOST("p2min", 'int'), GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel'); - } - - if ($object->elementtype == 'ticket') { // code should be TICKET_MSG, TICKET_MSG_PRIVATE, TICKET_MSG_SENTBYMAIL, TICKET_MSG_PRIVATE_SENTBYMAIL - if ($private) { - if ($object->code == 'TICKET_MSG') { - $object->code = 'TICKET_MSG_PRIVATE'; - } - if ($object->code == 'TICKET_MSG_SENTBYMAIL') { - $object->code = 'TICKET_MSG_PRIVATE_SENTBYMAIL'; - } - } else { - if ($object->code == 'TICKET_MSG_PRIVATE') { - $object->code = 'TICKET_MSG'; - } - if ($object->code == 'TICKET_MSG_PRIVATE_SENTBYMAIL') { - $object->code = 'TICKET_MSG_SENTBYMAIL'; - } - } - // type_id and type_code is not modified - } else { - $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); - $object->type_code = GETPOST("actioncode", 'aZ09'); - } - + $object->oldcopy = clone $object; + + $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); + $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); + + $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm'); @@ -808,3 +456,3 @@ - $object->priority = GETPOST("priority", "int"); - $object->fulldayevent = GETPOST("fullday") ? 1 : 0; - $object->location = GETPOST('location', "alphanohtml"); + $object->priority = GETPOST("priority", "alphanohtml"); + $object->fulldayevent = GETPOST("fullday") ? 1 : 0; + $object->location = GETPOST('location', "alphanohtml"); @@ -814,8 +462,6 @@ - foreach ($socpeopleassigned as $cid) { - $object->socpeopleassigned[$cid] = array('id' => $cid); - } - $object->contact_id = GETPOST("contactid", 'int'); - if (empty($object->contact_id) && !empty($object->socpeopleassigned)) { - reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); - } + foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); + $object->contactid = GETPOST("contactid", 'int'); + if (empty($object->contactid) && !empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } @@ -823,19 +469,7 @@ - $object->note_private = trim(GETPOST("note", "restricthtml")); - - if (GETPOST("elementtype", 'alpha')) { - $elProp = getElementProperties(GETPOST("elementtype", 'alpha')); - $modulecodetouseforpermissioncheck = $elProp['module']; - - $hasPermissionOnLinkedObject = 0; - if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) { - $hasPermissionOnLinkedObject = 1; - } - if ($hasPermissionOnLinkedObject) { - $object->fk_element = GETPOST("fk_element", 'int'); - $object->elementtype = GETPOST("elementtype", 'alpha'); - } - } - - if (!$datef && $percentage == 100) { - $error++; - $donotclearsession = 1; + $object->note_private = trim(GETPOST("note", "none")); + $object->fk_element = GETPOST("fk_element", "int"); + $object->elementtype = GETPOST("elementtype", "alphanohtml"); + + if (!$datef && $percentage == 100) + { + $error++; $donotclearsession = 1; @@ -850 +484,2 @@ - if (!empty($_SESSION['assignedtouser'])) { // Now concat assigned users + if (!empty($_SESSION['assignedtouser'])) // Now concat assigned users + { @@ -853,6 +488,6 @@ - foreach ($tmplist1 as $key => $val) { - if ($val['id'] > 0 && $val['id'] != $assignedtouser) { - $listofuserid[$val['id']] = $val; - } - } - } else { + foreach ($tmplist1 as $key => $val) + { + if ($val['id'] > 0 && $val['id'] != $assignedtouser) $listofuserid[$val['id']] = $val; + } + } + else { @@ -860,6 +495,3 @@ - if ($assignedtouser) { - $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first - } - } - $object->userassigned = array(); - $object->userownerid = 0; // Clear old content + if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first + } + $object->userassigned = array(); $object->userownerid = 0; // Clear old content @@ -867,4 +499,3 @@ - foreach ($listofuserid as $key => $val) { - if ($i == 0) { - $object->userownerid = $val['id']; - } + foreach ($listofuserid as $key => $val) + { + if ($i == 0) $object->userownerid = $val['id']; @@ -878,4 +509,3 @@ - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - if (GETPOST("doneby")) { - $object->userdoneid = GETPOST("doneby", "int"); - } + if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) + { + if (GETPOST("doneby")) $object->userdoneid = GETPOST("doneby", "int"); @@ -885,3 +515,3 @@ - if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0' - $error++; - $donotclearsession = 1; + if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) // actioncode is '0' + { + $error++; $donotclearsession = 1; @@ -890 +520,3 @@ - } else { + } + else + { @@ -893,3 +525,3 @@ - if (empty($object->userownerid)) { - $error++; - $donotclearsession = 1; + if (empty($object->userownerid)) + { + $error++; $donotclearsession = 1; @@ -901,65 +533,64 @@ - $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); - if ($ret < 0) { - $error++; - } - - if (!$error) { - // check if an event resource is already in use - if (getDolGlobalString('RESOURCE_USED_IN_EVENT_CHECK') && $object->element == 'action') { - $eventDateStart = $object->datep; - $eventDateEnd = $object->datef; - - $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id <> ".((int) $object->id); - $sql .= " AND er.resource_id IN ("; - $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".((int) $object->id); - $sql .= " AND element_type = '".$db->escape($object->element)."'"; - $sql .= " AND busy = 1"; - $sql .= ")"; - $sql .= " AND er.busy = 1"; - $sql .= " AND ("; - - // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; - // event date end between ac.datep and ac.datep2 - if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; - } - // event date start before ac.datep and event date end after ac.datep2 - $sql .= " OR ("; - $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; - if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; - } - $sql .= ")"; - - $sql .= ")"; - $resql = $db->query($sql); - if (!$resql) { - $error++; - $object->error = $db->lasterror(); - $object->errors[] = $object->error; - } else { - if ($db->num_rows($resql) > 0) { - // Resource already in use - $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; - while ($obj = $db->fetch_object($resql)) { - $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); - } - $object->errors[] = $object->error; - } - $db->free($resql); - } - - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - - if (!$error) { + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; + + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; + $sql .= " WHERE ac.id != ".$object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; + $sql .= " WHERE element_id = ".$object->id; + $sql .= " AND element_type = '".$db->escape($object->element)."'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if (!$error) + { @@ -970 +601,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -975,45 +606,0 @@ - $object->loadReminders($remindertype, 0, false); - - // If there is reminders, we remove them - if (!empty($object->reminders)) { - foreach ($object->reminders as $reminder) { - if ($reminder->status < 1) { // If already sent, we never remove it - $reminder->delete($user); - } - } - $object->reminders = array(); - } - - // Create reminders for every assigned user if reminder is on - if ($addreminder == 'on') { - $actionCommReminder = new ActionCommReminder($db); - - $dateremind = dol_time_plus_duree($datep, -1 * $offsetvalue, $offsetunit); - - $actionCommReminder->dateremind = $dateremind; - $actionCommReminder->typeremind = $remindertype; - $actionCommReminder->offsetunit = $offsetunit; - $actionCommReminder->offsetvalue = $offsetvalue; - $actionCommReminder->status = $actionCommReminder::STATUS_TODO; - $actionCommReminder->fk_actioncomm = $object->id; - if ($remindertype == 'email') { - $actionCommReminder->fk_email_template = $modelmail; - } - - // the notification must be created for every user assigned to the event - foreach ($object->userassigned as $userassigned) { - $actionCommReminder->fk_user = $userassigned['id']; - $res = $actionCommReminder->create($user); - - if ($res <= 0) { - // If error - $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); - $action = 'create'; - $donotclearsession = 1; - break; - } - } - } - @@ -1021,8 +608,5 @@ - unset($_SESSION['assignedtoresource']); - - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - } - } else { + + $db->commit(); + } + else + { @@ -1035,6 +619,8 @@ - if (!$error) { - if (!empty($backtopage)) { - unset($_SESSION['assignedtouser']); - header("Location: ".$backtopage); - exit; - } + if (!$error) + { + if (!empty($backtopage)) + { + unset($_SESSION['assignedtouser']); + header("Location: ".$backtopage); + exit; + } @@ -1044,2 +630,5 @@ -// Delete event -if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') { +/* + * delete event + */ +if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') +{ @@ -1047,6 +636,7 @@ - $object->fetch_optionals(); - $object->fetch_userassigned(); - $object->oldcopy = dol_clone($object, 2); - - if ($user->hasRight('agenda', 'myactions', 'delete') - || $user->hasRight('agenda', 'allactions', 'delete')) { + $object->fetch_optionals(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; + + if ($user->rights->agenda->myactions->delete + || $user->rights->agenda->allactions->delete) + { @@ -1055 +645,2 @@ - if ($result >= 0) { + if ($result >= 0) + { @@ -1058 +649,3 @@ - } else { + } + else + { @@ -1068,98 +661,103 @@ -if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { - $error = 0; - - $shour = dol_print_date($object->datep, "%H", 'tzuserrel'); // We take the date visible by user $newdate is also date visible by user. - $smin = dol_print_date($object->datep, "%M", 'tzuserrel'); - - $newdate = GETPOST('newdate', 'alpha'); - if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) { - header("Location: ".$backtopage, true, 307); - exit; - } - - $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4), 'tzuserrel'); - //print dol_print_date($datep, 'dayhour');exit; - - if ($datep != $object->datep) { - if (!empty($object->datef)) { - $object->datef += $datep - $object->datep; - } - $object->datep = $datep; - - if (!$error) { - // check if an event resource is already in use - if (getDolGlobalString('RESOURCE_USED_IN_EVENT_CHECK') && $object->element == 'action') { - $eventDateStart = $object->datep; - $eventDateEnd = $object->datef; - - $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id <> ".((int) $object->id); - $sql .= " AND er.resource_id IN ("; - $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".((int) $object->id); - $sql .= " AND element_type = '".$db->escape($object->element)."'"; - $sql .= " AND busy = 1"; - $sql .= ")"; - $sql .= " AND er.busy = 1"; - $sql .= " AND ("; - - // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; - // event date end between ac.datep and ac.datep2 - if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; - } - // event date start before ac.datep and event date end after ac.datep2 - $sql .= " OR ("; - $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; - if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; - } - $sql .= ")"; - - $sql .= ")"; - $resql = $db->query($sql); - if (!$resql) { - $error++; - $object->error = $db->lasterror(); - $object->errors[] = $object->error; - } else { - if ($db->num_rows($resql) > 0) { - // Resource already in use - $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; - while ($obj = $db->fetch_object($resql)) { - $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); - } - $object->errors[] = $object->error; - } - $db->free($resql); - } - - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - - if (!$error) { - $db->begin(); - $result = $object->update($user); - if ($result < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } else { - $db->commit(); - } - } - } - if (!empty($backtopage)) { - header("Location: ".$backtopage, true, 307); - exit; - } else { - $action = ''; - } +if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') +{ + $error = 0; + + $shour = dol_print_date($object->datep, "%H"); + $smin = dol_print_date($object->datep, "%M"); + + $newdate = GETPOST('newdate', 'alpha'); + if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) + { + header("Location: ".$backtopage); + exit; + } + + $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4)); + if ($datep != $object->datep) + { + if (!empty($object->datef)) + { + $object->datef += $datep - $object->datep; + } + $object->datep = $datep; + + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; + + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; + $sql .= " WHERE ac.id != ".$object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; + $sql .= " WHERE element_id = ".$object->id; + $sql .= " AND element_type = '".$db->escape($object->element)."'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; + + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; + } + $sql .= ")"; + + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } + + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if (!$error) { + $db->begin(); + $result = $object->update($user); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } else { + $db->commit(); + } + } + } + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + else + { + $action = ''; + } @@ -1170 +768 @@ -$permissiontoadd = ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'read'))); +$permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); @@ -1172 +770 @@ - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -1183,9 +781 @@ -$arrayrecurrulefreq = array( - 'no'=>$langs->trans("OnceOnly"), - 'MONTHLY'=>$langs->trans("EveryMonth"), - 'WEEKLY'=>$langs->trans("EveryWeek") - // 'DAILY'=>$langs->trans("EveryDay") -); - - -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; @@ -1194 +784,2 @@ -if ($action == 'create') { +if ($action == 'create') +{ @@ -1198 +789,2 @@ - if (!empty($socpeopleassigned[0])) { + if (!empty($socpeopleassigned[0])) + { @@ -1200,3 +792 @@ - if ($result < 0) { - dol_print_error($db, $contact->error); - } + if ($result < 0) dol_print_error($db, $contact->error); @@ -1207,3 +797,4 @@ - if (!empty($conf->use_javascript_ajax)) { - print "\n".''."\n"; - } + print ''."\n"; + } @@ -1267,15 +844,7 @@ - print ''; - if ($backtopage) { - print ''; - } - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { - print ''; - } - - if (GETPOST("actioncode", 'aZ09') == 'AC_RDV') { - print load_fiche_titre($langs->trans("AddActionRendezVous"), '', 'title_agenda'); - } else { - print load_fiche_titre($langs->trans("AddAnAction"), '', 'title_agenda'); - } - - print dol_get_fiche_head(); + if ($backtopage) print ''; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) print ''; + + if (GETPOST("actioncode", 'aZ09') == 'AC_RDV') print load_fiche_titre($langs->trans("AddActionRendezVous"), '', 'title_agenda'); + else print load_fiche_titre($langs->trans("AddAnAction"), '', 'title_agenda'); + + dol_fiche_head(); @@ -1286 +855,2 @@ - if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { @@ -1288,4 +858,2 @@ - $default = getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT', 'AC_RDV'); - print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); - $selectedvalue = GETPOSTISSET("actioncode") ? GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default); - print $formactions->select_type_actions($selectedvalue, "actioncode", "systemauto", 0, -1, 0, 1); // TODO Replace 0 with -2 in onlyautoornot + $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ? '' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT); + $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default), "actioncode", "systemauto", 0, -1); @@ -1296,8 +864,35 @@ - print ''.$langs->trans("Label").''; - - // Full day - print ''.$langs->trans("Date").''; - - // Recurring event - $userepeatevent = (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0); - if ($userepeatevent) { + print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Label").''; + + // Full day + print ''.$langs->trans("EventOnFullDay").''; + + // Date start + $datep = ($datep ? $datep : $object->datep); + if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); + print ''.$langs->trans("DateActionStart").''; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" + } else { + print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart'); + } + print ''; + + // Date end + $datef = ($datef ? $datef : $object->datef); + if (GETPOST('datef', 'int', 1)) $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 0); + if (empty($datef) && !empty($datep) && !empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS)) + { + $datef = dol_time_plus_duree($datep, $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS, 'h'); + } + print ''.$langs->trans("DateActionEnd").''; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + } else { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + } + print ''; + + // Dev in progress + $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); + if ($userepeatevent) + { @@ -1305,5 +900,8 @@ - //print ''; - print '        
'; - print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); - print ''; - + print ''.$langs->trans("RepeatEvent").''; + print ''; + $arrayrecurrulefreq = array( + 'no'=>$langs->trans("No"), + 'MONTHLY'=>$langs->trans("EveryMonth"), + 'WEEKLY'=>$langs->trans("EveryWeek"), + //'DAYLY'=>$langs->trans("EveryDay") + ); @@ -1313,16 +911,3 @@ - $object->recurrule = GETPOSTISSET('recurrulefreq') ? "FREQ=".GETPOST('recurrulefreq', 'alpha') : ""; - $object->recurrule .= GETPOSTISSET('BYMONTHDAY') ? "_BYMONTHDAY".GETPOST('BYMONTHDAY', 'alpha') : ""; - $object->recurrule .= GETPOSTISSET('BYDAY') ? "_BYDAY".GETPOST('BYDAY', 'alpha') : ""; - - - $reg = array(); - if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { - $selectedrecurrulefreq = $reg[1]; - } - if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebymonthday = $reg[1]; - } - if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebyday = $reg[1]; - } - + if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) $selectedrecurrulefreq = $reg[1]; + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebymonthday = $reg[1]; + if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebyday = $reg[1]; @@ -1330,4 +914,0 @@ - // print ''; - // For recursive event - - @@ -1342,17 +923,3 @@ - // limit date - $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate : ''; - print ''; - - print ''; - print '
'; - //print ''; - } - + '; + print ''; + } + + // Status + print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + print ''; + $percent = -1; + if (isset($_GET['status']) || isset($_POST['status'])) $percent = GETPOST('status'); + elseif (isset($_GET['percentage']) || isset($_POST['percentage'])) $percent = GETPOST('percentage'); + else + { + if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0'; + elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100; + } + $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); @@ -1389,34 +966,8 @@ - $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); - if (GETPOST('datep', 'int', 1)) { - $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuserrel'); - } - $datef = ($datef ? $datef : $object->datef); - if (GETPOST('datef', 'int', 1)) { - $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuserrel'); - } - if (empty($datef) && !empty($datep)) { - if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || !getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT')) { - $datef = dol_time_plus_duree($datep, (!getDolGlobalString('AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS') ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); - } - } - - // Date start - print ''; - print ''; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo" - } else { - print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); - } - print '     -     '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); - } - print ''; - - print ' '; - - // Assigned to user - print ''.$langs->trans("ActionAffectedTo").''; + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { + print ''.$langs->trans("Location").''; + } + + // Assigned to + print ''.$langs->trans("ActionAffectedTo").''; @@ -1424,10 +975,5 @@ - $listofcontactid = array(); - $listofotherid = array(); - - if (empty($donotclearsession)) { - $assignedtouser = GETPOST("assignedtouser") ? GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); - if ($assignedtouser) { - $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0); // Owner first - } - //$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init - $listofuserid[$assignedtouser]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1); // 1 by default at first init + if (empty($donotclearsession)) + { + $assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); + if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first + $listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 1; // 1 by default at first init @@ -1435,2 +981,5 @@ - } else { - if (!empty($_SESSION['assignedtouser'])) { + } + else + { + if (!empty($_SESSION['assignedtouser'])) + { @@ -1439,4 +988 @@ - $firstelem = reset($listofuserid); - if (isset($listofuserid[$firstelem['id']])) { - $listofuserid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing - } + $listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 0; // 0 by default when refreshing @@ -1446,0 +993,6 @@ + /*if (in_array($user->id,array_keys($listofuserid))) + { + print '
'; + print $langs->trans("MyAvailability").': '.$langs->trans("Busy"); + print '
'; + }*/ @@ -1449,2 +1001,3 @@ - // Done by - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { + // Realised by + if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) + { @@ -1452 +1005 @@ - print $form->select_dolusers(GETPOSTISSET("doneby") ? GETPOST("doneby", 'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); + print $form->select_dolusers(GETPOST("doneby") ?GETPOST("doneby") : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); @@ -1456,6 +1009 @@ - // Location - if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { - print ''.$langs->trans("Location").''; - } - - if (isModEnabled('categorie')) { + if ($conf->categorie->enabled) { @@ -1463 +1011 @@ - print ''.$langs->trans("Categories").''; + print ''.$langs->trans("Categories").''; @@ -1465 +1013 @@ - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%'); @@ -1469,44 +1016,0 @@ - if (isModEnabled('resource')) { - // Categories - print ''.$langs->trans("Resource").''; - - $listofresourceid = array(); - if (empty($donotclearsession)) { - $assignedtoresource = GETPOST("assignedtoresource"); - if ($assignedtoresource) { - $listofresourceid[$assignedtoresource] = array('id'=>$assignedtoresource, 'mandatory'=>0); // Owner first - } - $_SESSION['assignedtoresource'] = json_encode($listofresourceid); - } else { - if (!empty($_SESSION['assignedtoresource'])) { - $listofresourceid = json_decode($_SESSION['assignedtoresource'], true); - } - $firstelem = reset($listofresourceid); - if (isset($listofresourceid[$firstelem['id']])) { - $listofresourceid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing - } - } - print '
'; - print $form->select_dolresources_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtoresource', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofresourceid); - print '
'; - print ''; - } - - // Status - print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - print ''; - $percent = $complete !=='' ? $complete : -1; - if (GETPOSTISSET('status')) { - $percent = GETPOST('status'); - } elseif (GETPOSTISSET('percentage')) { - $percent = GETPOST('percentage', 'int'); - } else { - if ($complete == '0' || GETPOST("afaire") == 1) { - $percent = '0'; - } elseif ($complete == 100 || GETPOST("afaire") == 2) { - $percent = 100; - } - } - $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); - print ''; - @@ -1521 +1025,2 @@ - if (isModEnabled("societe")) { + if ($conf->societe->enabled) + { @@ -1524 +1029,2 @@ - if (GETPOST('socid', 'int') > 0) { + if (GETPOST('socid', 'int') > 0) + { @@ -1529 +1035,3 @@ - } else { + } + else + { @@ -1534 +1042 @@ - print img_picto('', 'company', 'class="paddingrightonly"').$form->select_company($user->socid, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); + print $form->select_company($user->socid, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300'); @@ -1536 +1044 @@ - print img_picto('', 'company', 'class="paddingrightonly"').$form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300 widthcentpercentminusxx maxwidth500'); + print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300'); @@ -1544,14 +1052,2 @@ - if (GETPOST('contactid', 'int')) { - $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); - } - if ($origin=='contact') { - $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); - } - // select "all" or "none" contact by default - if (getDolGlobalInt('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT')) { - $select_contact_default = 0; // select "all" contacts by default : avoid to use it if there is a lot of contacts - } else { - $select_contact_default = -1; // select "none" by default - } - print img_picto('', 'contact', 'class="paddingrightonly"'); - print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 widthcentpercentminusxx maxwidth500', false, 0, array(), false, 'multiple', 'contactid'); + if (GETPOST('contactid', 'int')) $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); + print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); @@ -1562 +1058,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -1567,6 +1064,5 @@ - print ''.$langs->trans("Project").''; - print img_picto('', 'project', 'class="pictofixedwidth"'); - print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx maxwidth500'); - - print ' '; - print ''; + print ''.$langs->trans("Project").''; + + $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + + print ' '; @@ -1580,2 +1076 @@ - var url = "'.DOL_URL_ROOT.'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val(); - console.log("Call url to get new list of tasks: "+url); + var url = "'.$url.'&projectid="+$("#projectid").val(); @@ -1583,2 +1078,2 @@ - console.log(data); - if (data) $("#taskid").html(data).select2(); + console.log($( data ).find("#taskid").html()); + if (data) $("#taskid").html( $( data ).find("#taskid").html() ).select2(); @@ -1592 +1086,0 @@ - // Task @@ -1594 +1088 @@ - print img_picto('', 'projecttask', 'class="paddingrightonly"'); + @@ -1596,7 +1090,3 @@ - if (!empty($projectid)) { - $projectsListId = $projectid; - } - - $tid = GETPOSTISSET("projecttaskid") ? GETPOST("projecttaskid", 'int') : (GETPOSTISSET("taskid") ? GETPOST("taskid", 'int') : ''); - - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500 widthcentpercentminusxx', $projectsListId); + if (!empty($projectid)) { $projectsListId = $projectid; } + $tid = GETPOST("projecttaskid") ?GETPOST("projecttaskid") : ''; + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500', $projectsListId); @@ -1607 +1097,2 @@ - if (!empty($origin) && !empty($originid)) { + if (!empty($origin) && !empty($originid)) + { @@ -1609,24 +1100,11 @@ - - $hasPermissionOnLinkedObject = 0; - - $elProp = getElementProperties($origin); - if ($user->hasRight($elProp['module'], 'read') || $user->hasRight($elProp['module'], $elProp['element'], 'read')) { - $hasPermissionOnLinkedObject = 1; - } - //var_dump('origin='.$origin.' originid='.$originid.' hasPermissionOnLinkedObject='.$hasPermissionOnLinkedObject); - - if (! in_array($origin, array('societe', 'project', 'task', 'user'))) { - // We do not use link for object that already contains a hard coded field to make links with agenda events - print ''.$langs->trans("LinkedObject").''; - print ''; - if ($hasPermissionOnLinkedObject) { - print dolGetElementUrl($originid, $origin, 1); - print ''; - print ''; - print ''; - print ''; - } else { - print ''; - } - print ''; - } + print ''.$langs->trans("LinkedObject").''; + print ''.dolGetElementUrl($originid, $origin, 1).''; + print ''; + print ''; + print ''; + print ''; + } + + if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg)) + { + $object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]); @@ -1636,11 +1114,2 @@ - if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS')) { - print ''.$langs->trans("Priority").''; - print ''; - print ''; - } - - // Description - print ''.$langs->trans("Description").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', (GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : $object->note_private), '', 120, 'dolibarr_notes', 'In', true, true, isModEnabled('fckeditor'), ROWS_4, '90%'); - $doleditor->Create(); + print ''.$langs->trans("Priority").''; + print ''; @@ -1649,6 +1118,14 @@ - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'create', $parameters); + // Description + print ''.$langs->trans("Description").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('note', (GETPOST('note', 'none') ? GETPOST('note', 'none') : $object->note_private), '', 180, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); + $doleditor->Create(); + print ''; + + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit', $parameters); @@ -1659,69 +1136,7 @@ - - if (getDolGlobalString('AGENDA_REMINDER_EMAIL') || getDolGlobalString('AGENDA_REMINDER_BROWSER')) { - //checkbox create reminder - print '
'; - print '
'; - print '

'; - - print ''; - - print "\n".''."\n"; - } - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Add"); + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -1733 +1148,2 @@ -if ($id > 0) { +if ($id > 0) +{ @@ -1735 +1151,2 @@ - if ($result1 <= 0) { + if ($result1 <= 0) + { @@ -1749,5 +1166,6 @@ - if ($listUserAssignedUpdated || $donotclearsession) { - $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status - - $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel'); - $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel'); + if ($listUserAssignedUpdated || $donotclearsession) + { + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + + $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); + $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -1761,2 +1179,2 @@ - $object->fulldayevent = GETPOST("fullday") ? 1 : 0; - $object->location = GETPOST('location', "alphanohtml"); + $object->fulldayevent = GETPOST("fullday") ? 1 : 0; + $object->location = GETPOST('location', "alpanohtml"); @@ -1765,4 +1183,2 @@ - foreach ($socpeopleassigned as $tmpid) { - $object->socpeopleassigned[$id] = array('id' => $tmpid); - } - $object->contact_id = GETPOST("contactid", 'int'); + foreach ($socpeopleassigned as $tmpid) $object->socpeopleassigned[$id] = array('id' => $tmpid); + $object->contactid = GETPOST("contactid", 'int'); @@ -1771,4 +1187,5 @@ - $object->note_private = GETPOST("note", 'restricthtml'); - } - - if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { + $object_private = GETPOST("note", 'none'); + } + + if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) + { @@ -1779,10 +1196,2 @@ - if ($object->authorid > 0) { - $tmpuser = new User($db); - $res = $tmpuser->fetch($object->authorid); - $object->author = $tmpuser; - } - if ($object->usermodid > 0) { - $tmpuser = new User($db); - $res = $tmpuser->fetch($object->usermodid); - $object->usermod = $tmpuser; - } + if ($object->authorid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; } + if ($object->usermodid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; } @@ -1800 +1208,0 @@ - @@ -1802,8 +1210,11 @@ - if ($action == 'delete') { - print $form->formconfirm("card.php?id=".urlencode($id), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1); - } - - if ($action == 'edit') { - if (!empty($conf->use_javascript_ajax)) { - print "\n".''."\n"; - } + print ''."\n"; + } @@ -1841,9 +1248,4 @@ - print ''; - if ($backtopage) { - print ''; - } - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && ! preg_match('/^TICKET_MSG_PRIVATE/', $object->code)) { - print ''; - } - - print dol_get_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action'); + if ($backtopage) print ''; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) print ''; + + dol_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action'); @@ -1857,10 +1259,11 @@ - if (getDolGlobalString('AGENDA_USE_EVENT_TYPE') && $object->elementtype != "ticket") { - print ''.$langs->trans("Type").''; - if ($object->type_code != 'AC_OTH_AUTO') { - print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); - print $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ? GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto", 0, 0, 0, 1); - } else { - print ''; - print $object->getTypePicto(); - print $langs->trans("Action".$object->type_code); - } + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + print ''.$langs->trans("Type").''; + if ($object->type_code != 'AC_OTH_AUTO') + { + $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); + } + else + { + print ''.$langs->trans("Action".$object->type_code); + } @@ -1870,7 +1272,0 @@ - // Private - if ($object->elementtype == 'ticket') { - print ''.$langs->trans("MarkMessageAsPrivate"); - print ' '.$form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help'); - print 'code) ? ' checked' : '').'>'; - } - @@ -1878,64 +1274,14 @@ - print ''.$langs->trans("Title").''; - - // Full day event - print ''.$langs->trans("Date").'fulldayevent ? ' checked' : '').'>'; - print ''; - - // // Recurring event - // $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); - // if ($userepeatevent) { - // // Repeat - // //print ''; - // print '        
'; - // print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); - // print ''; - // $selectedrecurrulefreq = 'no'; - // $selectedrecurrulebymonthday = ''; - // $selectedrecurrulebyday = ''; - // if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { - // $selectedrecurrulefreq = $reg[1]; - // } - // if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) { - // $selectedrecurrulebymonthday = $reg[1]; - // } - // if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { - // $selectedrecurrulebyday = $reg[1]; - // } - // print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); - // // If recurrulefreq is MONTHLY - // print ''; - // // If recurrulefreq is WEEKLY - // print ''; - // print ''; - // print '
'; - // //print ''; - // } + print ''.$langs->trans("Title").''; + + // Full day event + print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; + + // Date start + print ''.$langs->trans("DateActionStart").''; + if (GETPOST("afaire") == 1) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } else { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } @@ -1943,9 +1289,2 @@ - - // Date start - end - print ''; - /*print ''.$langs->trans("DateActionStart").''; - print ' - '; - print 'type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").''; - */ - print ''; - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); + // Date end + print ''.$langs->trans("DateActionEnd").''; @@ -1953,14 +1292,6 @@ - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } - print '     -     '; - if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); - } + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } else { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } @@ -1969 +1300,68 @@ - print ' '; + // Dev in progress + $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); + if ($userepeatevent) + { + // Repeat + print ''.$langs->trans("RepeatEvent").''; + print ''; + $arrayrecurrulefreq = array( + 'no'=>$langs->trans("No"), + 'MONTHLY'=>$langs->trans("EveryMonth"), + 'WEEKLY'=>$langs->trans("EveryWeek"), + //'DAYLY'=>$langs->trans("EveryDay"), + ); + $selectedrecurrulefreq = 'no'; + $selectedrecurrulebymonthday = ''; + $selectedrecurrulebyday = ''; + if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) $selectedrecurrulefreq = $reg[1]; + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebymonthday = $reg[1]; + if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebyday = $reg[1]; + print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); + // If recurrulefreq is MONTHLY + print ''; + // If recurrulefreq is WEEKLY + print ''; + print ''; + print ''; + } + + // Status + print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + $percent = GETPOST("percentage") ? GETPOST("percentage") : $object->percentage; + $formactions->form_select_status_action('formaction', $percent, 1); + print ''; + + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { + print ''.$langs->trans("Location").''; + } @@ -1972,31 +1370,39 @@ - $listofuserid = array(); // User assigned - if (empty($donotclearsession)) { - if ($object->userownerid > 0) { - $listofuserid[$object->userownerid] = array( - 'id'=>$object->userownerid, - 'type'=>'user', - //'transparency'=>$object->userassigned[$user->id]['transparency'], - 'transparency'=>$object->transparency, // Force transparency on ownerfrom event - 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], - 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] - ); - } - if (!empty($object->userassigned)) { // Now concat assigned users - // Restore array with key with same value than param 'id' - $tmplist1 = $object->userassigned; - foreach ($tmplist1 as $key => $val) { - if ($val['id'] && $val['id'] != $object->userownerid) { - $listofuserid[$val['id']] = $val; - } - } - } - $_SESSION['assignedtouser'] = json_encode($listofuserid); - } else { - if (!empty($_SESSION['assignedtouser'])) { - $listofuserid = json_decode($_SESSION['assignedtouser'], true); - } - } - $listofcontactid = $object->socpeopleassigned; // Contact assigned - $listofotherid = $object->otherassigned; // Other undefined email (not used yet) - - print ''.$langs->trans("ActionAssignedTo").''; + $listofuserid = array(); // User assigned + if (empty($donotclearsession)) + { + if ($object->userownerid > 0) + { + $listofuserid[$object->userownerid] = array( + 'id'=>$object->userownerid, + 'type'=>'user', + //'transparency'=>$object->userassigned[$user->id]['transparency'], + 'transparency'=>$object->transparency, // Force transparency on ownerfrom event + 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], + 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] + ); + } + if (!empty($object->userassigned)) // Now concat assigned users + { + // Restore array with key with same value than param 'id' + $tmplist1 = $object->userassigned; + foreach ($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) + { + $listofuserid[$val['id']] = $val; + } + } + } + $_SESSION['assignedtouser'] = json_encode($listofuserid); + } + else + { + if (!empty($_SESSION['assignedtouser'])) + { + $listofuserid = json_decode($_SESSION['assignedtouser'], true); + } + } + $listofcontactid = $object->socpeopleassigned; // Contact assigned + $listofotherid = $object->otherassigned; // Other undefined email (not used yet) + + print ''.$langs->trans("ActionAssignedTo").''; @@ -2015 +1421,2 @@ - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { + if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) + { @@ -2020,12 +1426,0 @@ - - // Location - if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { - print ''.$langs->trans("Location").''; - } - - // Status - print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage; - $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); - print ''; - @@ -2033 +1428 @@ - if (isModEnabled('categorie')) { + if ($conf->categorie->enabled) { @@ -2042 +1437 @@ - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); @@ -2052,3 +1447,4 @@ - print ''; - - if (isModEnabled("societe")) { + print '
'; + + if ($conf->societe->enabled) + { @@ -2058 +1454 @@ - print '
'; + print '
'; @@ -2063 +1459 @@ - print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company($object->socid, 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth200'); + print $form->select_company($object->socid, 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth200'); @@ -2070 +1466 @@ - print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts(!getDolGlobalString('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? $object->socid : 0, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'minwidth300 widthcentpercentminusx', false, 0, 0, array(), 'multiple', 'contactid'); + print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); @@ -2077 +1473,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -2081,4 +1478,4 @@ - print img_picto('', 'project', 'class="pictofixedwidth"'); - $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500 widthcentpercentminusxx'); - if ($numprojet == 0) { - print '   '; + $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500'); + if ($numprojet == 0) + { + print '   '; @@ -2090,5 +1487,3 @@ - if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS')) { - print '
'; - } + print ''; @@ -2097 +1492,2 @@ - if (!empty($object->fk_element) && !empty($object->elementtype)) { + if (!empty($object->fk_element) && !empty($object->elementtype)) + { @@ -2099 +1495 @@ - print ''; + print ''; @@ -2102,2 +1498,3 @@ - if ($object->elementtype == 'task' && isModEnabled('project')) { - print ''; - } else { - print ''; + })'; + print ''."\n"; + + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); + print ''; + + print ''; + } + else + { + print ''; @@ -2136,13 +1535,14 @@ - // Description - print ''; - - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) { + // Description + print ''; + + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { @@ -2154,89 +1554,7 @@ - // Reminders - if (getDolGlobalString('AGENDA_REMINDER_EMAIL') || getDolGlobalString('AGENDA_REMINDER_BROWSER')) { - $filteruserid = $user->id; - if ($user->hasRight('agenda', 'allactions', 'read')) { - $filteruserid = 0; - } - $object->loadReminders('', $filteruserid, false); - - print '
'; - - if (count($object->reminders) > 0) { - $checked = 'checked'; - $keys = array_keys($object->reminders); - $firstreminderId = array_shift($keys); - - $actionCommReminder = $object->reminders[$firstreminderId]; - } else { - $checked = ''; - $actionCommReminder = new ActionCommReminder($db); - $actionCommReminder->offsetvalue = getDolGlobalInt('AGENDA_REMINDER_DEFAULT_OFFSET', 30); - $actionCommReminder->offsetunit = 'i'; - $actionCommReminder->typeremind = 'email'; - } - $disabled = ''; - if ($object->datep < dol_now()) { - //$disabled = 'disabled title="'.dol_escape_htmltag($langs->trans("EventExpired")).'"'; - } - - print '
'; - - print '
'; - - print '
'; - - print '
'.$langs->trans("Priority").''; - print ''; - print '
'.$langs->trans("Priority").''; + print ''; + print '
'; + if ($object->elementtype == 'task' && !empty($conf->projet->enabled)) + { + print ''; @@ -2106,6 +1503,6 @@ - $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; - - // update task list - print "\n".''."\n"; - - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); - print ''; - - print ''; - print dolGetElementUrl($object->fk_element, $object->elementtype, 1); - print ''; - print ''; - print ''; + print dolGetElementUrl($object->fk_element, $object->elementtype, 1); + print ''; + print ''; + print '
'.$langs->trans("Description").''; - // Editeur wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note_private, '', 120, 'dolibarr_notes', 'In', true, true, isModEnabled('fckeditor'), ROWS_4, '90%'); - $doleditor->Create(); - print '
'.$langs->trans("Description").''; + // Editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('note', $object->note_private, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor->Create(); + print '
'; - - // Reminder - print ''; - - // Reminder Type - print ''; - - $hide = ''; - if ($actionCommReminder->typeremind == 'browser') { - $hide = 'style="display:none;"'; - } - - // Mail Model - if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) { - print ''; - } - - print '
'.$langs->trans("ReminderTime").''; - print ' '; - print $form->selectTypeDuration('offsetunit', $actionCommReminder->offsetunit, array('y', 'm')); - print '
'.$langs->trans("ReminderType").''; - print $form->selectarray('selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); - print '
'.$langs->trans("EMailTemplates").''; - print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1, 1); - print '
'; - - print "\n".''."\n"; - - print ''; // End of div for reminderparameters - } - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -2245,4 +1563,5 @@ - } else { - print dol_get_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action'); - - $formconfirm = ''; + } + else + { + dol_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action'); + @@ -2251,15 +1570,6 @@ - if ($action == 'clone') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.GETPOST('id'), $langs->trans('ToClone'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', array(), 'yes', 1); - } - - // Call Hook formConfirm - $parameters = array(); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm.=$hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm=$hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; + if ($action == 'clone') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.GETPOST('id'), $langs->trans('ToClone'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', $formquestion, 'yes', 1); + + print $formconfirm; + } @@ -2269,4 +1579,2 @@ - $linkback .= ''; - $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("BackToList").''; - $linkback .= ''; + $linkback .= img_picto($langs->trans("BackToList"), 'object_list-alt', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("BackToList").''; @@ -2275,4 +1583,2 @@ - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewCal").''; - $linkback .= ''; + $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("ViewCal").''; @@ -2281,4 +1587,2 @@ - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewWeek").''; - $linkback .= ''; + $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("ViewWeek").''; @@ -2287,4 +1591,2 @@ - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewDay").''; - $linkback .= ''; + $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("ViewDay").''; @@ -2293,13 +1595,2 @@ - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewPerUser").''; - $linkback .= ''; - - // Add more views from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); - if (empty($reshook)) { - $linkback .= $hookmanager->resPrint; - } elseif ($reshook > 1) { - $linkback = $hookmanager->resPrint; - } + $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("ViewPerUser").''; @@ -2313,19 +1604,34 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - //$morehtmlref .= '
'; - if ($usercancreate) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + //$morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; + if ($user->rights->agenda->allactions->create || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } + } @@ -2338,2 +1644 @@ - print '
'; - print '
'; + print '
'; @@ -2347,14 +1652,7 @@ - if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { - print ''.$langs->trans("Type").''; - print $object->getTypePicto(); - print $langs->trans("Action".$object->type_code); - print ''; - } - - // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent ? 1 : 0, 3).''; - - // Event into a serie - if ($object->recurid) { - print ''.$langs->trans("EventIntoASerie").''.dol_escape_htmltag($object->recurid).''; - } + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + print ''.$langs->trans("Type").''.$langs->trans($object->type).''; + } + + // Full day event + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; @@ -2363,3 +1661 @@ - if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { - $rowspan++; - } + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; @@ -2368,14 +1664,4 @@ - print ''.$langs->trans("DateActionStart").''; - // Test a date before the 27 march and one after - //print dol_print_date($object->datep, 'dayhour', 'gmt'); - //print dol_print_date($object->datep, 'dayhour', 'tzuser'); - //print dol_print_date($object->datep, 'dayhour', 'tzuserrel'); - if (empty($object->fulldayevent)) { - print dol_print_date($object->datep, 'dayhour', 'tzuserrel'); - } else { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel')); - } - if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) { - print img_warning($langs->trans("Late")); - } + print ''.$langs->trans("DateActionStart").''; + if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); + else print dol_print_date($object->datep, 'day'); + if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); @@ -2386,10 +1672,4 @@ - print ''.$langs->trans("DateActionEnd").''; - if (empty($object->fulldayevent)) { - print dol_print_date($object->datef, 'dayhour', 'tzuserrel'); - } else { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel')); - } - if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) { - print img_warning($langs->trans("Late")); - } + print ''.$langs->trans("DateActionEnd").''; + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); + else print dol_print_date($object->datef, 'day'); + if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); @@ -2398,7 +1678,8 @@ - // Location - if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { - print ''.$langs->trans("Location").''.$object->location.''; - } - - // Assigned to user - print ''.$langs->trans("ActionAssignedTo").''; + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { + print ''.$langs->trans("Location").''.$object->location.''; + } + + // Assigned to + print ''.$langs->trans("ActionAssignedTo").''; @@ -2406,2 +1687,4 @@ - if (empty($donotclearsession)) { - if ($object->userownerid > 0) { + if (empty($donotclearsession)) + { + if ($object->userownerid > 0) + { @@ -2415 +1698,2 @@ - if (!empty($object->userassigned)) { // Now concat assigned users + if (!empty($object->userassigned)) // Now concat assigned users + { @@ -2418,4 +1702,3 @@ - foreach ($tmplist1 as $key => $val) { - if ($val['id'] && $val['id'] != $object->userownerid) { - $listofuserid[$val['id']] = $val; - } + foreach ($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val; @@ -2425,2 +1708,5 @@ - } else { - if (!empty($_SESSION['assignedtouser'])) { + } + else + { + if (!empty($_SESSION['assignedtouser'])) + { @@ -2438,0 +1725,2 @@ + //var_dump($object->userassigned); + //var_dump($listofuserid); @@ -2447,3 +1735,5 @@ - if (getDolGlobalString('AGENDA_ENABLE_DONEBY')) { - print ''.$langs->trans("ActionDoneBy").''; - if ($object->userdoneid > 0) { + if ($conf->global->AGENDA_ENABLE_DONEBY) + { + print ''.$langs->trans("ActionDoneBy").''; + if ($object->userdoneid > 0) + { @@ -2456 +1745,0 @@ - @@ -2458,2 +1747,2 @@ - if (isModEnabled('categorie')) { - print ''.$langs->trans("Categories").''; + if ($conf->categorie->enabled) { + print ''.$langs->trans("Categories").''; @@ -2466,3 +1755 @@ - print '
'; - - print '
'; + print '
'; @@ -2473,6 +1760,8 @@ - if (isModEnabled("societe")) { - // Related company - print ''.$langs->trans("ActionOnCompany").''; - print ''.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); - if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { - if ($object->thirdparty->fetch($object->thirdparty->id)) { + if ($conf->societe->enabled) + { + // Related company + print ''.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); + if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') + { + if ($object->thirdparty->fetch($object->thirdparty->id)) + { @@ -2486,4 +1775,6 @@ - print ''; - - if (!empty($object->socpeopleassigned)) { - foreach ($object->socpeopleassigned as $cid => $Tab) { + print ''; + + if (!empty($object->socpeopleassigned)) + { + foreach ($object->socpeopleassigned as $cid => $Tab) + { @@ -2493,5 +1784,4 @@ - if ($result < 0) { - dol_print_error($db, $contact->error); - } - - if ($result > 0) { + if ($result < 0) dol_print_error($db, $contact->error); + + if ($result > 0) + { @@ -2499,4 +1789,3 @@ - if ($object->type_code == 'AC_TEL') { - if (!empty($contact->phone_pro)) { - print '('.dol_print_phone($contact->phone_pro).')'; - } + if ($object->type_code == 'AC_TEL') + { + if (!empty($contact->phone_pro)) print '('.dol_print_phone($contact->phone_pro).')'; @@ -2507 +1796,3 @@ - } else { + } + else + { @@ -2514,2 +1805,2 @@ - print ''.$langs->trans("Priority").''; - print($object->priority ? $object->priority : ''); + print ''.$langs->trans("Priority").''; + print ($object->priority ? $object->priority : ''); @@ -2520 +1811,2 @@ - if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe', 'contact', 'project'))) { + if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe', 'contact', 'project'))) + { @@ -2524,6 +1816,3 @@ - print ''; - if (empty($link)) { - print ''.$langs->trans("ObjectDeleted").''; - } else { - print $link; - } + print ''; + if (empty($link)) print ''.$langs->trans("ObjectDeleted").''; + else print $link; @@ -2533,14 +1821,0 @@ - //mail information - if (!empty($object->email_msgid)) { - print ''.$langs->trans('MailTopic').''; - print ''.dol_escape_htmltag($object->email_subject).''; - print ''.$langs->trans('MailFrom').''; - print ''.dol_escape_htmltag($object->email_from).''; - print ''.$langs->trans('MailTo').''; - print ''.dol_escape_htmltag($object->email_to).''; - if (!empty($object->email_tocc)) { - print ''.$langs->trans('MailCC').''; - print ''.dol_escape_htmltag($object->email_tocc).''; - } - } - @@ -2548 +1823 @@ - print ''.$langs->trans("Description").''; + print ''.$langs->trans("Description").''; @@ -2552,43 +1827,3 @@ - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - // Reminders - if (getDolGlobalString('AGENDA_REMINDER_EMAIL') || getDolGlobalString('AGENDA_REMINDER_BROWSER')) { - $filteruserid = $user->id; - if ($user->hasRight('agenda', 'allactions', 'read')) { - $filteruserid = 0; - } - $object->loadReminders('', $filteruserid, false); - - print ''.$langs->trans("Reminders").''; - - if (count($object->reminders) > 0) { - $tmpuserstatic = new User($db); - - foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { - print $TRemindTypes[$actioncommreminder->typeremind]['label']; - if ($actioncommreminder->fk_user > 0) { - $tmpuserstatic->fetch($actioncommreminder->fk_user); - print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; - } - print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; - - if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { - print ' - '; - print $langs->trans("NotSent"); - print ' '; - } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { - print ' - '; - print $langs->trans("Done"); - print ' '; - } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) { - print ' - '; - print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror); - print ' '; - } - print '
'; - } - } - - print ''; - } + // Other attributes + $cols = 3; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -2599,4 +1834,2 @@ - print '
'; - print '
'; - - print dol_get_fiche_end(); + + dol_fiche_end(); @@ -2607 +1840 @@ - * Action bar + * Barre d'actions @@ -2608,0 +1842 @@ + @@ -2613,6 +1847,11 @@ - if (empty($reshook)) { - if ($action != 'edit') { - if ($user->hasRight('agenda', 'allactions', 'create') || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) { - print ''; - } else { + if (empty($reshook)) + { + if ($action != 'edit') + { + if ($user->rights->agenda->allactions->create || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { + print ''; + } + else + { @@ -2622,2 +1861,3 @@ - if ($user->hasRight('agenda', 'allactions', 'create') || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) { + if ($user->rights->agenda->allactions->create || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { @@ -2625 +1865,3 @@ - } else { + } + else + { @@ -2629,4 +1871,7 @@ - if ($user->hasRight('agenda', 'allactions', 'delete') || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'delete'))) { - print ''; - } else { + if ($user->rights->agenda->allactions->delete || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) + { + print ''; + } + else + { @@ -2640,23 +1885,25 @@ - if ($action != 'edit') { - if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC')) { - print '
'; - print ''; // ancre - - /* - * Generated documents - */ - - $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - - $genallowed = $user->hasRight('agenda', 'myactions', 'read'); - $delallowed = $user->hasRight('agenda', 'myactions', 'create'); - - - print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang()); - - print '
'; - - - print '
'; - } + if ($action != 'edit') + { + if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) + { + print '
'; + print ''; // ancre + + /* + * Documents generes + */ + + $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + + $genallowed = $user->rights->agenda->myactions->read; + $delallowed = $user->rights->agenda->myactions->create; + + + print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); + + print '
'; + + + print '
'; + } --- /tmp/dsg/dolibarr/htdocs/comm/action/github_19.0.3_document.php +++ /tmp/dsg/dolibarr/htdocs/comm/action/client_document.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -38,3 +37 @@ -if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -} +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -46 +43 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -51,4 +48,3 @@ -if ($user->socid) { - $socid = $user->socid; -} -if ($user->socid > 0) { +if ($user->socid) $socid = $user->socid; +if ($user->socid > 0) +{ @@ -57,0 +54 @@ +$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); @@ -61 +58,2 @@ -if ($id > 0) { +if ($id > 0) +{ @@ -66,3 +63,0 @@ -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('actioncard', 'globalcard')); - @@ -71,2 +66,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -74,3 +69 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -80,6 +73,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; @@ -90,8 +78,0 @@ -$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); -if ($user->socid && $socid) { - $result = restrictedArea($user, 'societe', $socid); -} - -$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')); -$permissiontoadd = $usercancreate; - @@ -102,2 +83 @@ - -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -112,2 +92 @@ -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung'; - +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; @@ -116,4 +95,3 @@ -$now = dol_now(); -$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; - -if ($object->id > 0) { + +if ($object->id > 0) +{ @@ -126 +104,2 @@ - if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { + if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) + { @@ -131,10 +110,2 @@ - if ($object->authorid > 0) { - $tmpuser = new User($db); - $res = $tmpuser->fetch($object->authorid); - $object->author = $tmpuser; - } - if ($object->usermodid > 0) { - $tmpuser = new User($db); - $res = $tmpuser->fetch($object->usermodid); - $object->usermod = $tmpuser; - } + if ($object->authorid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; } + if ($object->usermodid > 0) { $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; } @@ -149 +120,7 @@ - print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); + $now = dol_now(); + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + + dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action'); + + $linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); + $linkback .= ''.$langs->trans("BackToList").''; @@ -152,37 +129,11 @@ - $linkback = ''; - $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("BackToList").''; - $linkback .= ''; - $linkback .= ''; - $linkback .= '
  • '; - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewCal").''; - $linkback .= ''; - $linkback .= '
  • '; - $linkback .= '
  • '; - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewWeek").''; - $linkback .= ''; - $linkback .= '
  • '; - $linkback .= '
  • '; - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewDay").''; - $linkback .= ''; - $linkback .= '
  • '; - $linkback .= '
  • '; - $linkback .= ''; - $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"'); - $linkback .= ''.$langs->trans("ViewPerUser").''; - $linkback .= ''; - - // Add more views from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); - if (empty($reshook)) { - $linkback .= $hookmanager->resPrint; - } elseif ($reshook > 1) { - $linkback = $hookmanager->resPrint; - } + $out = ''; + $out .= '
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewPerUser").''; + $out .= '
  • '.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewCal").''; + $out .= '
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewWeek").''; + $out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); + $out .= ''.$langs->trans("ViewDay").''; + + $linkback .= $out; @@ -194 +145,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -196,7 +148,9 @@ - //$morehtmlref .= '
    '; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + //$morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').': '; + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; @@ -204,8 +158 @@ - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } + $morehtmlref .= ''; @@ -225,6 +172,4 @@ - // Type of event - if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { - print ''.$langs->trans("Type").''; - print $object->getTypePicto(); - print $langs->trans("Action".$object->type_code); - print ''; + // Type + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + print ''.$langs->trans("Type").''.$object->type.''; @@ -234 +179 @@ - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent ? 1 : 0, 3).''; + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; @@ -238,9 +183,3 @@ - if (empty($object->fulldayevent)) { - print dol_print_date($object->datep, 'dayhour', 'tzuser'); - } else { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser')); - } - if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) { - print img_warning($langs->trans("Late")); - } + if (!$object->fulldayevent) print dol_print_date($object->datep, 'dayhour'); + else print dol_print_date($object->datep, 'day'); + if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); @@ -252,9 +191,3 @@ - if (empty($object->fulldayevent)) { - print dol_print_date($object->datef, 'dayhour', 'tzuser'); - } else { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser')); - } - if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) { - print img_warning($langs->trans("Late")); - } + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); + else print dol_print_date($object->datef, 'day'); + if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); @@ -264 +197,2 @@ - if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) { + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { @@ -271,5 +205,5 @@ - if (empty($donotclearsession)) { - if ($object->userownerid > 0) { - $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first - } - if (!empty($object->userassigned)) { // Now concat assigned users + if (empty($donotclearsession)) + { + if ($object->userownerid > 0) $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first + if (!empty($object->userassigned)) // Now concat assigned users + { @@ -277,5 +211,4 @@ - $tmplist1 = $object->userassigned; - foreach ($tmplist1 as $key => $val) { - if ($val['id'] && $val['id'] != $object->userownerid) { - $listofuserid[$val['id']] = $val; - } + $tmplist1 = $object->userassigned; $tmplist2 = array(); + foreach ($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']] = $val; @@ -285,2 +218,5 @@ - } else { - if (!empty($_SESSION['assignedtouser'])) { + } + else + { + if (!empty($_SESSION['assignedtouser'])) + { @@ -308 +244 @@ - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -310 +246,2 @@ - foreach ($filearray as $key => $file) { + foreach ($filearray as $key => $file) + { @@ -322 +259 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -326 +263 @@ - $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create'); + $permission = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create; @@ -328,2 +265,4 @@ - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ --- /tmp/dsg/dolibarr/htdocs/comm/action/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/comm/action/client_index.php @@ -10 +10 @@ - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018 Frédéric France @@ -33 +32,0 @@ -// Load Dolibarr environment @@ -40 +39 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -44,7 +43,3 @@ -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { - $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -} - -if (!getDolGlobalString('AGENDA_EXT_NB')) { - $conf->global->AGENDA_EXT_NB = 5; -} +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; + +if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; @@ -52,9 +47,5 @@ -$DELAYFORCACHE = 300; // 300 seconds - -$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); - -$check_holiday = GETPOST('check_holiday', 'int'); -$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); -$showbirthday = empty($conf->use_javascript_ajax) ? GETPOST("showbirthday", "int") : 1; + +$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); +$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); +$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$showbirthday = empty($conf->use_javascript_ajax) ?GETPOST("showbirthday", "int") : 1; @@ -63 +54,2 @@ -if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) { +if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) +{ @@ -67,4 +59,2 @@ -$newparam = ''; - -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -72,4 +62,2 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -77,6 +65,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "a.datec"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "a.datec"; @@ -85,7 +69,4 @@ -$socid = GETPOST("search_socid", "int") ? GETPOST("search_socid", "int") : GETPOST("socid", "int"); -if ($user->socid) { - $socid = $user->socid; -} -if ($socid < 0) { - $socid = ''; -} +$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'agenda', 0, '', 'myactions'); +if ($socid < 0) $socid = ''; @@ -94,16 +75,8 @@ -if (!$user->hasRight('agenda', 'myactions', 'read')) { - accessforbidden(); -} -if (!$user->hasRight('agenda', 'allactions', 'read')) { - $canedit = 0; -} -if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me - $filtert = $user->id; -} - -$action = GETPOST('action', 'aZ09'); - -$mode = GETPOST('mode', 'aZ09'); -if (empty($mode) && preg_match('/show_/', $action)) { - $mode = $action; // For backward compatibility -} +if (!$user->rights->agenda->myactions->read) accessforbidden(); +if (!$user->rights->agenda->allactions->read) $canedit = 0; +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me +{ + $filtert = $user->id; +} + +$action = GETPOST('action', 'alpha'); @@ -111,8 +84,8 @@ -$year = GETPOST("year", "int") ? GETPOST("year", "int") : date("Y"); -$month = GETPOST("month", "int") ? GETPOST("month", "int") : date("m"); -$week = GETPOST("week", "int") ? GETPOST("week", "int") : date("W"); -$day = GETPOST("day", "int") ? GETPOST("day", "int") : date("d"); -$pid = GETPOST("search_projectid", "int", 3) ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 -$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); -$maxprint = GETPOSTISSET("maxprint") ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW; +$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); +$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); +$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); +$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); +$pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); +$status = GETPOST("search_status", 'aZ09') ?GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' +$type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); +$maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); @@ -120,8 +92,0 @@ - -$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); -if ($dateselect > 0) { - $day = GETPOST('dateselectday', 'int'); - $month = GETPOST('dateselectmonth', 'int'); - $year = GETPOST('dateselectyear', 'int'); -} - @@ -129,14 +94,14 @@ -if (GETPOST('search_actioncode', 'array:aZ09')) { - $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} - -if ($status == '' && !GETPOSTISSET('search_status')) { - $status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -} - -$defaultview = (!getDolGlobalString('AGENDA_DEFAULT_VIEW') ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +if (GETPOST('search_actioncode', 'array')) +{ + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; +} +else +{ + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); +} +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); + +if ($status == '' && !GETPOSTISSET('search_status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); + +$defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); @@ -144,9 +109,7 @@ -if (empty($mode) && !GETPOSTISSET('mode')) { - $mode = $defaultview; -} -if ($mode == 'default') { // When action is default, we want a calendar view and not the list - $mode = (($defaultview != 'show_list') ? $defaultview : 'show_month'); -} -if (GETPOST('viewcal', 'int') && GETPOST('mode', 'alpha') != 'show_day' && GETPOST('mode', 'alpha') != 'show_week') { - $mode = 'show_month'; - $day = ''; +if (empty($action) && !GETPOSTISSET('action')) $action = $defaultview; +if ($action == 'default') // When action is default, we want a calendar view and not the list +{ + $action = (($defaultview != 'show_list') ? $defaultview : 'show_month'); +} +if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') { + $action = 'show_month'; $day = ''; @@ -154,4 +117,2 @@ -if (GETPOST('viewweek', 'int') || GETPOST('mode', 'alpha') == 'show_week') { - $mode = 'show_week'; - $week = ($week ? $week : date("W")); - $day = ($day ? $day : date("d")); +if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') { + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); @@ -159,3 +120,2 @@ -if (GETPOST('viewday', 'int') || GETPOST('mode', 'alpha') == 'show_day') { - $mode = 'show_day'; - $day = ($day ? $day : date("d")); +if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') { + $action = 'show_day'; $day = ($day ? $day : date("d")); @@ -163,2 +122,0 @@ - -$object = new ActionComm($db); @@ -171,5 +128,0 @@ - -$result = restrictedArea($user, 'agenda', 0, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); -if ($user->socid && $socid) { - $result = restrictedArea($user, 'societe', $socid); -} @@ -182,31 +135,41 @@ -if (GETPOST("viewlist", 'alpha') || $mode == 'show_list') { - $param = ''; - if (is_array($_POST)) { - foreach ($_POST as $key => $val) { - if ($key == 'token') { - continue; - } - $param .= '&'.$key.'='.urlencode($val); - } - } - if (!preg_match('/action=/', $param)) { - $param .= ($param ? '&' : '').'mode=show_list'; - } - //print $param; - header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); - exit; -} - -if (GETPOST("viewperuser", 'alpha') || $mode == 'show_peruser') { - $param = ''; - if (is_array($_POST)) { - foreach ($_POST as $key => $val) { - if ($key == 'token') { - continue; - } - $param .= '&'.$key.'='.urlencode($val); - } - } - //print $param; - header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); - exit; +if (GETPOST("viewlist", 'alpha') || $action == 'show_list') +{ + $param = ''; + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); + } + } + //print $param; + header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param); + exit; +} + +if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser') +{ + $param = ''; + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + if ($key == 'token') continue; + $param .= '&'.$key.'='.urlencode($val); + } + } + //print $param; + header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param); + exit; +} + +if ($action == 'delete_action') +{ + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; + + $result = $event->delete(); @@ -219 +181,0 @@ - @@ -239,5 +201,3 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; @@ -249 +208,0 @@ -$userstatic = new User($db); @@ -260 +219,21 @@ -if (!getDolGlobalString('AGENDA_DISABLE_EXT')) { +if (empty($conf->global->AGENDA_DISABLE_EXT)) +{ + $i = 0; + while ($i < $MAXAGENDA) + { + $i++; + $source = 'AGENDA_EXT_SRC'.$i; + $name = 'AGENDA_EXT_NAME'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; + $color = 'AGENDA_EXT_COLOR'.$i; + $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; + if (!empty($conf->global->$source) && !empty($conf->global->$name)) + { + // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' + $listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0)); + } + } +} +// Define list of external calendars (user setup) +if (empty($user->conf->AGENDA_DISABLE_EXT)) +{ @@ -262,25 +241,2 @@ - while ($i < $MAXAGENDA) { - $i++; - $source = 'AGENDA_EXT_SRC'.$i; - $name = 'AGENDA_EXT_NAME'.$i; - $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i; - $color = 'AGENDA_EXT_COLOR'.$i; - $default = 'AGENDA_EXT_ACTIVEBYDEFAULT'.$i; - $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i; - if (getDolGlobalString($source) && getDolGlobalString($name)) { - // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' - $listofextcals[] = array( - 'src' => getDolGlobalString($source), - 'name' => dol_string_nohtmltag(getDolGlobalString($name)), - 'offsettz' => (int) getDolGlobalInt($offsettz, 0), - 'color' => dol_string_nohtmltag(getDolGlobalString($color)), - 'default' => dol_string_nohtmltag(getDolGlobalString($default)), - 'buggedfile' => dol_string_nohtmltag(getDolGlobalString('buggedfile', '')) - ); - } - } -} -// Define list of external calendars (user setup) -if (empty($user->conf->AGENDA_DISABLE_EXT)) { - $i = 0; - while ($i < $MAXAGENDA) { + while ($i < $MAXAGENDA) + { @@ -290 +246 @@ - $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i; @@ -293 +248,0 @@ - $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i; @@ -295,2 +250,2 @@ - - if (getDolUserString($source) && getDolUserString($name)) { + if (!empty($user->conf->$source) && !empty($user->conf->$name)) + { @@ -298,8 +253 @@ - $listofextcals[] = array( - 'src' => getDolUserString($source), - 'name' => dol_string_nohtmltag(getDolUserString($name)), - 'offsettz' => (int) (empty($user->conf->$offsettz) ? 0 : $user->conf->$offsettz), - 'color' => dol_string_nohtmltag(getDolUserString($color)), - 'default' => dol_string_nohtmltag(getDolUserString($default)), - 'buggedfile' => dol_string_nohtmltag(isset($user->conf->buggedfile) ? $user->conf->buggedfile : '') - ); + $listofextcals[] = array('src'=>$user->conf->$source, 'name'=>$user->conf->$name, 'offsettz'=>$user->conf->$offsettz, 'color'=>$user->conf->$color, 'buggedfile'=>(isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0)); @@ -310,43 +258,41 @@ -if (empty($mode) || $mode == 'show_month') { - $prev = dol_get_prev_month($month, $year); - $prev_year = $prev['year']; - $prev_month = $prev['month']; - $next = dol_get_next_month($month, $year); - $next_year = $next['year']; - $next_month = $next['month']; - - $max_day_in_prev_month = date("t", dol_mktime(12, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')); // Nb of days in next month - // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) - $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')) + 2; // date('w') is 0 fo sunday - $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); - if ($tmpday >= 1) { - $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. - } - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year, 'tzuserrel'); - $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; - if ($next_day < 6) { - $next_day += 7; - } - $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year, 'tzuserrel'); -} -if ($mode == 'show_week') { - $prev = dol_get_first_day_week($day, $month, $year); - $prev_year = $prev['prev_year']; - $prev_month = $prev['prev_month']; - $prev_day = $prev['prev_day']; - $first_day = $prev['first_day']; - $first_month = $prev['first_month']; - $first_year = $prev['first_year']; - - $week = $prev['week']; - - $day = (int) $day; - $next = dol_get_next_week($first_day, $week, $first_month, $first_year); - $next_year = $next['year']; - $next_month = $next['month']; - $next_day = $next['day']; - - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel'); +if (empty($action) || $action == 'show_month') +{ + $prev = dol_get_prev_month($month, $year); + $prev_year = $prev['year']; + $prev_month = $prev['month']; + $next = dol_get_next_month($month, $year); + $next_year = $next['year']; + $next_month = $next['month']; + + $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month + // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) + $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday + $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); + if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); + $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; + if ($next_day < 6) $next_day += 7; + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); +} +if ($action == 'show_week') +{ + $prev = dol_get_first_day_week($day, $month, $year); + $prev_year = $prev['prev_year']; + $prev_month = $prev['prev_month']; + $prev_day = $prev['prev_day']; + $first_day = $prev['first_day']; + $first_month = $prev['first_month']; + $first_year = $prev['first_year']; + + $week = $prev['week']; + + $day = (int) $day; + $next = dol_get_next_week($first_day, $week, $first_month, $first_year); + $next_year = $next['year']; + $next_month = $next['month']; + $next_day = $next['day']; + + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); @@ -355,16 +301,18 @@ - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); - - $tmpday = $first_day; -} -if ($mode == 'show_day') { - $prev = dol_get_prev_day($day, $month, $year); - $prev_year = $prev['year']; - $prev_month = $prev['month']; - $prev_day = $prev['day']; - $next = dol_get_next_day($day, $month, $year); - $next_year = $next['year']; - $next_month = $next['month']; - $next_day = $next['day']; - // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) - $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year, 'tzuserrel'); - $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year, 'tzuserrel'); + $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); + + $tmpday = $first_day; +} +if ($action == 'show_day') +{ + $prev = dol_get_prev_day($day, $month, $year); + $prev_year = $prev['year']; + $prev_month = $prev['month']; + $prev_day = $prev['day']; + $next = dol_get_next_day($day, $month, $year); + $next_year = $next['year']; + $next_month = $next['month']; + $next_day = $next['day']; + + // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) + $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year); + $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); @@ -374,6 +322,6 @@ -//print dol_print_date($firstdaytoshow,'dayhour').' '.dol_print_date($lastdaytoshow,'dayhour'); - -/*$title = $langs->trans("DoneAndToDoActions"); - if ($status == 'done') $title = $langs->trans("DoneActions"); - if ($status == 'todo') $title = $langs->trans("ToDoActions"); - */ +//print dol_print_date($firstdaytoshow,'day'); +//print dol_print_date($lastdaytoshow,'day'); + +$title = $langs->trans("DoneAndToDoActions"); +if ($status == 'done') $title = $langs->trans("DoneActions"); +if ($status == 'todo') $title = $langs->trans("ToDoActions"); @@ -382 +330 @@ -if ($actioncode || GETPOSTISSET('search_actioncode')) { +if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { @@ -384,34 +332,13 @@ - foreach ($actioncode as $str_action) { - $param .= "&search_actioncode[]=".urlencode($str_action); - } - } else { - $param .= "&search_actioncode=".urlencode($actioncode); - } -} -if ($resourceid > 0) { - $param .= "&search_resourceid=".urlencode($resourceid); -} -if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { - $param .= "&search_status=".urlencode($status); -} -if ($filter) { - $param .= "&search_filter=".urlencode($filter); -} -if ($filtert) { - $param .= "&search_filtert=".urlencode($filtert); -} -if ($usergroup > 0) { - $param .= "&search_usergroup=".urlencode($usergroup); -} -if ($socid > 0) { - $param .= "&search_socid=".urlencode($socid); -} -if ($showbirthday) { - $param .= "&search_showbirthday=1"; -} -if ($pid) { - $param .= "&search_projectid=".urlencode($pid); -} -if ($type) { - $param .= "&search_type=".urlencode($type); -} + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); +} +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param .= '&action='.urlencode($action); @@ -419,3 +345,0 @@ -if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') { - $param .= '&mode='.urlencode($mode); -} @@ -424,31 +348,27 @@ -$nav = ''; -$nav .= ''; - -$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -//$nav .= ' '; -$nav .= ''; +if (empty($action) || $action == 'show_month') +{ + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendar'; +} +if ($action == 'show_week') +{ + $nav = "trans("Previous"))."\">  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; + $nav .= " \n"; + $nav .= "   trans("Next"))."\">\n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendarweek'; +} +if ($action == 'show_day') +{ + $nav = "  \n"; + $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); + $nav .= " \n"; + $nav .= "   \n"; + $nav .= "   (".$langs->trans("Today").")"; + $picto = 'calendarday'; +} @@ -457 +376,0 @@ -$paramnodate = $param; @@ -464,11 +383,7 @@ -/*$tabactive = ''; - if ($mode == 'show_month') $tabactive = 'cardmonth'; - if ($mode == 'show_week') $tabactive = 'cardweek'; - if ($mode == 'show_day') $tabactive = 'cardday'; - if ($mode == 'show_list') $tabactive = 'cardlist'; - if ($mode == 'show_pertuser') $tabactive = 'cardperuser'; - if ($mode == 'show_pertype') $tabactive = 'cardpertype'; - */ - -$paramnoaction = preg_replace('/mode=[a-z_]+/', '', preg_replace('/action=[a-z_]+/', '', $param)); -$paramnoactionodate = preg_replace('/mode=[a-z_]+/', '', preg_replace('/action=[a-z_]+/', '', $paramnodate)); +$tabactive = ''; +if ($action == 'show_month') $tabactive = 'cardmonth'; +if ($action == 'show_week') $tabactive = 'cardweek'; +if ($action == 'show_day') $tabactive = 'cardday'; +if ($action == 'show_list') $tabactive = 'cardlist'; + +$paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); @@ -479,3 +394 @@ -if ($optioncss != '') { - print ''; -} +if ($optioncss != '') print ''; @@ -483,64 +396,5 @@ -print ''; - -//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); -//print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); -//print dol_get_fiche_end(); - -$viewmode = ''; - -$viewmode .= ''; // To add a space before the navigation tools - - -$newcardbutton = ''; -$newparam = ''; -if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - $tmpforcreatebutton = dol_getdate(dol_now(), true); - - $newparam .= '&month='.((int) $month).'&year='.((int) $tmpforcreatebutton['year']).'&mode='.urlencode($mode); - - //$param='month='.$monthshown.'&year='.$year; - $hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation - - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); -} + +dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); +print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); +dol_fiche_end(); + @@ -552,30 +406,3 @@ -$bookcalcalendars = array(); - -// Load Bookcal Calendars -if (isModEnabled("bookcal")) { - $sql = "SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal"; - $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as ba"; - $sql .= " JOIN ".MAIN_DB_PREFIX."bookcal_calendar as bc"; - $sql .= " ON bc.rowid = ba.fk_bookcal_calendar"; - $sql .= " WHERE bc.status = 1"; - $sql .= " AND ba.status = 1"; - if (!empty($filtert) && $filtert != -1) { - $sql .= " AND bc.visibility = ".(int) $filtert ; - } - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); - $label = !empty($objp->label) ? $objp->label : $objp->ref; - $bookcalcalendars["calendars"][] = array("id" => $objp->id_cal, "label" => $label); - $bookcalcalendars["availabilitieslink"][$objp->rowid] = $objp->id_cal; - $i++; - } - } else { - dol_print_error($db); - } -} - -if (!empty($conf->use_javascript_ajax)) { // If javascript on + +if (!empty($conf->use_javascript_ajax)) // If javascript on +{ @@ -585,9 +412,5 @@ - $s .= 'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'."\n"; - $s .= 'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'."\n"; - if (isModEnabled("bookcal") && !empty($bookcalcalendars["calendars"])) { - foreach ($bookcalcalendars["calendars"] as $key => $value) { - $s .= 'jQuery(".check_bookcal_calendar_'.$value['id'].'").click(function() { console.log("Toggle Bookcal Calendar '.$value['id'].'"); jQuery(".family_bookcal_calendar_'.$value['id'].'").toggle(); });'."\n"; - } - } - if ($mode == "show_week" || $mode == "show_month" || empty($mode)) { - // Code to enable drag and drop + $s .= 'jQuery("#check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });'."\n"; + $s .= 'jQuery(".family_birthday").toggle();'."\n"; + if ($action == "show_week" || $action == "show_month" || empty($action)) + { + // Code to enable drag and drop @@ -595 +418 @@ - // Code to submit form + // Code to submit form @@ -597 +420 @@ - //$s.='console.log(event.target);'; + //$s.='console.log(event.target);'; @@ -602 +425 @@ - $s .= 'console.log("Found url on href of a.cal_event"+newurl+", we submit form with actionmove=mupdate");'."\n"; + $s .= 'console.log(newurl);'."\n"; @@ -604,4 +427,4 @@ - $s .= '});'."\n"; - } - $s .= '});'."\n"; - $s .= ''."\n"; + $s .= '});'."\n"; + } + $s .= '});'."\n"; + $s .= ''."\n"; @@ -610,12 +433 @@ - $s .= '
    '.$langs->trans("LocalAgenda").'  
    '; - - if ($user->hasRight("holiday", "read")) { - // Holiday calendar - $s .= ' -
    -   -
    '; - } + $s .= '
    '.$langs->trans("LocalAgenda").'  
    '; @@ -624 +436,2 @@ - if (is_array($showextcals) && count($showextcals) > 0) { + if (is_array($showextcals) && count($showextcals) > 0) + { @@ -627,10 +440 @@ - jQuery("div input[name^=\"check_ext\"]").each(function(index, elem) { - var name = jQuery(elem).attr("name"); - if (jQuery(elem).is(":checked")) { - jQuery(".family_ext" + name.replace("check_ext", "")).show(); - } else { - jQuery(".family_ext" + name.replace("check_ext", "")).hide(); - } - }); - - jQuery("div input[name^=\"check_ext\"]").click(function() { + jQuery("table input[name^=\"check_ext\"]").click(function() { @@ -643,10 +447,4 @@ - foreach ($showextcals as $val) { - $htmlname = md5($val['name']); // not used for security purpose, only to get a string with no special char - - if (!empty($val['default']) || GETPOST('check_ext'.$htmlname, 'int')) { - $default = "checked"; - } else { - $default = ''; - } - - $s .= '
     
    '; + foreach ($showextcals as $val) + { + $htmlname = md5($val['name']); + $s .= '
    '.$val['name'].'  
    '; @@ -657,11 +455 @@ - $s .= '
     
    '; - - // Bookcal Calendar - if (isModEnabled("bookcal")) { - if (!empty($bookcalcalendars["calendars"])) { - foreach ($bookcalcalendars["calendars"] as $key => $value) { - $label = $value['label']; - $s .= '
     
    '; - } - } - } + $s .= '
    '.$langs->trans("AgendaShowBirthdayEvents").'  
    '; @@ -670 +458 @@ - $parameters = array(); + $parameters = array(); $object = null; @@ -672 +460,2 @@ - if (empty($reshook)) { + if (empty($reshook)) + { @@ -674,6 +463,8 @@ - } elseif ($reshook > 1) { - $s = $hookmanager->resPrint; - } - - $s .= "\n".''."\n"; -} else { // If javascript off + } + elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } +} +else // If javascript off +{ @@ -681,13 +472,11 @@ - $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); - if (!preg_match('/showbirthday=/i', $newparam)) { - $newparam .= '&showbirthday=1'; - } - $link = ''; - if (empty($showbirthday)) { - $link .= $langs->trans("AgendaShowBirthdayEvents"); - } else { - $link .= $langs->trans("AgendaHideBirthdayEvents"); - } - $link .= ''; -} + $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam); + if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1'; + $link = ''; + if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents"); + else $link .= $langs->trans("AgendaHideBirthdayEvents"); + $link .= ''; +} + +print load_fiche_titre($s, $link.'     '.$nav, '', 0, 0, 'tablelistofcalendars'); @@ -699,2 +487,0 @@ - -// DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR @@ -702,3 +489 @@ -if ($usergroup > 0) { - $sql .= " DISTINCT"; -} +if ($usergroup > 0) $sql .= " DISTINCT"; @@ -711 +496 @@ -$sql .= ' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_calendar,'; +$sql .= ' a.fk_soc, a.fk_contact, a.fk_project,'; @@ -713 +498 @@ -$sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto'; +$sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color'; @@ -715,3 +500 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; @@ -719,3 +502 @@ -if ($resourceid > 0) { - $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; -} +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; @@ -723,6 +504,2 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -} -if ($usergroup > 0) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -} +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; @@ -732,40 +509,33 @@ -if (!empty($actioncode)) { - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND ca.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND ca.type = 'systemauto'"; - } else { - if ($actioncode == 'AC_OTH') { - $sql .= " AND ca.type != 'systemauto'"; - } - if ($actioncode == 'AC_OTH_AUTO') { - $sql .= " AND ca.type = 'systemauto'"; - } - } - } else { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND ca.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND ca.type = 'systemauto'"; - } else { - if (is_array($actioncode)) { - $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")"; - } else { - $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")"; - } - } - } -} -if ($resourceid > 0) { - $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid); -} -if ($pid) { - $sql .= " AND a.fk_project=".((int) $pid); -} -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; -} -if ($socid > 0) { - $sql .= " AND a.fk_soc = ".((int) $socid); -} +if (!empty($actioncode)) +{ + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else + { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } + else + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else + { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } + else + { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } +} +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; @@ -773,49 +543,34 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -} -//var_dump($day.' '.$month.' '.$year); -if ($mode == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; - $sql .= ')'; -} else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; - $sql .= ')'; -} -if ($type) { - $sql .= " AND ca.id = ".((int) $type); -} -if ($status == '0') { - // To do (not started) - $sql .= " AND a.percent = 0"; -} -if ($status == 'na') { - // Not applicable - $sql .= " AND a.percent = -1"; -} -if ($status == '50') { - // Running already started - $sql .= " AND (a.percent > 0 AND a.percent < 100)"; -} -if ($status == 'done' || $status == '100') { - $sql .= " AND (a.percent = 100)"; -} -if ($status == 'todo') { - $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; -} +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($action == 'show_day') +{ + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; +} +else +{ + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31 + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; + $sql .= ')'; +} +if ($type) $sql .= " AND ca.id = ".$type; +if ($status == '0') { $sql .= " AND a.percent = 0"; } +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } @@ -823,9 +578,6 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) { - $sql .= "ar.fk_element = ".((int) $filtert); - } - if ($usergroup > 0) { - $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup); - } - $sql .= ")"; +if ($filtert > 0 || $usergroup > 0) +{ + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; @@ -840,140 +592,104 @@ -if ($resql) { - $num = $db->num_rows($resql); - - $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) - $i = 0; - while ($i < $num && $i < $MAXONSAMEPAGE) { - $obj = $db->fetch_object($resql); - - // Discard auto action if option is on - if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code == 'AC_OTH_AUTO') { - $i++; - continue; - } - - // Create a new object action - $event = new ActionComm($db); - - $event->id = $obj->id; - $event->ref = $event->id; - - $event->fulldayevent = $obj->fulldayevent; - - // event->datep and event->datef must be GMT date. - if ($event->fulldayevent) { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - $event->datep = $db->jdate($obj->datep, $tzforfullday ? 'tzuser' : 'tzserver'); // If saved in $tzforfullday = gmt, we must invert date to be in user tz - $event->datef = $db->jdate($obj->datep2, $tzforfullday ? 'tzuser' : 'tzserver'); - } else { - // Example: $obj->datep = '1970-01-01 01:00:00', jdate will return 0 if TZ of PHP server is Europe/Berlin (+1) - $event->datep = $db->jdate($obj->datep, 'tzserver'); - $event->datef = $db->jdate($obj->datep2, 'tzserver'); - } - //$event->datep_formated_gmt = dol_print_date($event->datep, 'dayhour', 'gmt'); - //var_dump($obj->id.' '.$obj->datep.' '.dol_print_date($obj->datep, 'dayhour', 'gmt')); - //var_dump($obj->id.' '.$event->datep.' '.dol_print_date($event->datep, 'dayhour', 'gmt')); - - $event->type_code = $obj->type_code; - $event->type_label = $obj->type_label; - $event->type_color = $obj->type_color; - $event->type = $obj->type_type; - $event->type_picto = $obj->type_picto; - - $event->libelle = $obj->label; // deprecated - $event->label = $obj->label; - $event->percentage = $obj->percent; - - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->fetch_userassigned(); // This load $event->userassigned - - $event->priority = $obj->priority; - $event->location = $obj->location; - $event->transparency = $obj->transparency; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; - - $event->fk_project = $obj->fk_project; - - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; - $event->fk_bookcal_calendar = $obj->fk_bookcal_calendar; - if (!empty($event->fk_bookcal_calendar)) { - $event->type = "bookcal_calendar"; - } - - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - $event->date_start_in_calendar = $event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) { - $event->date_end_in_calendar = $event->datef; - } else { - $event->date_end_in_calendar = $event->datep; - } - - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { - // This record is out of visible range - } else { - if ($event->date_start_in_calendar < $firstdaytoshow) { - $event->date_start_in_calendar = $firstdaytoshow; - } - if ($event->date_end_in_calendar >= $lastdaytoshow) { - $event->date_end_in_calendar = ($lastdaytoshow - 1); - } - - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); - $mois = dol_print_date($daycursor, '%m', 'tzuserrel'); - $jour = dol_print_date($daycursor, '%d', 'tzuserrel'); - - $daycursorend = $event->date_end_in_calendar; - $anneeend = dol_print_date($daycursorend, '%Y', 'tzuserrel'); - $moisend = dol_print_date($daycursorend, '%m', 'tzuserrel'); - $jourend = dol_print_date($daycursorend, '%d', 'tzuserrel'); - - //var_dump(dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt')); // Hour at greenwich - //var_dump($annee.'-'.$mois.'-'.$jour); - //print 'annee='.$annee.' mois='.$mois.' jour='.$jour.'
    '; - - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; - $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); // $mois, $jour, $annee has been set for user tz - $daykeyend = dol_mktime(0, 0, 0, $moisend, $jourend, $anneeend, 'gmt'); // $moisend, $jourend, $anneeend has been set for user tz - /* - print 'GMT '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'gmt').'
    '; - print 'TZSERVER '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzserver').'
    '; - print 'TZUSERREL '.$event->date_start_in_calendar.' '.dol_print_date($event->date_start_in_calendar, 'dayhour', 'tzuserrel').'
    '; - print 'GMT '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'gmt').'
    '; - print 'TZSERVER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzserver').'
    '; - print 'TZUSER '.$event->date_end_in_calendar.' '.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel').'
    '; - */ - do { - //if ($event->id==408) - //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'gmt').' - '.dol_print_date($event->datep, 'dayhour', 'gmt').' '.dol_print_date($event->datef, 'dayhour', 'gmt').'
    '; - //print 'daykey='.$daykey.' daykeyend='.$daykeyend.' '.dol_print_date($daykey, 'dayhour', 'tzuserrel').' - '.dol_print_date($event->datep, 'dayhour', 'tzuserrel').' '.dol_print_date($event->datef, 'dayhour', 'tzuserrel').'
    '; - - $eventarray[$daykey][] = $event; - $j++; - - $daykey += 60 * 60 * 24; - //if ($daykey > $event->date_end_in_calendar) { - if ($daykey > $daykeyend) { - $loop = false; - } - } while ($loop); - //var_dump($eventarray); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; - } - $i++; - } -} else { - dol_print_error($db); -} -//var_dump($eventarray); - - -// BIRTHDATES CALENDAR +if ($resql) +{ + $num = $db->num_rows($resql); + + $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import) + $i = 0; + while ($i < $num && $i < $MAXONSAMEPAGE) + { + $obj = $db->fetch_object($resql); + + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } + + // Create a new object action + $event = new ActionComm($db); + + $event->id = $obj->id; + $event->ref = $event->id; + + $event->datep = $db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin + $event->datef = $db->jdate($obj->datep2); + //var_dump($obj->datep); + //var_dump($event->datep); + + $event->type_code = $obj->type_code; + $event->type_label = $obj->type_label; + $event->type_color = $obj->type_color; + + $event->libelle = $obj->label; // deprecated + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->fetch_userassigned(); // This load $event->userassigned + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; + + $event->fk_project = $obj->fk_project; + + $event->thirdparty_id = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; + + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + $event->date_start_in_calendar = $event->datep; + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } + + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + } + else + { + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); + + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do + { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; + + $eventarray[$daykey][] = $event; + $j++; + + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } + while ($loop); + + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; + } + $i++; + } +} +else +{ + dol_print_error($db); +} + @@ -981,153 +697,160 @@ -if ($showbirthday) { - // Add events in array - $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; - $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).'))'; - $sql .= " AND sp.entity IN (".getEntity('contact').")"; - if ($mode == 'show_day') { - $sql .= ' AND MONTH(birthday) = '.((int) $month); - $sql .= ' AND DAY(birthday) = '.((int) $day); - } else { - $sql .= ' AND MONTH(birthday) = '.((int) $month); - } - $sql .= ' ORDER BY birthday'; - - dol_syslog("comm/action/index.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - - $event = new ActionComm($db); - - $event->id = $obj->rowid; // We put contact id in action id for birthdays events - $event->ref = $event->id; - - $datebirth = dol_stringtotime($obj->birthday, 1); - //print 'ee'.$obj->birthday.'-'.$datebirth; - $datearray = dol_getdate($datebirth, true); - $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output - $event->datef = $event->datep; - - $event->type_code = 'BIRTHDAY'; - $event->type_label = ''; - $event->type_color = ''; - $event->type = 'birthdate'; - $event->type_picto = 'birthdate'; - - $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); - $event->percentage = 100; - $event->fulldayevent = 1; - - $event->contact_id = $obj->rowid; - - $event->date_start_in_calendar = $db->jdate($event->datep); - $event->date_end_in_calendar = $db->jdate($event->datef); - - // Add an entry in eventarray for each day - $daycursor = $event->datep; - $annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); - $mois = dol_print_date($daycursor, '%m', 'tzuserrel'); - $jour = dol_print_date($daycursor, '%d', 'tzuserrel'); - - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); - - $eventarray[$daykey][] = $event; - - /*$loop = true; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - $eventarray[$daykey][] = $event; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); - */ - $i++; - } - } else { - dol_print_error($db); - } -} - -if ($user->hasRight("holiday", "read")) { - // LEAVE-HOLIDAY CALENDAR - $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; - $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.rowid = x.fk_user"; - $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) - $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) - - if ($mode == 'show_day') { - // Request only leaves for the current selected day - $sql .= " AND '".$db->escape($year)."-".$db->escape($month)."-".$db->escape($day)."' BETWEEN x.date_debut AND x.date_fin"; // date_debut and date_fin are date without time - } elseif ($mode == 'show_week') { - // Restrict on current month (we get more, but we will filter later) - $sql .= " AND date_debut < '".$db->idate(dol_get_last_day($year, $month))."'"; - $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; - } elseif ($mode == 'show_month') { - // Restrict on current month - $sql .= " AND date_debut <= '".$db->idate(dol_get_last_day($year, $month))."'"; - $sql .= " AND date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'"; - } - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - while ($i < $num) { - $obj = $db->fetch_object($resql); - - $event = new ActionComm($db); - - // Need the id of the leave object for link to it - $event->id = $obj->rowid; - $event->ref = $event->id; - - $event->type_code = 'HOLIDAY'; - $event->type_label = ''; - $event->type_color = ''; - $event->type = 'holiday'; - $event->type_picto = 'holiday'; - - $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1); - $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1; - $event->date_start_in_calendar = $event->datep; - $event->date_end_in_calendar = $event->datef; - - if ($obj->status == 3) { - // Show no symbol for leave with state "leave approved" - $event->percentage = -1; - } elseif ($obj->status == 2) { - // Show TO-DO symbol for leave with state "leave wait for approval" - $event->percentage = 0; - } - - if ($obj->halfday == 1) { - $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; - } elseif ($obj->halfday == -1) { - $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; - } else { - $event->label = $obj->lastname; - } - - $daycursor = $event->date_start_in_calendar; - $annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); - $mois = dol_print_date($daycursor, '%m', 'tzuserrel'); - $jour = dol_print_date($daycursor, '%d', 'tzuserrel'); - - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); - do { - $eventarray[$daykey][] = $event; - - $daykey += 60 * 60 * 24; - } while ($daykey <= $event->date_end_in_calendar); - - $i++; - } - } -} - -// EXTERNAL CALENDAR +if ($showbirthday) +{ + // Add events in array + $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; + $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; + $sql .= " AND sp.entity IN (".getEntity('socpeople').")"; + if ($action == 'show_day') + { + $sql .= ' AND MONTH(birthday) = '.$month; + $sql .= ' AND DAY(birthday) = '.$day; + } + else + { + $sql .= ' AND MONTH(birthday) = '.$month; + } + $sql .= ' ORDER BY birthday'; + + dol_syslog("comm/action/index.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $event = new ActionComm($db); + + $event->id = $obj->rowid; // We put contact id in action id for birthdays events + $event->ref = $event->id; + + $datebirth = dol_stringtotime($obj->birthday, 1); + //print 'ee'.$obj->birthday.'-'.$datebirth; + $datearray = dol_getdate($datebirth, true); + $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output + $event->datef = $event->datep; + $event->type_code = 'BIRTHDAY'; + $event->label = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname); + $event->percentage = 100; + $event->fulldayevent = 1; + + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; + $event->ponctuel = 0; + + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); + + $loop = true; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do + { + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } + while ($loop); + $i++; + } + } + else + { + dol_print_error($db); + } +} + +if ($conf->global->AGENDA_SHOW_HOLIDAYS) +{ + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) + $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) + + if ($action == 'show_day') + { + // Request only leaves for the current selected day + $sql .= " AND '".$year."-".$month."-".$day."' BETWEEN x.date_debut AND x.date_fin"; + } + elseif ($action == 'show_week') + { + // TODO: Add filter to reduce database request + } + elseif ($action == 'show_month') + { + // TODO: Add filter to reduce database request + } + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $dateStartArray = dol_getdate(dol_stringtotime($obj->date_start, 1), true); + $dateEndArray = dol_getdate(dol_stringtotime($obj->date_end, 1), true); + + $event = new ActionComm($db); + + // Need the id of the leave object for link to it + $event->id = $obj->rowid; + $event->ref = $event->id; + + $event->type_code = 'HOLIDAY'; + $event->datep = dol_mktime(0, 0, 0, $dateStartArray['mon'], $dateStartArray['mday'], $dateStartArray['year'], true); + $event->datef = dol_mktime(0, 0, 0, $dateEndArray['mon'], $dateEndArray['mday'], $dateEndArray['year'], true); + $event->date_start_in_calendar = $event->datep; + $event->date_end_in_calendar = $event->datef; + + if ($obj->status == 3) + { + // Show no symbol for leave with state "leave approved" + $event->percentage = -1; + } + elseif ($obj->status == 2) + { + // Show TO-DO symbol for leave with state "leave wait for approval" + $event->percentage = 0; + } + + if ($obj->halfday == 1) + { + $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; + } + elseif ($obj->halfday == -1) + { + $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; + } + else + { + $event->label = $obj->lastname; + } + + $annee = date('Y', $event->date_start_in_calendar); + $mois = date('m', $event->date_start_in_calendar); + $jour = date('d', $event->date_start_in_calendar); + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + + do + { + $eventarray[$daykey][] = $event; + + $daykey += 60 * 60 * 24; + } + + while ($daykey <= $event->date_end_in_calendar); + + $i++; + } + } +} + @@ -1135,170 +858,177 @@ -if (count($listofextcals)) { - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; - foreach ($listofextcals as $extcal) { - $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics - $namecal = $extcal['name']; - $offsettz = $extcal['offsettz']; - $colorcal = $extcal['color']; - $buggedfile = $extcal['buggedfile']; - - $pathforcachefile = dol_sanitizePathName($conf->user->dir_temp).'/'.dol_sanitizeFileName('extcal_'.$namecal.'_user'.$user->id).'.cache'; - //var_dump($pathforcachefile);exit; - - $ical = new ICal(); - $ical->parse($url, $pathforcachefile, $DELAYFORCACHE); - - // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... - //var_dump($ical->cal); exit; - $icalevents = array(); - if (is_array($ical->get_event_list())) { - $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] - } - if (is_array($ical->get_freebusy_list())) { - $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] - } - - if (count($icalevents) > 0) { - // Duplicate all repeatable events into new entries - $moreicalevents = array(); - foreach ($icalevents as $icalevent) { - if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) { //repeatable event - //if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; - //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); - if ($icalevent['DTSTART;VALUE=DATE']) { //fullday event - $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day - } elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) { - $datecurstart = $icalevent['DTSTART']['unixtime']; - $datecurend = $icalevent['DTEND']['unixtime']; - if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) { - //var_dump($ical->cal); - $tmpcurstart = $datecurstart; - $tmpcurend = $datecurend; - $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; - $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; - //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); - // Edit datecurstart and datecurend - if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { - $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; - } else { - $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; - } - if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { - $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; - } else { - $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; - } - } - // datecurstart and datecurend are now GMT date - //var_dump($datecurstart); var_dump($datecurend); exit; - } else { - // Not a recongized record - dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR); - continue; - } - //print 'xx'.$datecurstart;exit; - - $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); - $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); - $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; - if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) { - continue; // We discard repeatable event that end before start date to show - } - if ($datecurstart >= $lastdaytoshow) { - continue; // We discard repeatable event that start after end date to show - } - - $numofevent = 0; - while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) { - if ($datecurend >= $firstdaytoshow) { // We add event - $newevent = $icalevent; - unset($newevent['RRULE']); - if ($icalevent['DTSTART;VALUE=DATE']) { - $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); - $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); - } else { - $newevent['DTSTART'] = $datecurstart; - $newevent['DTEND'] = $datecurend; - } - $moreicalevents[] = $newevent; - } - // Jump on next occurence - $numofevent++; - $savdatecurstart = $datecurstart; - if ($icalevent['RRULE']['FREQ'] == 'DAILY') { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); - } - if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); - } elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); - } elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') { - $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); - $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); - } - // Test to avoid infinite loop ($datecurstart must increase) - if ($savdatecurstart >= $datecurstart) { - dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); - $datecurstart += 3600 * 24 * 7; - $datecurend += 3600 * 24 * 7; - } - } - } - } - $icalevents = array_merge($icalevents, $moreicalevents); - - // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray - foreach ($icalevents as $icalevent) { - //var_dump($icalevent); - - //print $icalevent['SUMMARY'].'->'; - //var_dump($icalevent);exit; - if (!empty($icalevent['RRULE'])) { - continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. - } - - // Create a new object action - $event = new ActionComm($db); - $addevent = false; - if (isset($icalevent['DTSTART;VALUE=DATE'])) { // fullday event - // For full day events, date are also GMT but they wont but converted using tz during output - $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); - if (empty($icalevent['DTEND;VALUE=DATE'])) { - $dateend = $datestart + 86400 - 1; - } else { - $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day - } - //print 'x'.$datestart.'-'.$dateend;exit; - //print dol_print_date($dateend,'dayhour','gmt'); - $event->fulldayevent = 1; - $addevent = true; - } elseif (!is_array($icalevent['DTSTART'])) { // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) - $datestart = $icalevent['DTSTART']; - $dateend = empty($icalevent['DTEND']) ? $datestart : $icalevent['DTEND']; - - $datestart += +($offsettz * 3600); - $dateend += +($offsettz * 3600); - - $addevent = true; - //var_dump($offsettz); - //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); - } elseif (isset($icalevent['DTSTART']['unixtime'])) { // File contains a local timezone + a TZ (for example when using bluemind) - $datestart = $icalevent['DTSTART']['unixtime']; - $dateend = $icalevent['DTEND']['unixtime']; - - $datestart += +($offsettz * 3600); - $dateend += +($offsettz * 3600); - - // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' - if ($buggedfile === 'uselocalandtznodaylight') { // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 - // TODO - } - // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind) - if ($buggedfile === 'uselocalandtzdaylight') { // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer - $localtzs = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTSTART']['TZID'])); - $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); - $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); - $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze); +if (count($listofextcals)) +{ + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php'; + foreach ($listofextcals as $extcal) + { + $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics + $namecal = $extcal['name']; + $offsettz = $extcal['offsettz']; + $colorcal = $extcal['color']; + $buggedfile = $extcal['buggedfile']; + //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal." buggedfile=".$buggedfile; + $ical = new ICal(); + $ical->parse($url); + + // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... + //var_dump($ical->cal); exit; + $icalevents = array(); + if (is_array($ical->get_event_list())) $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] + if (is_array($ical->get_freebusy_list())) $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] + + if (count($icalevents) > 0) + { + // Duplicate all repeatable events into new entries + $moreicalevents = array(); + foreach ($icalevents as $icalevent) + { + if (isset($icalevent['RRULE']) && is_array($icalevent['RRULE'])) //repeatable event + { + //if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; + //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1); + if ($icalevent['DTSTART;VALUE=DATE']) //fullday event + { + $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day + } + elseif (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) + { + $datecurstart = $icalevent['DTSTART']['unixtime']; + $datecurend = $icalevent['DTEND']['unixtime']; + if (!empty($ical->cal['DAYLIGHT']['DTSTART']) && $datecurstart) + { + //var_dump($ical->cal); + $tmpcurstart = $datecurstart; + $tmpcurend = $datecurend; + $tmpdaylightstart = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['DAYLIGHT']['DTSTART']; + $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; + //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); + // Edit datecurstart and datecurend + if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; + else $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; + } + // datecurstart and datecurend are now GMT date + //var_dump($datecurstart); var_dump($datecurend); exit; + } + else + { + // Not a recongized record + dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR); + continue; + } + //print 'xx'.$datecurstart;exit; + + $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); + $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); + $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; + if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) continue; // We discard repeatable event that end before start date to show + if ($datecurstart >= $lastdaytoshow) continue; // We discard repeatable event that start after end date to show + + $numofevent = 0; + while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) + { + if ($datecurend >= $firstdaytoshow) // We add event + { + $newevent = $icalevent; + unset($newevent['RRULE']); + if ($icalevent['DTSTART;VALUE=DATE']) + { + $newevent['DTSTART;VALUE=DATE'] = dol_print_date($datecurstart, '%Y%m%d'); + $newevent['DTEND;VALUE=DATE'] = dol_print_date($datecurend + 1, '%Y%m%d'); + } + else + { + $newevent['DTSTART'] = $datecurstart; + $newevent['DTEND'] = $datecurend; + } + $moreicalevents[] = $newevent; + } + // Jump on next occurence + $numofevent++; + $savdatecurstart = $datecurstart; + if ($icalevent['RRULE']['FREQ'] == 'DAILY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'd'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'd'); + } + if ($icalevent['RRULE']['FREQ'] == 'WEEKLY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'w'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'w'); + } + elseif ($icalevent['RRULE']['FREQ'] == 'MONTHLY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'm'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'm'); + } + elseif ($icalevent['RRULE']['FREQ'] == 'YEARLY') + { + $datecurstart = dol_time_plus_duree($datecurstart, $interval, 'y'); + $datecurend = dol_time_plus_duree($datecurend, $interval, 'y'); + } + // Test to avoid infinite loop ($datecurstart must increase) + if ($savdatecurstart >= $datecurstart) + { + dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR); + $datecurstart += 3600 * 24 * 7; + $datecurend += 3600 * 24 * 7; + } + } + } + } + $icalevents = array_merge($icalevents, $moreicalevents); + + // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray + foreach ($icalevents as $icalevent) + { + //var_dump($icalevent); + + //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
    ';exit; + if (!empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. + + // Create a new object action + $event = new ActionComm($db); + $addevent = false; + if (isset($icalevent['DTSTART;VALUE=DATE'])) // fullday event + { + // For full day events, date are also GMT but they wont but converted using tz during output + $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1); + $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day + //print 'x'.$datestart.'-'.$dateend;exit; + //print dol_print_date($dateend,'dayhour','gmt'); + $event->fulldayevent = 1; + $addevent = true; + } + elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) + { + $datestart = $icalevent['DTSTART']; + $dateend = $icalevent['DTEND']; + + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); + + $addevent = true; + //var_dump($offsettz); + //var_dump(dol_print_date($datestart, 'dayhour', 'gmt')); + } + elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) + { + $datestart = $icalevent['DTSTART']['unixtime']; + $dateend = $icalevent['DTEND']['unixtime']; + + $datestart += +($offsettz * 3600); + $dateend += +($offsettz * 3600); + + // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' + if ($buggedfile === 'uselocalandtznodaylight') // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 + { + // TODO + } + // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind) + if ($buggedfile === 'uselocalandtzdaylight') // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer + { + $localtzs = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTSTART']['TZID'])); + $localtze = new DateTimeZone(preg_replace('/"/', '', $icalevent['DTEND']['TZID'])); + $localdts = new DateTime(dol_print_date($datestart, 'dayrfc', 'gmt'), $localtzs); + $localdte = new DateTime(dol_print_date($dateend, 'dayrfc', 'gmt'), $localtze); @@ -1310,110 +1040,69 @@ - } - $addevent = true; - } - - if ($addevent) { - $event->id = $icalevent['UID']; - $event->ref = $event->id; - $userId = $userstatic->findUserIdByEmail($namecal); - if (!empty($userId) && $userId > 0) { - $event->userassigned[$userId] = $userId; - $event->percentage = -1; - } - - $event->type_code = "ICALEVENT"; - $event->type_label = $namecal; - $event->type_color = $colorcal; - $event->type = 'icalevent'; - $event->type_picto = 'rss'; - - $event->icalname = $namecal; - $event->icalcolor = $colorcal; - $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. - $event->datep = $datestart + $usertime; - $event->datef = $dateend + $usertime; - - if ($icalevent['SUMMARY']) { - $event->label = dol_string_nohtmltag($icalevent['SUMMARY']); - } elseif ($icalevent['DESCRIPTION']) { - $event->label = dol_nl2br(dol_string_nohtmltag($icalevent['DESCRIPTION']), 1); - } else { - $event->label = $langs->trans("ExtSiteNoLabel"); - } - - // Priority (see https://www.kanzaki.com/docs/ical/priority.html) - // LOW = 0 to 4 - // MEDIUM = 5 - // HIGH = 6 to 9 - if (!empty($icalevent['PRIORITY'])) { - $event->priority = $icalevent['PRIORITY']; - } - - // Transparency (see https://www.kanzaki.com/docs/ical/transp.html) - if (!empty($icalevent['TRANSP'])) { - if ($icalevent['TRANSP'] == "TRANSPARENT") { - $event->transparency = 0; // 0 = available / free - } - if ($icalevent['TRANSP'] == "OPAQUE") { - $event->transparency = 1; // 1 = busy - } - - // TODO: MS outlook states - // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:TRANSPARENT => Available / Free - // X-MICROSOFT-CDO-BUSYSTATUS:FREE + TRANSP:OPAQUE => Work another place - // X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE + TRANSP:OPAQUE => With reservations - // X-MICROSOFT-CDO-BUSYSTATUS:BUSY + TRANSP:OPAQUE => Busy - // X-MICROSOFT-CDO-BUSYSTATUS:OOF + TRANSP:OPAQUE => Away from the office / off-site - } - - if (!empty($icalevent['LOCATION'])) { - $event->location = $icalevent['LOCATION']; - } - - $event->date_start_in_calendar = $event->datep; - - if ($event->datef != '' && $event->datef >= $event->datep) { - $event->date_end_in_calendar = $event->datef; - } else { - $event->date_end_in_calendar = $event->datep; - } - - // Add event into $eventarray if date range are ok. - if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { - //print 'x'.$datestart.'-'.$dateend;exit; - //print 'x'.$datestart.'-'.$dateend;exit; - //print 'x'.$datestart.'-'.$dateend;exit; - // This record is out of visible range - } else { - if ($event->date_start_in_calendar < $firstdaytoshow) { - $event->date_start_in_calendar = $firstdaytoshow; - } - if ($event->date_end_in_calendar >= $lastdaytoshow) { - $event->date_end_in_calendar = ($lastdaytoshow - 1); - } - - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); - $mois = dol_print_date($daycursor, '%m', 'tzuserrel'); - $jour = dol_print_date($daycursor, '%d', 'tzuserrel'); - - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; - $j = 0; - // daykey must be date that represent day box in calendar so must be a user time - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); - $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); - do { - //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; - $eventarray[$daykey][] = $event; - $daykey += 60 * 60 * 24; - $daykeygmt += 60 * 60 * 24; // Add one day - if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) { - $loop = false; - } - } while ($loop); - } - } - } - } - } + } + $addevent = true; + } + + if ($addevent) + { + $event->id = $icalevent['UID']; + $event->ref = $event->id; + + $event->icalname = $namecal; + $event->icalcolor = $colorcal; + $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output. + $event->datep = $datestart + $usertime; + $event->datef = $dateend + $usertime; + $event->type_code = "ICALEVENT"; + + if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY']; + elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1); + else $event->label = $langs->trans("ExtSiteNoLabel"); + + $event->date_start_in_calendar = $event->datep; + + if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar = $event->datef; + else $event->date_end_in_calendar = $event->datep; + + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + //print 'x'.$datestart.'-'.$dateend;exit; + } + + // Add event into $eventarray if date range are ok. + if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) + { + //print 'x'.$datestart.'-'.$dateend;exit; + //print 'x'.$datestart.'-'.$dateend;exit; + //print 'x'.$datestart.'-'.$dateend;exit; + // This record is out of visible range + } + else + { + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); + + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + // daykey must be date that represent day box in calendar so must be a user time + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + $daykeygmt = dol_mktime(0, 0, 0, $mois, $jour, $annee, true, 0); + do + { + //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' '; + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; $daykeygmt += 60 * 60 * 24; // Add one day + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) $loop = false; + } + while ($loop); + } + } + } + } + } @@ -1428,6 +1117,6 @@ - foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { - if (!isset($eventarray[$keyDate])) { - $eventarray[$keyDate] = array(); - } - $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); - } + foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) { + if (!isset($eventarray[$keyDate])) { + $eventarray[$keyDate] = array(); + } + $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events); + } @@ -1437 +1126,2 @@ -foreach ($eventarray as $keyDate => &$dateeventarray) { +foreach ($eventarray as $keyDate => &$dateeventarray) +{ @@ -1449,29 +1139,88 @@ -if (is_readable($color_file)) { - include $color_file; -} -if (!is_array($theme_datacolor)) { - $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); -} - -$massactionbutton =''; - -print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); - -// Show div with list of calendars -print $s; - - -if (empty($mode) || $mode == 'show_month') { // View by month - $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam = preg_replace('/mode=show_month&?/i', '', $newparam); - $newparam = preg_replace('/mode=show_week&?/i', '', $newparam); - $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam .= '&viewcal=1'; - - print '
    '; - print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); +if (is_readable($color_file)) +{ + include_once $color_file; +} +if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); + + +if (empty($action) || $action == 'show_month') // View by month +{ + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewcal=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewcal=1'; + + + print '
    '; + print ''; + print ' '; + $i = 0; + while ($i < 7) + { + print ' '."\n"; + $i++; + } + echo ' '."\n"; + + $todayarray = dol_getdate($now, 'fast'); + $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); + + // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) + //var_dump($eventarray); + for ($iter_week = 0; $iter_week < 6; $iter_week++) + { + echo " \n"; + for ($iter_day = 0; $iter_day < 7; $iter_day++) + { + /* Show days before the beginning of the current month (previous month) */ + if ($tmpday <= 0) + { + $style = 'cal_other_month cal_past'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + echo ' \n"; + } + /* Show days of the current month */ + elseif ($tmpday <= $max_day_in_month) + { + $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_current_month_right'; + $today = 0; + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + if ($today) $style = 'cal_today'; + if ($curtime < $todaytms) $style .= ' cal_past'; + //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); + echo ' \n"; + } + /* Show days after the current month (next month) */ + else + { + $style = 'cal_other_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + echo ' \n"; + } + $tmpday++; + } + echo " \n"; + } + print "
    '; + $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); + if (!empty($conf->dol_optimize_smallscreen)) + { + $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); + print $langs->trans($labelshort[$numdayinweek]); + } + else print $langs->trans("Day".$numdayinweek); + print '
    '; + show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + echo " '; + show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + echo " '; + show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + echo "
    \n"; @@ -1480,14 +1229,126 @@ - print '
    '; - print ''; - print ' '; - // Column title of weeks numbers - echo ' '; - $i = 0; - while ($i < 7) { - print ' '."\n"; - $i++; - } - echo ' '."\n"; - - $todayarray = dol_getdate($now, 'fast'); - $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']); - - // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) - //var_dump($eventarray); - for ($iter_week = 0; $iter_week < 6; $iter_week++) { - echo " \n"; - // Get date of the current day, format 'yyyy-mm-dd' - if ($tmpday <= 0) { // If number of the current day is in previous month - $currdate0 = sprintf("%04d", $prev_year).sprintf("%02d", $prev_month).sprintf("%02d", $max_day_in_prev_month + $tmpday); - } elseif ($tmpday <= $max_day_in_month) { // If number of the current day is in current month - $currdate0 = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $tmpday); - } else { // If number of the current day is in next month - $currdate0 = sprintf("%04d", $next_year).sprintf("%02d", $next_month).sprintf("%02d", $tmpday - $max_day_in_month); - } - // Get week number for the targeted date '$currdate0' - $numweek0 = date("W", strtotime(date($currdate0))); - // Show the week number, and define column width - echo ' '; - - for ($iter_day = 0; $iter_day < 7; $iter_day++) { - if ($tmpday <= 0) { - /* Show days before the beginning of the current month (previous month) */ - $style = 'cal_other_month cal_past'; - if ($iter_day == 6) { - $style .= ' cal_other_month_right'; - } - echo ' \n"; - } elseif ($tmpday <= $max_day_in_month) { - /* Show days of the current month */ - $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); - $style = 'cal_current_month'; - if ($iter_day == 6) { - $style .= ' cal_current_month_right'; - } - $today = 0; - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) { - $today = 1; - } - if ($today) { - $style = 'cal_today'; - } - if ($curtime < $todaytms) { - $style .= ' cal_past'; - } - //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); - echo ' \n"; - } else { - /* Show days after the current month (next month) */ - $style = 'cal_other_month'; - if ($iter_day == 6) { - $style .= ' cal_other_month_right'; - } - echo ' \n"; - } - $tmpday++; - } - echo " \n"; - } - print "
    #'; - $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); - if (!empty($conf->dol_optimize_smallscreen)) { - $labelshort = array(0=>'SundayMin', 1=>'MondayMin', 2=>'TuesdayMin', 3=>'WednesdayMin', 4=>'ThursdayMin', 5=>'FridayMin', 6=>'SaturdayMin'); - print $langs->trans($labelshort[$numdayinweek]); - } else { - print $langs->trans("Day".$numdayinweek); + print ''; + print ''; + print ''; +} +elseif ($action == 'show_week') // View by week +{ + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); + $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter + $newparam .= '&viewweek=1'; + + print '
    '; + print ''; + print ' '; + $i = 0; + while ($i < 7) + { + echo ' \n"; + $i++; + } + echo " \n"; + + echo " \n"; + + for ($iter_day = 0; $iter_day < 7; $iter_day++) + { + // Show days of the current week + $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); + $tmparray = dol_getdate($curtime, true); + $tmpday = $tmparray['mday']; + $tmpmonth = $tmparray['mon']; + $tmpyear = $tmparray['year']; + + $style = 'cal_current_month'; + if ($iter_day == 6) $style .= ' cal_other_month_right'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; + if ($today) $style = 'cal_today'; + + echo ' \n"; + } + echo " \n"; + + print "
    '.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
    '; + show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); + echo "
    \n"; + print '
    '; + + echo ''; + echo ''; + echo ''; +} +else // View by day +{ + $newparam = $param; // newparam is for birthday links + $newparam = preg_replace('/action=show_month&?/i', '', $newparam); + $newparam = preg_replace('/action=show_week&?/i', '', $newparam); + $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam); + $newparam .= '&viewday=1'; + // Code to show just one day + $style = 'cal_current_month cal_current_month_oneday'; + $today = 0; + $todayarray = dol_getdate($now, 'fast'); + if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) $today = 1; + //if ($today) $style='cal_today'; + + $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); + $arraytimestamp = dol_getdate($timestamp); + + //echo ''; + echo '
    '; + + echo ' '; + echo ' '; + echo ' \n"; + echo " \n"; + + /* + echo '
    '; + echo '
    '; + echo '
    '; + echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1); + echo '
    '."\n"; + echo "
    \n"; + */ + + echo '
    '.$langs->trans("Day".$arraytimestamp['wday'])."
    '; + + /* WIP View per hour */ + $useviewhour = 0; + if ($useviewhour) + { + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + + $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file + + echo '
    '; + echo '
    '; + + $maxnbofchar = 80; + + $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); + $minhour = round($tmp[0], 0); + $maxhour = round($tmp[1], 0); + if ($minhour > 23) $minhour = 23; + if ($maxhour < 1) $maxhour = 1; + if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } + + $i = 0; + $j = 0; + while ($i < 24) + { + echo '
    '."\n"; + echo '
    '.dol_print_date($i * 3600, 'hour', 'gmt').'
    '; + echo '
    '; + echo "
    \n"; + echo "
    \n"; + $i++; + $j++; @@ -1495,214 +1355,0 @@ - print '
    '.$numweek0.''; - show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); - echo " '; - show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars); - echo "'; - show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); - echo "
    \n"; - print '
    '; - - print ''; - print ''; - print ''; -} elseif ($mode == 'show_week') { - // View by week - $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done - $newparam = preg_replace('/mode=show_month&?/i', '', $newparam); - $newparam = preg_replace('/mode=show_week&?/i', '', $newparam); - $newparam = preg_replace('/day=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/month=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/year=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/viewweek=[0-9]+&?/i', '', $newparam); - $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter - $newparam .= '&viewweek=1'; - - print '
    '; - print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
    '; - - print '
    '; - print ''; - print ' '; - $i = 0; - while ($i < 7) { - echo ' \n"; - $i++; - } - echo " \n"; - - echo " \n"; - - for ($iter_day = 0; $iter_day < 7; $iter_day++) { - // Show days of the current week - $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); // $firstdaytoshow is in timezone of server - $tmpday = dol_print_date($curtime, '%d', 'tzuserrel'); - $tmpmonth = dol_print_date($curtime, '%m', 'tzuserrel'); - $tmpyear = dol_print_date($curtime, '%Y', 'tzuserrel'); - - $style = 'cal_current_month'; - if ($iter_day == 6) { - $style .= ' cal_other_month_right'; - } - - $today = 0; - $todayarray = dol_getdate($now, 'fast'); - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) { - $today = 1; - } - if ($today) { - $style = 'cal_today'; - } - - echo ' \n"; - } - echo " \n"; - - print "
    '.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
    '; - show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars); - echo "
    \n"; - print '
    '; - - echo ''; - echo ''; - echo ''; -} else { // View by day - $newparam = $param; // newparam is for birthday links - $newparam = preg_replace('/mode=show_month&?/i', '', $newparam); - $newparam = preg_replace('/mode=show_week&?/i', '', $newparam); - $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam); - $newparam .= '&viewday=1'; - // Code to show just one day - $style = 'cal_current_month cal_current_month_oneday'; - $today = 0; - $todayarray = dol_getdate($now, 'fast'); - if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) { - $today = 1; - } - //if ($today) $style='cal_today'; - - $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); - $arraytimestamp = dol_getdate($timestamp); - - print '
    '; - print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
    '; - - print '
    '; - echo ''; - - echo ' '; - echo ' \n"; - echo " \n"; - - /* - echo '
    '; - echo '
    '; - echo '
    '; - echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1); - echo '
    '."\n"; - echo "
    \n"; - */ - - echo '
    '.$langs->trans("Day".$arraytimestamp['wday'])."
    '; - print '
    '; - - /* WIP View per hour */ - $useviewhour = 0; - if ($useviewhour) { - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table - - $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file - - echo '
    '; - echo '
    '; - - $maxnbofchar = 80; - - $tmp = explode('-', getDolGlobalString('MAIN_DEFAULT_WORKING_HOURS')); - $minhour = round($tmp[0], 0); - $maxhour = round($tmp[1], 0); - if ($minhour > 23) { - $minhour = 23; - } - if ($maxhour < 1) { - $maxhour = 1; - } - if ($maxhour <= $minhour) { - $maxhour = $minhour + 1; - } - - $i = 0; - $j = 0; - while ($i < 24) { - echo '
    '."\n"; - echo '
    '.dol_print_date($i * 3600, 'hour', 'gmt').'
    '; - echo '
    '."\n"; - echo '
    '."\n"; - $i++; - $j++; - } @@ -1712 +1359 @@ - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars); + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); @@ -1715,7 +1362,9 @@ - } else { - print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table - - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars); - - print '
    '; - } + } + else + { + print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table + + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); + + print '
    '; + } @@ -1746,2 +1395 @@ - * @param int $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" - * @param array $bookcalcalendarsarray Used for Bookcal module array of calendar of bookcal + * @param string $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" @@ -1750,68 +1398,55 @@ -function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array()) -{ - global $user, $conf, $langs; - global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form - global $theme_datacolor; - global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; - - if ($conf->use_javascript_ajax) { // Enable the "Show more button..." - $conf->global->MAIN_JS_SWITCH_AGENDA = 1; - } - - $dateint = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - - //print 'show_day_events day='.$day.' month='.$month.' year='.$year.' dateint='.$dateint; - - print "\n"; - - $curtime = dol_mktime(0, 0, 0, $month, $day, $year); - $urltoshow = DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year.$newparam; - $urltocreate = ''; - if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; - $hourminsec = '100000'; - $urltocreate = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $year, $month, $day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); - } - - // Line with title of day - print '
    '."\n"; - - if ($nonew <= 0) { - print ''."\n"; - } - - if ($nonew < 0) { - print '
    '; - return; - } - - // Line with td contains all div of each events - print '
    '; - print '
    '; - - //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); - $i = 0; - $ireallyshown = 0; - $itoshow = 0; - $numother = 0; - $numbirthday = 0; - $numical = 0; - $numicals = array(); - $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); - - $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 - $nextindextouse = is_array($colorindexused) ? count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ... +function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0) +{ + global $user, $conf, $langs; + global $action, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form + global $theme_datacolor; + global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; + + $dateint = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + + print "\n"; + + // Line with title of day + $curtime = dol_mktime(0, 0, 0, $month, $day, $year); + print '
    '."\n"; + + if ($nonew <= 0) + { + print '
    '; + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + { + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; + + //$param='month='.$monthshown.'&year='.$year; + $hourminsec = '100000'; + print ''; + print img_picto($langs->trans("NewAction"), 'edit_add.png'); + print ''; + } + print '
    '."\n"; + } + + if ($nonew < 0) + { + print '
    '; + return; + } + + // Line with td contains all div of each events + print '
    '; + print '
    '; + + //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); + $i = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); + $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day); + + $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 + $nextindextouse = is_array($colorindexused) ?count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ... @@ -1820,432 +1455,356 @@ - include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; - $tmpholiday = new Holiday($db); - - foreach ($eventarray as $daykey => $notused) { // daykey is the 'YYYYMMDD' to show according to user - $annee = dol_print_date($daykey, '%Y', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD' - $mois = dol_print_date($daykey, '%m', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD' - $jour = dol_print_date($daykey, '%d', 'gmt'); // We use gmt because we want the value represented by string 'YYYYMMDD' - - //print 'event daykey='.$daykey.' dol_print_date(daykey)='.dol_print_date($daykey, 'dayhour', 'gmt').' jour='.$jour.' mois='.$mois.' annee='.$annee."
    \n"; - - if ($day == $jour && $month == $mois && $year == $annee) { - foreach ($eventarray[$daykey] as $index => $event) { - if ($i < $maxprint || $maxprint == 0 || getDolGlobalString('MAIN_JS_SWITCH_AGENDA')) { - $keysofuserassigned = array_keys($event->userassigned); - $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); - - // Define $color (Hex string like '0088FF') and $cssclass of event - $color = -1; - $cssclass = ''; - $colorindex = -1; - if (in_array($user->id, $keysofuserassigned)) { - $cssclass = 'family_mytasks'; - - if (empty($cacheusers[$event->userownerid])) { - $newuser = new User($db); - $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid] = $newuser; - } - //var_dump($cacheusers[$event->userownerid]->color); - - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (!empty($cacheusers[$event->userownerid]->color)) { - $color = $cacheusers[$event->userownerid]->color; - } - } elseif ($event->type_code == 'ICALEVENT') { // Event come from external ical file - $numical++; - if (!empty($event->icalname)) { - if (!isset($numicals[dol_string_nospecial($event->icalname)])) { - $numicals[dol_string_nospecial($event->icalname)] = 0; - } - $numicals[dol_string_nospecial($event->icalname)]++; - } - - $color = ($event->icalcolor ? $event->icalcolor : -1); - $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); - } elseif ($event->type_code == 'BIRTHDAY') { - $numbirthday++; - $colorindex = 2; - $cssclass = 'family_birthday '; - $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } elseif ($event->type == 'bookcal_calendar') { - $numbirthday++; - $colorindex = 3; - $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink"]) ? $bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_calendar] : ""); - $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } else { - $numother++; - $color = ($event->icalcolor ? $event->icalcolor : -1); - $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); - - if (empty($cacheusers[$event->userownerid])) { - $newuser = new User($db); - $newuser->fetch($event->userownerid); - $cacheusers[$event->userownerid] = $newuser; - } - //var_dump($cacheusers[$event->userownerid]->color); - - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if (!empty($cacheusers[$event->userownerid]->color)) { - $color = $cacheusers[$event->userownerid]->color; - } - } - - if ($color < 0) { // Color was not set on user card. Set color according to color index. - // Define color index if not yet defined - $idusertouse = ($event->userownerid ? $event->userownerid : 0); - if (isset($colorindexused[$idusertouse])) { - $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user - } else { - $colorindex = $nextindextouse; - $colorindexused[$idusertouse] = $colorindex; - if (!empty($theme_datacolor[$nextindextouse + 1])) { - $nextindextouse++; // Prepare to use next color - } - } - //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'
    '; - // Define color - $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); - } - $cssclass = $cssclass.' eventday_'.$ymd; - - // Defined style to disable drag and drop feature - if ($event->type_code == 'AC_OTH_AUTO') { - $cssclass .= " unmovable"; - } elseif ($event->type_code == 'HOLIDAY') { - $cssclass .= " unmovable"; - } elseif ($event->type_code == 'BIRTHDAY') { - $cssclass .= " unmovable"; - } elseif ($event->type_code == 'ICALEVENT') { - $cssclass .= " unmovable"; - } elseif ($event->date_start_in_calendar && $event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { - // If the event is on several days - $tmpyearend = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel'); - $tmpmonthend = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel'); - $tmpdayend = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel'); - //var_dump($tmpyearend.' '.$tmpmonthend.' '.$tmpdayend); - if ($tmpyearend != $annee || $tmpmonthend != $mois || $tmpdayend != $jour) { - $cssclass .= " unmovable unmovable-mustusefirstdaytodrag"; - } else { - $cssclass .= ' movable cursormove'; - } - } else { - if ($user->hasRight('agenda', 'allactions', 'create') || - (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) { - $cssclass .= " movable cursormove"; - } else { - $cssclass .= " unmovable"; - } - } - - $h = ''; - $nowrapontd = 1; - if ($mode == 'show_day') { - $h = 'height: 100%; '; - $nowrapontd = 0; - } - if ($mode == 'show_week') { - $h = 'height: 100%; '; - $nowrapontd = 0; - } - - // Show event box - print "\n"; - print ''."\n"; - - $morecss = ''; - if ($maxprint && $ireallyshown >= $maxprint) { - $morecss = 'showifmore'; - } - if ($event->type == 'birthdate' && !GETPOST('check_birthday')) { - $morecss = 'hidden'; - } - if ($event->type == 'holiday' && !GETPOST('check_holiday')) { - $morecss = 'hidden'; - } - if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_calendar])) { - $morecss = 'hidden'; - } - if ($morecss != 'hidden') { - $itoshow++; - } - if ($morecss != 'showifmore' && $morecss != 'hidden') { - $ireallyshown++; - } - //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow); - if (isModEnabled("bookcal") && $event->type == 'bookcal_calendar') { - print '
    fk_bookcal_calendar].' '.$cssclass.($morecss ? ' '.$morecss : '').'"'; - } else { - print '
    '; - - //var_dump($event->userassigned); - //var_dump($event->transparency); - print ''; - print ''; - print ''; - // Status - Percent - $withstatus = 0; - if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { - $withstatus = 1; - if ($event->percentage >= 0) { - $withstatus = 2; - } - } - print '
    '; - - $daterange = ''; - - if ($event->type_code == 'BIRTHDAY') { - // It's birthday calendar - $picb = ''; - //$pice = ''; - //$typea = ($objp->typea == 'birth') ? $picb : $pice; - //var_dump($event); - print $picb.' '.$langs->trans("Birthday").'
    '; - //print img_picto($langs->trans("Birthday"), 'birthday-cake').' '; - - $tmpid = $event->id; - if (empty($cachecontacts[$tmpid])) { - $newcontact = new Contact($db); - $newcontact->fetch($tmpid); - $cachecontact[$tmpid] = $newcontact; - } - print $cachecontact[$tmpid]->getNomUrl(1); - - //$event->picto = 'birthday-cake'; - //print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); - /*$listofcontacttoshow = ''; - $listofcontacttoshow .= '
    '.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle'); - print $listofcontacttoshow; - */ - } elseif ($event->type_code == 'HOLIDAY') { - // It's holiday calendar - $tmpholiday->fetch($event->id); - - print $tmpholiday->getNomUrl(1); - - $tmpid = $tmpholiday->fk_user; - if (empty($cacheusers[$tmpid])) { - $newuser = new User($db); - $newuser->fetch($tmpid); - $cacheusers[$tmpid] = $newuser; - } - - $listofusertoshow = ''; - $listofusertoshow .= '
    '.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle'); - print $listofusertoshow; - } else { - // Other calendar - if (empty($event->fulldayevent)) { - //print $event->getNomUrl(2).' '; - } - - // Date - if (empty($event->fulldayevent)) { - // Show hours (start ... end) - $tmpyearstart = dol_print_date($event->date_start_in_calendar, '%Y', 'tzuserrel'); - $tmpmonthstart = dol_print_date($event->date_start_in_calendar, '%m', 'tzuserrel'); - $tmpdaystart = dol_print_date($event->date_start_in_calendar, '%d', 'tzuserrel'); - $tmpyearend = dol_print_date($event->date_end_in_calendar, '%Y', 'tzuserrel'); - $tmpmonthend = dol_print_date($event->date_end_in_calendar, '%m', 'tzuserrel'); - $tmpdayend = dol_print_date($event->date_end_in_calendar, '%d', 'tzuserrel'); - - // Hour start - if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { - $daterange .= dol_print_date($event->date_start_in_calendar, 'hour', 'tzuserrel'); - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { - if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) { - $daterange .= '-'; - } - //else - //print '...'; - } - } - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { - if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { - $daterange .= '...'; - } - } - // Hour end - if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { - if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { - $daterange .= dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); - } - } - } else { - if ($showinfo) { - print $langs->trans("EventOnFullDay")."
    \n"; - } - } - - // Show title - $titletoshow = $daterange; - $titletoshow .= ($titletoshow ? ' ' : '').dol_escape_htmltag($event->label ? $event->label : $event->libelle); - - if ($event->type_code != 'ICALEVENT') { - $savlabel = $event->label ? $event->label : $event->libelle; - $event->label = $titletoshow; - $event->libelle = $titletoshow; // deprecatd - // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user. - $titletoshow = (($event->type_picto || $event->type_code) ? $event->getTypePicto() : ''); - $titletoshow .= $event->getNomUrl(0, $maxnbofchar, 'cal_event cal_event_title', '', 0, 0); - $event->label = $savlabel; - $event->libelle = $savlabel; - } - - // Loop on each assigned user - $listofusertoshow = ''; - $posuserassigned = 0; - foreach ($event->userassigned as $tmpid => $tmpdata) { - if (!$posuserassigned && $titletoshow) { - $listofusertoshow .= '
    '; - } - $posuserassigned++; - if (empty($cacheusers[$tmpid])) { - $newuser = new User($db); - $newuser->fetch($tmpid); - $cacheusers[$tmpid] = $newuser; - } - - $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle'); - } - - print $titletoshow; - print $listofusertoshow; - - if ($event->type_code == 'ICALEVENT') { - print '
    ('.dol_trunc($event->icalname, $maxnbofchar).')'; - } - - $thirdparty_id = ($event->socid > 0 ? $event->socid : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); - $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0)); - - // If action related to company / contact - $linerelatedto = ''; - if ($thirdparty_id > 0) { - if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) { - $thirdparty = new Societe($db); - $thirdparty->fetch($thirdparty_id); - $cachethirdparties[$thirdparty_id] = $thirdparty; - } else { - $thirdparty = $cachethirdparties[$thirdparty_id]; - } - if (!empty($thirdparty->id)) { - $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); - } - } - if (!empty($contact_id) && $contact_id > 0) { - if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) { - $contact = new Contact($db); - $contact->fetch($contact_id); - $cachecontacts[$contact_id] = $contact; - } else { - $contact = $cachecontacts[$contact_id]; - } - if ($linerelatedto) { - $linerelatedto .= ' '; - } - if (!empty($contact->id)) { - $linerelatedto .= $contact->getNomUrl(1, '', 0); - } - } - if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT')) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ($linerelatedto) { - $linerelatedto .= '
    '; - } - $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); - } - if ($linerelatedto) { - print ' '.$linerelatedto; - } - } - - // Show location - if ($showinfo) { - if ($event->location) { - print '
    '; - print $langs->trans("Location").': '.$event->location; - } - } - - print '
    '; - if ($withstatus) { - print $event->getLibStatut(3, 1); - } else { - print ' '; - } - print '
    '; - print '
    '."\n"; - - $i++; - } else { - print ''.img_picto("all", "1downarrow_selected.png").' ...'; - print ' +'.(count($eventarray[$daykey]) - $maxprint); - print ''; - break; - //$ok=false; // To avoid to show twice the link - } - } - - break; - } - } - if (!$i) { // No events - print ' '; - } - - if (getDolGlobalString('MAIN_JS_SWITCH_AGENDA') && $itoshow > $ireallyshown && $maxprint) { - print '
    '.img_picto("All", "angle-double-down", 'class="warning"').' +'.($itoshow - $ireallyshown).'
    '; - //print ' +'.(count($eventarray[$daykey])-$maxprint); - - print ''."\n"; - } - - print '
    '; // td tr - - print '
    '; // table - print "\n"; + foreach ($eventarray as $daykey => $notused) + { + $annee = date('Y', $daykey); + $mois = date('m', $daykey); + $jour = date('d', $daykey); + if ($day == $jour && $month == $mois && $year == $annee) + { + foreach ($eventarray[$daykey] as $index => $event) + { + if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) + { + $keysofuserassigned = array_keys($event->userassigned); + $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); + + // Define $color (Hex string like '0088FF') and $cssclass of event + $color = -1; $cssclass = ''; $colorindex = -1; + if (in_array($user->id, $keysofuserassigned)) + { + $cssclass = 'family_mytasks'; + + if (empty($cacheusers[$event->userownerid])) + { + $newuser = new User($db); + $newuser->fetch($event->userownerid); + $cacheusers[$event->userownerid] = $newuser; + } + //var_dump($cacheusers[$event->userownerid]->color); + + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; + } + elseif ($event->type_code == 'ICALEVENT') // Event come from external ical file + { + $numical++; + if (!empty($event->icalname)) { + if (!isset($numicals[dol_string_nospecial($event->icalname)])) { + $numicals[dol_string_nospecial($event->icalname)] = 0; + } + $numicals[dol_string_nospecial($event->icalname)]++; + } + + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); + } + elseif ($event->type_code == 'BIRTHDAY') + { + $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + } + else + { + $numother++; + $color = ($event->icalcolor ? $event->icalcolor : -1); + $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other'); + + if (empty($cacheusers[$event->userownerid])) + { + $newuser = new User($db); + $newuser->fetch($event->userownerid); + $cacheusers[$event->userownerid] = $newuser; + } + //var_dump($cacheusers[$event->userownerid]->color); + + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; + } + + if ($color < 0) // Color was not set on user card. Set color according to color index. + { + // Define color index if not yet defined + $idusertouse = ($event->userownerid ? $event->userownerid : 0); + if (isset($colorindexused[$idusertouse])) + { + $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user + } + else + { + $colorindex = $nextindextouse; + $colorindexused[$idusertouse] = $colorindex; + if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color + } + //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'
    '; + // Define color + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + } + $cssclass = $cssclass.' '.$cssclass.'_day_'.$ymd; + + // Defined style to disable drag and drop feature + if ($event->type_code == 'AC_OTH_AUTO') + { + $cssclass .= " unmovable"; + } + elseif ($event->type_code == 'ICALEVENT') + { + $cssclass .= " unmovable"; + } elseif ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { + $tmpyearend = date('Y', $event->date_end_in_calendar); + $tmpmonthend = date('m', $event->date_end_in_calendar); + $tmpdayend = date('d', $event->date_end_in_calendar); + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) + { + $cssclass .= " unmovable"; + } + } + else { + if ($user->rights->agenda->allactions->create || + (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { + $cssclass .= " movable cursormove"; + } else { + $cssclass .= " unmovable"; + } + } + + $h = ''; $nowrapontd = 1; + if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; } + if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; } + + // Show rect of event + print "\n"; + print ''."\n"; + print '
    '; + + //var_dump($event->userassigned); + //var_dump($event->transparency); + print ''; + print ''; + print ''; + // Status - Percent + $withstatus = 0; + if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') + { + $withstatus = 1; + if ($event->percentage >= 0) $withstatus = 2; + } + print '
    '; + + $daterange = ''; + + if ($event->type_code == 'BIRTHDAY') // It's a birthday + { + print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); + } + elseif ($event->type_code == 'HOLIDAY') + { + print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'holiday', 'user'); + } + elseif ($event->type_code != 'BIRTHDAY' && $event->type_code != 'HOLIDAY') + { + // Picto + if (empty($event->fulldayevent)) + { + //print $event->getNomUrl(2).' '; + } + + // Date + if (empty($event->fulldayevent)) + { + // Show hours (start ... end) + $tmpyearstart = date('Y', $event->date_start_in_calendar); + $tmpmonthstart = date('m', $event->date_start_in_calendar); + $tmpdaystart = date('d', $event->date_start_in_calendar); + $tmpyearend = date('Y', $event->date_end_in_calendar); + $tmpmonthend = date('m', $event->date_end_in_calendar); + $tmpdayend = date('d', $event->date_end_in_calendar); + // Hour start + if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) + { + $daterange .= dol_print_date($event->date_start_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) + $daterange .= '-'; + //else + //print '...'; + } + } + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) + { + $daterange .= '...'; + } + } + // Hour end + if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) + { + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) + $daterange .= dol_print_date($event->date_end_in_calendar, 'hour'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user + } + } + else + { + if ($showinfo) + { + print $langs->trans("EventOnFullDay")."
    \n"; + } + } + + // Show title + $titletoshow = $daterange; + $titletoshow .= ($titletoshow ? ' ' : '').($event->label ? $event->label : $event->libelle); + + if ($event->type_code != 'ICALEVENT') { + $savlabel = $event->label ? $event->label : $event->libelle; + $event->label = $titletoshow; + $event->libelle = $titletoshow; + // Note: List of users are inside $event->userassigned. Link may be clickable depending on permissions of user. + $titletoshow = $event->getNomUrl(0, $maxnbofchar, 'cal_event', '', 0, 0); + $event->label = $savlabel; + $event->libelle = $savlabel; + } + + // Loop on each assigned user + $listofusertoshow = ''; + $posuserassigned = 0; + foreach ($event->userassigned as $tmpid => $tmpdata) + { + if (!$posuserassigned && $titletoshow) $listofusertoshow .= '
    '; + $posuserassigned++; + if (empty($cacheusers[$tmpid])) + { + $newuser = new User($db); + $newuser->fetch($tmpid); + $cacheusers[$tmpid] = $newuser; + } + + $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); + } + + print $titletoshow; + print $listofusertoshow; + + if ($event->type_code == 'ICALEVENT') print '
    ('.dol_trunc($event->icalname, $maxnbofchar).')'; + + $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); + $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0)); + + // If action related to company / contact + $linerelatedto = ''; + if ($thirdparty_id > 0) + { + if (!isset($cachethirdparties[$thirdparty_id]) || !is_object($cachethirdparties[$thirdparty_id])) + { + $thirdparty = new Societe($db); + $thirdparty->fetch($thirdparty_id); + $cachethirdparties[$thirdparty_id] = $thirdparty; + } + else $thirdparty = $cachethirdparties[$thirdparty_id]; + if (!empty($thirdparty->id)) $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); + } + if (!empty($contact_id) && $contact_id > 0) + { + if (!is_object($cachecontacts[$contact_id])) + { + $contact = new Contact($db); + $contact->fetch($contact_id); + $cachecontacts[$contact_id] = $contact; + } + else $contact = $cachecontacts[$contact_id]; + if ($linerelatedto) $linerelatedto .= ' '; + if (!empty($contact->id)) $linerelatedto .= $contact->getNomUrl(1, '', 0); + } + if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if ($linerelatedto) $linerelatedto .= '
    '; + $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); + } + if ($linerelatedto) print '
    '.$linerelatedto; + } + + // Show location + if ($showinfo) + { + if ($event->location) + { + print '
    '; + print $langs->trans("Location").': '.$event->location; + } + } + + print '
    '; + if ($withstatus) print $event->getLibStatut(3, 1); + else print ' '; + print '
    '; + print '
    '."\n"; + $i++; + } + else + { + print ''.img_picto("all", "1downarrow_selected.png").' ...'; + print ' +'.(count($eventarray[$daykey]) - $maxprint); + print ''; + break; + //$ok=false; // To avoid to show twice the link + } + } + + break; + } + } + if (!$i) print ' '; + + if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) + { + print '
    '.img_picto("all", "1downarrow_selected.png").' +'.$langs->trans("More").'...
    '; + //print ' +'.(count($eventarray[$daykey])-$maxprint); + print ''."\n"; + } + + print '
    '; // td tr + + print '
    '; // table + print "\n"; @@ -2266,6 +1825,9 @@ - if ($minusunit == 16) { - $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); - $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); - $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); - } else { - // Not yet implemented + if ($minusunit == 16) + { + $newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0)); + $newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0)); + $newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0)); + } + else + { + // Not yet implemented @@ -2281 +1843 @@ - * @return int Return integer < 0 if event A should be before event B, > 0 otherwise, 0 if they have the exact same time slot + * @return int < 0 if event A should be before event B, > 0 otherwise, 0 if they have the exact same time slot @@ -2286,27 +1848,33 @@ - if ($a->type_code === 'HOLIDAY') { - return -1; - } - if ($b->type_code === 'HOLIDAY') { - return 1; - } - - // datep => Event start time - // datef => Event end time - - // Events have different start time - if ($a->datep !== $b->datep) { - return $a->datep - $b->datep; - } - - // Events have same start time and no end time - if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) { - return sort_events_by_percentage($a, $b); - } - - // Events have the same start time and same end time - if ($b->datef === $a->datef) { - return sort_events_by_percentage($a, $b); - } - - // Events have the same start time, but have different end time -> longest event first - return $b->datef - $a->datef; + if ($a->type_code === 'HOLIDAY') + { + return -1; + } + + if ($b->type_code === 'HOLIDAY') + { + return 1; + } + + // datep => Event start time + // datef => Event end time + + // Events have different start time + if ($a->datep !== $b->datep) + { + return $a->datep - $b->datep; + } + + // Events have same start time and no end time + if ((!is_numeric($b->datef)) || (!is_numeric($a->datef))) + { + return sort_events_by_percentage($a, $b); + } + + // Events have the same start time and same end time + if ($b->datef === $a->datef) + { + return sort_events_by_percentage($a, $b); + } + + // Events have the same start time, but have different end time -> longest event first + return $b->datef - $a->datef; @@ -2320 +1888 @@ - * @return int Return integer < 0 if event A should be before event B, > 0 otherwise, 0 if they have the exact same percentage + * @return int < 0 if event A should be before event B, > 0 otherwise, 0 if they have the exact same percentage @@ -2324,13 +1892,15 @@ - // Sort events with no percentage before each other - // (usefull to sort holidays, sick days or similar on the top) - - if ($a->percentage < 0) { - return -1; - } - - if ($b->percentage < 0) { - return 1; - } - - return $b->percentage - $a->percentage; -} + // Sort events with no percentage before each other + // (usefull to sort holidays, sick days or similar on the top) + + if ($a->percentage < 0) + { + return -1; + } + + if ($b->percentage < 0) + { + return 1; + } + + return $b->percentage - $a->percentage; +} --- /tmp/dsg/dolibarr/htdocs/comm/action/github_19.0.3_info.php +++ /tmp/dsg/dolibarr/htdocs/comm/action/client_info.php @@ -3 +3 @@ - * Copyright (C) 2004-2023 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur @@ -25 +24,0 @@ -// Load Dolibarr environment @@ -32,3 +31,3 @@ -if (isModEnabled('project')) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -42,3 +40,0 @@ -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('actioncard', 'globalcard')); - @@ -46,3 +42,4 @@ -if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; +if ($user->socid > 0) +{ + $action = ''; + $socid = $user->socid; @@ -52,5 +48,0 @@ -if ($user->socid && $socid) { - $result = restrictedArea($user, 'societe', $socid); -} - -$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create')); @@ -65 +57 @@ -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; @@ -73 +65,4 @@ -print dol_get_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action'); +dol_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action'); + +$linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"'); +$linkback .= ''.$langs->trans("BackToList").''; @@ -76,28 +71,9 @@ -$linkback = ''; -$linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"'); -$linkback .= ''.$langs->trans("BackToList").''; -$linkback .= ''; -$linkback .= '
  • '; -$linkback .= '
  • '; -$linkback .= ''; -$linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"'); -$linkback .= ''.$langs->trans("ViewCal").''; -$linkback .= ''; -$linkback .= '
  • '; -$linkback .= '
  • '; -$linkback .= ''; -$linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"'); -$linkback .= ''.$langs->trans("ViewWeek").''; -$linkback .= ''; -$linkback .= '
  • '; -$linkback .= '
  • '; -$linkback .= ''; -$linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"'); -$linkback .= ''.$langs->trans("ViewDay").''; -$linkback .= ''; -$linkback .= '
  • '; -$linkback .= '
  • '; -$linkback .= ''; -$linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"'); -$linkback .= ''.$langs->trans("ViewPerUser").''; -$linkback .= ''; +$out = ''; +$out .= '
  • '.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"'); +$out .= ''.$langs->trans("ViewPerUser").''; +$out .= '
  • '.img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"'); +$out .= ''.$langs->trans("ViewCal").''; +$out .= '
  • '.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"'); +$out .= ''.$langs->trans("ViewWeek").''; +$out .= '
  • '.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"'); +$out .= ''.$langs->trans("ViewDay").''; @@ -105,8 +81 @@ -// Add more views from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); -if (empty($reshook)) { - $linkback .= $hookmanager->resPrint; -} elseif ($reshook > 1) { - $linkback = $hookmanager->resPrint; -} +$linkback .= $out; @@ -114,0 +84,2 @@ +// Thirdparty +//$morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); @@ -116,19 +87,15 @@ -if (isModEnabled('project')) { - $langs->load("projects"); - //$morehtmlref .= '
    '; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } +if (!empty($conf->projet->enabled)) +{ + $langs->load("projects"); + //$morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').': '; + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } @@ -148 +115 @@ -print dol_get_fiche_end(); +dol_fiche_end(); --- /tmp/dsg/dolibarr/htdocs/comm/action/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/comm/action/client_list.php @@ -7,2 +7 @@ - * Copyright (C) 2018-2021 Frédéric France - * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2018 Frédéric France @@ -30 +29,2 @@ -// Load Dolibarr environment +if (!defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); + @@ -35,0 +36 @@ +include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; @@ -38,2 +38,0 @@ -include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - @@ -41,22 +40,9 @@ -$langs->loadLangs(array("users", "companies", "agenda", "commercial", "other", "orders", "bills")); - -// Get Parameters -$action = GETPOST('action', 'aZ09'); -$massaction = GETPOST('massaction', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); -$toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search -$optioncss = GETPOST('optioncss', 'alpha'); - - -$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); - -$mode = GETPOST('mode', 'aZ09'); -if (empty($mode) && preg_match('/show_/', $action)) { - $mode = $action; // For backward compatibility -} -$resourceid = GETPOST("search_resourceid", "int") ? GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); -$pid = GETPOST("search_projectid", 'int', 3) ? GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); -$search_status = (GETPOST("search_status", 'aZ09') != '') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); -$type = GETPOST('search_type', 'alphanohtml') ? GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); +$langs->loadLangs(array("users", "companies", "agenda", "commercial", "other")); + +$action = GETPOST('action', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search +$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); +$pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); +$search_status = (GETPOST("search_status", 'alpha') != '') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); +$optioncss = GETPOST('optioncss', 'alpha'); @@ -66 +51,0 @@ - @@ -68,10 +53,10 @@ -if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} - -// Search Fields +if (GETPOST('search_actioncode', 'array')) +{ + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; +} +else +{ + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); +} +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -82,17 +67,10 @@ -// $dateselect is a day included inside the event range -$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'), 'tzuserrel'); -$datestart_dtstart = dol_mktime(0, 0, 0, GETPOST('datestart_dtstartmonth', 'int'), GETPOST('datestart_dtstartday', 'int'), GETPOST('datestart_dtstartyear', 'int'), 'tzuserrel'); -$datestart_dtend = dol_mktime(23, 59, 59, GETPOST('datestart_dtendmonth', 'int'), GETPOST('datestart_dtendday', 'int'), GETPOST('datestart_dtendyear', 'int'), 'tzuserrel'); -$dateend_dtstart = dol_mktime(0, 0, 0, GETPOST('dateend_dtstartmonth', 'int'), GETPOST('dateend_dtstartday', 'int'), GETPOST('dateend_dtstartyear', 'int'), 'tzuserrel'); -$dateend_dtend = dol_mktime(23, 59, 59, GETPOST('dateend_dtendmonth', 'int'), GETPOST('dateend_dtendday', 'int'), GETPOST('dateend_dtendyear', 'int'), 'tzuserrel'); -if ($search_status == '' && !GETPOSTISSET('search_status')) { - $search_status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -} -if (empty($mode) && !GETPOSTISSET('mode')) { - $mode = (!getDolGlobalString('AGENDA_DEFAULT_VIEW') ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); -} - -$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); -$showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ? GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1; +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); +$datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); +$dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); +if ($search_status == '' && !GETPOSTISSET('search_status')) $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); + +$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); +$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); +$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ?GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1; @@ -111 +89,2 @@ -if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) { +if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) +{ @@ -115,4 +94,3 @@ -// Pagination parameters -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -120,4 +98 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if ($page == -1 || $page == null) { $page = 0; } @@ -125 +100,2 @@ -if (!$sortorder) { +if (!$sortorder) +{ @@ -127,5 +103,4 @@ - if ($search_status == 'todo') { - $sortorder = "DESC,DESC"; - } -} -if (!$sortfield) { + if ($search_status == 'todo') $sortorder = "DESC,DESC"; +} +if (!$sortfield) +{ @@ -133,3 +108 @@ - if ($search_status == 'todo') { - $sortfield = "a.datep,a.id"; - } + if ($search_status == 'todo') $sortfield = "a.datep,a.id"; @@ -139,7 +112,4 @@ -$socid = GETPOST("search_socid", 'int') ? GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); -if ($user->socid) { - $socid = $user->socid; -} -if ($socid < 0) { - $socid = ''; -} +$socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'agenda', 0, '', 'myactions'); +if ($socid < 0) $socid = ''; @@ -148,7 +118,4 @@ -if (!$user->hasRight('agenda', 'myactions', 'read')) { - accessforbidden(); -} -if (!$user->hasRight('agenda', 'allactions', 'read')) { - $canedit = 0; -} -if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me +if (!$user->rights->agenda->myactions->read) accessforbidden(); +if (!$user->rights->agenda->allactions->read) $canedit = 0; +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me +{ @@ -167,5 +134,5 @@ - 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>0), - 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>1, 'enabled'=>(getDolGlobalString('AGENDA_SHOW_LINKED_OBJECT'))), - 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>510), - 'a.tms'=>array('label'=>'DateModification', 'checked'=>0, 'position'=>520), - 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) + 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>1), + 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), + 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), + 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0), + 'a.tms'=>array('label'=>'DateModification', 'checked'=>0) @@ -174,2 +141,8 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} @@ -178,5 +150,0 @@ - -$result = restrictedArea($user, 'agenda', 0, '', 'myactions'); -if ($user->socid && $socid) { - $result = restrictedArea($user, 'societe', $socid); -} @@ -189,6 +157,2 @@ -if (GETPOST('cancel', 'alpha')) { - $mode = 'list'; - $massaction = ''; -} - -if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { +if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) +{ @@ -196,5 +160,7 @@ - if (is_array($_POST)) { - foreach ($_POST as $key => $val) { - $param .= '&'.$key.'='.urlencode($val); - } - } + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + $param .= '&'.$key.'='.urlencode($val); + } + } @@ -208,3 +174 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -215,3 +179,4 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - //$actioncode=''; - $search_id = ''; +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers +{ + //$actioncode=''; + $search_id = ''; @@ -219,55 +184,7 @@ - $search_note = ''; - $datestart_dtstart = ''; - $datestart_dtend = ''; - $dateend_dtstart = ''; - $dateend_dtend = ''; - $actioncode = ''; - $search_status = ''; - $pid = ''; - $socid = ''; - $resourceid = ''; - $filter = ''; - $filtert = ''; - $usergroup = ''; - $toselect = array(); - $search_array_options = array(); -} - -if (empty($reshook) && !empty($massaction)) { - unset($percent); - - switch ($massaction) { - case 'set_all_events_to_todo': - $percent = ActionComm::EVENT_TODO; - break; - - case 'set_all_events_to_in_progress': - $percent = ActionComm::EVENT_IN_PROGRESS; - break; - - case 'set_all_events_to_finished': - $percent = ActionComm::EVENT_FINISHED; - break; - } - - if (isset($percent)) { - foreach ($toselect as $toselectid) { - $result = $object->updatePercent($toselectid, $percent); - if ($result < 0) { - dol_print_error($db); - break; - } - } - } -} - -// As mass deletion happens with a confirm step, $massaction is not use for the final step (deletion). -if (empty($reshook)) { - $objectclass = 'ActionComm'; - $objectlabel = 'Events'; - $uploaddir = true; - // Only users that can delete any event can remove records. - $permissiontodelete = $user->hasRight('agenda', 'allactions', 'delete'); - $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create'); - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; -} + $search_note = ''; + $datestart = ''; + $dateend = ''; + $search_status = ''; + $search_array_options = array(); +} + @@ -276 +193 @@ - * View + * View @@ -283,4 +199,0 @@ -$actionstatic = new ActionComm($db); -$societestatic = new Societe($db); -$contactstatic = new Contact($db); - @@ -293,3 +206,2 @@ -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung'; -$title = $langs->trans("Agenda"); -llxHeader('', $title, $help_url); +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; +llxHeader('', $langs->trans("Agenda"), $help_url); @@ -301,6 +213,2 @@ -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); @@ -309,82 +217,22 @@ - foreach ($actioncode as $str_action) { - $param .= "&search_actioncode[]=".urlencode($str_action); - } - } else { - $param .= "&search_actioncode=".urlencode($actioncode); - } -} -if ($resourceid > 0) { - $param .= "&search_resourceid=".urlencode($resourceid); -} -if ($search_status != '') { - $param .= "&search_status=".urlencode($search_status); -} -if ($filter) { - $param .= "&search_filter=".urlencode($filter); -} -if ($filtert) { - $param .= "&search_filtert=".urlencode($filtert); -} -if ($usergroup > 0) { - $param .= "&search_usergroup=".urlencode($usergroup); -} -if ($socid > 0) { - $param .= "&search_socid=".urlencode($socid); -} -if ($showbirthday) { - $param .= "&search_showbirthday=1"; -} -if ($pid) { - $param .= "&search_projectid=".urlencode($pid); -} -if ($type) { - $param .= "&search_type=".urlencode($type); -} -if ($search_id != '') { - $param .= '&search_id='.urlencode($search_id); -} -if ($search_title != '') { - $param .= '&search_title='.urlencode($search_title); -} -if ($search_note != '') { - $param .= '&search_note='.urlencode($search_note); -} -if (GETPOST('datestart_dtstartday', 'int')) { - $param .= '&datestart_dtstartday='.GETPOST('datestart_dtstartday', 'int'); -} -if (GETPOST('datestart_dtstartmonth', 'int')) { - $param .= '&datestart_dtstartmonth='.GETPOST('datestart_dtstartmonth', 'int'); -} -if (GETPOST('datestart_dtstartyear', 'int')) { - $param .= '&datestart_dtstartyear='.GETPOST('datestart_dtstartyear', 'int'); -} -if (GETPOST('datestart_dtendday', 'int')) { - $param .= '&datestart_dtendday='.GETPOST('datestart_dtendday', 'int'); -} -if (GETPOST('datestart_dtendmonth', 'int')) { - $param .= '&datestart_dtendmonth='.GETPOST('datestart_dtendmonth', 'int'); -} -if (GETPOST('datestart_dtendyear', 'int')) { - $param .= '&datestart_dtendyear='.GETPOST('datestart_dtendyear', 'int'); -} -if (GETPOST('dateend_dtstartday', 'int')) { - $param .= '&dateend_dtstartday='.GETPOST('dateend_dtstartday', 'int'); -} -if (GETPOST('dateend_dtstartmonth', 'int')) { - $param .= '&dateend_dtstartmonth='.GETPOST('dateend_dtstartmonth', 'int'); -} -if (GETPOST('dateend_dtstartyear', 'int')) { - $param .= '&dateend_dtstartyear='.GETPOST('dateend_dtstartyear', 'int'); -} -if (GETPOST('dateend_dtendday', 'int')) { - $param .= '&dateend_dtendday='.GETPOST('dateend_dtendday', 'int'); -} -if (GETPOST('dateend_dtendmonth', 'int')) { - $param .= '&dateend_dtendmonth='.GETPOST('dateend_dtendmonth', 'int'); -} -if (GETPOST('dateend_dtendyear', 'int')) { - $param .= '&dateend_dtendyear='.GETPOST('dateend_dtendyear', 'int'); -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); +} +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($search_id != '') $param .= '&search_title='.urlencode($search_id); +if ($search_title != '') $param .= '&search_title='.urlencode($search_title); +if ($search_note != '') $param .= '&search_note='.$search_note; +if (GETPOST('datestartday', 'int')) $param .= '&datestartday='.GETPOST('datestartday', 'int'); +if (GETPOST('datestartmonth', 'int')) $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); +if (GETPOST('datestartyear', 'int')) $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); +if (GETPOST('dateendday', 'int')) $param .= '&dateendday='.GETPOST('dateendday', 'int'); +if (GETPOST('dateendmonth', 'int')) $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); +if (GETPOST('dateendyear', 'int')) $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -394,19 +241,0 @@ -$paramnoactionodate = $param; - -// List of mass actions available -$arrayofmassactions = array( - 'set_all_events_to_todo' => $langs->trans("SetAllEventsToTodo"), - 'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"), - 'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"), -); -if ($user->hasRight('agenda', 'allactions', 'delete')) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (isModEnabled('category') && $user->hasRight('agenda', 'myactions', 'create')) { - $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { - $arrayofmassactions = array(); -} -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - @@ -414,3 +243 @@ -if ($usergroup > 0) { - $sql .= " DISTINCT"; -} +if ($usergroup > 0) $sql .= " DISTINCT"; @@ -419 +246 @@ -$sql .= " a.fk_user_author, a.fk_user_action,"; +$sql .= ' a.fk_user_author,a.fk_user_action,'; @@ -422 +249 @@ -$sql .= " c.code as type_code, c.libelle as type_label, c.color as type_color, c.type as type_type, c.picto as type_picto,"; +$sql .= " c.code as type_code, c.libelle as type_label,"; @@ -427,3 +254 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -434 +259 @@ -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -437,2 +261,0 @@ -$sqlfields = $sql; // $sql fields to remove for count total - @@ -440,4 +263,2 @@ -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object)"; -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; -} +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; @@ -448,3 +269 @@ -if ($resourceid > 0) { - $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; -} +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; @@ -452,6 +271,2 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -} -if ($usergroup > 0) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -} +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; @@ -461,40 +276,33 @@ -if (!empty($actioncode)) { - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND c.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND c.type = 'systemauto'"; - } else { - if ($actioncode == 'AC_OTH') { - $sql .= " AND c.type != 'systemauto'"; - } - if ($actioncode == 'AC_OTH_AUTO') { - $sql .= " AND c.type = 'systemauto'"; - } - } - } else { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND c.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND c.type = 'systemauto'"; - } else { - if (is_array($actioncode)) { - $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")"; - } else { - $sql .= " AND c.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")"; - } - } - } -} -if ($resourceid > 0) { - $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid); -} -if ($pid) { - $sql .= " AND a.fk_project=".((int) $pid); -} -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; -} -if ($socid > 0) { - $sql .= " AND s.rowid = ".((int) $socid); -} +if (!empty($actioncode)) +{ + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else + { + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; + } + } + else + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; + else + { + if (is_array($actioncode)) + { + $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; + } + else + { + $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } + } +} +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= " AND s.rowid = ".$socid; @@ -502,33 +310,11 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -} -if ($type) { - $sql .= " AND c.id = ".((int) $type); -} -if ($search_status == '0') { - $sql .= " AND a.percent = 0"; -} -if ($search_status == 'na') { - $sql .= " AND a.percent = -1"; -} // Not applicable -if ($search_status == '50') { - $sql .= " AND (a.percent > 0 AND a.percent < 100)"; -} // Running already started -if ($search_status == '100') { - $sql .= " AND a.percent = 100"; -} -if ($search_status == 'done') { - $sql .= " AND (a.percent = 100)"; -} -if ($search_status == 'todo') { - $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; -} -if ($search_id) { - $sql .= natural_search("a.id", $search_id, 1); -} -if ($search_title) { - $sql .= natural_search("a.label", $search_title); -} -if ($search_note) { - $sql .= natural_search('a.note', $search_note); -} +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($type) $sql .= " AND c.id = ".(int) $type; +if ($search_status == '0') { $sql .= " AND a.percent = 0"; } +if ($search_status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($search_status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($search_status == '100') { $sql .= " AND a.percent = 100"; } +if ($search_status == 'done') { $sql .= " AND (a.percent = 100)"; } +if ($search_status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } +if ($search_id) $sql .= natural_search("a.id", $search_id, 1); +if ($search_title) $sql .= natural_search("a.label", $search_title); +if ($search_note) $sql .= natural_search('a.note', $search_note); @@ -536,9 +322,6 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) { - $sql .= "(ar.fk_element = ".((int) $filtert)." OR (ar.fk_element IS NULL AND a.fk_user_action = ".((int) $filtert)."))"; // The OR is for backward compatibility - } - if ($usergroup > 0) { - $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup); - } - $sql .= ")"; +if ($filtert > 0 || $usergroup > 0) +{ + $sql .= " AND ("; + if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; @@ -548,15 +331,3 @@ -if ($dateselect > 0) { - $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))"; -} -if ($datestart_dtstart > 0) { - $sql .= " AND a.datep >= '".$db->idate($datestart_dtstart)."'"; -} -if ($datestart_dtend > 0) { - $sql .= " AND a.datep <= '".$db->idate($datestart_dtend)."'"; -} -if ($dateend_dtstart > 0) { - $sql .= " AND a.datep2 >= '".$db->idate($dateend_dtstart)."'"; -} -if ($dateend_dtend > 0) { - $sql .= " AND a.datep2 <= '".$db->idate($dateend_dtend)."'"; -} +if ($dateselect > 0) $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))"; +if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; +if ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; @@ -569 +340 @@ -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -572 +343,2 @@ -// Count total nb of records +$sql .= $db->order($sortfield, $sortorder); + @@ -574,11 +346,114 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); +//print $sql; + +dol_syslog("comm/action/list.php", LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) +{ + $actionstatic = new ActionComm($db); + $societestatic = new Societe($db); + + $num = $db->num_rows($resql); + + // Local calendar + $newtitle = '
    '.$langs->trans("LocalAgenda").'  
    '; + //$newtitle=$langs->trans($title); + + $tabactive = 'cardlist'; + + $head = calendars_prepare_head($param); + + print '
    '."\n"; + + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $nav = ''; + + if ($filter) $nav .= ''; + if ($showbirthday) $nav .= ''; + print $nav; + + dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); + print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + dol_fiche_end(); + + // Add link to show birthdays + $link = ''; + /* + if (empty($conf->use_javascript_ajax)) + { + $newparam=$param; // newparam is for birthday links + $newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam); + if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1'; + $link=''; + if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents"); + else $link.=$langs->trans("AgendaHideBirthdayEvents"); + $link.=''; + } + */ + + $s = $newtitle; + + // Calendars from hooks + $parameters = array(); $object = null; + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); + if (empty($reshook)) + { + $s .= $hookmanager->resPrint; + } + elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } + + $newcardbutton = ''; + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + { + $tmpforcreatebutton = dol_getdate(dol_now(), true); + + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; + + //$param='month='.$monthshown.'&year='.$year; + $hourminsec = '100000'; + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); + } + + print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1); + + $moreforfilter = ''; + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + $i = 0; + print '
    '; + print ''."\n"; + + print ''; + if (!empty($arrayfields['a.id']['checked'])) print ''; + if (!empty($arrayfields['owner']['checked'])) print ''; + if (!empty($arrayfields['c.libelle']['checked'])) print ''; + if (!empty($arrayfields['a.label']['checked'])) print ''; + if (!empty($arrayfields['a.note']['checked'])) print ''; + if (!empty($arrayfields['a.datep']['checked'])) { + print ''; @@ -586,4 +461,4 @@ - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 - $page = 0; - $offset = 0; + if (!empty($arrayfields['a.datep2']['checked'])) { + print ''; @@ -591,150 +466,23 @@ - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} - -$resql = $db->query($sql); -if (!$resql) { - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -// Local calendar -$newtitle = '
    '; -$newtitle .= ' '.$langs->trans("LocalAgenda").'   '; -$newtitle .= '
    '; -//$newtitle=$langs->trans($title); - -$tabactive = 'cardlist'; - -$head = calendars_prepare_head($param); - -print ''."\n"; - -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; -print ''; -print ''; -$nav = ''; - -if ($filter) { - $nav .= ''; -} -if ($showbirthday) { - $nav .= ''; -} -print $nav; - -//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); -//print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); -//print dol_get_fiche_end(); - - -$s = $newtitle; - -// Calendars from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); -if (empty($reshook)) { - $s .= $hookmanager->resPrint; -} elseif ($reshook > 1) { - $s = $hookmanager->resPrint; -} -$viewyear = is_object($object) ? dol_print_date($object->datep, '%Y') : ''; -$viewmonth = is_object($object) ? dol_print_date($object->datep, '%m') : ''; -$viewday = is_object($object) ? dol_print_date($object->datep, '%d') : ''; -$viewmode = ''; -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewList").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewCal").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewWeek").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewDay").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewPerUser").''; - -$viewmode .= ''; - -// Add more views from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); -if (empty($reshook)) { - $viewmode .= $hookmanager->resPrint; -} elseif ($reshook > 1) { - $viewmode = $hookmanager->resPrint; -} - -$tmpforcreatebutton = dol_getdate(dol_now(), true); - -$newparam = '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; - -//$param='month='.$monthshown.'&year='.$year; -$hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation - -$url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; -$url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec; -$url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); - -$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')); - -$param .= '&mode='.$mode; - -print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, is_numeric($nbtotalofrecords) ? -1 * $nbtotalofrecords : $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode); - -print $s; - -$objecttmp = new ActionComm($db); -include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - -$moreforfilter = ''; - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields -if ($massactionbutton) { - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); -} -$i = 0; - -print '
    '; -print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); -print '
    '; - -print '
    '; -print '
    '; + print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0); + print ''; + print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0); + print '
    '."\n"; - -print ''; -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + } + if (!empty($arrayfields['a.fk_contact']['checked'])) print ''; + if (!empty($arrayfields['a.fk_element']['checked'])) print ''; + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + if (!empty($arrayfields['a.datec']['checked'])) print ''; + if (!empty($arrayfields['a.tms']['checked'])) print ''; + if (!empty($arrayfields['a.percent']['checked'])) { + print ''; + } + // Action column @@ -742,71 +489,0 @@ - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; -} -if (!empty($arrayfields['a.id']['checked'])) { - print ''; -} -if (!empty($arrayfields['owner']['checked'])) { - print ''; -} -if (!empty($arrayfields['c.libelle']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.label']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.note']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.datep']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.datep2']['checked'])) { - print ''; -} -if (!empty($arrayfields['s.nom']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.fk_contact']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.fk_element']['checked'])) { - print ''; -} - -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -if (!empty($arrayfields['a.datec']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.tms']['checked'])) { - print ''; -} -if (!empty($arrayfields['a.percent']['checked'])) { - print ''; -} -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''."\n"; - -$totalarray = array(); -$totalarray['nbfield'] = 0; - -// Fields title label -// -------------------------------------------------------------------- -print ''; -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print "\n"; + + print ''; + if (!empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); + //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (!empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + if (!empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + + if (!empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); @@ -827,118 +521,32 @@ - $totalarray['nbfield']++; -} -if (!empty($arrayfields['a.id']['checked'])) { - print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['owner']['checked'])) { - print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['c.libelle']['checked'])) { - print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['a.label']['checked'])) { - print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['a.note']['checked'])) { - print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -//if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) -if (!empty($arrayfields['a.datep']['checked'])) { - print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['a.datep2']['checked'])) { - print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['a.fk_contact']['checked'])) { - print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['a.fk_element']['checked'])) { - print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -if (!empty($arrayfields['a.datec']['checked'])) { - print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['a.tms']['checked'])) { - print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -// Status -if (!empty($arrayfields['a.percent']['checked'])) { - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); - $totalarray['nbfield']++; -} -print "\n"; - -$now = dol_now(); -$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; -$today_start_time = dol_mktime(0, 0, 0, date('m', $now), date('d', $now), date('Y', $now)); - -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; -$caction = new CActionComm($db); -$arraylist = $caction->liste_array(1, 'code', '', (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : 0), '', 1); -$contactListCache = array(); - -// Loop on record -// -------------------------------------------------------------------- -$i = 0; -//$savnbfield = $totalarray['nbfield']; -//$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -$cache_user_list = array(); -while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - // Store properties in $object - $object->setVarsFromFetchObj($obj); - - // Discard auto action if option is on - if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->type_code == 'AC_OTH_AUTO') { - $i++; - continue; - } - - $actionstatic->id = $obj->id; - $actionstatic->ref = $obj->id; - $actionstatic->code = $obj->code; - $actionstatic->type_code = $obj->type_code; - $actionstatic->type_label = $obj->type_label; - $actionstatic->type_picto = $obj->type_picto; - $actionstatic->type_color = $obj->type_color; - $actionstatic->label = $obj->label; - $actionstatic->location = $obj->location; - $actionstatic->note_private = dol_htmlentitiesbr($obj->note); - $actionstatic->datep = $db->jdate($obj->dp); - $actionstatic->percentage = $obj->percent; - $actionstatic->authorid = $obj->fk_user_author; - $actionstatic->userownerid = $obj->fk_user_action; - - // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid - // but only if we need it - if (!empty($arrayfields['a.fk_contact']['checked'])) { + print "\n"; + + $contactstatic = new Contact($db); + $now = dol_now(); + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; + $caction = new CActionComm($db); + $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); + $contactListCache = array(); + + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } + + $actionstatic->id = $obj->id; + $actionstatic->ref = $obj->id; + $actionstatic->code = $obj->code; + $actionstatic->type_code = $obj->type_code; + $actionstatic->type_label = $obj->type_label; + $actionstatic->type_picto = $obj->type_picto; + $actionstatic->label = $obj->label; + $actionstatic->location = $obj->location; + $actionstatic->note_private = dol_htmlentitiesbr($obj->note); + @@ -946,58 +554,18 @@ - } - - // cache of user list (owners) - if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { - $userstatic = new User($db); - $res = $userstatic->fetch($obj->fk_user_action); - if ($res > 0) { - $cache_user_list[$obj->fk_user_action] = $userstatic; - } - } - - // get event style for user owner - $event_owner_style = ''; - // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) - if ($cache_user_list[$obj->fk_user_action]->color != '') { - $event_owner_style .= 'border-left: #' . $cache_user_list[$obj->fk_user_action]->color . ' 5px solid;'; - } - - // get event style for start and end date - $event_more_class = ''; - $event_start_date_css = ''; - $event_end_date_css = ''; - $event_start_date_time = $actionstatic->datep; - if ($event_start_date_time > $now) { - // future event - $event_more_class = 'event-future'; - $event_start_date_css = $event_end_date_css = $event_more_class; - } else { - if ($obj->fulldayevent == 1) { - $today_start_date_time = $today_start_time; - } else { - $today_start_date_time = $now; - } - - // check event end date - $event_end_date_time = $db->jdate($obj->dp2); - if ($event_end_date_time != null && $event_end_date_time < $today_start_date_time) { - // past event - $event_more_class = 'event-past'; - } elseif ($event_end_date_time == null && $event_start_date_time < $today_start_date_time) { - // past event - $event_more_class = 'event-past'; - } else { - // current event - $event_more_class = 'event-current'; - } - $event_start_date_css = $event_end_date_css = $event_more_class; - } - $event_start_date_css = $event_end_date_css = $event_more_class; - - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + + // Ref + if (!empty($arrayfields['a.id']['checked'])) { + print ''; + } + + // User owner + if (!empty($arrayfields['owner']['checked'])) + { + print ''; - } - // Ref - if (!empty($arrayfields['a.id']['checked'])) { - print ''; - } - - // User owner - if (!empty($arrayfields['owner']['checked'])) { - //print ''; - } - - // Type - if (!empty($arrayfields['c.libelle']['checked'])) { - print ''; - } - - // Label - if (!empty($arrayfields['a.label']['checked'])) { - print ''; - } - - // Description - if (!empty($arrayfields['a.note']['checked'])) { - print ''; - } - - $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour'; - - // Start date - if (!empty($arrayfields['a.datep']['checked'])) { - print ''; - } - - // End date - if (!empty($arrayfields['a.datep2']['checked'])) { - print ''; - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - } - - // Contact - if (!empty($arrayfields['a.fk_contact']['checked'])) { - print ''; + } + + // Type + if (!empty($arrayfields['c.libelle']['checked'])) + { + print ''; + } + + // Label + if (!empty($arrayfields['a.label']['checked'])) { + print ''; + } + + // Description + if (!empty($arrayfields['a.note']['checked'])) { + print ''; + } + + $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour'; + // Start date + if (!empty($arrayfields['a.datep']['checked'])) { + print ''; + } + + // End date + if (!empty($arrayfields['a.datep2']['checked'])) { + print ''; + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + else print ' '; + print ''; + } + + // Contact + if (!empty($arrayfields['a.fk_contact']['checked'])) { + print ''; + } + + // Linked object + if (!empty($arrayfields['a.fk_element']['checked'])) { + print ''; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['a.datec']['checked'])) { + // Status/Percent + print ''; + } + // Date update + if (!empty($arrayfields['a.tms']['checked'])) { + print ''; + } + if (!empty($arrayfields['a.percent']['checked'])) { + // Status/Percent + $datep = $db->jdate($obj->datep); + print ''; + } + print ''; + + print "\n"; + $i++; @@ -1160,64 +748,10 @@ - - // Linked object - if (!empty($arrayfields['a.fk_element']['checked'])) { - print ''; - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['a.datec']['checked'])) { - // Status/Percent - print ''; - } - // Date update - if (!empty($arrayfields['a.tms']['checked'])) { - print ''; - } - if (!empty($arrayfields['a.percent']['checked'])) { - // Status/Percent - $datep = $db->jdate($obj->dp); - print ''; - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - - print ''."\n"; - - $i++; -} -// If no record found -if ($num == 0) { - print ''; -} - - -print '
    '; + $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); + print ajax_combobox('selectsearch_status'); + print ''; - print '
    '; - print $form->selectDate($datestart_dtstart, 'datestart_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel'); - print '
    '; - print '
    '; - print $form->selectDate($datestart_dtend, 'datestart_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel'); - print '
    '; - print '
    '; - print '
    '; - print $form->selectDate($dateend_dtstart, 'dateend_dtstart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'), 'tzuserrel'); - print '
    '; - print '
    '; - print $form->selectDate($dateend_dtend, 'dateend_dtend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('To'), 'tzuserrel'); - print '
    '; - print '
    '; - $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'search_status width100 onrightofpage'); - print ''; @@ -816,10 +493,27 @@ -} -print '
    '; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; + + print '
    '; + print $actionstatic->getNomUrl(1, -1); + print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. + if ($obj->fk_user_action > 0) + { + $userstatic->fetch($obj->fk_user_action); + print $userstatic->getNomUrl(-1); @@ -1005,135 +573,24 @@ - print ''; - } - print ''; - print $actionstatic->getNomUrl(1, -1); - print ''; - print ''; - if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { - $userstatic = new User($db); - $res = $userstatic->fetch($obj->fk_user_action); - if ($res > 0) { - $cache_user_list[$obj->fk_user_action] = $userstatic; - } - } - if (isset($cache_user_list[$obj->fk_user_action])) { - print $cache_user_list[$obj->fk_user_action]->getNomUrl(-1); - } else { - print ' '; - } - print ''; - print $actionstatic->getTypePicto(); - $labeltype = $obj->type_code; - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) { - $labeltype = 'AC_OTH'; - } - if (preg_match('/^TICKET_MSG/', $actionstatic->code)) { - $labeltype = $langs->trans("Message"); - } else { - if (!empty($arraylist[$labeltype])) { - $labeltype = $arraylist[$labeltype]; - } - if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) { - $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code - } - } - print dol_trunc($labeltype, 28); - print ''; - print $actionstatic->label; - print ''; - $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 1)); - print $form->textwithtooltip(dol_trunc($text, 48), $actionstatic->note_private); - print ''; - if (empty($obj->fulldayevent)) { - print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel'); - } else { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); - } - print ''; - $late = 0; - if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100) { - $late = 1; - } - if ($late) { - print img_warning($langs->trans("Late")).' '; - } - print ''; - if (empty($obj->fulldayevent)) { - print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuserrel'); - } else { - $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); - print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); - } - print ''; - print ''; - if ($obj->socid > 0) { - $societestatic->id = $obj->socid; - $societestatic->client = $obj->client; - $societestatic->name = $obj->societe; - $societestatic->email = $obj->socemail; - - print $societestatic->getNomUrl(1, '', 28); - } else { - print ' '; - } - print ''; - - if (!empty($actionstatic->socpeopleassigned)) { - $contactList = array(); - foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) { - if (!isset($contactListCache[$socpeopleassigned['id']])) { - // if no cache found we fetch it - $contact = new Contact($db); - if ($contact->fetch($socpeopleassigned['id']) > 0) { - $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); - $contactList[] = $contact->getNomUrl(1, '', 0); - } - } else { - // use cache - $contactList[] = $contactListCache[$socpeopleassigned['id']]; + else print ' '; + print ''; + $actioncomm = $actionstatic; + // TODO Code common with code into showactions + $imgpicto = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncomm->type_picto) { + $imgpicto = img_picto('', $actioncomm->type_picto); + } + else { + if ($actioncomm->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) $imgpicto = img_picto('', 'object_other', '', false, 0, 0, '', 'paddingright').' '; @@ -1142,2 +599,58 @@ - if (!empty($contactList)) { - print implode(', ', $contactList); + print $imgpicto; + + $labeltype = $obj->type_code; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; + if ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') { + $labeltype = $langs->trans("Message"); + } elseif (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; + print dol_trunc($labeltype, 28); + print ''; + print $actionstatic->label; + print ''; + $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 0)); + print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note_private); + print ''; + print dol_print_date($db->jdate($obj->dp), $formatToUse); + $late = 0; + if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if ($late) print img_warning($langs->trans("Late")).' '; + print ''; + print dol_print_date($db->jdate($obj->dp2), $formatToUse); + print ''; + if ($obj->socid > 0) + { + $societestatic->id = $obj->socid; + $societestatic->client = $obj->client; + $societestatic->name = $obj->societe; + $societestatic->email = $obj->socemail; + + print $societestatic->getNomUrl(1, '', 28); @@ -1145,14 +658,89 @@ - } elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event - $contactstatic->id = $obj->fk_contact; - $contactstatic->email = $obj->email; - $contactstatic->lastname = $obj->lastname; - $contactstatic->firstname = $obj->firstname; - $contactstatic->phone_pro = $obj->phone_pro; - $contactstatic->phone_mobile = $obj->phone_mobile; - $contactstatic->phone_perso = $obj->phone_perso; - $contactstatic->country_id = $obj->country_id; - print $contactstatic->getNomUrl(1, '', 0); - } else { - print " "; - } - print ''; + + if (!empty($actionstatic->socpeopleassigned)) + { + $contactList = array(); + foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) + { + if (!isset($contactListCache[$socpeopleassigned['id']])) + { + // if no cache found we fetch it + $contact = new Contact($db); + if ($contact->fetch($socpeopleassigned['id']) > 0) + { + $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); + $contactList[] = $contact->getNomUrl(1, '', 0); + } + } + else { + // use cache + $contactList[] = $contactListCache[$socpeopleassigned['id']]; + } + } + if (!empty($contactList)) { + print implode(', ', $contactList); + } + } + elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event + { + $contactstatic->id = $obj->fk_contact; + $contactstatic->email = $obj->email; + $contactstatic->lastname = $obj->lastname; + $contactstatic->firstname = $obj->firstname; + $contactstatic->phone_pro = $obj->phone_pro; + $contactstatic->phone_mobile = $obj->phone_mobile; + $contactstatic->phone_perso = $obj->phone_perso; + $contactstatic->country_id = $obj->country_id; + print $contactstatic->getNomUrl(1, '', 0); + } + else + { + print " "; + } + print ''; + //var_dump($obj->fkelement.' '.$obj->elementtype); + if ($obj->fk_element > 0 && !empty($obj->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); + } else { + print " "; + } + print ''.dol_print_date($db->jdate($obj->datec), 'dayhour').''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'
    '; - //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && !empty($obj->elementtype)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); - } else { - print " "; - } - print ''.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuserrel').''.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuserrel').''.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
    '.$langs->trans("NoRecordFound").'
    '."\n"; -print '
    '."\n"; - -print '
    '."\n"; - -$db->free($resql); + print ""; + print '
  • '; + print ''; + + $db->free($resql); +} +else +{ + dol_print_error($db); +} --- /tmp/dsg/dolibarr/htdocs/comm/action/github_19.0.3_pertype.php +++ /tmp/dsg/dolibarr/htdocs/comm/action/client_pertype.php @@ -26,3 +26,3 @@ - * \file htdocs/comm/action/pertype.php - * \ingroup agenda - * \brief Tab of calendar events per type + * \file htdocs/comm/action/pertype.php + * \ingroup agenda + * \brief Tab of calendar events per type @@ -31 +30,0 @@ -// Load Dolibarr environment @@ -33 +32,4 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; @@ -36,2 +38 @@ -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -39,15 +40,7 @@ -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; - - -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { - $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; -} - -$action = GETPOST('action', 'aZ09'); - -$disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); - -$filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); + + +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; + +$filter = GETPOST("filter", 'alpha', 3); +$filtert = GETPOST("filtert", "int", 3); +$usergroup = GETPOST("usergroup", "int", 3); @@ -55,3 +48,2 @@ - -// $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; -$showbirthday = 0; // will be hidden here +//$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; +$showbirthday = 0; @@ -60 +52,2 @@ -if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) { +if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) +{ @@ -64,3 +57,2 @@ -// Sorting -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -68,4 +60,2 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -73,7 +63,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "a.datec"; -} - +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "a.datec"; @@ -82,9 +67,5 @@ -$socid = GETPOST("search_socid", "int") ? GETPOST("search_socid", "int") : GETPOST("socid", "int"); -if ($user->socid) { - $socid = $user->socid; -} -if ($socid < 0) { - $socid = ''; -} - -// Permissions +$socid = GETPOST("socid", "int"); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'agenda', 0, '', 'myactions'); +if ($socid < 0) $socid = ''; + @@ -92,22 +73,18 @@ -if (!$user->hasRight('agenda', 'myactions', 'read')) { - accessforbidden(); -} -if (!$user->hasRight('agenda', 'allactions', 'read')) { - $canedit = 0; -} -if (!$user->hasRight('agenda', 'allactions', 'read') || $filter == 'mine') { // If no permission to see all, we show only affected to me - $filtert = $user->id; -} - -$mode = 'show_pertype'; -$resourceid = GETPOST("search_resourceid", "int") ? GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); -$year = GETPOST("year", "int") ? GETPOST("year", "int") : date("Y"); -$month = GETPOST("month", "int") ? GETPOST("month", "int") : date("m"); -$week = GETPOST("week", "int") ? GETPOST("week", "int") : date("W"); -$day = GETPOST("day", "int") ? GETPOST("day", "int") : date("d"); -$pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); -$type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); -$maxprint = ((GETPOST("maxprint", 'int') != '') ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - +if (!$user->rights->agenda->myactions->read) accessforbidden(); +if (!$user->rights->agenda->allactions->read) $canedit = 0; +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me +{ + $filtert = $user->id; +} + +//$action=GETPOST('action','alpha'); +$action = 'show_pertype'; +$resourceid = GETPOST("resourceid", "int"); +$year = GETPOST("year", "int") ?GETPOST("year", "int") : date("Y"); +$month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); +$week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); +$day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); +$pid = GETPOST("projectid", "int", 3); +$status = GETPOST("status", 'alpha'); +$type = GETPOST("type", 'alpha'); +$maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); @@ -115,8 +92,10 @@ -if (GETPOST('search_actioncode', 'array:aZ09')) { - $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); -} +if (GETPOST('actioncode', 'array')) +{ + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; +} +else +{ + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); +} +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -125,2 +104,3 @@ -if ($dateselect > 0) { - $day = GETPOST('dateselectday', 'int'); +if ($dateselect > 0) +{ + $day = GETPOST('dateselectday', 'int'); @@ -128,6 +108,4 @@ - $year = GETPOST('dateselectyear', 'int'); -} - -// working hours -$tmp = !getDolGlobalString('MAIN_DEFAULT_WORKING_HOURS') ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; -$tmp = str_replace(' ', '', $tmp); // FIX 7533 + $year = GETPOST('dateselectyear', 'int'); +} + +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_HOURS) ? '9-18' : $conf->global->MAIN_DEFAULT_WORKING_HOURS; @@ -135,15 +113,7 @@ -$begin_h = GETPOST('begin_h', 'int') != '' ? GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); -$end_h = GETPOST('end_h', 'int') ? GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); -if ($begin_h < 0 || $begin_h > 23) { - $begin_h = 9; -} -if ($end_h < 1 || $end_h > 24) { - $end_h = 18; -} -if ($end_h <= $begin_h) { - $end_h = $begin_h + 1; -} - -// working days -$tmp = !getDolGlobalString('MAIN_DEFAULT_WORKING_DAYS') ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; -$tmp = str_replace(' ', '', $tmp); // FIX 7533 +$begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); +$end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); +if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; +if ($end_h < 1 || $end_h > 24) $end_h = 18; +if ($end_h <= $begin_h) $end_h = $begin_h + 1; + +$tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; @@ -152,32 +122,17 @@ -$end_d = 53; - -if ($status == '' && !GETPOSTISSET('search_status')) { - $status = ((!getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS') || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -} -if (empty($mode) && !GETPOSTISSET('mode')) { - $mode = (!getDolGlobalString('AGENDA_DEFAULT_VIEW') ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); -} - -// View by month -if (GETPOST('viewcal', 'alpha') && $mode != 'show_day' && $mode != 'show_week' && $mode != 'show_peruser') { - $mode = 'show_month'; - $day = ''; -} -// View by week -if (GETPOST('viewweek', 'alpha') || $mode == 'show_week') { - $mode = 'show_week'; - $week = ($week ? $week : date("W")); - $day = ($day ? $day : date("d")); -} -// View by day -if (GETPOST('viewday', 'alpha') || $mode == 'show_day') { - $mode = 'show_day'; - $day = ($day ? $day : date("d")); -} -// View by year -if (GETPOST('viewyear', 'alpha') || $mode == 'show_year') { - $mode = 'show_year'; -} - -// Initialize object -$object = new ActionComm($db); +$end_d = 53; + +if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); + +if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { + $action = 'show_month'; $day = ''; +} // View by month +if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); +} // View by week +if (GETPOST('viewday', 'alpha') || $action == 'show_day') { + $action = 'show_day'; $day = ($day ? $day : date("d")); +} // View by day +if (GETPOST('viewyear', 'alpha') || $action == 'show_year') { + $action = 'show_year'; +} // View by year @@ -190,7 +144,0 @@ - -$result = restrictedArea($user, 'agenda', 0, '', 'myactions'); -if ($user->socid && $socid) { - $result = restrictedArea($user, 'societe', $socid); -} - -$search_status = $status; @@ -203 +151,7 @@ -// None +if ($action == 'delete_action') +{ + $event = new ActionComm($db); + $event->fetch($actionid); + $result = $event->delete(); +} + @@ -210,24 +163,0 @@ -$parameters = array( - 'socid' => $socid, - 'status' => $status, - 'year' => $year, - 'month' => $month, - 'day' => $day, - 'type' => $type, - 'maxprint' => $maxprint, - 'filter' => $filter, - 'filtert' => $filtert, - 'showbirthday' => $showbirthday, - 'canedit' => $canedit, - 'optioncss' => $optioncss, - 'actioncode' => $actioncode, - 'pid' => $pid, - 'resourceid' => $resourceid, - 'usergroup' => $usergroup, -); - -$reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - @@ -237 +167 @@ -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; @@ -242 +172 @@ -$nowyear = $nowarray['year']; +$nowyear = $nowarray['year']; @@ -244 +174 @@ -$nowday = $nowarray['mday']; +$nowday = $nowarray['mday']; @@ -257 +187 @@ -$day = (int) $day; +$day = (int) $day; @@ -270,6 +200,2 @@ -if ($status == 'done') { - $title = $langs->trans("DoneActions"); -} -if ($status == 'todo') { - $title = $langs->trans("ToDoActions"); -} +if ($status == 'done') $title = $langs->trans("DoneActions"); +if ($status == 'todo') $title = $langs->trans("ToDoActions"); @@ -278,54 +204,12 @@ -if ($actioncode || GETPOSTISSET('search_actioncode')) { - if (is_array($actioncode)) { - foreach ($actioncode as $str_action) { - $param .= "&search_actioncode[]=".urlencode($str_action); - } - } else { - $param .= "&search_actioncode=".urlencode($actioncode); - } -} -if ($resourceid > 0) { - $param .= "&search_resourceid=".urlencode($resourceid); -} -if ($status || GETPOSTISSET('status') || GETPOSTISSET('search_status')) { - $param .= "&search_status=".urlencode($status); -} -if ($filter) { - $param .= "&search_filter=".urlencode($filter); -} -if ($filtert) { - $param .= "&search_filtert=".urlencode($filtert); -} -if ($usergroup > 0) { - $param .= "&search_usergroup=".urlencode($usergroup); -} -if ($socid > 0) { - $param .= "&search_socid=".urlencode($socid); -} -if ($showbirthday) { - $param .= "&search_showbirthday=1"; -} -if ($pid) { - $param .= "&search_projectid=".urlencode($pid); -} -if ($type) { - $param .= "&search_type=".urlencode($type); -} -if ($mode != 'show_pertype') { - $param .= '&mode='.urlencode($mode); -} -if ($begin_h != '') { - $param .= '&begin_h='.urlencode($begin_h); -} -if ($end_h != '') { - $param .= '&end_h='.urlencode($end_h); -} -if ($begin_d != '') { - $param .= '&begin_d='.urlencode($begin_d); -} -if ($end_d != '') { - $param .= '&end_d='.urlencode($end_d); -} -$param .= "&maxprint=".urlencode($maxprint); - -$paramnoactionodate = $param; +if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) $param .= "&actioncode=".$actioncode; +if ($resourceid > 0) $param .= "&resourceid=".$resourceid; +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&status=".$status; +if ($filter) $param .= "&filter=".$filter; +if ($filtert) $param .= "&filtert=".$filtert; +if ($usergroup) $param .= "&usergroup=".$usergroup; +if ($socid) $param .= "&socid=".$socid; +if ($showbirthday) $param .= "&showbirthday=1"; +if ($pid) $param .= "&projectid=".$pid; +if ($type) $param .= "&type=".$type; +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser' || $action != 'show_pertype') $param .= '&action='.$action; +$param .= "&maxprint=".$maxprint; @@ -349,3 +233,2 @@ -// Define firstdaytoshow and lastdaytoshow. Warning: lastdaytoshow is last second to show + 1 -// $firstdaytoshow and lastdaytoshow become a gmt dates to use to search/compare because first_xxx are in tz idea and we used tzuserrel -$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel'); +// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); @@ -354,4 +237,4 @@ -//print dol_print_date($firstdaytoshow, 'dayhour', 'gmt'); -//print dol_print_date($lastdaytoshow,'dayhour', 'gmt'); - -$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); +//print dol_print_date($firstdaytoshow,'dayhour'); +//print dol_print_date($lastdaytoshow,'dayhour'); + +$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); @@ -360,5 +243,2 @@ -$picto = 'calendarweek'; - -// Show navigation bar -$nav = ''; +$nav .= "   (".$langs->trans("Today").")"; +$picto = 'calendarweek'; + +$nav .= '  
    '; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; +$nav .= ''; @@ -373 +267,2 @@ -$nav .= ' '; +$nav .= ' '; +$nav .= '
    '; @@ -376 +271 @@ -$param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); +$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); @@ -379,0 +275,4 @@ + + +$tabactive = 'cardpertype'; + @@ -384 +283,3 @@ -print '
    '."\n"; +dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); +print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); +dol_fiche_end(); @@ -388 +289,2 @@ -if ($conf->use_javascript_ajax) { +if ($conf->use_javascript_ajax) +{ @@ -395,2 +297,4 @@ - if ($mode == "show_week" || $mode == "show_month" || empty($mode)) { - $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + if ($action == "show_week" || $action == "show_month" || empty($action)) + { + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; @@ -398 +302 @@ - $s .= '});'."\n"; + $s .= '});'."\n"; @@ -400 +304,2 @@ - if (!empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) + { @@ -402,2 +307,4 @@ - if (is_array($showextcals) && count($showextcals) > 0) { - foreach ($showextcals as $val) { + if (is_array($showextcals) && count($showextcals) > 0) + { + foreach ($showextcals as $val) + { @@ -420 +327 @@ - $parameters = array(); + $parameters = array(); $object = null; @@ -422 +329,2 @@ - if (empty($reshook)) { + if (empty($reshook)) + { @@ -424,3 +332,5 @@ - } elseif ($reshook > 1) { - $s = $hookmanager->resPrint; - } + } + elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } @@ -430,57 +339,0 @@ -$massactionbutton = ''; - -$viewmode = ''; -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("List"), 'object_calendarlist', 'class="imgforviewmode pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewList").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewCal").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewWeek").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewDay").''; - -$viewmode .= ''; -//$viewmode .= ''; -$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); -//$viewmode .= ''; -$viewmode .= ''.$langs->trans("ViewPerUser").''; - -$viewmode .= ''; - -// Add more views from hooks -$parameters = array(); $object = null; -$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); -if (empty($reshook)) { - $viewmode .= $hookmanager->resPrint; -} elseif ($reshook > 1) { - $viewmode = $hookmanager->resPrint; -} - -$newparam = ''; -$newcardbutton = ''; -if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - $tmpforcreatebutton = dol_getdate(dol_now(), true); - - $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; - - //$param='month='.$monthshown.'&year='.$year; - $hourminsec = '100000'; - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); -} - -print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); @@ -490,15 +343 @@ -//print load_fiche_titre('', $link.'     '.$nav.' '.$newcardbutton, ''); - -// Local calendar -$newtitle = '
    '; -$newtitle .= ' '.$langs->trans("LocalAgenda").'   '; -$newtitle .= '
    '; -//$newtitle=$langs->trans($title); - -$s = $newtitle; - -print $s; - -print '
    '; -print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); -print '
    '; +print load_fiche_titre($s, $link.'     '.$nav, ''); @@ -510,2 +348,0 @@ - -// DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR @@ -513,3 +350 @@ -if ($usergroup > 0) { - $sql .= " DISTINCT"; -} +if ($usergroup > 0) $sql .= " DISTINCT"; @@ -523 +358 @@ -$sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto'; +$sql .= ' ca.code, ca.color'; @@ -525,3 +360 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; @@ -529,3 +362 @@ -if ($resourceid > 0) { - $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; -} +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; @@ -533,6 +364,2 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -} -if ($usergroup > 0) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -} +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; @@ -542,40 +369,26 @@ -if (!empty($actioncode)) { - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND ca.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND ca.type = 'systemauto'"; - } else { - if ($actioncode == 'AC_OTH') { - $sql .= " AND ca.type != 'systemauto'"; - } - if ($actioncode == 'AC_OTH_AUTO') { - $sql .= " AND ca.type = 'systemauto'"; - } - } - } else { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND ca.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND ca.type = 'systemauto'"; - } else { - if (is_array($actioncode)) { - $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")"; - } else { - $sql .= " AND ca.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")"; - } - } - } -} -if ($resourceid > 0) { - $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid); -} -if ($pid) { - $sql .= " AND a.fk_project=".((int) $pid); -} -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; -} -if ($socid > 0) { - $sql .= ' AND a.fk_soc = '.((int) $socid); -} +if (!empty($actioncode)) +{ + if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else + { + if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; + } + } + else + { + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; + else + { + $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; + } + } +} +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; @@ -583,47 +396,34 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -} -if ($mode == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; - $sql .= ')'; -} else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= ')'; -} -if ($type) { - $sql .= " AND ca.id = ".((int) $type); -} -if ($status == '0') { - $sql .= " AND a.percent = 0"; -} -if ($status === 'na') { - // Not applicable - $sql .= " AND a.percent = -1"; -} -if ($status == '50') { - // Running already started - $sql .= " AND (a.percent > 0 AND a.percent < 100)"; -} -if ($status == 'done' || $status == '100') { - $sql .= " AND (a.percent = 100)"; -} -if ($status == 'todo') { - $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; -} +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($action == 'show_day') +{ + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; +} +else +{ + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= ')'; +} +if ($type) $sql .= " AND ca.id = ".$type; +if ($status == '0') { $sql .= " AND a.percent = 0"; } +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } @@ -631,9 +431,6 @@ -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) { - $sql .= "ar.fk_element = ".$filtert; - } - if ($usergroup > 0) { - $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".((int) $usergroup); - } - $sql .= ")"; +if ($filtert > 0 || $usergroup > 0) +{ + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; @@ -645 +442 @@ -dol_syslog("comm/action/pertype.php", LOG_DEBUG); +dol_syslog("comm/action/index.php", LOG_DEBUG); @@ -647,63 +444,71 @@ -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - - // Discard auto action if option is on - if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO') && $obj->code == 'AC_OTH_AUTO') { - $i++; - continue; - } - - $datep = $db->jdate($obj->datep); - $datep2 = $db->jdate($obj->datep2); - - // Create a new object action - $event = new ActionComm($db); - $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; - - $event->fk_project = $obj->fk_project; - - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; - - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; - - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) { - $event->date_end_in_calendar = $datep2; - } else { - $event->date_end_in_calendar = $datep; - } - } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) { - $event->date_end_in_calendar = $datep2; - } else { - $event->date_end_in_calendar = $datep; - } - } - - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) { - // This record is out of visible range - unset($event); - } else { +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } + + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); + + // Create a new object action + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; + + $event->fk_project = $obj->fk_project; + + $event->socid = $obj->fk_soc; + $event->contactid = $obj->fk_contact; + + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; + + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + else + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } + + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + unset($event); + } + else + { @@ -713,37 +518,33 @@ - if ($event->date_start_in_calendar < $firstdaytoshow) { - $event->date_start_in_calendar = $firstdaytoshow; - } - if ($event->date_end_in_calendar >= $lastdaytoshow) { - $event->date_end_in_calendar = ($lastdaytoshow - 1); - } - - // Add an entry in actionarray for each day - $daycursor = $event->date_start_in_calendar; - $annee = dol_print_date($daycursor, '%Y', 'tzuserrel'); - $mois = dol_print_date($daycursor, '%m', 'tzuserrel'); - $jour = dol_print_date($daycursor, '%d', 'tzuserrel'); - - // Loop on each day covered by action to prepare an index to show on calendar - $loop = true; - $j = 0; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; - - $eventarray[$daykey][] = $event; - $j++; - - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) { - $loop = false; - } - } while ($loop); - - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; - } - $i++; - } - $db->free($resql); -} else { - dol_print_error($db); + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; + if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + + // Add an entry in actionarray for each day + $daycursor = $event->date_start_in_calendar; + $annee = date('Y', $daycursor); + $mois = date('m', $daycursor); + $jour = date('d', $daycursor); + + // Loop on each day covered by action to prepare an index to show on calendar + $loop = true; $j = 0; + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do + { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
    '; + + $eventarray[$daykey][] = $event; + $j++; + + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } + while ($loop); + + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
    '; + } + $i++; + } +} +else +{ + dol_print_error($db); @@ -755 +555,0 @@ -$cacheusers = array(); @@ -759,6 +559,5 @@ -if (is_readable($color_file)) { - include $color_file; -} -if (!is_array($theme_datacolor)) { - $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); -} +if (is_readable($color_file)) +{ + include_once $color_file; +} +if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); @@ -769,2 +568,2 @@ -$newparam = preg_replace('/mode=show_month&?/i', '', $newparam); -$newparam = preg_replace('/mode=show_week&?/i', '', $newparam); +$newparam = preg_replace('/action=show_month&?/i', '', $newparam); +$newparam = preg_replace('/action=show_week&?/i', '', $newparam); @@ -778 +577 @@ -print ''; +echo ''; @@ -781,0 +581 @@ +echo '
    '; @@ -788,3 +588,2 @@ -echo '
    '; - -echo ''; + +echo '
    '; @@ -805 +604,2 @@ -for ($h = $begin_d; $h < $end_d; $h++) { +for ($h = $begin_d; $h < $end_d; $h++) +{ @@ -821,2 +621,2 @@ -while ($obj = $db->fetch_object($resql)) { - $typeofevents[$obj->code] = $obj->code; +while ($obj = $db->fetch_object($resql)) +{ @@ -832 +632,2 @@ -foreach ($typeofevents as $typeofevent) { +foreach ($typeofevents as $typeofevent) +{ @@ -835 +636 @@ - echo ''; + echo ''; @@ -840,2 +641,4 @@ - for ($iter_day = 0; $iter_day < 8; $iter_day++) { - if (($i + 1) < $begin_d || ($i + 1) > $end_d) { + for ($iter_day = 0; $iter_day < 8; $iter_day++) + { + if (($i + 1) < $begin_d || ($i + 1) > $end_d) + { @@ -846 +649 @@ - // Show days of the current week + // Show days of the current week @@ -848,5 +651,4 @@ - // $curtime is a gmt time, but we want the day, month, year in user TZ - $tmpday = dol_print_date($curtime, "%d", "tzuserrel"); - $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel"); - $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel"); - //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear); + $tmparray = dol_getdate($curtime, 'fast'); + $tmpday = $tmparray['mday']; + $tmpmonth = $tmparray['mon']; + $tmpyear = $tmparray['year']; @@ -855,3 +657 @@ - if ($iter_day == 6) { - $style .= ' cal_other_month'; - } + if ($iter_day == 6) $style .= ' cal_other_month'; @@ -859,8 +659,4 @@ - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) { - $today = 1; - } - if ($today) { - $style = 'cal_today_peruser'; - } - - show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; + if ($today) $style = 'cal_today_peruser'; + + show_day_events_pertype($username, $tmpday, $tmpmonth, $tmpyear, $monthshown, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); @@ -875,5 +671,4 @@ -echo "
    "; - -echo ''; - -if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { + + +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) +{ @@ -882,2 +677,4 @@ - foreach ($colorsbytype as $code => $color) { - if ($color) { + foreach ($colorsbytype as $code => $color) + { + if ($color) + { @@ -901,3 +697,0 @@ -print "\n".''; -print "\n"; - @@ -905 +699 @@ -print '
    '.$typeofevent.''.$username->getNomUrl(1).'