Пример #1
0
                $type = 'avance';
            } elseif ($type == Compta\Categories::RECETTES) {
                $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);
Пример #2
0
    $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;
                    $b = $cat['compte'];
                } else {
                    if (!trim(Utils::post('banque'))) {
                        throw new UserException('Le compte bancaire choisi est invalide.');
                    }
                    if (!array_key_exists(Utils::post('banque'), $banques->getList())) {
                        throw new UserException('Le compte bancaire choisi n\'existe pas.');
                    }
                    $a = Utils::post('banque');
                    $b = $cat['compte'];
                }