Skip to content

Commit

Permalink
refacotr: rewritten Format::dateTimeReadable usages
Browse files Browse the repository at this point in the history
* Use Format::dateTimeIntlReadable to replace all basic
  Format::dateTimeReadable usages (without specified formatting string).
  • Loading branch information
yookoala authored and SKuipers committed May 17, 2024
1 parent 22f7dd7 commit b847354
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 39 deletions.
18 changes: 9 additions & 9 deletions modules/Admissions/applicationFormView.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@
echo $form->getOutput();
return;
}

if ($public && !empty($account['timestampTokenExpire'])) {
echo Format::alert(__('Welcome back! You are accessing this page through a unique link sent to your email address {email}. Please keep this link secret to protect your personal details. This link will expire {expiry}.', ['email' => '<u>'.$account['email'].'</u>', 'expiry' => Format::relativeTime($account['timestampTokenExpire'])]), 'message');
}
}

$page->return->addReturns(['success1' => __('A new admissions account has been created for {email}', ['email' => $account['email'] ?? ''])]);

$formPayment = $container->get(FormPayment::class);

$criteria = $admissionsApplicationGateway->newQueryCriteria(true)
->sortBy('timestampCreated', 'ASC');

Expand All @@ -120,16 +120,16 @@
$table = DataTable::create('submissions');
$table->setTitle(__('Current Applications'));


$table->addColumn('student', __('Applicant'))->format(function ($values) {
return !empty($values['studentSurname'])
? Format::name('', $values['studentPreferredName'], $values['studentSurname'], 'Student')
: Format::small(__('N/A'));
: Format::small(__('N/A'));

});
$table->addColumn('formName', __('Application Form'));
$table->addColumn('status', __('Status'))->translatable();
$table->addColumn('timestampCreated', __('Date'))->width('20%')->format(Format::using('dateTimeReadable', 'timestampCreated'));
$table->addColumn('timestampCreated', __('Date'))->width('20%')->format(Format::using('dateTimeIntlReadable', 'timestampCreated'));

$table->modifyRows(function ($values, $row) {
if ($values['status'] == 'Incomplete') $row->addClass('warning');
Expand Down Expand Up @@ -182,7 +182,7 @@

if (count($forms) == 0) {
return;
}
}

// FORM
$form = Form::create('admissionsAccount', $session->get('absoluteURL').'/index.php?q=/modules/Admissions/applicationForm.php');
Expand All @@ -191,10 +191,10 @@
$form->setDescription((count($submissions) > 0 ? __('You may continue submitting applications with the form below and they will be linked to your account data.').' ' : '').__('Some information has been pre-filled for you, feel free to change this information as needed.'));

$form->setClass('w-full blank');

$form->addHiddenValue('address', $session->get('address'));
$form->addHiddenValue('accessID', $account['accessID'] ?? '');

// Display all available public forms
$firstForm = current($forms);
foreach ($forms as $index => $applicationForm) {
Expand Down
12 changes: 6 additions & 6 deletions modules/Admissions/applicationForm_payFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
// APPLICATION PROCESSING FEE
if ($processPaymentRequired) {
$form = Form::create('action', $session->get('absoluteURL').'/modules/Admissions/applicationForm_payFeeProcess.php');

$form->addHiddenValue('address', $session->get('address'));
$form->addHiddenValue('accessID', $accessID);
$form->addHiddenValue('gibbonFormID', $gibbonFormID);
Expand Down Expand Up @@ -132,10 +132,10 @@
$row = $form->addRow();
$row->addLabel('statusLabel', __('Status'));
$row->addTextField('status')->readOnly()->setValue($payment['status'] ?? __('Complete'));

$row = $form->addRow();
$row->addLabel('timestampLabel', __('Date Paid'));
$row->addTextField('timestamp')->readOnly()->setValue(Format::dateTimeReadable($payment['timestamp'] ?? ''));
$row->addTextField('timestamp')->readOnly()->setValue(Format::dateTimeIntlReadable($payment['timestamp'] ?? ''));

$row = $form->addRow();
$row->addLabel('gatewayLabel', __('Payment Gateway'));
Expand All @@ -149,7 +149,7 @@
// APPLICATION SUBMISSION FEE
if ($submitPaymentRequired) {
$form = Form::create('action', $session->get('absoluteURL').'/modules/Admissions/applicationForm_payFeeProcess.php');

$form->addHiddenValue('address', $session->get('address'));
$form->addHiddenValue('accessID', $accessID);
$form->addHiddenValue('gibbonFormID', $gibbonFormID);
Expand Down Expand Up @@ -177,10 +177,10 @@
$row = $form->addRow();
$row->addLabel('statusLabel', __('Status'));
$row->addTextField('status')->readOnly()->setValue($payment['status'] ?? __('Complete'));

$row = $form->addRow();
$row->addLabel('timestampLabel', __('Date Paid'));
$row->addTextField('timestamp')->readOnly()->setValue(Format::dateTimeReadable($payment['timestamp'] ?? ''));
$row->addTextField('timestamp')->readOnly()->setValue(Format::dateTimeIntlReadable($payment['timestamp'] ?? ''));

$row = $form->addRow();
$row->addLabel('gatewayLabel', __('Payment Gateway'));
Expand Down
4 changes: 2 additions & 2 deletions modules/Reports/archive_byReport_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
if ($archive) {
$tag = '<span class="tag ml-2 '.($archive['status'] == 'Final' ? 'success' : 'dull').'">'.__($archive['status']).'</span>';
$url = './modules/Reports/archive_byStudent_download.php?gibbonReportArchiveEntryID='.$archive['gibbonReportArchiveEntryID'].'&gibbonPersonID='.$report['gibbonPersonID'];
$title = Format::dateTimeReadable($archive['timestampModified']);
$title = Format::dateTimeIntlReadable($archive['timestampModified']);
$output .= Format::link($url, $title).$tag;
}

Expand Down Expand Up @@ -169,7 +169,7 @@
if ($archive) {
$tag = '<span class="tag ml-2 '.($archive['status'] == 'Final' ? 'success' : 'dull').'">'.__($archive['status']).'</span>';
$url = './modules/Reports/archive_byReport_download.php?gibbonReportArchiveEntryID='.$archive['gibbonReportArchiveEntryID'];
$title = Format::dateTimeReadable($archive['timestampModified']);
$title = Format::dateTimeIntlReadable($archive['timestampModified']);
return Format::link($url, $title).$tag;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/Reports/reports_generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
.'<img class="align-middle w-56 -mt-px" src="./themes/Default/img/loading.gif">'
.'<span class="tag ml-2 message">'.__('Running').'</span></div>';
}
return !empty($report['timestampGenerated'])? Format::dateTimeReadable($report['timestampGenerated']) : '';

return !empty($report['timestampGenerated'])? Format::dateTimeIntlReadable($report['timestampGenerated']) : '';
});

$table->addActionColumn()
Expand Down
2 changes: 1 addition & 1 deletion modules/Reports/reports_generate_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
$tag = '<span class="tag success ml-2">'.__('Complete').'</span>';
$tag .= '<span class="tag ml-2 '.($archive['status'] == 'Final' ? 'success' : 'dull').'">'.__($archive['status']).'</span>';
$url = './modules/Reports/archive_byReport_download.php?gibbonReportArchiveEntryID='.$archive['gibbonReportArchiveEntryID'];
$title = Format::dateTimeReadable($archive['timestampModified']);
$title = Format::dateTimeIntlReadable($archive['timestampModified']);
echo Format::link($url, $title).$tag;
}

Expand Down
10 changes: 5 additions & 5 deletions modules/Reports/reports_generate_batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@


$gibbonReportID = $_GET['gibbonReportID'] ?? '';

$reportGateway = $container->get(ReportGateway::class);
$reportArchiveEntryGateway = $container->get(ReportArchiveEntryGateway::class);

$report = $reportGateway->getByID($gibbonReportID);

if (empty($gibbonReportID) || empty($report)) {
$page->addError(__('The specified record cannot be found.'));
return;
Expand Down Expand Up @@ -122,7 +122,7 @@
if ($archive) {
$tag = '<span class="tag ml-2 '.($archive['status'] == 'Final' ? 'success' : 'dull').'">'.__($archive['status']).'</span>';
$url = './modules/Reports/archive_byReport_download.php?gibbonReportArchiveEntryID='.$archive['gibbonReportArchiveEntryID'];
$title = Format::dateTimeReadable($archive['timestampModified']);
$title = Format::dateTimeIntlReadable($archive['timestampModified']);
return Format::link($url, $title).$tag;
}

Expand All @@ -133,7 +133,7 @@
->addParam('gibbonReportID', $gibbonReportID)
->format(function ($report, $actions) use (&$logs) {
$reportLogs = $logs[$report['gibbonYearGroupID']] ?? [];

if (count($reportLogs) == 0) {
$actions->addAction('run', __('Run'))
->setIcon('run')
Expand Down
8 changes: 4 additions & 4 deletions modules/Reports/reports_generate_single.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
->add(__('Run'), 'reports_generate_batch.php', ['gibbonReportID' => $gibbonReportID])
->add(__('Single'));


$reportGateway = $container->get(ReportGateway::class);
$reportArchiveEntryGateway = $container->get(ReportArchiveEntryGateway::class);

Expand Down Expand Up @@ -106,14 +106,14 @@
->format(function ($report) use ($gibbonReportID, &$reportArchiveEntryGateway) {
if ($report['archive']) {
$tag = '<span class="tag ml-2 '.($report['archive']['status'] == 'Final' ? 'success' : 'dull').'">'.__($report['archive']['status']).'</span>';
$title = Format::dateTimeReadable($report['archive']['timestampModified']);
$title = Format::dateTimeIntlReadable($report['archive']['timestampModified']);
$url = './modules/Reports/archive_byStudent_download.php?gibbonReportArchiveEntryID='.$report['archive']['gibbonReportArchiveEntryID'].'&gibbonPersonID='.$report['gibbonPersonID'];
return Format::link($url, $title).$tag;
}

return '';
});

$debugMode = $container->get(SettingGateway::class)->getSettingByScope('Reports', 'debugMode');

$table->addActionColumn()
Expand All @@ -134,7 +134,7 @@
->addParam('gibbonPersonID', $report['gibbonPersonID'] ?? '')
->addParam('gibbonReportArchiveEntryID', $report['archive']['gibbonReportArchiveEntryID'] ?? '')
->setURL('/modules/Reports/archive_byStudent_download.php');

$actions->addAction('download', __('Download'))
->directLink()
->setIcon('download')
Expand Down
4 changes: 2 additions & 2 deletions modules/Reports/reports_manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
if (!empty($gibbonSchoolYearID)) {
$page->navigator->addSchoolYearNavigation($gibbonSchoolYearID);
}

$reportGateway = $container->get(ReportGateway::class);

// QUERY
Expand Down Expand Up @@ -73,7 +73,7 @@
});

$table->addColumn('accessDate', __('Go Live'))
->format(Format::using('dateTimeReadable', 'accessDate'));
->format(Format::using('dateTimeIntlReadable', 'accessDate'));

$table->addActionColumn()
->addParam('gibbonSchoolYearID', $gibbonSchoolYearID)
Expand Down
4 changes: 2 additions & 2 deletions modules/Reports/reports_send.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
$table->addColumn('timestampModified', __('Last Created'))
->format(function ($report) {
$tag = '<span class="tag ml-2 success">'.__('Final').'</span>';
return Format::dateTimeReadable($report['timestampModified']).$tag;
return Format::dateTimeIntlReadable($report['timestampModified']).$tag;
});

$table->addActionColumn()
Expand Down Expand Up @@ -107,7 +107,7 @@

if ($archive) {
$tag = '<span class="tag ml-2 '.($archive['status'] == 'Final' ? 'success' : 'dull').'">'.__($archive['status']).'</span>';
return Format::dateTimeReadable($archive['timestampModified']).$tag;
return Format::dateTimeIntlReadable($archive['timestampModified']).$tag;
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion modules/Reports/reports_send_batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
->format(function ($report) {

$tag = '<span class="tag ml-2 '.($report['status'] == 'Final' ? 'success' : 'dull').'">'.__($report['status']).'</span>';
$title = Format::dateTimeReadable($report['timestampModified']);
$title = Format::dateTimeIntlReadable($report['timestampModified']);
$url = './modules/Reports/archive_byStudent_download.php?gibbonReportArchiveEntryID='.$report['gibbonReportArchiveEntryID'].'&gibbonPersonID='.$report['gibbonPersonID'];
return Format::link($url, $title).$tag;
});
Expand Down
2 changes: 1 addition & 1 deletion modules/Staff/src/Messages/AbsenceApproval.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getText() : string
public function getDetails() : array
{
return [
__($this->absence['status']) => Format::dateTimeReadable($this->absence['timestampApproval']),
__($this->absence['status']) => Format::dateTimeIntlReadable($this->absence['timestampApproval']),
__('Reply') => $this->absence['notesApproval'],
];
}
Expand Down
2 changes: 1 addition & 1 deletion modules/User Admin/user_manage_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

$row = $form->addRow();
$row->addLabel('lastTimestampLabel', __('Last Login: Time'));
$row->addTextField('lastTimestamp')->setValue(Format::dateTimeReadable($values['lastTimestamp']))->setClass('w-64')->readonly();
$row->addTextField('lastTimestamp')->setValue(Format::dateTimeIntlReadable($values['lastTimestamp']))->setClass('w-64')->readonly();
$row->addContent(!empty($values['lastTimestamp'])? $trueIcon : $falseIcon);

$row = $form->addRow();
Expand Down
6 changes: 3 additions & 3 deletions src/Forms/Builder/View/ApplicationCheckView.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class ApplicationCheckView extends AbstractFormView
{
protected $session;

public function __construct(Session $session)
{
$this->session = $session;
Expand All @@ -43,7 +43,7 @@ public function getName() : string

public function configure(Form $form)
{

}

public function display(Form $form, FormDataInterface $data)
Expand All @@ -52,7 +52,7 @@ public function display(Form $form, FormDataInterface $data)
$col->addSubheading($this->getName());

$list[__('Status')] = $data->getStatus();
$list[__('Date')] = Format::dateTimeReadable($data->getResult('statusDate'));
$list[__('Date')] = Format::dateTimeIntlReadable($data->getResult('statusDate'));

$col->addContent(Format::listDetails($list));

Expand Down

0 comments on commit b847354

Please sign in to comment.