Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new timetable logic #1850

Open
wants to merge 2 commits into
base: v28.0.00
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,3 +832,26 @@
UPDATE gibbonCountry SET iddCountryCode='850' WHERE printable_name='Korea, Democratic People\'s Republic of';end
UPDATE `gibboni18n` SET `active` = 'Y' WHERE `code` = 'el_GR';end
";

//v28.0.01
++$ount;
$sql[$count[0]] = '28.0.01';
$sql[$count[1]] = "
ALTER TABLE `gibboncourse` ADD COLUMN `gibbonSchoolYearTermIDList` TEXT NOT NULL AFTER `gibbonYearGroupIDList`;end
CREATE TABLE `gibboncourseclassslot` (
`gibbonCourseClassSlotID` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT,
`gibbonCourseClassID` int(8) unsigned zerofill NOT NULL,
`gibbonSpaceID` int(10) unsigned zerofill DEFAULT NULL,
`locationExternal` varchar(50) NOT NULL,
`gibbonDaysOfWeekID` int(2) unsigned zerofill NOT NULL,
`timeStart` time NOT NULL,
`timeEnd` time NOT NULL,
PRIMARY KEY (`gibbonCourseClassSlotID`)
) ENGINE=InnoDB AUTO_INCREMENT=1535 DEFAULT CHARSET=utf8;end
CREATE TABLE `gibboncourseclassslotexception` (
`gibbonCourseClassSlotExceptionID` int(14) unsigned zerofill NOT NULL AUTO_INCREMENT,
`gibbonCourseClassSlotID` int(12) unsigned zerofill NOT NULL,
`gibbonPersonID` int(10) unsigned zerofill NOT NULL,
PRIMARY KEY (`gibbonCourseClassSlotExceptionID`)
) ENGINE=InnoDB AUTO_INCREMENT=1564 DEFAULT CHARSET=utf8;end
";
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@
'jquery-time' => 'lib/jquery-timepicker/jquery.timepicker.min.js',
'jquery-chained' => 'lib/chained/jquery.chained.min.js',
'core' => 'resources/assets/js/core.min.js',
// 'timetable-util' => 'resources/assets/timetable/util.js',
// 'timetable-weekly' => 'resources/assets/timetable/weekly-schedule.min.js',

], ['context' => 'head']);

// Set page scripts: foot - jquery
Expand Down Expand Up @@ -389,6 +392,7 @@

$page->stylesheets->add('theme-dev', 'resources/assets/css/theme.min.css');
$page->stylesheets->add('core', 'resources/assets/css/core.min.css', ['weight' => 10]);
$page->stylesheets->add('timetable', 'resources/assets/timetable/timetable.css');

/**
* USER CONFIGURATION
Expand Down
54 changes: 54 additions & 0 deletions modules/Timetable Admin/courseException_manage_class_delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/*
Gibbon: the flexible, open school platform
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/)
Copyright © 2010, Gibbon Foundation
Gibbon™, Gibbon Education Ltd. (Hong Kong)

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\Forms\Prefab\DeleteForm;

if (isActionAccessible($guid, $connection2, '/modules/Timetable Admin/courseEnrolment_manage_class_edit_delete.php') == false) {
// Access denied
$page->addError(__('You do not have access to this action.'));
} else {
//Proceed
$gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? '';
$gibbonCourseID = $_GET['gibbonCourseID'] ?? '';
$gibbonSchoolYearID = $_GET['gibbonSchoolYearID'] ?? '';
$gibbonCourseClassSlotExceptionID = $_GET['gibbonCourseClassSlotExceptionID'] ?? '';
$search = $_GET['search'] ?? '';

if ($gibbonCourseClassSlotExceptionID == '' or $gibbonCourseClassID == '' or $gibbonCourseID == '' or $gibbonSchoolYearID == '') {
$page->addError(__('You have not specified one or more required parameters.'));
} else {

$data = array('gibbonCourseClassSlotExceptionID' => $gibbonCourseClassSlotExceptionID);
$sql = 'SELECT * FROM gibbonCourseClassSlotException
WHERE gibbonCourseClassSlotException.gibbonCourseClassSlotExceptionID=:gibbonCourseClassSlotExceptionID';
$result = $connection2->prepare($sql);
$result->execute($data);

if ($result->rowCount() != 1) {
$page->addError(__('The specified record cannot be found.'));
} else {
//Let's go!
$row = $result->fetch();
$form = DeleteForm::createForm($session->get('absoluteURL').'/modules/'.$session->get('module')."/courseException_manage_class_deleteProcess.php?gibbonCourseClassID=$gibbonCourseClassID&gibbonCourseID=$gibbonCourseID&gibbonSchoolYearID=$gibbonSchoolYearID&gibbonCourseClassSlotExceptionID=$gibbonCourseClassSlotExceptionID&search=$search");
echo $form->getOutput();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/*
Gibbon: the flexible, open school platform
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/)
Copyright © 2010, Gibbon Foundation
Gibbon™, Gibbon Education Ltd. (Hong Kong)

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/>.
*/

include '../../gibbon.php';

$gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? '';
$gibbonCourseID = $_GET['gibbonCourseID'] ?? '';
$gibbonSchoolYearID = $_GET['gibbonSchoolYearID'] ?? '';
$gibbonCourseClassSlotExceptionID = $_GET['gibbonCourseClassSlotExceptionID'] ?? '';
$search = $_GET['search'] ?? '';

if ($gibbonCourseClassID == '' or $gibbonCourseID == '' or $gibbonSchoolYearID == '' or $gibbonCourseClassSlotExceptionID == '') { echo 'Fatal error loading this page!';
} else {
$URL = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_POST['address'])."/courseException_manage_class_edit.php&gibbonCourseID=$gibbonCourseID&gibbonCourseClassSlotExceptionID=$gibbonCourseClassSlotExceptionID&gibbonSchoolYearID=$gibbonSchoolYearID&gibbonCourseClassID=$gibbonCourseClassID";
$URLDelete = $session->get('absoluteURL').'/index.php?q=/modules/'.getModuleName($_POST['address'])."/courseException_manage_class_edit.php&gibbonCourseID=$gibbonCourseID&gibbonCourseClassID=$gibbonCourseClassID&gibbonSchoolYearID=$gibbonSchoolYearID&search=$search";

if (isActionAccessible($guid, $connection2, '/modules/Timetable Admin/courseEnrolment_manage_class_edit_delete.php') == false) {
$URL .= '&return=error0';
header("Location: {$URL}");
} else {
//Proceed!
//Check if gibbonCourseClassSlotExceptionID specified
if ($gibbonCourseClassSlotExceptionID == '') {
$URL .= '&return=error1';
header("Location: {$URL}");
} else {
try {
$data = array('gibbonCourseClassSlotExceptionID' => $gibbonCourseClassSlotExceptionID);
$sql = 'SELECT *
FROM gibbonCourseClassSlotException
WHERE gibbonCourseClassSlotException.gibbonCourseClassSlotExceptionID=:gibbonCourseClassSlotExceptionID';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$URL .= '&return=error2';
header("Location: {$URL}");
exit();
}

if ($result->rowCount() != 1) {
$URL .= '&return=error2';
header("Location: {$URL}");
} else {
//Write to database
try {
$data = array('gibbonCourseClassSlotExceptionID' => $gibbonCourseClassSlotExceptionID);
$sql = 'DELETE FROM gibbonCourseClassSlotException WHERE gibbonCourseClassSlotExceptionID=:gibbonCourseClassSlotExceptionID';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$URL .= '&return=error2';
header("Location: {$URL}");
exit();
}

$URLDelete = $URLDelete.'&return=success0';
header("Location: {$URLDelete}");
}
}
}
}
161 changes: 161 additions & 0 deletions modules/Timetable Admin/courseException_manage_class_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?php
/*
Gibbon: the flexible, open school platform
Founded by Ross Parker at ICHK Secondary. Built by Ross Parker, Sandra Kuipers and the Gibbon community (https://gibbonedu.org/about/)
Copyright © 2010, Gibbon Foundation
Gibbon™, Gibbon Education Ltd. (Hong Kong)

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\Http\Url;
use Gibbon\Forms\Form;
use Gibbon\Services\Format;
use Gibbon\Tables\DataTable;
use Gibbon\Domain\QueryCriteria;
use Gibbon\Domain\Timetable\CourseClassGateway;
use Gibbon\Domain\User\UserGateway;
use Gibbon\Forms\Prefab\BulkActionForm;
use Gibbon\Domain\Timetable\CourseEnrolmentGateway;
use Gibbon\Domain\Timetable\CourseGateway;

if (isActionAccessible($guid, $connection2, '/modules/Timetable Admin/courseEnrolment_manage_class_edit.php') == false) {
// Access denied
$page->addError(__('You do not have access to this action.'));
} else {
//Check if gibbonCourseID, gibbonSchoolYearID, and gibbonCourseClassID specified
$gibbonCourseClassID = $_GET['gibbonCourseClassID'] ?? '';
$gibbonCourseID = $_GET['gibbonCourseID'] ?? '';
$gibbonSchoolYearID = $_GET['gibbonSchoolYearID'] ?? '';
$search = $_GET['search'] ?? '';
$urlParams = compact('gibbonSchoolYearID', 'search');


if (empty($gibbonCourseID) or empty($gibbonSchoolYearID) or empty($gibbonCourseClassID)) {
$page->addError(__('You have not specified one or more required parameters.'));
} else {
$userGateway = $container->get(UserGateway::class);
$courseGateway = $container->get(CourseGateway::class);
$courseEnrolmentGateway = $container->get(CourseEnrolmentGateway::class);
$courseClassGateway = $container->get(CourseClassGateway::class);

$values = $courseGateway->getCourseClassByID($gibbonCourseClassID);

if (empty($values)) {
$page->addError(__('The specified record cannot be found.'));
} else {
//Let's go!
$page->breadcrumbs
->add(__('Manage Courses & Classes'), 'course_manage.php', $urlParams)
->add(__('Edit Course & Classes'), 'course_manage_edit.php', $urlParams + ['gibbonCourseID' => $gibbonCourseID])
->add(__('Edit Exception'));

//Report minimum/maximum enrolment messages
if (is_numeric($values['enrolmentMin']) && $values['studentsTotal'] < $values['enrolmentMin']) {
$page->addWarning(__('This class is currently under enrolled, based on a minimum enrolment of {enrolmentMin} students.', ['enrolmentMin' => $values['enrolmentMin']]));
}
if (is_numeric($values['enrolmentMax']) && $values['studentsTotal'] > $values['enrolmentMax']) {
$page->addError(__('This class is currently over enrolled, based on a maximum enrolment of {enrolmentMax} students.', ['enrolmentMax' => $values['enrolmentMax']]));
}

if (!empty($search)) {
$page->navigator->addSearchResultsAction(Url::fromModuleRoute('Timetable Admin', 'course_manage.php')->withQueryParams($urlParams));
}
echo '<h2>';
echo __('Add Exceptions');
echo '</h2>';

$form = Form::create('manageException', $session->get('absoluteURL').'/modules/'.$session->get('module')."/courseException_manage_class_editProcessBulk.php?gibbonCourseClassID=$gibbonCourseClassID&gibbonCourseID=$gibbonCourseID&gibbonSchoolYearID=$gibbonSchoolYearID&search=$search");

$form->addHiddenValue('address', $session->get('address'));
$form->addHiddenValue('gibbonCourseID', $gibbonCourseID);
$form->addHiddenValue('gibbonCourseClassID', $gibbonCourseClassID);
$form->addHiddenValue('gibbonSchoolYearID', $gibbonSchoolYearID);
$form->addHiddenValue('search', $search);

$people = array();

$participants = array();
try {
$dataSelect = array('gibbonCourseClassID' => $gibbonCourseClassID);
$sqlSelect = "SELECT gibbonPerson.gibbonPersonID, preferredName, surname , gibbonCourseClassPerson.role
FROM gibbonPerson
JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID)
LEFT JOIN gibbonCourseClassSlotException ON (gibbonCourseClassSlotException.gibbonPersonID=gibbonPerson.gibbonPersonID)
WHERE gibbonCourseClassID=:gibbonCourseClassID
AND NOT role='Student - Left'
AND NOT role='Teacher - Left'
AND NOT gibbonPerson.status='Left'
ORDER BY surname, preferredName";
$resultSelect = $connection2->prepare($sqlSelect);
$resultSelect->execute($dataSelect);
} catch (PDOException $e) {
}
while ($rowSelect = $resultSelect->fetch()) {
$participants[$rowSelect['gibbonPersonID']] = Format::name('', htmlPrep($rowSelect['preferredName']), htmlPrep($rowSelect['surname']), 'Student', true) . ' (' . __($rowSelect['role'] . ')');
}

$row = $form->addRow();
$row->addLabel('Members', __('Participants'));
$row->addSelect('Members')->fromArray($participants)->selectMultiple()->required()->setSize(8);

$slots = array();
try{
$dataSelect = array('gibbonCourseClassID' => $gibbonCourseClassID);
$query = "SELECT gibbonCourseClassSlot.gibbonCourseClassSlotID, gibbonCourseClassSlot.timeStart, gibbonCourseClassSlot.timeEnd, gibbonDaysOfWeek.name, gibbonDaysOfWeek.nameShort FROM gibbonCourseClassSlot
LEFT JOIN gibbonDaysOfWeek ON gibbonCourseClassSlot.gibbonDaysOfWeekID=gibbonDaysOfWeek.gibbonDaysOfWeekID WHERE gibbonCourseClassID=:gibbonCourseClassID ORDER BY gibbonDaysOfWeek.sequenceNumber, timeStart";
$resultSlots = $connection2->prepare($query);
$resultSlots->execute($dataSelect);
} catch (PDOException $e) {
}

while ($rowSelect = $resultSlots->fetch()) {
$slots[$rowSelect['gibbonCourseClassSlotID']] = $rowSelect['name']. " " . substr($rowSelect['timeStart'], 0 ,5).' - '.substr($rowSelect['timeEnd'], 0, 5);
}

$row = $form->addRow();
$row->addLabel('slot', __('Slot'));
$row->addSelect('slot')->fromArray($slots)->required();

$row = $form->addRow();
$row->addFooter();
$row->addSubmit();

echo $form->getOutput();

$courseClassSlotExceptions = $courseClassGateway->selectCourseClassExceptionsByID($gibbonCourseClassID);

$table = DataTable::create('timetableDayRowClassExceptions');
$table->setTitle(__('Exception List'));
$table->addColumn('name2', __('Name'))->format(Format::using('name', ['', 'preferredName', 'surname', 'Student', true]));

$table->addColumn('name', __('Day'));
$table->addColumn('slot', __('Time Slot'));

// ACTIONS
$table->addActionColumn()
->addParam('gibbonSchoolYearID', $gibbonSchoolYearID)
->addParam('gibbonCourseID', $gibbonCourseID)
->addParam('gibbonCourseClassID', $gibbonCourseClassID)
->addParam('gibbonCourseClassSlotExceptionID')
->format(function ($values, $actions) {
$actions->addAction('delete', __('Delete'))
->setURL('/modules/Timetable Admin/courseException_manage_class_delete.php');
});

echo $table->render($courseClassSlotExceptions->toDataSet());

}
}
}
Loading
Loading