Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d0905de
added field-type for maintenance scheuduling to field-editor
RealDekkia Aug 3, 2025
d7a1300
implemented maintenance scheuduling in item-editor
RealDekkia Aug 3, 2025
d5ce5f2
removed debug log
RealDekkia Aug 3, 2025
9e28e19
displaying maintenance schedule in list
RealDekkia Aug 3, 2025
57afd76
relocated the code that cleans up the MAINTENANCE_SCHEDULE dropdown t…
RealDekkia Aug 4, 2025
e3f52aa
added display for remaining days until next maintenance
RealDekkia Aug 5, 2025
d1c0a14
fixed bug with displaying maintenance entries in print preview
RealDekkia Aug 5, 2025
a625fba
fixed bug with maintenance days in exports
RealDekkia Aug 5, 2025
cf6f10b
added translation
RealDekkia Aug 5, 2025
b057708
updated other language files
RealDekkia Aug 5, 2025
2844a60
added tooltip for MAINTENANCE_SCHEDULE in fields_edit_new
RealDekkia Aug 5, 2025
a56a5d2
error-handling is pretty good already
RealDekkia Aug 5, 2025
a733a3c
remove "day(s)"-string at the end of schedule days remaining to impro…
RealDekkia Aug 5, 2025
5516e14
chore: sort en.xml alphabetically
Aug 5, 2025
4c252b2
fixed bug that stopped maintenance schedule field from being deleted
RealDekkia Aug 6, 2025
6237050
Merge branch 'master' of github.com:RealDekkia/InventoryManager
RealDekkia Aug 6, 2025
208528d
reduce duplicated code by putting some of it into a function
RealDekkia Aug 6, 2025
ef0c982
fixed code formatting
RealDekkia Aug 6, 2025
4da7ee7
renamed MAINTENANCE_SCHEDULE into DATE_INTERVAL
RealDekkia Aug 6, 2025
39764ba
chore: sort en.xml alphabetically
Aug 6, 2025
0604f32
feat: implement imf_date_interval_field to avoid #-reference in value…
MightyMCoder Aug 8, 2025
795e9fe
feat: enhance DATE_INTERVAL handling in inventory manager
MightyMCoder Aug 8, 2025
06d2f58
fix: translations
MightyMCoder Aug 8, 2025
a90236f
chore: sort en.xml alphabetically
Aug 8, 2025
f2c7171
chore: sort language files alphabetically
MightyMCoder Aug 8, 2025
52d1fb5
feat: implement hide/show JS for imf_date_interval_field selection
MightyMCoder Aug 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion classes/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ public function getProperty($fieldNameIntern, $column, $format = '')

$value = $this->mItemFields[$fieldNameIntern]->getValue($column, $format);

if ($column === 'imf_value_list' && in_array($this->mItemFields[$fieldNameIntern]->getValue('imf_type'), ['DROPDOWN', 'RADIO_BUTTON'])) {
if ($column === 'imf_value_list' && in_array($this->mItemFields[$fieldNameIntern]->getValue('imf_type'), ['DROPDOWN', 'RADIO_BUTTON', 'MAINTENANCE_SCHEDULE'])) {
Comment thread
RealDekkia marked this conversation as resolved.
Outdated
$value = $this->getListValue($fieldNameIntern, $value, $format);

}


return $value;
}

Expand Down Expand Up @@ -188,6 +190,19 @@ protected function getListValue($fieldNameIntern, $value, $format): array
$valueFormatted = str_replace("\r\n", "\n", $value);
$arrListValues = explode("\n", $valueFormatted);

// remove lines starting with # from MAINTENANCE_SCHEDULE
Comment thread
MightyMCoder marked this conversation as resolved.
Outdated
// as they're used to select the name of the last inspection date field
// Also remove the | and anything that follows
if($this->mItemFields[$fieldNameIntern]->getValue('imf_type') == 'MAINTENANCE_SCHEDULE' && $format != 'unfiltered'){
$cleanValue = array();
foreach ($arrListValues as $line) {
if(substr($line,0,1) != '#'){
array_push($cleanValue, explode('|', $line)[0]);
}
}
$arrListValues = $cleanValue;
}

foreach ($arrListValues as $item => &$listValue) {
if ($this->mItemFields[$fieldNameIntern]->getValue('imf_type') === 'RADIO_BUTTON') {
// if value is imagefile or imageurl then show image
Expand Down Expand Up @@ -291,12 +306,24 @@ public function getHtmlValue($fieldNameIntern, $value): string

case 'DROPDOWN':
case 'RADIO_BUTTON':
case 'MAINTENANCE_SCHEDULE':
$arrListValuesWithItems = array(); // array with list values and items that represents the internal value

// first replace windows new line with unix new line and then create an array
$valueFormatted = str_replace("\r\n", "\n", $this->mItemFields[$fieldNameIntern]->getValue('imf_value_list', 'database'));
$arrListValues = explode("\n", $valueFormatted);

//Clean up control-chars from maintenance scheudule
if($imfType == 'MAINTENANCE_SCHEDULE'){
$cleanArrListValues = array();
foreach ($arrListValues as $line) {
if(substr($line,0,1) != '#'){
array_push($cleanArrListValues, explode('|', $line)[0]);
}
}
$arrListValues = $cleanArrListValues;
}

foreach ($arrListValues as $index => $listValue) {
// if value is imagefile or imageurl then show image
if ($imfType === 'RADIO_BUTTON' && (Image::isFontAwesomeIcon($listValue)
Expand Down
11 changes: 9 additions & 2 deletions fields/fields_edit_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,20 @@

$page->addJavascript('
function setValueList() {
if ($("#imf_type").val() === "DROPDOWN" || $("#imf_type").val() === "RADIO_BUTTON") {
if ($("#imf_type").val() === "DROPDOWN" || $("#imf_type").val() === "RADIO_BUTTON" || $("#imf_type").val() === "MAINTENANCE_SCHEDULE") {
$("#imf_value_list_group").show("slow");
$("#imf_value_list").attr("required", "required");
} else {
$("#imf_value_list").removeAttr("required");
$("#imf_value_list_group").hide();
}

var valueListTooltipContainer = document.getElementById("imf_value_list_group").getElementsByTagName("label")[0].getElementsByTagName("i")[0];
if($("#imf_type").val() === "MAINTENANCE_SCHEDULE"){
valueListTooltipContainer.setAttribute("data-content","' . $gL10n->get('PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DESC') . '");
}else{
valueListTooltipContainer.setAttribute("data-content","' . $gL10n->get('ORG_VALUE_LIST_DESC') . '");
}
}

setValueList();
Expand Down Expand Up @@ -108,7 +115,7 @@ function setValueList() {
'RADIO_BUTTON' => $gL10n->get('SYS_RADIO_BUTTON'),
'TEXT' => $gL10n->get('SYS_TEXT') . ' (100 ' . $gL10n->get('SYS_CHARACTERS') . ')',
'TEXT_BIG' => $gL10n->get('SYS_TEXT') . ' (4000 ' . $gL10n->get('SYS_CHARACTERS') . ')',
);
'MAINTENANCE_SCHEDULE' => $gL10n->get('PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE'));
Comment thread
RealDekkia marked this conversation as resolved.
Outdated
asort($itemFieldText);

//bei Systemfeldern darf der Datentyp nicht mehr veraendert werden
Expand Down
78 changes: 77 additions & 1 deletion inventory_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,31 @@
}

$columnNumber++;

//Add additional column to header after each MAINTENANCE_SCHEDULE
if($items->getProperty($imfNameIntern, 'imf_type') === 'MAINTENANCE_SCHEDULE'){
$columnAlign[] = 'left';
$columnHeader2 = convlanguagePIM($items->getProperty($imfNameIntern, 'imf_name')) . ' ' . $gL10n->get('PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DAYS_REMAINING');
Comment thread
RealDekkia marked this conversation as resolved.
Outdated

switch ($getMode) {
case 'csv':
case "ods":
case 'xlsx':
$header[$columnHeader2] = 'string';
break;

case 'pdf':
$arrValidColumns[] = $columnHeader2;
break;

case 'html':
case 'print':
$columnValues[] = $columnHeader2;
break;
}

$columnNumber++;
}
}

if ($getMode == 'html') {
Expand Down Expand Up @@ -568,6 +593,7 @@
}

$content = $items->getValue($imfNameIntern, 'database');
$value = $content; // content gets overwritten in the next part of code but is still needed for MAINTENANCE_SCHEDULE stuff

if ($imfNameIntern == 'KEEPER' && strlen($content) > 0) {
$found = $user->readDataById($content);
Expand Down Expand Up @@ -626,12 +652,62 @@
elseif ($items->getProperty($imfNameIntern, 'imf_type') == 'DATE') {
$content = $items->getHtmlValue($imfNameIntern, $content);
}
elseif (in_array($items->getProperty($imfNameIntern, 'imf_type'), array('DROPDOWN', 'RADIO_BUTTON'))) {
elseif (in_array($items->getProperty($imfNameIntern, 'imf_type'), array('DROPDOWN', 'RADIO_BUTTON', 'MAINTENANCE_SCHEDULE'))) {
$content = $items->getHtmlValue($imfNameIntern, $content);
}

$columnValues[] = ($strikethrough && $getMode != 'csv' && $getMode != 'ods' && $getMode != 'xlsx') ? '<s>' . $content . '</s>' : $content;
$columnNumber++;

//Add additional column to header after each MAINTENANCE_SCHEDULE
if($items->getProperty($imfNameIntern, 'imf_type') === 'MAINTENANCE_SCHEDULE'){
$columnAlign[] = 'left';

//get #-line from dropdown
$unfilteredSelectionItems = $items->getProperty($imfNameIntern, 'imf_value_list', 'unfiltered');
$date_field_internal_name = null;
$filteredSelectionItems = array();

foreach ($unfilteredSelectionItems as $line) {
if(substr($line,0,1) === '#'){
$date_field_internal_name = substr($line,1);
}else{
array_push($filteredSelectionItems, explode('|', $line)[1]);
}
}
//use part after # as internal_name for last test date
$compDate1 = date_create($items->getValue($date_field_internal_name, 'database'));
$compDate2 = date_create();

//Calculate future test date
$dateAdditionSplit = array();
preg_match("/^\s*(\d*)([wymd])\s*$/", $filteredSelectionItems[$value-1], $dateAdditionSplit);
Comment thread
MightyMCoder marked this conversation as resolved.
Outdated

if(intval($dateAdditionSplit[1]) && $dateAdditionSplit[2]){
switch ($dateAdditionSplit[2]) {
case 'w':
date_add($compDate1, new DateInterval('P' . $dateAdditionSplit[1] . 'W'));
break;
case 'm':
date_add($compDate1, new DateInterval('P' . $dateAdditionSplit[1] . 'M'));
break;
case 'y':
date_add($compDate1, new DateInterval('P' . $dateAdditionSplit[1] . 'Y'));
break;
case 'd':
default:
date_add($compDate1, new DateInterval('P' . $dateAdditionSplit[1] . 'D'));
break;
}
}

//Compare last test date with future date and output days
$dateDiff = date_diff($compDate2, $compDate1);
$daysRemaining = $dateDiff->format('%R%a');

$columnValues[] = ($strikethrough && $getMode != 'csv' && $getMode != 'ods' && $getMode != 'xlsx') ? '<s>' . $daysRemaining . '</s>' : $daysRemaining;
$columnNumber++;
}
}

if ($getMode == 'html') {
Expand Down
3 changes: 2 additions & 1 deletion items/items_edit_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ function validateReceivedOnAndBackOn() {
break;

case 'DROPDOWN':
case'MAINTENANCE_SCHEDULE':

Comment thread
RealDekkia marked this conversation as resolved.
Outdated
$form->addSelectBox(
'imf-' . $items->getProperty($imfNameIntern, 'imf_id'),
convlanguagePIM($items->getProperty($imfNameIntern, 'imf_name')),
Expand Down Expand Up @@ -304,7 +306,6 @@ function validateReceivedOnAndBackOn() {
)
);
break;
Comment thread
RealDekkia marked this conversation as resolved.

default:
$fieldType = 'text';
$maxlength = '50';
Expand Down
3 changes: 3 additions & 0 deletions languages/de-DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<string name="PLG_INVENTORY_MANAGER_DISABLE_BORROWING">Ausleih-Optionen deaktivieren</string>
<string name="PLG_INVENTORY_MANAGER_DISABLE_BORROWING_DESC">Deaktiviere die Felder und deren Funktionen, die das Ausleihen und Zurückgeben von Gegenständen abbilden.</string>
<string name="PLG_INVENTORY_MANAGER_DEFAULT_CATEGORY">Allgemein</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE">Prüfturnus</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DAYS_REMAINING">Tage Übrig</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DESC">In diesem Feld können Sie die Einträge für Prüfturnusse eingeben. Pro Zeile kann hier ein Eintrag des Dropdown-Listenfeldes erfasst werden.\n\n Im Inventar wird später nicht der Text gespeichert, sondern die ausgewählte Position aus der Liste. Ändert man somit den Text in einer Zeile, so sehen alle Benutzer:innen sofort den neuen Text. Verschiebt man allerdings einen Eintrag in eine andere Zeile, so wird bei den Benutzerinnen bzw. Benutzern evtl. ein anderer Eintrag angezeigt.\n\n Der interne Name des Datums-Feldes auf das sich der Turnus bezieht, muss mit einem #-Symbol angegeben werden. z.B. #LETZTE_PRUEFUNG \n\n Der Turnus-Intervall muss durch das |-Symbol getrennt hinter die Bezeichnung in die selbe Zeile geschrieben werden. z.B. Jährlich | 1y \n\n Wenn keine Einheit angegeben wird, wird von Tagen ausgegangen. \nMögliche einheiten: d: Tage, w: Wochen, m: Monate, y: Jahre</string>
<!-- Phrases only in Database -->
<string name="PIM_CATEGORY">Kategorie</string>
<string name="PIM_CATEGORY_DESCRIPTION">Die Kategorie des Gegenstandes</string>
Expand Down
3 changes: 3 additions & 0 deletions languages/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<string name="PLG_INVENTORY_MANAGER_DISABLE_BORROWING">Ausleih-Optionen deaktivieren</string>
<string name="PLG_INVENTORY_MANAGER_DISABLE_BORROWING_DESC">Deaktiviere die Felder und deren Funktionen, die das Ausleihen und Zurückgeben von Gegenständen abbilden.</string>
<string name="PLG_INVENTORY_MANAGER_DEFAULT_CATEGORY">Allgemein</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE">Prüfturnus</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DAYS_REMAINING">Tage Übrig</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DESC">In diesem Feld können Sie die Einträge für Prüfturnusse eingeben. Pro Zeile kann hier ein Eintrag des Dropdown-Listenfeldes erfasst werden.\n\n Im Inventar wird später nicht der Text gespeichert, sondern die ausgewählte Position aus der Liste. Ändert man somit den Text in einer Zeile, so sehen alle Benutzer:innen sofort den neuen Text. Verschiebt man allerdings einen Eintrag in eine andere Zeile, so wird bei den Benutzerinnen bzw. Benutzern evtl. ein anderer Eintrag angezeigt.\n\n Der interne Name des Datums-Feldes auf das sich der Turnus bezieht, muss mit einem #-Symbol angegeben werden. z.B. #LETZTE_PRUEFUNG \n\n Der Turnus-Intervall muss durch das |-Symbol getrennt hinter die Bezeichnung in die selbe Zeile geschrieben werden. z.B. Jährlich | 1y \n\n Wenn keine Einheit angegeben wird, wird von Tagen ausgegangen. \nMögliche einheiten: d: Tage, w: Wochen, m: Monate, y: Jahre</string>
<!-- Phrases only in Database -->
<string name="PIM_CATEGORY">Kategorie</string>
<string name="PIM_CATEGORY_DESCRIPTION">Die Kategorie des Gegenstandes</string>
Expand Down
3 changes: 3 additions & 0 deletions languages/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<string name="PLG_INVENTORY_MANAGER_KEEPER">Keeper</string>
<string name="PLG_INVENTORY_MANAGER_KEEPER_FORMER_DESC">You can reintegrate the item into the inventory management. This has the advantage that the data is preserved and you can later always see who has borrowed this item.\n\nIf you want to delete the item, please contact an administrator or the manager of the inventory management!</string>
<string name="PLG_INVENTORY_MANAGER_KEEPER_ITEM_UNDO_FORMER_DESC">You can reintegrate the item into the inventory management.\n\nIf you want to delete the item, please contact an administrator or the manager of the inventory management!</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE">maintenance Schedule</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DAYS_REMAINING">Days Left</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DESC">In this field, you can enter the entries for maintenance schedules. For each line, an entry of the drop-down list field can be entered here. \n\nThe List-Item is not stored as text later, but the selected position from the list. If you change the text in a line, all users will immediately see the new text. However, if you move an entry into another line, users may see a different entry.\n\nThe internal name of the date field the current schedules applies to must be specified with a # symbol. e.g. #LAST_CHECK \n\nThe cycle interval must be written in the same line separated by the |-symbol after the title. e.g. Yearly | 1y \n\nIf no unit is specified, days are assumed. \nPossible units: d: days, w: weeks, m: months, y: years</string>
<string name="PLG_INVENTORY_MANAGER_MENU_URL_ERROR">The authorization check of the plugin failed. There is more than one menu item with the same URL defined.\n\n=&gt; #VAR1_BOLD#</string>
<string name="PLG_INVENTORY_MANAGER_NAME_OF_PLUGIN">InventoryManager</string>
<string name="PLG_INVENTORY_MANAGER_NOTIFICATION_MESSAGE_ITEMS_IMPORTED">The following items were imported by #VAR1_BOLD#:</string>
Expand Down
3 changes: 3 additions & 0 deletions languages/fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<string name="PLG_INVENTORY_MANAGER_DISABLE_BORROWING">Désactiver les options d'emprunt</string>
<string name="PLG_INVENTORY_MANAGER_DISABLE_BORROWING_DESC">Désactivez les champs et leurs fonctions qui représentent l'emprunt et le retour d'objets.</string>
<string name="PLG_INVENTORY_MANAGER_DEFAULT_CATEGORY">Générale</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE">Périodicité des contrôles</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DAYS_REMAINING">Jours restants</string>
<string name="PLG_INVENTORY_MANAGER_MAINTENANCE_SCHEDULE_DESC">Dans ce champ, vous pouvez saisir les entrées pour les tournées de contrôle. Une entrée de la liste déroulante peut être saisie ici par ligne.\n\nPlus tard, ce n'est pas le texte qui sera enregistré dans l'inventaire, mais la position sélectionnée dans la liste. Si l'on modifie le texte d'une ligne, tous les utilisateurs voient immédiatement le nouveau texte. Si l'on déplace une entrée sur une autre ligne, les utilisateurs verront éventuellement une autre entrée.\n\n Le nom interne du champ de date auquel se réfère le tournus doit être indiqué avec un symbole #. p.ex. #DERNIER_PRUIT \n\n L'intervalle de tournus doit être écrit sur la même ligne après la désignation, séparé par le symbole |. p.ex. annuel | 1y \n\n Si aucune unité n'est indiquée, on part de jours. \nUnités possibles : d : jours, w : semaines, m : mois, y : années</string>
<!-- Phrases only in Database -->
<string name="PIM_CATEGORY">Catégorie</string>
<string name="PIM_CATEGORY_DESCRIPTION">La catégorie de l'objet</string>
Expand Down