Skip to content

Commit 9705655

Browse files
committed
small fixes inventory module
1 parent b87a3bf commit 9705655

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

languages/en.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@
865865
<string name="SYS_INVENTORY_LAST_RECEIVER">Last receiver</string>
866866
<string name="SYS_INVENTORY_LAST_RECEIVER_DESC">Last receiver of the item</string>
867867
<string name="SYS_INVENTORY_NO_NEW_IMPORT_DATA">There was no new data in the import file!</string>
868+
<string name="SYS_INVENTORY_NO_EDITABLE_CATEGORIES">There are no categories available for you that can be assigned to items. Please contact an administrator of the inventory manager.</string>
868869
<string name="SYS_INVENTORY_NOTIFICATION_MESSAGE_ITEM_CHANGED">The item #VAR1_BOLD# was changed by #VAR2_BOLD#:</string>
869870
<string name="SYS_INVENTORY_NOTIFICATION_MESSAGE_ITEM_CREATED">The item #VAR1_BOLD# was created by #VAR2_BOLD#:</string>
870871
<string name="SYS_INVENTORY_NOTIFICATION_MESSAGE_ITEM_DELETED">The following item was deleted:</string>

modules/inventory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@
326326
case 'item_delete_keeper_explain_msg':
327327
// check if all items are shown
328328
$showAll = admFuncVariableIsValid($_GET, 'items_filter_status', 'int', array('defaultValue' => 1)) === 0;
329-
329+
$retireOnClick = 'callUrlHideElement(\'adm_inventory_item_' . $getiniUUID . '\', \'' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_MODULES . '/inventory.php', array('mode' => 'item_retire', 'item_uuid' => $getiniUUID)) . '\', \'' . $gCurrentSession->getCsrfToken() . '\', ' . ($showAll ? '\'refreshInventoryTable\'' : '\'\'') . ')';
330330
$msg = '
331331
<div class="modal-header">
332332
<h3 class="modal-title">' . $gL10n->get('SYS_INVENTORY_ITEM_RETIRE') . '</h3>
@@ -336,7 +336,7 @@
336336
<p><i class="bi bi-eye-slash-fill"></i>&nbsp;' . $gL10n->get('SYS_INVENTORY_KEEPER_ITEM_RETIRE_DESC', array('SYS_INVENTORY_KEEPER_ITEM_DELETE_DESC')) . '</p>
337337
</div>
338338
<div class="modal-footer">
339-
<button id="adm_button_retire" type="button" class="btn btn-primary mr-4" onclick="callUrlHideElement(\'adm_inventory_item_' . $getiniUUID . '\', \'' . SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_MODULES . '/inventory.php', array('mode' => 'item_retire', 'item_uuid' => $getiniUUID)) . '\', \'' . $gCurrentSession->getCsrfToken() . '\', ' . $showAll ? '\'refreshInventoryTable\'' : ' \'\' ' . ')">
339+
<button id="adm_button_retire" type="button" class="btn btn-primary mr-4" onclick="' . $retireOnClick . '">
340340
<i class="bi bi-eye-slash"></i>' . $gL10n->get('SYS_INVENTORY_ITEM_RETIRE') . '</button>
341341
<div id="adm_status_message" class="mt-4 w-100"></div>
342342
</div>';

src/Categories/Service/CategoryService.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public function getEditableCategories(): array
7979
if ($this->editableCategories === null) {
8080
$editableCategoryIDs = $gCurrentUser->getAllEditableCategories($this->type);
8181

82+
if (count($editableCategoryIDs) === 0) {
83+
// No editable categories
84+
return array();
85+
}
86+
8287
$sql = 'SELECT cat_id, cat_uuid, cat_name, cat_default
8388
FROM ' . TBL_CATEGORIES . '
8489
WHERE cat_id IN (' . Database::getQmForValues($editableCategoryIDs) . ')';
@@ -122,6 +127,11 @@ public function getVisibleCategories(): array
122127
if ($this->visibleCategories === null) {
123128
$visibleCategoryIDs = $gCurrentUser->getAllVisibleCategories($this->type);
124129

130+
if (count($visibleCategoryIDs) === 0) {
131+
// No visible categories
132+
return array();
133+
}
134+
125135
$sql = 'SELECT cat_id, cat_uuid, cat_name, cat_default
126136
FROM ' . TBL_CATEGORIES . '
127137
WHERE cat_id IN (' . Database::getQmForValues($visibleCategoryIDs) . ')';

src/UI/Presenter/InventoryItemPresenter.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use Admidio\Infrastructure\Utils\PhpIniUtils;
1212
use Admidio\Inventory\Entity\Item;
1313
use Admidio\Inventory\ValueObjects\ItemsData;
14-
use Admidio\UI\Presenter\FormPresenter;
15-
use Admidio\UI\Presenter\PagePresenter;
1614
use Admidio\Users\Entity\User;
1715
use DateTime;
1816
use Ramsey\Uuid\Uuid;
@@ -191,7 +189,7 @@ function callbackItemPicture() {
191189
);
192190

193191
} elseif ($categoryService->count() > 0) {
194-
if (!empty($gCurrentUser->getAllEditableCategories('IVT'))) {
192+
if (!empty($categoryService->getEditableCategories())) {
195193
$form->addSelectBoxForCategories(
196194
'INF-' . $infNameIntern,
197195
$gL10n->get('SYS_CATEGORY'),
@@ -204,18 +202,14 @@ function callbackItemPicture() {
204202
)
205203
);
206204
} else {
207-
$categories = array();
208-
foreach ($categoryService->getVisibleCategories() as $category) {
209-
$categories[$category['cat_uuid']] = $category['cat_name'];
210-
}
211-
212-
$form->addSelectBox(
205+
$form->addInput(
213206
'INF-' . $infNameIntern,
214207
$gL10n->get('SYS_CATEGORY'),
215-
$categories,
208+
$items->getValue($infNameIntern),
216209
array(
217-
'property' => FormPresenter::FIELD_REQUIRED,
218-
'defaultValue' => $items->getValue($infNameIntern, 'database'),
210+
'type' => 'text',
211+
'property' => FormPresenter::FIELD_DISABLED,
212+
'helpTextId' => 'SYS_INVENTORY_NO_EDITABLE_CATEGORIES'
219213
)
220214
);
221215
}
@@ -929,9 +923,9 @@ function isSelect2Empty(selectId) {
929923
$maxlength = null;
930924
$date = new DateTime('now');
931925
if ($fieldType === 'datetime') {
932-
$defaultDate = $date->format('Y-m-d H:i');
926+
$defaultDate = $date->format($gSettingsManager->getString('system_date') . ' ' . $gSettingsManager->getString('system_time'));
933927
} else {
934-
$defaultDate = $date->format('Y-m-d');
928+
$defaultDate = $date->format($gSettingsManager->getString('system_date'));
935929
}
936930

937931
} elseif ($infNameIntern === 'ITEMNAME') {

src/UI/Presenter/PreferencesPresenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ public function createInventoryForm(): string
10181018

10191019
$formInventory->addInput(
10201020
'inventory_export_filename',
1021-
$gL10n->get('SYS_INVENTORY_FILENAME'),
1021+
'SYS_INVENTORY_FILENAME',
10221022
$formValues['inventory_export_filename'],
10231023
array('maxLength' => 50, 'property' => FormPresenter::FIELD_REQUIRED, 'helpTextId' => 'SYS_INVENTORY_FILENAME_DESC')
10241024
);

0 commit comments

Comments
 (0)