major fixes

This commit is contained in:
2024-09-25 16:55:03 +02:00
parent e1cb68766e
commit 598acfd77c
12 changed files with 351 additions and 236 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ services:
- internal
- myadmin
www:
image: registry.docker.rhost.ovh/sprawozdania:0.2.0
image: registry.docker.rhost.ovh/sprawozdania:0.2.2
restart: on-failure
build:
context: .
@@ -0,0 +1,35 @@
import { Controller } from '@hotwired/stimulus';
/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
allCardsDiv;
connect() {
this.allCardsDiv = $('#allCardsReport .report-one');
}
showModal(){
const reportId = event.params.reportid, date = event.params.date;
$("#showReportModal").find('.modal-body').html(
this.findReport(reportId)
);
$("#showReportModal").find('.modal-title').html(date)
$("#showReportModal").modal('show');
}
findReport(id) {
for (const allCardsDivKey of this.allCardsDiv) {
const tmp = $(allCardsDivKey);
if (tmp.data('report_id') === id) {
return tmp;
}
}
}
}
+15 -1
View File
@@ -5,6 +5,7 @@ body {
.col {
margin-bottom: 20px;
}
}
.report-one {
.card-header {
display: flex;
@@ -51,7 +52,6 @@ body {
}
}
}
}
.reports-months-all {
margin-bottom: 20px;
}
@@ -66,3 +66,17 @@ a {
top: 2px;
right: 2px;
}
.card-footer {
.edit-client-group {
display: inline-flex;
margin: auto;
>div {
padding: 10px;
}
}
}
#allCardsReport{
display: none;
opacity: 0;
}
@@ -1,3 +1,3 @@
<?php // prod.DATABASE_PASSWORD.b77cc3 on Thu, 25 Jul 2024 14:54:39 +0200
<?php // prod.DATABASE_PASSWORD.b77cc3 on Wed, 21 Aug 2024 11:10:09 +0200
return "\x0FA\x82\x24\x0E\xC5I\x1Ep7\xA5A\x1Cx\x80\x18m\xB0\x17\x1B\x82B\x92\x99\xAF\x9APi\x24\x9B\x009\x15\xA4\x25k\xBE\x20\xE8t\xF9\xD1\xF9W\xD3\xC4\x25\xFFU\x7D\xAF\x04\xE9\xF9j\x7F\xFBFZ\x81\x0A\x254\x12";
return "u\x2C\x1D\xF4\x2CKm\x98\xCA\x01\x7C\xABJ\x3A\xA7\xCA\x1B\x94R\x98\xF5D\xC9\x25\xCDY\xDF\x5C\x23\x8DLK\xBD\x03jew\x5C9\x7B\x7F\x05\x5EE\x21Z\x9A\xB0\x87\xC9\xB8\xCES\xB7N\xE6\xFF\xA4\xB6\xDA\xFC\xC8\xB3\x94";
+15 -10
View File
@@ -36,18 +36,21 @@ class BaseController extends AbstractController
}
return $this->redirectToRoute('app_base');
}
#[Route('/reports/{monthId}', name: 'app_base')]
#[Route('/reports/{monthId}/{clientId}', name: 'app_base')]
#[IsGranted('reportView')]
public function reportsIndex(EntityManagerInterface $entityManager, CacheInterface $cache, OverdueReports $overdueReports, int $monthId = 0) : Response
public function reportsIndex(EntityManagerInterface $entityManager, CacheInterface $cache, OverdueReports $overdueReports, int $monthId = 0, int $clientId = 0) : Response
{
$client = null;
if ($clientId) {
$client = $entityManager->getRepository(Clients::class)->find($clientId);
}
$overdueReports->setClient($client);
$monthHelper = new MonthHelper($overdueReports);
$isOverdue = false;
$monthCurrentDate = $monthHelper->getCurrentMonthDate($monthId);
$reportsAll = $this->takeReportsAll($entityManager,$cache,$monthCurrentDate);
$reportsAll = $this->takeReportsAll($entityManager, $clientId, $monthCurrentDate);
if ($monthId > -1) {
$reportsAll = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrentDate);
} else {
if ($monthId < 0) {
$isOverdue = true;
}
@@ -69,16 +72,18 @@ class BaseController extends AbstractController
'currentMonth' => $monthCurrentDate ?? null,
'reportToDoList' => ReportTodoEnum::cases(),
'isOverdue' => $isOverdue,
'countOverdueLeft' => $overdueReports->getLeftCount()
'countOverdueLeft' => $overdueReports->getLeftCount(),
'client' => $client,
'clientId' => $clientId
]);
}
private function takeReportsAll(EntityManagerInterface $entityManager, CacheInterface $cache, ?\DateTime $monthCurrent = null) : array
private function takeReportsAll(EntityManagerInterface $entityManager, int $clientId, ?\DateTime $monthCurrent = null) : array
{
if ($monthCurrent !== null) {
$ret = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrent);
$ret = $entityManager->getRepository(Reports::class)->findAllInMonth($monthCurrent,$clientId);
} else {
$ret = $entityManager->getRepository(Reports::class)->findAllOverdue();
$ret = $entityManager->getRepository(Reports::class)->findAllOverdue($clientId);
}
return $ret;
+5 -2
View File
@@ -6,6 +6,8 @@ use App\Entity\Clients;
use App\Entity\Notes;
use App\Entity\Reports;
use App\Entity\Schedule;
use App\Enum\ReportStatus;
use App\Enum\ReportTodoEnum;
use App\Services\AddReports;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -50,13 +52,14 @@ class ClientController extends AbstractController
$schedules = $entityManager->getRepository(Schedule::class)->findOneBy(["client" => $clients->getId()]);
$reports = $entityManager->getRepository(Reports::class)->findBy(["client" => $clients->getId()],["number"=>"DESC"]);
$notes = $entityManager->getRepository(Notes::class)->findOneBy(["clientId" => $clients->getId()]);
return $this->render('customers/show.html.twig', [
'client' => $clients,
'schedules' => $schedules,
'reports' => $reports,
'notes' => $notes,
'backUrl' => $request->headers->get('referer')
'backUrl' => $request->headers->get('referer'),
'reportToDoList' => ReportTodoEnum::cases(),
'reportStatus' => ReportStatus::INSERT
]);
}
#[Route('/dodaj_klienta/{id}', name: 'app_add_client', defaults: ['id'=>0])]
+16 -8
View File
@@ -26,7 +26,7 @@ class ReportsRepository extends ServiceEntityRepository
return parent::findBy($criteria, $orderBy, $limit, $offset); // TODO: Change the autogenerated stub
}
public function findAllOverdue()
public function findAllOverdue(int $clientId = 0)
{
$dateEnd = new \DateTime();
$dateEnd->modify("last day of previous month");
@@ -36,7 +36,12 @@ class ReportsRepository extends ServiceEntityRepository
->andWhere('r.isDone = :isDone')
->setParameter('isDone', 0)
->setParameter('isDelete', 0)
->setParameter('dateEnd', $dateEnd)
->setParameter('dateEnd', $dateEnd);
if ($clientId > 0) {
$reports->andWhere('r.client = :client');
$reports->setParameter('client', $clientId);
}
$reports = $reports
->orderBy("r.number","ASC")
->getQuery()
->getResult();
@@ -48,8 +53,9 @@ class ReportsRepository extends ServiceEntityRepository
/**
* @return Reports[] Returns an array of Reports objects
* @throws \DateMalformedStringException
*/
public function findAllInMonth(\DateTime $date): array
public function findAllInMonth(\DateTime $date, int $clientId = 0): array
{
$dateStart = clone $date;
$dateStart->modify("first day of this month");
@@ -61,13 +67,15 @@ class ReportsRepository extends ServiceEntityRepository
->andWhere('r.isDelete = :deleted')
->setParameter('dateStart', $dateStart->format('Y-m-d'))
->setParameter('dateEnd', $dateEnd->format('Y-m-d'))
->setParameter('deleted', 0)
->setParameter('deleted', 0);
if ($clientId > 0) {
$reports->andWhere('r.client = :client');
$reports->setParameter('client', $clientId);
}
$reports = $reports
->orderBy("r.number","ASC")
// ->setMaxResults(10)
->getQuery()
->getResult()
;
->getResult();
// $this->countReport($reports);
return $reports;
+16 -4
View File
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Services;
use App\Entity\Clients;
use App\Entity\Reports;
use Doctrine\ORM\EntityManager;
@@ -8,12 +9,14 @@ class OverdueReports
{
private array $list;
private int $leftCount = 0;
public function __construct(private readonly EntityManager $entity){
$this->list = $this->takeOverdueList();
}
private ?Clients $client = null;
public function __construct(private readonly EntityManager $entity){}
public function getList(): array
{
if(!isset($this->list)){
$this->list = $this->takeOverdueList();
}
return $this->list;
}
@@ -22,6 +25,11 @@ class OverdueReports
$this->leftCount = $leftCount;
}
public function setClient(?Clients $client): void
{
$this->client = $client;
}
public function getLeftCount(): int
{
return $this->leftCount;
@@ -29,7 +37,11 @@ class OverdueReports
private function takeOverdueList() : array
{
$reports = $this->entity->getRepository(Reports::class)->findAllOverdue();
$clientId = 0;
if($this->client){
$clientId = $this->client->getId();
}
$reports = $this->entity->getRepository(Reports::class)->findAllOverdue($clientId);
if (!$reports) {
return [];
}
+46 -7
View File
@@ -1,5 +1,7 @@
{% import 'reports/listInclude.html.twig' as sets %}
{% extends 'base.html.twig' %}
{% block body %}
<div data-controller="customer-show">
{% if client.isComplete %}
<div class="alert alert-warning"><i class="fa-solid fa-circle-info"></i> Zakończono generowanie sprawozdań!</div>
{% endif %}
@@ -27,12 +29,19 @@
</li>
{% endif %}
</ul>
<div class="card-footer" style="display: inline-flex;margin: auto;">
<div class="card-footer">
<div class='edit-client-group'>
{% if is_granted('reportView') %}
<div>
<a href="{{ path('app_base',{clientId: client.id}) }}" class="btn btn-outline-info">Wyświetl sprawozdania</a>
</div>
{% endif %}
{% if is_granted('reportEdit') %}
<form action="{{ path('app_set_complete',{id: client.id}) }}" method="post" style="padding: 0 5px;">
<div>
<form action="{{ path('app_set_complete',{id: client.id}) }}" method="post">
<input type="hidden" name="isComplete" value="1">
<input type="hidden" name="token" value="{{ csrf_token("set-complete-item") }}">
<button class="btn btn-warning" type="submit">
<button class="btn btn-outline-warning" type="submit">
{% if client.isComplete %}
Wznów
{% else %}
@@ -40,16 +49,22 @@
{% endif %}
</button>
</form>
</div>
{% endif %}
{% if not client.isComplete and is_granted('clientEdit') %}
<a href="{{ path('app_add_client',{id: client.id}) }}" class="btn btn-success">Edytuj</a>
<div>
<a href="{{ path('app_add_client',{id: client.id}) }}" class="btn btn-outline-success">Edytuj</a>
</div>
{% endif %}
{% if is_granted('clientDelete') %}
<button class="btn btn-danger" type="button" data-bs-toggle="modal" data-bs-target="#removeConfirmModal">Usuń</button>
<div>
<button class="btn btn-outline-danger" type="button" data-bs-toggle="modal" data-bs-target="#removeConfirmModal">Usuń</button>
</div>
{% endif %}
</div>
</div>
</div>
{% if is_granted('reportView') %}
<div class="card text-center bg-light-subtle">
<div class="card-header">
@@ -58,14 +73,18 @@
<form action="{{ path('app_add_next_report') }}" method="post">
<input type="hidden" name="clientId" value="{{ client.id }}">
<input type="hidden" name="token" value="{{ csrf_token('add-next-report') }}">
<button type="submit" class="btn btn-primary">Dodaj następne sprawozdanie</button>
<button type="submit" class="btn btn-outline-primary">Dodaj następne sprawozdanie</button>
</form>
{% endif %}
</div>
<div class="card-body">
<ul class="list-group list-group-flush">
{% for report in reports %}
<li class="list-group-item d-flex align-items-center">
<li class="list-group-item d-flex align-items-center"
data-action="click->customer-show#showModal"
data-customer-show-reportid-param="{{ report.id }}"
data-customer-show-date-param="{{ report.getDateStart | date("Y-m-d") }}"
>
<span class="badge rounded-pill text-bg-primary">{{ report.number }}</span>
<span class="badge rounded-pill text-bg-light">{{ report.getDateStart | date("Y-m-d") }}</span>
@@ -129,4 +148,24 @@
</div>
</div>
</div>
<div class="modal fade" id="showReportModal" tabindex="-1" aria-labelledby="showReportModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="showReportModalLabel"></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
<div id="allCardsReport">
{% for report in reports %}
{{ sets.cardView(report, reportStatus, reportToDoList) }}
{% endfor %}
</div>
</div>
{% endblock %}
@@ -1,8 +1,18 @@
{% macro month_menu(routeName, months, currentMonth, countOverdueLeft) %}
{% macro month_menu(routeName, months, currentMonth, countOverdueLeft, clientId, client) %}
{% if client %}
<div class="row justify-content-center">
<div class="alert alert-info col-3 text-center " role="alert">
<h5 class="alert-heading"><strong>{{ client.strName }}</strong></h5>
<p>
<a href="{{ path(routeName,{monthId: 0}) }}" class="btn btn-outline-warning">Wróć do wszystkich</a>
</p>
</div>
</div>
{% endif %}
<div class="row reports-months-all">
<ul class="nav nav-underline nav-fill">
<li class="nav-item position-relative">
<a href="{{ path(routeName, {monthId:-1}) }}" class="nav-link {% if currentMonth is null %}active{% endif %}">Zaległe</a>
<a href="{{ path(routeName, {monthId:-1, clientId:clientId}) }}" class="nav-link {% if currentMonth is null %}active{% endif %}">Zaległe</a>
{% if countOverdueLeft > 0 %}
<div class="spinner-grow spinner-grow-sm text-danger overdue"></div>
{% endif %}
@@ -15,7 +25,7 @@
data-toggle="tooltip" data-bs-placement="bottom" title="Zaległe sprawozdania do zrobienia"
{% endif %}
>
<a class="nav-link {% if isCurrent %} active{% endif %}" href="{{ path(routeName,{monthId: id}) }}">
<a class="nav-link {% if isCurrent %} active{% endif %}" href="{{ path(routeName,{monthId: id, clientId:clientId}) }}">
{% if routeName=='app_schedule' %}
{{ id }}
{% else %}
+2 -36
View File
@@ -2,7 +2,7 @@
{% import 'navigation/switch_months.html.twig' as navigation %}
{% import 'reports/listInclude.html.twig' as sets %}
{% block body %}
{{ navigation.month_menu('app_base',months,currentMonth,countOverdueLeft) }}
{{ navigation.month_menu('app_base',months,currentMonth,countOverdueLeft,clientId,client) }}
<div class="
row
d-flex
@@ -17,41 +17,7 @@
<h3 class="card-header">{{ reports.status.takeLang }}</h3>
<div class="card-body">
{% for report in reports.reports %}
<div class="card text-{{ reports.status.textColor }} report-one {{ reports.status.name | lower }}">
<div class="report-number">
<div class="badge bg-{{ reports.status.takeBadgeBg }} text-dark" data-toggle="tooltip" data-placement="bottom" title="Numer sprawozdania">{{ report.number }}</div>
</div>
{% if enum(reports.status, 'COMPLETE') and false %}
<div class="report-mark-uncompleted">
<form action="{{ path('app_set_status_todo',{id:report.id}) }}" method="post">
<input type="hidden" name="token" value="{{ csrf_token('report-status') }}">
<input type="hidden" name="unDone" value="1">
<button type="submit" class="badge bg-danger" data-toggle="tooltip" data-placement="bottom" title="Oznacz jako nie zakończone"><i class="fa fa-solid fa-remove"></i></button>
</form>
</div>
{% endif %}
<div class="card-header">
<h5 class="card-title">
{% if is_granted('clientView') %}
<a href="{{ path('app_client',{id: report.client.id}) }}" >{{ report.client.strName }}</a>
{% else %}
{{ report.client.strName }}
{% endif %}
</h5>
</div>
{# {% if not enum(reports.status, 'COMPLETE') %}#}
<div class="card-body">
<p class="card-text">{{ sets.statusForm(report, reportToDoList, reports.status) }}</p>
</div>
{# {% endif %}#}
{% if enum(reports.status, 'WORKING') %}
<div class="card-footer bg-transparent">
{{ sets.progress(report, reportToDoList|length) }}
</div>
{% endif %}
</div>
{{ sets.cardView(report, reports.status, reportToDoList) }}
{% endfor %}
</div>
</div>
+36 -13
View File
@@ -4,19 +4,6 @@
<div class="btn-group" role="group" aria-label="Todos">
{% for todo in reportToDoList %}
<button type="submit" class="btn-check" name="{{ todo.value }}" value='1' id="checkboxToDo{{ todo.value }}Id{{ report.id }}"></button>
{# <input onchange="this.form.submit()"#}
{# name="{{ todo.value }}"#}
{# type="checkbox"#}
{# class="btn-check"#}
{# id="checkboxToDo{{ todo.value }}Id{{ report.id }}"#}
{# {% if report.isReportsTodo(todo) %}#}
{# checked="checked"#}
{# {% endif %}#}
{# {% if not is_granted('reportEdit') %}#}
{# disabled#}
{# {% endif %}#}
{# autocomplete="off"#}
{# >#}
<label class="btn
{% if report.isReportsTodo(todo) %}
btn-{{ reportEnum.checkboxColor }}
@@ -47,3 +34,39 @@
</div>
</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">
<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 %}
<div class="report-mark-uncompleted">
<form action="{{ path('app_set_status_todo',{id:report.id}) }}" method="post">
<input type="hidden" name="token" value="{{ csrf_token('report-status') }}">
<input type="hidden" name="unDone" value="1">
<button type="submit" class="badge bg-danger" data-toggle="tooltip" data-placement="bottom" title="Oznacz jako nie zakończone"><i class="fa fa-solid fa-remove"></i></button>
</form>
</div>
{% endif %}
<div class="card-header">
<h5 class="card-title">
{% if is_granted('clientView') %}
<a href="{{ path('app_client',{id: report.client.id}) }}" >{{ report.client.strName }}</a>
{% else %}
{{ report.client.strName }}
{% endif %}
</h5>
</div>
{# {% if not enum(groupStatus, 'COMPLETE') %}#}
<div class="card-body">
<p class="card-text">{{ _self.statusForm(report, reportToDoList, groupStatus) }}</p>
</div>
{# {% endif %}#}
{% if enum(groupStatus, 'WORKING') %}
<div class="card-footer bg-transparent">
{{ _self.progress(report, reportToDoList|length) }}
</div>
{% endif %}
</div>
{% endmacro %}