Skip to content

Commit

Permalink
v1.5.03
Browse files Browse the repository at this point in the history
  • Loading branch information
SKuipers committed Sep 11, 2023
1 parent 02f25f0 commit 83e9c1d
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Trip Planner/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,10 @@
$sql[$count][0]="1.5.02";
$sql[$count][1]="
";

$count++;
$sql[$count][0]="1.5.03";
$sql[$count][1]="
INSERT INTO gibbonAction SET name='Trip Archive', precedence=0, category='Trips', description='Gives users read-only access to past trips.', URLList='trips_archive.php,trips_archiveView.php', entryURL='trips_archive.php', defaultPermissionAdmin='Y', defaultPermissionTeacher='N', defaultPermissionStudent='N', defaultPermissionParent='N', defaultPermissionSupport='N', categoryPermissionStaff='Y', categoryPermissionStudent='N', categoryPermissionParent='N', categoryPermissionOther='N', gibbonModuleID=(SELECT gibbonModuleID FROM gibbonModule WHERE name='Trip Planner');end
INSERT INTO `gibbonPermission` (`permissionID` ,`gibbonRoleID` ,`gibbonActionID`) VALUES (NULL , '1', (SELECT gibbonActionID FROM gibbonAction JOIN gibbonModule ON (gibbonAction.gibbonModuleID=gibbonModule.gibbonModuleID) WHERE gibbonModule.name='Trip Planner' AND gibbonAction.name='Trip Archive'));end
";
4 changes: 4 additions & 0 deletions Trip Planner/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
CHANGELOG
=========
v1.5.03
-------
Added a Trip Archive page for accessing past trips

v1.5.02
-------
Added a better status message when viewing a rejected trip
Expand Down
19 changes: 17 additions & 2 deletions Trip Planner/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$entryURL = "trips_manage.php";
$type = "Additional";
$category = "Learn";
$version = "1.5.02";
$version = "1.5.03";
$author = "Ray Clark";
$url = "https://github.com/GibbonEdu/module-tripPlanner";

Expand Down Expand Up @@ -283,4 +283,19 @@
$actionRows[$actionCount]["categoryPermissionOther"] = "N";
$actionCount++;

?>
$actionRows[$actionCount]["name"] = "Trip Archive";
$actionRows[$actionCount]["precedence"] = "0";
$actionRows[$actionCount]["category"] = "Trips";
$actionRows[$actionCount]["description"] = "Gives users read-only access to past trips.";
$actionRows[$actionCount]["URLList"] = "trips_archive.php,trips_archiveView.php";
$actionRows[$actionCount]["entryURL"] = "trips_archive.php";
$actionRows[$actionCount]["defaultPermissionAdmin"] = "Y";
$actionRows[$actionCount]["defaultPermissionTeacher"] = "N";
$actionRows[$actionCount]["defaultPermissionStudent"] = "N";
$actionRows[$actionCount]["defaultPermissionParent"] = "N";
$actionRows[$actionCount]["defaultPermissionSupport"] = "N";
$actionRows[$actionCount]["categoryPermissionStaff"] = "Y";
$actionRows[$actionCount]["categoryPermissionStudent"] = "N";
$actionRows[$actionCount]["categoryPermissionParent"] = "N";
$actionRows[$actionCount]["categoryPermissionOther"] = "N";
$actionCount++;
13 changes: 8 additions & 5 deletions Trip Planner/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function tripCommentNotifications($tripPlannerRequestID, $gibbonPersonID, $tripL

/**
*/
function renderTrip(ContainerInterface $container, $tripPlannerRequestID, $approveMode, $readOnly = false) {
function renderTrip(ContainerInterface $container, $tripPlannerRequestID, $approveMode, $readOnly = false, $showLogs = true) {
global $gibbon;

$gibbonPersonID = $gibbon->session->get('gibbonPersonID');
Expand Down Expand Up @@ -465,11 +465,13 @@ function toggleSection(&$row, $section, $icon) {
->setValue(Format::currency($totalCost))
->readOnly();

$row = $form->addRow();
$row->addHeading(__('Log'));
toggleSection($row, 'logs', $on);
if ($showLogs) {

$row = $form->addRow();
$row->addHeading(__('Log'));
toggleSection($row, 'logs', $on);

$row = $form->addRow()->addClass('logs');
$row = $form->addRow()->addClass('logs');

$tripLogGateway = $container->get(TripLogGateway::class);
$logCiteria = $tripLogGateway->newQueryCriteria()
Expand Down Expand Up @@ -498,6 +500,7 @@ function toggleSection(&$row, $section, $icon) {
$table->addColumn('action', __('Event'));

$row->addContent($table->render($tripLogGateway->queryLogs($logCiteria)));
}

if ($approveMode) {
$row = $form->addRow();
Expand Down
100 changes: 100 additions & 0 deletions Trip Planner/trips_archive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Domain\Departments\DepartmentGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Form;
use Gibbon\Module\TripPlanner\Domain\ApproverGateway;
use Gibbon\Module\TripPlanner\Domain\TripGateway;
use Gibbon\Services\Format;
use Gibbon\Tables\DataTable;
use Gibbon\Forms\DatabaseFormFactory;

require_once __DIR__ . '/moduleFunctions.php';

$page->breadcrumbs->add(__('Trip Archive'));

if (!isActionAccessible($guid, $connection2, '/modules/Trip Planner/trips_archive.php')) {
$page->addError(__('You do not have access to this action.'));
} else {
$gibbonPersonID = $session->get('gibbonPersonID');

//Settings
$settingGateway = $container->get(SettingGateway::class);

$expiredUnapproved = $settingGateway->getSettingByScope('Trip Planner', 'expiredUnapprovedFilter');

// Select school year
$gibbonSchoolYearID = $_REQUEST['gibbonSchoolYearID'] ?? $session->get('gibbonSchoolYearID');
$page->navigator->addSchoolYearNavigation($gibbonSchoolYearID);

//Trips Data
$tripGateway = $container->get(TripGateway::class);
$criteria = $tripGateway->newQueryCriteria(true)
->sortBy('firstDayOfTrip', 'DESC')
->filterBy('showActive', 'Y')
->filterBy('status', 'Approved')
->fromPOST();

$trips = $tripGateway->queryTrips($criteria, $gibbonSchoolYearID, null, null, $expiredUnapproved);

//Trips Table
$table = DataTable::createPaginated('trips', $criteria);
$table->setTitle(__('Past Trips'));

$table->modifyRows(function (&$trip, $row) {
if ($trip['status'] == 'Approved') $row->addClass('success');
if ($trip['status'] == 'Draft') $row->addClass('dull');
if ($trip['status'] == 'Awaiting Final Approval') $row->addClass('message');
if ($trip['status'] == 'Rejected' || $trip['status'] == 'Cancelled') $row->addClass('dull');

return $row;
});

$table->addMetaData('post', ['gibbonSchoolYearID' => $gibbonSchoolYearID]);

$table->addExpandableColumn('contents')
->format(function ($trip) {
return formatExpandableSection(__('Description'), $trip['description']);
});

$table->addColumn('tripTitle', __('Title'))
->format(function ($trip) {
return $trip['tripTitle'];
});

$table->addColumn('owner', __('Owner'))
->format(Format::using('name', ['title', 'preferredName', 'surname', 'Staff', false, true]))
->sortable('surname');

$table->addColumn('firstDayOfTrip', __('First Day of Trip'))
->format(Format::using('dateReadable', ['firstDayOfTrip']));

$table->addActionColumn()
->addParam('tripPlannerRequestID')
->addParam('gibbonSchoolYearID', $gibbonSchoolYearID)
->format(function ($trip, $actions) {
if ($trip['status'] != 'Approved') return;

$actions->addAction('view', __('View Details'))
->setURL('/modules/Trip Planner/trips_archiveView.php');
});

echo $table->render($trips);
}
41 changes: 41 additions & 0 deletions Trip Planner/trips_archiveView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Module\TripPlanner\Domain\TripGateway;

require_once __DIR__ . '/moduleFunctions.php';

$page->breadcrumbs
->add(__('Trip Archive'), 'trips_archive.php')
->add(__('View Request'));

if (!isActionAccessible($guid, $connection2, '/modules/Trip Planner/trips_archiveView.php')) {
$page->addError(__('You do not have access to this action.'));
} else {
$tripPlannerRequestID = $_GET['tripPlannerRequestID'] ?? '';

$tripGateway = $container->get(TripGateway::class);

if (empty($tripPlannerRequestID) || !$tripGateway->exists($tripPlannerRequestID)) {
$page->addError('No request selected.');
return;
}

renderTrip($container, $tripPlannerRequestID, false, true, false);
}
4 changes: 3 additions & 1 deletion Trip Planner/trips_manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

//Filters
$gibbonDepartmentID = $_POST['gibbonDepartmentID'] ?? [];
$gibbonSchoolYearID = $_POST['gibbonSchoolYearID'] ?? $session->get('gibbonSchoolYearID');
$gibbonSchoolYearID = $_REQUEST['gibbonSchoolYearID'] ?? $session->get('gibbonSchoolYearID');

//Filter Form
$form = Form::create('tripFilters', $gibbon->session->get('absoluteURL') . '/index.php?q=' . $_GET['q']);
Expand Down Expand Up @@ -139,6 +139,7 @@

$filters['showActive:Y'] = __m('Upcoming / Approved Trips');

$table->addMetaData('post', ['gibbonSchoolYearID' => $gibbonSchoolYearID]);
$table->addMetaData('filterOptions', $filters);

$table->addHeaderAction('add', __('Submit Request'))
Expand Down Expand Up @@ -173,6 +174,7 @@

$table->addActionColumn()
->addParam('tripPlannerRequestID')
->addParam('gibbonSchoolYearID', $gibbonSchoolYearID)
->format(function ($trip, $actions) use ($container, $gibbonPersonID, $highestAction) {
$actions->addAction('view', __('View Details'))
->setURL('/modules/Trip Planner/trips_requestView.php');
Expand Down
2 changes: 1 addition & 1 deletion Trip Planner/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
/**
* Sets version information
*/
$moduleVersion = "1.5.02";
$moduleVersion = "1.5.03";
$coreVersion = '24.0.00';

0 comments on commit 83e9c1d

Please sign in to comment.