diff --git a/ChangeLog b/ChangeLog index 02224d73acd..dcb15de394e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -172,6 +172,7 @@ NEW: VAT can be modified during add of line NEW: write all fields and their properties in asciidoc format NEW: Can add an array of several links in date selector NEW: Implement MAIN_ACTIVATE_FILECACHE on bithday widget +NEW: Add widget "The next upcoming events" For developers or integrators: ------------------------------ diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 55259ecfff3..bc584f8a479 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -138,12 +138,6 @@ $modules = array( $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly")); -if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) { - $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php -} -if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) { - $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php -} if (!isset($conf->global->MAIN_DELAY_MEMBERS)) { $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php } diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 7b149ba4085..31852cfe9ff 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -56,7 +56,7 @@ class box_actions extends ModeleBoxes */ public function __construct($db, $param) { - global $conf, $user; + global $user; $this->db = $db; @@ -145,7 +145,7 @@ class box_actions extends ModeleBoxes } //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) - $label = empty($objp->label) ? $objp->type_label : $objp->label; + //$label = empty($objp->label) ? $objp->type_label : $objp->label; $this->info_box_contents[$line][0] = array( 'td' => 'class="tdoverflowmax200"', diff --git a/htdocs/core/boxes/box_actions_future.php b/htdocs/core/boxes/box_actions_future.php new file mode 100644 index 00000000000..bded39e4774 --- /dev/null +++ b/htdocs/core/boxes/box_actions_future.php @@ -0,0 +1,285 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2014 Charles-Fr BENKE + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_actions.php + * \ingroup actions + * \brief Module to build boxe for events + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + +/** + * Class to manage the box to show events in future + */ +class box_actions_future extends ModeleBoxes +{ + public $boxcode = "futureactions"; + public $boximg = "object_action"; + public $boxlabel = "BoxTitleFutureActions"; + public $depends = array("agenda"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->enabled = isModEnabled('agenda'); + + $this->hidden = !($user->hasRight('agenda', 'myactions', 'read')); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + + $this->max = $max; + + $now = dol_now(); + + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $societestatic = new Societe($this->db); + $actionstatic = new ActionComm($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleFutureActions", $max)); + + if ($user->rights->agenda->myactions->read) { + $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage"; + $sql .= ", ta.code"; + $sql .= ", ta.libelle as type_label"; + $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; + $sql .= ", s.code_client, s.code_compta, s.client"; + $sql .= ", s.logo, s.email, s.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; + if (empty($user->rights->societe->client->voir) && !$user->socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + } + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql .= " WHERE a.fk_action = ta.id"; + $sql .= " AND a.entity IN (".getEntity('actioncomm').")"; + //$sql .= " AND a.percent >= 0 AND a.percent < 100"; + if (empty($user->rights->societe->client->voir) && !$user->socid) { + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".((int) $user->id).")"; + } + if ($user->socid) { + $sql .= " AND s.rowid = ".((int) $user->socid); + } + if (empty($user->rights->agenda->allactions->read)) { + $sql .= " AND (a.fk_user_author = ".((int) $user->id)." OR a.fk_user_action = ".((int) $user->id)." OR a.fk_user_done = ".((int) $user->id).")"; + } + $sql .= " AND a.datep > '".$this->db->idate($now)."'"; + $sql .= " ORDER BY a.datep ASC"; + $sql .= $this->db->plimit($max, 0); + + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $now = dol_now(); + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + + $num = $this->db->num_rows($result); + + $line = 0; + while ($line < $num) { + $late = ''; + $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->dp); + + $actionstatic->id = $objp->id; + $actionstatic->label = $objp->label; + $actionstatic->type_label = $objp->type_label; + $actionstatic->code = $objp->code; + + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + //$societestatic->name_alias = $objp->name_alias; + $societestatic->code_client = $objp->code_client; + $societestatic->code_compta = $objp->code_compta; + $societestatic->client = $objp->client; + $societestatic->logo = $objp->logo; + $societestatic->email = $objp->email; + $societestatic->entity = $objp->entity; + + if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) { + $late = img_warning($langs->trans("Late")); + } + + //($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) + //$label = empty($objp->label) ? $objp->type_label : $objp->label; + + $this->info_box_contents[$line][0] = array( + 'td' => 'class="tdoverflowmax200"', + 'text' => $actionstatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1 + ); + + $this->info_box_contents[$line][1] = array( + 'td' => 'class="tdoverflowmax100"', + 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), + 'asis' => 1 + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="center nowraponall"', + 'text' => $datelimite ? dol_print_date($datelimite, "dayhour", 'tzuserrel') : '', + 'asis' => 1 + ); + + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''), + 'asis' => 1 + ); + + $this->info_box_contents[$line][4] = array( + 'td' => 'class="right" width="18"', + 'text' => $actionstatic->LibStatut($objp->percentage, 3), + 'asis' => 1 + ); + + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoActionsToDo") + ); + } + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + global $langs, $conf; + $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1); + + if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) { + $actioncejour = false; + $contents = $this->info_box_contents; + if (is_countable($contents) && count($contents) > 0) { + $nblines = count($contents); + } + if ($contents[0][0]['text'] != $langs->trans("NoActionsToDo")) { + $out .= '
trans("ActionsToDo").'">'; + $out .= ''; + for ($line = 0, $n = $nblines; $line < $n; $line++) { + if (isset($contents[$line])) { + // on affiche que les évènement du jours ou passé + // qui ne sont pas à 100% + $actioncejour = true; + + // TR + $logo = $contents[$line][0]['logo']; + $label = $contents[$line][1]['text']; + $urlevent = $contents[$line][1]['url']; + $logosoc = $contents[$line][2]['logo']; + $nomsoc = $contents[$line][3]['text']; + $urlsoc = $contents[$line][3]['url']; + $dateligne = $contents[$line][4]['text']; + $percentage = $contents[$line][5]['text']; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + } + } + $out .= '
'; + $out .= img_object("", $logo); + $out .= ''.$label.''.img_object("", $logosoc)." ".$nomsoc.''.$dateligne.''.$percentage.'
'; + } + $out .= '
'; + if ($actioncejour) { + $out .= ''; + } else { + $out .= ''; + } + } + + if ($nooutput) { + return $out; + } else { + print $out; + } + + return ''; + } +} diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0d3273dff2c..635f19ca831 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -864,9 +864,9 @@ class Conf $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? (int) $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400; } if (isset($this->projet)) { - $this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? (int) $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400; + $this->projet->warning_delay = (getDolGlobalInt('MAIN_DELAY_PROJECT_TO_CLOSE', 7) * 86400); $this->projet->task = new StdClass(); - $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? (int) $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400; + $this->projet->task->warning_delay = (getDolGlobalInt('MAIN_DELAY_TASKS_TODO', 7) * 86400); } if (isset($this->commande)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f93e63abcb5..52cb381791f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -103,7 +103,7 @@ function getDolGlobalString($key, $default = '') { global $conf; // return $conf->global->$key ?? $default; - return (string) (empty($conf->global->$key) ? $default : $conf->global->$key); + return (string) (isset($conf->global->$key) ? $conf->global->$key : $default); } /** @@ -117,7 +117,7 @@ function getDolGlobalInt($key, $default = 0) { global $conf; // return $conf->global->$key ?? $default; - return (int) (empty($conf->global->$key) ? $default : $conf->global->$key); + return (int) (isset($conf->global->$key) ? $conf->global->$key : $default); } /** diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 20a2016939f..aa2029bc38a 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -107,7 +107,10 @@ class modAgenda extends DolibarrModules // Boxes //------ - $this->boxes = array(0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home')); + $this->boxes = array( + 0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home'), + 1=>array('file'=>'box_actions_future.php', 'enabledbydefaulton'=>'Home') + ); // Cronjobs //------------ diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index be6c641f852..8f931499077 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -125,19 +125,6 @@ class modProjet extends DolibarrModules $this->const[$r][4] = 0; $r++; - $this->const[$r][0] = "MAIN_DELAY_PROJECT_TO_CLOSE"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "7"; - $this->const[$r][3] = ""; - $this->const[$r][4] = 0; - $r++; - $this->const[$r][0] = "MAIN_DELAY_TASKS_TODO"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "7"; - $this->const[$r][3] = ""; - $this->const[$r][4] = 0; - $r++; - // Boxes $this->boxes = array( 0=>array('file'=>'box_project.php', 'enabledbydefaulton'=>'Home'), diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 03840b9fab8..762ce5ee189 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -49,6 +49,7 @@ BoxOldestActions=Oldest events to do BoxLastExpiredServices=Latest %s oldest contacts with active expired services BoxTitleLastActionsToDo=Latest %s actions to do BoxTitleOldestActionsToDo=Oldest %s events to do, not completed +BoxTitleFutureActions=The next %s upcoming events BoxTitleLastContracts=Latest %s contracts which were modified BoxTitleLastModifiedDonations=Latest %s donations which were modified BoxTitleLastModifiedExpenses=Latest %s expense reports which were modified @@ -112,6 +113,7 @@ NumberOfLinesInSuspenseAccount=Number of line in suspense account SuspenseAccountNotDefined=Suspense account isn't defined BoxLastCustomerShipments=Last customer shipments BoxTitleLastCustomerShipments=Latest %s customer shipments +BoxTitleLastLeaveRequests=Latest %s modified leave requests NoRecordedShipments=No recorded customer shipment BoxCustomersOutstandingBillReached=Customers with oustanding limit reached # Pages diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 0ec98d01a12..f8c61f327e2 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -100,7 +100,6 @@ SendRequestCollectiveCP=Send collective leave request AutoValidationOnCreate=Automatic validation FirstDayOfHoliday=Beginning day of leave request LastDayOfHoliday=Ending day of leave request -BoxTitleLastLeaveRequests=Latest %s modified leave requests HolidaysMonthlyUpdate=Monthly update ManualUpdate=Manual update HolidaysCancelation=Leave request cancelation