Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions fields/fields_edit_new.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ function setValueList() {
);

$form->addCheckbox('imf_mandatory', $gL10n->get('SYS_REQUIRED_INPUT'), (bool)$itemField->getValue('imf_mandatory'), array(
'property' => $itemField->getValue('imf_system') == 1 ? HtmlForm::FIELD_DISABLED : HtmlForm::FIELD_DEFAULT,
'property' => HtmlForm::FIELD_DEFAULT,
'icon' => 'fa-asterisk'
)
);
Expand All@@ -144,5 +144,5 @@ function setValueList() {
));

// add form to html page and show page
$page->addHtml($form->show(false));
$page->addHtml($form->show());
$page->show();
51 changes: 24 additions & 27 deletions import/import_column_config.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,15 +91,12 @@ function getColumnAssignmentHtml(array $arrayColumnList, array $arrayCsvColumns)
return $html;
}

$items = new CItems($gDb, $gCurrentOrgId);
$items->readItems($gCurrentOrgId);

// create html page object
$page = new HtmlPage('admidio-items-import-csv', $headline);
$page->addHtml('<p class="lead">'.$gL10n->get('PLG_INVENTORY_MANAGER_IMPORT_ASSIGN_FIELDS').'</p>');

// show form
$form = new HtmlForm('import_assign_fields_form', ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/import/import_items.php', $page, array('type' => 'vertical'));
$form = new HtmlForm('import_assign_fields_form', SecurityUtils::encodeUrl(ADMIDIO_URL . FOLDER_PLUGINS . PLUGIN_FOLDER_IM . '/import/import_items.php'), $page, array('type' => 'vertical'));
$form->addCheckbox('first_row', $gL10n->get('SYS_FIRST_LINE_COLUMN_NAME'), $formValues['first_row']);
$form->addHtml('<div class="alert alert-warning alert-small" id="admidio-import-unused"><i class="fas fa-exclamation-triangle"></i>'.$gL10n->get('PLG_INVENTORY_MANAGER_IMPORT_UNUSED_HEAD').'<div id="admidio-import-unused-fields">-</div></div>');

Expand DownExpand Up@@ -147,31 +144,31 @@ function getColumnAssignmentHtml(array $arrayColumnList, array $arrayCsvColumns)
</tr>
</thead>';

$arrayCsvColumns = $_SESSION['import_data'][0];
// Remove only null values
$arrayCsvColumns = array_filter($arrayCsvColumns, function ($value) {
return !is_null($value);
});
$arrayCsvColumns = $_SESSION['import_data'][0];
// Remove only null values
$arrayCsvColumns = array_filter($arrayCsvColumns, function ($value) {
return !is_null($value);
});

$categoryId = null;
$arrayImportableFields = array();
$items = new CItems($gDb, $gCurrentOrgId);
$row = array();
foreach ($items->mItemFields as $columnKey => $columnValue) {
$imfName = $columnValue->GetValue('imf_name');
// If the field name starts with 'PIM_', it is a language key
if (strpos($imfName, 'PIM_') !== false) {
$row = array($columnValue->GetValue('imf_name_intern') => $gL10n->get($imfName));
} else {
$row = array($columnValue->GetValue('imf_name_intern') => $imfName);
}
$arrayImportableFields[] = $row;
}
$categoryId = null;
$arrayImportableFields = array();

$items = new CItems($gDb, $gCurrentOrgId);
$row = array();
foreach ($items->mItemFields as $columnKey => $columnValue) {
$imfName = $columnValue->GetValue('imf_name');

// If the field name starts with 'PIM_', it is a language key
if (strpos($imfName, 'PIM_') !== false) {
$row = array($columnValue->GetValue('imf_name_intern') => $gL10n->get($imfName));
} else {
$row = array($columnValue->GetValue('imf_name_intern') => $imfName);
}

$arrayImportableFields[] = $row;
}

$htmlFieldTable .= getColumnAssignmentHtml($arrayImportableFields, $arrayCsvColumns) .'
$htmlFieldTable .= getColumnAssignmentHtml($arrayImportableFields, $arrayCsvColumns) .'
</tbody>
</table>';
$form->addHtml($htmlFieldTable);
Expand Down
8 changes: 5 additions & 3 deletions import/import_items.php
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@

<?php
/**
***********************************************************************************************
Expand DownExpand Up@@ -41,16 +40,19 @@
*/
function compareArrays(array $array1, array $array2): bool {
$array1 = array_filter($array1, function($key) {
return $key !== 'KEEPER' && $key !== 'LAST_RECEIVER' && $key !== 'CATEGORY';
return $key !== 'KEEPER' && $key !== 'LAST_RECEIVER' && $key !== 'CATEGORY' && $key !== 'IN_INVENTORY';
}, ARRAY_FILTER_USE_KEY);

foreach (['RECEIVED_ON', 'RECEIVED_BACK_ON'] as $dateField) {
if (isset($array1[$dateField])) {
if (isset($array1[$dateField]) && $array1[$dateField] !== '') {
$date = DateTime::createFromFormat('d.m.Y', $array1[$dateField]);
if ($date) {
$array1[$dateField] = $date->format('Y-m-d');
}
}
else {
unset($array1[$dateField]);
}
}

foreach ($array1 as $value) {
Expand Down
7 changes: 0 additions & 7 deletions import/import_read_file.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,6 @@

require_once(__DIR__ . '/../../../adm_program/system/common.php');
require_once(__DIR__ . '/../common_function.php');
require_once(__DIR__ . '/../classes/items.php');

// Access only with valid login
require_once(__DIR__ . '/../../../adm_program/system/login_valid.php');
Expand DownExpand Up@@ -73,12 +72,6 @@
// => EXIT
}

$items = new CItems($gDb, $gCurrentOrgId);
$items->readItemData($getItemId, $gCurrentOrgId);

// read file using the phpSpreadsheet library
//$_SESSION['rol_id'] = (int) $items->getValue('rol_id');

switch ($postImportFormat) {
case 'XLSX':
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
Expand Down
2 changes: 1 addition & 1 deletion items/items_delete.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ function displayItemDeleteForm($items, $user, $getItemId, $getItemFormer) {
$form->addCustomContent('', '<br />'.$gL10n->get('PLG_INVENTORY_MANAGER_ITEM_MAKE_TO_FORMER'));
}

$page->addHtml($form->show(false));
$page->addHtml($form->show());
$page->show();
}

Expand Down
2 changes: 1 addition & 1 deletion items/items_edit_new.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -434,5 +434,5 @@ function isSelect2Empty(selectId) {
(int) $infoItem->getValue('imi_usr_id_change'), $infoItem->getValue('imi_timestamp_change')
));

$page->addHtml($form->show(false));
$page->addHtml($form->show());
$page->show();
2 changes: 1 addition & 1 deletion items/items_history.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,7 +91,7 @@
$form->addInput('filter_date_to', $gL10n->get('SYS_END'), $dateToHtml, array('type' => 'date', 'maxLength' => 10));
$form->addInput('item_id', '', $getItemId, array('property' => HtmlForm::FIELD_HIDDEN));
$form->addSubmitButton('btn_send', $gL10n->get('SYS_OK'));
$FilterNavbar->addForm($form->show(false));
$FilterNavbar->addForm($form->show());
$page->addHtml($FilterNavbar->show());

$table = new HtmlTable('profile_field_history_table', $page, true, true);
Expand Down
2 changes: 1 addition & 1 deletion preferences/preferences_function.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,7 +124,7 @@ function showDeinstallationDialog() {
$form->addSubmitButton('btn_deinstall', $gL10n->get('PLG_INVENTORY_MANAGER_DEINSTALLATION'), array('icon' => 'fa-trash-alt', 'class' => 'offset-sm-3'));

// add form to html page and show page
$page->addHtml($form->show(false));
$page->addHtml($form->show());
$page->show();
}

Expand Down