Пример #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();
$import = new Compta\Import();
if (isset($_GET['export'])) {
    header('Content-type: application/csv');
    header('Content-Disposition: attachment; filename="Export comptabilité - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"');
    $import->toCSV($e->getCurrentId());
    exit;
}
$error = false;
if (!empty($_POST['import'])) {
    if (!Utils::CSRF_check('compta_import')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } elseif (empty($_FILES['upload']['tmp_name'])) {
        $error = 'Aucun fichier fourni.';
    } else {
        try {
            if (Utils::post('type') == 'citizen') {
                $import->fromCitizen($_FILES['upload']['tmp_name']);
            } elseif (Utils::post('type') == 'garradin') {
                $import->fromCSV($_FILES['upload']['tmp_name']);
            } else {
                throw new UserException('Import inconnu.');
            }
Пример #2
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$exercices = new Compta\Exercices();
$journal = new Compta\Journal();
$exercice = Utils::get('exercice') ?: $exercices->getCurrentId();
if (!$exercice) {
    throw new UserException('Exercice inconnu.');
}
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
    throw new UserException("Argument du numéro de membre manquant.");
}
$id = (int) $_GET['id'];
$membre = $membres->get($id);
if (!$membre) {
    throw new UserException("Le membre demandé n'existe pas.");
}
$liste_comptes = $comptes->getListAll();
function get_nom_compte($compte)
{
    if (is_null($compte)) {
        return '';
    }
    global $liste_comptes;
    return $liste_comptes[$compte];
}
$tpl->register_modifier('get_nom_compte', 'Garradin\\get_nom_compte');
$tpl->assign('journal', $journal->listForMember($membre['id'], $exercice));
$tpl->assign('exercices', $exercices->getList());