Commit cc5469e3 authored by iruiz's avatar iruiz
Browse files

follow code review #1246

parent 71047ef6
......@@ -225,12 +225,28 @@ class TypeDossierControler extends PastellControler
$this->{'limit'} = 20;
$this->{'count'} = $this->getTypeDossierActionService()->countById($this->{'id_t'});
$this->{'csrfToken'} = $this->getObjectInstancier()->getInstance(CSRFToken::class);
$this->{'typeDossierAction'} = $this->getTypeDossierActionService()->getById($this->{'id_t'}, $this->{'offset'}, $this->{'limit'});
$this->{'template_milieu'} = "TypeDossierDetail";
$this->renderDefault();
}
/**
* @throws NotFoundException
*/
public function etatAction()
{
$this->verifDroit(0, "system:edition");
$this->{'id_t'} = $this->getPostOrGetInfo()->getInt('id_t');
$this->{'page_title'} = "États du type de dossier personnalisé {$this->getTypeDossierSQL()->getInfo($this->{'id_t'})['id_type_dossier']}";
$this->{'offset'} = $this->getPostOrGetInfo()->get('offset', 0);
$this->{'limit'} = 10;
$this->{'count'} = $this->getTypeDossierActionService()->countById($this->{'id_t'});
$this->{'typeDossierAction'} = $this->getTypeDossierActionService()->getById($this->{'id_t'}, $this->{'offset'}, $this->{'limit'});
$this->{'template_milieu'} = "TypeDossierEtat";
$this->renderDefault();
}
/**
* @throws NotFoundException
*/
......
This diff is collapsed.
......@@ -311,6 +311,7 @@ CREATE TABLE `type_dossier_action` (
`date` datetime NOT NULL,
`empreinte_sha256` varchar(128) NOT NULL,
`message` mediumtext NOT NULL,
`export_json` json NOT NULL,
PRIMARY KEY (`id_a`),
KEY `id_t` (`id_t`)
) ENGINE=MyISAM ;
......
......@@ -5,12 +5,12 @@ class TypeDossierActionSQL extends SQL
public const DEFAULT_LIMIT = 20;
public function add(int $id_u, int $id_t, string $action, string $empreinte_sha256, string $message): int
public function add(int $id_u, int $id_t, string $action, string $empreinte_sha256, string $message, string $export_json): int
{
$now = date(Date::DATE_ISO);
$sql = "INSERT INTO type_dossier_action(id_u, id_t, action, date, empreinte_sha256, message) VALUES (?,?,?,?,?,?)";
$this->query($sql, $id_u, $id_t, $action, $now, $empreinte_sha256, $message);
$sql = "INSERT INTO type_dossier_action(id_u, id_t, action, date, empreinte_sha256, message, export_json) VALUES (?,?,?,?,?,?,?)";
$this->query($sql, $id_u, $id_t, $action, $now, $empreinte_sha256, $message, $export_json);
return $this->lastInsertId();
}
......@@ -21,6 +21,7 @@ class TypeDossierActionSQL extends SQL
" type_dossier_action.date AS date, " .
" type_dossier_action.empreinte_sha256 AS empreinte_sha256, " .
" type_dossier_action.message AS message, " .
" type_dossier_action.export_json AS export_json, " .
" utilisateur.nom AS nom, " .
" utilisateur.prenom AS prenom" .
" FROM type_dossier_action " .
......
......@@ -4,6 +4,7 @@ namespace Pastell\Service\TypeDossier;
use TypeDossierActionSQL;
use Pastell\Service\TypeDossier\TypeDossierManager;
use Pastell\Service\TypeDossier\TypeDossierExportService;
class TypeDossierActionService
{
......@@ -22,11 +23,18 @@ class TypeDossierActionService
*/
private $typeDossierManager;
/**
* @var TypeDossierExportService
*/
private $typeDossierExportService;
public function __construct(
TypeDossierActionSQL $typeDossierActionSQL,
TypeDossierExportService $typeDossierExportService,
TypeDossierManager $typeDossierManager
) {
$this->typeDossierActionSQL = $typeDossierActionSQL;
$this->typeDossierExportService = $typeDossierExportService;
$this->typeDossierManager = $typeDossierManager;
}
......@@ -37,7 +45,8 @@ class TypeDossierActionService
$id_t,
$action,
$this->typeDossierManager->getHash($id_t),
$message
$message,
$this->typeDossierExportService->export($id_t)
);
}
......
......@@ -7,10 +7,6 @@
* @var int $id_t
* @var CSRFToken $csrfToken
* @var array $all_etape_type
* @var array $typeDossierAction
* @var int $offset
* @var int $limit
* @var int $count
*/
?>
<a class='btn btn-link' href='<?php $this->url("TypeDossier/list")?>'>
......@@ -157,38 +153,9 @@
</div>
<div class="box" >
<a class="collapse-link" data-toggle="collapse" href="#collapseExample">
<h2> <i class="fa fa-plus-square"></i>&nbsp;États du type de dossier</h2>
</a>
<div class="collapse" id="collapseExample">
<?php
$this->SuivantPrecedent($offset, $limit, $count, "TypeDossier/detail?id_t=$id_t");
?>
<table class="table table-striped">
<tr>
<th>État</th>
<th>Date</th>
<th>Utilisateur</th>
<th>Empreinte sha256</th>
<th>Message</th>
</tr>
<?php foreach ($typeDossierAction as $action) : ?>
<tr>
<td><?php echo $action['action'] ?></td>
<td><?php echo time_iso_to_fr($action['date'])?></td>
<td>
<?php if ($action['id_u'] == 0) : ?>
Action automatique
<?php else : ?>
<a href='Utilisateur/detail?id_u=<?php echo $action['id_u']?>'><?php hecho($action['prenom']); ?> <?php hecho($action['nom']); ?></a>
<?php endif;?>
</td>
<td><?php echo $action['empreinte_sha256'] ?></td>
<td><?php echo $action['message'] ?></td>
</tr>
<?php endforeach;?>
</table>
<div class="row">
<div class="col float-right">
<a class='btn btn-link' href='TypeDossier/etat?id_t=<?php echo $id_t ?>'><i class='fa fa-list-alt'></i>&nbsp;Voir les états du type de dossier</a>
</div>
</div>
......
<?php
/**
* @var int $id_t
* @var array $typeDossierAction
* @var int $offset
* @var int $limit
* @var int $count
*/
?>
<a class='btn btn-link' href='TypeDossier/detail?id_t=<?php echo $id_t?>'>
<i class="fa fa-arrow-left"></i>&nbsp;Détail du type de dossier
</a>
<?php $this->SuivantPrecedent($offset, $limit, $count, "TypeDossier/etat?id_t=$id_t"); ?>
<div class="box" >
<table class="table table-striped">
<tr>
<th>État</th>
<th>Date</th>
<th>Utilisateur</th>
<th>Empreinte sha256</th>
<th>Message</th>
<th>Export Json</th>
</tr>
<?php foreach ($typeDossierAction as $action) : ?>
<tr>
<td><?php echo $action['action'] ?></td>
<td><?php echo time_iso_to_fr($action['date'])?></td>
<td>
<?php if ($action['id_u'] == 0) : ?>
Action automatique
<?php else : ?>
<a href='Utilisateur/detail?id_u=<?php echo $action['id_u']?>'><?php hecho($action['prenom']); ?> <?php hecho($action['nom']); ?></a>
<?php endif;?>
</td>
<td><?php echo $action['empreinte_sha256'] ?></td>
<td><?php echo $action['message'] ?></td>
<td><?php echo $action['export_json'] ?></td>
</tr>
<?php endforeach;?>
</table>
</div>
<?php $this->SuivantPrecedent($offset, $limit, $count, "TypeDossier/etat?id_t=$id_t"); ?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment