Example #1
0
<?php

namespace Garradin;

require_once __DIR__ . '/../../../_inc.php';
if ($user['droits']['membres'] < Membres::DROIT_ADMIN) {
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}
if (!Utils::get('id') || !is_numeric(Utils::get('id'))) {
    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();
Example #2
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();
$error = false;
if (!empty($_POST['add'])) {
    if (!Utils::CSRF_check('compta_ajout_cat')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $cats->add(['intitule' => Utils::post('intitule'), 'description' => Utils::post('description'), 'compte' => Utils::post('compte'), 'type' => Utils::post('type')]);
            if (Utils::post('type') == Compta\Categories::DEPENSES) {
                $type = 'depenses';
            } elseif (Utils::post('type') == Compta\Categories::AUTRES) {
                $type = 'autres';
            } else {
                $type = 'recettes';
            }
            Utils::redirect('/admin/compta/categories/?' . $type);
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('type', isset($_POST['type']) ? Utils::post('type') : Compta\Categories::RECETTES);
Example #3
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
if ($user['droits']['compta'] < Membres::DROIT_ECRITURE) {
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}
$journal = new Compta\Journal();
$journal->checkExercice();
$cats = new Compta\Categories();
$banques = new Compta\Comptes_Bancaires();
if (isset($_GET['depense'])) {
    $type = Compta\Categories::DEPENSES;
} elseif (isset($_GET['virement'])) {
    $type = 'virement';
} elseif (isset($_GET['dette'])) {
    $type = 'dette';
} elseif (isset($_GET['avance'])) {
    $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']]);
Example #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();
$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 #5
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');
Example #6
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.");
}
$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 {
Example #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.");
}
$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');
Example #8
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 #9
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');
Example #10
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['delete'])) {
    if (!Utils::CSRF_check('delete_compta_cat_' . $cat['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $cats->delete($id);
            Utils::redirect('/admin/compta/categories/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('cat', $cat);
$tpl->display('admin/compta/categories/supprimer.tpl');
Example #11
0
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}
$membre = false;
if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
    $membre = $membres->get((int) $_GET['id']);
    if (!$membre) {
        throw new UserException("Ce membre n'existe pas.");
    }
    $cats = new Membres\Categories();
    $categorie = $cats->get($membre['id_categorie']);
} else {
    $categorie = ['id_cotisation_obligatoire' => false];
}
$cotisations = new Cotisations();
$m_cotisations = new Membres\Cotisations();
$cats = new Compta\Categories();
$banques = new Compta\Comptes_Bancaires();
$error = false;
if (!empty($_POST['add'])) {
    if (!Utils::CSRF_check('add_cotisation')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $data = ['date' => Utils::post('date'), 'id_cotisation' => Utils::post('id_cotisation'), 'id_membre' => Utils::post('id_membre'), 'id_auteur' => $user['id'], 'montant' => Utils::post('montant'), 'moyen_paiement' => Utils::post('moyen_paiement'), 'numero_cheque' => Utils::post('numero_cheque'), 'banque' => Utils::post('banque')];
            $m_cotisations->add($data);
            Utils::redirect('/admin/membres/cotisations.php?id=' . (int) Utils::post('id_membre'));
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}