Пример #1
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
if ($user['droits']['compta'] < Membres::DROIT_ADMIN) {
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}
$e = new Compta\Exercices();
$exercice = $e->get((int) Utils::get('id'));
if (!$exercice) {
    throw new UserException('Exercice inconnu.');
}
if ($exercice['cloture']) {
    throw new UserException('Impossible de modifier un exercice clôturé.');
}
$error = false;
if (!empty($_POST['edit'])) {
    if (!Utils::CSRF_check('compta_modif_exercice_' . $exercice['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $e->edit($exercice['id'], ['libelle' => Utils::post('libelle'), 'debut' => Utils::post('debut'), 'fin' => Utils::post('fin')]);
            Utils::redirect('/admin/compta/exercices/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('exercice', $exercice);
Пример #2
0
namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$journal = new Compta\Journal();
$operation = $journal->get(Utils::get('id'));
if (!$operation) {
    throw new UserException("L'opération demandée n'existe pas.");
}
$exercices = new Compta\Exercices();
$tpl->assign('operation', $operation);
$credit = $comptes->get($operation['compte_credit']);
$tpl->assign('nom_compte_credit', $credit['libelle']);
$debit = $comptes->get($operation['compte_debit']);
$tpl->assign('nom_compte_debit', $debit['libelle']);
$tpl->assign('exercice', $exercices->get($operation['id_exercice']));
if ($operation['id_categorie']) {
    $cats = new Compta\Categories();
    $categorie = $cats->get($operation['id_categorie']);
    $tpl->assign('categorie', $categorie);
    if ($categorie['type'] == Compta\Categories::RECETTES) {
        $tpl->assign('compte', $debit['libelle']);
    } else {
        $tpl->assign('compte', $credit['libelle']);
    }
    $tpl->assign('moyen_paiement', $cats->getMoyenPaiement($operation['moyen_paiement']));
}
if ($operation['id_auteur']) {
    $auteur = $membres->get($operation['id_auteur']);
    $tpl->assign('nom_auteur', $auteur['identite']);
}