$stats = new Compta\Stats(); $plot = new \KD2\SVGPlot(400, 300); if ($graph == 'recettes_depenses') { $r = new \KD2\SVGPlot_Data($stats->recettes()); $r->title = 'Recettes'; $d = new \KD2\SVGPlot_Data($stats->depenses()); $d->title = 'Dépenses'; $data = [$d, $r]; $plot->setTitle('Recettes et dépenses de l\'exercice courant'); } elseif ($graph == 'banques_caisses') { $banques = new Compta\Comptes_Bancaires(); $data = []; $r = new \KD2\SVGPlot_Data($stats->soldeCompte(Compta\Comptes::CAISSE)); $r->title = 'Caisse'; $data[] = $r; foreach ($banques->getList() as $banque) { $r = new \KD2\SVGPlot_Data($stats->soldeCompte($banque['id'])); $r->title = $banque['libelle']; $data[] = $r; } $plot->setTitle('Solde des comptes et caisses'); } if (!empty($data)) { $labels = []; foreach ($data[0]->get() as $k => $v) { $labels[] = Utils::date_fr('M y', strtotime(substr($k, 0, 4) . '-' . substr($k, 4, 2) . '-01')); } $plot->setLabels($labels); $i = 0; $colors = ['#c71', '#941', '#fa4', '#fd9', '#ffc', '#cc9']; foreach ($data as $line) {
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.'); } } else { 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']; } } if ($type === Compta\Categories::DEPENSES) { $debit = $b; $credit = $a; } elseif ($type === Compta\Categories::RECETTES) { $debit = $a; $credit = $b; } elseif ($type === 'dette') { $debit = $cat['compte']; $credit = Utils::post('compte');
Utils::redirect('/admin/membres/cotisations.php?id=' . (int) Utils::post('id_membre')); } catch (UserException $e) { $error = $e->getMessage(); } } } $tpl->assign('error', $error); $tpl->assign('membre', $membre); $tpl->assign('cotisations', $cotisations->listCurrent()); $tpl->assign('default_co', null); $tpl->assign('default_amount', 0.0); $tpl->assign('default_date', date('Y-m-d')); $tpl->assign('default_compta', null); $tpl->assign('moyens_paiement', $cats->listMoyensPaiement()); $tpl->assign('moyen_paiement', Utils::post('moyen_paiement') ?: 'ES'); $tpl->assign('comptes_bancaires', $banques->getList()); $tpl->assign('banque', Utils::post('banque')); if (Utils::get('cotisation')) { $co = $cotisations->get(Utils::get('cotisation')); if (!$co) { throw new UserException("La cotisation indiquée en paramètre n'existe pas."); } $tpl->assign('default_co', $co['id']); $tpl->assign('default_compta', $co['id_categorie_compta']); $tpl->assign('default_amount', $co['montant']); } elseif ($membre) { if (!empty($categorie['id_cotisation_obligatoire'])) { $co = $cotisations->get($categorie['id_cotisation_obligatoire']); $tpl->assign('default_co', $co['id']); $tpl->assign('default_amount', $co['montant']); }