feat(CustomerDns): Ajoute la gestion des DNS expirant bientôt.
```
This commit is contained in:
Serreau Jovann
2025-11-13 10:43:16 +01:00
parent fe53d11690
commit 6502fffb55
3 changed files with 53 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ use App\Entity\CustomerAdvertPayment;
use App\Repository\ComputeRepository;
use App\Repository\CustomerAdvertPaymentRepository;
use App\Repository\CustomerDevisRepository;
use App\Repository\CustomerDnsRepository;
use App\Repository\CustomerOrderRepository;
use App\Service\Docuseal\SignClient;
use App\Service\Google\ComputeEngineClient;
@@ -26,6 +27,7 @@ class DashboardController extends AbstractController
CustomerAdvertPaymentRepository $customerAdvertPaymentRepository,
CustomerDevisRepository $customerDevisRepository,
ComputeRepository $computeRepository,
CustomerDnsRepository $customerDnsRepository,
ComputeEngineClient $computeEngineClient,
Client $client,
SignClient $signClient,
@@ -38,6 +40,7 @@ class DashboardController extends AbstractController
$remaining_amount = 0;
$services = [];
$servers = [];
$dns = [];
if(in_array("ROLE_CUSTOMER",$this->getUser()->getRoles())) {
/** @var Customer $customer */
$customer = $this->getUser()->getCustomers()[0];
@@ -102,13 +105,15 @@ class DashboardController extends AbstractController
];
}
} else {
$servers = [];
foreach ($computeEngineClient->list() as $instance) {
$servers[] = $computeEngineClient->detail($instance);
}
foreach ($client->servers() as $instance) {
$servers[] = $client->detail($instance);
}
foreach ($customerDnsRepository->expitedSoonLimited() as $dnsItem) {
$dns[] = $dnsItem;
}
}
@@ -119,6 +124,7 @@ class DashboardController extends AbstractController
'active_services' => $services,
'remaining_amount' => $remaining_amount,
'servers' => $servers,
'dns' => $dns,
]);
}
}

View File

@@ -57,4 +57,22 @@ class CustomerDnsRepository extends ServiceEntityRepository
->getQuery()
->getResult();
}
public function expitedSoonLimited()
{
// Get the first day of the current month
$startOfCurrentMonth = new \DateTimeImmutable('first day of this month 00:00:00');
// Get the first day of the month after the next one
// e.g., if current month is Nov, this gets Jan 1st of the next year.
$startOfSecondNextMonth = $startOfCurrentMonth->modify('+2 months');
return $this->createQueryBuilder('c')
->andWhere('c.expiredAt >= :start')
->andWhere('c.expiredAt < :end')
->setParameter('start', $startOfCurrentMonth)
->setParameter('end', $startOfSecondNextMonth)
->setMaxResults(20)
->getQuery()
->getResult();
}
}

View File

@@ -191,14 +191,34 @@
<div class="p-6 rounded-lg shadow-xl bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100">
<h2 class="text-xl font-semibold mb-4">🔔 Domaines à Renouveler</h2>
<ul class="space-y-2">
<li class="flex justify-between text-sm">
<span>mondomaine.com</span>
<span class="text-red-500 font-medium">J-7</span>
</li>
<li class="flex justify-between text-sm">
<span>autre-site.fr</span>
<span class="text-orange-400 font-medium">J-30</span>
</li>
{% for dnsItem in dns %}
{% set expiration_date = date(dnsItem.expiredAt) %}
{% set now = date('now') %}
{% set days = ((expiration_date.timestamp - now.timestamp) / (60 * 60 * 24))|round(0, 'floor') %}
{% set text_class = 'text-gray-500 dark:text-gray-400' %}
{% if days < 0 %}
{% set text_class = 'text-gray-400 dark:text-gray-500 italic' %}
{% elseif days < 30 %}
{% set text_class = 'text-red-600 dark:text-red-500' %}
{% elseif days < 60 %}
{% set text_class = 'text-yellow-600 dark:text-yellow-400' %}
{% else %}
{% set text_class = 'text-green-600 dark:text-green-400' %}
{% endif %}
<li class="flex justify-between items-center py-2 text-sm border-b border-gray-100 dark:border-gray-700 last:border-b-0">
<span class="text-gray-900 dark:text-gray-200 font-medium truncate w-1/2">
{{ dnsItem.ndd }}
</span>
<span class="font-bold w-1/4 text-right {{ text_class }}">
{% if days < 0 %}
Expiré (J{{ days }})
{% else %}
J-{{ days }}
{% endif %}
</span>
</li>
{% endfor %}
</ul>
</div>