Skip to content

Commit

Permalink
v1.5.02
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Parker committed Mar 25, 2022
1 parent 9678cf5 commit a5ffd31
Show file tree
Hide file tree
Showing 15 changed files with 537 additions and 602 deletions.
5 changes: 5 additions & 0 deletions Higher Education/CHANGEDB.php
Expand Up @@ -182,3 +182,8 @@
++$count;
$sql[$count][0] = '1.5.01';
$sql[$count][1] = "";

//v1.5.02
++$count;
$sql[$count][0] = '1.5.02';
$sql[$count][1] = "";
6 changes: 5 additions & 1 deletion Higher Education/CHANGELOG.txt
@@ -1,8 +1,12 @@
CHANGELOG
=========
v1.5.02
-------
Refactoring of printPagination

v1.5.01
-------
Refactoring of linkTop divs
Refactoring of linkTop divs

v1.5.00
-------
Expand Down
134 changes: 48 additions & 86 deletions Higher Education/institutions_manage.php
Expand Up @@ -17,6 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Services\Format;
use Gibbon\Tables\DataTable;
use Gibbon\Module\HigherEducation\Domain\InstitutionGateway;

//Module includes
include __DIR__.'/moduleFunctions.php';

Expand All @@ -30,91 +34,49 @@
if ($role != 'Coordinator') {
$page->addError(__('You do not have access to this action.'));
} else {
//Set pagination variable
$pagination = null;
if (isset($_GET['page'])) {
$pagination = $_GET['page'];
}
if ((!is_numeric($pagination)) or $pagination < 1) {
$pagination = 1;
}

try {
$data = array('gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'));
$sql = 'SELECT * FROM higherEducationInstitution ORDER BY name, country';
$sqlPage = $sql.' LIMIT '.$session->get('pagination').' OFFSET '.(($pagination - 1) * $session->get('pagination'));
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$page->addError(__('Error: {error}. Students cannot be displayed.', ['error' => $e->getMessage()]));
}

echo "<p class='text-right mb-2 text-xs'>";
echo "<a href='".$session->get('absoluteURL').'/index.php?q=/modules/'.$session->get('module')."/institutions_manage_add.php'>".__("Add")."<img style='margin-left: 5px' src='./themes/".$session->get('gibbonThemeName')."/img/page_new.png'/></a>";
echo '</p>';

if ($result->rowCount() < 1) {
$page->addError(__('There are no students to display.'));
} else {
if ($result->rowCount() > $session->get('pagination')) {
printPagination($guid, $result->rowCount(), $pagination, $session->get('pagination'), 'top');
}

echo "<table cellspacing='0' style='width: 100%'>";
echo "<tr class='head'>";
echo '<th>';
echo 'Name';
echo '</th>';
echo '<th>';
echo 'Active';
echo '</th>';
echo '<th>';
echo 'Actions';
echo '</th>';
echo '</tr>';

$count = 0;
$rowNum = 'odd';
try {
$resultPage = $connection2->prepare($sqlPage);
$resultPage->execute($data);
} catch (PDOException $e) {
echo "<div class='warning'>";
echo $e->getMessage();
echo '</div>';
}

while ($row = $resultPage->fetch()) {
if ($count % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
++$count;

if ($row['active'] == 'N') {
$rowNum = 'error';
}

//COLOR ROW BY STATUS!
echo "<tr class=$rowNum>";
echo '<td>';
echo $row['name'].', '.$row['country'];
echo '</td>';
echo '<td>';
echo $row['active'];
echo '</td>';
echo '<td>';
echo "<a href='".$session->get('absoluteURL').'/index.php?q=/modules/'.$session->get('module').'/institutions_manage_edit.php&higherEducationInstitutionID='.$row['higherEducationInstitutionID']."'><img title='Edit' src='./themes/".$session->get('gibbonThemeName')."/img/config.png'/></a> ";
echo "<a class='thickbox' href='".$session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/institutions_manage_delete.php&higherEducationInstitutionID='.$row['higherEducationInstitutionID']."&width=650&height=135'><img title='Delete' src='./themes/".$session->get('gibbonThemeName')."/img/garbage.png'/></a> ";
echo '</td>';
echo '</tr>';
}
echo '</table>';

if ($result->rowCount() > $session->get('pagination')) {
printPagination($guid, $result->rowCount(), $pagination, $session->get('pagination'), 'bottom');
}
}

$institutionGateway = $container->get(InstitutionGateway::class);

// QUERY
$criteria = $institutionGateway->newQueryCriteria(true)
->sortBy(['name', 'country'])
->pageSize(50)
->fromPOST();

$institutions = $institutionGateway->queryInstitutions($criteria);

// TABLE
$table = DataTable::createPaginated('institutions', $criteria);
$table->setTitle(__('View'));

$table->modifyRows(function ($unit, $row) {
if ($unit['active'] != 'Y') $row->addClass('error');
return $row;
});

$table->addHeaderAction('add', __('Add'))
->setURL('/modules/Higher Education/institutions_manage_add.php')
->displayLabel();

$table->addColumn('name', __('Name'))
->format(function ($values) {
return $values['name'].", ".$values['country'];
});

$table->addColumn('active', __('active'))
->format(function ($values) {
return Format::yesNo(__($values['active']));
});

$actions = $table->addActionColumn()
->addParam('higherEducationInstitutionID')
->format(function ($resource, $actions) {
$actions->addAction('edit', __('Edit'))
->setURL('/modules/Higher Education/institutions_manage_edit.php');
$actions->addAction('delete', __('Delete'))
->setURL('/modules/Higher Education/institutions_manage_delete.php');
});

echo $table->render($institutions);
}
}
130 changes: 44 additions & 86 deletions Higher Education/majors_manage.php
Expand Up @@ -17,6 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Services\Format;
use Gibbon\Tables\DataTable;
use Gibbon\Module\HigherEducation\Domain\MajorGateway;

//Module includes
include __DIR__.'/moduleFunctions.php';

Expand All @@ -30,91 +34,45 @@
if ($role != 'Coordinator') {
$page->addError(__('You do not have access to this action.'));
} else {
//Set pagination variable
$pagination = null;
if (isset($_GET['page'])) {
$pagination = $_GET['page'];
}
if ((!is_numeric($pagination)) or $pagination < 1) {
$pagination = 1;
}

try {
$data = array('gibbonSchoolYearID' => $session->get('gibbonSchoolYearID'));
$sql = 'SELECT * FROM higherEducationMajor ORDER BY name';
$sqlPage = $sql.' LIMIT '.$session->get('pagination').' OFFSET '.(($pagination - 1) * $session->get('pagination'));
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$page->addError(__('Error: {error}. Students cannot be displayed.', ['error' => $e->getMessage()]));;
}

echo "<p class='text-right mb-2 text-xs'>";
echo "<a href='".$session->get('absoluteURL').'/index.php?q=/modules/'.$session->get('module')."/majors_manage_add.php'>".__("Add")."<img style='margin-left: 5px' src='./themes/".$session->get('gibbonThemeName')."/img/page_new.png'/></a>";
echo '</p>';

if ($result->rowCount() < 1) {
$page->addError(__('There are no students to display.'));
} else {
if ($result->rowCount() > $session->get('pagination')) {
printPagination($guid, $result->rowCount(), $pagination, $session->get('pagination'), 'top');
}

echo "<table cellspacing='0' style='width: 100%'>";
echo "<tr class='head'>";
echo '<th>';
echo 'Name';
echo '</th>';
echo '<th>';
echo 'Active';
echo '</th>';
echo '<th>';
echo 'Actions';
echo '</th>';
echo '</tr>';

$count = 0;
$rowNum = 'odd';
try {
$resultPage = $connection2->prepare($sqlPage);
$resultPage->execute($data);
} catch (PDOException $e) {
echo "<div class='warning'>";
echo $e->getMessage();
echo '</div>';
}

while ($row = $resultPage->fetch()) {
if ($count % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
++$count;

if ($row['active'] == 'N') {
$rowNum = 'error';
}

//COLOR ROW BY STATUS!
echo "<tr class=$rowNum>";
echo '<td>';
echo $row['name'];
echo '</td>';
echo '<td>';
echo $row['active'];
echo '</td>';
echo '<td>';
echo "<a href='".$session->get('absoluteURL').'/index.php?q=/modules/'.$session->get('module').'/majors_manage_edit.php&higherEducationMajorID='.$row['higherEducationMajorID']."'><img title='Edit' src='./themes/".$session->get('gibbonThemeName')."/img/config.png'/></a> ";
echo "<a class='thickbox' href='".$session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module').'/majors_manage_delete.php&higherEducationMajorID='.$row['higherEducationMajorID']."&width=650&height=135'><img title='Delete' src='./themes/".$session->get('gibbonThemeName')."/img/garbage.png'/></a> ";
echo '</td>';
echo '</tr>';
}
echo '</table>';

if ($result->rowCount() > $session->get('pagination')) {
printPagination($guid, $result->rowCount(), $pagination, $session->get('pagination'), 'bottom');
}
}
$majorGateway = $container->get(MajorGateway::class);

// QUERY
$criteria = $majorGateway->newQueryCriteria(true)
->sortBy(['name'])
->pageSize(50)
->fromPOST();

$majors = $majorGateway->queryMajors($criteria);

// TABLE
$table = DataTable::createPaginated('majors', $criteria);
$table->setTitle(__('View'));

$table->modifyRows(function ($unit, $row) {
if ($unit['active'] != 'Y') $row->addClass('error');
return $row;
});

$table->addHeaderAction('add', __('Add'))
->setURL('/modules/Higher Education/majors_manage_add.php')
->displayLabel();

$table->addColumn('name', __('Name'));

$table->addColumn('active', __('active'))
->format(function ($values) {
return Format::yesNo(__($values['active']));
});

$actions = $table->addActionColumn()
->addParam('higherEducationMajorID')
->format(function ($resource, $actions) {
$actions->addAction('edit', __('Edit'))
->setURL('/modules/Higher Education/majors_manage_edit.php');
$actions->addAction('delete', __('Delete'))
->setURL('/modules/Higher Education/majors_manage_delete.php');
});

echo $table->render($majors);
}
}
2 changes: 1 addition & 1 deletion Higher Education/manifest.php
Expand Up @@ -25,7 +25,7 @@
$entryURL = 'index.php';
$type = 'Additional';
$category = 'Other';
$version = '1.5.01';
$version = '1.5.02';
$author = 'Ross Parker';
$url = 'http://rossparker.org';

Expand Down

0 comments on commit a5ffd31

Please sign in to comment.