mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW: Add widget "The next upcoming events"
This commit is contained in:
parent
57a9ef35ae
commit
e0ef2870a4
|
|
@ -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:
|
||||
------------------------------
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"',
|
||||
|
|
|
|||
285
htdocs/core/boxes/box_actions_future.php
Normal file
285
htdocs/core/boxes/box_actions_future.php
Normal file
|
|
@ -0,0 +1,285 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2014 Charles-Fr BENKE <charles.fr@benke.fr>
|
||||
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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 .= '<div id="dialogboxaction" title="'.$nblines." ".$langs->trans("ActionsToDo").'">';
|
||||
$out .= '<table width=100%>';
|
||||
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 .= '<tr class="oddeven">';
|
||||
$out .= '<td class="center">';
|
||||
$out .= img_object("", $logo);
|
||||
$out .= '</td>';
|
||||
$out .= '<td class="center"><a href="'.$urlevent.'">'.$label.'</a></td>';
|
||||
$out .= '<td class="center"><a href="'.$urlsoc.'">'.img_object("", $logosoc)." ".$nomsoc.'</a></td>';
|
||||
$out .= '<td class="center">'.$dateligne.'</td>';
|
||||
$out .= '<td class="center">'.$percentage.'</td>';
|
||||
$out .= '</tr>';
|
||||
}
|
||||
}
|
||||
$out .= '</table>';
|
||||
}
|
||||
$out .= '</div>';
|
||||
if ($actioncejour) {
|
||||
$out .= '<script nonce="'.getNonce().'">';
|
||||
$out .= '$("#dialogboxaction").dialog({ autoOpen: true });';
|
||||
if ($conf->global->SHOW_DIALOG_HOMEPAGE > 1) { // autoclose after this delay
|
||||
$out .= 'setTimeout(function(){';
|
||||
$out .= '$("#dialogboxaction").dialog("close");';
|
||||
$out .= '}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).');';
|
||||
}
|
||||
$out .= '</script>';
|
||||
} else {
|
||||
$out .= '<script nonce="'.getNonce().'">';
|
||||
$out .= '$("#dialogboxaction").dialog({ autoOpen: false });';
|
||||
$out .= '</script>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($nooutput) {
|
||||
return $out;
|
||||
} else {
|
||||
print $out;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
//------------
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user