Skip to content

Commit

Permalink
Merge pull request #134 from ReedFamily/v2.0.5-DEV
Browse files Browse the repository at this point in the history
V2.0.5 dev
  • Loading branch information
JRSofty authored Aug 10, 2023
2 parents d8cdb8b + da265a4 commit 74ef864
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 23 deletions.
14 changes: 12 additions & 2 deletions admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,18 @@ <h5 class="modal-title" id="instructor-editor-title">Dozentin bearbeiten</h5>
<input id="inputHebamioUrl" class="form-control-sm" type="text" />
</div>
<div class="form-group col-6">
<label for="team" class="dialog-form-label">Praxis Team</label>
<input type="checkbox" id="team" name="team" class="form-control-sm" />
<div class="row">
<div class="col-12">
<label for="team" class="dialog-form-label">Praxis Team</label>
<input type="checkbox" id="team" name="team" class="form-control-sm" />
</div>
</div>
<div class="row">
<div class="col-12">
<label for="visible" class="dialog-form-label">Sichtbar</label>
<input type="checkbox" id="visible" name="visible" class="form-control-sm" />
</div>
</div>
</div>
</div>
<div class="row">
Expand Down
38 changes: 30 additions & 8 deletions admin/js/instructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const displayInstructors = function (response) {
$("<th />", { scope: "col", text: "Bild" }),
$("<th />", { scope: "col", text: "Name" }),
$("<th />", { scope: "col", text: "Vorname" }),
$("<th />", { scope: "col", text: "Sichtbar" }),
$("<th />", { scope: "col", text: "Aktionen" })
),
$("<tbody />", { id: "instructors-table-body" }),
Expand All @@ -29,7 +30,8 @@ const displayInstructors = function (response) {
$("body").off("click", "#edit-instructor-save-button", editInstructorEvent);
$("body").on("click", "#edit-instructor-save-button", newInstructorEvent);
$("#edit-instructor-form").trigger("reset");
$("#team").removeAttr("checked");
$("#team").prop("checked", false);
$("#visible").prop("checked", true);
var thumb = buildThumbnail();
$("#imagewrapper").empty();
$("#imagewrapper").append(thumb);
Expand Down Expand Up @@ -93,16 +95,28 @@ const buildInstructorTableRow = function (instructor) {
var thumbnail = buildThumbnail(instructor);
var editLink = createEditInstructorLink(instructor);
var deleteLink = createDeleteInstructorLink(instructor);
var visibility = showVisiblity(instructor);
var row = $("<tr />").append(
$("<td />", { text: instructor.id }),
$("<td />").append(thumbnail),
$("<td />", { text: instructor.lastname }),
$("<td />", { text: instructor.firstname }),
$("<td />").append(visibility),
$("<td />").append(editLink, deleteLink)
);
return row;
};

const showVisiblity = function (instructor) {
var result;
if (instructor.visible === "1") {
result = $("<i />", { class: "fi-xnluxl-eye linkchar" });
} else {
result = $("<i />", { class: "fi-xnpuxl-eye linkchar" });
}
return result;
};

const createEditInstructorLink = function (instructor) {
var linkId = "link-edit-instructor-" + instructor.id;
var link = $("<a />", { id: linkId, text: " " }).click(function (event) {
Expand Down Expand Up @@ -142,11 +156,9 @@ const editInstructor = function (ele) {
$("#inputInstructorDescription").val(response.instructor.description);
$("#inputHebamioUrl").val(response.instructor.hebamiolink);
$("#editInstructorThumbnailUrl").val(response.instructor.imageurl);
if (response.instructor.team == "1") {
$("#team").attr("checked", true);
} else {
$("#team").removeAttr("checked");
}

$("#team").prop("checked", response.instructor.team === "1");
$("#visible").prop("checked", response.instructor.visible === "1");

var thumb = buildThumbnail(response.instructor);
$("#imagewrapper").empty();
Expand All @@ -171,11 +183,16 @@ const editInstructor = function (ele) {
const newInstructorEvent = function (event) {
event.stopImmediatePropagation();
var newInstructorData = Object.create(Instructor);
if ($("#team").attr("checked")) {
if ($("#team").is(":checked")) {
newInstructorData.team = 1;
} else {
newInstructorData.team = 0;
}
if ($("#visible").is(":checked")) {
newInstructorData.visible = 1;
} else {
newInstructorData.visible = 0;
}
newInstructorData.firstname = $("#editInstructorFirstname").val();
newInstructorData.lastname = $("#editInstructorLastname").val();
var email = $("#inputInstructorEmail").val();
Expand Down Expand Up @@ -223,11 +240,16 @@ const sendNewInstructor = function (newInstructorData) {
const editInstructorEvent = function (event) {
event.stopImmediatePropagation();
var editInstructorData = new Object();
if ($("#team").attr("checked")) {
if ($("#team").is(":checked")) {
editInstructorData.team = 1;
} else {
editInstructorData.team = 0;
}
if ($("#visible").is(":checked")) {
editInstructorData.visible = 1;
} else {
editInstructorData.visible = 0;
}
editInstructorData.id = $("#editInstructorId").val();
editInstructorData.firstname = $("#editInstructorFirstname").val();
editInstructorData.lastname = $("#editInstructorLastname").val();
Expand Down
37 changes: 35 additions & 2 deletions backend/db_classes/db_instructors.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,28 @@ public function __construct(){
$this->connect();
}

public function listAllVisibleInstructors(){

// WHERE `viewable` = 1
$query = "SELECT `id`, `last_name` as lastname, `first_name` as firstname, `email`, `phone`, `mobile`, `image_url` as imageurl, `description`, `position`, `registration_link` as hebamiolink, `team_member` as `team`, `viewable` as `visible` FROM `instructor` WHERE `viewable` = 1";
$stmt = $this->pdo->prepare($query);
$result = api_response::getResponse(500);
try{
$stmt->execute();
$instructors = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result = api_response::getResponse(200);
$result["instructors"] = $instructors;
}catch(Exception $e){
log_util::logEntry("error", $e->getMessage());
$result["exception"] = $e->getMessage();
}finally{
$this->disconnect();
}
return $result;
}

public function listAllInstructors(){
$query = "SELECT `id`, `last_name` as lastname, `first_name` as firstname, `email`, `phone`, `mobile`, `image_url` as imageurl, `description`, `position`, `registration_link` as hebamiolink, `team_member` as `team` FROM `instructor`";
$query = "SELECT `id`, `last_name` as lastname, `first_name` as firstname, `email`, `phone`, `mobile`, `image_url` as imageurl, `description`, `position`, `registration_link` as hebamiolink, `team_member` as `team`, `viewable` as `visible` FROM `instructor`";
$stmt = $this->pdo->prepare($query);
$result = api_response::getResponse(500);
try{
Expand Down Expand Up @@ -65,6 +85,13 @@ public function createInstructor($instructor){
$colnames .= ", `team_member`";
$paramNames .= ", 0";
}
if(isset($instructor["visible"])){
$colnames .= ", `viewable`";
$paramNames .= ", :visible";
}else{
$colnames .= ", `viewable`";
$paramNames .= ", 1";
}

$query = "INSERT INTO `instructor` ($colnames) VALUES ($paramNames)";

Expand All @@ -91,7 +118,7 @@ public function createInstructor($instructor){
}

public function getInstructorById($id){
$query = "SELECT `id`, `last_name` as lastname, `first_name` as firstname, `email`, `phone`, `mobile`, `image_url` as imageurl, `description`, `position`, `registration_link` as hebamiolink, `team_member` as team FROM `instructor` WHERE `id` = :id";
$query = "SELECT `id`, `last_name` as lastname, `first_name` as firstname, `email`, `phone`, `mobile`, `image_url` as imageurl, `description`, `position`, `registration_link` as hebamiolink, `team_member` as team, `viewable` as visible FROM `instructor` WHERE `id` = :id";
$params = ["id" => $id];
$stmt = $this->pdo->prepare($query);
$result = api_response::getResponse(404);
Expand Down Expand Up @@ -147,6 +174,11 @@ public function updateInstructor($instructor){
}else{
$setValues .= ", `team_member` = false";
}
if(isset($instructor["visible"])){
$setValues .= ", `viewable` = :visible";
}else{
$setValues .= ", `viewable` = true";
}


$query = "UPDATE `instructor` SET $setValues WHERE `id` = :id";
Expand All @@ -163,6 +195,7 @@ public function updateInstructor($instructor){
$result["message"] = "Instructor " . $instructor["firstname"] . " " . $instructor["lastname"] . " has been updated.";
}catch(Exception $e){
log_util::logEntry("error", $e->getMessage());
log_util::logEntry("info", $query);
$result = api_reponse::getReponse(500);
$result["exception"] = $e->getMessage();
$this->pdo->rollback();
Expand Down
10 changes: 8 additions & 2 deletions backend/instructors_processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ public function updateInstructor($params){
return $result;
}

public function listInstructors(){
public function listInstructors($params){
$db = new db_instructors();
$result = $db->listAllInstructors();
if(isset($params["visible"])){
$result = $db->listAllVisibleInstructors();
}else{
$result = $db->listAllInstructors();
}


return $result;
}

Expand Down
4 changes: 4 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -705,4 +705,8 @@ footer a {
}
.faq-card-body p {
margin-bottom: 0;
}

.version {
font-size: 0.3em;
}/*# sourceMappingURL=styles.css.map */
Loading

0 comments on commit 74ef864

Please sign in to comment.