Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
432 changes: 93 additions & 339 deletions phpstan-baseline.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sources/Afup/Utils/PDF_AG.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Afup\Site\Utils;

use Afup\Site\Comptabilite\PDF;
use AppBundle\GeneralMeeting\Attendee;
use AppBundle\AssembleeGenerale\Dto\Attendee;

class PDF_AG extends PDF
{
Expand Down
95 changes: 95 additions & 0 deletions sources/AppBundle/AssembleeGenerale/Dto/Attendee.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

declare(strict_types=1);

namespace AppBundle\AssembleeGenerale\Dto;

use AppBundle\AssembleeGenerale\Enum\PresenceEtat;
use DateTimeImmutable;

class Attendee
{
public function __construct(
private int $id,
private string $email,
private string $login,
private string $lastname,
private string $firstname,
private ?string $nearestOffice,
private ?DateTimeImmutable $consultationDate,
private int $presence,
private ?int $powerId,
private ?string $powerLastname,
private ?string $powerFirstname,
) {}

public function getId(): int
{
return $this->id;
}

public function getEmail(): string
{
return $this->email;
}

public function getLogin(): string
{
return $this->login;
}

public function getLastname(): string
{
return $this->lastname;
}

public function getFirstname(): string
{
return $this->firstname;
}

public function getNearestOffice(): ?string
{
return $this->nearestOffice;
}

public function getConsultationDate(): ?DateTimeImmutable
{
return $this->consultationDate;
}

public function getPresence(): int
{
return $this->presence;
}

public function isPresent(): bool
{
return $this->presence === PresenceEtat::Present->value;
}

public function isAbsent(): bool
{
return $this->presence === PresenceEtat::NonPresent->value;
}

public function getPowerId(): ?int
{
return $this->powerId;
}

public function getPowerLastname(): ?string
{
return $this->powerLastname;
}

public function getPowerFirstname(): ?string
{
return $this->powerFirstname;
}

public function getHash(): string
{
return md5($this->id . '_' . $this->email . '_' . $this->login);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,37 @@ public function upsert(\DateTimeInterface $date, string $description): void
$assemblee->description = $description;
$this->save($assemblee);
}

public function prepare(\DateTimeInterface $date, string $description): bool
{
$conn = $this->getEntityManager()->getConnection();

$members = $conn->executeQuery('SELECT id FROM afup_personnes_physiques WHERE etat = 1')->fetchAllAssociative();
$insertQuery = $conn->prepare('INSERT INTO afup_presences_assemblee_generale (id_personne_physique, date) VALUES (:id, :date)');
$insertQuery->bindValue('date', $date->getTimestamp());

$success = 0;
foreach ($members as $row) {
$alreadyExists = $conn->prepare('SELECT id FROM afup_presences_assemblee_generale WHERE id_personne_physique = :id AND date = :date');
$alreadyExists->bindValue('id', $row['id']);
$alreadyExists->bindValue('date', $date->getTimestamp());

if (!is_array($alreadyExists->executeQuery()->fetchAssociative())) {
$insertQuery->bindValue('id', $row['id']);
if ($insertQuery->executeStatement()) {
$success++;
}
}
}

if (0 === $success) {
return false;
}

$replaceQuery = $conn->prepare('REPLACE INTO afup_assemblee_generale (`date`, `description`) VALUES (:date, :description)');
$replaceQuery->bindValue('date', $date->getTimestamp());
$replaceQuery->bindValue('description', $description);

return $replaceQuery->executeStatement() > 0;
}
}
Loading
Loading