Skip to content

Commit

Permalink
afup#1428 qualification comptable code review
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Mar 3, 2024
1 parent 503c221 commit 6b322b9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
26 changes: 13 additions & 13 deletions db/migrations/20240120222107_compta_regle.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ class ComptaRegle extends AbstractMigration
public function change()
{
$sql = <<<EOF
CREATE TABLE compta_regle
(
`id` tinyint(5) NOT NULL AUTO_INCREMENT,
`label` VARCHAR(255) NOT NULL,
`condition` VARCHAR(255) NOT NULL,
`is_credit` TINYINT(2) NULL,
`vat` VARCHAR(7) NULL,
`category_id` TINYINT(5) NULL,
`event_id` TINYINT(5) NULL,
`mode_regl_id` TINYINT(5) NULL,
`attachment_required` TINYINT(2) NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE compta_regle
(
`id` tinyint(5) NOT NULL AUTO_INCREMENT,
`label` VARCHAR(255) NOT NULL,
`condition` VARCHAR(255) NOT NULL,
`is_credit` TINYINT(2) NULL,
`vat` VARCHAR(7) NULL,
`category_id` TINYINT(5) NULL,
`event_id` TINYINT(5) NULL,
`mode_regl_id` TINYINT(5) NULL,
`attachment_required` TINYINT(2) NULL,
PRIMARY KEY (`id`)
);
EOF;
$this->execute($sql);
}
Expand Down
1 change: 0 additions & 1 deletion db/seeds/ComptaRegle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class ComptaRegle extends AbstractSeed
{
public function run()
{

$data = [
[
'id' => 1,
Expand Down
21 changes: 9 additions & 12 deletions htdocs/pages/administration/compta_conf_regle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

use Afup\Site\Comptabilite\Comptabilite;
use Afup\Site\Utils\Logs;
use AppBundle\Controller\LegacyController;
use AppBundle\Model\ComptaModeReglement;

/** @var LegacyController $this */

// Impossible to access the file itself
if (!defined('PAGE_LOADED_USING_INDEX')) {
trigger_error("Direct access forbidden.", E_USER_ERROR);
Expand All @@ -19,17 +16,17 @@

$compta = new Comptabilite($bdd);

if ($action == 'lister') {
if ($action === 'lister') {
$data = $compta->obtenirListRegles(true);
$smarty->assign('data', $data);
} elseif ($action == 'ajouter' || $action == 'modifier') {
} elseif ($action === 'ajouter' || $action === 'modifier') {
$formulaire = instancierFormulaire();

if ($action == 'modifier') {
$champs = $compta->obtenirListRegles('', intval($_GET['id']));
if ($action === 'modifier') {
$champs = $compta->obtenirListRegles('', (int)$_GET['id']);
$formulaire->setDefaults($champs);

$formulaire->addElement('hidden', 'id', intval($_GET['id']));
$formulaire->addElement('hidden', 'id', (int)$_GET['id']);
}

// partie saisie
Expand All @@ -54,26 +51,26 @@
if ($formulaire->validate()) {
$valeur = $formulaire->exportValues();

if ($action == 'ajouter') {
if ($action === 'ajouter') {
$ok = $compta->ajouterRegle($valeur['label'], $valeur['condition'], $valeur['is_credit'], $valeur['vat'], $valeur['category_id'], $valeur['event_id']);
} else {
$ok = $compta->modifierRegle($valeur['id'], $valeur['label'], $valeur['condition'], $valeur['is_credit'], $valeur['vat'], $valeur['category_id'], $valeur['event_id']);
}

if ($ok) {
if ($action == 'ajouter') {
if ($action === 'ajouter') {
Logs::log('Ajout une règle '.$formulaire->exportValue('label'));
} else {
Logs::log('Modification une règle '.$formulaire->exportValue('label').' ('.$_GET['id'].')');
}
afficherMessage(
'La règle a été '.(($action == 'ajouter') ? 'ajoutée' : 'modifiée'),
'La règle a été '.(($action === 'ajouter') ? 'ajoutée' : 'modifiée'),
'index.php?page=compta_conf_regle&action=lister'
);
} else {
$smarty->assign(
'erreur',
'Une erreur est survenue lors de '.(($action == 'ajouter') ? "l'ajout" : 'la modification').' de la règle'
'Une erreur est survenue lors de '.(($action === 'ajouter') ? "l'ajout" : 'la modification').' de la règle'
);
}
}
Expand Down

0 comments on commit 6b322b9

Please sign in to comment.