-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathjourney_record_add.php
More file actions
104 lines (84 loc) · 6.3 KB
/
Copy pathjourney_record_add.php
File metadata and controls
104 lines (84 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?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\Forms\DatabaseFormFactory;
use Gibbon\Domain\Students\StudentGateway;
if (isActionAccessible($guid, $connection2, '/modules/Mastery Transcript/journey_record_add.php') == false) {
// Access denied
$page->addError(__('You do not have access to this action.'));
} else {
// Proceed!
$search = $_GET['search'] ?? '';
$page->breadcrumbs
->add(__m('Record Journey'), 'journey_record.php')
->add(__m('Add'));
$editLink = '';
if (isset($_GET['editID'])) {
$editLink = $session->get('absoluteURL').'/index.php?q=/modules/Mastery Transcript/journey_record_edit.php&masteryTranscriptJourneyID='.$_GET['editID']."&search=$search";
}
$page->return->setEditLink($editLink);
if ($search !='') {
$params = [
"search" => $search
];
$page->navigator->addSearchResultsAction(Url::fromModuleRoute('Mastery Transcript', 'journey_record.php')->withQueryParams($params));
}
$form = Form::create('domain', $session->get('absoluteURL').'/modules/'.$session->get('module')."/journey_record_addProcess.php?search=$search");
$form->setFactory(DatabaseFormFactory::create($pdo));
$form->addHiddenValue('address', $session->get('address'));
$types = array(
'Credit' => __m('Credit'),
'Opportunity' => __m('Opportunity'),
);
$row = $form->addRow();
$row->addLabel('type', __('Type'));
$row->addSelect('type')->fromArray($types)->required()->placeholder();
//Credit fields
$form->toggleVisibilityByClass('credit')->onSelect('type')->when('Credit');
$sql = "SELECT masteryTranscriptCreditID AS value, masteryTranscriptCredit.name, masteryTranscriptDomain.name AS groupBy FROM masteryTranscriptCredit INNER JOIN masteryTranscriptDomain ON (masteryTranscriptCredit.masteryTranscriptDomainID=masteryTranscriptDomain.masteryTranscriptDomainID) WHERE masteryTranscriptCredit.active='Y' ORDER BY masteryTranscriptDomain.sequenceNumber, masteryTranscriptDomain.name, masteryTranscriptCredit.name";
$row = $form->addRow()->addClass('credit');
$row->addLabel('masteryTranscriptCreditID', __m('Available Credits'))->description(__m('Which credit do you want to apply for?'));
$row->addSelect('masteryTranscriptCreditID')->fromQuery($pdo, $sql, array(), 'groupBy')->required()->placeholder();
$data = array();
$sql = 'SELECT masteryTranscriptCredit.masteryTranscriptCreditID as chainedTo, CONCAT(masteryTranscriptCredit.masteryTranscriptCreditID, \'-\', gibbonPerson.gibbonPersonID) AS value, CONCAT(surname, \', \', preferredName) AS name FROM masteryTranscriptCredit JOIN masteryTranscriptCreditMentor ON (masteryTranscriptCreditMentor.masteryTranscriptCreditID=masteryTranscriptCredit.masteryTranscriptCreditID) JOIN gibbonPerson ON (masteryTranscriptCreditMentor.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.status=\'Full\' ORDER BY surname, preferredname';
$row = $form->addRow()->addClass('credit');
$row->addLabel('gibbonPersonIDSchoolMentor_credit', __('Mentor'));
$row->addSelect('gibbonPersonIDSchoolMentor_credit')->setName('gibbonPersonIDSchoolMentor')->fromQueryChained($pdo, $sql, $data, 'masteryTranscriptCreditID')->required()->placeholder();
//Opportunity fields
$form->toggleVisibilityByClass('opportunity')->onSelect('type')->when('Opportunity');
$studentGateway = $container->get(StudentGateway::class);
$student = $studentGateway->selectActiveStudentByPerson($session->get('gibbonSchoolYearID'), $session->get('gibbonPersonID'))->fetch();
if (empty($student['gibbonYearGroupID'])) {
$page->addError(__('The selected record does not exist, or you do not have access to it.'));
return;
}
$data = array('gibbonYearGroupID' => '%'.$student['gibbonYearGroupID'].'%');
$sql = "SELECT masteryTranscriptOpportunityID AS value, masteryTranscriptOpportunity.name FROM masteryTranscriptOpportunity WHERE masteryTranscriptOpportunity.active='Y' AND gibbonYearGroupIDList LIKE :gibbonYearGroupID ORDER BY masteryTranscriptOpportunity.name";
$row = $form->addRow()->addClass('opportunity');
$row->addLabel('masteryTranscriptOpportunityID', __m('Available Opportunities'))->description(__m('Which opportunity do you want to apply for?'));
$row->addSelect('masteryTranscriptOpportunityID')->fromQuery($pdo, $sql, $data)->required()->placeholder();
$sql = 'SELECT masteryTranscriptOpportunity.masteryTranscriptOpportunityID as chainedTo, CONCAT(masteryTranscriptOpportunity.masteryTranscriptOpportunityID, \'-\', gibbonPerson.gibbonPersonID) AS value, CONCAT(surname, \', \', preferredName) AS name FROM masteryTranscriptOpportunity JOIN masteryTranscriptOpportunityMentor ON (masteryTranscriptOpportunityMentor.masteryTranscriptOpportunityID=masteryTranscriptOpportunity.masteryTranscriptOpportunityID) JOIN gibbonPerson ON (masteryTranscriptOpportunityMentor.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPerson.status=\'Full\' ORDER BY surname, preferredname';
$row = $form->addRow()->addClass('opportunity');
$row->addLabel('gibbonPersonIDSchoolMentor_opportunity', __('Mentor'));
$row->addSelect('gibbonPersonIDSchoolMentor_opportunity')->setName('gibbonPersonIDSchoolMentor')->fromQueryChained($pdo, $sql, array(), 'masteryTranscriptOpportunityID')->required()->placeholder();
$row = $form->addRow();
$row->addFooter();
$row->addSubmit();
echo $form->getOutput();
}