add mailto to reports
This commit is contained in:
+2
-1
@@ -14,8 +14,9 @@ services:
|
||||
- internal
|
||||
- myadmin
|
||||
www:
|
||||
image: registry.docker.rhost.ovh/sprawozdania:0.2.2
|
||||
image: registry.docker.rhost.ovh/sprawozdania:0.2.3
|
||||
restart: on-failure
|
||||
platform: linux/x86_64
|
||||
build:
|
||||
context: .
|
||||
dockerfile: services/www/Dockerfile
|
||||
|
||||
@@ -24,5 +24,8 @@ services:
|
||||
resource: '../src/Services/'
|
||||
arguments:
|
||||
- '@doctrine.orm.entity_manager'
|
||||
App\Twig\AppExtension:
|
||||
arguments:
|
||||
- '@twig'
|
||||
# add more service definitions when explicit configuration is needed
|
||||
# please note that last definitions always *replace* previous ones
|
||||
|
||||
@@ -4,7 +4,10 @@ namespace App\Entity;
|
||||
|
||||
use App\Enum\ReportStatus;
|
||||
use App\Enum\ReportTodoEnum;
|
||||
use App\Helper\MonthHelper;
|
||||
use App\Repository\ReportsRepository;
|
||||
use App\Services\AddReports;
|
||||
use App\Services\MailtoServices;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
@@ -127,6 +130,11 @@ class Reports
|
||||
return $this->isReportsTodo(ReportTodoEnum::COMPLETE);
|
||||
}
|
||||
|
||||
public function isEmailSend(): bool
|
||||
{
|
||||
return $this->isReportsTodo(ReportTodoEnum::SENT_EMAIL);
|
||||
}
|
||||
|
||||
public function countTodoReports(): int
|
||||
{
|
||||
$count = 0;
|
||||
@@ -197,4 +205,11 @@ class Reports
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function takeMailToUrl(): string
|
||||
{
|
||||
$service = new MailtoServices();
|
||||
|
||||
return $service->takeUrl($this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace App\Helper;
|
||||
|
||||
use App\Services\OverdueReports;
|
||||
use Symfony\Component\Validator\Constraints\Date;
|
||||
|
||||
class MonthHelper
|
||||
{
|
||||
@@ -53,4 +54,29 @@ class MonthHelper
|
||||
}
|
||||
return $monthCurrent['date'];
|
||||
}
|
||||
|
||||
|
||||
public static function takeMonthNameForEmail(int $month) : string
|
||||
{
|
||||
$months = [
|
||||
"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"
|
||||
];
|
||||
return $months[$month - 1] ?? "";
|
||||
}
|
||||
|
||||
public static function takeDateFormatWithPolishMonths(\DateTimeInterface $date, bool $showDays = true): string
|
||||
{
|
||||
$day = $date->format('d');
|
||||
$month = $date->format('n');
|
||||
$year = $date->format('Y');
|
||||
$monthName = self::takeMonthNameForEmail($month);
|
||||
|
||||
$stringReturn = "";
|
||||
if ($showDays) {
|
||||
$stringReturn .= "$day ";
|
||||
}
|
||||
$stringReturn .= "$monthName $year";
|
||||
|
||||
return $stringReturn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Services;
|
||||
|
||||
use App\Entity\Clients;
|
||||
use App\Entity\Reports;
|
||||
use App\Helper\MonthHelper;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Twig\Environment;
|
||||
|
||||
class MailtoServices extends AbstractController
|
||||
{
|
||||
public function takeUrl(Reports $reports): string
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,10 @@
|
||||
// src/Twig/AppExtension.php
|
||||
namespace App\Twig;
|
||||
|
||||
use App\Entity\Clients;
|
||||
use App\Entity\Reports;
|
||||
use App\Helper\MonthHelper;
|
||||
use App\Services\AddReports;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
@@ -20,6 +24,7 @@ class AppExtension extends AbstractExtension
|
||||
return [
|
||||
new TwigFunction('enum', [$this, 'enumChecker']),
|
||||
new TwigFunction('is_route_active', [$this, 'getActualRoute']),
|
||||
new TwigFunction('getMailtoLink', [$this, 'getMailtoLink']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -41,4 +46,28 @@ class AppExtension extends AbstractExtension
|
||||
{
|
||||
return $value === $route ? 'active' : '';
|
||||
}
|
||||
|
||||
public function getMailtoLink(Reports $reports): string
|
||||
{
|
||||
$subject = rawurlencode("Sprawozdanie z wykonania układu");
|
||||
$dateBase = (clone $reports->getDateStart())->modify("-1 month");
|
||||
|
||||
$template = "email/report.html.twig";
|
||||
$dateStart = (clone $dateBase)->modify("-".(AddReports::NEXT_REPORT_MONTH-1)." months")->modify("first day of this month");
|
||||
if ($reports->getNumber() === 1){
|
||||
$template = "email/firstReport.html.twig";
|
||||
$dateStart = $reports->getClient()->getDateLegitimacy();
|
||||
}
|
||||
$view = sprintf(
|
||||
file_get_contents($_SERVER['PWD']."/templates/".$template),
|
||||
MonthHelper::takeDateFormatWithPolishMonths($dateStart),
|
||||
MonthHelper::takeDateFormatWithPolishMonths($dateBase->modify("last day of this month"))
|
||||
);
|
||||
$content = rawurlencode($view);
|
||||
|
||||
/** @var Clients $client */
|
||||
$client = $reports->getClient();
|
||||
|
||||
return "mailto:{$client->getStrEmail()}?subject=$subject&body=$content";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
Szanowni Państwo,
|
||||
w związku z prawomocnym zatwierdzeniem układu sąd ustanowił nadzorcą wykonania układu Pana Michała Kolczyńskiego. Wiąże się to z koniecznością składania do sądu kwartalnych sprawozdań z wykonania układu i realizacji płatności.
|
||||
|
||||
Co za tym idzie, zwracam się z uprzejmą prośbą o przesłanie potwierdzeń dokonanych przelewów rat układowych za okres od %s roku do %s roku
|
||||
oraz o odpowiedź na następujące pytania:
|
||||
|
||||
1) Czy w okresie sprawozdawczym nastąpiły zwolnienia lub zatrudnienia pracowników;
|
||||
|
||||
2) Czy zbyty lub nabyty został jakiś majątek?
|
||||
|
||||
3) Proszę wymienić najważniejsze wydarzenia w działalności. (Czy udało się pozyskać nowych kontrahentów? Rozszerzenie rynku zbytu, nowe usługi, obniżenie kosztów utrzymania, nowi dostawcy?)
|
||||
|
||||
4) Czy nastąpiły jakieś zmiany organizacyjne?
|
||||
|
||||
Proszę o przekazanie niniejszych informacji oraz dokumentów w nieprzekraczalnym terminie 5 dni od otrzymania wiadomości.
|
||||
|
||||
W razie pytań lub wątpliwości proszę o kontakt z asystentem prowadzącym postępowanie.
|
||||
@@ -0,0 +1,15 @@
|
||||
Szanowni Państwo,
|
||||
|
||||
zwracam się z uprzejmą prośbą o przesłanie potwierdzeń dokonanych przelewów rat układowych za okres od %s roku do %s roku oraz o odpowiedź na następujące pytania:
|
||||
|
||||
1) Czy w okresie sprawozdawczym nastąpiły zwolnienia lub zatrudnienia pracowników;
|
||||
|
||||
2) Czy zbyty lub nabyty został jakiś majątek?
|
||||
|
||||
3) Proszę wymienić najważniejsze wydarzenia w działalności. (Czy udało się pozyskać nowych kontrahentów? Rozszerzenie rynku zbytu, nowe usługi, obniżenie kosztów utrzymania, nowi dostawcy?)
|
||||
|
||||
4) Czy nastąpiły jakieś zmiany organizacyjne?
|
||||
|
||||
Proszę o przekazanie niniejszych informacji oraz dokumentów w nieprzekraczalnym terminie 5 dni od otrzymania wiadomości.
|
||||
|
||||
W razie pytań lub wątpliwości proszę o kontakt z asystentem prowadzącym postępowanie.
|
||||
@@ -61,6 +61,11 @@
|
||||
{# {% if not enum(groupStatus, 'COMPLETE') %}#}
|
||||
<div class="card-body">
|
||||
<p class="card-text">{{ _self.statusForm(report, reportToDoList, groupStatus) }}</p>
|
||||
|
||||
{% if is_granted('reportEdit') and not report.isEmailSend %}
|
||||
<a class="btn btn-sm btn-outline-primary" href="{{ getMailtoLink(report) }}">Wyślij maila</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{# {% endif %}#}
|
||||
{% if enum(groupStatus, 'WORKING') %}
|
||||
|
||||
Reference in New Issue
Block a user