add highlight report
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250329215035 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reports ADD highlight INT DEFAULT 0 NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reports DROP highlight');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250330100207 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE clients ADD highlight INT DEFAULT 0 NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE clients DROP highlight');
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,21 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header text-center"><h2>Oznaczenie</h2></div>
|
||||
<div class="card-body">
|
||||
|
||||
<form action="{{ path('app_client_highlight',{id: client.id}) }}" method="post">
|
||||
<input type="hidden" name="token" value="{{ csrf_token('client-highlight') }}">
|
||||
{% for status in highlightStatus %}
|
||||
<button type="submit" name="highlight_id" value="{{ status.value }}" class="btn btn-{{ status.borderColor }}">
|
||||
{{ status.buttonLang }}
|
||||
</button>
|
||||
{% endfor %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<h3 class="card-header">{{ reports.status.takeLang }}</h3>
|
||||
<div class="card-body">
|
||||
{% for report in reports.reports %}
|
||||
{{ sets.cardView(report, reports.status, reportToDoList) }}
|
||||
{{ sets.cardView(report, reports.status, reportToDoList,highlightStatus) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro cardView(report, groupStatus, reportToDoList) %}
|
||||
<div class="card text-{{ groupStatus.textColor }} report-one {{ groupStatus.name | lower }}" data-report_id="{{ report.id }}">
|
||||
<div class="report-number">
|
||||
{% macro cardView(report, groupStatus, reportToDoList, highlightStatus) %}
|
||||
<div class="card text-{{ groupStatus.textColor }} report-one {{ groupStatus.name | lower }} border-{{ report.client.highlight.borderColor }}" data-report_id="{{ report.id }}">
|
||||
<div class="report-number" data-bs-toggle="modal" data-bs-target="#editSchedule{{ report.id }}">
|
||||
<div class="badge bg-{{ groupStatus.takeBadgeBg }} text-dark" data-toggle="tooltip" data-placement="bottom" title="Numer sprawozdania">{{ report.number }}</div>
|
||||
</div>
|
||||
{% if enum(groupStatus, 'COMPLETE') and false %}
|
||||
@@ -49,7 +49,7 @@
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card-header">
|
||||
<div class="card-header bg-{{ report.highlight.borderColor }}">
|
||||
<h5 class="card-title">
|
||||
{% if is_granted('clientView') %}
|
||||
<a href="{{ path('app_client',{id: report.client.id}) }}" >{{ report.client.strName }}</a>
|
||||
@@ -74,4 +74,29 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="editSchedule{{ report.id }}" tabindex="-1" aria-labelledby="editSchedule{{ report.id }}Label" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="exampleModalLabel">Ustaw wyróżnienie sprawozdania</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ path('app_report_highlight',{id: report.id}) }}" method="post">
|
||||
<input type="hidden" name="token" value="{{ csrf_token('schedule-highlight') }}">
|
||||
{% for status in highlightStatus %}
|
||||
<button type="submit" name="highlight_id" value="{{ status.value }}" class="btn btn-{{ status.borderColor }}">
|
||||
{{ status.buttonLang }}</button>
|
||||
{% endfor %}
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Zamknij</button>
|
||||
{# <button type="button" class="btn btn-primary">Save changes</button>#}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user