-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
afup#1428 compta regle auto DB + CRUD
- Loading branch information
Showing
11 changed files
with
236 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
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, | ||
`attachment_required` TINYINT(2) NULL, | ||
PRIMARY KEY (`id`) | ||
); | ||
EOF; | ||
$this->execute($sql); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
use Afup\Site\Comptabilite\Comptabilite; | ||
use Afup\Site\Utils\Logs; | ||
use AppBundle\Controller\LegacyController; | ||
|
||
/** @var LegacyController $this */ | ||
|
||
// Impossible to access the file itself | ||
if (!defined('PAGE_LOADED_USING_INDEX')) { | ||
trigger_error("Direct access forbidden.", E_USER_ERROR); | ||
exit; | ||
} | ||
|
||
$action = verifierAction(array('lister', 'ajouter', 'modifier')); | ||
|
||
$smarty->assign('action', $action); | ||
|
||
$compta = new Comptabilite($bdd); | ||
|
||
if ($action == 'lister') { | ||
$data = $compta->obtenirListRegles(true); | ||
$smarty->assign('data', $data); | ||
} elseif ($action == 'ajouter' || $action == 'modifier') { | ||
$formulaire = instancierFormulaire(); | ||
|
||
if ($action == 'modifier') { | ||
$champs = $compta->obtenirListRegles('', intval($_GET['id'])); | ||
$formulaire->setDefaults($champs); | ||
|
||
$formulaire->addElement('hidden', 'id', intval($_GET['id'])); | ||
} | ||
|
||
// partie saisie | ||
$formulaire->addElement('header', '', ''); | ||
$formulaire->addElement('text', 'label', 'Nom de la règle', array('size' => 30, 'maxlength' => 255)); | ||
$formulaire->addElement('text', 'condition', 'Condition', array('size' => 30, 'maxlength' => 255)); | ||
$formulaire->addElement('select', 'is_credit', 'Sens', array(null => 'Les deux', '1' => 'Crédit', '0' => 'Débit')); | ||
$formulaire->addElement('select', 'vat', 'Taux de TVA', array('0' => 'Non soumis', '5.50' => '5.5%', '10.00' => '10%', '20.00' => '20%')); | ||
$formulaire->addElement('select', 'category_id', 'Catégorie', $compta->obtenirListCategories()); | ||
$formulaire->addElement('select', 'event_id', 'Évènement', $compta->obtenirListEvenements()); | ||
|
||
$formulaire->addRule('label' , 'Nom manquant' , 'required'); | ||
$formulaire->addRule('condition' , 'Condition manquante' , 'required'); | ||
|
||
// boutons | ||
$formulaire->addElement('header', 'boutons', ''); | ||
$formulaire->addElement('submit', 'soumettre', ucfirst($action)); | ||
|
||
|
||
if ($formulaire->validate()) { | ||
$valeur = $formulaire->exportValues(); | ||
|
||
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') { | ||
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'), | ||
'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' | ||
); | ||
} | ||
} | ||
$smarty->assign('formulaire', genererFormulaire($formulaire)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="ui top attached tabular menu"> | ||
<a class="{if $page eq 'compta_conf_evenement'}active{/if} item" href="index.php?page=compta_conf_evenement">Évènements</a> | ||
<a class="{if $page eq 'compta_conf_categorie'}active{/if} item" href="index.php?page=compta_conf_categorie">Catégories</a> | ||
<a class="{if $page eq 'compta_conf_operation'}active{/if} item" href="index.php?page=compta_conf_operation">Opérations</a> | ||
<a class="{if $page eq 'compta_conf_reglement'}active{/if} item" href="index.php?page=compta_conf_reglement">Modes de réglements</a> | ||
<a class="{if $page eq 'compta_conf_compte'}active{/if} item" href="index.php?page=compta_conf_compte">Comptes</a> | ||
<a class="{if $page eq 'compta_conf_regle'}active{/if} item" href="index.php?page=compta_conf_regle">Règles</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{if $action == 'lister' } | ||
<h2>Configuration des règles</h2> | ||
|
||
{include file="compta_conf_menu.html" page=compta_conf_regle} | ||
|
||
<div class="ui bottom attached segment"> | ||
<div class="ui menu"> | ||
<a href="index.php?page=compta_conf_regle&action=ajouter" class="item"> | ||
<div data-tooltip="Ajouter une règle" data-position="bottom left"> | ||
<i class="icon plus square"></i> | ||
Ajouter | ||
</div> | ||
</a> | ||
</div> | ||
|
||
<table class="ui table striped compact celled"> | ||
<thead> | ||
<tr> | ||
<th>Règle</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{foreach from=$data item=regle} | ||
<tr> | ||
<td>{$regle.label}</td> | ||
<td style="text-align: right"> | ||
<a href="index.php?page=compta_conf_regle&action=modifier&id={$regle.id}" | ||
data-position="left center" | ||
data-tooltip="Modifier la règle {$regle.label}" | ||
class="compact ui icon button" | ||
> | ||
<i class="pencil alernate icon"></i> | ||
</a> | ||
</td> | ||
</tr> | ||
{foreachelse} | ||
<tr> | ||
<td><em>Aucune règle actuellement</em></td> | ||
</tr> | ||
{/foreach} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
{else} | ||
{if $action == 'ajouter'} | ||
<h2>Ajouter une règle</h2> | ||
{else} | ||
<h2>Modifier une règle</h2> | ||
{/if} | ||
{include file="formulaire.html"} | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters