add highlight report
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Entity\ReportsTodo;
|
||||
use App\Enum\Months;
|
||||
use App\Enum\ReportStatus;
|
||||
use App\Enum\ReportTodoEnum;
|
||||
use App\Enum\ReportHighlight;
|
||||
use App\Helper\MonthHelper;
|
||||
use App\Services\OverdueReports;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -80,7 +81,8 @@ class BaseController extends AbstractController
|
||||
'isOverdue' => $isOverdue,
|
||||
'countOverdueLeft' => $overdueReports->getLeftCount(),
|
||||
'client' => $client,
|
||||
'clientId' => $clientId
|
||||
'clientId' => $clientId,
|
||||
'highlightStatus' => ReportHighlight::cases()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Entity\Clients;
|
||||
use App\Entity\Notes;
|
||||
use App\Entity\Reports;
|
||||
use App\Entity\Schedule;
|
||||
use App\Enum\ReportHighlight;
|
||||
use App\Enum\ReportStatus;
|
||||
use App\Enum\ReportTodoEnum;
|
||||
use App\Services\AddReports;
|
||||
@@ -59,7 +60,8 @@ class ClientController extends AbstractController
|
||||
'notes' => $notes,
|
||||
'backUrl' => $request->headers->get('referer'),
|
||||
'reportToDoList' => ReportTodoEnum::cases(),
|
||||
'reportStatus' => ReportStatus::INSERT
|
||||
'reportStatus' => ReportStatus::INSERT,
|
||||
'highlightStatus' => ReportHighlight::cases()
|
||||
]);
|
||||
}
|
||||
#[Route('/dodaj_klienta/{id}', name: 'app_add_client', defaults: ['id'=>0])]
|
||||
@@ -165,4 +167,18 @@ class ClientController extends AbstractController
|
||||
->add('submitAndRedirect', SubmitType::class, )
|
||||
->getForm();
|
||||
}
|
||||
|
||||
#[Route('/client_highlight/{id}', name: 'app_client_highlight', methods: ['POST'])]
|
||||
public function updateHighlight(EntityManagerInterface $entityManager, Request $request, Clients $client): Response
|
||||
{
|
||||
$token = $request->get("token");
|
||||
if ($this->isCsrfTokenValid('client-highlight', $token)) {
|
||||
$highlightId = intval($request->get("highlight_id"));
|
||||
$highlight = ReportHighlight::tryFrom($highlightId);
|
||||
$client->setHighlight($highlight);
|
||||
$entityManager->persist($client);
|
||||
$entityManager->flush();
|
||||
}
|
||||
return $this->redirectToRoute('app_client', ['id'=>$client->getId()]);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ namespace App\Controller;
|
||||
use App\Entity\Clients;
|
||||
use App\Entity\Reports;
|
||||
use App\Entity\ReportsTodo;
|
||||
use App\Entity\Schedule;
|
||||
use App\Enum\ReportTodoEnum;
|
||||
use App\Enum\ReportHighlight;
|
||||
use App\Services\AddReports;
|
||||
use App\Services\InvoiceServices;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -114,4 +116,18 @@ class ReportsController extends AbstractController
|
||||
{
|
||||
return new Response(var_export($_POST,true));
|
||||
}
|
||||
|
||||
#[Route('/reports_highlight/{id}', name: 'app_report_highlight', methods: ['POST'])]
|
||||
public function updateHighlight(EntityManagerInterface $entityManager, Request $request, Reports $reports): Response
|
||||
{
|
||||
$token = $request->get("token");
|
||||
if ($this->isCsrfTokenValid('schedule-highlight', $token)) {
|
||||
$highlightId = intval($request->get("highlight_id"));
|
||||
$highlight = ReportHighlight::tryFrom($highlightId);
|
||||
$reports->setHighlight($highlight);
|
||||
$entityManager->persist($reports);
|
||||
$entityManager->flush();
|
||||
}
|
||||
return $this->redirect($request->headers->get('referer') ?? $this->generateUrl('app_schedule'));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Enum\ReportHighlight;
|
||||
use App\Repository\ClientsRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -50,6 +51,9 @@ class Clients
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $intPhone = null;
|
||||
|
||||
#[ORM\Column(enumType: ReportHighlight::class, options: ["default" => "0"])]
|
||||
private ReportHighlight $highlight = ReportHighlight::STANDARD;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->schedules = new ArrayCollection();
|
||||
@@ -198,4 +202,16 @@ class Clients
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHighlight(): ReportHighlight
|
||||
{
|
||||
return $this->highlight;
|
||||
}
|
||||
|
||||
public function setHighlight(ReportHighlight $highlight): static
|
||||
{
|
||||
$this->highlight = $highlight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Enum\ReportHighlight;
|
||||
use App\Enum\ReportStatus;
|
||||
use App\Enum\ReportTodoEnum;
|
||||
use App\Helper\MonthHelper;
|
||||
@@ -49,6 +50,9 @@ class Reports
|
||||
#[ORM\Column]
|
||||
private ?int $number = null;
|
||||
|
||||
#[ORM\Column(enumType: ReportHighlight::class, options: ["default" => "0"])]
|
||||
private ReportHighlight $highlight = ReportHighlight::STANDARD;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->reportsTodos = new ArrayCollection();
|
||||
@@ -212,4 +216,16 @@ class Reports
|
||||
|
||||
return $service->takeUrl($this);
|
||||
}
|
||||
|
||||
public function getHighlight(): ReportHighlight
|
||||
{
|
||||
return $this->highlight;
|
||||
}
|
||||
|
||||
public function setHighlight(ReportHighlight $highlight): static
|
||||
{
|
||||
$this->highlight = $highlight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace App\Enum;
|
||||
|
||||
enum ReportHighlight: int
|
||||
{
|
||||
case STANDARD = 0;
|
||||
case INFO = 1;
|
||||
case WARNING = 5;
|
||||
case DANGER = 10;
|
||||
|
||||
|
||||
public function borderColor(): string
|
||||
{
|
||||
return match ($this)
|
||||
{
|
||||
ReportHighlight::STANDARD => '',
|
||||
ReportHighlight::WARNING => 'warning',
|
||||
ReportHighlight::INFO => 'info',
|
||||
ReportHighlight::DANGER => 'danger',
|
||||
};
|
||||
}
|
||||
public function buttonLang(): string
|
||||
{
|
||||
return match ($this)
|
||||
{
|
||||
ReportHighlight::STANDARD => 'Brak',
|
||||
ReportHighlight::WARNING => 'Ostrzeżenie',
|
||||
ReportHighlight::INFO => 'Informacja',
|
||||
ReportHighlight::DANGER => 'Ważne',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user