X-Git-Url: https://git.cyclocoop.org/?p=garradin.git;a=blobdiff_plain;f=www%2Fadmin%2Fcompta%2Fimport.php;h=b14fe02da1b8db5cb494af552f71918a2dae7a42;hp=22a11375d9af2ca1fb9eb6bc18837a2b0438356c;hb=f7ee0ae730f47bfef173c394fa4db71a22dece61;hpb=1ab3343a95ed3ef4958d91dfbf49372dce8a092e diff --git a/www/admin/compta/import.php b/www/admin/compta/import.php index 22a1137..b14fe02 100644 --- a/www/admin/compta/import.php +++ b/www/admin/compta/import.php @@ -10,6 +10,7 @@ if ($user['droits']['compta'] < Membres::DROIT_ADMIN) $e = new Compta_Exercices; $import = new Compta_Import; +$comptes = new Compta_Comptes; if (isset($_GET['export'])) { @@ -27,7 +28,7 @@ if (!empty($_POST['import'])) { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } - elseif (empty($_FILES['upload']['tmp_name'])) + if (empty($_FILES['upload']['tmp_name'])) { $error = 'Aucun fichier fourni.'; } @@ -35,13 +36,23 @@ if (!empty($_POST['import'])) { try { + if (isset($_FILES['upload-plan-comptable'])) + { + if (!$comptes->importPlan($_FILES['upload-plan-comptable']['tmp_name'])) + { + throw new UserException('Erreur lors de l’import du plan comptable'); + } + } if (utils::post('type') == 'citizen') { $import->fromCitizen($_FILES['upload']['tmp_name']); } elseif (utils::post('type') == 'garradin') { - $import->fromCSV($_FILES['upload']['tmp_name']); + if (!$import->fromCSV($_FILES['upload']['tmp_name'])) + { + throw new UserException('Erreur lors de l’import'); + } } else { @@ -62,4 +73,4 @@ $tpl->assign('ok', isset($_GET['ok']) ? true : false); $tpl->display('admin/compta/import.tpl'); -?> \ No newline at end of file +?>