Пример #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
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$exercices = new Compta\Exercices();
$exercice = $exercices->get((int) Utils::get('id'));
if (!$exercice) {
    throw new UserException('Exercice inconnu.');
}
$liste_comptes = $comptes->getListAll();
function get_nom_compte($compte)
{
    global $liste_comptes;
    return $liste_comptes[$compte];
}
$tpl->register_modifier('get_nom_compte', 'Garradin\\get_nom_compte');
$tpl->assign('compte_resultat', $exercices->getCompteResultat($exercice['id']));
$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);
$tpl->display('admin/compta/exercices/compte_resultat.tpl');
Пример #3
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.');
            }
Пример #4
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');
Пример #5
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$exercices = new Compta\Exercices();
$exercice = $exercices->get((int) Utils::get('id'));
if (!$exercice) {
    throw new UserException('Exercice inconnu.');
}
$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', $exercices->getJournal($exercice['id']));
$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);
$tpl->display('admin/compta/exercices/journal.tpl');
Пример #6
0
                $id_membre = $membres->add(['id_categorie' => $id, 'nom' => Utils::post('nom_membre'), 'email' => Utils::post('email_membre'), 'passe' => Utils::post('passe_membre'), 'pays' => 'FR']);
                // Création wiki
                $page = Wiki::transformTitleToURI(Utils::post('nom_asso'));
                $config->set('accueil_wiki', $page);
                $wiki = new Wiki();
                $id_page = $wiki->create(['titre' => Utils::post('nom_asso'), 'uri' => $page]);
                $wiki->editRevision($id_page, 0, ['id_auteur' => $id_membre, 'contenu' => "Bienvenue dans le wiki de " . Utils::post('nom_asso') . " !\n\nCliquez sur le bouton « éditer » pour modifier cette page."]);
                // Création page wiki connexion
                $page = Wiki::transformTitleToURI('Bienvenue');
                $config->set('accueil_connexion', $page);
                $id_page = $wiki->create(['titre' => 'Bienvenue', 'uri' => $page]);
                $wiki->editRevision($id_page, 0, ['id_auteur' => $id_membre, 'contenu' => "Bienvenue dans l'administration de " . Utils::post('nom_asso') . " !\n\n" . "Utilisez le menu à gauche pour accéder aux différentes rubriques."]);
                // Mise en place compta
                $comptes = new Compta\Comptes();
                $comptes->importPlan();
                $comptes = new Compta\Categories();
                $comptes->importCategories();
                $ex = new Compta\Exercices();
                $ex->add(['libelle' => 'Premier exercice', 'debut' => date('Y-01-01'), 'fin' => date('Y-12-31')]);
                $config->save();
                Utils::redirect('/admin/login.php');
            } catch (UserException $e) {
                @unlink(DB_FILE);
                $error = $e->getMessage();
            }
        }
    }
    $tpl->assign('error', $error);
}
$tpl->assign('passphrase', Utils::suggestPassword());
$tpl->display('admin/install.tpl');
Пример #7
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.');
}
$error = false;
if (!empty($_POST['close'])) {
    if (!Utils::CSRF_check('compta_cloturer_exercice_' . $exercice['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $e->close($exercice['id'], Utils::post('fin'));
            if ($id && Utils::post('reports')) {
                $e->doReports($exercice['id'], Utils::modifyDate(Utils::post('fin'), '+1 day'));
            }
            Utils::redirect('/admin/compta/exercices/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('exercice', $exercice);
Пример #8
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();
$error = false;
if (!empty($_POST['add'])) {
    if (!Utils::CSRF_check('compta_ajout_exercice')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $e->add(['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->display('admin/compta/exercices/ajouter.tpl');
Пример #9
0
<?php

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']);
Пример #10
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$exercices = new Compta\Exercices();
$exercice = $exercices->get((int) Utils::get('id'));
if (!$exercice) {
    throw new UserException('Exercice inconnu.');
}
$liste_comptes = $comptes->getListAll();
function get_nom_compte($compte)
{
    global $liste_comptes;
    return $liste_comptes[$compte];
}
$tpl->register_modifier('get_nom_compte', 'Garradin\\get_nom_compte');
$tpl->assign('livre', $exercices->getGrandLivre($exercice['id']));
$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);
$tpl->display('admin/compta/exercices/grand_livre.tpl');
Пример #11
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 supprimer un exercice clôturé.');
}
$error = false;
if (!empty($_POST['delete'])) {
    if (!Utils::CSRF_check('compta_supprimer_exercice_' . $exercice['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $e->delete($exercice['id']);
            Utils::redirect('/admin/compta/exercices/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('exercice', $exercice);
Пример #12
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());
Пример #13
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$e = new Compta\Exercices();
$tpl->assign('liste', $e->getList());
$tpl->assign('current', $e->getCurrent());
$tpl->display('admin/compta/exercices/index.tpl');
Пример #14
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$exercices = new Compta\Exercices();
$exercice = $exercices->get((int) Utils::get('id'));
if (!$exercice) {
    throw new UserException('Exercice inconnu.');
}
$liste_comptes = $comptes->getListAll();
function get_nom_compte($compte)
{
    global $liste_comptes;
    return $liste_comptes[$compte];
}
$tpl->register_modifier('get_nom_compte', 'Garradin\\get_nom_compte');
$tpl->assign('bilan', $exercices->getBilan($exercice['id']));
$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);
$tpl->display('admin/compta/exercices/bilan.tpl');