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
36 changes: 19 additions & 17 deletions classes/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,24 +660,26 @@ public function setValue($fieldNameIntern, $newValue)

// format of date will be local but database has stored Y-m-d format must be changed for compare
if ($this->mItemFields[$fieldNameIntern]->getValue('imf_type') === 'DATE') {
if ($this->pPreferences->config['Optionen']['field_date_time_format'] === 'datetime') {
//check if date is datetime or only date
if (strpos($newValue, ' ') === false) {
$newValue .= ' 00:00';
}
$date = \DateTime::createFromFormat('Y-m-d H:i', $newValue);
if ($date !== false) {
$newValue = $date->format('Y-m-d H:i');
}
}
else {
// check if date is date or datetime
if (strpos($newValue, ' ') !== false) {
$newValue = substr($newValue, 0, 10);
if ($newValue !== '') {
if ($this->pPreferences->config['Optionen']['field_date_time_format'] === 'datetime') {
//check if date is datetime or only date
if (strpos($newValue, ' ') === false) {
$newValue .= ' 00:00';
}
$date = \DateTime::createFromFormat('Y-m-d H:i', $newValue);
if ($date !== false) {
$newValue = $date->format('Y-m-d H:i');
}
}
$date = \DateTime::createFromFormat('Y-m-d', $newValue);
if ($date !== false) {
$newValue = $date->format('Y-m-d');
else {
// check if date is date or datetime
if (strpos($newValue, ' ') !== false) {
$newValue = substr($newValue, 0, 10);
}
$date = \DateTime::createFromFormat('Y-m-d', $newValue);
if ($date !== false) {
$newValue = $date->format('Y-m-d');
}
}
}
}
Expand Down
44 changes: 44 additions & 0 deletions import/import_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require_once(__DIR__ . '/../../../adm_program/system/common.php');
require_once(__DIR__ . '/../common_function.php');
require_once(__DIR__ . '/../classes/items.php');
require_once(__DIR__ . '/../classes/configtable.php');

// Access only with valid login
require_once(__DIR__ . '/../../../adm_program/system/login_valid.php');
Expand All @@ -34,6 +35,9 @@
$startRow = 0;
$importedFields = array();

$pPreferences = new CConfigTablePIM();
$pPreferences->read();

// create array with all profile fields that where assigned to columns of the import file
foreach ($_POST as $formFieldId => $importFileColumn) {
if ($importFileColumn !== '' && $formFieldId !== 'admidio-csrf-token' && $formFieldId !== 'first_row') {
Expand Down Expand Up @@ -176,6 +180,46 @@
}
}
}
elseif($imfNameIntern === 'RECEIVED_ON' || $imfNameIntern === 'RECEIVED_BACK_ON') {
$val = $values[$imfNameIntern];
if ($val !== '') {
// date must be formatted
if ($pPreferences->config['Optionen']['field_date_time_format'] === 'datetime') {
//check if date is datetime or only date
if (strpos($val, ' ') === false) {
$val .= '00:00';
}
// check if date is wrong formatted
$dateObject = DateTime::createFromFormat('d.m.Y H:i', $val);
if ($dateObject instanceof DateTime) {
// convert date to correct format
$val = $dateObject->format('Y-m-d H:i');
}
// check if date is right formatted
$date = DateTime::createFromFormat('Y-m-d H:i', $val);
if ($date instanceof DateTime) {
$val = $date->format($gSettingsManager->getString('system_date').' '.$gSettingsManager->getString('system_time'));
}
}
else {
// check if date is date or datetime
if (strpos($val, ' ') !== false) {
$val = substr($val, 0, 10);
}
// check if date is wrong formatted
$dateObject = DateTime::createFromFormat('d.m.Y', $val);
if ($dateObject instanceof DateTime) {
// convert date to correct format
$val = $dateObject->format('Y-m-d');
}
// check if date is right formatted
$date = DateTime::createFromFormat('Y-m-d', $val);
if ($date instanceof DateTime) {
$htmlValue = $date->format($gSettingsManager->getString('system_date'));
}
}
}
}
else {
$val = $values[$imfNameIntern];
}
Expand Down