Skip to content

Commit

Permalink
v1.7.02
Browse files Browse the repository at this point in the history
  • Loading branch information
rossdotparker committed Dec 13, 2019
1 parent 053f4e3 commit 8edca1e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
5 changes: 5 additions & 0 deletions Clinics/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,8 @@
$sql[$count][0] = "1.7.01";
$sql[$count][1] = "ALTER TABLE `clinicsClinicStudent` ADD UNIQUE KEY `student` (`clinicsBlockID`,`gibbonPersonID`);end";
$count++;

//v1.7.02
$sql[$count][0] = "1.7.02";
$sql[$count][1] = "";
$count++;
4 changes: 4 additions & 0 deletions Clinics/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
CHANGELOG
=========
v1.7.02
-------
Fixed null record issue in clinicsClinicStudent

v1.7.01
-------
Added unique key for student/block
Expand Down
28 changes: 16 additions & 12 deletions Clinics/assignProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


use Gibbon\Module\Clinics\Domain\ClinicsBlocksGateway;
use Gibbon\Module\Clinics\Domain\ClinicsStudentsGateway;

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

Expand All @@ -32,6 +33,7 @@
exit;
} else {
//Fetch blocks
$clinicsStudentsGateway = $container->get(ClinicsStudentsGateway::class);
$clinicsBlocksGateway = $container->get(ClinicsBlocksGateway::class);

$criteria = $clinicsBlocksGateway->newQueryCriteria()
Expand Down Expand Up @@ -65,18 +67,23 @@
$clinicsClinicID = ($clinics[$count] != '') ? $clinics[$count] : NULL ;
$status = (!is_null($clinicsClinicID)) ? 'Assigned' : NULL;

if ($resultStudent->rowCount() == 1) { //Exists, so update
if ($resultStudent->rowCount() == 1) { //Exists
$rowStudent = $resultStudent->fetch();
try {
$data = array('clinicsClinicID' => $clinicsClinicID, 'status' => $status, 'clinicsClinicStudentID' => $rowStudent['clinicsClinicStudentID']);
$sql = 'UPDATE clinicsClinicStudent SET clinicsClinicID=:clinicsClinicID, status=:status WHERE clinicsClinicStudentID=:clinicsClinicStudentID';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$partialFail = true;
if (!is_null($clinicsClinicID)) { //Update
try {
$data = array('clinicsClinicID' => $clinicsClinicID, 'status' => $status, 'clinicsClinicStudentID' => $rowStudent['clinicsClinicStudentID']);
$sql = 'UPDATE clinicsClinicStudent SET clinicsClinicID=:clinicsClinicID, status=:status WHERE clinicsClinicStudentID=:clinicsClinicStudentID';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$partialFail = true;
}
}
else { //Remove
$clinicsStudentsGateway->delete($rowStudent['clinicsClinicStudentID']);
}
}
else if ($resultStudent->rowCount() == 0) { //Does not exist, so insert
else if ($resultStudent->rowCount() == 0 && !is_null($clinicsClinicID)) { //Does not exist, so insert if not blank
try {
$data = array('clinicsClinicID' => $clinicsClinicID, 'status' => $status, 'clinicsBlockID' => $block['clinicsBlockID'], 'gibbonPersonID' => $gibbonPersonID);
$sql = 'INSERT INTO clinicsClinicStudent SET clinicsClinicID=:clinicsClinicID, status=:status, clinicsBlockID=:clinicsBlockID, gibbonPersonID=:gibbonPersonID';
Expand All @@ -86,9 +93,6 @@
$partialFail = true;
}
}
else {
$partialFail = true;
}
}
$count++;
}
Expand Down
2 changes: 1 addition & 1 deletion Clinics/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$entryURL = "clinics.php";
$type = "Additional";
$category = "Learn";
$version = "1.7.01";
$version = "1.7.02";
$author = "Ross Parker";
$url = "http://rossparker.org";

Expand Down
2 changes: 1 addition & 1 deletion Clinics/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
/**
* Sets version information
*/
$moduleVersion = '1.7.01';
$moduleVersion = '1.7.02';

0 comments on commit 8edca1e

Please sign in to comment.