4 require_once __DIR__
. '/_inc.php';
6 if ($user['droits']['compta'] < Membres
::DROIT_ADMIN
)
8 throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
11 $e = new Compta_Exercices
;
12 $import = new Compta_Import
;
14 if (isset($_GET['export']))
16 header('Content-type: application/csv');
17 header('Content-Disposition: attachment; filename="Export comptabilité - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"');
18 $import->toCSV($e->getCurrentId());
24 if (!empty($_POST['import']))
26 if (!utils
::CSRF_check('compta_import'))
28 $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
30 elseif (empty($_FILES['upload']['tmp_name']))
32 $error = 'Aucun fichier fourni.';
38 if (utils
::post('type') == 'citizen')
40 $import->fromCitizen($_FILES['upload']['tmp_name']);
42 elseif (utils
::post('type') == 'garradin')
44 $import->fromCSV($_FILES['upload']['tmp_name']);
48 throw new UserException('Import inconnu.');
51 utils
::redirect('/admin/compta/import.php?ok');
53 catch (UserException
$e)
55 $error = $e->getMessage();
60 $tpl->assign('error', $error);
61 $tpl->assign('ok', isset($_GET['ok']) ?
true : false);
63 $tpl->display('admin/compta/import.tpl');