Merge pull request #432 from allerta-vvf/master

Improve services
This commit is contained in:
Matteo Gheza 2022-01-14 22:23:14 +01:00 committed by GitHub
commit aacf445671
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View File

@ -97,9 +97,9 @@ function apiRouter (FastRoute\RouteCollector $r) {
requireLogin() || accessDenied();
$users->online_time_update();
if($users->hasRole(Role::FULL_VIEWER)) {
$response = $db->select("SELECT * FROM `".DB_PREFIX."_profiles` ORDER BY available DESC, chief DESC, services ASC, trainings DESC, availability_minutes DESC, name ASC WHERE `hidden` = 0");
$response = $db->select("SELECT * FROM `".DB_PREFIX."_profiles` WHERE `hidden` = 0 ORDER BY available DESC, chief DESC, services ASC, trainings DESC, availability_minutes ASC, name ASC");
} else {
$response = $db->select("SELECT `id`, `chief`, `online_time`, `available`, `availability_minutes`, `name`, `driver`, `services` FROM `".DB_PREFIX."_profiles` ORDER BY available DESC, chief DESC, services ASC, trainings DESC, availability_minutes DESC, name ASC WHERE `hidden` = 0");
$response = $db->select("SELECT `id`, `chief`, `online_time`, `available`, `availability_minutes`, `name`, `driver`, `services` FROM `".DB_PREFIX."_profiles` WHERE `hidden` = 0 ORDER BY available DESC, chief DESC, services ASC, trainings DESC, availability_minutes ASC, name ASC");
}
apiResponse(
!is_null($response) ? $response : []

View File

@ -61,16 +61,16 @@ function sendTelegramNotification($message)
$chats = $db->select("SELECT * FROM `".DB_PREFIX."_bot_telegram_notifications`");
if(!is_null($chats)) {
foreach ($chats as $chat) {
if($chat['last_notification'] === $message) continue;
if(urldecode($chat['last_notification']) === $message) continue;
$chat = $chat['chat_id'];
$Bot->sendMessage([
"chat_id" => $chat,
"text" => $message
]);
$db->update(
"`".DB_PREFIX."_bot_telegram_notifications`",
["last_notification" => $message],
["id" => $chat["id"]]
DB_PREFIX."_bot_telegram_notifications",
["last_notification" => urlencode($message)],
["chat_id" => $chat]
);
}
}

View File

@ -361,7 +361,7 @@ class Services {
public function increment_counter($increment)
{
$increment = str_replace(";", ",", $increment);
$increment = implode(",", array_unique(explode(",", str_replace(";", ",", $increment))));
$this->db->exec(
"UPDATE `".DB_PREFIX."_profiles` SET `services`= services + 1 WHERE id IN ($increment)"
);
@ -369,7 +369,7 @@ class Services {
public function decrement_counter($decrement)
{
$decrement = str_replace(";", ",", $decrement);
$decrement = implode(",", array_unique(explode(",", str_replace(";", ",", $decrement))));
$this->db->exec(
"UPDATE `".DB_PREFIX."_profiles` SET `services`= services - 1 WHERE id IN ($decrement)"
);
@ -392,7 +392,7 @@ class Services {
);
$serviceId = $this->db->getLastInsertId();
$this->increment_counter($chief.";".$drivers.";".$crew);
$this->increment_counter($chief.",".$drivers.",".$crew);
logger("Service added");
return $serviceId;

View File

@ -58,7 +58,7 @@
<label>Altri membri della squadra</label>
<br>
<ng-container *ngFor="let user of users">
<div class="form-check" *ngIf="!user.chief && !user.driver">
<div class="form-check" *ngIf="!user.chief">
<input class="form-check-input crew-{{ user.id }}" [class.is-invalid]="!isFieldValid('crew')"
(change)="onCrewCheckboxChange($event)" [checked]="isCrewSelected(user.id)" type="checkbox" value='{{ user.id }}'>
<label class="form-check-label" for="crew-{{ user.id }}">