Example #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.");
}
$cats = new Compta\Categories();
$id = (int) Utils::get('id');
$cat = $cats->get($id);
if (!$cat) {
    throw new UserException('Cette catégorie n\'existe pas.');
}
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('compta_edit_cat_' . $cat['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $cats->edit($id, ['intitule' => Utils::post('intitule'), 'description' => Utils::post('description')]);
            if ($cat['type'] == Compta\Categories::DEPENSES) {
                $type = 'depenses';
            } elseif ($cat['type'] == Compta\Categories::AUTRES) {
                $type = 'autres';
            } else {
                $type = 'recettes';
            }
            Utils::redirect('/admin/compta/categories/?' . $type);
        } catch (UserException $e) {
            $error = $e->getMessage();
Example #2
0
    $type = null;
} else {
    $type = Compta\Categories::RECETTES;
}
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('compta_saisie')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            if (is_null($type)) {
                $id = $journal->add(['libelle' => Utils::post('libelle'), 'montant' => Utils::post('montant'), 'date' => Utils::post('date'), 'compte_credit' => Utils::post('compte_credit'), 'compte_debit' => Utils::post('compte_debit'), 'numero_piece' => Utils::post('numero_piece'), 'remarques' => Utils::post('remarques'), 'id_auteur' => $user['id']]);
            } elseif ($type === 'virement') {
                $id = $journal->add(['libelle' => Utils::post('libelle'), 'montant' => Utils::post('montant'), 'date' => Utils::post('date'), 'compte_debit' => Utils::post('compte1'), 'compte_credit' => Utils::post('compte2'), 'numero_piece' => Utils::post('numero_piece'), 'remarques' => Utils::post('remarques'), 'id_auteur' => $user['id']]);
            } else {
                $cat = $cats->get(Utils::post('categorie'));
                if (!$cat) {
                    throw new UserException('Il faut choisir une catégorie.');
                }
                if ($type == 'dette') {
                    if (!trim(Utils::post('compte')) || Utils::post('compte') != 4010 && Utils::post('compte') != 4110) {
                        throw new UserException('Type de dette invalide.');
                    }
                } else {
                    if (Utils::post('moyen_paiement') == 'ES') {
                        $a = Compta\Comptes::CAISSE;
                        $b = $cat['compte'];
                    } else {
                        if (!trim(Utils::post('banque'))) {
                            throw new UserException('Le compte bancaire choisi est invalide.');
                        }
Example #3
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$cats = new Compta\Categories();
$cat = $type = false;
if (Utils::get('cat')) {
    $cat = $cats->get(Utils::get('cat'));
    if (!$cat) {
        throw new UserException("La catégorie demandée n'existe pas.");
    }
    $type = $cat['type'];
} else {
    if (isset($_GET['autres'])) {
        $type = Compta\Categories::AUTRES;
    } elseif (isset($_GET['depenses'])) {
        $type = Compta\Categories::DEPENSES;
    } else {
        $type = Compta\Categories::RECETTES;
    }
}
$journal = new Compta\Journal();
$list = $journal->getListForCategory($type === Compta\Categories::AUTRES ? null : $type, $cat ? $cat['id'] : null);
$tpl->assign('categorie', $cat);
$tpl->assign('journal', $list);
$tpl->assign('type', $type);
if ($type !== Compta\Categories::AUTRES) {
    $tpl->assign('liste_cats', $cats->getList($type));
}
$total = 0.0;
Example #4
0
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.");
}
$journal = new Compta\Journal();
$cats = new Compta\Categories();
$banques = new Compta\Comptes_Bancaires();
$operation = $journal->get(Utils::get('id'));
if (!$operation) {
    throw new UserException("L'opération demandée n'existe pas.");
}
if ($operation['id_categorie']) {
    $categorie = $cats->get($operation['id_categorie']);
} else {
    $categorie = false;
}
if ($categorie && $categorie['type'] != Compta\Categories::AUTRES) {
    $type = $categorie['type'];
} else {
    $type = null;
}
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('compta_modifier_' . $operation['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            if (is_null($type)) {
Example #5
0
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']);
}
$tpl->assign('related_members', $journal->listRelatedMembers($operation['id']));
$tpl->display('admin/compta/operations/voir.tpl');