Overview
Comment:Merge with trunk
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: e5ad3de6e31c852cc047e0119e9b9c34c23cabec81c006ee3ca3261d396c62e1
User & Date: bohwaz on 2022-09-02 20:16:42
Other Links: branch diff | manifest | tags
Context
2022-09-02
20:40
Refactor plugin admin page, a bit check-in: 74806bd766 user: bohwaz tags: dev
20:16
Merge with trunk check-in: e5ad3de6e3 user: bohwaz tags: dev
20:03
Improve WebDAV details for NextCloud check-in: 70b0db9fce user: bohwaz tags: dev
18:58
Missing return statement check-in: 941cbc6502 user: bohwaz tags: trunk, stable, 1.1.29
Changes

Modified README.md from [b535b9dd6a] to [39058ba00d].

20
21
22
23
24
25
26
27
28



Cette clause s'applique même si le logiciel n'est pas distribué et simplement installé sur un serveur.

## Code utilisé

Inclus les bibliothèques suivantes :

* [KD2fw](https://fossil.kd2.org/kd2fw/) - Copyright : 2001-2020+ BohwaZ - Licence : GNU AGPL v3
* [Gibberish AES](https://github.com/mdp/gibberish-aes) - Copyright : Mark Percival 2008 - http://markpercival.us -Licence : MIT









|
|
>
>
20
21
22
23
24
25
26
27
28
29
30

Cette clause s'applique même si le logiciel n'est pas distribué et simplement installé sur un serveur.

## Code utilisé

Inclus les bibliothèques suivantes :

* [KD2fw](https://fossil.kd2.org/kd2fw/) - Copyright : 2001-2022+ BohwaZ - Licence : GNU AGPL v3
* [Gibberish AES](https://github.com/mdp/gibberish-aes) - Copyright : Mark Percival 2008 - http://markpercival.us - Licence : MIT
* [Parsedown](https://github.com/erusev/parsedown) - Copyright Emanuil Rusev - License MIT
* [Unzipit.js](https://github.com/greggman/unzipit) - Copyright (c) 2019 Gregg Tavares  2014 Josh Wolfe - License MIT

Modified debian/garradin from [f3db96af25] to [aadb37a9bb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31




32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63



64
65
66
67
68
69
70
#!/bin/sh

ROOT=/usr/share/garradin/www
#ROOT=~/fossil/garradin/src/www
ROUTER=${ROOT}/_route.php
PORT=8081
ADDRESS="127.0.0.1"
VERBOSE=0
PID_FILE="${XDG_RUNTIME_DIR}/garradin/pid"

[ ! -d `dirname $PID_FILE` ] && mkdir -p `dirname $PID_FILE`

# Execute getopt
ARGS=`getopt -o "p:vh" -l "port:,verbose,help" -n "garradin" -- "$@"`

# Bad arguments
if [ $? -ne 0 ];
then
  exit 1
fi

# A little magic
eval set -- "$ARGS"

# Now go through all the options
while true;
do
  case "$1" in
    -p|--port)
      PORT=$2
      shift;;





    -v|--verbose)
      VERBOSE=1
      shift;;

    -h|--help)
      cat <<EOF
Usage : $0 [COMMANDE] [PROJET]

Où COMMANDE peut être :

        server [-p|--port PORT]
                Démarre un serveur web Garradin sur le port spécifié
                (ou sur le port 8081 par défaut)

        ui [-p|--port PORT]
                Idem que 'server' mais démarre ensuite le navigateur web par défaut
                et connecte automatiquement avec le premier administrateur
                de l'association.

Si aucune COMMANDE n'est donnée, Garradin utilisera 'ui' par défaut.

PROJET est le chemin menant à un projet Garradin précis
        (fichier .garradin.sqlite). Si aucun projet n'est indiqué, le
        dernier projet ouvert sera rouvert. Si aucun projet n'a jamais été
        ouvert un nouveau projet sera créé.

Options :

        -p|--port PORT
                Spécifie le port pour le mode ui ou le mode serveur.




        -v|--verbose
                Affiche les requêtes reçues sur le serveur web.

        -h|--help
                Affiche ce message.
EOF
      exit













|

















>
>
>
>











|

|

|
















>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh

ROOT=/usr/share/garradin/www
#ROOT=~/fossil/garradin/src/www
ROUTER=${ROOT}/_route.php
PORT=8081
ADDRESS="127.0.0.1"
VERBOSE=0
PID_FILE="${XDG_RUNTIME_DIR}/garradin/pid"

[ ! -d `dirname $PID_FILE` ] && mkdir -p `dirname $PID_FILE`

# Execute getopt
ARGS=`getopt -o "pb:vh" -l "port:,bind:,verbose,help" -n "garradin" -- "$@"`

# Bad arguments
if [ $? -ne 0 ];
then
  exit 1
fi

# A little magic
eval set -- "$ARGS"

# Now go through all the options
while true;
do
  case "$1" in
    -p|--port)
      PORT=$2
      shift;;

    -b|--bind)
      ADDRESS=$2
      shift;;

    -v|--verbose)
      VERBOSE=1
      shift;;

    -h|--help)
      cat <<EOF
Usage : $0 [COMMANDE] [PROJET]

Où COMMANDE peut être :

        server [-p|--port PORT] [-b|--bind IP]
                Démarre un serveur web Garradin sur le port spécifié
                (8081 par défaut) et l'IP spécifiée (127.0.0.1 par défaut)

        ui [-p|--port PORT] [-b|--bind IP]
                Idem que 'server' mais démarre ensuite le navigateur web par défaut
                et connecte automatiquement avec le premier administrateur
                de l'association.

Si aucune COMMANDE n'est donnée, Garradin utilisera 'ui' par défaut.

PROJET est le chemin menant à un projet Garradin précis
        (fichier .garradin.sqlite). Si aucun projet n'est indiqué, le
        dernier projet ouvert sera rouvert. Si aucun projet n'a jamais été
        ouvert un nouveau projet sera créé.

Options :

        -p|--port PORT
                Spécifie le port pour le mode ui ou le mode serveur.

        -b|--bind IP
                Spécifie l'adresse IP du serveur web.

        -v|--verbose
                Affiche les requêtes reçues sur le serveur web.

        -h|--help
                Affiche ce message.
EOF
      exit

Modified debian/manpage.txt from [beb215ce60] to [5528468d0a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19





20
21
22
23
24








25
26
27
28
29
30
31
GARRADIN(1)
===========
:doctype: manpage


NAME
----
garradin - gestionnaire d'association à but non lucratif


SYNOPSIS
--------
*garradin* ['OPTIONS'] ['COMMANDE']


DESCRIPTION
-----------
Lancer garradin(1) sans argument lance le serveur web intégré sur
l'adresse localhost:8088 et le navigateur web par défaut.






OPTIONS
-------
*-p, --port*='PORT'::
Défini le port utilisé par le serveur web.









*-v, --verbose*::
Affiche les messages du serveur web.

*-h, --help*::
Affiche un message d'aide sur l'utilisation de la commande.













|





|
>
>
>
>
>





>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
GARRADIN(1)
===========
:doctype: manpage


NAME
----
garradin - gestionnaire d'association à but non lucratif


SYNOPSIS
--------
*garradin* ['OPTIONS'] ['COMMANDE'] ['BASE']


DESCRIPTION
-----------
Lancer garradin(1) sans argument lance le serveur web intégré sur
l'adresse localhost:8081 et le navigateur web par défaut.

*BASE* défini le chemin de la base de données (fichier .sqlite) à
utiliser. Par défaut, si aucune base n'est spécifiée, c'est le fichier
'association.sqlite' situé dans le répertoire des données qui est
utilisé.

OPTIONS
-------
*-p, --port*='PORT'::
Défini le port utilisé par le serveur web.
Par défaut c'est le port 8081 qui est utilisé.

*-b, --bind*='IP'::
Adresse IP où sera exposé le serveur web.
Par défaut c'est 127.0.0.1 qui est utilisé.

Utiliser 0.0.0.0 pour que le serveur web soit accessible d'autres
machines. (Attention cela peut présenter un risque de sécurité.)

*-v, --verbose*::
Affiche les messages du serveur web.

*-h, --help*::
Affiche un message d'aide sur l'utilisation de la commande.

42
43
44
45
46
47
48




49



















50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
-----------
*0*::
Succès

*1*::
Erreur

























BUGS
----
Voir http://dev.kd2.org/garradin/ pour un accès au bugtracker.


AUTEUR
------
Garradin est développé par bohwaz et d'autres contributeurs.


RESSOURCES
----------

Site principal : <http://dev.kd2.org/garradin/>


COPYING
-------
Copyright \(C) 2011-2014 BohwaZ. Free use of this software is
granted under the terms of the GNU Affero General Public License v3
(AGPL).







>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|










|







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-----------
*0*::
Succès

*1*::
Erreur

EMPLACEMENTS DE STOCKAGE
------------------------
Les données sont stockées dans $XDG_DATA_HOME/garradin.
Généralement c'est ~/.local/share/garradin

CONFIGURATION
-------------
Il est possible de créer un fichier de configuration dans
$XDG_CONFIG_HOME/garradin/config.local.php

Voir la documentation pour plus de détails sur les constantes
de configuration acceptées.

INSTALLATION SERVEUR WEB
------------------------
Il est possible d'utiliser ce package avec Apache pour héberger
une instance Garradin.

La procédure est détaillée ici :
https://fossil.kd2.org/garradin/wiki?name=Installation%20sous%20Debian-Ubuntu

Les données et plugins seront stockés dans le répertoire
/var/lib/garradin

BUGS
----
Voir https://fossil.kd2.org/garradin/ pour un accès au bugtracker.


AUTEUR
------
Garradin est développé par bohwaz et d'autres contributeurs.


RESSOURCES
----------

Site principal : <https://fossil.kd2.org/garradin/>


COPYING
-------
Copyright \(C) 2011-2014 BohwaZ. Free use of this software is
granted under the terms of the GNU Affero General Public License v3
(AGPL).

Added src/include/data/1.1.29_migration.sql version [79c6023bea].

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
CREATE TEMP TABLE IF NOT EXISTS su_fix_fee (id);

INSERT INTO su_fix_fee
	SELECT su.id FROM services_users su LEFT JOIN services_fees sf ON sf.id = su.id_fee AND sf.id_service = sf.id_service
	WHERE sf.id IS NULL AND su.id_fee IS NOT NULL;

-- Remove id_fee from subscriptions where it belongs to another service
UPDATE services_users SET id_fee = NULL WHERE id IN (SELECT id FROM su_fix_fee);

Modified src/include/data/charts/fr_pca_2018.csv from [fef45dc8f4] to [f41f4d5fe4].

182
183
184
185
186
187
188




189
190
191
192
193
194
195
4286,Personnel- Charges à payer,,Passif,
4287,Personnel- Produits à recevoir,,Actif,
43,SÉCURITÉ SOCIALE &  AUTRES ORGANISMES SOCIAUX,,Passif,
431,Sécurité sociale,,Passif,
4372,Mutuelles,,Passif,
4373,Caisses de retraites et de prévoyance,,Passif,
4378,Autres organismes sociaux,,Passif,




44,ETAT ET AUTRES COLLECTIVITÉS PUBLIQUES,,Actif,
441,Etat - Subventions à recevoir,,Actif,
4421,Prélèvements à la source- Impôt sur le revenu,,Actif ou passif,
444,Etat - Impôts sur les bénéfices,,Actif ou passif,
4452,TVA due intracommunautaire,,Actif ou passif,
4455,Taxes sur CA à décaisser,,Actif,
44562,TVA déductible sur immobilisations,,Actif,







>
>
>
>







182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
4286,Personnel- Charges à payer,,Passif,
4287,Personnel- Produits à recevoir,,Actif,
43,SÉCURITÉ SOCIALE &  AUTRES ORGANISMES SOCIAUX,,Passif,
431,Sécurité sociale,,Passif,
4372,Mutuelles,,Passif,
4373,Caisses de retraites et de prévoyance,,Passif,
4378,Autres organismes sociaux,,Passif,
438,Organismes sociaux - Charges à payer et produits à recevoir,,Passif,
4382,Charges sociales sur congés à payer,,Passif,
4386,Autres charges à payer,,Passif,
4387,Produits à recevoir,,Passif,
44,ETAT ET AUTRES COLLECTIVITÉS PUBLIQUES,,Actif,
441,Etat - Subventions à recevoir,,Actif,
4421,Prélèvements à la source- Impôt sur le revenu,,Actif ou passif,
444,Etat - Impôts sur les bénéfices,,Actif ou passif,
4452,TVA due intracommunautaire,,Actif ou passif,
4455,Taxes sur CA à décaisser,,Actif,
44562,TVA déductible sur immobilisations,,Actif,

Modified src/include/lib/Garradin/Accounting/Accounts.php from [5d04be4dbd] to [1dd8a6b1a7].

231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247







248
249


250
251
252
253
254
255
256
		if (empty($file['size']) || empty($file['tmp_name'])) {
			throw new UserException('Fichier invalide');
		}

		self::importCSV($file['tmp_name']);
	}

	public function importCSV(string $file): void
	{
		$db = DB::getInstance();
		$positions = array_flip(Account::POSITIONS_NAMES);
		$types = array_flip(Account::TYPES_NAMES);

		$db->begin();

		try {
			foreach (CSV::import($file, self::EXPECTED_CSV_COLUMNS) as $line => $row) {







				$account = new Account;
				$account->id_chart = $this->chart_id;


				try {
					if (!isset($positions[$row['position']])) {
						throw new ValidationException('Position inconnue : ' . $row['position']);
					}

					if (!isset($types[$row['type']])) {
						throw new ValidationException('Type inconnu : ' . $row['type']);







|









>
>
>
>
>
>
>
|
|
>
>







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
		if (empty($file['size']) || empty($file['tmp_name'])) {
			throw new UserException('Fichier invalide');
		}

		self::importCSV($file['tmp_name']);
	}

	public function importCSV(string $file, bool $update = false): void
	{
		$db = DB::getInstance();
		$positions = array_flip(Account::POSITIONS_NAMES);
		$types = array_flip(Account::TYPES_NAMES);

		$db->begin();

		try {
			foreach (CSV::import($file, self::EXPECTED_CSV_COLUMNS) as $line => $row) {
				$account = null;

				if ($update) {
					$account = EntityManager::findOne(Account::class, 'SELECT * FROM @TABLE WHERE code = ? AND id_chart = ?;', $row['code'], $this->chart_id);
				}

				if (!$account) {
					$account = new Account;
					$account->id_chart = $this->chart_id;
				}

				try {
					if (!isset($positions[$row['position']])) {
						throw new ValidationException('Position inconnue : ' . $row['position']);
					}

					if (!isset($types[$row['type']])) {
						throw new ValidationException('Type inconnu : ' . $row['type']);

Modified src/include/lib/Garradin/Accounting/AssistedReconciliation.php from [ef71372dca] to [d39e44d921].

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
				$has_amount = in_array('amount', $this->csv->getTranslationTable());
			}

			if (!$has_amount && isset($line->credit) && isset($line->debit)) {
				$line->amount = $line->credit ?: '-' . ltrim($line->debit, '- \t\r\n');
			}

			$line->amount = Utils::moneyToInteger($line->amount);

			if (!empty($line->balance)) {
				$line->balance = (substr($line->balance, 0, 1) == '-' ? -1 : 1) * Utils::moneyToInteger($line->balance);
			}

			$line->new_params = http_build_query([
				'a' => abs($line->amount)/100,







|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
				$has_amount = in_array('amount', $this->csv->getTranslationTable());
			}

			if (!$has_amount && isset($line->credit) && isset($line->debit)) {
				$line->amount = $line->credit ?: '-' . ltrim($line->debit, '- \t\r\n');
			}

			$line->amount = Utils::moneyToInteger($line->amount ?? 0);

			if (!empty($line->balance)) {
				$line->balance = (substr($line->balance, 0, 1) == '-' ? -1 : 1) * Utils::moneyToInteger($line->balance);
			}

			$line->new_params = http_build_query([
				'a' => abs($line->amount)/100,

Modified src/include/lib/Garradin/Accounting/Charts.php from [92d19977a5] to [37242cb581].

43
44
45
46
47
48
49
















50
51
52
53
54
55
56
		$chart->label = self::BUNDLED_CHARTS[$chart_code];
		$chart->country = $country;
		$chart->code = $code;
		$chart->save();
		$chart->accounts()->importCSV($file);
		return $chart;
	}

















	static public function listInstallable(): array
	{
		$installed = DB::getInstance()->getAssoc('SELECT id, LOWER(country || \'_\' || code) FROM acc_charts;');
		$out = [];

		foreach (self::BUNDLED_CHARTS as $code => $label) {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
		$chart->label = self::BUNDLED_CHARTS[$chart_code];
		$chart->country = $country;
		$chart->code = $code;
		$chart->save();
		$chart->accounts()->importCSV($file);
		return $chart;
	}

	static public function updateInstalled(string $chart_code): ?Chart
	{
		$file = sprintf('%s/include/data/charts/%s.csv', ROOT, $chart_code);
		$country = strtoupper(substr($chart_code, 0, 2));
		$code = strtoupper(substr($chart_code, 3));

		$chart = EntityManager::findOne(Chart::class, 'SELECT * FROM @TABLE WHERE code = ? AND country = ?;', $code, $country);

		if (!$chart) {
			return self::install($chart_code);
		}

		$chart->accounts()->importCSV($file, true);
		return $chart;
	}

	static public function listInstallable(): array
	{
		$installed = DB::getInstance()->getAssoc('SELECT id, LOWER(country || \'_\' || code) FROM acc_charts;');
		$out = [];

		foreach (self::BUNDLED_CHARTS as $code => $label) {

Modified src/include/lib/Garradin/Accounting/Graph.php from [3599db72d6] to [f3f094025c].

1
2
3
4
5
6
7
8
9
10


11
12
13

14
15
16
17
18
19
20
<?php

namespace Garradin\Accounting;

use Garradin\Entities\Accounting\Account;
use Garradin\Entities\Accounting\Line;
use Garradin\Entities\Accounting\Transaction;
use Garradin\Utils;
use Garradin\Config;
use Garradin\DB;


use const Garradin\ADMIN_COLOR1;
use const Garradin\ADMIN_COLOR2;
use const Garradin\ADMIN_URL;

use KD2\DB\EntityManager;

use KD2\Graphics\SVG\Plot;
use KD2\Graphics\SVG\Plot_Data;

use KD2\Graphics\SVG\Pie;
use KD2\Graphics\SVG\Pie_Data;










>
>



>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace Garradin\Accounting;

use Garradin\Entities\Accounting\Account;
use Garradin\Entities\Accounting\Line;
use Garradin\Entities\Accounting\Transaction;
use Garradin\Utils;
use Garradin\Config;
use Garradin\DB;
use Garradin\UserTemplate\CommonModifiers;

use const Garradin\ADMIN_COLOR1;
use const Garradin\ADMIN_COLOR2;
use const Garradin\ADMIN_URL;

use KD2\DB\EntityManager;

use KD2\Graphics\SVG\Plot;
use KD2\Graphics\SVG\Plot_Data;

use KD2\Graphics\SVG\Pie;
use KD2\Graphics\SVG\Pie_Data;
135
136
137
138
139
140
141


142
143
144
145
146
147
148
149
150
151
152
153
154
155


156
157
158
159
160
161
162
163


164
165
166
167
168
169
170
		$others = 0;
		$colors = self::getColors();
		$max = count($colors);
		$total = 0;
		$count = 0;
		$i = 0;



		foreach ($data as $row) {
			$total += $row->balance;
		}

		foreach ($data as $row)
		{
			if ($i++ >= $max || $count > $total*0.95)
			{
				$others += $row->balance;
			}
			else
			{
				$label = strlen($row->label) > 40 ? substr($row->label, 0, 38) . '…' : $row->label;
				$pie->add(new Pie_Data(abs($row->balance) / 100, $label, $colors[$i-1]));


			}

			$count += $row->balance;
		}

		if ($others != 0)
		{
			$pie->add(new Pie_Data(abs($others) / 100, 'Autres', '#ccc'));


		}

		$pie->togglePercentage(true);

		$out = $pie->output();

		return $out;







>
>












|
|
>
>







|
>
>







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
		$others = 0;
		$colors = self::getColors();
		$max = count($colors);
		$total = 0;
		$count = 0;
		$i = 0;

		$currency = Config::getInstance()->monnaie;

		foreach ($data as $row) {
			$total += $row->balance;
		}

		foreach ($data as $row)
		{
			if ($i++ >= $max || $count > $total*0.95)
			{
				$others += $row->balance;
			}
			else
			{
				$label = strlen($row->label) > 40 ? trim(substr($row->label, 0, 38)) . '…' : $row->label;
				$data = new Pie_Data(abs($row->balance) / 100, $label, $colors[$i-1]);
				$data->sublabel = Utils::money_format(intval($row->balance / 100) * 100, null, ' ', true) . ' ' . $currency;
				$pie->add($data);
			}

			$count += $row->balance;
		}

		if ($others != 0)
		{
			$data = new Pie_Data(abs($others) / 100, 'Autres', '#ccc');
			$data->sublabel = Utils::money_format(intval($others / 100) * 100, null, ' ', true) . ' ' . $currency;
			$pie->add($data);
		}

		$pie->togglePercentage(true);

		$out = $pie->output();

		return $out;

Modified src/include/lib/Garradin/Accounting/Import.php from [119c7ad9c6] to [f47afbfa9c].

1
2
3
4
5
6
7
8
9
10
11
12
13


































14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


32
33
34
35
36
37
38
<?php

namespace Garradin\Accounting;

use Garradin\Entities\Accounting\Line;
use Garradin\Entities\Accounting\Transaction;
use Garradin\Entities\Accounting\Year;
use Garradin\CSV_Custom;
use Garradin\DB;
use Garradin\UserException;

class Import
{


































	/**
	 * Imports a CSV file of transactions in a year
	 * @param  string     $type    Type of CSV format
	 * @param  Year       $year    Target year where transactions should be updated or created
	 * @param  CSV_Custom $csv     CSV object
	 * @param  int        $user_id Current user ID, the one running the import
	 * @param  array      $options array of options
	 * @return ?array
	 */
	static public function import(string $type, Year $year, CSV_Custom $csv, int $user_id, array $options = []): ?array
	{
		$options_default = [
			'ignore_ids'      => false,
			'dry_run'         => false,
			'return_report'   => false,
		];

		$o = (object) array_merge($options_default, $options);



		if ($type != Export::GROUPED && $type != Export::SIMPLE && $type != Export::FEC) {
			throw new \InvalidArgumentException('Invalid type value');
		}

		if ($year->closed) {
			throw new \InvalidArgumentException('Closed year');













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


















>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php

namespace Garradin\Accounting;

use Garradin\Entities\Accounting\Line;
use Garradin\Entities\Accounting\Transaction;
use Garradin\Entities\Accounting\Year;
use Garradin\CSV_Custom;
use Garradin\DB;
use Garradin\UserException;

class Import
{
	static protected function saveImportedTransaction(Transaction $transaction, bool $dry_run = false, array &$report = null): void
	{
		if ($transaction->countLines() > 2) {
			$transaction->type = Transaction::TYPE_ADVANCED;
		}
		// Try to magically find out what kind of transaction this is
		elseif (!isset($transaction->type)) {
			$transaction->type = $transaction->findTypeFromAccounts();
		}

		if (!$dry_run) {
			if ($transaction->isModified()) {
				$transaction->save();
			}
		}
		else {
			$transaction->selfCheck();
		}

		if (null !== $report) {
			if (!$transaction->isModified()) {
				$target = 'unchanged';
			}
			elseif ($transaction->exists()) {
				$target = 'modified';
			}
			else {
				$target = 'created';
			}

			$report[$target][] = $transaction->asJournalArray();
		}
	}

	/**
	 * Imports a CSV file of transactions in a year
	 * @param  string     $type    Type of CSV format
	 * @param  Year       $year    Target year where transactions should be updated or created
	 * @param  CSV_Custom $csv     CSV object
	 * @param  int        $user_id Current user ID, the one running the import
	 * @param  array      $options array of options
	 * @return ?array
	 */
	static public function import(string $type, Year $year, CSV_Custom $csv, int $user_id, array $options = []): ?array
	{
		$options_default = [
			'ignore_ids'      => false,
			'dry_run'         => false,
			'return_report'   => false,
		];

		$o = (object) array_merge($options_default, $options);

		$dry_run = $o->dry_run;

		if ($type != Export::GROUPED && $type != Export::SIMPLE && $type != Export::FEC) {
			throw new \InvalidArgumentException('Invalid type value');
		}

		if ($year->closed) {
			throw new \InvalidArgumentException('Closed year');
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
		if ($o->return_report) {
			$report = ['created' => [], 'modified' => [], 'unchanged' => []];
		}
		else {
			$report = null;
		}

		$save_transaction = function (Transaction &$transaction) use ($o, &$report) {
			if (!is_null($report)) {
				if (!$transaction->isModified()) {
					$target = 'unchanged';
				}
				elseif ($transaction->exists()) {
					$target = 'modified';
				}
				else {
					$target = 'created';
				}

				$report[$target][] = $transaction->asJournalArray();
			}

			if ($transaction->countLines() > 2) {
				$transaction->type = Transaction::TYPE_ADVANCED;
			}

			if (!$o->dry_run) {
				if ($transaction->isModified()) {
					$transaction->save();
				}
			}
			else {
				$transaction->selfcheck();
			}

			$transaction = null;
		};

		$l = 1;

		try {
			$current_id = null;

			foreach ($csv->iterate() as $l => $row) {
				$row = (object) $row;







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







84
85
86
87
88
89
90































91
92
93
94
95
96
97
		if ($o->return_report) {
			$report = ['created' => [], 'modified' => [], 'unchanged' => []];
		}
		else {
			$report = null;
		}
































		$l = 1;

		try {
			$current_id = null;

			foreach ($csv->iterate() as $l => $row) {
				$row = (object) $row;
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
						&& empty($row->date)
						&& empty($row->notes)
						&& empty($row->reference)
					);

					// New transaction, save previous one
					if (null !== $transaction && $has_transaction) {

						$save_transaction($transaction);
					}

					if (!$has_transaction && null === $transaction) {
						throw new UserException('cette ligne n\'est reliée à aucune écriture');
					}
				}
				else {
					if (!empty($row->id) && $row->id != $current_id) {
						if (null !== $transaction) {

							$save_transaction($transaction);
						}

						$current_id = (int) $row->id;
					}

					if (empty($row->type)) {
						$row->type = Transaction::TYPES_NAMES[Transaction::TYPE_ADVANCED];
					}
				}

				// Find or create transaction
				if (null === $transaction) {
					if (!empty($row->id) && !$o->ignore_ids) {
						$transaction = Transactions::get((int)$row->id);








>
|









>
|




<
<
<
<







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129




130
131
132
133
134
135
136
						&& empty($row->date)
						&& empty($row->notes)
						&& empty($row->reference)
					);

					// New transaction, save previous one
					if (null !== $transaction && $has_transaction) {
						self::saveImportedTransaction($transaction, $dry_run, $report);
						$transaction = null;
					}

					if (!$has_transaction && null === $transaction) {
						throw new UserException('cette ligne n\'est reliée à aucune écriture');
					}
				}
				else {
					if (!empty($row->id) && $row->id != $current_id) {
						if (null !== $transaction) {
							self::saveImportedTransaction($transaction, $dry_run, $report);
							$transaction = null;
						}

						$current_id = (int) $row->id;
					}




				}

				// Find or create transaction
				if (null === $transaction) {
					if (!empty($row->id) && !$o->ignore_ids) {
						$transaction = Transactions::get((int)$row->id);

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
					}
					else {
						$transaction = new Transaction;
						$transaction->id_creator = $user_id;
						$transaction->id_year = $year->id();
					}

					if (!isset($types[$row->type])) {
						throw new UserException(sprintf('le type "%s" est inconnu', $row->type));
					}

					// FEC does not define type, so don't change it
					if (isset($row->type)) {
						$transaction->type = $types[$row->type];
					}







|







150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
					}
					else {
						$transaction = new Transaction;
						$transaction->id_creator = $user_id;
						$transaction->id_year = $year->id();
					}

					if (isset($row->type) && !isset($types[$row->type])) {
						throw new UserException(sprintf('le type "%s" est inconnu', $row->type));
					}

					// FEC does not define type, so don't change it
					if (isset($row->type)) {
						$transaction->type = $types[$row->type];
					}
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
						'debit'      => $row->amount,
						'id_account' => $debit_account,
					]);

					$transaction->addLine($l1);
					$transaction->addLine($l2);

					$save_transaction($transaction);
					$transaction = null;
				}
				else {
					$id_account = $accounts->getIdFromCode($row->account);

					if (!$id_account) {
						throw new UserException(sprintf('le compte "%s" n\'existe pas dans le plan comptable', $row->account));







|







226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
						'debit'      => $row->amount,
						'id_account' => $debit_account,
					]);

					$transaction->addLine($l1);
					$transaction->addLine($l2);

					self::saveImportedTransaction($transaction, $dry_run, $report);
					$transaction = null;
				}
				else {
					$id_account = $accounts->getIdFromCode($row->account);

					if (!$id_account) {
						throw new UserException(sprintf('le compte "%s" n\'existe pas dans le plan comptable', $row->account));
249
250
251
252
253
254
255

256
257
258
259
260
261
262
263
					$line = new Line;
					$line->importForm($data);
					$transaction->addLine($line);
				}
			}

			if (null !== $transaction) {

				$save_transaction($transaction);
			}
		}
		catch (UserException $e) {
			$db->rollback();
			$e->setMessage(sprintf('Erreur sur la ligne %d : %s', $l - 1, $e->getMessage()));

			if (null !== $transaction) {







>
|







252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
					$line = new Line;
					$line->importForm($data);
					$transaction->addLine($line);
				}
			}

			if (null !== $transaction) {
				self::saveImportedTransaction($transaction, $dry_run, $report);
				$transaction = null;
			}
		}
		catch (UserException $e) {
			$db->rollback();
			$e->setMessage(sprintf('Erreur sur la ligne %d : %s', $l - 1, $e->getMessage()));

			if (null !== $transaction) {

Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [4472bc20a3] to [4c16025e4d].

106
107
108
109
110
111
112



















113
114
115
116
117
118
119
			case Account::TYPE_CASH:
			case Account::TYPE_OUTSTANDING:
				return self::TYPE_TRANSFER;
			default:
				return self::TYPE_ADVANCED;
		}
	}




















	public function getLinesWithAccounts(): array
	{
		$db = EntityManager::getInstance(Line::class)->DB();

		// Merge data from accounts with lines
		$accounts = [];







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
			case Account::TYPE_CASH:
			case Account::TYPE_OUTSTANDING:
				return self::TYPE_TRANSFER;
			default:
				return self::TYPE_ADVANCED;
		}
	}

	public function findTypeFromAccounts(): int
	{
		if (count($this->getLines()) != 2) {
			return self::TYPE_ADVANCED;
		}

		foreach ($this->getLinesWithAccounts() as $line) {
			if ($line->account_position == Account::REVENUE && $line->credit) {
				return self::TYPE_REVENUE;
			}
			elseif ($line->account_position == Account::EXPENSE && $line->debit) {
				return self::TYPE_EXPENSE;
			}
		}

		// Did not find a expense/revenue account: fall back to advanced
		return self::TYPE_ADVANCED;
	}

	public function getLinesWithAccounts(): array
	{
		$db = EntityManager::getInstance(Line::class)->DB();

		// Merge data from accounts with lines
		$accounts = [];
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872

	public function updateLinkedUsers(array $users)
	{
		$db = EntityManager::getInstance(self::class)->DB();

		$db->begin();

		$sql = sprintf('DELETE FROM acc_transactions_users WHERE id_transaction = ? AND %s;', $db->where('id_user', 'NOT IN', $users));
		$db->preparedQuery($sql, $this->id());

		foreach ($users as $id) {
			$db->preparedQuery('INSERT OR IGNORE INTO acc_transactions_users (id_transaction, id_user) VALUES (?, ?);', $this->id(), $id);
		}

		$db->commit();







|







877
878
879
880
881
882
883
884
885
886
887
888
889
890
891

	public function updateLinkedUsers(array $users)
	{
		$db = EntityManager::getInstance(self::class)->DB();

		$db->begin();

		$sql = sprintf('DELETE FROM acc_transactions_users WHERE id_transaction = ? AND %s AND id_service_user IS NULL;', $db->where('id_user', 'NOT IN', $users));
		$db->preparedQuery($sql, $this->id());

		foreach ($users as $id) {
			$db->preparedQuery('INSERT OR IGNORE INTO acc_transactions_users (id_transaction, id_user) VALUES (?, ?);', $this->id(), $id);
		}

		$db->commit();
883
884
885
886
887
888
889
890
891
892






893
894
895
896
897
898
899
	public function listLinkedUsersAssoc()
	{
		$db = EntityManager::getInstance(self::class)->DB();
		$identity_column = DynamicFields::getNameFieldsSQL('u');
		$sql = sprintf('SELECT u.id, %s AS identity, l.id_service_user
			FROM users u
			INNER JOIN acc_transactions_users l ON l.id_user = u.id
			WHERE l.id_transaction = ?;', $identity_column);
		return $db->getAssoc($sql, $this->id());
	}







	public function listRelatedTransactions()
	{
		return EntityManager::getInstance(self::class)->all('SELECT * FROM @TABLE WHERE id_related = ?;', $this->id);
	}

	/**







|


>
>
>
>
>
>







902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
	public function listLinkedUsersAssoc()
	{
		$db = EntityManager::getInstance(self::class)->DB();
		$identity_column = DynamicFields::getNameFieldsSQL('u');
		$sql = sprintf('SELECT u.id, %s AS identity, l.id_service_user
			FROM users u
			INNER JOIN acc_transactions_users l ON l.id_user = u.id
			WHERE l.id_transaction = ? AND l.id_service_user IS NULL;', $identity_column);
		return $db->getAssoc($sql, $this->id());
	}

	public function unlinkServiceUser(int $id): void
	{
		$db = EntityManager::getInstance(self::class)->DB();
		$db->delete('acc_transactions_users', 'id_transaction = ? AND id_service_user = ?', $this->id(), $id);
	}

	public function listRelatedTransactions()
	{
		return EntityManager::getInstance(self::class)->all('SELECT * FROM @TABLE WHERE id_related = ?;', $this->id);
	}

	/**

Modified src/include/lib/Garradin/Entities/Files/File.php from [df6ccfaebe] to [5229aa4637].

1
2
3
4
5
6
7

8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

namespace Garradin\Entities\Files;

use KD2\Graphics\Image;
use KD2\Graphics\Blob;
use KD2\DB\EntityManager as EM;


use Garradin\Config;
use Garradin\DB;
use Garradin\Entity;
use Garradin\Plugin;

use Garradin\UserException;
use Garradin\ValidationException;
use Garradin\Users\Session;
use Garradin\Static_Cache;
use Garradin\Utils;
use Garradin\Entities\Web\Page;
use Garradin\Web\Render\Render;

use Garradin\Files\Files;

use const Garradin\{WWW_URL, BASE_URL, ENABLE_XSENDFILE};

/**
 * This is a virtual entity, it cannot be saved to a SQL table
 */
class File extends Entity
{
	const TABLE = 'files';







>





>










|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

namespace Garradin\Entities\Files;

use KD2\Graphics\Image;
use KD2\Graphics\Blob;
use KD2\DB\EntityManager as EM;
use KD2\Security;

use Garradin\Config;
use Garradin\DB;
use Garradin\Entity;
use Garradin\Plugin;
use Garradin\Template;
use Garradin\UserException;
use Garradin\ValidationException;
use Garradin\Users\Session;
use Garradin\Static_Cache;
use Garradin\Utils;
use Garradin\Entities\Web\Page;
use Garradin\Web\Render\Render;

use Garradin\Files\Files;

use const Garradin\{WWW_URL, BASE_URL, ENABLE_XSENDFILE, SECRET_KEY};

/**
 * This is a virtual entity, it cannot be saved to a SQL table
 */
class File extends Entity
{
	const TABLE = 'files';
415
416
417
418
419
420
421














422
423
424
425
426
427
428
	}

	public function removeFromSearch(): void
	{
		$db = DB::getInstance();
		$db->preparedQuery('DELETE FROM files_search WHERE path = ?;', $this->path);
	}















	/**
	 * Full URL with https://...
	 */
	public function url(bool $download = false): string
	{
		$base = in_array($this->context(), [self::CONTEXT_WEB, self::CONTEXT_SKELETON, self::CONTEXT_CONFIG]) ? WWW_URL : BASE_URL;







>
>
>
>
>
>
>
>
>
>
>
>
>
>







417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
	}

	public function removeFromSearch(): void
	{
		$db = DB::getInstance();
		$db->preparedQuery('DELETE FROM files_search WHERE path = ?;', $this->path);
	}

	/**
	 * Returns true if this is a vector or bitmap image
	 * as 'image' property is only for bitmaps
	 * @return boolean
	 */
	public function isImage(): bool
	{
		if ($this->image || $this->mime == 'image/svg+xml') {
			return true;
		}

		return false;
	}

	/**
	 * Full URL with https://...
	 */
	public function url(bool $download = false): string
	{
		$base = in_array($this->context(), [self::CONTEXT_WEB, self::CONTEXT_SKELETON, self::CONTEXT_CONFIG]) ? WWW_URL : BASE_URL;
436
437
438
439
440
441
442



443
444

445
446
447
448

449
450
451
452




453
454
455
456
457
458
459
460
461
462
463
464
465
466















467
468
469
470
471
472
473
	}

	/**
	 * Returns local URI, eg. user/1245/file.jpg
	 */
	public function uri(): string
	{



		if ($this->context() == self::CONTEXT_WEB) {
			return Utils::basename(Utils::dirname($this->path)) . '/' . Utils::basename($this->path);

		}
		else {
			return $this->path;
		}

	}

	public function thumb_url($size = null): string
	{




		if (is_int($size)) {
			$size .= 'px';
		}

		$size = isset(self::ALLOWED_THUMB_SIZES[$size]) ? $size : key(self::ALLOWED_THUMB_SIZES);
		return sprintf('%s?%dpx', $this->url(), $size);
	}

	/**
	 * Envoie le fichier au client HTTP
	 */
	public function serve(?Session $session = null, bool $download = false): void
	{
		if (!$this->checkReadAccess($session)) {















			header('HTTP/1.1 403 Forbidden', true, 403);
			throw new UserException('Vous n\'avez pas accès à ce fichier.');
			return;
		}

		// Only simple files can be served, not directories
		if ($this->type != self::TYPE_FILE) {







>
>
>

<
>

<
<
|
>




>
>
>
>











|

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







452
453
454
455
456
457
458
459
460
461
462

463
464


465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
	}

	/**
	 * Returns local URI, eg. user/1245/file.jpg
	 */
	public function uri(): string
	{
		$parts = explode('/', $this->path);
		$parts = array_map('rawurlencode', $parts);

		if ($this->context() == self::CONTEXT_WEB) {

			$parts = array_slice($parts, -2);
		}



		return implode('/', $parts);
	}

	public function thumb_url($size = null): string
	{
		if (!$this->image) {
			return $this->url();
		}

		if (is_int($size)) {
			$size .= 'px';
		}

		$size = isset(self::ALLOWED_THUMB_SIZES[$size]) ? $size : key(self::ALLOWED_THUMB_SIZES);
		return sprintf('%s?%dpx', $this->url(), $size);
	}

	/**
	 * Envoie le fichier au client HTTP
	 */
	public function serve(?Session $session = null, bool $download = false, ?string $share_hash = null, ?string $share_password = null): void
	{
		$can_access = $this->checkReadAccess($session);

		if (!$can_access && $share_hash) {
			$can_access = $this->checkShareLink($share_hash, $share_password);

			if (!$can_access && $this->checkShareLinkRequiresPassword($share_hash)) {
				$tpl = Template::getInstance();
				$has_password = (bool) $share_password;

				$tpl->assign(compact('can_access', 'has_password'));
				$tpl->display('ask_share_password.tpl');
				exit;
			}
		}

		if (!$can_access) {
			header('HTTP/1.1 403 Forbidden', true, 403);
			throw new UserException('Vous n\'avez pas accès à ce fichier.');
			return;
		}

		// Only simple files can be served, not directories
		if ($this->type != self::TYPE_FILE) {
881
882
883
884
885
886
887
888





















































		return null;
	}

	public function export(): array
	{
		return $this->asArray(true) + ['url' => $this->url()];
	}
}




























































|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
		return null;
	}

	public function export(): array
	{
		return $this->asArray(true) + ['url' => $this->url()];
	}

	/**
	 * Returns a sharing link for a file, valid
	 * @param  int $expiry Expiry, in hours
	 * @param  string|null $password
	 * @return string
	 */
	public function createShareLink(int $expiry = 24, ?string $password = null): string
	{
		$expiry = intval(time() / 3600) + $expiry;

		$hash = $this->_createShareHash($expiry, $password);

		$expiry -= intval(gmmktime(0, 0, 0, 8, 1, 2022) / 3600);
		$expiry = base_convert($expiry, 10, 36);

		return sprintf('%s?s=%s%s:%s', $this->url(), $password ? ':' : '', $hash, $expiry);
	}

	protected function _createShareHash(int $expiry, ?string $password): string
	{
		$password = trim((string)$password) ?: null;

		$str = sprintf('%s:%s:%s:%s', SECRET_KEY, $this->path, $expiry, $password);

		$hash = hash('sha256', $str, true);
		$hash = substr($hash, 0, 10);
		$hash = Security::base64_encode_url_safe($hash);
		return $hash;
	}

	public function checkShareLinkRequiresPassword(string $str): bool
	{
		return substr($str, 0, 1) == ':';
	}

	public function checkShareLink(string $str, ?string $password): bool
	{
		$str = ltrim($str, ':');

		$hash = strtok($str, ':');
		$expiry = strtok(false);
		$expiry = (int)base_convert($expiry, 36, 10);
		$expiry += intval(gmmktime(0, 0, 0, 8, 1, 2022) / 3600);

		if ($expiry < time()/3600) {
			return false;
		}

		$hash_check = $this->_createShareHash($expiry, $password);

		return hash_equals($hash, $hash_check);
	}
}

Modified src/include/lib/Garradin/Entities/Services/Service_User.php from [cb142619a1] to [a64392310f].

8
9
10
11
12
13
14


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51






52
53
54
55
56
57
58
use Garradin\ValidationException;
use Garradin\Services\Fees;
use Garradin\Services\Services;
use Garradin\Users\Users;
use Garradin\Accounting\Transactions;
use Garradin\Entities\Accounting\Transaction;
use Garradin\Entities\Accounting\Line;



class Service_User extends Entity
{
	const TABLE = 'services_users';

	protected $id;
	protected $id_user;
	protected $id_service;
	/**
	 * This can be NULL if there is no fee for the service
	 * @var null|int
	 */
	protected $id_fee;
	protected $paid;
	protected $expected_amount;
	protected $date;
	protected $expiry_date;

	protected $_types = [
		'id'          => 'int',
		'id_user'     => 'int',
		'id_service'  => 'int',
		'id_fee'      => '?int',
		'paid'        => 'bool',
		'expected_amount' => '?int',
		'date'        => 'date',
		'expiry_date' => '?date',
	];

	protected $_service, $_fee;

	public function selfCheck(): void
	{
		$this->paid = (bool) $this->paid;
		$this->assert($this->id_service, 'Aucune activité spécifiée');
		$this->assert($this->id_user, 'Aucun membre spécifié');
		$this->assert(!$this->isDuplicate(), 'Cette activité a déjà été enregistrée pour ce membre et cette date');






	}

	public function isDuplicate(bool $using_date = true): bool
	{
		$params = [
			'id_user' => $this->id_user,
			'id_service' => $this->id_service,







>
>





|
|
|




|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<





<



>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33











34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use Garradin\ValidationException;
use Garradin\Services\Fees;
use Garradin\Services\Services;
use Garradin\Users\Users;
use Garradin\Accounting\Transactions;
use Garradin\Entities\Accounting\Transaction;
use Garradin\Entities\Accounting\Line;

use KD2\DB\Date;

class Service_User extends Entity
{
	const TABLE = 'services_users';

	protected ?int $id;
	protected int $id_user;
	protected int $id_service;
	/**
	 * This can be NULL if there is no fee for the service
	 * @var null|int
	 */
	protected ?int $id_fee = null;
	protected bool $paid;
	protected ?int $expected_amount = null;
	protected Date $date;
	protected ?Date $expiry_date = null;












	protected $_service, $_fee;

	public function selfCheck(): void
	{

		$this->assert($this->id_service, 'Aucune activité spécifiée');
		$this->assert($this->id_user, 'Aucun membre spécifié');
		$this->assert(!$this->isDuplicate(), 'Cette activité a déjà été enregistrée pour ce membre et cette date');

		$db = DB::getInstance();
		// don't allow an id_fee that does not match a service
		if (null !== $this->id_fee && !$db->test(Fee::TABLE, 'id = ? AND id_service = ?', $this->id_fee, $this->id_service)) {
			$this->set('id_fee', null);
		}
	}

	public function isDuplicate(bool $using_date = true): bool
	{
		$params = [
			'id_user' => $this->id_user,
			'id_service' => $this->id_service,
73
74
75
76
77
78
79


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99






100
101
102
103
104
105
106
	}

	public function importForm(?array $source = null)
	{
		if (null === $source) {
			$source = $_POST;
		}



		if (!empty($source['id_service']) && empty($source['expiry_date'])) {
			$service = $this->_service = Services::get((int) $source['id_service']);

			if (!$service) {
				throw new \LogicException('The requested service is not found');
			}

			if ($service->duration) {
				$dt = new \DateTime;
				$dt->modify(sprintf('+%d days', $service->duration));
				$this->set('expiry_date', $dt);
			}
			elseif ($service->end_date) {
				$this->set('expiry_date', $service->end_date);
			}
			else {
				$this->set('expiry_date', null);
			}
		}







		return parent::importForm($source);
	}

	public function service(): Service
	{
		if (null === $this->_service) {







>
>









|










>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
	}

	public function importForm(?array $source = null)
	{
		if (null === $source) {
			$source = $_POST;
		}

		$service = null;

		if (!empty($source['id_service']) && empty($source['expiry_date'])) {
			$service = $this->_service = Services::get((int) $source['id_service']);

			if (!$service) {
				throw new \LogicException('The requested service is not found');
			}

			if ($service->duration) {
				$dt = new Date;
				$dt->modify(sprintf('+%d days', $service->duration));
				$this->set('expiry_date', $dt);
			}
			elseif ($service->end_date) {
				$this->set('expiry_date', $service->end_date);
			}
			else {
				$this->set('expiry_date', null);
			}
		}

		if (!empty($source['id_service'])) {
			if (!$service) {
				$service = $this->_service = Services::get((int) $source['id_service']);
			}
		}

		return parent::importForm($source);
	}

	public function service(): Service
	{
		if (null === $this->_service) {
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214

		if (!count($users)) {
			throw new ValidationException('Aucun membre n\'a été sélectionné.');
		}

		foreach ($users as $id => $name) {
			$su = new self;
			$su->date = new \DateTime;
			$su->importForm($source);
			$su->id_user = (int) $id;

			if ($su->id_fee && $su->fee() && $su->fee()->id_account && $su->id_user) {
				$su->expected_amount = $su->fee()->getAmountForUser($su->id_user);
			}








|







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

		if (!count($users)) {
			throw new ValidationException('Aucun membre n\'a été sélectionné.');
		}

		foreach ($users as $id => $name) {
			$su = new self;
			$su->date = new Date;
			$su->importForm($source);
			$su->id_user = (int) $id;

			if ($su->id_fee && $su->fee() && $su->fee()->id_account && $su->id_user) {
				$su->expected_amount = $su->fee()->getAmountForUser($su->id_user);
			}

Modified src/include/lib/Garradin/Entities/Web/Page.php from [6c2ba925c2] to [287a793773].

384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
		$tagged = [];

		if (!$all) {
			$tagged = $this->listTaggedAttachments($this->content);
		}

		foreach ($this->listAttachments() as $a) {
			if ($images && !$a->image) {
				continue;
			}
			elseif (!$images && $a->image) {
				continue;
			}

			// Skip
			if (!$all && in_array($a->name, $tagged)) {
				continue;
			}







|


|







384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
		$tagged = [];

		if (!$all) {
			$tagged = $this->listTaggedAttachments($this->content);
		}

		foreach ($this->listAttachments() as $a) {
			if ($images && !$a->isImage()) {
				continue;
			}
			elseif (!$images && $a->isImage()) {
				continue;
			}

			// Skip
			if (!$all && in_array($a->name, $tagged)) {
				continue;
			}
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
			if (strpos($link, WWW_URL) === 0) {
				$link = substr($link, strlen(WWW_URL));
			}

			$link = trim($link, '/');

			// Link is not internal
			if (preg_match('!https?:|\w+:|/|#!', $link)) {
				continue;
			}

			if (null !== $pages && !array_key_exists($link, $pages)) {
				$errors[] = $link;
			}
			elseif (null === $pages && !Web::getByURI($link)) {







|







423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
			if (strpos($link, WWW_URL) === 0) {
				$link = substr($link, strlen(WWW_URL));
			}

			$link = trim($link, '/');

			// Link is not internal
			if (!trim($link) || preg_match('!https?:|\w+:|/|#!', $link)) {
				continue;
			}

			if (null !== $pages && !array_key_exists($link, $pages)) {
				$errors[] = $link;
			}
			elseif (null === $pages && !Web::getByURI($link)) {

Modified src/include/lib/Garradin/Entity.php from [4081a66519] to [0c0151fd71].

1
2
3
4
5
6

7
8
9
10
11
12
13
<?php

namespace Garradin;

use Garradin\Form;
use KD2\DB\AbstractEntity;


class Entity extends AbstractEntity
{
	/**
	 * Valider les champs avant enregistrement
	 * @throws ValidationException Si une erreur de validation survient
	 */






>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

namespace Garradin;

use Garradin\Form;
use KD2\DB\AbstractEntity;
use KD2\DB\Date;

class Entity extends AbstractEntity
{
	/**
	 * Valider les champs avant enregistrement
	 * @throws ValidationException Si une erreur de validation survient
	 */
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
	static public function filterUserDateValue(?string $value): ?\DateTime
	{
		if (!trim((string) $value)) {
			return null;
		}

		if (preg_match('!^\d{2}/\d{2}/\d{2}$!', $value)) {
			return \DateTime::createFromFormat('d/m/y', $value);
		}
		elseif (preg_match('!^\d{2}/\d{2}/\d{4}$!', $value)) {
			return \DateTime::createFromFormat('d/m/Y', $value);
		}
		elseif (preg_match('!^\d{4}/\d{2}/\d{2}$!', $value)) {
			return \DateTime::createFromFormat('Y/m/d', $value);
		}
		elseif (preg_match('!^20\d{2}[01]\d[0123]\d$!', $value)) {
			return \DateTime::createFromFormat('Ymd', $value);
		}
		elseif (preg_match('!^\d{4}-\d{2}-\d{2}$!', $value)) {
			return \DateTime::createFromFormat('Y-m-d', $value);
		}
		elseif (null !== $value) {
			throw new ValidationException('Format de date invalide (merci d\'utiliser le format JJ/MM/AAAA) : ' . $value);
		}
	}

	protected function filterUserValue(string $type, $value, string $key)
	{
		if ($type == 'date') {
			return self::filterUserDateValue($value);
		}
		elseif ($type == 'DateTime' && is_string($value)) {
			if (preg_match('!^\d{2}/\d{2}/\d{4}\s\d{1,2}:\d{2}$!', $value)) {
				return \DateTime::createFromFormat('d/m/Y H:i', $value);
			}
		}







|


|


|


|


|








|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	static public function filterUserDateValue(?string $value): ?\DateTime
	{
		if (!trim((string) $value)) {
			return null;
		}

		if (preg_match('!^\d{2}/\d{2}/\d{2}$!', $value)) {
			return Date::createFromFormat('d/m/y', $value);
		}
		elseif (preg_match('!^\d{2}/\d{2}/\d{4}$!', $value)) {
			return Date::createFromFormat('d/m/Y', $value);
		}
		elseif (preg_match('!^\d{4}/\d{2}/\d{2}$!', $value)) {
			return Date::createFromFormat('Y/m/d', $value);
		}
		elseif (preg_match('!^20\d{2}[01]\d[0123]\d$!', $value)) {
			return Date::createFromFormat('Ymd', $value);
		}
		elseif (preg_match('!^\d{4}-\d{2}-\d{2}$!', $value)) {
			return Date::createFromFormat('Y-m-d', $value);
		}
		elseif (null !== $value) {
			throw new ValidationException('Format de date invalide (merci d\'utiliser le format JJ/MM/AAAA) : ' . $value);
		}
	}

	protected function filterUserValue(string $type, $value, string $key)
	{
		if ($type == 'date' || $type == Date::class) {
			return self::filterUserDateValue($value);
		}
		elseif ($type == 'DateTime' && is_string($value)) {
			if (preg_match('!^\d{2}/\d{2}/\d{4}\s\d{1,2}:\d{2}$!', $value)) {
				return \DateTime::createFromFormat('d/m/Y H:i', $value);
			}
		}

Modified src/include/lib/Garradin/Files/Files.php from [c2c1a74a08] to [7673bca1fd].

44
45
46
47
48
49
50


51













52
53
54
55
56
57
58
			snippet(files_search, \'<b>\', \'</b>\', \'…\', 2, -30) AS snippet,
			rank(matchinfo(files_search), 0, 1.0, 1.0) AS points
			FROM files_search
			WHERE files_search MATCH ? %s
			ORDER BY points DESC
			LIMIT 0,50;', $where);



		return DB::getInstance()->get($query, ...$params);













	}

	/**
	 * Returns a list of files and directories inside a parent path
	 * This is not recursive and will only return files and directories
	 * directly in the specified $parent path.
	 */







>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
			snippet(files_search, \'<b>\', \'</b>\', \'…\', 2, -30) AS snippet,
			rank(matchinfo(files_search), 0, 1.0, 1.0) AS points
			FROM files_search
			WHERE files_search MATCH ? %s
			ORDER BY points DESC
			LIMIT 0,50;', $where);

		$out = [];

		$db = DB::getInstance();
		$db->begin();

		foreach ($db->iterate($query, ...$params) as $row) {
			// Remove deleted/moved files
			if (FILE_STORAGE_BACKEND != 'SQLite' && !Files::callStorage('exists', $row->path)) {
				$db->delete('files_search', 'path = ?', $row->path);
				continue;
			}
		}

		$db->commit();

		return $out;
	}

	/**
	 * Returns a list of files and directories inside a parent path
	 * This is not recursive and will only return files and directories
	 * directly in the specified $parent path.
	 */

Modified src/include/lib/Garradin/Services/Services_User.php from [403bcb312a] to [3cadb98b09].

63
64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
			],
			'paid' => [
				'label' => 'Payé',
				'select' => 'su.paid',
			],
			'amount' => [
				'label' => 'Reste à régler',
				'select' => 'expected_amount - SUM(tl.debit)',
			],

		];

		$tables = 'services_users su
			INNER JOIN services s ON s.id = su.id_service
			LEFT JOIN services_fees sf ON sf.id = su.id_fee
			LEFT JOIN acc_transactions_users tu ON tu.id_service_user = su.id
			LEFT JOIN acc_transactions_lines tl ON tl.id_transaction = tu.id_transaction';







|

>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
			],
			'paid' => [
				'label' => 'Payé',
				'select' => 'su.paid',
			],
			'amount' => [
				'label' => 'Reste à régler',
				'select' => 'MAX(0, expected_amount - SUM(tl.debit))',
			],
			'expected_amount' => [],
		];

		$tables = 'services_users su
			INNER JOIN services s ON s.id = su.id_service
			LEFT JOIN services_fees sf ON sf.id = su.id_fee
			LEFT JOIN acc_transactions_users tu ON tu.id_service_user = su.id
			LEFT JOIN acc_transactions_lines tl ON tl.id_transaction = tu.id_transaction';

Modified src/include/lib/Garradin/Template.php from [508b009c04] to [fc6e34a343].

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
			Utils::safe_mkdir($cache_dir, 0777, true);
		}

		$this->setTemplatesDir(ROOT . '/templates');
		$this->setCompiledDir($cache_dir);
		$this->setNamespace('Garradin');

		// Hash de la version pour les éléments statiques (cache)
		// On ne peut pas utiliser la version directement comme query string
		// pour les éléments statiques (genre /admin/static/admin.css?v0.9.0)
		// car cela dévoilerait la version de Garradin utilisée, posant un souci
		// en cas de faille, on cache donc la version utilisée, chaque instance
		// aura sa propre version
		$this->assign('version_hash', substr(sha1(garradin_version() . garradin_manifest() . ROOT . SECRET_KEY), 0, 10));

		$this->assign('www_url', WWW_URL);
		$this->assign('admin_url', ADMIN_URL);
		$this->assign('help_url', sprintf(HELP_URL, str_replace('/admin/', '', Utils::getSelfURI(false))));
		$this->assign('admin_url', ADMIN_URL);
		$this->assign('self_url', Utils::getSelfURI());
		$this->assign('self_url_no_qs', Utils::getSelfURI(false));







<
<
<
<
<
<
|







72
73
74
75
76
77
78






79
80
81
82
83
84
85
86
			Utils::safe_mkdir($cache_dir, 0777, true);
		}

		$this->setTemplatesDir(ROOT . '/templates');
		$this->setCompiledDir($cache_dir);
		$this->setNamespace('Garradin');







		$this->assign('version_hash', Utils::getVersionHash());

		$this->assign('www_url', WWW_URL);
		$this->assign('admin_url', ADMIN_URL);
		$this->assign('help_url', sprintf(HELP_URL, str_replace('/admin/', '', Utils::getSelfURI(false))));
		$this->assign('admin_url', ADMIN_URL);
		$this->assign('self_url', Utils::getSelfURI());
		$this->assign('self_url_no_qs', Utils::getSelfURI(false));

Modified src/include/lib/Garradin/Upgrade.php from [570a800d42] to [3a6c2969e4].

1
2
3
4
5
6


7
8
9
10
11
12
13
<?php

namespace Garradin;

use Garradin\Users\Session;



use Garradin\Files\Files;
use Garradin\Entities\Files\File;

use KD2\HTTP;

use KD2\FossilInstaller;







>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

namespace Garradin;

use Garradin\Users\Session;

use Garradin\Accounting\Charts;

use Garradin\Files\Files;
use Garradin\Entities\Files\File;

use KD2\HTTP;

use KD2\FossilInstaller;

115
116
117
118
119
120
121





122
123
124
125
126
127
128
				$db->import(ROOT . '/include/data/1.1.0_schema.sql');
			}

			if (version_compare($v, '1.1.28', '<')) {
				$db->createFunction('html_decode', 'htmlspecialchars_decode');
				$db->exec('UPDATE files_search SET content = html_decode(content) WHERE content IS NOT NULL;');
			}






			if (version_compare($v, '1.2.0', '<')) {
				$db->beginSchemaUpdate();

				// Get old keys
				$config = (object) $db->getAssoc('SELECT key, value FROM config WHERE key IN (\'champs_membres\', \'champ_identifiant\', \'champ_identite\');');








>
>
>
>
>







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
				$db->import(ROOT . '/include/data/1.1.0_schema.sql');
			}

			if (version_compare($v, '1.1.28', '<')) {
				$db->createFunction('html_decode', 'htmlspecialchars_decode');
				$db->exec('UPDATE files_search SET content = html_decode(content) WHERE content IS NOT NULL;');
			}

			if (version_compare($v, '1.1.29', '<')) {
				Charts::updateInstalled('fr_pca_2018');
				$db->import(ROOT . '/include/data/1.1.29_migration.sql');
			}

			if (version_compare($v, '1.2.0', '<')) {
				$db->beginSchemaUpdate();

				// Get old keys
				$config = (object) $db->getAssoc('SELECT key, value FROM config WHERE key IN (\'champs_membres\', \'champ_identifiant\', \'champ_identite\');');

Modified src/include/lib/Garradin/UserTemplate/Sections.php from [61b5494afd] to [1a012140ca].

400
401
402
403
404
405
406










407
408
409
410
411
412
413
				$page = new Page;
				$page->exists(true);
				$page->load($data);

				if (!$page->file()) {
					continue;
				}











				$row = array_merge($row, $page->asTemplateArray());
			}

			yield $row;
		}
	}







>
>
>
>
>
>
>
>
>
>







400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
				$page = new Page;
				$page->exists(true);
				$page->load($data);

				if (!$page->file()) {
					continue;
				}

				if (isset($row['snippet'])) {
					$row['snippet'] = preg_replace('!</b>(\s*)<b>!', '$1', $row['snippet']);
					if (preg_match('!<b>(.*?)</b>!', $row['snippet'], $match)) {
						$row['url_highlight'] = $page->url() . '#:~:text=' . rawurlencode($match[1]);
					}
					else {
						$row['url_highlight'] = $page->url();
					}
				}

				$row = array_merge($row, $page->asTemplateArray());
			}

			yield $row;
		}
	}
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465









466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498

499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
			if (!$page) {
				return null;
			}

			// Store attachments in temp table
			$db = DB::getInstance();
			$db->begin();
			$db->exec('CREATE TEMP TABLE IF NOT EXISTS web_pages_attachments (page_id, uri, path, name, modified, image);');
			$page_file_name = Utils::basename($page->file_path);

			foreach ($page->listAttachments() as $file) {
				if ($file->name == $page_file_name || $file->type != File::TYPE_FILE) {
					continue;
				}










				$db->preparedQuery('INSERT OR REPLACE INTO web_pages_attachments VALUES (?, ?, ?, ?, ?, ?);',
					$page->id(), $file->uri(), $file->path, $file->name, $file->modified, $file->image);
			}

			$db->commit();

			return $page;
		});

		if (!$page) {
			return;
		}

		$params['select'] = 'path';
		$params['tables'] = 'web_pages_attachments';
		$params['where'] .= ' AND page_id = :page';
		$params[':page'] = $page->id();
		unset($params['parent']);

		// Generate a temporary table containing the list of files included in the text
		if (!empty($params['except_in_text'])) {
			// Don't regenerate that table for each section called in the page,
			// we assume the content and list of files will not change between sections
			self::cache('page_files_text_' . $parent, function () use ($page) {
				$db = DB::getInstance();
				$db->begin();

				// Put files mentioned in the text in a temporary table
				$db->exec('CREATE TEMP TABLE IF NOT EXISTS files_tmp_in_text (page_id, uri);');

				foreach ($page->listTaggedAttachments() as $uri) {
					$db->insert('files_tmp_in_text', ['page_id' => $page->id(), 'uri' => $uri]);
				}


				$db->commit();
			});

			$params['where'] .= sprintf(' AND uri NOT IN (SELECT uri FROM files_tmp_in_text WHERE page_id = %d)', $page->id());
		}

		if (empty($params['order'])) {
			$params['order'] = 'name';
		}

		if ($params['order'] == 'name') {
			$params['order'] .= ' COLLATE U_NOCASE';
		}

		foreach (self::sql($params, $tpl, $line) as $row) {
			$file = Files::get($row['path']);

			if (null === $file) {
				continue;
			}

			$row = $file->asArray();
			$row['url'] = $file->url();
			$row['download_url'] = $file->url(true);
			$row['thumb_url'] = $file->thumb_url();
			$row['small_url'] = $file->thumb_url(File::THUMB_SIZE_SMALL);
			yield $row;
		}
	}

	static public function sql(array $params, UserTemplate $tpl, int $line): \Generator
	{
		static $defaults = [
			'select' => '*',







|
<


|



>
>
>
>
>
>
>
>
>
|
|











|



















>
















<
<
<
<
<
<
<
<
<
<
<
|







461
462
463
464
465
466
467
468

469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533











534
535
536
537
538
539
540
541
			if (!$page) {
				return null;
			}

			// Store attachments in temp table
			$db = DB::getInstance();
			$db->begin();
			$db->exec('CREATE TEMP TABLE IF NOT EXISTS web_pages_attachments (page_id, uri, path, name, modified, image, data);');


			foreach ($page->listAttachments() as $file) {
				if ($file->type != File::TYPE_FILE) {
					continue;
				}

				$row = $file->asArray();
				$row['title'] = str_replace(['_', '-'], ' ', $file->name);
				$row['title'] = preg_replace('!\.[^\.]{3,5}$!', '', $row['title']);
				$row['extension'] = strtoupper(preg_replace('!^.*\.([^\.]{3,5})$!', '$1', $file->name));
				$row['url'] = $file->url();
				$row['download_url'] = $file->url(true);
				$row['thumb_url'] = $file->thumb_url();
				$row['small_url'] = $file->thumb_url(File::THUMB_SIZE_SMALL);

				$db->preparedQuery('INSERT OR REPLACE INTO web_pages_attachments VALUES (?, ?, ?, ?, ?, ?, ?);',
					$page->id(), rawurldecode($file->uri()), $file->path, $file->name, $file->modified, $file->isImage(), json_encode($row));
			}

			$db->commit();

			return $page;
		});

		if (!$page) {
			return;
		}

		$params['select'] = 'data';
		$params['tables'] = 'web_pages_attachments';
		$params['where'] .= ' AND page_id = :page';
		$params[':page'] = $page->id();
		unset($params['parent']);

		// Generate a temporary table containing the list of files included in the text
		if (!empty($params['except_in_text'])) {
			// Don't regenerate that table for each section called in the page,
			// we assume the content and list of files will not change between sections
			self::cache('page_files_text_' . $parent, function () use ($page) {
				$db = DB::getInstance();
				$db->begin();

				// Put files mentioned in the text in a temporary table
				$db->exec('CREATE TEMP TABLE IF NOT EXISTS files_tmp_in_text (page_id, uri);');

				foreach ($page->listTaggedAttachments() as $uri) {
					$db->insert('files_tmp_in_text', ['page_id' => $page->id(), 'uri' => $uri]);
				}


				$db->commit();
			});

			$params['where'] .= sprintf(' AND uri NOT IN (SELECT uri FROM files_tmp_in_text WHERE page_id = %d)', $page->id());
		}

		if (empty($params['order'])) {
			$params['order'] = 'name';
		}

		if ($params['order'] == 'name') {
			$params['order'] .= ' COLLATE U_NOCASE';
		}

		foreach (self::sql($params, $tpl, $line) as $row) {











			yield json_decode($row['data'], true);
		}
	}

	static public function sql(array $params, UserTemplate $tpl, int $line): \Generator
	{
		static $defaults = [
			'select' => '*',

Modified src/include/lib/Garradin/UserTemplate/UserTemplate.php from [a4444b72e1] to [c811698a60].

61
62
63
64
65
66
67

68
69
70
71
72
73
74
		$config['telephone_asso'] = $config['org_phone'];
		$config['site_asso'] = $config['org_web'];

		$session = Session::getInstance();
		$is_logged = $session->isLogged();

		self::$root_variables = [

			'root_url'     => WWW_URL,
			'request_url'  => Utils::getRequestURI(),
			'admin_url'    => ADMIN_URL,
			'_GET'         => &$_GET,
			'_POST'        => &$_POST,
			'visitor_lang' => Translate::getHttpLang(),
			'config'       => $config,







>







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
		$config['telephone_asso'] = $config['org_phone'];
		$config['site_asso'] = $config['org_web'];

		$session = Session::getInstance();
		$is_logged = $session->isLogged();

		self::$root_variables = [
			'version_hash' => Utils::getVersionHash(),
			'root_url'     => WWW_URL,
			'request_url'  => Utils::getRequestURI(),
			'admin_url'    => ADMIN_URL,
			'_GET'         => &$_GET,
			'_POST'        => &$_POST,
			'visitor_lang' => Translate::getHttpLang(),
			'config'       => $config,

Modified src/include/lib/Garradin/Utils.php from [b486dfc7a7] to [160a0ce20b].

13
14
15
16
17
18
19

20
21
22
23
24
25
26
    static protected $collator;
    static protected $transliterator;

    const ICONS = [
        'up'              => '↑',
        'down'            => '↓',
        'export'          => '↷',

        'reset'           => '↺',
        'upload'          => '⇑',
        'download'        => '⇓',
        'home'            => '⌂',
        'print'           => '⎙',
        'star'            => '★',
        'check'           => '☑',







>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    static protected $collator;
    static protected $transliterator;

    const ICONS = [
        'up'              => '↑',
        'down'            => '↓',
        'export'          => '↷',
        'import'          => '↶',
        'reset'           => '↺',
        'upload'          => '⇑',
        'download'        => '⇓',
        'home'            => '⌂',
        'print'           => '⎙',
        'star'            => '★',
        'check'           => '☑',
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237




238
239
240
241
242
243
244
        }

        $value = $match[1] . $match[2] . str_pad($match[3] ?? '', 2, '0', STR_PAD_RIGHT);
        $value = (int) $value;
        return $value;
    }

    static public function money_format($number, string $dec_point = ',', string $thousands_sep = ' ', $zero_if_empty = true): string {
        if ($number == 0) {
            return $zero_if_empty ? '0' : '0,00';
        }

        $sign = $number < 0 ? '-' : '';
        $number = abs((int) $number);

        $decimals = substr('0' . $number, -2);
        $number = (int) substr($number, 0, -2);





        return sprintf('%s%s%s%s', $sign, number_format($number, 0, $dec_point, $thousands_sep), $dec_point, $decimals);
    }

    static public function getLocalURL(string $url = '', ?string $default_prefix = null): string
    {
        if ($url[0] == '!') {







|









>
>
>
>







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
        }

        $value = $match[1] . $match[2] . str_pad($match[3] ?? '', 2, '0', STR_PAD_RIGHT);
        $value = (int) $value;
        return $value;
    }

    static public function money_format($number, ?string $dec_point = ',', string $thousands_sep = ' ', $zero_if_empty = true): string {
        if ($number == 0) {
            return $zero_if_empty ? '0' : '0,00';
        }

        $sign = $number < 0 ? '-' : '';
        $number = abs((int) $number);

        $decimals = substr('0' . $number, -2);
        $number = (int) substr($number, 0, -2);

        if ($dec_point === null) {
            $decimals = null;
        }

        return sprintf('%s%s%s%s', $sign, number_format($number, 0, $dec_point, $thousands_sep), $dec_point, $decimals);
    }

    static public function getLocalURL(string $url = '', ?string $default_prefix = null): string
    {
        if ($url[0] == '!') {
1103
1104
1105
1106
1107
1108
1109
1110














            // * 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            hexdec(substr($uuid, 16, 4)) & 0x3fff | 0x8000,
            // 48 bits for "node"
            substr($uuid, 20, 12)
        );
    }
}





















|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
            // * 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            hexdec(substr($uuid, 16, 4)) & 0x3fff | 0x8000,
            // 48 bits for "node"
            substr($uuid, 20, 12)
        );
    }

    /**
     * Hash de la version pour les éléments statiques (cache)
     *
     * On ne peut pas utiliser la version directement comme query string
     * pour les éléments statiques (genre /admin/static/admin.css?v0.9.0)
     * car cela dévoilerait la version de Garradin utilisée, posant un souci
     * en cas de faille, on cache donc la version utilisée, chaque instance
     * aura sa propre version
     */
    static public function getVersionHash(): string
    {
        return substr(sha1(garradin_version() . garradin_manifest() . ROOT . SECRET_KEY), 0, 10);
    }
}

Modified src/include/lib/Garradin/Web/Render/Skriv.php from [293b0e6d0d] to [962e942dae].

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113





114
115

116
117
118
119

120
121
122
123
124
125
126
		if (!$name || null === $this->current_path)
		{
			return $skriv->parseError('/!\ Tag file : aucun nom de fichier indiqué.');
		}

		if (empty($caption))
		{
			$caption = $name;
		}

		$url = $this->resolveAttachment($name);
		$ext = substr($name, strrpos($name, '.')+1);

		return sprintf(
			'<aside class="file" data-type="%s"><a href="%s" class="internal-file">%s</a> <small>(%s)</small></aside>',
			htmlspecialchars($ext), htmlspecialchars($url), htmlspecialchars($caption), htmlspecialchars(strtoupper($ext))
		);
	}

	/**
	 * Callback utilisé pour l'extension <<image>> dans le wiki-texte
	 * @param array $args    Arguments passés à l'extension
	 * @param string $content Contenu éventuel (en mode bloc)
	 * @param SkrivLite $skriv   Objet SkrivLite
	 */
	public function SkrivImage(array $args, ?string $content, SkrivLite $skriv): string
	{
		static $align_replace = ['gauche' => 'left', 'droite' => 'right', 'centre' => 'center'];

		$name = $args[0] ?? null;
		$align = $args[1] ?? null;
		$caption = $args[2] ?? null;

		$align = strtr($align, $align_replace);

		if (!$name || null === $this->current_path)
		{
			return $skriv->parseError('/!\ Tag image : aucun nom de fichier indiqué.');
		}

		$url = $this->resolveAttachment($name);





		$thumb_url = sprintf('%s?%s', $url, $align == 'center' ? '500px' : '200px');


		$out = sprintf('<a href="%s" class="internal-image" target="_image"><img src="%s" alt="%s" loading="lazy" /></a>',
			htmlspecialchars($url),
			htmlspecialchars($thumb_url),
			htmlspecialchars($caption ?? $name)

		);

		if (!empty($align))
		{
			if ($caption) {
				$caption = sprintf('<figcaption>%s</figcaption>', htmlspecialchars($caption));
			}







|






|


















|







>
>
>
>
>
|
|
>
|

|
|
>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
		if (!$name || null === $this->current_path)
		{
			return $skriv->parseError('/!\ Tag file : aucun nom de fichier indiqué.');
		}

		if (empty($caption))
		{
			$caption = substr($name, 0, strrpos($name, '.'));
		}

		$url = $this->resolveAttachment($name);
		$ext = substr($name, strrpos($name, '.')+1);

		return sprintf(
			'<aside class="file" data-type="%s"><a href="%s" class="internal-file"><b>%s</b> <small>(%s)</small></a></aside>',
			htmlspecialchars($ext), htmlspecialchars($url), htmlspecialchars($caption), htmlspecialchars(strtoupper($ext))
		);
	}

	/**
	 * Callback utilisé pour l'extension <<image>> dans le wiki-texte
	 * @param array $args    Arguments passés à l'extension
	 * @param string $content Contenu éventuel (en mode bloc)
	 * @param SkrivLite $skriv   Objet SkrivLite
	 */
	public function SkrivImage(array $args, ?string $content, SkrivLite $skriv): string
	{
		static $align_replace = ['gauche' => 'left', 'droite' => 'right', 'centre' => 'center'];

		$name = $args[0] ?? null;
		$align = $args[1] ?? null;
		$caption = $args[2] ?? null;

		$align = strtr((string)$align, $align_replace);

		if (!$name || null === $this->current_path)
		{
			return $skriv->parseError('/!\ Tag image : aucun nom de fichier indiqué.');
		}

		$url = $this->resolveAttachment($name);
		$size = $align == 'center' ? 500 : 200;
		$svg = substr($name, -4) == '.svg';
		$thumb_url = null;

		if (!$svg) {
			$thumb_url = sprintf('%s?%spx', $url, $size);
		}

		$out = sprintf('<a href="%s" class="internal-image" target="_image"><img src="%s" alt="%s" loading="lazy" style="max-width: %dpx; max-height: %4$dpx;" /></a>',
			htmlspecialchars($url),
			htmlspecialchars($thumb_url ?? $url),
			htmlspecialchars($caption ?? ''),
			$size
		);

		if (!empty($align))
		{
			if ($caption) {
				$caption = sprintf('<figcaption>%s</figcaption>', htmlspecialchars($caption));
			}

Modified src/include/lib/Garradin/Web/Router.php from [936960c1cb] to [a90d38093f].

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
				return;
			}

			if ($size) {
				$file->serveThumbnail($session, $size);
			}
			else {
				$file->serve($session, isset($_GET['download']) ? true : false);
			}

			Plugin::fireSignal('http.request.file.after', compact('file', 'uri', 'session'));

			return;
		}








|







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
				return;
			}

			if ($size) {
				$file->serveThumbnail($session, $size);
			}
			else {
				$file->serve($session, isset($_GET['download']), $_GET['s'] ?? null, $_POST['p'] ?? null);
			}

			Plugin::fireSignal('http.request.file.after', compact('file', 'uri', 'session'));

			return;
		}

Modified src/include/test_required.php from [b874a8e54e] to [c40a0ae26a].

68
69
70
71
72
73
74





    $options[] = $row[0];
}

test_requis(
    in_array('ENABLE_FTS4', $options),
    'Le module SQLite3 FTS4 (permettant de faire des recherches) n\'est pas installé ou activé.'
);












>
>
>
>
>
68
69
70
71
72
73
74
75
76
77
78
79
    $options[] = $row[0];
}

test_requis(
    in_array('ENABLE_FTS4', $options),
    'Le module SQLite3 FTS4 (permettant de faire des recherches) n\'est pas installé ou activé.'
);

test_requis(
    class_exists('Phar'),
    'Le module "Phar" n\'est pas disponible, il faut l\'installer.'
);

Modified src/skel-dist/web/_head.html from [7b636d0bec] to [54b71b8794].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html lang="fr">
<head>
	<meta charset="utf-8" />
	<title>{{if $title}}{{$title}} — {{/if}}{{$config.org_name}}</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, target-densitydpi=device-dpi" />
	<style type="text/css">
	:root {
		--first-color: {{if $config.couleur1}}{{$config.couleur1|css_hex_to_rgb}}{{else}}120, 120, 120{{/if}};
		--second-color: {{if $config.couleur2}}{{$config.couleur2|css_hex_to_rgb}}{{else}}30, 30, 30{{/if}};
	}
	</style>
	<link rel="stylesheet" type="text/css" href="{{$root_url}}default.css?2022-07" media="screen,projection,handheld" />
	<link rel="stylesheet" type="text/css" href="{{$root_url}}content.css" media="all" />
	<link rel="alternate" type="application/atom+xml" title="{{$config.org_name}}" href="{{$root_url}}atom.xml" />
	<link rel="icon" type="image/png" href="{{$config.files.favicon}}" />
</head>

<body>

<header class="nav">












|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html lang="fr">
<head>
	<meta charset="utf-8" />
	<title>{{if $title}}{{$title}} — {{/if}}{{$config.org_name}}</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, target-densitydpi=device-dpi" />
	<style type="text/css">
	:root {
		--first-color: {{if $config.couleur1}}{{$config.couleur1|css_hex_to_rgb}}{{else}}120, 120, 120{{/if}};
		--second-color: {{if $config.couleur2}}{{$config.couleur2|css_hex_to_rgb}}{{else}}30, 30, 30{{/if}};
	}
	</style>
	<link rel="stylesheet" type="text/css" href="{{$root_url}}default.css?{{$version_hash}}" media="screen,projection,handheld" />
	<link rel="stylesheet" type="text/css" href="{{$root_url}}content.css?{{$version_hash}}" media="all" />
	<link rel="alternate" type="application/atom+xml" title="{{$config.org_name}}" href="{{$root_url}}atom.xml" />
	<link rel="icon" type="image/png" href="{{$config.files.favicon}}" />
</head>

<body>

<header class="nav">

Modified src/skel-dist/web/content.css from [5332555b7f] to [686e986b7d].

115
116
117
118
119
120
121
122



123
124
125
126
127
128
129
130
131
132
133



134
135
136
137
138
139
140
141





142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
}

.web-content .toc ol li:before {
    content: counters(item, ".") " ";
    counter-increment: item;
    color: #666;
}




.web-content aside.file {
    margin: .3em;
}

.web-content aside.file small {
    opacity: 0.7;
}

.web-content aside.file a {
    display: inline-block;
    margin-right: .5em;



    padding: .3em .5em .3em 1.8em;
    border: 1px solid #999;
    background: #eee;
    border-radius: .5em;
    background-repeat: no-repeat;
    background-position: .5em center;
    background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAQCAYAAADAvYV+AAAAd0lEQVQoz2NgQAVNQDwDCTcw4AF3gPg/Er4xSBWnAXEHFL9HU/wWSS4FpFgZiJ+jKULHT4BYAWa6LhC/w6HwNRBrojvHEoi/oCn8BMQmuDzoBsQ/oQq/A7E9AwEQDMQ/gNiHgUggx0AN8IVI/AGkeA+ReCdJTgAAgMhKhf6mzTIAAAAASUVORK5CYII=");
    transition: background-color .2s, color .2s;





}

.web-content aside.file a:hover {
    background-color: #ccc;
    color: darkred;
}

.web-content figure.image {
    text-align: center;
}

.web-content figure.image figcaption {
    font-style: italic;
    color: #666;
    margin-top: 2pt;
}

.web-content figure.image.img-center {
    max-width: 500px;
    margin: 0 auto 8pt auto;
}

.web-content figure.image.img-left {
    max-width: 200px;
    float: left;
    margin: 0 8pt 4pt 0;
    clear: left;








>
>
>

|








|
>
>
>
|
|
<

<
<
<

>
>
>
>
>



















|







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

142



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
}

.web-content .toc ol li:before {
    content: counters(item, ".") " ";
    counter-increment: item;
    color: #666;
}

aside.file a {
}

.web-content aside.file {
    margin: .8em;
}

.web-content aside.file small {
    opacity: 0.7;
}

.web-content aside.file a {
    display: inline-block;
    background: #ddd no-repeat .5em center;
    background-image: url('data:image/svg+xml;utf8,<svg width="33.87mm" height="33.87mm" version="1.1" viewBox="0 0 33.87 33.87" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-45.16 -132.5)"><path d="m46.87 166.3c-1.895-0.8504-2.04-3.422-1.368-5.124 0.4287-0.9042 1.363-1.675 2.405-1.471h29.27c1.387 0.5818 2.074 2.134 1.853 3.586 0.137 1.429-0.8551 3.219-2.472 3.059-8.696 0.1509-17.4 0.0429-26.09 0.0478-1.196-0.027-2.4 0.0278-3.591-0.0985zm14.74-10.2c-2.695-3.234-5.319-6.532-7.861-9.888-0.6409-1.955 1.712-1.953 2.991-1.809h1.863c5.01e-4 -3.406 1e-3 -6.812 0.0015-10.22 0.3553-1.875 2.409-1.689 3.866-1.626 1.341-0.2301 3.068 0.2243 3.15 1.818 4.92e-4 3.342 9.83e-4 6.684 0.0015 10.03 1.442 0.0378 2.903-0.0975 4.331 0.1108 1.533 1.159-0.2458 2.66-0.9956 3.69-2.104 2.658-4.17 5.352-6.377 7.926-0.2941 0.1659-0.6875 0.1582-0.9702-0.0291z" fill="%23000" stroke-width=".07256"/></g></svg>');
    background-size: 1em;
    text-decoration: none;
    padding: .3em .5em .3em 2em;
    font-size: 1.2em;

    border-radius: .5em;



    transition: background-color .2s, color .2s;
    color: darkblue;
}

.web-content aside.file a b {
    text-decoration: underline;
}

.web-content aside.file a:hover {
    background-color: #ccc;
    color: darkred;
}

.web-content figure.image {
    text-align: center;
}

.web-content figure.image figcaption {
    font-style: italic;
    color: #666;
    margin-top: 2pt;
}

.web-content figure.image.img-center {
    max-width: 500px;
    margin: 1em auto 1em auto;
}

.web-content figure.image.img-left {
    max-width: 200px;
    float: left;
    margin: 0 8pt 4pt 0;
    clear: left;
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228















229
230
231
232
233
234
235

.imageBrowser figure {
    max-height: 90%;
    max-width: 90%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .5s;
    margin: 0;
}

.imageBrowser figure img {
    background: #000;
    max-width: 100%;
    max-height: 100%;
    padding: .5rem;
    border-radius: .5em;
    cursor: pointer;















}

.web-grid {
    /* Default grid template: just auto sized columns */;
    --grid-template: none / repeat(auto-fit, minmax(100px, 1fr));
    grid-gap: 1rem;
    display: grid;







|




<


|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







218
219
220
221
222
223
224
225
226
227
228
229

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256

.imageBrowser figure {
    max-height: 90%;
    max-width: 90%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity .5s;
    margin: 0;
}

.imageBrowser figure img {

    max-width: 100%;
    max-height: 100%;
    border: .5em solid #000;
    border-radius: .5em;
    cursor: pointer;
    background: #fff;
    /* For transparent images */
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%, #ccc),
        linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%, #ccc);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px;
}

.imageBrowser figure.loading {
    opacity: 0;
}

.imageBrowser figure.loading img {
    border: none;
}

.web-grid {
    /* Default grid template: just auto sized columns */;
    --grid-template: none / repeat(auto-fit, minmax(100px, 1fr));
    grid-gap: 1rem;
    display: grid;

Modified src/skel-dist/web/default.css from [db424ff1b1] to [ff86d4a451].

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
nav.main ul li a:hover, .subcategories li a:hover {
    color: darkred;
    background: #eee;
}


/* Formulaire de recherche */
.search article p b {
    background: #ff9;
    padding: .2em 0;
}

.search-widget p {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 1em;







|
|
|







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
nav.main ul li a:hover, .subcategories li a:hover {
    color: darkred;
    background: #eee;
}


/* Formulaire de recherche */
.search article p b, ::target-text {
    background: #ff0;
    padding: .2em;
}

.search-widget p {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 1em;
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386


































387
388
389
390
391
392
393
}

article > h1 {
    margin-bottom: 1rem;
}

/* GALERIE D'IMAGES EN DESSOUS DE L'ARTICLE */
section.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-gap: 1.5rem;
    justify-content: center;
    align-items: center;
}

section.gallery figure {
    display: inline-flex;
    justify-content: center;
    align-items: center;


































}

/* FORMULAIRES */
fieldset {
    border: 2px solid #ccc;
    border-radius: .5em;
    padding: 1em;







|







|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
}

article > h1 {
    margin-bottom: 1rem;
}

/* GALERIE D'IMAGES EN DESSOUS DE L'ARTICLE */
section.gallery, section.documents {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-gap: 1.5rem;
    justify-content: center;
    align-items: center;
}

section.gallery figure, section.documents aside {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

section.documents aside a {
    display: block;
    text-decoration: none;
    border-radius: .5em;
    background: rgba(var(--first-color), 0.2) no-repeat center center;
    background-image: url('data:image/svg+xml;utf8,<svg width="33.87mm" height="33.87mm" version="1.1" viewBox="0 0 33.87 33.87" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-45.16 -132.5)"><path d="m46.87 166.3c-1.895-0.8504-2.04-3.422-1.368-5.124 0.4287-0.9042 1.363-1.675 2.405-1.471h29.27c1.387 0.5818 2.074 2.134 1.853 3.586 0.137 1.429-0.8551 3.219-2.472 3.059-8.696 0.1509-17.4 0.0429-26.09 0.0478-1.196-0.027-2.4 0.0278-3.591-0.0985zm14.74-10.2c-2.695-3.234-5.319-6.532-7.861-9.888-0.6409-1.955 1.712-1.953 2.991-1.809h1.863c5.01e-4 -3.406 1e-3 -6.812 0.0015-10.22 0.3553-1.875 2.409-1.689 3.866-1.626 1.341-0.2301 3.068 0.2243 3.15 1.818 4.92e-4 3.342 9.83e-4 6.684 0.0015 10.03 1.442 0.0378 2.903-0.0975 4.331 0.1108 1.533 1.159-0.2458 2.66-0.9956 3.69-2.104 2.658-4.17 5.352-6.377 7.926-0.2941 0.1659-0.6875 0.1582-0.9702-0.0291z" fill="%23fff" stroke-width=".07256"/></g></svg>');
    padding: .5em;
    color: #666;
    transition: background-color .2s, color .2s, box-shadow .2s;
    background-size: 90% 90%;
}

section.documents aside a:hover {
    background-color: #eee;
    color: #333;
    box-shadow: 0px 0px 5px rgba(var(--first-color), 1);
}

section.documents aside a:hover b {
    color: darkred;
}

section.documents aside b {
    display: block;
    font-size: 1.1em;
    text-decoration: underline;
    color: darkblue;
}

section.documents aside span {
    font-size: .8em;
}

/* FORMULAIRES */
fieldset {
    border: 2px solid #ccc;
    border-radius: .5em;
    padding: 1em;

Modified src/skel-dist/web/documents.html from [b071506de9] to [303cfe31d5].

1
2
3
4
5
6
7
<section class="documents">
{{#documents order="name" parent=$parent except_in_text=true}}
	<aside class="fichier">
		<a href="{{$url}}">{{$name}} ({{$type}}, {{$size|size_in_bytes}})</a>
	</aside>
{{/documents}}
</section>


|
|



1
2
3
4
5
6
7
<section class="documents">
{{#documents order="name" parent=$parent except_in_text=true}}
	<aside class="file">
		<a href="{{$url}}"><b>{{$title}}</b> <span class="type">({{$extension}})</span> <span class="size">{{$size|size_in_bytes}}</span></a>
	</aside>
{{/documents}}
</section>

Modified src/skel-dist/web/search.html from [a95eae70e5] to [07ae417478].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
		{{if !$count}}
			<p class="alert">Aucun résultat trouvé.</p>
		{{else}}
			<p class="alert">{{if $count == 1}}1 résultat trouvé{{else}}{{$count}} résultats trouvés{{/if}}.</p>

			{{#pages search=$_GET.search future=false}}
			<article>
				<h3><a href="{{$url}}">{{$title}}</a></h3>
				<h5>{{$published|date_long}}</h5>
				<p>{{$snippet|raw}}</p>
			</article>
			{{else}}
			<p class="alert">
				Aucun résultat trouvé.
			</p>
			{{/pages}}
		{{/if}}
	{{/pages}}
</section>

{{:include file="./_foot.html"}}







|













15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
		{{if !$count}}
			<p class="alert">Aucun résultat trouvé.</p>
		{{else}}
			<p class="alert">{{if $count == 1}}1 résultat trouvé{{else}}{{$count}} résultats trouvés{{/if}}.</p>

			{{#pages search=$_GET.search future=false}}
			<article>
				<h3><a href="{{$url_highlight}}">{{$title}}</a></h3>
				<h5>{{$published|date_long}}</h5>
				<p>{{$snippet|raw}}</p>
			</article>
			{{else}}
			<p class="alert">
				Aucun résultat trouvé.
			</p>
			{{/pages}}
		{{/if}}
	{{/pages}}
</section>

{{:include file="./_foot.html"}}

Modified src/templates/acc/index.tpl from [3c1a040fe0] to [a2711afef3].

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
				<img src="{$url|args:'year='|cat:$year.id}" alt="" />
				<figcaption>{$label}</figcaption>
			</figure>
			{/foreach}
		</section>
	{else}
		<p class="help block">Il n'y a pas encore suffisamment d'écritures dans cet exercice pour pouvoir afficher les statistiques.</p>
		<p>{linkbutton label="Saisir une nouvelle écriture" shape="plus" href="transactions/new.php"}</p>
	{/if}

	{if $year.nb_transactions}
	<?php $list = $last_transactions[$year->id]; ?>
	<table class="list">
		<caption>Dernières écritures</caption>
		<thead>







|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
				<img src="{$url|args:'year='|cat:$year.id}" alt="" />
				<figcaption>{$label}</figcaption>
			</figure>
			{/foreach}
		</section>
	{else}
		<p class="help block">Il n'y a pas encore suffisamment d'écritures dans cet exercice pour pouvoir afficher les statistiques.</p>
		<p>{linkbutton label="Saisir une nouvelle écriture" shape="plus" href="transactions/new.php?set_year=%d"|args:$year.id}</p>
	{/if}

	{if $year.nb_transactions}
	<?php $list = $last_transactions[$year->id]; ?>
	<table class="list">
		<caption>Dernières écritures</caption>
		<thead>

Modified src/templates/acc/reports/_journal.tpl from [64e553e4c7] to [b7e93bd479].

1
2
3
4
5
6
7
8
9
10
11
12

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





28
29
30
31
32
33
34
<table class="list multi">
	<thead>
		<tr>
			<td class="num">N°</td>
			<td>Pièce comptable</td>
			<td>Date</td>
			<th>Libellé</th>
			<td>Comptes</td>
			<td class="money">Débit</td>
			<td class="money">Crédit</td>
			<td>Libellé ligne</td>
			<td>Réf. ligne</td>

		</tr>
	</thead>
	{foreach from=$journal item="transaction"}
	<tbody>
		<tr>
			<td rowspan="{$transaction.lines|count}" class="num">{if $transaction.id}<a href="{$admin_url}acc/transactions/details.php?id={$transaction.id}">#{$transaction.id}</a>{/if}</td>
			<td rowspan="{$transaction.lines|count}">{$transaction.reference}</td>
			<td rowspan="{$transaction.lines|count}">{$transaction.date|date_short}</td>
			<th rowspan="{$transaction.lines|count}">{$transaction.label}</th>
		{foreach from=$transaction.lines item="line"}
			<td>{$line.account_code} - {$line.account_label}</td>
			<td class="money">{$line.debit|raw|money}</td>
			<td class="money">{$line.credit|raw|money}</td>
			<td>{$line.label}</td>
			<td>{$line.reference}</td>





		</tr>
		<tr>
		{/foreach}
		</tr>
	</tbody>
	{/foreach}
</table>












>









|





>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<table class="list multi">
	<thead>
		<tr>
			<td class="num">N°</td>
			<td>Pièce comptable</td>
			<td>Date</td>
			<th>Libellé</th>
			<td>Comptes</td>
			<td class="money">Débit</td>
			<td class="money">Crédit</td>
			<td>Libellé ligne</td>
			<td>Réf. ligne</td>
			{if !empty($action)}<td></td>{/if}
		</tr>
	</thead>
	{foreach from=$journal item="transaction"}
	<tbody>
		<tr>
			<td rowspan="{$transaction.lines|count}" class="num">{if $transaction.id}<a href="{$admin_url}acc/transactions/details.php?id={$transaction.id}">#{$transaction.id}</a>{/if}</td>
			<td rowspan="{$transaction.lines|count}">{$transaction.reference}</td>
			<td rowspan="{$transaction.lines|count}">{$transaction.date|date_short}</td>
			<th rowspan="{$transaction.lines|count}">{$transaction.label}</th>
		{foreach from=$transaction.lines key="k" item="line"}
			<td>{$line.account_code} - {$line.account_label}</td>
			<td class="money">{$line.debit|raw|money}</td>
			<td class="money">{$line.credit|raw|money}</td>
			<td>{$line.label}</td>
			<td>{$line.reference}</td>
			{if !empty($action) && $k == 0}
			<td class="actions" rowspan="{$transaction.lines|count}">
				{linkbutton href=$action.href|args:$transaction.id shape=$action.shape label=$action.label}
			</td>
			{/if}
		</tr>
		<tr>
		{/foreach}
		</tr>
	</tbody>
	{/foreach}
</table>

Added src/templates/ask_share_password.tpl version [bbf76fbdb1].

































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>Accès document</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link rel="stylesheet" type="text/css" href="{$admin_url}static/admin.css?{$version_hash}" media="all" />
	<style type="text/css">
	{literal}
	main {
		max-width: 650px;
		margin: 2em auto;
		text-align: center;
	}

	main input[type=password] {
		font-size: 1.5em;
	}

	main legend {
		font-size: 1.3em;
		padding: 0 2em;
	}

	main dl {
		padding: 1em 0;
	}

	main p.block.error, main p.block.alert {
		margin: 2em 0;
		font-size: 1.2em;
	}
	{/literal}
	</style>
</head>

<body class="transparent dialog">

<main>

{if $has_password}
<p class="block error">
	Le mot de passe fourni ne correspond pas.<br />Merci de vérifier la saisie.
</p>
{else}
	<p class="block alert">Un mot de passe est nécessaire pour accéder à ce document.</p>
{/if}

<form method="post" action="">
	<fieldset>
		<legend>Accès au document</legend>
		<dl>
			{input type="password" name="p" required=true label="Mot de passe"}
		</dl>
		<p class="submit">
			{button type="submit" label="Accéder au document" shape="right" class="main"}
		</p>
	</fieldset>
</form>

</main>

</body>
</html>

Added src/templates/common/files/share.tpl version [ed6ea2bce6].



























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{include file="admin/_head.tpl" title="Partager" current=null}

{form_errors}

<form method="post" action="{$self_url}" data-focus="1">
	<fieldset>
		<legend>{$file.name}</legend>
	{if $share_url}
		<dl>
			{input type="url" copy=true readonly=true name="" size=100 onclick="this.select();" label="Pour partager ce fichier, transmettez cette adresse :" default=$share_url}
		</dl>
	{else}
		<dl>
			{input type="select" name="expiry" required=true label="Durée de validité du partage" options=$expiry_options default=24*365 help="Après ce délai, le lien ne sera plus valide."}
			{input type="password" name="password" label="Définir un mot de passe" help="Si renseigné, alors la personne devra entrer ce mot de passe pour accéder au fichier partagé"}
		</dl>
		<p class="submit">
			{csrf_field key=$csrf_key}
			{button type="submit" name="share" label="Partager" shape="right" class="main"}
		</p>
	{/if}
	</fieldset>
</form>

<p class="help block">
	Le lien de partage cessera de fonctionner si le fichier est renommé ou déplacé.
</p>

{include file="admin/_foot.tpl"}

Modified src/templates/docs/index.tpl from [f596fbbbc9] to [2bc2de20fc].

136
137
138
139
140
141
142
143
144
145
146
147



148
149
150
151
152
153
154
							{linkbutton href="!common/files/edit.php?p=%s"|args:$file.path label="Modifier" shape="edit" target="_dialog" data-dialog-height="90%"}
						{/if}
						{if $file->canPreview()}
							{linkbutton href="!common/files/preview.php?p=%s"|args:$file.path label="Voir" shape="eye" target="_dialog" data-mime=$file.mime}
						{/if}
						{linkbutton href=$file->url(true) label="Télécharger" shape="download"}
						{if $can_write}
							{linkbutton href="!common/files/rename.php?p=%s"|args:$file.path label="Renommer" shape="minus" target="_dialog"}
						{/if}
						{if $can_delete}
							{linkbutton href="!common/files/delete.php?p=%s"|args:$file.path label="Supprimer" shape="delete" target="_dialog"}
						{/if}



					</td>
				</tr>
				{/if}
			{/foreach}

			</tbody>








|




>
>
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
							{linkbutton href="!common/files/edit.php?p=%s"|args:$file.path label="Modifier" shape="edit" target="_dialog" data-dialog-height="90%"}
						{/if}
						{if $file->canPreview()}
							{linkbutton href="!common/files/preview.php?p=%s"|args:$file.path label="Voir" shape="eye" target="_dialog" data-mime=$file.mime}
						{/if}
						{linkbutton href=$file->url(true) label="Télécharger" shape="download"}
						{if $can_write}
							{linkbutton href="!common/files/rename.php?p=%s"|args:$file.path label="Renommer" shape="reload" target="_dialog"}
						{/if}
						{if $can_delete}
							{linkbutton href="!common/files/delete.php?p=%s"|args:$file.path label="Supprimer" shape="delete" target="_dialog"}
						{/if}
						{if $can_write}
							{linkbutton href="!common/files/share.php?p=%s"|args:$file.path label="Partager" shape="export" target="_dialog"}
						{/if}
					</td>
				</tr>
				{/if}
			{/foreach}

			</tbody>

Modified src/templates/services/user/index.tpl from [bc1c800a95] to [f7d117f323].

10
11
12
13
14
15
16

17
18
19
20
21
22
23
		<li class="current">{link href="!services/user/?id=%d"|args:$user_id label="Inscriptions aux activités"}</li>
		<li>{link href="!services/reminders/user.php?id=%d"|args:$user_id label="Rappels envoyés"}</li>
	</ul>
</nav>

{form_errors}


<dl class="cotisation">
	<dt>Statut des inscriptions</dt>
	{foreach from=$services item="service"}
	<dd{if $service.archived} class="disabled"{/if}>
		{$service.label}
		{if $service.archived} <em>(activité passée)</em>{/if}
		{if $service.status == -1 && $service.end_date} — expirée







>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
		<li class="current">{link href="!services/user/?id=%d"|args:$user_id label="Inscriptions aux activités"}</li>
		<li>{link href="!services/reminders/user.php?id=%d"|args:$user_id label="Rappels envoyés"}</li>
	</ul>
</nav>

{form_errors}

{if !$only}
<dl class="cotisation">
	<dt>Statut des inscriptions</dt>
	{foreach from=$services item="service"}
	<dd{if $service.archived} class="disabled"{/if}>
		{$service.label}
		{if $service.archived} <em>(activité passée)</em>{/if}
		{if $service.status == -1 && $service.end_date} — expirée
45
46
47
48
49
50
51

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
					{linkbutton href="?id=%d&export=xlsx"|args:$user_id shape="export" label="Export Excel"}
				{/if}
			</span>
		</nav>
		{/if}
	</dd>
</dl>


{if $only}
	<p class="alert block">Cette liste ne montre qu'une seule inscription, liée à une écriture. {link href="?id=%d"|args:$user_id label="Voir toutes les inscriptions"}</p>
{/if}

{include file="common/dynamic_list_head.tpl"}

	{foreach from=$list->iterate() item="row"}
		<tr>
			<th>{$row.label}</th>
			<td>{$row.date|date_short}</td>
			<td>{$row.expiry|date_short}</td>
			<td>{$row.fee}</td>
			<td>{if $row.paid}<b class="confirm">Oui</b>{else}<b class="error">Non</b>{/if}</td>
			<td>{$row.amount|raw|money_currency}</td>
			<td class="actions">
				{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE) && $row.id_account}
					{linkbutton shape="plus" label="Nouveau règlement" href="payment.php?id=%d"|args:$row.id}
				{/if}
				{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ)}
					{if $row.has_transactions}
						{linkbutton shape="menu" label="Liste des écritures" href="!acc/transactions/service_user.php?id=%d&user=%d"|args:$row.id,$user_id}







>


|











|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
					{linkbutton href="?id=%d&export=xlsx"|args:$user_id shape="export" label="Export Excel"}
				{/if}
			</span>
		</nav>
		{/if}
	</dd>
</dl>
{/if}

{if $only}
	<p class="alert block">Cette liste ne montre qu'une seule inscription, liée à l'activité <strong>{$only_service.label}</strong><br />{linkbutton shape="right" href="?id=%d"|args:$user_id label="Voir toutes les inscriptions"}</p>
{/if}

{include file="common/dynamic_list_head.tpl"}

	{foreach from=$list->iterate() item="row"}
		<tr>
			<th>{$row.label}</th>
			<td>{$row.date|date_short}</td>
			<td>{$row.expiry|date_short}</td>
			<td>{$row.fee}</td>
			<td>{if $row.paid}<b class="confirm">Oui</b>{else}<b class="error">Non</b>{/if}</td>
			<td>{if $row.expected_amount}{$row.amount|raw|money_currency:false}{/if}</td>
			<td class="actions">
				{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE) && $row.id_account}
					{linkbutton shape="plus" label="Nouveau règlement" href="payment.php?id=%d"|args:$row.id}
				{/if}
				{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ)}
					{if $row.has_transactions}
						{linkbutton shape="menu" label="Liste des écritures" href="!acc/transactions/service_user.php?id=%d&user=%d"|args:$row.id,$user_id}

Modified src/templates/web/_attach.tpl from [9964704ed2] to [1602af30f8].

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

{if !empty($files)}
<table class="list">
	<tbody>
	{foreach from=$files item="file"}
		<tr>
			<th>{$file.name}</th>
			<td>{$file.type}, {$file.size|size_in_bytes}</td>
			<td class="actions">
				<form class="actions" method="post" action="{$self_url}">
					{linkbutton shape="plus" label="Insérer" href=$file->url() data-name=$file.name data-insert="file"}
					{linkbutton shape="download" label="Télécharger" href=$file->url() target="_blank"}
					{csrf_field key=$csrf_key}
					<input type="hidden" name="delete" value="{$file.name}" />
					<noscript><input type="submit" value="Supprimer" /></noscript>







|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

{if !empty($files)}
<table class="list">
	<tbody>
	{foreach from=$files item="file"}
		<tr>
			<th>{$file.name}</th>
			<td>{$file.mime}, {$file.size|size_in_bytes}</td>
			<td class="actions">
				<form class="actions" method="post" action="{$self_url}">
					{linkbutton shape="plus" label="Insérer" href=$file->url() data-name=$file.name data-insert="file"}
					{linkbutton shape="download" label="Télécharger" href=$file->url() target="_blank"}
					{csrf_field key=$csrf_key}
					<input type="hidden" name="delete" value="{$file.name}" />
					<noscript><input type="submit" value="Supprimer" /></noscript>

Modified src/www/admin/acc/_inc.php from [b33504a9a2] to [159d9bd2b6].

1
2
3
4
5
6
7
8
9
10
11




12
13
14
15
16
17
18
<?php

namespace Garradin;

use Garradin\Accounting\Years;

require_once __DIR__ . '/../_inc.php';

if (!defined('Garradin\ALLOW_ACCOUNTS_ACCESS') || !ALLOW_ACCOUNTS_ACCESS) {
	$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);
}





$current_year_id = $session->get('acc_year');
$current_year = null;

if ($current_year_id) {
	// Check that the year is still valid
	$current_year = Years::get($current_year_id);











>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

namespace Garradin;

use Garradin\Accounting\Years;

require_once __DIR__ . '/../_inc.php';

if (!defined('Garradin\ALLOW_ACCOUNTS_ACCESS') || !ALLOW_ACCOUNTS_ACCESS) {
	$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);
}

if (!empty($_GET['set_year'])) {
	$session->set('acc_year', (int)$_GET['set_year']);
}

$current_year_id = $session->get('acc_year');
$current_year = null;

if ($current_year_id) {
	// Check that the year is still valid
	$current_year = Years::get($current_year_id);

Modified src/www/admin/acc/reports/graph_pie.php from [d13fac73c5] to [b843b08c23].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
namespace Garradin;

use Garradin\Accounting\Graph;

require_once __DIR__ . '/_inc.php';

header('Content-Type: image/svg+xml');

$expiry = time() - 30;
$hash = sha1('graph_pie_' . json_encode($criterias));

if (!Utils::HTTPCache($hash, $expiry)) {
	echo Graph::pie(qg('type'), $criterias);
}











|





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
namespace Garradin;

use Garradin\Accounting\Graph;

require_once __DIR__ . '/_inc.php';

header('Content-Type: image/svg+xml');

$expiry = time() - 30;
$hash = sha1('graph_pie_v2_' . json_encode($criterias));

if (!Utils::HTTPCache($hash, $expiry)) {
	echo Graph::pie(qg('type'), $criterias);
}

Modified src/www/admin/acc/transactions/new.php from [b08a590bb9] to [c35c025848].

86
87
88
89
90
91
92



93




94
95
96
97
98
99
100

	if (!$account || $account->id_chart != $current_year->id_chart) {
		throw new UserException('Ce compte ne correspond pas à l\'exercice comptable ou n\'existe pas');
	}

	$transaction->type = Transaction::getTypeFromAccountType($account->type);
	$index = $transaction->type == Transaction::TYPE_DEBT || $transaction->type == Transaction::TYPE_CREDIT ? 1 : 0;



	$types_details[$transaction->type]->accounts[$index]->selector_value = [$account->id => sprintf('%s — %s', $account->code, $account->label)];




}

$form->runIf('save', function () use ($transaction, $session, $current_year) {
	$transaction->importFromNewForm();
	$transaction->id_year = $current_year->id();
	$transaction->id_creator = $session->getUser()->id;
	$transaction->save();







>
>
>
|
>
>
>
>







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

	if (!$account || $account->id_chart != $current_year->id_chart) {
		throw new UserException('Ce compte ne correspond pas à l\'exercice comptable ou n\'existe pas');
	}

	$transaction->type = Transaction::getTypeFromAccountType($account->type);
	$index = $transaction->type == Transaction::TYPE_DEBT || $transaction->type == Transaction::TYPE_CREDIT ? 1 : 0;
	$s = [$account->id => sprintf('%s — %s', $account->code, $account->label)];

	if ($transaction->type) {
		$types_details[$transaction->type]->accounts[$index]->selector_value = $s;
	}
	else {
		$lines = [['account_selector' => $s], []];
	}
}

$form->runIf('save', function () use ($transaction, $session, $current_year) {
	$transaction->importFromNewForm();
	$transaction->id_year = $current_year->id();
	$transaction->id_creator = $session->getUser()->id;
	$transaction->save();

Modified src/www/admin/acc/transactions/payoff.php from [56988c3eb1] to [bcca3ec0bf].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

$chart = $current_year->chart();
$accounts = $chart->accounts();

$date = new \DateTime;

if ($session->get('acc_last_date')) {
	$date = \DateTime::createFromFormat('!d/m/Y', $session->get('acc_last_date'));
}

if (!$date || ($date < $current_year->start_date || $date > $current_year->end_date)) {
	$date = $current_year->start_date;
}

$transaction->date = $date;







|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

$chart = $current_year->chart();
$accounts = $chart->accounts();

$date = new \DateTime;

if ($session->get('acc_last_date')) {
	$date = \DateTime::createFromFormat('!Y-m-d', $session->get('acc_last_date'));
}

if (!$date || ($date < $current_year->start_date || $date > $current_year->end_date)) {
	$date = $current_year->start_date;
}

$transaction->date = $date;

Modified src/www/admin/acc/transactions/service_user.php from [6ef72d23d2] to [160445d1d1].

1
2
3
4

5
6
7
8
9
10









11

12
13
14
15
16

17
18
<?php
namespace Garradin;

use Garradin\Accounting\Reports;

use Garradin\Accounting\Years;

require_once __DIR__ . '/../../_inc.php';

$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);










$criterias = ['subscription' => (int)qg('id')];


$tpl->assign('balance', Reports::getAccountsBalances($criterias));
$tpl->assign('journal', Reports::getJournal($criterias));
$tpl->assign('user_id', qg('user'));
$tpl->assign('service_user_id', qg('id'));


$tpl->display('acc/transactions/service_user.tpl');




>






>
>
>
>
>
>
>
>
>
|
>



|
|
>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace Garradin;

use Garradin\Accounting\Reports;
use Garradin\Accounting\Transactions;
use Garradin\Accounting\Years;

require_once __DIR__ . '/../../_inc.php';

$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);

$id = (int)qg('id');
$user = (int)qg('user');
$self_url = sprintf('!acc/transactions/service_user.php?id=%d&user=%d', $id, $user);

$form->runIf(qg('unlink') !== null, function () use ($id) {
	$t = Transactions::get((int)qg('unlink'));
	$t->unlinkServiceUser($id);
}, null, $self_url);

$criterias = ['subscription' => $id];
$action = ['shape' => 'delete', 'href' => $self_url . '&unlink=%d', 'label' => 'Dé-lier cette écriture'];

$tpl->assign('balance', Reports::getAccountsBalances($criterias));
$tpl->assign('journal', Reports::getJournal($criterias));
$tpl->assign('user_id', $user);
$tpl->assign('service_user_id', $id);
$tpl->assign(compact('action'));

$tpl->display('acc/transactions/service_user.tpl');

Modified src/www/admin/acc/years/export.php from [ff77b91d6e] to [f39aed5a9b].

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$types = [
	Export::FULL => [
		'label' => 'Complet (comptabilité d\'engagement)',
		'help' => '(Conseillé pour transfert vers un autre logiciel) Chaque ligne reprend toutes les informations de la ligne et de l\'écriture.',
	],
	Export::GROUPED => [
		'label' => 'Complet groupé',
		'help' => 'Idem, sauf que les lignes suivantes ne mentionnent pas les informations de l\'écriture.',
	],
	Export::SIMPLE => [
		'label' => 'Simplifié (comptabilité de trésorerie)',
		'help' => 'Les écritures avancées ne sont pas inclues dans cet export.',
	],
	Export::FEC => [
		'label' => 'FEC (Fichier des Écritures Comptables)',







|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$types = [
	Export::FULL => [
		'label' => 'Complet (comptabilité d\'engagement)',
		'help' => '(Conseillé pour transfert vers un autre logiciel) Chaque ligne reprend toutes les informations de la ligne et de l\'écriture.',
	],
	Export::GROUPED => [
		'label' => 'Complet groupé',
		'help' => 'Les colonnes de l\'écriture ne sont pas répétées pour chaque ligne.',
	],
	Export::SIMPLE => [
		'label' => 'Simplifié (comptabilité de trésorerie)',
		'help' => 'Les écritures avancées ne sont pas inclues dans cet export.',
	],
	Export::FEC => [
		'label' => 'FEC (Fichier des Écritures Comptables)',

Added src/www/admin/common/files/share.php version [dababf0f5e].















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Garradin;

use Garradin\Entities\Files\File;
use Garradin\Files\Files;

require __DIR__ . '/../../_inc.php';

$file = Files::get(qg('p'));

if (!$file) {
	throw new UserException('Fichier inconnu');
}

if (!$file->checkWriteAccess($session)) {
    throw new UserException('Vous n\'avez pas le droit de modifier ce fichier.');
}

$context = $file->context();

$csrf_key = 'file_share_' . $file->pathHash();
$share_url = null;

$form->runIf('share', function () use ($file, &$share_url) {
	$share_url = $file->createShareLink(f('expiry'), f('password'));
}, $csrf_key);

$expiry_options = [
	1         => 'Une heure',
	24        => 'Un jour',
	24*31     => 'Un mois',
	24*365    => 'Un an',
	24*365*10 => 'Dix ans',
	24*365*30 => 'Infinie',
];

$tpl->assign(compact('file', 'csrf_key', 'share_url', 'expiry_options'));

$tpl->display('common/files/share.tpl');

Modified src/www/admin/services/user/index.php from [c14070827e] to [2f23981676].

1
2
3
4

5
6
7
8
9
10
11
<?php

namespace Garradin;


use Garradin\Services\Services_User;
use Garradin\Users\Users;

require_once __DIR__ . '/../_inc.php';

$session->requireAccess($session::SECTION_USERS, $session::ACCESS_READ);





>







1
2
3
4
5
6
7
8
9
10
11
12
<?php

namespace Garradin;

use Garradin\Services\Services;
use Garradin\Services\Services_User;
use Garradin\Users\Users;

require_once __DIR__ . '/../_inc.php';

$session->requireAccess($session::SECTION_USERS, $session::ACCESS_READ);

24
25
26
27
28
29
30

31
32
33
34
35
36
37
38
39
	}

	$su->paid = (bool)qg('paid');
	$su->save();
}, null, ADMIN_URL . 'services/user/?id=' . $user_id);

$only = (int)qg('only') ?: null;


$list = Services_User::perUserList($user_id, $only);
$list->setTitle(sprintf('Inscriptions — %s', $user_name));
$list->loadFromQueryString();

$tpl->assign('services', Services_User::listDistinctForUser($user_id));
$tpl->assign(compact('list', 'user_id', 'user_name', 'only'));

$tpl->display('services/user/index.tpl');







>






|


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
	}

	$su->paid = (bool)qg('paid');
	$su->save();
}, null, ADMIN_URL . 'services/user/?id=' . $user_id);

$only = (int)qg('only') ?: null;
$only_service = !$only ? null : Services::get($only);

$list = Services_User::perUserList($user_id, $only);
$list->setTitle(sprintf('Inscriptions — %s', $user_name));
$list->loadFromQueryString();

$tpl->assign('services', Services_User::listDistinctForUser($user_id));
$tpl->assign(compact('list', 'user_id', 'user_name', 'only', 'only_service'));

$tpl->display('services/user/index.tpl');

Modified src/www/admin/static/font/config.json from [ce3115b784] to [6b19a4d91c].

547
548
549
550
551
552
553














554
555
556
      "svg": {
        "path": "M831.2 104.2L765.4 238.1Q711.8 183.9 593.7 183.9 422.7 183.9 359.6 378.2H703.7L666.8 472.2H340.2Q338.1 497.1 338.1 521.4 338.1 546.9 340.2 571.2H623.9L587.7 665.2H358.9Q415.9 839.6 581.6 839.6 715.8 839.6 779.5 750.6V921.2Q700.4 983.4 568.9 983.4 411.9 983.4 312 895 219.4 812.8 187.9 665.2H102.7V571.2H174.5Q170.4 518.9 173.8 472.2H102.7V378.2H187.9Q222.8 231.2 321.4 140.3 429.4 40.1 583.6 40.1T831.2 104.2Z",
        "width": 1000
      },
      "search": [
        "euro-svgrepo-com-(1)"
      ]














    }
  ]
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>



547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
      "svg": {
        "path": "M831.2 104.2L765.4 238.1Q711.8 183.9 593.7 183.9 422.7 183.9 359.6 378.2H703.7L666.8 472.2H340.2Q338.1 497.1 338.1 521.4 338.1 546.9 340.2 571.2H623.9L587.7 665.2H358.9Q415.9 839.6 581.6 839.6 715.8 839.6 779.5 750.6V921.2Q700.4 983.4 568.9 983.4 411.9 983.4 312 895 219.4 812.8 187.9 665.2H102.7V571.2H174.5Q170.4 518.9 173.8 472.2H102.7V378.2H187.9Q222.8 231.2 321.4 140.3 429.4 40.1 583.6 40.1T831.2 104.2Z",
        "width": 1000
      },
      "search": [
        "euro-svgrepo-com-(1)"
      ]
    },
    {
      "uid": "f9cd6e558fac8be365aacaa4c11acc75",
      "css": "import",
      "code": 8630,
      "src": "custom_icons",
      "selected": true,
      "svg": {
        "path": "M129.9 947.8C70.8 939.7 21.5 895.6 4.5 835.8 1.2 823.9 1 808.6 1 544S1.2 264 4.5 252.1C21.6 191.9 69.8 149.1 130.1 140.7 138.9 139.5 189.1 138.7 256 138.7H367.2V246.1H252.8C151.5 246.1 137.8 246.5 132.2 249.3 123.4 253.7 115.6 261.4 110.7 270.5L106.4 278.3 105.9 538.1C105.6 715.9 106.1 801 107.5 807.9 109.9 819.8 119.6 832.1 131.6 838.5L139.6 842.8H670.9L678.7 838.6C683 836.3 688.9 831.9 691.8 828.8 703.4 816.6 703.1 819.5 703.1 691.5V574.2H810.8L810.1 697.8C809.4 817 809.3 821.8 805.2 836.2 791.8 884 758 921.9 713.6 938.7 685.6 949.3 692.4 949.1 403.3 948.9 256.1 948.8 133.1 948.3 129.9 947.8ZM992.5 660.2C982.8 624.3 967.3 589.8 946.5 558.6 927.1 529.3 887.6 490.2 857.4 470.1 806.7 436.6 740.4 413.2 683.5 408.8L668 407.6 667 559 509.3 432.8C422.5 363.4 351.6 306.2 351.6 305.7S422.5 247.9 509.3 178.5L667 52.3 669 203.6 694.4 210C724 217.5 747.2 226.1 774.4 239.8 914 310 1006.4 468.3 999.2 625 998.5 640.6 997.2 656.8 996.3 661.1L994.8 668.9Z",
        "width": 1000
      },
      "search": [
        "import"
      ]
    }
  ]
}

Modified src/www/admin/static/font/garradin.css from [e87860e999] to [fc98d57e41].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@charset "UTF-8";
@font-face {
  font-family: 'garradin';
  src: url('../font/garradin.eot?61352908');
  src: url('../font/garradin.eot?61352908#iefix') format('embedded-opentype'),
       url('../font/garradin.woff2?61352908') format('woff2'),
       url('../font/garradin.woff?61352908') format('woff'),
       url('../font/garradin.ttf?61352908') format('truetype'),
       url('../font/garradin.svg?61352908#garradin') format('svg');
  font-weight: normal;
  font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'garradin';
    src: url('../font/garradin.svg?61352908#garradin') format('svg');
  }
}
*/
[class^="icn-"]:before, [class*=" icn-"]:before {
  font-family: "garradin";
  font-style: normal;
  font-weight: normal;



|
|
|
|
|
|









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@charset "UTF-8";
@font-face {
  font-family: 'garradin';
  src: url('../font/garradin.eot?62744060');
  src: url('../font/garradin.eot?62744060#iefix') format('embedded-opentype'),
       url('../font/garradin.woff2?62744060') format('woff2'),
       url('../font/garradin.woff?62744060') format('woff'),
       url('../font/garradin.ttf?62744060') format('truetype'),
       url('../font/garradin.svg?62744060#garradin') format('svg');
  font-weight: normal;
  font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'garradin';
    src: url('../font/garradin.svg?62744060#garradin') format('svg');
  }
}
*/
[class^="icn-"]:before, [class*=" icn-"]:before {
  font-family: "garradin";
  font-style: normal;
  font-weight: normal;
66
67
68
69
70
71
72

73
74
75
76
77
78
79
.icn-quote:before { content: '\ab'; } /* '«' */
.icn-list-ul:before { content: '\2022'; } /* '•' */
.icn-euro:before { content: '\20ac'; } /* '€' */
.icn-left:before { content: '\2190'; } /* '←' */
.icn-up:before { content: '\2191'; } /* '↑' */
.icn-right:before { content: '\2192'; } /* '→' */
.icn-down:before { content: '\2193'; } /* '↓' */

.icn-export:before { content: '\21b7'; } /* '↷' */
.icn-reset:before { content: '\21ba'; } /* '↺' */
.icn-upload:before { content: '\21d1'; } /* '⇑' */
.icn-download:before { content: '\21d3'; } /* '⇓' */
.icn-home:before { content: '\2302'; } /* '⌂' */
.icn-print:before { content: '\2399'; } /* '⎙' */
.icn-col:before { content: '\259a'; } /* '▚' */







>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.icn-quote:before { content: '\ab'; } /* '«' */
.icn-list-ul:before { content: '\2022'; } /* '•' */
.icn-euro:before { content: '\20ac'; } /* '€' */
.icn-left:before { content: '\2190'; } /* '←' */
.icn-up:before { content: '\2191'; } /* '↑' */
.icn-right:before { content: '\2192'; } /* '→' */
.icn-down:before { content: '\2193'; } /* '↓' */
.icn-import:before { content: '\21b6'; } /* '↶' */
.icn-export:before { content: '\21b7'; } /* '↷' */
.icn-reset:before { content: '\21ba'; } /* '↺' */
.icn-upload:before { content: '\21d1'; } /* '⇑' */
.icn-download:before { content: '\21d3'; } /* '⇓' */
.icn-home:before { content: '\2302'; } /* '⌂' */
.icn-print:before { content: '\2399'; } /* '⎙' */
.icn-col:before { content: '\259a'; } /* '▚' */

Modified src/www/admin/static/font/garradin.eot from [20dc4de2d6] to [1d8a2e98d5].

cannot compute difference between binary files

Modified src/www/admin/static/font/garradin.svg from [683208e5f6] to [9704223aaa].

31
32
33
34
35
36
37


38
39
40
41
42
43
44
<glyph glyph-name="left" unicode="&#x2190;" d="M654 682l-297-296 297-297q10-10 10-25t-10-25l-93-93q-11-10-25-10t-25 10l-414 415q-11 10-11 25t11 25l414 414q10 11 25 11t25-11l93-93q10-10 10-25t-10-25z" horiz-adv-x="714.3" />

<glyph glyph-name="up" unicode="&#x2191;" d="M571 171q0-14-10-25t-25-10h-500q-15 0-25 10t-11 25 11 26l250 250q10 10 25 10t25-10l250-250q10-11 10-26z" horiz-adv-x="571.4" />

<glyph glyph-name="right" unicode="&#x2192;" d="M618 361l-414-415q-11-10-25-10t-25 10l-93 93q-11 11-11 25t11 25l296 297-296 296q-11 11-11 25t11 25l93 93q10 11 25 11t25-11l414-414q10-11 10-25t-10-25z" horiz-adv-x="714.3" />

<glyph glyph-name="down" unicode="&#x2193;" d="M571 457q0-14-10-25l-250-250q-11-11-25-11t-25 11l-250 250q-11 11-11 25t11 25 25 11h500q14 0 25-11t10-25z" horiz-adv-x="571.4" />



<glyph glyph-name="export" unicode="&#x21b7;" d="M750 60l0 56 100 82 0-188q0-20-15-35t-35-15l-750 0q-20 0-35 15t-15 35l0 550q0 22 14 36t36 14l288 0q-32-24-59-49t-39-39l-10-12-130 0 0-450 650 0z m-82 348q-166 0-242-41t-160-181q0 8 1 22t9 56 22 79 44 83 70 79 107 56 149 23l0 156 332-250-332-260 0 178z" horiz-adv-x="1000" />

<glyph glyph-name="reset" unicode="&#x21ba;" d="M857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z" horiz-adv-x="857.1" />

<glyph glyph-name="upload" unicode="&#x21d1;" d="M714 29q0 14-10 25t-25 10-25-10-11-25 11-25 25-11 25 11 10 25z m143 0q0 14-10 25t-26 10-25-10-10-25 10-25 25-11 26 11 10 25z m72 125v-179q0-22-16-38t-38-16h-821q-23 0-38 16t-16 38v179q0 22 16 38t38 15h238q12-31 39-51t62-20h143q34 0 61 20t40 51h238q22 0 38-15t16-38z m-182 361q-9-22-33-22h-143v-250q0-15-10-25t-25-11h-143q-15 0-25 11t-11 25v250h-143q-23 0-33 22-9 22 8 39l250 250q10 10 25 10t25-10l250-250q18-17 8-39z" horiz-adv-x="928.6" />








>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<glyph glyph-name="left" unicode="&#x2190;" d="M654 682l-297-296 297-297q10-10 10-25t-10-25l-93-93q-11-10-25-10t-25 10l-414 415q-11 10-11 25t11 25l414 414q10 11 25 11t25-11l93-93q10-10 10-25t-10-25z" horiz-adv-x="714.3" />

<glyph glyph-name="up" unicode="&#x2191;" d="M571 171q0-14-10-25t-25-10h-500q-15 0-25 10t-11 25 11 26l250 250q10 10 25 10t25-10l250-250q10-11 10-26z" horiz-adv-x="571.4" />

<glyph glyph-name="right" unicode="&#x2192;" d="M618 361l-414-415q-11-10-25-10t-25 10l-93 93q-11 11-11 25t11 25l296 297-296 296q-11 11-11 25t11 25l93 93q10 11 25 11t25-11l414-414q10-11 10-25t-10-25z" horiz-adv-x="714.3" />

<glyph glyph-name="down" unicode="&#x2193;" d="M571 457q0-14-10-25l-250-250q-11-11-25-11t-25 11l-250 250q-11 11-11 25t11 25 25 11h500q14 0 25-11t10-25z" horiz-adv-x="571.4" />

<glyph glyph-name="import" unicode="&#x21b6;" d="M130-98c-59 8-108 52-125 112-4 12-4 27-4 292s0 280 4 292c17 60 65 103 125 111 9 2 59 2 126 2h111v-107h-114c-101 0-115 0-121-3-9-5-16-12-21-21l-5-8 0-260c0-178 0-263 2-270 2-12 12-24 24-30l8-5h531l8 4c4 3 10 7 13 10 11 12 11 10 11 138v117h108l-1-124c-1-119-1-124-5-138-13-48-47-86-91-103-28-10-22-10-311-10-147 0-270 1-273 1z m863 288c-10 36-26 70-46 101-20 30-59 69-90 89-50 33-117 57-173 61l-16 1-1-151-158 126c-86 70-157 127-157 127s71 58 157 128l158 126 2-152 25-6c30-7 53-16 80-30 140-70 232-228 225-385 0-16-2-32-3-36l-1-8z" horiz-adv-x="1000" />

<glyph glyph-name="export" unicode="&#x21b7;" d="M750 60l0 56 100 82 0-188q0-20-15-35t-35-15l-750 0q-20 0-35 15t-15 35l0 550q0 22 14 36t36 14l288 0q-32-24-59-49t-39-39l-10-12-130 0 0-450 650 0z m-82 348q-166 0-242-41t-160-181q0 8 1 22t9 56 22 79 44 83 70 79 107 56 149 23l0 156 332-250-332-260 0 178z" horiz-adv-x="1000" />

<glyph glyph-name="reset" unicode="&#x21ba;" d="M857 350q0-87-34-166t-91-137-137-92-166-34q-96 0-183 41t-147 114q-4 6-4 13t5 11l76 77q6 5 14 5 9-1 13-7 41-53 100-82t126-29q58 0 110 23t92 61 61 91 22 111-22 111-61 91-92 61-110 23q-55 0-105-20t-90-57l77-77q17-16 8-38-10-23-33-23h-250q-15 0-25 11t-11 25v250q0 24 22 33 22 10 39-8l72-72q60 57 137 88t159 31q87 0 166-34t137-92 91-137 34-166z" horiz-adv-x="857.1" />

<glyph glyph-name="upload" unicode="&#x21d1;" d="M714 29q0 14-10 25t-25 10-25-10-11-25 11-25 25-11 25 11 10 25z m143 0q0 14-10 25t-26 10-25-10-10-25 10-25 25-11 26 11 10 25z m72 125v-179q0-22-16-38t-38-16h-821q-23 0-38 16t-16 38v179q0 22 16 38t38 15h238q12-31 39-51t62-20h143q34 0 61 20t40 51h238q22 0 38-15t16-38z m-182 361q-9-22-33-22h-143v-250q0-15-10-25t-25-11h-143q-15 0-25 11t-11 25v250h-143q-23 0-33 22-9 22 8 39l250 250q10 10 25 10t25-10l250-250q18-17 8-39z" horiz-adv-x="928.6" />

Modified src/www/admin/static/font/garradin.ttf from [2e98cc8df3] to [ad57f8896d].

cannot compute difference between binary files

Modified src/www/admin/static/font/garradin.woff from [36fee96d8f] to [4f41034eac].

cannot compute difference between binary files

Modified src/www/admin/static/font/garradin.woff2 from [f144ee71de] to [dae54afd29].

cannot compute difference between binary files

Modified src/www/admin/static/scripts/service_form.js from [d1f9694e15] to [8d6f8fab97].

16
17
18
19
20
21
22


23


24

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	let first = document.querySelector('[data-service="s' + elm.value + '"] input[name=id_fee]');
	let selected = document.querySelector('[data-service="s' + elm.value + '"] input[name=id_fee]:checked');

	if (first && !selected) {
		first.checked = true;
		selected = first;
	}





	selectFee(selected);

}

function selectFee(elm) {
	var amount = parseInt(elm.getAttribute('data-user-amount'), 10);

	// Toggle accounting part of the form
	var accounting = elm.getAttribute('data-account') ? true : false;
	g.toggle('.accounting', accounting);

	if (accounting && create) {
		$('#f_create_payment_1').checked = true;
		let btn = $('#f_account_container').firstElementChild;
		btn.value = btn.value.replace(/&year=\d+/, '') + '&year=' + elm.getAttribute('data-year');
	}

	// Fill the amount paid by the user
	if (amount && create) {
		$('#f_amount').value = g.formatMoney(amount);
	}







>
>
|
>
>
|
>











|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	let first = document.querySelector('[data-service="s' + elm.value + '"] input[name=id_fee]');
	let selected = document.querySelector('[data-service="s' + elm.value + '"] input[name=id_fee]:checked');

	if (first && !selected) {
		first.checked = true;
		selected = first;
	}
	else if (!first) {
		document.querySelector('input[name=id_fee]:checked').checked = false;
	}

	if (selected) {
		selectFee(selected);
	}
}

function selectFee(elm) {
	var amount = parseInt(elm.getAttribute('data-user-amount'), 10);

	// Toggle accounting part of the form
	var accounting = elm.getAttribute('data-account') ? true : false;
	g.toggle('.accounting', accounting);

	if (accounting && create) {
		$('#f_create_payment_1').checked = true;
		let btn = $('#f_account_selector_container').querySelector('button');
		btn.value = btn.value.replace(/&year=\d+/, '') + '&year=' + elm.getAttribute('data-year');
	}

	// Fill the amount paid by the user
	if (amount && create) {
		$('#f_amount').value = g.formatMoney(amount);
	}

Modified src/www/admin/static/scripts/wiki_gallery.js from [b3da297b33] to [5fb6dc7088].

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
        };

        var img = document.createElement('img');
        img.title = 'Cliquer sur l\'image pour aller à la suivante, ou à côté pour fermer';
        img.pos = pos || 0;

        img.onload = function () {
            fig.style.opacity = 1;
            img.style.width = 'initial';
            img.style.height = 'initial';
        };

        img.onclick = function (e) {
            e.stopPropagation();
            img.pos++;







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
        };

        var img = document.createElement('img');
        img.title = 'Cliquer sur l\'image pour aller à la suivante, ou à côté pour fermer';
        img.pos = pos || 0;

        img.onload = function () {
            fig.classList.remove('loading');
            img.style.width = 'initial';
            img.style.height = 'initial';
        };

        img.onclick = function (e) {
            e.stopPropagation();
            img.pos++;
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        openImage(img, items, div);
    }

    function openImage(img, items)
    {
        // Pour animation
        var fig = img.parentNode;
        fig.style.opacity = 0;

        console.log(img);
        var pos = img.pos;

        if (pos >= items.length)
        {
            var div = img.parentNode.parentNode;
            div.style.opacity = 0;
            window.setTimeout(function() { div.parentNode.removeChild(div); }, 500);







|

<







58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73
        openImage(img, items, div);
    }

    function openImage(img, items)
    {
        // Pour animation
        var fig = img.parentNode;
        fig.classList.add('loading');


        var pos = img.pos;

        if (pos >= items.length)
        {
            var div = img.parentNode.parentNode;
            div.style.opacity = 0;
            window.setTimeout(function() { div.parentNode.removeChild(div); }, 500);

Modified src/www/admin/static/styles/00-reset.css from [763506382d] to [b968acbdbc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@charset "UTF-8";

@font-face {
    font-family: 'gicon';
    src: url('../font/garradin.eot?2021');
    src: url('../font/garradin.eot?2021#iefix') format('embedded-opentype'),
        url('../font/garradin.woff?2021') format('woff'),
        url('../font/garradin.woff2?2021') format('woff2'),
        url('../font/garradin.ttf?2021') format('truetype'),
        url('../font/garradin.svg?2021#garradin') format('svg');
    font-weight: normal;
    font-style: normal;
}

body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, 
pre, form, fieldset, input, textarea, p, blockquote, th, td,
figure, article, aside, section, header, footer { 




|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@charset "UTF-8";

@font-face {
    font-family: 'gicon';
    src: url('../font/garradin.eot?2022');
    src: url('../font/garradin.eot?2022#iefix') format('embedded-opentype'),
        url('../font/garradin.woff?2022') format('woff'),
        url('../font/garradin.woff2?2022') format('woff2'),
        url('../font/garradin.ttf?2022') format('truetype'),
        url('../font/garradin.svg?2022#garradin') format('svg');
    font-weight: normal;
    font-style: normal;
}

body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, 
pre, form, fieldset, input, textarea, p, blockquote, th, td,
figure, article, aside, section, header, footer {