-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from frederic34/devh
fix duration units
- Loading branch information
Showing
5 changed files
with
49 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.php] | ||
indent_style = tab | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
[*.js] | ||
indent_style = tab | ||
[*.css] | ||
indent_style = tab | ||
[*.xml] | ||
indent_style = tab | ||
[*.md] | ||
trim_trailing_whitespace = false | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.php] | ||
indent_style = tab | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
[*.js] | ||
indent_style = tab | ||
[*.css] | ||
indent_style = tab | ||
[*.xml] | ||
indent_style = tab | ||
insert_final_newline = false | ||
[*.md] | ||
trim_trailing_whitespace = false | ||
[*.sql] | ||
indent_style = tab | ||
trim_trailing_whitespace = true | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
/* Copyright (C) 2023 Frédéric France <[email protected]> | ||
/* Copyright (C) 2023-2024 Frédéric France <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -70,7 +70,6 @@ public function __construct($db) | |
$this->db = $db; | ||
} | ||
|
||
|
||
/** | ||
* Overloading the getTooltipContent function : replacing the parent's function with the one below | ||
* | ||
|
@@ -84,7 +83,6 @@ public function getTooltipContent($parameters, &$object, &$action, $hookmanager) | |
{ | ||
global $conf, $user, $langs; | ||
|
||
// var_dump($parameters); | ||
$langs->load('easytooltip@easytooltip'); | ||
$contexts = explode(':', $parameters['context']); | ||
$found = false; | ||
|
@@ -103,13 +101,21 @@ public function getTooltipContent($parameters, &$object, &$action, $hookmanager) | |
// ADDING DURATION IF NOT PRESENT | ||
if ($object->type == Product::TYPE_SERVICE && empty($parameters['tooltipcontentarray']['duration']) && !empty($object->duration_value)) { | ||
// Duration | ||
$tooltip = '<br><b>' . $langs->trans("Duration") . ':</b> ' . $object->duration_value; | ||
require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; | ||
$measuringUnits = new CUnits($this->db); | ||
$durations = []; | ||
$plural = ''; | ||
if ($object->duration_value > 1) { | ||
$dur = ["i" => $langs->trans("Minutes"), "h" => $langs->trans("Hours"), "d" => $langs->trans("Days"), "w" => $langs->trans("Weeks"), "m" => $langs->trans("Months"), "y" => $langs->trans("Years")]; | ||
} elseif ($object->duration_value > 0) { | ||
$dur = ["i" => $langs->trans("Minute"), "h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year")]; | ||
$plural = 's'; | ||
} | ||
$result = $measuringUnits->fetchAll('', 'scale', 0, 0, ['t.active' => 1, 't.unit_type' => 'time']); | ||
if ($result !== -1) { | ||
foreach ($measuringUnits->records as $record) { | ||
$durations[$record->short_label] = dol_ucfirst($record->label) . $plural; | ||
} | ||
} | ||
$tooltip .= (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? " " . $langs->trans($dur[$object->duration_unit]) : ''); | ||
$tooltip = '<br><b>' . $langs->trans("Duration") . ':</b> ' . $object->duration_value; | ||
$tooltip .= (!empty($object->duration_unit) && isset($durations[$object->duration_unit]) ? " " . $langs->trans($durations[$object->duration_unit]) : ''); | ||
self::arraySpliceAssoc($parameters['tooltipcontentarray'], 4, 0, ['duration' => $tooltip]); | ||
} | ||
// ADDING LAST CUSTOMER ORDER | ||
|
@@ -264,6 +270,9 @@ public function getTooltipContent($parameters, &$object, &$action, $hookmanager) | |
} elseif (in_array('ticketdao', $contexts)) { | ||
/** @var Ticket $object */ | ||
$found = true; | ||
} elseif (in_array('opensurvey_sondagedao', $contexts)) { | ||
/** @var Opensurveysondage $object */ | ||
$found = true; | ||
} elseif (in_array('projectdao', $contexts)) { | ||
/** @var Project $object */ | ||
$found = true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,4 @@ PROJECT=Projet | |
PROPAL=Devis | ||
SOCIETE=Tiers | ||
TICKET=Ticket | ||
OPENSURVEY_SONDAGE=Sondage |