Overview
Comment:Widget de simplification de la gestion des boutons avec icône
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: b9f5fcdd5ff74398e4da5a91f93a6954998c0246
User & Date: bohwaz on 2020-04-23 23:04:08
Other Links: branch diff | manifest | tags
Context
2020-04-24
02:07
Suppression de la colonne "parent", on n'utilise plus que le code pour classer les comptes, il n'y a plus de notion de hiérarchie check-in: 98f1c451f5 user: bohwaz tags: dev
2020-04-23
23:04
Widget de simplification de la gestion des boutons avec icône check-in: b9f5fcdd5f user: bohwaz tags: dev
23:02
Simplifier les positions des comptes (en anglais) check-in: a3648b395f user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Template.php from [e722f81cb4] to [b681c34e8f].

69
70
71
72
73
74
75


76
77
78
79
80
81
82
...
156
157
158
159
160
161
162









163
164
165
166
167
168
169
170
171
172
173
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
		$this->register_function('pagination', [$this, 'pagination']);
		$this->register_function('format_droits', [$this, 'formatDroits']);

		$this->register_function('csrf_field', function ($params) {
			return Form::tokenHTML($params['key']);
		});



		$this->register_modifier('strlen', 'strlen');
		$this->register_modifier('dump', ['KD2\ErrorManager', 'dump']);
		$this->register_modifier('get_country_name', ['Garradin\Utils', 'getCountryName']);
		$this->register_modifier('format_sqlite_date_to_french', ['Garradin\Utils', 'sqliteDateToFrench']);
		$this->register_modifier('format_bytes', ['Garradin\Utils', 'format_bytes']);
		$this->register_modifier('format_tel', [$this, 'formatPhoneNumber']);
		$this->register_modifier('abs', 'abs');
................................................................................
		if (!$params['if'])
		{
			return '';
		}

		return '<p class="error">' . $this->escape($params['message']) . '</p>';
	}










	protected function formInput(array $params)
	{
		static $keep_attributes = ['pattern', 'max', 'min', 'step', 'title', 'name', 'cols', 'rows'];
		extract($params, \EXTR_SKIP);

		if (!isset($name, $type)) {
			throw new \InvalidArgumentException('Missing name or type');
		}

		$current_value = null;
................................................................................

		$out = sprintf('<dt><label for="f_%s">%s</label>%s</dt>', $name, $this->escape($label), $required_label);

		if (isset($help)) {
			$out .= sprintf('<dd class="help">%s</dd>', $this->escape($help));
		}

		$attributes = array_intersect_key($params, $keep_attributes);
		$attributes['id'] = 'f_' . $name;

		// Create attributes string
		if (array_key_exists('required', $params)) {
			$attributes['required'] = 'required';
		}








>
>







 







>
>
>
>
>
>
>
>
>



|







 







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
		$this->register_function('pagination', [$this, 'pagination']);
		$this->register_function('format_droits', [$this, 'formatDroits']);

		$this->register_function('csrf_field', function ($params) {
			return Form::tokenHTML($params['key']);
		});

		$this->register_function('icon', [$this, 'widgetIcon']);

		$this->register_modifier('strlen', 'strlen');
		$this->register_modifier('dump', ['KD2\ErrorManager', 'dump']);
		$this->register_modifier('get_country_name', ['Garradin\Utils', 'getCountryName']);
		$this->register_modifier('format_sqlite_date_to_french', ['Garradin\Utils', 'sqliteDateToFrench']);
		$this->register_modifier('format_bytes', ['Garradin\Utils', 'format_bytes']);
		$this->register_modifier('format_tel', [$this, 'formatPhoneNumber']);
		$this->register_modifier('abs', 'abs');
................................................................................
		if (!$params['if'])
		{
			return '';
		}

		return '<p class="error">' . $this->escape($params['message']) . '</p>';
	}

	protected function widgetIcon(array $params): string
	{
		if (empty($params['href'])) {
			return sprintf('<b class="icn">%s</b>', Utils::iconUnicode($params['shape']));
		}

		return sprintf('<a href="%s" class="icn" title="%s">%s</a>', $this->escape(ADMIN_URL . $params['href']), $this->escape($params['label']), Utils::iconUnicode($params['shape']));
	}

	protected function formInput(array $params)
	{
		static $keep_attributes = ['pattern', 'max', 'min', 'step', 'title', 'name', 'cols', 'rows', 'maxlength'];
		extract($params, \EXTR_SKIP);

		if (!isset($name, $type)) {
			throw new \InvalidArgumentException('Missing name or type');
		}

		$current_value = null;
................................................................................

		$out = sprintf('<dt><label for="f_%s">%s</label>%s</dt>', $name, $this->escape($label), $required_label);

		if (isset($help)) {
			$out .= sprintf('<dd class="help">%s</dd>', $this->escape($help));
		}

		$attributes = array_intersect_key($params, array_flip($keep_attributes));
		$attributes['id'] = 'f_' . $name;

		// Create attributes string
		if (array_key_exists('required', $params)) {
			$attributes['required'] = 'required';
		}

Modified src/include/lib/Garradin/Utils.php from [a6b8cfab15] to [6ab057f79b].

824
825
826
827
828
829
830
831






































            {
                $raw_headers .= sprintf("%s: %s\r\n", $name, $value);
            }

            return \mail($to, $subject, $content, $raw_headers);
        }
    }
}













































|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
            {
                $raw_headers .= sprintf("%s: %s\r\n", $name, $value);
            }

            return \mail($to, $subject, $content, $raw_headers);
        }
    }

    static public function iconUnicode(string $shape): string
    {
        switch ($shape) {
            case 'up': return '↑';
            case 'down': return '↓';
            case 'export': return '↷';
            case 'reset': return '↺';
            case 'upload': return '⇑';
            case 'download': return '⇓';
            case 'home': return '⌂';
            case 'print': return '⎙';
            case 'star': return '★';
            case 'check': return '☑';
            case 'settings': return '☸';
            case 'alert': return '⚠';
            case 'mail': return '✉';
            case 'edit': return '✎';
            case 'delete': return '✘';
            case 'help': return '❓';
            case 'plus': return '➕';
            case 'minus': return '➖';
            case 'logout': return '⤝';
            case 'eye-off': return '⤫';
            case 'menu': return '𝍢';
            case 'eye': return '👁';
            case 'user': return '👤';
            case 'users': return '👪';
            case 'attach': return '📎';
            case 'search': return '🔍';
            case 'lock': return '🔒';
            case 'unlock': return '🔓';
            case 'folder': return '🗀';
            case 'document': return '🗅';
            default:
                throw new \InvalidArgumentException('Unknown icon shape: ' . $shape);
        }
    }
}

Modified src/templates/admin/acc/plans/accounts/index.tpl from [707bc79df3] to [dec2e48b0b].

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
{include file="admin/_head.tpl" title=$plan.label current="acc/plans"}

<ul class="actions">
	<li><a href="{$admin_url}acc/plans/">Gérer les plans</a></li>
	<li><a href="{$admin_url}acc/plans/import.php">Import / export</a></li>
	<li class="current"><a href="{$admin_url}acc/plans/accounts/?id={$plan.id}">Modifier le plan</a></li>




</ul>

{if count($accounts)}
	<table class="list accounts">
		<thead>
			<td>Code</td>
			<th>Libellé</th>
			<td>Position</td>
			<td></td>
			<td></td>
			<td></td>
		</thead>
		<tbody>
			{foreach from=$accounts item="item"}
				<tr class="account-level-<?=strlen($item->code)?>">
					<td>{$item.code}</td>
					<th>{$item.label}</th>
					<td>{$item.position|account_position}</td>


					<td>{$item.type|account_type}</td>
					<td>{if $item.bookmark}Favori{/if}</td>

					<td class="actions">
						{if !$item.user}
							<a class="icn" href="{$admin_url}acc/plans/delete.php?id={$item.id}" title="Supprimer">✘</a>

						{/if}
						<a class="icn" href="{$admin_url}acc/plans/edit.php?id={$item.id}" title="Modifier">✎</a>

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

<form method="post" action="{$self_url_no_qs}">
	<fieldset>
		<legend>Ajouter un compte au plan comptable</legend>
		<dl>

			{input type="text" name="label" label="Libellé" required=1}
		</dl>
		<p class="submit">
			<input type="submit" value="Créer &rarr;" />
		</p>
	</fieldset>
</form>

{include file="admin/_foot.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
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
{include file="admin/_head.tpl" title=$plan.label current="acc/plans"}

<ul class="actions">
	<li><a href="{$admin_url}acc/plans/">Gérer les plans</a></li>

	<li class="current"><a href="{$admin_url}acc/plans/accounts/?id={$plan.id}">Modifier le plan</a></li>
	<li><a href="{$admin_url}acc/plans/export.php?id={$plan.id}">Exporter ce plan en CSV</a></li>
	<li><a href="{$admin_url}acc/plans/import.php?id={$plan.id}">Importer</a></li>
	<li><a href="{$admin_url}acc/plans/delete.php?id={$plan.id}">Supprimer</a></li>
	<li><a href="{$admin_url}acc/plans/reset.php?id={$plan.id}">Remettre à zéro</a></li>
</ul>

{if count($accounts)}
	<table class="list accounts">
		<thead>
			<td>Code</td>
			<th>Libellé</th>
			<td>Position</td>
			<td></td>
			<td></td>

		</thead>
		<tbody>
			{foreach from=$accounts item="item"}
				<tr class="account-level-<?=strlen($item->code)?>">
					<td>{$item.code}</td>
					<th>{$item.label}</th>
					<td>{$item.position|account_position}</td>
					<td>
						{if $item.type == $item::TYPE_BOOKMARK}{icon shape="star"}{/if}
						{$item.type|account_type}

					</td>
					<td class="actions">
						{if $item.user}

							{icon shape="delete" label="Supprimer" href="acc/plans/accounts/delete.php?id=%d"|args:$item.id}
						{/if}

						{icon shape="edit" label="Modifier" href="acc/plans/accounts/edit.php?id=%d"|args:$item.id}
					</td>
				</tr>
			{/foreach}
		</tbody>
	</table>
{/if}

<form method="post" action="{$self_url_no_qs}">
	<fieldset>
		<legend>Ajouter un compte au plan comptable</legend>
		<dl>
			{input type="text" name="code" label="Code" required=1 pattern="\d+" maxlength=8 help="Utilisé pour ordonner la liste des comptes. Seuls les chiffres sont acceptés."}
			{input type="text" name="label" label="Libellé" required=1}
		</dl>
		<p class="submit">
			<input type="submit" value="Créer &rarr;" />
		</p>
	</fieldset>
</form>

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

Modified src/templates/admin/acc/plans/index.tpl from [c2e9712d2e] to [79693cc5d5].

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

24
25


26
27

28
29
30
31
32
33
34
{include file="admin/_head.tpl" title="Gestion des plans comptables" current="acc/plans"}

<ul class="actions">
	<li class="current"><a href="{$admin_url}acc/plans/">Gérer les plans</a></li>
	<li><a href="{$admin_url}acc/plans/import.php">Import / export</a></li>
	<li><a href="{$admin_url}acc/plans/reset.php">Remise à zéro</a></li>
</ul>

{if count($list)}
    <table class="list">
        <thead>
        	<td>Pays</td>
            <th>Libellé</th>
................................................................................
        </thead>
        <tbody>
            {foreach from=$list item="item"}
                <tr>
                	<td>{$item.country|get_country_name}</td>
                    <th><a href="{$admin_url}acc/plans/accounts/?id={$item.id}">{$item.label}</a> <em>{if $item.code}(officiel){else}(copie){/if}</em></th>
                    <td class="actions">
                    	<a class="icn" href="{$admin_url}acc/plans/accounts/?id={$item.id}" title="Gérer les comptes">𝍢</a>
                        <a class="icn" href="{$admin_url}acc/plans/edit.php?id={$item.id}" title="Renommer le plan comptable">✎</a>

                        {if empty($item.code)}
                        	<a class="icn" href="{$admin_url}acc/plans/delete.php?id={$item.id}" title="Supprimer le plan comptable">✘</a>


                        {else}
                        	<a class="icn" href="{$admin_url}acc/plans/reset.php?id={$item.id}" title="Remettre à zéro">⤝</a>

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




|
<







 







|
|
>

<
>
>

<
>







1
2
3
4
5

6
7
8
9
10
11
12
..
14
15
16
17
18
19
20
21
22
23
24

25
26
27

28
29
30
31
32
33
34
35
{include file="admin/_head.tpl" title="Gestion des plans comptables" current="acc/plans"}

<ul class="actions">
	<li class="current"><a href="{$admin_url}acc/plans/">Gérer les plans</a></li>
	<li><a href="{$admin_url}acc/plans/import.php">Importer</a></li>

</ul>

{if count($list)}
    <table class="list">
        <thead>
        	<td>Pays</td>
            <th>Libellé</th>
................................................................................
        </thead>
        <tbody>
            {foreach from=$list item="item"}
                <tr>
                	<td>{$item.country|get_country_name}</td>
                    <th><a href="{$admin_url}acc/plans/accounts/?id={$item.id}">{$item.label}</a> <em>{if $item.code}(officiel){else}(copie){/if}</em></th>
                    <td class="actions">
                        {icon shape="menu" label="Gérer les comptes" href="acc/plans/accounts/?id=%d"|args:$item.id}
                        {icon shape="edit" label="Renommer" href="acc/plans/edit.php?id=%d"|args:$item.id}
                        {icon shape="export" label="Exporter en CSV" href="acc/plans/export.php?id=%d"|args:$item.id}
                        {if empty($item.code)}

                            {icon shape="upload" label="Importer" href="acc/plans/import.php?id=%d"|args:$item.id}
                            {icon shape="delete" label="Supprimer" href="acc/plans/delete.php?id=%d"|args:$item.id}
                        {else}

                            {icon shape="reset" label="Remettre à zéro" href="acc/plans/reset.php?id=%d"|args:$item.id}
                        {/if}
                    </td>
                </tr>
            {/foreach}
        </tbody>
    </table>
{/if}