Overview
Comment:* Gérer les fichiers CSV provenant des vieilles versions d'Excel pour Mac OS. * Ajouter la mention de la taille limite du fichier
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA1: b81cf4d462ca597eb3e56f20013bf40090f34b14
User & Date: bohwaz on 2020-01-31 01:06:19
Other Links: manifest | tags
Context
2020-01-31
01:29
Corriger statut cotisation check-in: c5da0736f0 user: bohwaz tags: trunk, stable
01:06
* Gérer les fichiers CSV provenant des vieilles versions d'Excel pour Mac OS. * Ajouter la mention de la taille limite du fichier check-in: b81cf4d462 user: bohwaz tags: trunk, stable
00:23
Correctif PHP 7.4: référence à une variable nulle check-in: 83f694001d user: bohwaz tags: dev
2020-01-27
00:43
* Gérer les fichiers CSV provenant des vieilles versions d'Excel pour Mac OS. * Ajouter la mention de la taille limite du fichier check-in: 738039429a user: bohwaz tags: dev
2020-01-05
19:05
Fix: parfois le rappel sélectionné n'était pas forcément le plus proche, dans le cas où plusieurs rappels ont été créés pour une même cotisation check-in: 16a3fb2fbe user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Membres/Import.php from [6ee80dccef] to [5800dd1bd4].

13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27







-
+







	public function getCSVAsArray($path)
	{
		if (!file_exists($path) || !is_readable($path))
		{
			throw new \RuntimeException('Fichier inconnu : '.$path);
		}

		$fp = fopen($path, 'r');
		$fp = Utils::open_csv_file($path);

		if (!$fp)
		{
			return false;
		}

		$delim = Utils::find_csv_delim($fp);
175
176
177
178
179
180
181
182

183
184
185
186
187
188
189
175
176
177
178
179
180
181

182
183
184
185
186
187
188
189







-
+







	public function fromGarradinCSV($path, $current_user_id)
	{
		if (!file_exists($path) || !is_readable($path))
		{
			throw new \RuntimeException('Fichier inconnu : '.$path);
		}

		$fp = fopen($path, 'r');
		$fp = Utils::open_csv_file($path);

		if (!$fp)
		{
			return false;
		}

		$db = DB::getInstance();

Modified src/include/lib/Garradin/Squelette.php from [f4ce828da9] to [c51c3077ae].

653
654
655
656
657
658
659
660

661
662
663
664
665
666
667
653
654
655
656
657
658
659

660
661
662
663
664
665
666
667







-
+







        catch (\Exception $e)
        {
            throw new \KD2\MiniSkelMarkupException("Erreur SQL dans la requête : ".$e->getMessage() . "\n " . $query);
        }

        $hash = sha1(uniqid(mt_rand(), true));
        $out = new Squelette_Snippet();
        $out->append(1, '$parent_hash = $this->current[\'_self_hash\'];');
        $out->append(1, '$parent_hash = @$this->current[\'_self_hash\'];');
        $out->append(1, '$this->parent =& $parent_hash ? $this->_vars[$parent_hash] : null;');

        if (!empty($search))
        {
            $out->append(1, 'if (trim($this->getVariable(\'recherche\'))) { ');
        }

Modified src/include/lib/Garradin/Utils.php from [794409535e] to [eeb7ab32e4].

615
616
617
618
619
620
621






622
623
624
625
626
627
628
629

630
631





632
633
634
635
636
637
638
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634

635
636

637
638
639
640
641
642
643
644
645
646
647
648







+
+
+
+
+
+







-
+

-
+
+
+
+
+







            
            if (!(is_numeric($params['query']) && (int)$params['query'] === 1) && $params['query'] !== true)
                $url .= $params['query'];
        }

        return $url;
    }

    static public function open_csv_file($file)
    {
        ini_set('auto_detect_line_endings', true);
        return fopen($file, 'r');
    }

    static public function find_csv_delim(&$fp)
    {
        $line = '';

        while ($line === '' && !feof($fp))
        {
            $line = trim(fgets($fp, 4096));
            $line = fgets($fp, 4096);
        }
        

        if (strlen($line) >= 4095) {
            throw new UserException('Fichier CSV illisible : la première ligne est trop longue.');
        }

        // Delete the columns content
        $line = preg_replace('/".*?"/', '', $line);

        $delims = [
            ';' => substr_count($line, ';'),
            ',' => substr_count($line, ','),
            "\t"=> substr_count($line, "\t")

Modified src/templates/admin/membres/import.tpl from [f774ddb844] to [1c6c043793].

56
57
58
59
60
61
62

63
64
65
66
67
68
69
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70







+








    {else}

    <fieldset>
        <legend>Importer depuis un fichier</legend>
        <dl>
            <dt><label for="f_file">Fichier à importer</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd class="help">La taille maximale du fichier est de {$max_upload_size|format_bytes}.</dd>
            <dd><input type="file" name="upload" id="f_file" required="required" /></dd>
            <dt><label for="f_type">Type de fichier</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <input type="radio" name="type" id="f_type" value="garradin" {form_field name=type checked="garradin" default="garradin"} />
                <label for="f_type">Fichier CSV de Garradin</label>
            </dd>
            <dd class="help">

Modified src/www/admin/membres/import.php from [ad7949cf6c] to [bd11ab09aa].

79
80
81
82
83
84
85


86
87
88
89
79
80
81
82
83
84
85
86
87
88
89
90
91







+
+




    }
}

$tpl->assign('ok', null !== qg('ok') ? true : false);

$tpl->assign('csv_file', $csv_file);
$tpl->assign('csv_first_line', $csv_file ? reset($csv_file) : null);

$tpl->assign('max_upload_size', Utils::getMaxUploadSize());

$tpl->assign('garradin_champs', $champs);

$tpl->display('admin/membres/import.tpl');