Esempio n. 1
0
    throw new UserException("Argument du numéro de cotisation manquant.");
}
$cotisations = new Cotisations();
$co = $cotisations->get(Utils::get('id'));
$cats = new Compta\Categories();
if (!$co) {
    throw new UserException("Cette cotisation n'existe pas.");
}
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('edit_co_' . $co['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $duree = Utils::post('periodicite') == 'jours' ? (int) Utils::post('duree') : null;
            $debut = Utils::post('periodicite') == 'date' ? Utils::post('debut') : null;
            $fin = Utils::post('periodicite') == 'date' ? Utils::post('fin') : null;
            $id_cat = Utils::post('categorie') ? (int) Utils::post('id_categorie_compta') : null;
            $cotisations->edit($co['id'], ['intitule' => Utils::post('intitule'), 'description' => Utils::post('description'), 'montant' => (double) Utils::post('montant'), 'duree' => $duree, 'debut' => $debut, 'fin' => $fin, 'id_categorie_compta' => $id_cat]);
            Utils::redirect('/admin/membres/cotisations/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$co['periodicite'] = $co['duree'] ? 'jours' : ($co['debut'] ? 'date' : 'ponctuel');
$co['categorie'] = $co['id_categorie_compta'] ? 1 : 0;
$tpl->assign('cotisation', $co);
$tpl->assign('categories', $cats->getList(Compta\Categories::RECETTES));
$tpl->display('admin/membres/cotisations/gestion/modifier.tpl');
Esempio n. 2
0
                        throw new UserException('Le compte bancaire choisi n\'existe pas.');
                    }
                    $a = Utils::post('banque');
                    $b = $cat['compte'];
                }
                if ($type == Compta\Categories::DEPENSES) {
                    $debit = $b;
                    $credit = $a;
                } elseif ($type == Compta\Categories::RECETTES) {
                    $debit = $a;
                    $credit = $b;
                }
                $journal->edit($operation['id'], ['libelle' => Utils::post('libelle'), 'montant' => Utils::post('montant'), 'date' => Utils::post('date'), 'moyen_paiement' => Utils::post('moyen_paiement'), 'numero_cheque' => Utils::post('numero_cheque'), 'compte_credit' => $credit, 'compte_debit' => $debit, 'numero_piece' => Utils::post('numero_piece'), 'remarques' => Utils::post('remarques'), 'id_categorie' => (int) $cat['id']]);
            }
            Utils::redirect('/admin/compta/operations/voir.php?id=' . (int) $operation['id']);
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('type', $type);
if ($type === null) {
    $tpl->assign('comptes', $comptes->listTree());
} else {
    $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
    $tpl->assign('categories', $cats->getList($type));
    $tpl->assign('comptes_bancaires', $banques->getList());
}
$tpl->assign('operation', $operation);
$tpl->display('admin/compta/operations/modifier.tpl');
Esempio n. 3
0
                $type = 'recette';
            }
            Utils::redirect('/admin/compta/operations/saisir.php?' . $type . '&ok=' . (int) $id);
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('type', $type);
if ($type === null) {
    $tpl->assign('comptes', $comptes->listTree());
} else {
    $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
    $tpl->assign('moyen_paiement', Utils::post('moyen_paiement') ?: 'ES');
    $tpl->assign('categories', $cats->getList($type === 'dette' ? Compta\Categories::DEPENSES : $type));
    $tpl->assign('comptes_bancaires', $banques->getList());
    $tpl->assign('banque', Utils::post('banque'));
}
if (!$membres->sessionGet('compta_date')) {
    $exercices = new Compta\Exercices();
    $exercice = $exercices->getCurrent();
    if ($exercice['debut'] > time() || $exercice['fin'] < time()) {
        $membres->sessionStore('compta_date', date('Y-m-d', $exercice['debut']));
    } else {
        $membres->sessionStore('compta_date', date('Y-m-d'));
    }
}
$tpl->assign('date', $membres->sessionGet('compta_date') ?: false);
$tpl->assign('ok', (int) Utils::get('ok'));
$tpl->display('admin/compta/operations/saisir.tpl');
Esempio n. 4
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();
if (isset($_GET['depenses'])) {
    $type = Compta\Categories::DEPENSES;
} else {
    $type = Compta\Categories::RECETTES;
}
$tpl->assign('type', $type);
$tpl->assign('liste', $cats->getList($type));
$tpl->display('admin/compta/categories/index.tpl');