Fix box of events

This commit is contained in:
Laurent Destailleur 2020-10-30 18:58:40 +01:00
parent 23d0d4635a
commit aafac6f989
2 changed files with 24 additions and 17 deletions

View File

@ -42,7 +42,7 @@ class box_actions extends ModeleBoxes
*/ */
public $db; public $db;
public $param; public $enabled = 1;
public $info_box_head = array(); public $info_box_head = array();
public $info_box_contents = array(); public $info_box_contents = array();
@ -54,12 +54,14 @@ class box_actions extends ModeleBoxes
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param string $param More parameters * @param string $param More parameters
*/ */
public function __construct($db, $param = '') public function __construct($db, $param)
{ {
global $user; global $conf, $user;
$this->db = $db; $this->db = $db;
$this->enabled = $conf->agenda->enabled;
$this->hidden = !($user->rights->agenda->myactions->read); $this->hidden = !($user->rights->agenda->myactions->read);
} }
@ -93,7 +95,7 @@ class box_actions extends ModeleBoxes
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; if (!$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 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql .= " WHERE a.fk_action = ta.id"; $sql .= " WHERE a.fk_action = ta.id";
$sql .= " AND a.entity = ".$conf->entity; $sql .= " AND a.entity IN (".getEntity('actioncomm').")";
$sql .= " AND a.percent >= 0 AND a.percent < 100"; $sql .= " AND a.percent >= 0 AND a.percent < 100";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
@ -101,13 +103,14 @@ class box_actions extends ModeleBoxes
$sql .= " ORDER BY a.datec DESC"; $sql .= " ORDER BY a.datec DESC";
$sql .= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);
dol_syslog("Box_actions::loadBox", LOG_DEBUG); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$now = dol_now(); $now = dol_now();
$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$line = 0; $line = 0;
while ($line < $num) { while ($line < $num) {
$late = ''; $late = '';
@ -127,32 +130,35 @@ class box_actions extends ModeleBoxes
//($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label) //($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][] = array( $this->info_box_contents[$line][0] = array(
'td' => '', 'td' => '',
'text' => $actionstatic->getNomUrl(1), 'text' => $actionstatic->getNomUrl(1),
'text2'=> $late, 'text2'=> $late,
'asis' => 1, 'asis' => 1
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][1] = array(
'td' => '', 'td' => '',
'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''), 'text' => ($societestatic->id > 0 ? $societestatic->getNomUrl(1) : ''),
'asis' => 1, 'asis' => 1
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][2] = array(
'td' => 'class="nowrap left"', 'td' => 'class="nowrap left"',
'text' => dol_print_date($datelimite, "dayhour"), 'text' => dol_print_date($datelimite, "dayhour"),
'asis' => 1
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][3] = array(
'td' => 'class="right"', 'td' => 'class="right"',
'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''), 'text' => ($objp->percentage >= 0 ? $objp->percentage.'%' : ''),
'asis' => 1
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][4] = array(
'td' => 'class="right" width="18"', 'td' => 'class="right" width="18"',
'text' => $actionstatic->LibStatut($objp->percentage, 3), 'text' => $actionstatic->LibStatut($objp->percentage, 3),
'asis' => 1
); );
$line++; $line++;
@ -160,8 +166,8 @@ class box_actions extends ModeleBoxes
if ($num == 0) if ($num == 0)
$this->info_box_contents[$line][0] = array( $this->info_box_contents[$line][0] = array(
'td' => 'class="center"', 'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoActionsToDo"), 'text'=>$langs->trans("NoActionsToDo")
); );
$this->db->free($result); $this->db->free($result);
@ -169,7 +175,7 @@ class box_actions extends ModeleBoxes
$this->info_box_contents[0][0] = array( $this->info_box_contents[0][0] = array(
'td' => '', 'td' => '',
'maxlength'=>500, 'maxlength'=>500,
'text' => ($this->db->error().' sql='.$sql), 'text' => ($this->db->error().' sql='.$sql)
); );
} }
} else { } else {
@ -191,7 +197,7 @@ class box_actions extends ModeleBoxes
public function showBox($head = null, $contents = null, $nooutput = 0) public function showBox($head = null, $contents = null, $nooutput = 0)
{ {
global $langs, $conf; global $langs, $conf;
$out = parent::showBox($this->info_box_head, $this->info_box_contents); $out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE))
{ {

View File

@ -458,6 +458,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
{ {
// Define disabledbyname and disabledbymodule // Define disabledbyname and disabledbymodule
$disabledbyname = 0; $disabledbyname = 0;
$disabledbymodule = 0; // TODO Set to 2 if module is not enabled
$module = ''; $module = '';
// Check if widget file is disabled by name // Check if widget file is disabled by name
@ -476,7 +477,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
$text = '<b>'.$langs->trans("Description").':</b><br>'; $text = '<b>'.$langs->trans("Description").':</b><br>';
$text .= $objMod->boxlabel.'<br>'; $text .= $objMod->boxlabel.'<br>';
$text .= '<br><b>'.$langs->trans("Status").':</b><br>'; $text .= '<br><b>'.$langs->trans("Status").':</b><br>';
if ($disabledbymodule == 2) $text .= $langs->trans("HooksDisabledAsModuleDisabled", $module).'<br>'; if ($disabledbymodule == 2) $text .= $langs->trans("WidgetDisabledAsModuleDisabled", $module).'<br>';
$widget[$j]['info'] = $text; $widget[$j]['info'] = $text;
} }