diff --git a/docker-compose.yml b/docker-compose.yml index 32ae6e0..82f6c53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: . diff --git a/project/assets/controllers/customer-show_controller.js b/project/assets/controllers/customer-show_controller.js new file mode 100644 index 0000000..e36239f --- /dev/null +++ b/project/assets/controllers/customer-show_controller.js @@ -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; + } + } + } +} diff --git a/project/assets/styles/main.less b/project/assets/styles/main.less index 948c4d5..9b29b24 100644 --- a/project/assets/styles/main.less +++ b/project/assets/styles/main.less @@ -5,50 +5,50 @@ body { .col { margin-bottom: 20px; } - .report-one { - .card-header { - display: flex; - .card-title { - margin: auto; - } - } - &.complete { - .card-header { - min-height: 52px; - } - } - margin-bottom: 10px; - .fa{ +} +.report-one { + .card-header { + display: flex; + .card-title { margin: auto; - font-size: 20px; - padding: 5px 20px; } - .btn-group { - width: 100%; + } + &.complete { + .card-header { + min-height: 52px; } - .report-number { - position: absolute; - right: 3px; - width: 25px; - height: 25px; - .badge { - font-size: 15px; - } + } + margin-bottom: 10px; + .fa{ + margin: auto; + font-size: 20px; + padding: 5px 20px; + } + .btn-group { + width: 100%; + } + .report-number { + position: absolute; + right: 3px; + width: 25px; + height: 25px; + .badge { + font-size: 15px; } - .report-mark-uncompleted { - width: 25px; - height: 25px; - cursor: pointer; - font-size: 12px; - position: absolute; - right: 2px; - top:26px; - .fa { - padding: 0; - } - .badge { - border: none; - } + } + .report-mark-uncompleted { + width: 25px; + height: 25px; + cursor: pointer; + font-size: 12px; + position: absolute; + right: 2px; + top:26px; + .fa { + padding: 0; + } + .badge { + border: none; } } } @@ -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; +} \ No newline at end of file diff --git a/project/config/secrets/prod/prod.DATABASE_PASSWORD.b77cc3.php b/project/config/secrets/prod/prod.DATABASE_PASSWORD.b77cc3.php index 027fd8f..26eeb6f 100644 --- a/project/config/secrets/prod/prod.DATABASE_PASSWORD.b77cc3.php +++ b/project/config/secrets/prod/prod.DATABASE_PASSWORD.b77cc3.php @@ -1,3 +1,3 @@ -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; diff --git a/project/src/Controller/ClientController.php b/project/src/Controller/ClientController.php index 1d4d66a..6aef647 100644 --- a/project/src/Controller/ClientController.php +++ b/project/src/Controller/ClientController.php @@ -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])] diff --git a/project/src/Repository/ReportsRepository.php b/project/src/Repository/ReportsRepository.php index 9ddc2ae..2eb0c0b 100644 --- a/project/src/Repository/ReportsRepository.php +++ b/project/src/Repository/ReportsRepository.php @@ -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; diff --git a/project/src/Services/OverdueReports.php b/project/src/Services/OverdueReports.php index 269d859..c4137a8 100644 --- a/project/src/Services/OverdueReports.php +++ b/project/src/Services/OverdueReports.php @@ -1,6 +1,7 @@ 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 []; } diff --git a/project/templates/customers/show.html.twig b/project/templates/customers/show.html.twig index 58fa781..6a2848c 100644 --- a/project/templates/customers/show.html.twig +++ b/project/templates/customers/show.html.twig @@ -1,132 +1,171 @@ +{% import 'reports/listInclude.html.twig' as sets %} {% extends 'base.html.twig' %} {% block body %} - {% if client.isComplete %} -
Zakończono generowanie sprawozdań!
- {% endif %} -
-
-
-
-

{{ client.strName }}

-
-
    -
  • Adres: {{ client.strAddress }}
  • -
  • NIP: {{ client.intNIP }}
  • -
  • E-mail: {{ client.strEmail }}
  • -
  • Telefon: {{ client.intPhone | phone }}
  • -
  • Data prawomocności: {{ client.dateLegitimacy | date("d-m-Y") }}
  • -
  • Data obwieszczenia: {{ client.dateProclamation | date("d-m-Y") }}
  • - {% if schedules %} -
  • - Harmonogram: - {% if schedules.isDone %} - wysłano: {{ schedules.getDateDone | date("d-m-Y H:i") }} - {% else %} - Pozostały czas: {{ schedules.getTimeLeft }} dni - {% endif %} -
  • - {% endif %} -
- -
- {% if is_granted('reportView') %} -
+
+ {% if client.isComplete %} +
Zakończono generowanie sprawozdań!
+ {% endif %} +
+
+
-

Sprawozdania

- {% if not client.isComplete and is_granted('reportEdit') %} -
- - - -
- {% endif %} +

{{ client.strName }}

-
-
    - {% for report in reports %} -
  • - {{ report.number }} - {{ report.getDateStart | date("Y-m-d") }} +
      +
    • Adres: {{ client.strAddress }}
    • +
    • NIP: {{ client.intNIP }}
    • +
    • E-mail: {{ client.strEmail }}
    • +
    • Telefon: {{ client.intPhone | phone }}
    • +
    • Data prawomocności: {{ client.dateLegitimacy | date("d-m-Y") }}
    • +
    • Data obwieszczenia: {{ client.dateProclamation | date("d-m-Y") }}
    • + {% if schedules %} +
    • + Harmonogram: + {% if schedules.isDone %} + wysłano: {{ schedules.getDateDone | date("d-m-Y H:i") }} + {% else %} + Pozostały czas: {{ schedules.getTimeLeft }} dni + {% endif %} +
    • + {% endif %} +
    + +
+ {% if is_granted('reportView') %} +
+
+

Sprawozdania

+ {% if not client.isComplete and is_granted('reportEdit') %} +
+ + + +
+ {% endif %} +
+
+
    + {% for report in reports %} +
  • + {{ report.number }} + {{ report.getDateStart | date("Y-m-d") }} + + {% for todo in report.getReportsTodos %} + {% if report.isReportsTodo(todo.getName) %} + {{ todo.getName.takeLang }} - {% endif %} - {% endfor %} -
  • - {% endfor %} -
-
-
- {% endif %} -
-
-
-

Notatka

- {% if notes %} -
-

- {% apply markdown_to_html %} - {{ notes.description }} - {% endapply %} -

-
- {% endif %} - {% if not client.isComplete and is_granted('clientEdit') %} -
{% endif %}
-
-
- - - -