Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 13 additions & 3 deletions classes/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ 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', 'DATE_INTERVAL'])) {
$value = $this->getListValue($fieldNameIntern, $value, $format);
}

return $value;
}

Expand Down Expand Up @@ -291,12 +289,24 @@ public function getHtmlValue($fieldNameIntern, $value): string

case 'DROPDOWN':
case 'RADIO_BUTTON':
case 'DATE_INTERVAL':
$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 == 'DATE_INTERVAL'){
$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
3 changes: 2 additions & 1 deletion fields/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ function moveCategory(direction, imfID) {
'TEXT' => $gL10n->get('SYS_TEXT') . ' (100)',
'TEXT_BIG' => $gL10n->get('SYS_TEXT') . ' (4000)',
'NUMBER' => $gL10n->get('SYS_NUMBER'),
'DECIMAL' => $gL10n->get('SYS_DECIMAL_NUMBER')
'DECIMAL' => $gL10n->get('SYS_DECIMAL_NUMBER'),
'DATE_INTERVAL' => $gL10n->get('PLG_INVENTORY_MANAGER_DATE_INTERVAL')
);

$imfSystem = $itemField->getValue('imf_system') == 1
Expand Down
1 change: 1 addition & 0 deletions fields/fields_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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') . ')',
'DATE_INTERVAL' => $gL10n->get('PLG_INVENTORY_MANAGER_DATE_INTERVAL')
);
asort($itemFieldText);

Expand Down
25 changes: 23 additions & 2 deletions fields/fields_edit_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,25 @@

$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() === "DATE_INTERVAL") {
$("#imf_value_list_group").show("slow");
$("#imf_value_list").attr("required", "required");
if ($("#imf_type").val() === "DATE_INTERVAL") {
$("#imf_date_interval_field_group").show("slow");
$("#imf_date_interval_field").attr("required", "required");
}
} else {
$("#imf_value_list").removeAttr("required");
$("#imf_value_list_group").hide();
$("#imf_date_interval_field").removeAttr("required");
$("#imf_date_interval_field_group").hide();
}

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

Expand Down Expand Up @@ -108,7 +121,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') . ')',
);
'DATE_INTERVAL' => $gL10n->get('PLG_INVENTORY_MANAGER_DATE_INTERVAL'));
asort($itemFieldText);

//bei Systemfeldern darf der Datentyp nicht mehr veraendert werden
Expand All @@ -118,6 +131,14 @@ function setValueList() {
)
);

$sql = "SELECT imf_id, imf_name FROM " . TBL_INVENTORY_MANAGER_FIELDS . " WHERE imf_type = 'DATE'";
$form->addSelectBoxFromSql('imf_date_interval_field', $gL10n->get('PLG_INVENTORY_MANAGER_DATE_INTERVAL_FIELD'), $gDb, $sql, array(
'property' => HtmlForm::FIELD_REQUIRED,
'defaultValue' => $itemField->getValue('imf_date_interval_field'),
'helpTextIdLabel' => 'PLG_INVENTORY_MANAGER_DATE_INTERVAL_FIELD_DESC'
)
);

$form->addMultilineTextInput('imf_value_list', $gL10n->get('ORG_VALUE_LIST'), (string)$itemField->getValue('imf_value_list', 'database'), 6, array(
'property' => HtmlForm::FIELD_REQUIRED,
'helpTextIdLabel' => 'ORG_VALUE_LIST_DESC'
Expand Down
53 changes: 52 additions & 1 deletion inventory_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,12 @@
$imfNameIntern = $itemField->getValue('imf_name_intern');
$columnHeader = convlanguagePIM($items->getProperty($imfNameIntern, 'imf_name'));

if ($disableBorrowing == 1 && ($imfNameIntern === 'LAST_RECEIVER' || $imfNameIntern === 'RECEIVED_ON' || $imfNameIntern === 'RECEIVED_BACK_ON')) {
if($items->getProperty($imfNameIntern, 'imf_type') === 'DATE_INTERVAL'){
// modify column Header for DATE_INTERVAL fields
$columnHeader .= ' ' . $gL10n->get('PLG_INVENTORY_MANAGER_DATE_INTERVAL_DAYS_REMAINING');
}

if ($disableBorrowing == 1 && ($imfNameIntern === 'LAST_RECEIVER' || $imfNameIntern === 'RECEIVED_ON' || $imfNameIntern === 'RECEIVED_BACK_ON')) {
break;
}

Expand Down Expand Up @@ -629,6 +634,52 @@
elseif (in_array($items->getProperty($imfNameIntern, 'imf_type'), array('DROPDOWN', 'RADIO_BUTTON'))) {
$content = $items->getHtmlValue($imfNameIntern, $content);
}
elseif ($items->getProperty($imfNameIntern, 'imf_type') == 'DATE_INTERVAL') {
$selectedInterval = $content;
$content = '';

$intervalValues = $items->getProperty($imfNameIntern, 'imf_value_list');
$dateIntervalFieldId = $items->getProperty($imfNameIntern, 'imf_date_interval_field', 'database');
if (isset($items->mItemData[$dateIntervalFieldId])) {
$dateInternalFieldName = $items->mItemData[$dateIntervalFieldId]->getValue('imf_name_intern');
$filteredSelectionItems = array();

foreach ($intervalValues as $value) {
$filteredSelectionItems[] = trim(explode('|', $value)[1]);
}
//use part after # as internal_name for last test date
$compDate1 = date_create($items->getValue($dateInternalFieldName, 'database'));
$compDate2 = date_create();

//Calculate future test date
$dateAdditionSplit = array();
if (isset($filteredSelectionItems[$selectedInterval-1])) {
preg_match("/^\s*(\d*)([wymd])\s*$/", $filteredSelectionItems[$selectedInterval-1], $dateAdditionSplit);
}

if(isset($dateAdditionSplit[1]) && isset($dateAdditionSplit[2]) && is_numeric($dateAdditionSplit[1])){
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);
$content = $dateDiff->format('%R%a');
}
}
}

$columnValues[] = ($strikethrough && $getMode != 'csv' && $getMode != 'ods' && $getMode != 'xlsx') ? '<s>' . $content . '</s>' : $content;
$columnNumber++;
Expand Down
1 change: 1 addition & 0 deletions items/items_edit_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ function validateReceivedOnAndBackOn() {
break;

case 'DROPDOWN':
case'DATE_INTERVAL':
$form->addSelectBox(
'imf-' . $items->getProperty($imfNameIntern, 'imf_id'),
convlanguagePIM($items->getProperty($imfNameIntern, 'imf_name')),
Expand Down
Loading