minor fixes
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ services:
|
|||||||
- internal
|
- internal
|
||||||
- myadmin
|
- myadmin
|
||||||
www:
|
www:
|
||||||
image: registry.docker.rhost.ovh/sprawozdania:0.2.3
|
image: registry.docker.rhost.ovh/sprawozdania:0.2.5
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
platform: linux/x86_64
|
platform: linux/x86_64
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?php // dev.API_FAKTUROWNIA.f73a67 on Fri, 01 Nov 2024 22:52:28 +0100
|
||||||
|
|
||||||
|
return "\xA9c\xD0\xC5\xD1\x3Aek\xE6\x24\x16\x15b\x3A\xDF\x83\x9B\xED\xE8n\x04_d\x5B\xAE8\x1B\xAC\x02\x2C\x9CA\xFB\x8Ee\x99\xFC3\xDE\xC34f\x28\x08\x26\xC8\x26o\x88\xF9\xF4z";
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'API_FAKTUROWNIA' => null,
|
||||||
'DATABASE_PASSWORD' => null,
|
'DATABASE_PASSWORD' => null,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||||
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
||||||
parameters:
|
parameters:
|
||||||
|
FAKTUROWNIA_API: '%env(API_FAKTUROWNIA)%'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
@@ -24,6 +25,6 @@ services:
|
|||||||
resource: '../src/Services/'
|
resource: '../src/Services/'
|
||||||
arguments:
|
arguments:
|
||||||
- '@doctrine.orm.entity_manager'
|
- '@doctrine.orm.entity_manager'
|
||||||
- 'Symfony\Contracts\HttpClient\HttpClientInterface'
|
- '@Symfony\Contracts\HttpClient\HttpClientInterface'
|
||||||
# add more service definitions when explicit configuration is needed
|
# add more service definitions when explicit configuration is needed
|
||||||
# please note that last definitions always *replace* previous ones
|
# please note that last definitions always *replace* previous ones
|
||||||
|
|||||||
@@ -31,9 +31,15 @@ class BaseController extends AbstractController
|
|||||||
#[Route('/', name: 'index')]
|
#[Route('/', name: 'index')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
if (!$this->isGranted('reportView')) {
|
if ($this->isGranted('reportView')) {
|
||||||
|
return $this->redirectToRoute('app_base');
|
||||||
|
}
|
||||||
|
if ($this->isGranted('scheduleView')) {
|
||||||
return $this->redirectToRoute('app_schedule');
|
return $this->redirectToRoute('app_schedule');
|
||||||
}
|
}
|
||||||
|
if ($this->isGranted('clientView')) {
|
||||||
|
return $this->redirectToRoute('app_customers_list');
|
||||||
|
}
|
||||||
return $this->redirectToRoute('app_base');
|
return $this->redirectToRoute('app_base');
|
||||||
}
|
}
|
||||||
#[Route('/reports/{monthId}/{clientId}', name: 'app_base')]
|
#[Route('/reports/{monthId}/{clientId}', name: 'app_base')]
|
||||||
|
|||||||
@@ -54,11 +54,12 @@ class ReportsController extends AbstractController
|
|||||||
$report->setDone(true);
|
$report->setDone(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($todo->getName() === ReportTodoEnum::INVOICE_SEND && !$todo->isDeleted()) {
|
// if ($todo->getName() === ReportTodoEnum::INVOICE_SEND && !$todo->isDeleted()) {
|
||||||
$invoiceServices->setClients($report->getClient());
|
// $invoiceServices->setApiKey($this->getParameter('FAKTUROWNIA_API'));
|
||||||
$invoiceServices->setReportDate($report->getDateStart());
|
// $invoiceServices->setClients($report->getClient());
|
||||||
$invoiceServices->send();
|
// $invoiceServices->setReportDate($report->getDateStart());
|
||||||
}
|
// $invoiceServices->send();
|
||||||
|
// }
|
||||||
$entityManager->persist($todo);
|
$entityManager->persist($todo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
|
||||||
class ScheduleController extends AbstractController
|
class ScheduleController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/schedule/{typeId}', name: 'app_schedule', defaults: ['typeId' => 1])]
|
#[Route('/schedule/{typeId}', name: 'app_schedule', defaults: ['typeId' => 1])]
|
||||||
|
#[IsGranted('scheduleView')]
|
||||||
public function index(EntityManagerInterface $entityManager, int $typeId = 1): Response
|
public function index(EntityManagerInterface $entityManager, int $typeId = 1): Response
|
||||||
{
|
{
|
||||||
if ($typeId == 1) {
|
if ($typeId == 1) {
|
||||||
@@ -31,6 +33,7 @@ class ScheduleController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/schedule_status/{id}', name: 'app_schedule_status', methods: ['POST'])]
|
#[Route('/schedule_status/{id}', name: 'app_schedule_status', methods: ['POST'])]
|
||||||
|
#[IsGranted('scheduleEdit')]
|
||||||
public function setDone(EntityManagerInterface $entityManager, Request $request, Schedule $schedule): Response
|
public function setDone(EntityManagerInterface $entityManager, Request $request, Schedule $schedule): Response
|
||||||
{
|
{
|
||||||
$token = $request->get("token");
|
$token = $request->get("token");
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Security;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
|
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||||
|
|
||||||
|
class SchedulesVoter extends Voter
|
||||||
|
{
|
||||||
|
const VIEW = "scheduleView";
|
||||||
|
const EDIT = "scheduleEdit";
|
||||||
|
|
||||||
|
public function __construct(readonly private Security $security)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
protected function supports(string $attribute, mixed $subject): bool
|
||||||
|
{
|
||||||
|
if (!in_array($attribute, [self::VIEW, self::EDIT])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true; }
|
||||||
|
|
||||||
|
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
||||||
|
{
|
||||||
|
$user = $token->getUser();
|
||||||
|
if (!$user instanceof User) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match ($attribute) {
|
||||||
|
self::VIEW => $this->canView(),
|
||||||
|
self::EDIT => $this->canEdit()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private function canView(): bool
|
||||||
|
{
|
||||||
|
if ($this->canAll()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return $this->security->isGranted('ROLE_SCHEDULE_VIEW');
|
||||||
|
}
|
||||||
|
private function canEdit(): bool
|
||||||
|
{
|
||||||
|
if ($this->canAll()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return $this->canView();
|
||||||
|
}
|
||||||
|
private function canAll(): bool
|
||||||
|
{
|
||||||
|
return $this->security->isGranted('ROLE_ACCESS_ALL');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,10 @@ class InvoiceServices
|
|||||||
{
|
{
|
||||||
private Clients $clients;
|
private Clients $clients;
|
||||||
private \DateTimeInterface $reportDate;
|
private \DateTimeInterface $reportDate;
|
||||||
public function __construct(private EntityManager $entityManager, private HttpClientInterface $curl){}
|
private string $apiKey;
|
||||||
|
public function __construct(
|
||||||
|
private readonly EntityManager $entityManager,
|
||||||
|
private readonly HttpClientInterface $curl){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Clients $clients
|
* @param Clients $clients
|
||||||
@@ -21,6 +24,11 @@ class InvoiceServices
|
|||||||
$this->clients = $clients;
|
$this->clients = $clients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setApiKey(string $api): void
|
||||||
|
{
|
||||||
|
$this->apiKey = $api;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTimeInterface $reportDate
|
* @param \DateTimeInterface $reportDate
|
||||||
*/
|
*/
|
||||||
@@ -61,7 +69,7 @@ class InvoiceServices
|
|||||||
$monthStartPeriod = (clone $this->reportDate)->modify("-2 months")->format('m');
|
$monthStartPeriod = (clone $this->reportDate)->modify("-2 months")->format('m');
|
||||||
$periodStr = $monthStartPeriod . ' - ' . $this->reportDate->format('m') . '/' . $this->reportDate->format('Y');
|
$periodStr = $monthStartPeriod . ' - ' . $this->reportDate->format('m') . '/' . $this->reportDate->format('Y');
|
||||||
|
|
||||||
$post = [
|
$invoice = [
|
||||||
'kinds' => ["vat","proforma"],
|
'kinds' => ["vat","proforma"],
|
||||||
'number' => null,
|
'number' => null,
|
||||||
'sell_date' => $todayStr,
|
'sell_date' => $todayStr,
|
||||||
@@ -93,6 +101,9 @@ class InvoiceServices
|
|||||||
// {"name":"Produkt A2", "tax":0, "total_price_gross":50, "quantity":3}
|
// {"name":"Produkt A2", "tax":0, "total_price_gross":50, "quantity":3}
|
||||||
// ]
|
// ]
|
||||||
|
|
||||||
return $post;
|
return [
|
||||||
|
'api_token' => $this->apiKey,
|
||||||
|
'invoice' => $invoice,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class AppExtension extends AbstractExtension
|
|||||||
|
|
||||||
public function getMailtoLink(Reports $reports): string
|
public function getMailtoLink(Reports $reports): string
|
||||||
{
|
{
|
||||||
$subject = rawurlencode("Sprawozdanie z wykonania układu");
|
$subject = rawurlencode("Sprawozdanie z wykonania układu nr {$reports->getNumber()}");
|
||||||
$dateBase = (clone $reports->getDateStart())->modify("-1 month");
|
$dateBase = (clone $reports->getDateStart())->modify("-1 month");
|
||||||
|
|
||||||
$template = "email/report.html.twig";
|
$template = "email/report.html.twig";
|
||||||
|
|||||||
@@ -12,9 +12,11 @@
|
|||||||
<a class="nav-link {{ is_route_active('app_base', route) }}" aria-current="page" href="{{ path('app_base') }}">Sprawozdania</a>
|
<a class="nav-link {{ is_route_active('app_base', route) }}" aria-current="page" href="{{ path('app_base') }}">Sprawozdania</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if is_granted('scheduleView') %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link {{ is_route_active('app_schedule', route) }}" aria-current="page" href="{{ path('app_schedule') }}">Harmonogramy</a>
|
<a class="nav-link {{ is_route_active('app_schedule', route) }}" aria-current="page" href="{{ path('app_schedule') }}">Harmonogramy</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% if is_granted('clientView') %}
|
{% if is_granted('clientView') %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link {{ is_route_active('app_customers_list', route) }}" aria-current="page" href="{{ path('app_customers_list') }}">Klienci</a>
|
<a class="nav-link {{ is_route_active('app_customers_list', route) }}" aria-current="page" href="{{ path('app_customers_list') }}">Klienci</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user