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

My conferences development #6

Merged
merged 5 commits into from
Oct 21, 2022
Merged
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
Binary file removed .vs/26-CMA/v16/.suo
Binary file not shown.
7 changes: 0 additions & 7 deletions .vs/VSWorkspaceState.json

This file was deleted.

Binary file removed .vs/slnx.sqlite
Binary file not shown.
64 changes: 52 additions & 12 deletions classes/components/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public static function display($type = '', $data = array())
case 'submission':
return self::submissionCard($data[0], $data[1], $data[2], $data[3], $data[4], $data[5]);

case 'conference':
return self::conferenceCard($data[0], $data[1], $data[2], $data[3], $data[4], $data[5]);
case 'conferenceCard':
return self::conferenceCard($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6]);

case 'upcomingConference':
return self::upcomingConferenceCard($data[0], $data[1], $data[2], $data[3]);
Expand Down Expand Up @@ -55,28 +55,40 @@ private static function submissionCard($cTitle, $filePath, $status, $date, $time
';
}

private static function conferenceCard($title, $link, $timestamp, $filePath, $presenter, $status)
private static function conferenceCard($title, $date, $time, $link, $filePath, $status, $subId)
{
$accept_selected = $reject_selected = "";
if ($status == "pending") {
$accept_selected = $reject_selected = "";
}
else if ($status == 1) {
$accept_selected = "selected";
}
else if ($status == 0) {
$reject_selected = "selected";
}


return '
<div class="card">
<span class="badge ' . self::defineConfirmationStatus($status) . ' text-dark">Conference ' . $status . '</span>
<span class="badge ' . self::defineAttendanceBadge($status) . ' text-dark">' . self::defineAttendanceStatus($status) . '</span>
<div class="card-body">
<h5 class="card-title">' . $title . '</h5>
<h6 class="card-subtitle mb-2 text-muted">Presented by: ' . $presenter . ' </h6>
<div class="text-left">
<p class="card-text">
<strong> Conference Date </strong> : ' . date("d M y \a\\t g:i A", strtotime($timestamp)) . '</a><br>
<strong> Event Date </strong> : ' . $date . '</a><br>
<strong> Event Time </strong> : ' . $time . '</a><br>
<strong> Meeting URL </strong> : <a href="' . $link . '">' . $link . '</a><br>
<strong> Paper to be presented </strong> : <a href="' . $filePath . '">' . $filePath . '</a>
<strong> Paper to be presented </strong> : <a href=./viewSubmission?filepath=' . rawurlencode($filePath) . '&subId=' . $subId . '">' . $filePath . '</a>
</p>
<form>
<select class="form-select" name="attendanceOption">
<option value="accept">Confirmed Attendance</option>
<option value="reject">Cancel Attendance</option>
<form action="#" method="post">
<select class="form-select" name="attendance_options">
<option value="accept-' . $subId . '"' . $accept_selected .'>Confirm Attendance</option>
<option value="reject-' . $subId . '"' . $reject_selected .'>Cancel Attendance</option>
</select>
<br>
<div class="form-group btn-group-sm d-grid gap-2">
<button name="submitAttendance" type="submit" class="btn btn-primary" onclick="showToast()">Submit Attendance</button>
<button name="submitAttendance" type="submit" class="btn btn-primary">Submit Attendance</button>
</div>
</form>
</div>
Expand Down Expand Up @@ -722,4 +734,32 @@ private static function defineConfirmationStatus($status)
return 'bg-danger';
}
}

private static function defineAttendanceStatus($status)
{
switch ($status) {
case "pending":
return 'Confirmation Pending';

case 1:
return 'Attendance Confirmed';

case 0:
return 'Attendance Cancelled';
}
}

private static function defineAttendanceBadge($status)
{
switch ($status) {
case "pending":
return 'bg-warning';

case 1:
return 'bg-success';

case 0:
return 'bg-danger';
}
}
}
61 changes: 56 additions & 5 deletions classes/dbAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,23 +473,74 @@ public function updateReview()

/* START EVENT API CONNECTION*/

public function createNewConference()
public function createRegistration()
{
extract(func_get_args(), EXTR_PREFIX_ALL, "arg");
$fields = [
'RegId' => $arg_0,
'RegistrationId' => $arg_0,
'UserId' => $arg_1,
'ConferenceId' => $arg_2,
'RegDateTime' => $arg_3,
'Attendance' => $arg_4
'RegistrationTimestamp' => $arg_3,
'RegistrationAttendance' => $arg_4
];

return API::request(
$this->baseUrl . 'user/createNewConference',
$this->baseUrl . 'registration/createRegistration',
"POST_REQUEST",
$fields
);
}

public function updateRegistration()
{
extract(func_get_args(), EXTR_PREFIX_ALL, "arg");
$fields = [
'RegistrationId' => $arg_0,
'UserId' => $arg_1,
'ConferenceId' => $arg_2,
'RegistrationTimestamp' => $arg_3,
'RegistrationAttendance' => $arg_4
];

return API::request(
$this->baseUrl . 'registration/updateRegistration',
"POST_REQUEST",
$fields
);
}

public function getRegistration()
{
return API::request(
$this->baseUrl . 'registration/list',
"GET_REQUEST",
$this->baseHeader
);
}

public function findRegistrationByUserId($id) {
return API::request(
$this->baseUrl . 'registration/findRegistrationByUserId?id=' . $id,
"GET_REQUEST",
$this->baseHeader
);
}

public function findRegistrationByConferenceId($id) {
return API::request(
$this->baseUrl . 'registration/findRegistrationByConferenceId?id=' . $id,
"GET_REQUEST",
$this->baseHeader
);
}

public function findRegistrationByAttendance($attendance) {
return API::request(
$this->baseUrl . 'registration/findRegistrationByAttendance?attendance=' . $attendance,
"GET_REQUEST",
$this->baseHeader
);
}

/* END EVENT API CONNECTION*/
}
5 changes: 5 additions & 0 deletions classes/idGenerator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ static function conference()
return self::unqid(8);
}

static function registration()
{
return self::unqid(8);
}

private static function unqid($lenght = 5)
{
$bytes = openssl_random_pseudo_bytes(ceil($lenght / 2));
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
require $publicPath . '/submitter/viewSubmission.php';
break;

case '/manageMyConferences':
require $publicPath . '/submitter/manageMyConferences.php';
case '/registerConference':
require $publicPath . '/submitter/registerConference.php';
break;

case '/myUpcomingConferences':
Expand Down
1 change: 1 addition & 0 deletions src/pages/reviewer/reviewSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function getFilePath($uId) {
$db->updateSubmission(
$subId,
$submission[0]->UserId,
$submission[0]->ReviewerId,
$submission[0]->ConferenceId,
$submission[0]->SubmissionTimestamp,
$submission[0]->SubmissionPath,
Expand Down
137 changes: 108 additions & 29 deletions src/pages/submitter/manageMyConferences.php
Original file line number Diff line number Diff line change
@@ -1,70 +1,149 @@
<?php
include_once("./classes/components/card.php");
include_once("./classes/components/timeProcessor.php");
require_once "./classes/dbAPI.class.php";

$db = new Database();
$conferences = $db->getConferences();
$submissions = $db->getAllSubmission();

foreach($conferences as $conference) {
if (TimeProcessor::cmpETimeandCTime($conference->ConferenceEndTimestamp)) {
$db->updateConference(
$conference->ConferenceId,
$conference->ConferenceTitle,
$conference->ConferenceStartTimestamp,
$conference->ConferenceEndTimestamp,
$conference->ConferenceLocation,
"0"
);
}
include_once("./classes/components/card.php");
include_once("./classes/components/timeProcessor.php");
require_once "./classes/dbAPI.class.php";

$db = new Database();
$conferences = $db->getConferences();

foreach ($conferences as $conference) {
if (TimeProcessor::cmpETimeandCTime($conference->ConferenceEndTimestamp)) {
$db->updateConference(
$conference->ConferenceId,
$conference->ConferenceTitle,
$conference->ConferenceStartTimestamp,
$conference->ConferenceEndTimestamp,
$conference->ConferenceLocation,
"0"
);
}
}

if (isset($_POST['manageMyConferences'])) {
$attendanceOption = $_POST["attendanceOption"];

$db->createRegistration(
$regId,
$_SESSION["UID"],
$conference->ConferenceId,
'',
$_POST["attendanceOption"]
);

header('Location: /dashboard');
}

$submissions = $db->findSubmissionByUserId($_SESSION['UID']);
$users = $db->findUserById($_SESSION['UID']);

$conferences = $db->findConferenceByStatus("1");
?>

<!--CONTENT START-->
<div id="content" class="container-fluid p-5">
<div class="d-flex flex-column justify-content-center align-items-center text-center h-100 mb-5">
<h1 class="display-4">My Conferences</h1>
<p class="lead">Check your conferences progress here. We'll send you a notification nearing the conference date. Keep a look out!</p>
<div style="margin: auto; width: <?php echo (!Mobile::isActive()? '36rem' : '100%') ?>;">
<div style="margin: auto; width: <?php echo (!Mobile::isActive() ? '36rem' : '100%') ?>;">

<?php
if (!$conferences) {
echo '
if(isset($_POST["attendanceOption"])){
$confirmedAttendance = $_POST["attendanceOption"];
} else {
$confirmedAttendance = "";
}

if (!$conferences) {
echo '
<div class="d-flex align-items-center justify-content-center vh-50 bg-secondary">
<h1 class="display-6 fw-bold text-white">No current conferences available</h1>
</div>';
} else {
foreach ($conferences as $conference) {
} else {
foreach ($conferences as $conference) {
echo Card::display(
'conferenceCard',
[
$conference->ConferenceTitle,
$conference->ConferenceLocation,
$conference->ConferenceStartTimestamp,
$submissions[0]->SubmissionPath,
$users[0]->UserFirstName . ' ' . $users[0]->UserLastName,
$submissions[0]->SubmissionStatus
]
);

if ($db->findRegistrationByAttendance($confirmedAttendance)) {
echo '<p>attending status will show here</p>';
} else {
//No regID found, choose confirmation status, then a record will be created with your regId (same as submissionID) and your attending status + other info
echo '<form action="/manageMyConferences" method="POST">
<select class="form-select" name="attendanceOption">
<option value="accept">Confirmed Attendance</option>
<option value="reject">Cancel Attendance</option>
</select>
<br>
<div class="form-group btn-group-sm d-grid gap-2">
<button name="manageMyConferences" type="submit" class="btn btn-primary" onclick="showToast()">Submit Attendance</button>
</div>
</form>';
}


/*
echo '<div class="card">';
$submissionByID = $db->findSubmissionByConferenceId($conference->ConferenceId);
$regId = $conference->ConferenceId . '_' . $_SESSION["UID"];
$attendanceByID = $db->findAttendanceById($regId);

if (in_array($_SESSION["UID"], array_column($submissionByID, 'UserId'))) {

// This wil needs fixing
// This line checks, if a submission path for the current conference exists, assign it to $file, otherwise display 'file is not available'
if (in_array($conference->ConferenceId, array_column($submissions, 'SubmissionPath'))) {
$file = in_array($conference->ConferenceId, array_column($submissions, 'SubmissionPath'));
} else {
$file = 'Not available yet';
}

//This needs to get the submission status from submissions
$status = "unkown";

$subData = [
$conference->ConferenceTitle,
$conference->ConferenceLocation,
$conference->ConferenceStartTimestamp,
$file,
$_SESSION['uFName'] . " " . $_SESSION['uLName'],
'status unknown'
$status
];

echo Card::display("conference", $subData);

// Search for the regID, if found, display attending status, else display confirmation form
if (in_array($regId, array_column($allAttendance, 'RegId'))) {
echo '<p>attending status will show here</p>';
} else {
//No regID found, choose confirmation status, then a record will be created with your regId (same as submissionID) and your attending status + other info
echo '<form action="/manageMyConferences" method="POST">
<select class="form-select" name="attendanceOption">
<option value="accept">Confirmed Attendance</option>
<option value="reject">Cancel Attendance</option>
</select>
<br>
<div class="form-group btn-group-sm d-grid gap-2">
<button name="manageMyConferences" type="submit" class="btn btn-primary" onclick="showToast()">Submit Attendance</button>
</div>
</form>';
}

echo '</div>';
} else {
echo 'This User has no conferences';
}
}
*/
}
}
?>

</div>
</div>
</div>
Expand Down
Loading