Skip to content

Commit

Permalink
Merge pull request #932 from Evarisk/develop
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
nicolas-eoxia authored May 17, 2024
2 parents db0b082 + 75a124b commit 85a3d72
Show file tree
Hide file tree
Showing 20 changed files with 431 additions and 256 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
## Informations

- Numéro du module : 436318
- Dernière mise à jour : 02/04/2024
- Dernière mise à jour : 17/05/2024
- Éditeur : [Evarisk](https://evarisk.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

### Version

- Version : 1.3.0
- Version : 1.4.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 16.0.0 - 19.0.1
- Compatibilité : Dolibarr 16.0.0 - 19.0.2

## Liens

Expand Down
36 changes: 31 additions & 5 deletions class/saturnedashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ public function show_dashboard(?array $moreParams = [])
if (is_array($dashboardGraph['labels']) && !empty($dashboardGraph['labels'])) {
foreach ($dashboardGraph['labels'] as $dashboardGraphLabel) {
$dashboardGraphLegend[$uniqueKey][] = $dashboardGraphLabel['label'];
$dashboardGraphColor[$uniqueKey][] = $dashboardGraphLabel['color'];
if (dol_strlen($dashboardGraphLabel['color']) > 0) {
$dashboardGraphColor[$uniqueKey][] = $dashboardGraphLabel['color'];
}
}
}

Expand All @@ -236,13 +238,25 @@ public function show_dashboard(?array $moreParams = [])
if ($dashboardGraph['dataset'] >= 2) {
$graph->SetLegend($dashboardGraphLegend[$uniqueKey]);
}
$graph->SetDataColor($dashboardGraphColor[$uniqueKey]);
if (isset($dashboardGraphColor[$uniqueKey])) {
$graph->SetDataColor($dashboardGraphColor[$uniqueKey]);
}
$graph->SetType([$dashboardGraph['type'] ?? 'pie']);
$graph->SetWidth($dashboardGraph['width'] ?? $width);
$graph->SetHeight($dashboardGraph['height'] ?? $height);
$graph->setShowLegend($dashboardGraph['showlegend'] ?? 2);
$graph->draw($fileName[$uniqueKey], $fileUrl[$uniqueKey]);
print '<div>';
print '<div class="' . $dashboardGraph['moreCSS'] . '">';

$downloadCSV = '<form method="POST" action="' . $_SERVER['PHP_SELF'] . (GETPOSTISSET('id') ? '?id=' . GETPOST('id') : '') . '">';
$downloadCSV .= '<input type="hidden" name="token" value="' . newToken() . '">';
$downloadCSV .= '<input type="hidden" name="action" value="generate_csv">';
$downloadCSV .= '<input type="hidden" name="graph" value="' . http_build_query($dashboardGraph) . '">';
$downloadCSV .= '<button class="wpeo-button no-load button-grey">';
$downloadCSV .= img_picto('ExportCSV', 'fontawesome_file-csv_fas_#31AD29_15px');
$downloadCSV .= '</button></form>';
$dashboardGraph['morehtmlright'] .= $downloadCSV;

print load_fiche_titre($dashboardGraph['title'], $dashboardGraph['morehtmlright'], $dashboardGraph['picto']);
print $graph->show();
print '</div>';
Expand All @@ -264,13 +278,13 @@ public function show_dashboard(?array $moreParams = [])
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
foreach ($dashboardList['labels'] as $key => $dashboardListLabel) {
print '<td class="nowraponall tdoverflowmax200' . (($key != 'Ref') ? ' center' : '') . '">' . $langs->transnoentities($dashboardListLabel) . '</td>';
print '<td class="nowraponall tdoverflowmax200 ' . (($key != 'Ref') ? 'center' : '') . '">' . $langs->transnoentities($dashboardListLabel) . '</td>';
}
print '</tr>';
foreach ($dashboardList['data'] as $dashboardListDatasets) {
print '<tr class="oddeven">';
foreach ($dashboardListDatasets as $key => $dashboardGraphDataset) {
print '<td class="nowraponall tdoverflowmax200' . (($key != 'Ref') ? ' center ' : '') . $dashboardGraphDataset['morecss'] . '">' . $dashboardGraphDataset['value'] . '</td>';
print '<td class="nowraponall tdoverflowmax200 ' . (($key != 'Ref') ? 'center ' : '') . $dashboardGraphDataset['morecss'] . '"' . $dashboardGraphDataset['moreAttr'] . '>' . $dashboardGraphDataset['value'] . '</td>';
}
print '</tr>';
}
Expand All @@ -282,4 +296,16 @@ public function show_dashboard(?array $moreParams = [])

print '</form>';
}

/**
* get color range for key
*
* @param int $key Key to find in color array
* @return string
*/
public static function getColorRange(int $key): string
{
$colorArray = ['#f44336', '#e81e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722', '#795548', '#9e9e9e', '#607d8b'];
return $colorArray[$key % count($colorArray)];
}
}
8 changes: 5 additions & 3 deletions class/saturnedocuments.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class SaturneDocuments extends SaturneObject
/**
* @var string Module name.
*/
public string $module_name;
public string $module_name = '';

/**
* @var string|null Json.
Expand All @@ -156,7 +156,7 @@ class SaturneDocuments extends SaturneObject
/**
* @var string Object parent type.
*/
public string $parent_type;
public string $parent_type = '';

/**
* @var int Object parent ID.
Expand Down Expand Up @@ -196,7 +196,9 @@ public function create(User $user, bool $notrigger = false, object $parentObject
$this->date_creation = $this->db->idate($now);
$this->tms = $now;
$this->status = 1;
$this->type = $this->element;
if (empty($this->type)) {
$this->type = $this->element;
}
$this->module_name = $this->module;
$this->parent_id = $parentObject->id;
$this->parent_type = $parentObject->element_type ?: $parentObject->element;
Expand Down
Loading

0 comments on commit 85a3d72

Please sign in to comment.