Skip to content

Commit

Permalink
Backend: Applications joins
Browse files Browse the repository at this point in the history
Backend:
  - Added manager user information in applications list
  • Loading branch information
fet1sov committed May 29, 2024
1 parent 13b2c75 commit 08c3af8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion www/backend/models/application.mdl.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($id = 0, $applicationData = array()) {
}

public static function getFullList() {
$stmt = $GLOBALS["dbAdapter"]->prepare("SELECT * FROM `applications` INNER JOIN `application_statuses` ON `applications`.`status` = `application_statuses`.`id`");
$stmt = $GLOBALS["dbAdapter"]->prepare("SELECT `applications`.*, `user`.`username` AS `user_author`, `user`.`username` AS `user_manager` FROM `applications` INNER JOIN `application_statuses` ON `applications`.`status` = `application_statuses`.`id` INNER JOIN `user` ON `applications`.`author_id` = `user`.`id` LEFT JOIN `user` manager_user ON `applications`.`manager_id`=`user`.`id`");
$stmt->execute();

$applicationsResult = $stmt->get_result();
Expand Down
3 changes: 3 additions & 0 deletions www/backend/models/user.mdl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class User extends DatabaseEntity {
public $password = "";
public $company = "";
public $email = "";
public $roleid = 0;

public function __construct($id = 0, $userData = array()) {
$this->id = $id;
Expand All @@ -38,6 +39,7 @@ public function __construct($id = 0, $userData = array()) {
$this->password = $row["password"];
$this->company = $row["company"];
$this->email = $row["email"];
$this->roleid = $row["role_id"] ? $row["role_id"] : 0;
} else {
if (!count($userData))
{
Expand Down Expand Up @@ -67,6 +69,7 @@ public function __construct($id = 0, $userData = array()) {
$this->password = md5($userData["password"]);
$this->company = $userData["company"];
$this->email = $userData["email"];
$this->roleid = array_key_exists("role_id", $userData) ? $userData["role_id"] : 0;
}
}

Expand Down
5 changes: 4 additions & 1 deletion www/frontend/components/elems/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@
</a>
</li>


<?php
$userData = unserialize($_SESSION["userData"]);
if($userData->getPermissions()["admin_rights"]) { ?>
<li>
<a href="/admin">
<svg fill="#000000" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M983.727 5.421 1723.04 353.62c19.765 9.374 32.414 29.252 32.414 51.162v601.525c0 489.6-424.207 719.774-733.779 887.943l-34.899 18.975c-8.47 4.517-17.731 6.889-27.105 6.889-9.262 0-18.523-2.372-26.993-6.89l-34.9-18.974C588.095 1726.08 164 1495.906 164 1006.306V404.78c0-21.91 12.65-41.788 32.414-51.162L935.727 5.42c15.134-7.228 32.866-7.228 48 0ZM757.088 383.322c-176.075 0-319.285 143.323-319.285 319.398 0 176.075 143.21 319.285 319.285 319.285 1.92 0 3.84 0 5.76-.113l58.504 58.503h83.689v116.781h116.781v83.803l91.595 91.482h313.412V1059.05l-350.57-350.682c.114-1.807.114-3.727.114-5.647 0-176.075-143.21-319.398-319.285-319.398Zm0 112.942c113.732 0 206.344 92.724 205.327 216.62l-3.953 37.271 355.426 355.652v153.713h-153.713l-25.412-25.299v-149.986h-116.78v-116.78H868.108l-63.812-63.7-47.209 5.309c-113.732 0-206.344-92.5-206.344-206.344 0-113.732 92.612-206.456 206.344-206.456Zm4.98 124.98c-46.757 0-84.705 37.948-84.705 84.706s37.948 84.706 84.706 84.706c46.757 0 84.706-37.948 84.706-84.706s-37.949-84.706-84.706-84.706Z" fill-rule="evenodd"></path> </g></svg>
<div><?= $GLOBALS["locale"]["userMenu"]["admin"] ?></div>
</a>
</li>
<?php } ?>


<li>
Expand Down

0 comments on commit 08c3af8

Please sign in to comment.