diff --git a/classes/items.php b/classes/items.php index c9aa8b6..791b8af 100644 --- a/classes/items.php +++ b/classes/items.php @@ -877,6 +877,7 @@ public function sendNotification($organizationId, $importData = null): bool } $textOld = $gL10n->get('SYS_NO_USER_FOUND'); + $textNew = ''; if ($this->itemImported) { $textOld = ''; $textNew = $gL10n->get('SYS_NO_USER_FOUND'); diff --git a/common_function.php b/common_function.php index 4d6f87e..a787cb8 100644 --- a/common_function.php +++ b/common_function.php @@ -40,16 +40,16 @@ function defineConstantsPIM() define('PLUGIN_FOLDER_IM', '/' . basename(__DIR__)); } if (!defined('TBL_INVENTORY_MANAGER_FIELDS')) { - define('TBL_INVENTORY_MANAGER_FIELDS', $g_tbl_praefix . '_inventory_manager_fields'); + define('TBL_INVENTORY_MANAGER_FIELDS', TABLE_PREFIX . '_inventory_manager_fields'); } if (!defined('TBL_INVENTORY_MANAGER_DATA')) { - define('TBL_INVENTORY_MANAGER_DATA', $g_tbl_praefix . '_inventory_manager_data'); + define('TBL_INVENTORY_MANAGER_DATA', TABLE_PREFIX . '_inventory_manager_data'); } if (!defined('TBL_INVENTORY_MANAGER_ITEMS')) { - define('TBL_INVENTORY_MANAGER_ITEMS', $g_tbl_praefix . '_inventory_manager_items'); + define('TBL_INVENTORY_MANAGER_ITEMS', TABLE_PREFIX . '_inventory_manager_items'); } if (!defined('TBL_INVENTORY_MANAGER_LOG')) { - define('TBL_INVENTORY_MANAGER_LOG', $g_tbl_praefix . '_inventory_manager_log'); + define('TBL_INVENTORY_MANAGER_LOG', TABLE_PREFIX . '_inventory_manager_log'); } } diff --git a/import/import_items.php b/import/import_items.php index a477986..9f3c537 100644 --- a/import/import_items.php +++ b/import/import_items.php @@ -40,7 +40,7 @@ */ function compareArrays(array $array1, array $array2): bool { $array1 = array_filter($array1, function($key) { - return $key !== 'KEEPER' && $key !== 'LAST_RECEIVER' && $key !== 'CATEGORY' && $key !== 'IN_INVENTORY' && $key !== 'RECEIVED_ON' && $key !== 'RECEIVED_BACK_ON'; + return $key !== 'KEEPER' && $key !== 'LAST_RECEIVER' && $key !== 'IN_INVENTORY' && $key !== 'RECEIVED_ON' && $key !== 'RECEIVED_BACK_ON'; }, ARRAY_FILTER_USE_KEY); foreach ($array1 as $value) { @@ -113,11 +113,23 @@ function compareArrays(array $array1, array $array2): bool { $itemValues = array(); foreach ($items->mItemData as $key => $itemData) { $itemValue = $itemData->getValue('imd_value'); - if ($itemData->getValue('imf_name_intern') === 'KEEPER' || $itemData->getValue('imf_name_intern') === 'LAST_RECEIVER' || $itemData->getValue('imf_name_intern') === 'CATEGORY' || $itemData->getValue('imf_name_intern') === 'IN_INVENTORY' || $itemData->getValue('imf_name_intern') === 'RECEIVED_ON' || $itemData->getValue('imf_name_intern') === 'RECEIVED_BACK_ON') + if ($itemData->getValue('imf_name_intern') === 'KEEPER' || $itemData->getValue('imf_name_intern') === 'LAST_RECEIVER' || $itemData->getValue('imf_name_intern') === 'IN_INVENTORY' || $itemData->getValue('imf_name_intern') === 'RECEIVED_ON' || $itemData->getValue('imf_name_intern') === 'RECEIVED_BACK_ON') { continue; } + if ($itemData->getValue('imf_name_intern') === 'CATEGORY') { + $imfNameIntern = $itemData->getValue('imf_name_intern'); + // get value list of the item field + $valueList = $items->getProperty($imfNameIntern, 'imf_value_list'); + + // select the value from the value list + $val = $valueList[$itemValue]; + + $itemValues[] = array($itemData->getValue('imf_name_intern') => $val); + continue; + } + $itemValues[] = array($itemData->getValue('imf_name_intern') => $itemValue); } $itemValues = array_merge_recursive(...$itemValues); @@ -169,13 +181,13 @@ function compareArrays(array $array1, array $array2): bool { } else { $sql = 'SELECT usr_id, CONCAT(last_name.usd_value, \', \', first_name.usd_value, IFNULL(CONCAT(\', \', postcode.usd_value),\'\'), IFNULL(CONCAT(\' \', city.usd_value),\'\'), IFNULL(CONCAT(\', \', street.usd_value),\'\') ) as name - FROM ' . TBL_USERS . ' - JOIN ' . TBL_USER_DATA . ' as last_name ON last_name.usd_usr_id = usr_id AND last_name.usd_usf_id = ' . $gProfileFields->getProperty('LAST_NAME', 'usf_id') . ' - JOIN ' . TBL_USER_DATA . ' as first_name ON first_name.usd_usr_id = usr_id AND first_name.usd_usf_id = ' . $gProfileFields->getProperty('FIRST_NAME', 'usf_id') . ' - LEFT JOIN ' . TBL_USER_DATA . ' as postcode ON postcode.usd_usr_id = usr_id AND postcode.usd_usf_id = ' . $gProfileFields->getProperty('POSTCODE', 'usf_id') . ' - LEFT JOIN ' . TBL_USER_DATA . ' as city ON city.usd_usr_id = usr_id AND city.usd_usf_id = ' . $gProfileFields->getProperty('CITY', 'usf_id') . ' - LEFT JOIN ' . TBL_USER_DATA . ' as street ON street.usd_usr_id = usr_id AND street.usd_usf_id = ' . $gProfileFields->getProperty('ADDRESS', 'usf_id') . ' - WHERE usr_valid = 1 AND EXISTS (SELECT 1 FROM ' . TBL_MEMBERS . ', ' . TBL_ROLES . ', ' . TBL_CATEGORIES . ' WHERE mem_usr_id = usr_id AND mem_rol_id = rol_id AND mem_begin <= \'' . DATE_NOW . '\' AND mem_end > \'' . DATE_NOW . '\' AND rol_valid = 1 AND rol_cat_id = cat_id AND (cat_org_id = ' . $gCurrentOrgId . ' OR cat_org_id IS NULL)) ORDER BY last_name.usd_value, first_name.usd_value;'; + FROM ' . TBL_USERS . ' + JOIN ' . TBL_USER_DATA . ' as last_name ON last_name.usd_usr_id = usr_id AND last_name.usd_usf_id = ' . $gProfileFields->getProperty('LAST_NAME', 'usf_id') . ' + JOIN ' . TBL_USER_DATA . ' as first_name ON first_name.usd_usr_id = usr_id AND first_name.usd_usf_id = ' . $gProfileFields->getProperty('FIRST_NAME', 'usf_id') . ' + LEFT JOIN ' . TBL_USER_DATA . ' as postcode ON postcode.usd_usr_id = usr_id AND postcode.usd_usf_id = ' . $gProfileFields->getProperty('POSTCODE', 'usf_id') . ' + LEFT JOIN ' . TBL_USER_DATA . ' as city ON city.usd_usr_id = usr_id AND city.usd_usf_id = ' . $gProfileFields->getProperty('CITY', 'usf_id') . ' + LEFT JOIN ' . TBL_USER_DATA . ' as street ON street.usd_usr_id = usr_id AND street.usd_usf_id = ' . $gProfileFields->getProperty('ADDRESS', 'usf_id') . ' + WHERE usr_valid = 1 AND EXISTS (SELECT 1 FROM ' . TBL_MEMBERS . ', ' . TBL_ROLES . ', ' . TBL_CATEGORIES . ' WHERE mem_usr_id = usr_id AND mem_rol_id = rol_id AND mem_begin <= \'' . DATE_NOW . '\' AND mem_end > \'' . DATE_NOW . '\' AND rol_valid = 1 AND rol_cat_id = cat_id AND (cat_org_id = ' . $gCurrentOrgId . ' OR cat_org_id IS NULL)) ORDER BY last_name.usd_value, first_name.usd_value;'; } $result = $gDb->queryPrepared($sql); diff --git a/inventory_manager.php b/inventory_manager.php index 7cce343..2f2746d 100644 --- a/inventory_manager.php +++ b/inventory_manager.php @@ -52,7 +52,7 @@ // Access only with valid login require_once(__DIR__ . '/../../adm_program/system/login_valid.php'); -//$scriptName ist der Name wie er im Menue eingetragen werden muss, also ohne evtl. vorgelagerte Ordner wie z.B. /playground/adm_plugins/inventory_manager... +//$scriptName is the name as it must be entered in the menu, without any preceding folders such as /playground/adm_plugins/InventoryManager... $scriptName = substr($_SERVER['SCRIPT_NAME'], strpos($_SERVER['SCRIPT_NAME'], FOLDER_PLUGINS)); // only authorized user are allowed to start this module @@ -154,7 +154,7 @@ // if html mode and last url was not a list view then save this url to navigation stack if ($gNavigation->count() === 0 || ($getMode == 'html' && strpos($gNavigation->getUrl(), 'inventory_manager.php') === false)) { - $gNavigation->addStartUrl(CURRENT_URL, $headline, 'fa-key'); + $gNavigation->addStartUrl(CURRENT_URL, $headline, 'fa-warehouse'); } $datatable = false; diff --git a/items/items_edit_new.php b/items/items_edit_new.php index edb22ab..6a5a7b8 100644 --- a/items/items_edit_new.php +++ b/items/items_edit_new.php @@ -228,7 +228,7 @@ function validateReceivedOnAndBackOn() { $form->addCheckbox( 'imf-' . $items->getProperty($imfNameIntern, 'imf_id'), convlanguagePIM($items->getProperty($imfNameIntern, 'imf_name')), - (bool) $items->getValue($imfNameIntern), + ($getItemId === 0) ? true : (bool) $items->getValue($imfNameIntern), array( 'property' => $fieldProperty, 'helpTextIdLabel' => $helpId, diff --git a/items/items_history.php b/items/items_history.php index 367531f..862838a 100644 --- a/items/items_history.php +++ b/items/items_history.php @@ -140,7 +140,7 @@ if ($imlValueOld !== '') { if ($items->getPropertyById((int) $row['iml_imf_id'], 'imf_name_intern') === 'KEEPER' || $items->getPropertyById((int) $row['iml_imf_id'], 'imf_name_intern') === 'LAST_RECEIVER') { if (is_numeric($imlValueOld)) { - $found = $user->readDataById($imlValueNew); + $found = $user->readDataById($imlValueOld); if ($found) { $columnValues[] = ''.$user->getValue('LAST_NAME').', '.$user->getValue('FIRST_NAME').''; } @@ -149,7 +149,7 @@ } } else { - $columnValues[] = $imlValueNew; + $columnValues[] = $imlValueOld; } } else {