Skip to content

Commit

Permalink
Big amount of fixes
Browse files Browse the repository at this point in the history
Frontend:
  - Finished edit form for the user application
  - Added the company name in admin application list

Backend:
  - Added the edit process for the user application
  - Fixed the avatars for the admin application view
  • Loading branch information
fet1sov committed May 30, 2024
1 parent 7f9f85d commit f4696a4
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 49 deletions.
21 changes: 12 additions & 9 deletions www/backend/routes/admin/admin.view.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<section>

<?php if (!isset($category)) { ?>
<?php if (!isset($category)) {
if ($applications && count($applications)) {?>


<table align="center" >
<tr>
<th><?= $GLOBALS["locale"]["userPage"]["account"]["appTable"]["id"] ?></th>
Expand All @@ -12,15 +15,14 @@
</tr>

<?php
if ($applications)
{
foreach ($applications as $application) { ?>
foreach ($applications as $application) { ?>
<tr> <td><?= $application["id"] ?></td> <td><img style="width: 32px; height: 32px; border-radius: 10px;" src="/api/avatar?userid=<?= $application["author_id"] ?>"> <?= $application["user_author"] ? $application["user_author"] : $GLOBALS["locale"]["errors"]["nullField"] ?></td> <td><?= $application["user_manager"] ? $application["user_manager"] : $GLOBALS["locale"]["errors"]["nullField"] ?></td> <td><?= $application["status_name"] ? $GLOBALS["locale"]["userPage"]["statuses"][$application["status_name"]] : $GLOBALS["locale"]["errors"]["noStatus"] ?></td> <td><?= date("d.m.Y", $application["creation_date"]) ?></td> <td><a href="/admin/application?id=<?= $application["id"] ?>" class="small-primary-button"><?= $GLOBALS["locale"]["buttons"]["view"] ?></td>
</tr>
<?php
}
} ?>
<?php } ?>
</table>
<?php } else { ?>
<p><?= $GLOBALS["locale"]["errors"]["noApplications"] ?></p>
<?php } ?>
<?php } else {
switch ($category) {
case "application": { ?>
Expand Down Expand Up @@ -79,14 +81,15 @@
<div class="info-block">
<strong><?= $GLOBALS["locale"]["userPage"]["applicationInfo"]["author"] ?></strong>
<div class="row-block">
<img style="width: 32px; height: 32px; border-radius: 10px;" src="../api/avatar?id=<?= $applicationData->authorId ?>">
<img style="width: 32px; height: 32px; border-radius: 10px;" src="../api/avatar?userid=<?= $applicationData->authorId ?>">
<p style="margin-left: 10px"><?= $authorData["username"] ?></p>
</div>
</div>

<div class="info-block">
<strong><?= $GLOBALS["locale"]["userPage"]["applicationInfo"]["contact"] ?></strong>
<p><?= $authorData["email"] ?></p>
<p><?= $authorData["company"] ?></p>
</div>

<div class="info-block collumn-block">
Expand Down Expand Up @@ -126,7 +129,7 @@

<div class="info-block row-block">
<button name="action" value="update" class="small-primary-button"><?= $GLOBALS["locale"]["buttons"]["update"] ?></button>
<button name="action" value="cancel" class="small-primary-button"><?= $GLOBALS["locale"]["buttons"]["cancel"] ?></button>
<button name="action" value="cancel" class="small-primary-button"><?= $GLOBALS["locale"]["buttons"]["delete"] ?></button>
</div>

<p style="text-align: center; color: #00d907;"><?= isset($message) ? $message : "" ?></p>
Expand Down
81 changes: 54 additions & 27 deletions www/backend/routes/user/user.ctrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,39 +86,66 @@

if (!isset($_GET["id"]))
{
Renderer::includeTemplate("frontend/components/layout.php", [
"layout_path" => ROUTE_ROOT . "user/user.view.php",
"layout_data" => [
"category" => $params['category'],
"footerShow" => false,
]
]);
if ($_SERVER["REQUEST_METHOD"] == "POST"
&& isset($_SESSION["userData"]))
{
$userData = unserialize($_SESSION["userData"]);

$application = new Application(0, [
"author_id" => $userData->id,
"creation_date" => time(),
"text" => htmlspecialchars($_POST["application-text"])
]);

header("Location: /user");
} else {
Renderer::includeTemplate("frontend/components/layout.php", [
"layout_path" => ROUTE_ROOT . "user/user.view.php",
"layout_data" => [
"category" => $params['category'],
"footerShow" => false,
]
]);
}
} else {
$application = new Application(intval($_GET["id"]));

Renderer::includeTemplate("frontend/components/layout.php", [
"layout_path" => ROUTE_ROOT . "user/user.view.php",
"layout_data" => [
"category" => $params['category'],
"applicationData" => $application,
"managerData" => $application->getManagerInfo(),
"footerShow" => false,
]
]);
}

if ($_SERVER['REQUEST_METHOD'] == "GET")
{
Renderer::includeTemplate("frontend/components/layout.php", [
"layout_path" => ROUTE_ROOT . "user/user.view.php",
"layout_data" => [
"category" => $params['category'],
"applicationData" => $application,
"managerData" => $application->getManagerInfo(),
"footerShow" => false,
]
]);
} else {
if (isset($_POST["action"])
&& $_POST["action"] == "edit")
{
$application->text = $_POST["application-text"];
$application->saveData();

if ($_SERVER["REQUEST_METHOD"] == "POST"
&& isset($_SESSION["userData"]))
{
$userData = unserialize($_SESSION["userData"]);
$application = new Application(intval($_GET["id"]));

$application = new Application(0, [
"author_id" => $userData->id,
"creation_date" => time(),
"text" => htmlspecialchars($_POST["application-text"])
]);
Renderer::includeTemplate("frontend/components/layout.php", [
"layout_path" => ROUTE_ROOT . "user/user.view.php",
"layout_data" => [
"category" => $params['category'],
"applicationData" => $application,
"managerData" => $application->getManagerInfo(),
"footerShow" => false,
]
]);
} else if ($_POST["action"] == "delete") {
$application->remove();
header("Location: /user");
}
}
}

break;
}
}
Expand Down
9 changes: 7 additions & 2 deletions www/backend/routes/user/user.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
<svg width="32" height="32" style="margin: 10px" viewBox="0 -4 28 28" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <title>arrow-left</title> <desc>Created with Sketch Beta.</desc> <defs> </defs> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage"> <g id="Icon-Set-Filled" sketch:type="MSLayerGroup" transform="translate(-416.000000, -939.000000)" fill="#000000"> <path d="M443,948 L436,948 L436,950 L443,950 C443.553,950 444,949.553 444,949 C444,948.448 443.553,948 443,948 L443,948 Z M426.657,955.243 C427.047,955.633 427.047,956.267 426.657,956.657 C426.267,957.048 425.633,957.048 425.242,956.657 L418.343,949.758 C418.135,949.549 418.046,949.272 418.06,949 C418.046,948.728 418.135,948.451 418.343,948.243 L425.242,941.344 C425.633,940.953 426.267,940.953 426.657,941.344 C427.047,941.733 427.047,942.367 426.657,942.758 L421.414,948 L436,948 L436,941 C436,939.896 435.104,939 434,939 L418,939 C416.896,939 416,939.896 416,941 L416,957 C416,958.104 416.896,959 418,959 L434,959 C435.104,959 436,958.104 436,957 L436,950 L421.414,950 L426.657,955.243 L426.657,955.243 Z" id="arrow-left" sketch:type="MSShapeGroup"> </path> </g> </g> </g></svg>
<?= $GLOBALS["locale"]["buttons"]["backtolist"] ?>
</a>
<form class="application-form">
<form class="application-form" method="post">
<div class="info-block">
<strong><?= $GLOBALS["locale"]["userPage"]["applicationInfo"]["manager"] ?></strong>
<div class="row-block">
Expand All @@ -271,7 +271,12 @@

<div class="info-block">
<strong><?= $GLOBALS["locale"]["userPage"]["applicationInfo"]["text"] ?></strong>
<p><?= $applicationData->text ?></p>
<textarea name="application-text"><?= $applicationData->text ?></textarea>
</div>

<div class="row-block">
<button name="action" value="edit" style="margin: 10px;" class="small-primary-button"><?= $GLOBALS["locale"]["buttons"]["edit"] ?></button>
<button name="action" value="delete" style="margin: 10px;" class="small-primary-button"><?= $GLOBALS["locale"]["buttons"]["recall"] ?></button>
</div>
</div>
</form>
Expand Down
12 changes: 9 additions & 3 deletions www/data/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
}
},
"nullField": "Not clarified",
"noStatus": "In process"
"noStatus": "In process",
"noApplications": "No applications sent yet"
},
"success": {
"settings": {
Expand Down Expand Up @@ -85,7 +86,9 @@
},
"repeatPassword": {
"placeholder": "Repeat new password"
}
},

"header02": "Language"
}
},
"applicationInfo": {
Expand Down Expand Up @@ -152,7 +155,10 @@
"backtolist": "Back to list",
"update": "Update",

"delete": "Delete"
"delete": "Delete",
"edit": "Edit",

"recall": "Recall"
},
"successMessages": {
"updatedData": "Application was updated"
Expand Down
12 changes: 9 additions & 3 deletions www/data/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
}
},
"nullField": "Не назначено",
"noStatus": "В процессе"
"noStatus": "В процессе",
"noApplications": "Не отправлено ни одной заявки"
},
"success": {
"settings": {
Expand Down Expand Up @@ -85,7 +86,9 @@
},
"repeatPassword": {
"placeholder": "Повторите новый пароль"
}
},

"header02": "Язык"
}
},
"applicationInfo": {
Expand Down Expand Up @@ -152,7 +155,10 @@
"backtolist": "Назад к списку",
"update": "Обновить",

"delete": "Удалить"
"delete": "Удалить",
"edit": "Отредактировать",

"recall": "Отозвать"
},
"successMessages": {
"updatedData": "Заявка успешно обновлена"
Expand Down
27 changes: 27 additions & 0 deletions www/frontend/components/settings/securityBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,33 @@
<p class="message-success"><?= $GLOBALS["locale"]["success"]["settings"]["profileSettings"] ?></p>
<?php } ?>

<div style="margin-top: 20px;">
<div class="settings-row-header">
<div class="tiny-icon">
<svg fill="#000000" viewBox="0 0 20 20" 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="M19.753 10.909c-.624-1.707-2.366-2.726-4.661-2.726-.09 0-.176.002-.262.006l-.016-2.063 3.525-.607c.115-.019.133-.119.109-.231-.023-.111-.167-.883-.188-.976-.027-.131-.102-.127-.207-.109-.104.018-3.25.461-3.25.461l-.013-2.078c-.001-.125-.069-.158-.194-.156l-1.025.016c-.105.002-.164.049-.162.148l.033 2.307s-3.061.527-3.144.543c-.084.014-.17.053-.151.143s.19 1.094.208 1.172c.018.08.072.129.188.107l2.924-.504.035 2.018c-1.077.281-1.801.824-2.256 1.303-.768.807-1.207 1.887-1.207 2.963 0 1.586.971 2.529 2.328 2.695 3.162.387 5.119-3.06 5.769-4.715 1.097 1.506.256 4.354-2.094 5.98-.043.029-.098.129-.033.207l.619.756c.08.096.206.059.256.023 2.51-1.73 3.661-4.515 2.869-6.683zm-7.386 3.188c-.966-.121-.944-.914-.944-1.453 0-.773.327-1.58.876-2.156a3.21 3.21 0 0 1 1.229-.799l.082 4.277c-.385.131-.799.185-1.243.131zm2.427-.553l.046-4.109c.084-.004.166-.01.252-.01.773 0 1.494.145 1.885.361.391.217-1.023 2.713-2.183 3.758zm-8.95-7.668a.196.196 0 0 0-.196-.145h-1.95a.194.194 0 0 0-.194.144L.008 16.916c-.017.051-.011.076.062.076h1.733c.075 0 .099-.023.114-.072l1.008-3.318h3.496l1.008 3.318c.016.049.039.072.113.072h1.734c.072 0 .078-.025.062-.076-.014-.05-3.083-9.741-3.494-11.04zm-2.618 6.318l1.447-5.25 1.447 5.25H3.226z"></path></g></svg>
</div>

<h2><?= $GLOBALS["locale"]["userPage"]["settings"]["password"]["header02"] ?></h2>
</div>

<div class="settings-row">
<select id="language-input" name="language-input">
<option value="en-US" <?= $_COOKIE["locale"] ? "selected" : "" ?>>English</option>
<option value="ru-RU" <?= $_COOKIE["locale"] ? "selected" : "" ?>>Русский</option>
</select>
</div>

<script>
window.addEventListener("DOMContentLoaded", function() {
const languageInput = document.getElementById("language-input");
languageInput.onchange = function() {
document.cookie = `locale=${this.value}`;
}
});
</script>

</div>

<div class="settings-buttons-block">
<button class="small-primary-button"><?= $GLOBALS["locale"]["buttons"]["saveButton"] ?></button>
<div class="primary-link-button"><?= $GLOBALS["locale"]["buttons"]["discardButton"] ?></div>
Expand Down
17 changes: 12 additions & 5 deletions www/includes/wtframework/locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@


$locale_data = "";
if (isset($geoDetails->country))

if (!isset($_COOKIE["locale"]))
{
if (in_array($geoDetails->country, $regionLocales["Russian"]["regions"])) {
$locale_data = file_get_contents(realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $regionLocales["Russian"]["localeCode"] . '.json');
if (isset($geoDetails->country))
{
if (in_array($geoDetails->country, $regionLocales["Russian"]["regions"])) {
$locale_data = file_get_contents(realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $regionLocales["Russian"]["localeCode"] . '.json');
} else {
$locale_data = file_get_contents(realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $regionLocales["English"]["localeCode"] . '.json');
}
} else {
$locale_data = file_get_contents(realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $regionLocales["English"]["localeCode"] . '.json');
$locale_data = file_get_contents(realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $regionLocales["Russian"]["localeCode"] . '.json');
}
} else {
$locale_data = file_get_contents(realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $regionLocales["Russian"]["localeCode"] . '.json');
$locale_data = file_get_contents(realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $_COOKIE["locale"] . '.json');
}


$GLOBALS["locale"] = json_decode($locale_data, JSON_OBJECT_AS_ARRAY);
} else {
Expand Down

0 comments on commit f4696a4

Please sign in to comment.