Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c3d49e

Browse files
committed
Ooified the import history table, updated strings
1 parent 20ba569 commit 0c3d49e

File tree

5 files changed

+54
-73
lines changed

5 files changed

+54
-73
lines changed

Data Admin/export_run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
return;
6060
} elseif (!$importType->isValid()) {
6161
echo "<div class='error'>";
62-
echo __('Import cannot proceed, there was an error reading the import file type {type}.', ['type' => $type]);
62+
echo __('There was an error reading the file {value}.', ['value' => $type]);
6363
echo "<br/></div>";
6464
return;
6565
}

Data Admin/import_history.php

Lines changed: 47 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
*/
1919

2020
use Gibbon\Data\ImportType;
21+
use Gibbon\Tables\DataTable;
22+
use Gibbon\Domain\DataSet;
23+
use Gibbon\Domain\System\LogGateway;
24+
use Gibbon\Services\Format;
2125

2226
// Module Bootstrap
2327
require __DIR__ . '/module.php';
@@ -28,76 +32,51 @@
2832
echo __("You do not have access to this action.") ;
2933
echo "</div>" ;
3034
} else {
31-
$page->breadcrumbs->add(__('View Import History', 'Data Admin'));
32-
33-
echo "<h3>" ;
34-
echo __("Import History", 'Data Admin') ;
35-
echo "</h3>" ;
35+
$page->breadcrumbs->add(__('View Import History'));
3636

3737
// Get a list of available import options
3838
$importTypeList = ImportType::loadImportTypeList($pdo, false);
3939

40-
$sql = "SELECT gibbonLog.*, gibbonPerson.username, gibbonPerson.surname, gibbonPerson.preferredName
41-
FROM gibbonLog
42-
JOIN gibbonPerson ON (gibbonPerson.gibbonPersonID=gibbonLog.gibbonPersonID)
43-
WHERE gibbonLog.title LIKE 'Import -%'";
44-
45-
$result=$pdo->executeQuery(array(), $sql);
46-
47-
if (empty($importTypeList) || $result->rowCount()<1) {
48-
echo "<div class='error'>" ;
49-
echo __("There are no records to display.") ;
50-
echo "</div>" ;
51-
} else {
52-
echo "<table class='fullWidth colorOddEven' cellspacing='0'>" ;
53-
echo "<tr class='head'>" ;
54-
echo "<th style='width: 100px;'>" ;
55-
echo __("Date") ;
56-
echo "</th>" ;
57-
echo "<th>" ;
58-
echo __("User") ;
59-
echo "</th>" ;
60-
echo "<th style='width: 80px;'>" ;
61-
echo __("Category") ;
62-
echo "</th>" ;
63-
echo "<th >" ;
64-
echo __("Import Type", 'Data Admin') ;
65-
echo "</th>" ;
66-
echo "<th>" ;
67-
echo __("Details") ;
68-
echo "</th>" ;
69-
echo "<th>" ;
70-
echo __("Actions") ;
71-
echo "</th>" ;
72-
echo "</tr>" ;
73-
74-
while ($row=$result->fetch()) {
75-
$data = isset($row['serialisedArray'])? unserialize($row['serialisedArray']) : [];
76-
if (!isset($importTypeList[ $data['type'] ])) {
77-
continue;
78-
} // Skip invalid import types
79-
80-
echo "<tr class='".($data['success'] == false? 'error' : '')."'>" ;
81-
$importType = $importTypeList[ $data['type'] ];
82-
83-
echo "<td>";
84-
printf("<span title='%s'>%s</span> ", $row['timestamp'], date('M j, Y', strtotime($row['timestamp'])));
85-
echo "</td>";
86-
87-
echo "<td>";
88-
echo $row['preferredName'].' '.$row['surname'];
89-
echo "</td>";
90-
91-
echo "<td>" . $importType->getDetail('category'). "</td>" ;
92-
echo "<td>" . $importType->getDetail('name'). "</td>" ;
93-
echo "<td>" .(($data['success'] == true)? 'Success' : 'Failed'). "</td>";
94-
95-
echo "<td>";
96-
echo "<a class='thickbox' href='" . $_SESSION[$guid]["absoluteURL"] . "/fullscreen.php?q=/modules/" . $_SESSION[$guid]["module"] . "/import_history_view.php&gibbonLogID=" . $row['gibbonLogID'] . "&width=600&height=550'><img title='" . __('View Details') . "' src='./themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/plus.png'/></a> " ;
97-
echo "</td>";
98-
99-
echo "</tr>" ;
100-
}
101-
echo "</table>" ;
102-
}
40+
$logGateway = $container->get(LogGateway::class);
41+
$logsByType = $logGateway->selectLogsByModuleAndTitle('System Admin', 'Import - %')->fetchAll();
42+
43+
$logsByType = array_map(function ($log) use (&$importTypeList) {
44+
$log['data'] = isset($log['serialisedArray'])? unserialize($log['serialisedArray']) : [];
45+
$log['importType'] = @$importTypeList[$log['data']['type']];
46+
return $log;
47+
}, $logsByType);
48+
49+
$table = DataTable::create('importHistory');
50+
$table->setTitle(__('Import History'));
51+
52+
$table->addColumn('timestamp', __('Date'))
53+
->format(Format::using('dateTime', 'timestamp'));
54+
55+
$table->addColumn('user', __('User'))
56+
->format(Format::using('name', ['', 'preferredName', 'surname', 'Staff', false, true]));
57+
58+
$table->addColumn('category', __('Category'))
59+
->format(function ($log) {
60+
return $log['importType']->getDetail('category');
61+
});
62+
63+
$table->addColumn('name', __('Name'))
64+
->format(function ($log) {
65+
return $log['importType']->getDetail('name');
66+
});
67+
68+
$table->addColumn('details', __('Details'))
69+
->format(function ($log) {
70+
return !empty($log['data']['success']) ? __('Success') : __('Failed');
71+
});
72+
73+
$table->addActionColumn()
74+
->addParam('gibbonLogID')
75+
->format(function ($importType, $actions) {
76+
$actions->addAction('view', __('View'))
77+
->isModal('600', '550')
78+
->setURL('/modules/Data Admin/import_history_view.php');
79+
});
80+
81+
echo $table->render(new DataSet($logsByType));
10382
}

Data Admin/import_manage.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
echo __("You do not have access to this action.") ;
3434
echo "</div>" ;
3535
} else {
36-
$page->breadcrumbs->add(__('Import From File', 'Data Admin'));
36+
$page->breadcrumbs->add(__('Import From File'));
3737

3838
$logGateway = $container->get(LogGateway::class);
3939
$logsByType = $logGateway->selectLogsByModuleAndTitle('System Admin', 'Import - %')->fetchGrouped();
@@ -43,6 +43,7 @@
4343
// Get a list of available import options
4444
$importTypeList = ImportType::loadImportTypeList($pdo, false);
4545

46+
// Build an array of combined import type info and log data
4647
$importTypeGroups = array_reduce($importTypeList, function ($group, $importType) use ($checkUserPermissions, $guid, $connection2, $logsByType) {
4748
if ($importType->isValid()) {
4849
$type = $importType->getDetail('type');
@@ -62,7 +63,7 @@
6263
}, []);
6364

6465
foreach ($importTypeGroups as $importGroupName => $importTypes) {
65-
$table = DataTable::create('rollGroups');
66+
$table = DataTable::create('imports');
6667
$table->setTitle(__($importGroupName));
6768

6869
$table->addColumn('category', __('Category'))

Data Admin/import_run.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
echo Format::alert(__('Your request failed because your inputs were invalid.'));
6262
return;
6363
} elseif (!$importType->isValid()) {
64-
echo Format::alert(__('Import cannot proceed, there was an error reading the import file type {type}.', ['type' => $type]));
64+
echo Format::alert(__('There was an error reading the file {value}.', ['value' => $type]));
6565
return;
6666
}
6767

@@ -217,7 +217,7 @@
217217
$firstLine = $importer->getFirstRow();
218218

219219
if (empty($csvData) || empty($headings) || empty($firstLine)) {
220-
echo Format::alert(__('Import cannot proceed, there was an error reading the import file type {type}.', ['type' => $_FILES['file']['name']]));
220+
echo Format::alert(__('There was an error reading the file {value}.', ['value' => $_FILES['file']['name']]));
221221
return;
222222
}
223223

Data Admin/src/DatabaseTools.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespace Gibbon\Module\DataAdmin;
2121

2222
use Gibbon\Contracts\Database\Connection;
23+
use Gibbon\Data\ImportType;
2324

2425
/**
2526
* Database Tools class

0 commit comments

Comments
 (0)