Index: src/include/lib/Garradin/Compta/Import.php ================================================================== --- src/include/lib/Garradin/Compta/Import.php +++ src/include/lib/Garradin/Compta/Import.php @@ -88,13 +88,14 @@ $db = DB::getInstance(); $db->begin(); $cats = new Categories; $journal = new Journal; - $liste_cats = $db->getAssoc('SELECT intitule, id FROM compta_categories;'); + $liste_cats = $db->getAssoc('SELECT type || intitule, id FROM compta_categories;'); // Liste des moyens sous la forme nom -> code $liste_moyens = array_flip($cats->listMoyensPaiement(true)); + $liste_moyens = array_change_key_case($liste_moyens, \CASE_LOWER); // Liste associative des projets $liste_projets = $db->getAssoc('SELECT libelle, id FROM compta_projets;'); $col = function($column) use (&$row, &$columns) @@ -166,28 +167,46 @@ $debit = $col('Compte de débit - numéro'); $credit = $col('Compte de crédit - numéro'); $cat = $col('Catégorie'); - $moyen = strtoupper(substr($col('Moyen de paiement'), 0, 2)); + $moyen = strtolower($col('Moyen de paiement')); + $type = $col('Type de mouvement'); + + if ('Recette' === $type) { + $type = 1; + } + elseif ('Dépense' === $type) { + $type = -1; + } + else { + $type = 0; + } // Association du moyen de paiement par nom if ($moyen && array_key_exists($moyen, $liste_moyens)) { $moyen = $liste_moyens[$moyen]; } + // Sinon on estime que c'est juste le code qui est fourni + else + { + $moyen = substr(strtoupper($moyen), 0, 2); + } // Vérification de l'existence du moyen de paiement // s'il n'est pas valide, on ne peut pas avoir de catégorie non plus - if (!$moyen || !in_array($moyen, $liste_moyens, true)) + if (!trim($moyen) || !in_array($moyen, $liste_moyens, true)) { $moyen = false; $cat = false; } - if ($cat && !array_key_exists($cat, $liste_cats)) - { + if ($cat && array_key_exists($type . $cat, $liste_cats)) { + $cat = $liste_cats[$type . $cat]; + } + else { $cat = $moyen = false; } $id_projet = null; @@ -212,11 +231,11 @@ if ($cat) { $data['moyen_paiement'] = $moyen; $data['numero_cheque'] = $col('Numéro de chèque'); - $data['id_categorie'] = $liste_cats[$cat]; + $data['id_categorie'] = $cat; } try { if (empty($id)) { @@ -231,186 +250,11 @@ { throw new UserException(sprintf('Ligne %s: %s', $line, $e->getMessage())); } } - $db->commit(); - - fclose($fp); - return true; - } - - public function fromCitizen($path) - { - if (!file_exists($path) || !is_readable($path)) - { - throw new \RuntimeException('Fichier inconnu : '.$path); - } - - $fp = fopen($path, 'r'); - - if (!$fp) - { - return false; - } - - $db = DB::getInstance(); - $db->begin(); - $comptes = new Comptes; - $banques = new Comptes_Bancaires; - $cats = new Categories; - $journal = new Journal; - - $columns = []; - $liste_comptes = $db->getAssoc('SELECT id, id FROM compta_comptes;'); - $liste_cats = $db->getAssoc('SELECT intitule, id FROM compta_categories;'); - $liste_moyens = $cats->listMoyensPaiement(); - - $get_compte = function ($compte, $intitule) use (&$liste_comptes, &$comptes, &$banques) - { - if (substr($compte, 0, 2) == '51') - { - $compte = '512' . substr($compte, -1); - } - - // Création comptes - if (!array_key_exists($compte, $liste_comptes)) - { - if (substr($compte, 0, 3) == '512') - { - $liste_comptes[$compte] = $banques->add([ - 'libelle' => $intitule, - 'banque' => 'Inconnue', - ]); - } - else - { - $liste_comptes[$compte] = $comptes->add([ - 'id' => $compte, - 'libelle' => $intitule, - 'parent' => substr($compte, 0, -1) - ]); - } - } - - return $compte; - }; - - $col = function($column) use (&$row, &$columns) - { - if (!isset($columns[$column])) - return null; - - if (!isset($row[$columns[$column]])) - return null; - - return $row[$columns[$column]]; - }; - - $line = 0; - $delim = Utils::find_csv_delim($fp); - Utils::skip_bom($fp); - - while (!feof($fp)) - { - $row = fgetcsv($fp, 4096, $delim); - $line++; - - if (empty($row)) - { - continue; - } - - if (empty($columns)) - { - if (empty($row[0])) - { - throw new UserException(sprintf('Erreur sur la ligne %d : la ligne est vide ?', $line)); - } - - $columns = $row; - $columns = array_flip($columns); - continue; - } - - $date = $col('Date'); - $date = \DateTime::createFromFormat('d/m/Y', $date); - - if (!$date) - { - $db->rollback(); - throw new UserException(sprintf('Erreur sur la ligne %d : la date "%s" n\'est pas au format jj/mm/aaaa.', $line, $col('Date'))); - } - - $date = $date->format('Y-m-d'); - - if ($db->test('compta_exercices', '(? < debut OR ? > fin) AND cloture = 0', $date, $date)) - { - continue; - } - - $debit = $get_compte($col('Compte débité - Numéro'), $col('Compte débité - Intitulé')); - $credit = $get_compte($col('Compte crédité - Numéro'), $col('Compte crédité - Intitulé')); - - $cat = $col('Rubrique'); - $moyen = strtoupper(substr($col('Moyen de paiement'), 0, 2)); - - if (!$moyen || !array_key_exists($moyen, $liste_moyens)) - { - $moyen = false; - $cat = false; - } - - if ($cat && !array_key_exists($cat, $liste_cats)) - { - if ($col('Nature') == 'Recette') - { - $type = $cats::RECETTES; - $compte = $credit; - } - elseif ($col('Nature') == 'Dépense') - { - $type = $cats::DEPENSES; - $compte = $debit; - } - else - { - $type = $cats::AUTRES; - $cat = false; - } - - if ($type != $cats::AUTRES) - { - $liste_cats[$cat] = $cats->add([ - 'intitule' => $cat, - 'type' => $type, - 'compte' => $compte - ]); - } - } - - $data = [ - 'libelle' => $col('Libellé'), - 'montant' => $col('Montant'), - 'date' => $date, - 'compte_credit' => $credit, - 'compte_debit' => $debit, - 'numero_piece' => $col('Numéro de pièce'), - 'remarques' => $col('Remarques'), - ]; - - if ($cat) - { - $data['moyen_paiement'] = $moyen; - $data['numero_cheque'] = $col('Numéro de chèque'); - $data['id_categorie'] = $liste_cats[$cat]; - } - - $journal->add($data); - } - $db->commit(); fclose($fp); return true; } } Index: src/include/lib/Garradin/Membres.php ================================================================== --- src/include/lib/Garradin/Membres.php +++ src/include/lib/Garradin/Membres.php @@ -48,10 +48,15 @@ if ($config->type == 'datetime' && trim($data[$key]) !== '') { $dt = new \DateTime($data[$key]); $data[$key] = $dt->format('Y-m-d H:i'); } + elseif ($config->type == 'date' && trim($data[$key]) !== '') + { + $dt = new \DateTime($data[$key]); + $data[$key] = $dt->format('Y-m-d'); + } elseif ($config->type == 'tel') { $data[$key] = Utils::normalizePhoneNumber($data[$key]); } elseif ($config->type == 'country') @@ -143,11 +148,11 @@ $this->_checkFields($data, true, $require_password); if (isset($data[$id]) && $db->test('membres', $id . ' = ? COLLATE NOCASE', $data[$id])) { - throw new UserException('La valeur du champ '.$id.' est déjà utilisée par un autre membre, hors ce champ doit être unique à chaque membre.'); + throw new UserException('La valeur du champ '.$id.' est déjà utilisée par un autre membre, or ce champ doit être unique à chaque membre.'); } if (isset($data['passe']) && trim($data['passe']) != '') { Session::checkPasswordValidity($data['passe']); @@ -182,11 +187,11 @@ $champ_id = $config->get('champ_identifiant'); if (!empty($data[$champ_id]) && $db->firstColumn('SELECT 1 FROM membres WHERE '.$champ_id.' = ? COLLATE NOCASE AND id != ? LIMIT 1;', $data[$champ_id], (int)$id)) { - throw new UserException('La valeur du champ '.$champ_id.' est déjà utilisée par un autre membre, hors ce champ doit être unique à chaque membre.'); + throw new UserException('La valeur du champ '.$champ_id.' est déjà utilisée par un autre membre, or ce champ doit être unique à chaque membre.'); } if (isset($data['numero'])) { if (!preg_match('/^\d+$/', $data['numero'])) Index: src/include/lib/Garradin/Membres/Champs.php ================================================================== --- src/include/lib/Garradin/Membres/Champs.php +++ src/include/lib/Garradin/Membres/Champs.php @@ -494,38 +494,38 @@ { $this->champs = $champs; return true; } - if (!array_key_exists('email', $champs)) + if (!property_exists($champs, 'email')) { throw new UserException('Le champ E-Mail ne peut être supprimé des fiches membres.'); } - if (!array_key_exists('passe', $champs)) + if (!property_exists($champs, 'passe')) { throw new UserException('Le champ Mot de passe ne peut être supprimé des fiches membres.'); } - if (!array_key_exists('numero', $champs)) + if (!property_exists($champs, 'numero')) { throw new UserException('Le champ numéro de membre ne peut être supprimé des fiches membres.'); } $config = Config::getInstance(); $identite = $config->get('champ_identite'); - if ($identite != 'id' && !array_key_exists($identite, $champs)) + if ($identite != 'id' && !property_exists($champs, $identite)) { throw new UserException('Le champ '.$config->get('champ_identite') .' est défini comme identité des membres et ne peut donc être supprimé des fiches membres.'); } $identifiant = $config->get('champ_identifiant'); - if ($identifiant != 'id' && !array_key_exists($identifiant, $champs)) + if ($identifiant != 'id' && !property_exists($champs, $identifiant)) { throw new UserException('Le champ '.$config->get('champ_identifiant') .' est défini comme identifiant à la connexion et ne peut donc être supprimé des fiches membres.'); } Index: src/include/lib/Garradin/Membres/Cotisations.php ================================================================== --- src/include/lib/Garradin/Membres/Cotisations.php +++ src/include/lib/Garradin/Membres/Cotisations.php @@ -287,11 +287,11 @@ // Renvoyer la liste avec tous les membres des catégories dont la cotisation obligatoire est celle-ci if ($include_category) { $cats_obligatoires = $db->getAssoc('SELECT id, id FROM membres_categories WHERE id_cotisation_obligatoire = ? AND cacher = 0;', $id); - return $db->get('SELECT m.id AS id_membre, MAX(cm.date), cm.id, m.numero, + return $db->get('SELECT m.id AS id_membre, MAX(cm.date) AS date, cm.id, m.numero, m.'.$champ_id.' AS nom, c.montant, CASE WHEN cm.id IS NULL THEN 0 WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\') >= date() WHEN c.fin IS NOT NULL THEN (cm.date <= c.fin AND cm.date >= c.debut) ELSE 1 END AS a_jour @@ -302,11 +302,11 @@ '.$db->where('m.id_categorie', $cats_obligatoires) . ' GROUP BY m.id ORDER BY '.$order.' '.$desc.' LIMIT ?,?;', $id, $begin, self::ITEMS_PER_PAGE); } - return $db->get('SELECT cm.id_membre, MAX(cm.date), cm.id, m.numero, + return $db->get('SELECT cm.id_membre, MAX(cm.date) AS date, cm.id, m.numero, m.'.$champ_id.' AS nom, c.montant, CASE WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\') >= date() WHEN c.fin IS NOT NULL THEN (cm.date <= c.fin AND cm.date >= c.debut) ELSE 1 END AS a_jour FROM cotisations_membres AS cm Index: src/include/lib/Garradin/Template.php ================================================================== --- src/include/lib/Garradin/Template.php +++ src/include/lib/Garradin/Template.php @@ -435,10 +435,12 @@ if (!empty($config->mandatory)) { $attributes .= 'required="required" '; } + + $attributes .= 'autocomplete="off" '; if (!empty($params['user_mode']) && empty($config->editable)) { $out = '
{csrf_field key="compta_rapprocher_%s"|args:$compte.id} Index: src/templates/admin/compta/import.tpl ================================================================== --- src/templates/admin/compta/import.tpl +++ src/templates/admin/compta/import.tpl @@ -29,21 +29,10 @@
Si le fichier comporte des opérations dont la date est en dehors de l'exercice courant, Index: src/templates/admin/config/membres.tpl ================================================================== --- src/templates/admin/config/membres.tpl +++ src/templates/admin/config/membres.tpl @@ -5,12 +5,12 @@ {if isset($status) && $status == 'OK'}
La configuration a bien été enregistrée.
{elseif isset($status) && $status == 'ADDED'} -- Le champ a été ajouté à la fin de la liste. +
+ Le champ a été ajouté à la fin de la liste. Pour sauvegarder les modifications de la fiche membre cliquer sur le bouton « Enregistrer » en base de page.
{/if} {form_errors} Index: src/templates/admin/install.tpl ================================================================== --- src/templates/admin/install.tpl +++ src/templates/admin/install.tpl @@ -42,13 +42,13 @@{csrf_field key="install"} Index: src/templates/admin/login.tpl ================================================================== --- src/templates/admin/login.tpl +++ src/templates/admin/login.tpl @@ -24,11 +24,11 @@