Example #1
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 #2
0
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';
$compte = $comptes->get(Utils::get('id'));
if (!$compte) {
    throw new UserException("Le compte demandé n'existe pas.");
}
$journal = new Compta\Journal();
$solde = $journal->getSolde($compte['id']);
if ($compte['position'] & Compta\Comptes::ACTIF || $compte['position'] & Compta\Comptes::CHARGE) {
    $tpl->assign('credit', '-');
    $tpl->assign('debit', '+');
} else {
    $tpl->assign('credit', '+');
    $tpl->assign('debit', '-');
}
$tpl->assign('compte', $compte);
$tpl->assign('solde', $solde);
$tpl->assign('journal', $journal->getJournalCompte($compte['id']));
$tpl->display('admin/compta/comptes/journal.tpl');
Example #3
0
$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;
foreach ($list as $row) {
    $total += (double) $row['montant'];
}
$tpl->assign('total', $total);
$tpl->display('admin/compta/operations/index.tpl');
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.");
}
$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 #5
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']);
Example #6
0
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.");
}
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("Ce membre n'existe pas.");
}
$champs = $config->get('champs_membres');
$tpl->assign('champs', $champs->getAll());
$cats = new Membres\Categories();
$categorie = $cats->get($membre['id_categorie']);
$tpl->assign('categorie', $categorie);
$cotisations = new Membres\Cotisations();
if (!empty($categorie['id_cotisation_obligatoire'])) {
    $tpl->assign('cotisation', $cotisations->isMemberUpToDate($membre['id'], $categorie['id_cotisation_obligatoire']));
} else {
    $tpl->assign('cotisation', false);
}
$tpl->assign('nb_activites', $cotisations->countForMember($membre['id']));
if ($user['droits']['compta'] >= Membres::DROIT_ACCES) {
    $journal = new Compta\Journal();
    $tpl->assign('nb_operations', $journal->countForMember($membre['id']));
}
$tpl->assign('membre', $membre);
$tpl->display('admin/membres/fiche.tpl');
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.");
}
$journal = new Compta\Journal();
$query = trim(Utils::get('query'));
$tpl->assign('schema', $journal->schemaSQL());
$tpl->assign('query', $query);
if ($query != '') {
    try {
        $tpl->assign('result', $journal->searchSQL($query));
    } catch (\Exception $e) {
        $tpl->assign('result', null);
        $tpl->assign('error', $e->getMessage());
    }
} else {
    $tpl->assign('result', null);
}
$tpl->display('admin/compta/operations/recherche_sql.tpl');
Example #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.");
}
$journal = new Compta\Journal();
$operation = $journal->get(Utils::get('id'));
if (!$operation) {
    throw new UserException("L'opération demandée n'existe pas.");
}
$error = false;
if (!empty($_POST['delete'])) {
    if (!Utils::CSRF_check('compta_supprimer_' . $operation['id'])) {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    } else {
        try {
            $journal->delete($operation['id']);
            Utils::redirect('/admin/compta/operations/');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('operation', $operation);
$tpl->display('admin/compta/operations/supprimer.tpl');
Example #9
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());