Esempio n. 1
0
<?php

namespace Garradin;

require_once __DIR__ . '/_inc.php';
if ($user['droits']['wiki'] < Membres::DROIT_ADMIN) {
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}
if (!trim(Utils::get('id'))) {
    throw new UserException("Page inconnue.");
}
$page = $wiki->getByID(Utils::get('id'));
if (!$page) {
    throw new UserException("Cette page n'existe pas.");
}
$error = false;
if (!empty($_POST['delete'])) {
    if (!Utils::CSRF_check('delete_wiki_' . $page['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        if ($wiki->delete($page['id'])) {
            Utils::redirect('/admin/wiki/');
        } else {
            $error = "D'autres pages utilisent cette page comme rubrique parente.";
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('page', $page);
$tpl->display('admin/wiki/supprimer.tpl');
Esempio n. 2
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.");
}
$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);
$tpl->display('admin/compta/exercices/modifier.tpl');
Esempio n. 3
0
<?php

namespace Garradin;

require_once __DIR__ . '/_inc.php';
$error = false;
if (isset($_GET['ok'])) {
    $error = 'OK';
}
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('config')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $config->set('nom_asso', Utils::post('nom_asso'));
            $config->set('email_asso', Utils::post('email_asso'));
            $config->set('adresse_asso', Utils::post('adresse_asso'));
            $config->set('site_asso', Utils::post('site_asso'));
            $config->set('email_envoi_automatique', Utils::post('email_envoi_automatique'));
            $config->set('accueil_wiki', Utils::post('accueil_wiki'));
            $config->set('accueil_connexion', Utils::post('accueil_connexion'));
            $config->set('categorie_membres', Utils::post('categorie_membres'));
            $config->set('champ_identite', Utils::post('champ_identite'));
            $config->set('champ_identifiant', Utils::post('champ_identifiant'));
            $config->set('pays', Utils::post('pays'));
            $config->set('monnaie', Utils::post('monnaie'));
            $config->save();
            Utils::redirect('/admin/config/?ok');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
Esempio n. 4
0
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.');
            }
            Utils::redirect('/admin/compta/import.php?ok');
        } catch (UserException $e) {
            $error = $e->getMessage();
Esempio n. 5
0
$page = $wiki->getById(Utils::get('id'));
$error = false;
if (!$page) {
    throw new UserException('Page introuvable.');
}
if (!empty($page['contenu'])) {
    $page['chiffrement'] = $page['contenu']['chiffrement'];
    $page['contenu'] = $page['contenu']['contenu'];
}
if (Utils::post('date')) {
    $date = Utils::post('date') . ' ' . Utils::post('date_h') . ':' . Utils::post('date_min');
} else {
    $date = false;
}
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('wiki_edit_' . $page['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } elseif ($page['date_modification'] > (int) Utils::post('debut_edition')) {
        $error = 'La page a été modifiée par quelqu\'un d\'autre depuis que vous avez commencé l\'édition.';
    } else {
        try {
            $wiki->edit($page['id'], ['titre' => Utils::post('titre'), 'uri' => Utils::post('uri'), 'parent' => Utils::post('parent'), 'droit_lecture' => Utils::post('droit_lecture'), 'droit_ecriture' => Utils::post('droit_ecriture'), 'date_creation' => $date]);
            $wiki->editRevision($page['id'], (int) Utils::post('revision_edition'), ['contenu' => Utils::post('contenu'), 'modification' => Utils::post('modification'), 'id_auteur' => $user['id'], 'chiffrement' => Utils::post('chiffrement')]);
            $page = $wiki->getById($page['id']);
            Utils::redirect('/admin/wiki/?' . $page['uri']);
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$parent = (int) Utils::post('parent') ?: (int) $page['parent'];
Esempio n. 6
0
$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']]);
            } 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.');
Esempio n. 7
0
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();
        }
    }
}
$tpl->assign('error', $error);
Esempio n. 8
0
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 rappel manquant.");
}
$rappels = new Rappels();
$rappel = $rappels->get(Utils::get('id'));
if (!$rappel) {
    throw new UserException("Ce rappel n'existe pas.");
}
$cotisations = new Cotisations();
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('edit_rappel_' . $rappel['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            if (Utils::post('delai_choix') == 0) {
                $delai = 0;
            } elseif (Utils::post('delai_choix') > 0) {
                $delai = (int) Utils::post('delai_post');
            } else {
                $delai = -(int) Utils::post('delai_pre');
            }
            $rappels->edit($rappel['id'], ['sujet' => Utils::post('sujet'), 'texte' => Utils::post('texte'), 'delai' => $delai, 'id_cotisation' => Utils::post('id_cotisation')]);
            Utils::redirect('/admin/membres/cotisations/gestion/rappels.php');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
Esempio n. 9
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.");
}
$banque = new Compta\Comptes_Bancaires();
$compte = $banque->get(Utils::get('id'));
if (!$compte) {
    throw new UserException('Le compte demandé n\'existe pas.');
}
$error = false;
if (!empty($_POST['delete'])) {
    if (!Utils::CSRF_check('compta_delete_banque_' . $compte['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $banque->delete($compte['id']);
            Utils::redirect('/admin/compta/banques/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('compte', $compte);
$tpl->display('admin/compta/banques/supprimer.tpl');
Esempio n. 10
0
<?php

namespace Garradin;

require_once __DIR__ . '/_inc.php';
$error = false;
$parent = (int) Utils::get('parent') ?: 0;
if (!empty($_POST['create'])) {
    if (!Utils::CSRF_check('wiki_create')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $wiki->create(['titre' => Utils::post('titre'), 'parent' => $parent]);
            Utils::redirect('/admin/wiki/editer.php?id=' . $id);
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->display('admin/wiki/creer.tpl');
Esempio n. 11
0
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.");
}
$cats = new Membres\Categories();
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
    throw new UserException("Argument du numéro de catégorie manquant.");
}
$id = (int) $_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('edit_cat_' . $id)) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $cats->edit($id, ['nom' => Utils::post('nom'), 'description' => Utils::post('description'), 'droit_wiki' => (int) Utils::post('droit_wiki'), 'droit_compta' => (int) Utils::post('droit_compta'), 'droit_config' => (int) Utils::post('droit_config'), 'droit_membres' => (int) Utils::post('droit_membres'), 'droit_connexion' => (int) Utils::post('droit_connexion'), 'droit_inscription' => (int) Utils::post('droit_inscription'), 'cacher' => (int) Utils::post('cacher'), 'id_cotisation_obligatoire' => (int) Utils::post('id_cotisation_obligatoire')]);
            if ($id == $user['id_categorie']) {
                $membres->updateSessionData();
            }
            Utils::redirect('/admin/membres/categories.php');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('cat', $cat);
$tpl->assign('error', $error);
Esempio n. 12
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');
Esempio n. 13
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.");
}
$cats = new Membres\Categories();
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('new_cat')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $cats->add(['nom' => Utils::post('nom')]);
            Utils::redirect('/admin/membres/categories.php');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('liste', $cats->listCompleteWithStats());
$tpl->display('admin/membres/categories.tpl');
Esempio n. 14
0
require_once __DIR__ . '/_inc.php';
if ($membres->isLogged()) {
    Utils::redirect('/admin/');
}
// Relance session_start et renvoie une image de 1px transparente
if (isset($_GET['keepSessionAlive'])) {
    $membres->keepSessionAlive();
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-Type: image/gif');
    echo base64_decode("R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==");
    exit;
}
$error = false;
if (Utils::post('login')) {
    if (!Utils::CSRF_check('login')) {
        $error = 'OTHER';
    } else {
        if (Utils::post('id') && Utils::post('passe') && $membres->login(Utils::post('id'), Utils::post('passe'))) {
            Utils::redirect('/admin/');
        }
        $error = 'LOGIN';
    }
}
$champs = $config->get('champs_membres');
$champ = $champs->get($config->get('champ_identifiant'));
$tpl->assign('ssl_enabled', empty($_SERVER['HTTPS']) ? false : true);
$tpl->assign('prefer_ssl', (bool) PREFER_HTTPS);
$tpl->assign('own_https_url', str_replace('http://', 'https://', utils::getSelfURL()));
$tpl->assign('champ', $champ);
$tpl->assign('error', $error);
Esempio n. 15
0
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)) {
                $journal->edit($operation['id'], ['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')]);
            } else {
                $cat = $cats->get(Utils::post('id_categorie'));
                if (!$cat) {
                    throw new UserException('Il faut choisir une catégorie.');
                }
                if (!array_key_exists(Utils::post('moyen_paiement'), $cats->listMoyensPaiement())) {
                    throw new UserException('Moyen de paiement invalide.');
                }
                if (Utils::post('moyen_paiement') == 'ES') {
                    $a = Compta\Comptes::CAISSE;
Esempio n. 16
0
        } else {
            if (strtotime($fin) > $exercice['fin']) {
                $fin = date('Y-m-d', $exercice['fin']);
            }
        }
    }
}
if (!$debut || !$fin) {
    $date = $exercice['fin'];
    $debut = date('Y-m-01', $date);
    $fin = date('Y-m-t', $date);
}
$journal = $rapprochement->getJournal($compte['id'], $debut, $fin, $solde_initial, $solde_final);
// Enregistrement des cases cochées
if (Utils::post('save')) {
    if (!Utils::CSRF_check('compta_rapprocher_' . $compte['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $rapprochement->record($compte['id'], $journal, Utils::post('rapprocher'), $user['id']);
            Utils::redirect(Utils::getSelfURL());
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
if (substr($debut, 0, 7) == substr($fin, 0, 7)) {
    $tpl->assign('prev', Utils::modifyDate($debut, '-1 month', true));
    $tpl->assign('next', Utils::modifyDate($fin, '+1 month', true));
}
$tpl->assign('compte', $compte);
Esempio n. 17
0
            $config->set('categorie_membres', Utils::post('categorie_membres'));
            $config->save();
            Utils::redirect('/admin/config/site.php?ok');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
if (Utils::get('edit')) {
    $source = Squelette::getSource(Utils::get('edit'));
    if (!$source) {
        throw new UserException("Ce squelette n'existe pas.");
    }
    $csrf_key = 'edit_skel_' . md5(Utils::get('edit'));
    if (Utils::post('save')) {
        if (!Utils::CSRF_check($csrf_key)) {
            $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
        } else {
            if (Squelette::editSource(Utils::get('edit'), Utils::post('content'))) {
                Utils::redirect('/admin/config/site.php?edit=' . rawurlencode(Utils::get('edit')) . '&ok');
            } else {
                $error = "Impossible d'enregistrer le squelette.";
            }
        }
    }
    $tpl->assign('edit', ['file' => trim(Utils::get('edit')), 'content' => $source]);
    $tpl->assign('csrf_key', $csrf_key);
    $tpl->assign('sources_json', json_encode(Squelette::listSources()));
} else {
    $tpl->assign('sources', Squelette::listSources());
}
Esempio n. 18
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.");
}
$membre = $membres->get(Utils::get('id'));
if (!$membre) {
    throw new UserException("Ce membre n'existe pas.");
}
$error = false;
if (Utils::post('delete')) {
    if (!Utils::CSRF_check('delete_membre_' . $membre['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $membres->delete($membre['id']);
            Utils::redirect('/admin/membres/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('membre', $membre);
$tpl->assign('error', $error);
$tpl->display('admin/membres/supprimer.tpl');
Esempio n. 19
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.");
}
$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();
        }
Esempio n. 20
0
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'));
if (!$co) {
    throw new UserException("Cette cotisation n'existe pas.");
}
$error = false;
if (!empty($_POST['delete'])) {
    if (!Utils::CSRF_check('delete_co_' . $co['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $cotisations->delete($co['id']);
            Utils::redirect('/admin/membres/cotisations/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('cotisation', $co);
$tpl->display('admin/membres/cotisations/gestion/supprimer.tpl');
Esempio n. 21
0
<?php

namespace Garradin;

const LOGIN_PROCESS = true;
require_once __DIR__ . '/_inc.php';
$error = false;
if (trim(Utils::get('c'))) {
    if ($membres->recoverPasswordConfirm(Utils::get('c'))) {
        Utils::redirect('/admin/password.php?new_sent');
    }
    $error = 'EXPIRED';
} elseif (!empty($_POST['recover'])) {
    if (!Utils::CSRF_check('recoverPassword')) {
        $error = 'OTHER';
    } else {
        if (trim(Utils::post('id')) && $membres->recoverPasswordCheck(Utils::post('id'))) {
            Utils::redirect('/admin/password.php?sent');
        }
        $error = 'MAIL';
    }
}
if (!$error && isset($_GET['sent'])) {
    $tpl->assign('sent', true);
} elseif (!$error && isset($_GET['new_sent'])) {
    $tpl->assign('new_sent', true);
}
$champs = $config->get('champs_membres');
$champ = $champs->get($config->get('champ_identifiant'));
$tpl->assign('champ', $champ);
$tpl->assign('error', $error);
Esempio n. 22
0
    throw new UserException('Le compte demandé n\'existe pas.');
}
$error = false;
if (!empty($_POST['delete'])) {
    if (!Utils::CSRF_check('compta_delete_compte_' . $compte['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $comptes->delete($compte['id']);
            Utils::redirect('/admin/compta/comptes/?classe=' . substr($compte['id'], 0, 1));
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
} elseif (!empty($_POST['disable'])) {
    if (!Utils::CSRF_check('compta_disable_compte_' . $compte['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $comptes->disable($compte['id']);
            Utils::redirect('/admin/compta/comptes/?classe=' . substr($compte['id'], 0, 1));
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('can_delete', $comptes->canDelete($compte['id']));
$tpl->assign('can_disable', $comptes->canDisable($compte['id']));
$tpl->assign('error', $error);
$tpl->assign('compte', $compte);
$tpl->display('admin/compta/comptes/supprimer.tpl');
Esempio n. 23
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);
Esempio n. 24
0
    // Renommage du fichier sqlite à la version 0.5.0
    $old_file = str_replace('.sqlite', '.db', DB_FILE);
    if (file_exists($old_file)) {
        rename($old_file, DB_FILE);
        Utils::redirect('/admin/upgrade.php');
    }
}
$tpl = Template::getInstance();
$tpl->assign('admin_url', WWW_URL . 'admin/');
if (file_exists(DB_FILE)) {
    $tpl->assign('disabled', true);
} else {
    $tpl->assign('disabled', false);
    $error = false;
    if (!empty($_POST['save'])) {
        if (!Utils::CSRF_check('install')) {
            $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
        } elseif (Utils::post('passe_membre') != Utils::post('repasse_membre')) {
            $error = 'La vérification ne correspond pas au mot de passe.';
        } else {
            try {
                $db = DB::getInstance(true);
                // Création de la base de données
                $db->exec('BEGIN;');
                $db->exec(file_get_contents(DB_SCHEMA));
                $db->exec('END;');
                // Configuration de base
                $config = Config::getInstance();
                $config->set('nom_asso', Utils::post('nom_asso'));
                $config->set('adresse_asso', Utils::post('adresse_asso'));
                $config->set('email_asso', Utils::post('email_asso'));
Esempio n. 25
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
if ($user['droits']['membres'] < Membres::DROIT_ECRITURE) {
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}
$cats = new Membres\Categories();
$champs = $config->get('champs_membres');
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('new_member')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } elseif (Utils::post('passe') != Utils::post('repasse')) {
        $error = 'La vérification ne correspond pas au mot de passe.';
    } else {
        try {
            if ($user['droits']['membres'] == Membres::DROIT_ADMIN) {
                $id_categorie = Utils::post('id_categorie');
            } else {
                $id_categorie = $config->get('categorie_membres');
            }
            $data = ['id_categorie' => $id_categorie];
            foreach ($champs->getAll() as $key => $dismiss) {
                $data[$key] = Utils::post($key);
            }
            $id = $membres->add($data);
            Utils::redirect('/admin/membres/fiche.php?id=' . (int) $id);
        } catch (UserException $e) {
            $error = $e->getMessage();
Esempio n. 26
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.");
}
$id = Utils::get('id');
$compte = $comptes->get($id);
if (!$compte) {
    throw new UserException('Le compte demandé n\'existe pas.');
}
$error = false;
if (!empty($_POST['save'])) {
    if (!Utils::CSRF_check('compta_edit_compte_' . $compte['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $id = $comptes->edit($compte['id'], ['libelle' => Utils::post('libelle'), 'position' => Utils::post('position')]);
            Utils::redirect('/admin/compta/comptes/?classe=' . substr($compte['id'], 0, 1));
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('positions', $comptes->getPositions());
$tpl->assign('position', Utils::post('position') ?: $compte['position']);
$tpl->assign('compte', $compte);
$tpl->display('admin/compta/comptes/modifier.tpl');
Esempio n. 27
0
if ($user['droits']['membres'] < Membres::DROIT_ADMIN) {
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}
$import = new Membres\Import();
if (isset($_GET['export'])) {
    header('Content-type: application/csv');
    header('Content-Disposition: attachment; filename="Export membres - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"');
    $import->toCSV();
    exit;
}
$error = false;
$champs = $config->get('champs_membres')->getAll();
$champs['date_inscription'] = ['title' => 'Date inscription', 'type' => 'date'];
if (Utils::post('import')) {
    // FIXME
    if (false && !Utils::CSRF_check('membres_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') == 'galette') {
                $import->fromGalette($_FILES['upload']['tmp_name'], Utils::post('galette_translate'));
            } elseif (Utils::post('type') == 'garradin') {
                $import->fromCSV($_FILES['upload']['tmp_name']);
            } else {
                throw new UserException('Import inconnu.');
            }
            Utils::redirect('/admin/membres/import.php?ok');
        } catch (UserException $e) {
            $error = $e->getMessage();
Esempio n. 28
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);
Esempio n. 29
0
// Restauration de ce qui était en session
if ($champs = $membres->sessionGet('champs_membres')) {
    $champs = new Membres\Champs($champs);
} else {
    // Il est nécessaire de créer une nouvelle instance ici, sinon
    // l'enregistrement des modifs ne marchera pas car les deux instances seront identiques.
    // Càd si on utilise directement l'instance de $config, elle sera modifiée directement
    // du coup quand on essaiera de comparer si ça a changé ça comparera deux fois la même chose
    // donc ça n'aura pas changé forcément.
    $champs = new Membres\Champs($config->get('champs_membres'));
}
if (isset($_GET['ok'])) {
    $error = 'OK';
}
if (!empty($_POST['save']) || !empty($_POST['add']) || !empty($_POST['review']) || !empty($_POST['reset'])) {
    if (!Utils::CSRF_check('config_membres')) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        if (!empty($_POST['reset'])) {
            $membres->sessionStore('champs_membres', null);
            Utils::redirect('/admin/config/membres.php');
        } elseif (!empty($_POST['review'])) {
            try {
                $nouveau_champs = Utils::post('champs');
                foreach ($nouveau_champs as $key => &$cfg) {
                    $cfg['type'] = $champs->get($key, 'type');
                }
                $champs->setAll($nouveau_champs);
                $membres->sessionStore('champs_membres', (string) $champs);
                Utils::redirect('/admin/config/membres.php?review');
            } catch (UserException $e) {
Esempio n. 30
0
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.");
}
$cats = new Membres\Categories();
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
    throw new UserException("Argument du numéro de catégorie manquant.");
}
$id = (int) $_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_cat_' . $id)) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $cats->remove($id);
            Utils::redirect('/admin/membres/categories.php');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('cat', $cat);
$tpl->assign('error', $error);
$tpl->display('admin/membres/cat_supprimer.tpl');