53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Class qui gère les user
|
|
**/
|
|
class Class_user
|
|
{
|
|
private $pdo = null;
|
|
|
|
public function __construct(PdoGsb $pDO)
|
|
{
|
|
$this->pdo = $pDO->getPdoGsb();
|
|
}
|
|
|
|
/**
|
|
* FONCTION QUI CONNECTE UN UTILISATEUR
|
|
*/
|
|
public function connectUser(string $login, string $password): array|bool
|
|
{
|
|
$req = 'SELECT "uId", "uNom", "uPrenom", "uAdresse", "uCp", "uVille", "uSecteur", "uLabo", "parametre"."pLibelle"
|
|
FROM utilisateur
|
|
INNER JOIN parametre ON "parametre"."pType" = \'statUti\'
|
|
AND "utilisateur"."uStatut" = "parametre"."pIndice"
|
|
WHERE "uLogin" = :login AND "uMdp" = :pwd ;';
|
|
|
|
$result = $this->pdo->prepare($req);
|
|
$result->bindParam('login', $login);
|
|
$result->bindParam('pwd', $password);
|
|
$result->execute();
|
|
$result = $result->fetch();
|
|
|
|
if ($result['pLibelle'] == 'comptable') {
|
|
$this->updateBdd();
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function updateBdd(): void
|
|
{
|
|
$curMonth = date('Ym');
|
|
$prevMonth = DateTime::createFromFormat('Ym', $curMonth);
|
|
$prevMonth->modify('first day of last month');
|
|
|
|
$prevMonth = $prevMonth->format('Ym');
|
|
|
|
$req = 'SELECT updateEtat(:currentMonth, :previousMonth)';
|
|
$result = $this->pdo->prepare($req);
|
|
$result->bindParam('currentMonth', $curMonth);
|
|
$result->bindParam('previousMonth', $prevMonth);
|
|
$result->execute();
|
|
}
|
|
}
|