Liste dynamique triable des clients + export CSV/ODS
This commit is contained in:
parent
6db516f5b2
commit
440b2e3e66
|
@ -3,6 +3,7 @@
|
||||||
namespace Garradin\Plugin\Facturation;
|
namespace Garradin\Plugin\Facturation;
|
||||||
|
|
||||||
use Garradin\DB;
|
use Garradin\DB;
|
||||||
|
use Garradin\DynamicList;
|
||||||
use Garradin\Plugin;
|
use Garradin\Plugin;
|
||||||
use Garradin\UserException;
|
use Garradin\UserException;
|
||||||
use Garradin\Utils;
|
use Garradin\Utils;
|
||||||
|
@ -103,6 +104,44 @@ class Client
|
||||||
return DB::getInstance()->get('SELECT *, strftime(\'%s\', date_creation) AS date_creation FROM plugin_facturation_clients');
|
return DB::getInstance()->get('SELECT *, strftime(\'%s\', date_creation) AS date_creation FROM plugin_facturation_clients');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function list(): DynamicList
|
||||||
|
{
|
||||||
|
$columns = [
|
||||||
|
'id' => [
|
||||||
|
'label' => 'Numéro',
|
||||||
|
],
|
||||||
|
'nom' => [
|
||||||
|
'label' => 'Nom',
|
||||||
|
],
|
||||||
|
'adresse' => [
|
||||||
|
'label' => 'Adresse',
|
||||||
|
],
|
||||||
|
'code_postal' => [
|
||||||
|
'label' => 'Code postal',
|
||||||
|
],
|
||||||
|
'ville' => [
|
||||||
|
'label' => 'Ville',
|
||||||
|
],
|
||||||
|
'telephone' => [
|
||||||
|
'label' => 'Téléphone',
|
||||||
|
],
|
||||||
|
'email' => [
|
||||||
|
'label' => 'E-Mail',
|
||||||
|
],
|
||||||
|
'nb_documents' => [
|
||||||
|
'label' => 'Nombre de documents',
|
||||||
|
'select' => '(SELECT COUNT(*) FROM plugin_facturation_factures WHERE receveur_id = c.id)',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$tables = 'plugin_facturation_clients AS c';
|
||||||
|
|
||||||
|
$list = new DynamicList($columns, $tables);
|
||||||
|
$list->orderBy('id', false);
|
||||||
|
$list->setPageSize(1000);
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
public function edit($id, $data = [])
|
public function edit($id, $data = [])
|
||||||
{
|
{
|
||||||
$db = DB::getInstance();
|
$db = DB::getInstance();
|
||||||
|
|
|
@ -1,65 +1,45 @@
|
||||||
{include file="admin/_head.tpl" title="Clients — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=1}
|
{include file="admin/_head.tpl" title="Clients — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=1}
|
||||||
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="clients"}
|
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="clients"}
|
||||||
|
|
||||||
{form_errors}
|
{if $list->count()}
|
||||||
|
{include file="common/dynamic_list_head.tpl"}
|
||||||
|
|
||||||
|
{foreach from=$list->iterate() item="row"}
|
||||||
<form method="post" action="{$self_url}" class="memberList">
|
|
||||||
|
|
||||||
{if !empty($clients)}
|
|
||||||
<table class="list">
|
|
||||||
<thead class="userOrder">
|
|
||||||
<tr>
|
<tr>
|
||||||
{* FIXME
|
<td>{$row.id}</td>
|
||||||
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
|
<th><a href="client.php?id={$row.id}">{$row.nom}</a></th>
|
||||||
<td class="check"><input type="checkbox" title="Tout cocher / décocher" /></td>
|
|
||||||
|
{foreach from=$row item="value" key="key"}
|
||||||
|
{if $key == 'id' || $key == 'nom'}
|
||||||
|
<?php continue; ?>
|
||||||
{/if}
|
{/if}
|
||||||
*}
|
<td>{$value}</td>
|
||||||
{foreach from=$champs key="c" item="champ"}
|
|
||||||
<td>{if $c == "numero"}#{else}{$champ.title}{/if} </td>
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
<td></td>
|
<td class="actions">
|
||||||
</tr>
|
{linkbutton shape="user" href="client.php?id=%d"|args:$row.id label="Fiche client"}
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{foreach from=$clients item="membre"}
|
|
||||||
<tr>
|
|
||||||
{* FIXME
|
|
||||||
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
|
|
||||||
<td class="check">
|
|
||||||
{input type="checkbox" name="selected" value=$membre.id default=0}
|
|
||||||
</td>
|
|
||||||
{/if}
|
|
||||||
*}
|
|
||||||
{foreach from=$champs key="c" item="cfg"}
|
|
||||||
<td>
|
|
||||||
{if $c == 'nom'}<a href="{plugin_url file="client.php"}?id={$membre.id}">{/if}
|
|
||||||
{$membre->$c}
|
|
||||||
{if $c == 'nom'}</a>{/if}
|
|
||||||
</td>
|
|
||||||
{/foreach}
|
|
||||||
<td class="tabs">
|
|
||||||
{linkbutton shape="user" href="client.php?id=%d"|args:$membre.id label="Fiche client"}
|
|
||||||
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)}
|
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)}
|
||||||
{linkbutton shape="edit" href="client_modifier.php?id=%d"|args:$membre.id label="Modifier"}
|
{linkbutton shape="edit" href="client_modifier.php?id=%d"|args:$row.id label="Modifier"}
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
{* FIXME
|
|
||||||
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
|
|
||||||
{include file="%s/templates/_list_actions.tpl"|args:$plugin_root colspan=count((array)$champs)}
|
|
||||||
{/if}
|
|
||||||
*}
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<p class="help">
|
||||||
|
Export de la liste :
|
||||||
|
{linkbutton href="?export=csv" label="Export CSV" shape="download"}
|
||||||
|
{linkbutton href="?export=ods" label="Export tableur" shape="download"}
|
||||||
|
</p>
|
||||||
|
|
||||||
{else}
|
{else}
|
||||||
<p class="alert block">
|
<p class="alert block">
|
||||||
Aucun client trouvé.
|
Aucun client trouvé.
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
</form>
|
{form_errors}
|
||||||
|
|
||||||
<form method="post" action="{$self_url}">
|
<form method="post" action="{$self_url}">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|
|
@ -40,17 +40,9 @@ if(f('add'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$tpl->assign('clients', $client->listAll());
|
$list = $client->list();
|
||||||
$tpl->assign('champs',
|
$list->loadFromQueryString();
|
||||||
[
|
|
||||||
'id' => 'id',
|
$tpl->assign(compact('list'));
|
||||||
'nom' => 'Nom',
|
|
||||||
'adresse' => 'Adresse',
|
|
||||||
'code_postal' => 'Code postal',
|
|
||||||
'ville' => 'Ville',
|
|
||||||
'telephone' => 'Numéro de téléphone',
|
|
||||||
'email' => 'Adresse mail'
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/clients.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/clients.tpl');
|
||||||
|
|
Loading…
Reference in New Issue