Merge branch 'improve' from bohwaz

Améliorations / corrections diverses

See merge request ramoloss/garradin-plugin-facturation!4
This commit is contained in:
Noizette 2021-12-21 02:33:26 +00:00
commit c042452e56
18 changed files with 315 additions and 240 deletions

View File

@ -3,6 +3,7 @@
namespace Garradin\Plugin\Facturation;
use Garradin\DB;
use Garradin\DynamicList;
use Garradin\Plugin;
use Garradin\UserException;
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');
}
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 = [])
{
$db = DB::getInstance();
@ -117,15 +156,15 @@ class Client
return $db->update('plugin_facturation_clients', $data, $db->where('id', (int)$id));
}
public function isDeletable($id)
public function isDeletable($id): bool
{
$f = new Facture;
return $f->hasDocs(0, $id);
return !$f->hasDocs(0, $id);
}
public function delete($id)
{
if($this->isDeletable($id))
if(!$this->isDeletable($id))
{
return false;
}

View File

@ -3,12 +3,22 @@
namespace Garradin\Plugin\Facturation;
use DateTime;
use Garradin\Config;
use Garradin\DB;
use Garradin\DynamicList;
use Garradin\UserException;
use Garradin\Utils;
use Garradin\Services\Services_User;
class Facture
{
const TYPES_NAMES = [
DEVIS => 'Devis',
FACT => 'Facture',
CERFA => 'Reçu fiscal',
COTIS => 'Reçu de cotisation',
];
private $keys = [
'type_facture', // 0 : devis, 1 : facture, 2 : reçu cerfa, 3 : reçu cotis
'numero',
@ -235,6 +245,103 @@ class Facture
return $r;
}
public function list(): DynamicList
{
$id_field = Config::getInstance()->champ_identite;
$columns = [
// Sélectionner cette colonne, mais ne pas la mettre dans la liste des colonnes
// (absence de label)
'id' => [
'select' => 'f.id',
],
'type_facture' => [
],
'receveur_membre' => [
],
'receveur_id' => [
],
// Créer une colonne virtuelle
'type' => [
'label' => 'Type',
'select' => null,
],
'numero' => [
'label' => 'Numéro',
'select' => 'f.numero',
],
'receveur' => [
'label' => 'Receveur',
'select' => sprintf('CASE WHEN receveur_membre THEN u.%s ELSE c.nom END', $id_field),
],
'receveur_adresse' => [
'label' => 'Son adresse',
'select' => 'CASE WHEN receveur_membre THEN u.adresse ELSE c.adresse END',
],
'receveur_ville' => [
'label' => 'Sa ville',
'select' => 'CASE WHEN receveur_membre THEN u.ville ELSE c.ville END',
],
'date_emission' => [
'label' => 'Émission',
],
'date_echeance' => [
'label' => 'Échéance',
],
'reglee' => [
'label' => 'Réglée',
],
'archivee' => [
'label' => 'Archivée',
],
'moyen_paiement' => [
'label' => 'Moyen de paiement',
'select' => 'mp.nom',
],
'contenu' => [
'label' => 'Contenu',
],
'total' => [
'label' => 'Total',
],
];
$tables = 'plugin_facturation_factures AS f
INNER JOIN plugin_facturation_paiement AS mp ON mp.code = f.moyen_paiement
LEFT JOIN membres AS u ON f.receveur_membre = 1 AND u.id = f.receveur_id
LEFT JOIN plugin_facturation_clients AS c ON f.receveur_membre = 0 AND c.id = f.receveur_id';
$list = new DynamicList($columns, $tables);
$list->orderBy('numero', true);
$currency = Config::getInstance()->monnaie;
$list->setModifier(function ($row) use ($currency) {
// Remplir la colonne virtuelle
$row->type = self::TYPES_NAMES[$row->type_facture] ?? null;
$row->reglee = $row->reglee ? 'Réglée' : 'Non';
$row->archivee = $row->archivee ? 'Archivée' : 'Non';
// Remplir le contenu
$content = json_decode((string)$row->contenu);
if ($row->type_facture == COTIS && isset($content->intitule, $content->souscription)) {
$row->contenu = sprintf("Cotisation %s\nSouscrite le %s",
$content->intitule,
Utils::date_fr($content->souscription, 'd/m/Y')
);
}
else {
$row->contenu = implode("\n", array_map(function ($row) use ($currency) {
return sprintf('%s : %s %s', $row->designation, Utils::money_format($row->prix), $currency);
}, (array)$content));
}
});
$list->setPageSize(1000);
return $list;
}
public function edit($id, $data = [])
{
$db = DB::getInstance();
@ -296,7 +403,7 @@ class Facture
throw new UserException("Woopsie, g pô encore implémenté l'usage des membres de l'asso comme clients");
}
return DB::getInstance()->test('plugin_facturation_factures', 'receveur_membre = '. $base .' AND receveur_id = '. $id);
return DB::getInstance()->test('plugin_facturation_factures', 'receveur_membre = ? AND receveur_id = ?', $base, $id);
}
// ** Pour type reçu **
@ -348,5 +455,4 @@ class Facture
{
return DB::getInstance()->delete('plugin_facturation_factures', 'id = '. (int)$id);
}
}

View File

@ -4,10 +4,14 @@
function updateSum(){
var total = 0;
e = document.querySelectorAll('input[name="prix[]"]');
e.forEach( function sum(item, index){
total = total + Number(item.value);
e.forEach((item) => {
if (!item.value) {
return;
}
total += g.getMoneyAsInt(item.value);
});
document.getElementById('total').innerHTML = total.toFixed(2);
document.getElementById('total').innerHTML = g.formatMoney(total);
}
(function () {
@ -21,6 +25,7 @@
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
updateSum();
};
newdiv.getElementsByTagName('input')[0].onkeyup = updateSum;
document.getElementById('Lines').appendChild(newdiv);
}
plus();
@ -40,10 +45,14 @@
function changeTypeSaisie(type)
{
g.toggle(['.type_client', '.type_membre'], false);
if (type) {
g.toggle('.type_' + type, true);
}
}
changeTypeSaisie(document.forms[0].base_receveur.value);
const form = document.querySelector('#f_numero_facture').form;
changeTypeSaisie(form.base_receveur.value);
var inputs = $('input[name="base_receveur"]');
@ -83,7 +92,6 @@
g.toggle(e, true);
g.toggle('p.submit', true);
});
console.log(e.value);
selectType(e.value);
};
});

View File

@ -1,22 +1,22 @@
{include file="admin/_head.tpl" title="Client — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=0}
{include file="%s/templates/_menu_client.tpl"|args:$plugin_root current="client"}
<dl class="describe" style="display: inline-block;">
<dl class="describe">
<dt>Numéro de client</dt>
<dd><p>{$client.id}</p></dd>
<dd>{$client.id}</dd>
<dt>Nom</dt>
<dd><p>{$client.nom|escape|rtrim|nl2br}</p>
<dd>{$client.nom|escape|rtrim|nl2br}
<dt>Adresse</dt>
<dd><p>{$client.adresse|escape|rtrim|nl2br}</p></dd>
<dd>{$client.adresse|escape|rtrim|nl2br}</dd>
<dt>Ville</dt>
<dd><p>{$client.ville|escape|rtrim|nl2br}</p></dd>
<dd>{$client.ville|escape|rtrim|nl2br}</dd>
<dt>Code postal</dt>
<dd><p>{$client.code_postal|escape|rtrim|nl2br}</p></dd>
<dd>{$client.code_postal|escape|rtrim|nl2br}</dd>
<dt>Adresse électronique</dt>
<dd>
@ -68,10 +68,10 @@
<td>{$facture.moyen_paiement}</td>
<td>
{foreach from=$facture.contenu item=contenu}
<p>{$contenu.designation} : {$contenu.prix|escape|money}&nbsp;{$config.monnaie}</p>
{$contenu.designation} : {$contenu.prix|escape|money_currency}
{/foreach}
</td>
<td>{$facture.total|escape|money}&nbsp;{$config.monnaie}</td>
<td>{$facture.total|escape|money_currency}</td>
</tr>
{/foreach}
</tbody>
@ -79,7 +79,7 @@
</table>
</div>
{else}
<h4>Cet utilisateur n'a pas de document associé.</h4>
<p class="alert block">Ce client n'a pas de document associé.</p>
{/if}
{include file="admin/_foot.tpl"}

View File

@ -7,24 +7,18 @@
<fieldset>
<legend>Modifier un client</legend>
<dl>
<dt><label for="f_nom">Nom</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="text" name="nom" id="f_nom" value="{$client.nom}"/></dd>
<dt><label for="f_adresse">Adresse</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="text" name="adresse" id="f_adresse" value="{$client.adresse}"/></dd>
<dt><label for="f_cp">Code postal</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="text" name="code_postal" id="f_cp" value="{$client.code_postal}"/></dd>
<dt><label for="f_ville">Ville</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="text" name="ville" id="f_ville" value="{$client.ville}"/></dd>
<dt><label for="f_tel">Téléphone</label></dt>
<dd><input type="text" name="telephone" id="f_tel" value="{$client.telephone}"/></dd>
<dt><label for="f_email">Adresse mail</label></dt>
<dd><input type="text" name="email" id="f_email" value="{$client.email}"/></dd>
{input type="text" name="nom" label="Nom" required=true source=$client}
{input type="text" name="adresse" label="Adresse" required=true source=$client}
{input type="text" name="code_postal" label="Code postal" required=true source=$client}
{input type="text" name="ville" label="Ville" required=true source=$client}
{input type="tel" name="telephone" label="Téléphone" source=$client}
{input type="email" name="email" label="Adresse e-mail" source=$client}
</dl>
</fieldset>
<p class="submit">
{csrf_field key="edit_client"}
<input type="submit" name="save" value="Enregistrer &rarr;" />
{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}
</p>
</form>

View File

@ -1,30 +1,15 @@
{include file="admin/_head.tpl" title="Supprimer un client — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=0}
{include file="%s/templates/_menu_client.tpl"|args:$plugin_root current="client_supprimer"}
{form_errors}
{if !$deletable}
<form method="post" action="{$self_url}">
<fieldset>
<legend>Supprimer ce client ?</legend>
<h3 class="warning">
Êtes-vous sûr de vouloir supprimer le membre «&nbsp;{$client.nom}&nbsp;» ?
</h3>
<p class="alert">
<strong>Attention</strong> : cette action est irréversible.
</p>
</fieldset>
<p class="submit">
{csrf_field key="delete_client_"|cat:$client.id}
<input type="submit" name="delete" value="Supprimer &rarr;" />
</p>
</form>
<p class="error block">Ce/cette client·e ne peut pas être supprimé·e car des documents lui y sont liés.</p>
{else}
<p>Ce/cette client·e ne peut pas être supprimé·e car des documents lui y sont liés.</p>
{include file="common/delete_form.tpl"
legend="Supprimer ce client ?"
warning="Êtes-vous sûr de vouloir supprimer le client « %s » ?"|args:$client.nom
alert="Attention, cette action est irréversible."}
{/if}
{include file="admin/_foot.tpl"}

View File

@ -1,77 +1,65 @@
{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"}
{form_errors}
{if $list->count()}
{include file="common/dynamic_list_head.tpl"}
<form method="post" action="{$self_url}" class="memberList">
{if !empty($clients)}
<table class="list">
<thead class="userOrder">
{foreach from=$list->iterate() item="row"}
<tr>
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}<td class="check"><input type="checkbox" title="Tout cocher / décocher" /></td>{/if}
{foreach from=$champs key="c" item="champ"}
<td>{if $c == "numero"}#{else}{$champ.title}{/if} </td>
{/foreach}
<td></td>
</tr>
</thead>
<tbody>
{foreach from=$clients item="membre"}
<tr>
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}<td class="check">
{input type="checkbox" name="selected" value=$membre.id default=0}
</td>
<td>{$row.id}</td>
<th><a href="client.php?id={$row.id}">{$row.nom}</a></th>
{foreach from=$row item="value" key="key"}
{if $key == 'id' || $key == 'nom'}
<?php continue; ?>
{/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>
<td>{$value}</td>
{/foreach}
<td class="tabs">
<a class="icn" href="{plugin_url file="client.php"}?id={$membre.id}" title="Fiche membre">👤</a>
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_WRITE)}<a class="icn" href="{plugin_url file="client_modifier.php"}?id={$membre.id}" title="Modifier la fiche membre">✎</a>{/if}
</td>
</tr>
{/foreach}
</tbody>
<td class="actions">
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN)}
{linkbutton shape="delete" href="client_supprimer.php?id=%d"|args:$row.id label="Supprimer"}
{/if}
{if $session->canAccess($session::SECTION_USERS, $session::ACCESS_ADMIN)}
{include file="%s/templates/_list_actions.tpl"|args:$plugin_root colspan=count((array)$champs)}
{linkbutton shape="edit" href="client_modifier.php?id=%d"|args:$row.id label="Modifier"}
{/if}
{linkbutton shape="user" href="client.php?id=%d"|args:$row.id label="Fiche client"}
</td>
</tr>
{/foreach}
</tbody>
</table>
<p class="help">
Export de la liste&nbsp;:
{linkbutton href="?export=csv" label="Export CSV" shape="download"}
{linkbutton href="?export=ods" label="Export tableur" shape="download"}
</p>
{else}
<p class="alert">
<p class="alert block">
Aucun client trouvé.
</p>
{/if}
</form>
{form_errors}
<form method="post" action="{$self_url}">
<fieldset>
<legend>Ajouter un client</legend>
<dl>
<dt><label for="f_nom">Nom</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="nom" name="nom" id="f_nom" value="{form_field name="nom"}"/></dd>
<dt><label for="f_adresse">Adresse</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="text" name="adresse" id="f_adresse" value="{form_field name="adresse"}"/></dd>
<dt><label for="f_cp">Code postal</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="text" name="code_postal" id="f_cp" value="{form_field name="code_postal"}"/></dd>
<dt><label for="f_ville">Ville</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
<dd><input type="text" name="ville" id="f_ville" value="{form_field name="ville"}"/></dd>
<dt><label for="f_tel">Téléphone</label></dt>
<dd><input type="text" name="telephone" id="f_tel" value="{form_field name="telephone"}"/></dd>
<dt><label for="f_email">Adresse mail</label></dt>
<dd><input type="text" name="email" id="f_email" value="{form_field name="email"}"/></dd>
{input type="text" name="nom" label="Nom" required=true}
{input type="text" name="adresse" label="Adresse" required=true}
{input type="text" name="code_postal" label="Code postal" required=true}
{input type="text" name="ville" label="Ville" required=true}
{input type="tel" name="telephone" label="Téléphone"}
{input type="email" name="email" label="Adresse e-mail"}
</dl>
</fieldset>
<p class="submit">
{csrf_field key="add_client"}
<input type="submit" name="add" value="Enregistrer &rarr;" />
{button type="submit" name="add" label="Enregistrer" shape="right" class="main"}
</p>
</form>

View File

@ -51,9 +51,7 @@
<fieldset>
<legend>Factures</legend>
<dl>
<dt><label for="f_footer">Pied de documents/informations légales</label></dt>
<dd><textarea name="footer" id="f_footer" cols="50" rows="5">{form_field data=$plugin.config name=footer}</textarea></dd>
{input type="textarea" class="full-width" rows="10" name="footer" source=$plugin.config label="Pied de document — informations légales" required=true}
</dl>
</fieldset>

View File

@ -9,9 +9,11 @@
{linkbutton shape="download" href="%spdf.php?d&id=%d"|args:$plugin_url,$facture.id label="Télécharger ce document"}
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN)}
{linkbutton shape="delete" href="%sfacture_supprimer.php?id=%d"|args:$plugin_url,$facture.id label="Supprimer ce document"}
{/if}
<div style="margin-top: 1em; width: min-content;">
<embed src="pdf.php?id={$id}" type="application/pdf" width="840px" height="1188px" style="max-width: 900px; border: 1px solid black;">
<embed src="pdf.php?id={$id}" width="840px" height="1188px" style="max-width: 900px; border: 1px solid black;">
</div>
{include file="admin/_foot.tpl"}

View File

@ -58,24 +58,26 @@
<legend>Client</legend>
<dl>
<dt><label>Document adressée à :</label></dt>
<dt><label>Document adressé à :</label></dt>
{if !empty($clients)}
<dd>
{input type="radio" name="base_receveur" value="membre" label="Un·e membre" default=1}
{input type="radio" name="base_receveur" value="client" label="Un·e client·e"}
</dd>
{/if}
</dl>
<div class="type_membre">
<dl class="type_membre">
{input type="select" name="membre" label="Membre" options=$membres required=1}
</div>
</dl>
{if !empty($clients)}
<div class="type_client">
<dl class="type_client">
{input type="select" name="client" label="Client" options=$clients required=1 class="type_client"}
</div>
{/if}
</dl>
{else}
<input type="hidden" name="base_receveur" value="membre" />
{/if}
</fieldset>
<fieldset data-types="t0 t1 t2">

View File

@ -58,24 +58,26 @@
<legend>Client</legend>
<dl>
<dt><label>Document adressée à :</label></dt>
<dt><label>Document adressé à :</label></dt>
{if !empty($clients)}
<dd>
{input type="radio" name="base_receveur" value="membre" source=$doc label="Un·e membre"}
{input type="radio" name="base_receveur" value="client" source=$doc label="Un·e client·e"}
{input type="radio" name="base_receveur" value="membre" label="Un·e membre" default=1 source=$doc}
{input type="radio" name="base_receveur" value="client" label="Un·e client·e" source=$doc}
</dd>
{/if}
<div class="type_membre">
{input type="select" name="membre" label="Membre" options=$membres required=1 source=$doc}
</div>
{if !empty($clients)}
<div class="type_client">
{input type="select" name="client" label="Client" options=$clients required=1 source=$doc class="type_client"}
</div>
{/if}
</dl>
<dl class="type_membre">
{input type="select" name="membre" label="Membre" options=$membres required=1 source=$doc}
</dl>
{if !empty($clients)}
<dl class="type_client">
{input type="select" name="client" label="Client" options=$clients required=1 class="type_client" source=$doc}
</dl>
{else}
<input type="hidden" name="base_receveur" value="membre" />
{/if}
</fieldset>
<fieldset data-types="t0 t1 t2">

View File

@ -3,69 +3,44 @@
{form_errors}
<table class="list">
<thead>
<td>Type</td>
<td>Numéro</td>
<td>Receveur</td>
<td>Son adresse</td>
<td>Sa ville</td>
<td>Emission</td>
<td>Echéance</td>
<td>Réglée</td>
<td>Archivée</td>
<td>Moyen paiement</td>
<td>Contenu</td>
<td>Total</td>
<td></td>
</thead>
<tbody>
{foreach from=$factures item=facture}
<tr>
<td><?php switch($facture->type_facture) {
case 0:
echo 'Devis';
break;
case 1:
echo 'Facture';
break;
case 2:
echo 'Reçu fiscal';
break;
case 3:
echo 'Reçu cotisation';
break;
}
?></td>
<td><a href="{plugin_url file="facture.php"}?id={$facture.id}">{$facture.numero}</a></td>
{if $list->count()}
{include file="common/dynamic_list_head.tpl"}
{foreach from=$list->iterate() item="facture"}
<tr>
<td>{$facture.type}</td>
<th><a href="facture.php?id={$facture.id}">{$facture.numero}</a></th>
{if $facture.receveur_membre}
<td><a href="{$admin_url}membres/fiche.php?id={$facture.receveur.id}">{$facture.receveur->$identite}</a></td>
<td>{link href="!membres/fiche.php?id=%d"|args:$facture.receveur_id label=$facture.receveur}</td>
{else}
<td><a href="{plugin_url file="client.php"}?id={$facture.receveur.id}">{$facture.receveur.nom}</a></td>
<td>{link href="client.php?id=%d"|args:$facture.receveur_id label=$facture.receveur}</td>
{/if}
<td>{$facture.receveur.adresse}</td>
<td>{$facture.receveur.ville}</td>
<td>{$facture.receveur_adresse}</td>
<td>{$facture.receveur_ville}</td>
<td>{$facture.date_emission|date:'d/m/Y'}</td>
<td>{$facture.date_echeance|date:'d/m/Y'}</td>
<td><?= $facture->reglee?'Réglée':'Non' ?></td>
<td><?= $facture->archivee?'Archivée':'Non' ?></td>
<td>{$facture.reglee}</td>
<td>{$facture.archivee}</td>
<td>{$facture.moyen_paiement}</td>
<td>
{if $facture.type_facture == 3}
<p>Cotisation {$facture.contenu.intitule}</p>
<p>Souscrite le {$facture.contenu.souscription|date_short}</p>
{else}
{foreach from=$facture.contenu item=contenu}
<p>{$contenu.designation} : {$contenu.prix|escape|money:false}&nbsp;{$config.monnaie}</p>
{/foreach}
{/if}
<td>{$facture.contenu|escape|nl2br}</td>
<td>{$facture.total|escape|money_currency}</td>
<td class="actions">
{linkbutton shape="download" href="pdf.php?id=%d&d"|args:$facture.id label="Télécharger"}
{linkbutton shape="menu" href="facture.php?id=%d"|args:$facture.id label="Voir"}
</td>
<td>{$facture.total|escape|money}&nbsp;{$config.monnaie}</td>
{* <td>{linkbutton shape="delete" href="%sfacture_supprimer.php?id=%d"|args:$plugin_url,$facture.id label="Supprimer"}</td> *}
</tr>
{/foreach}
</tbody>
</tr>
{/foreach}
</tbody>
</table>
<p class="help">
Export de la liste&nbsp;:
{linkbutton href="?export=csv" label="Export CSV" shape="download"}
{linkbutton href="?export=ods" label="Export tableur" shape="download"}
</p>
{else}
<p class="help">Aucun document, vous pouvez commencer par {link href="facture_ajouter.php" label="créer un nouveau document"}.</p>
{/if}
{include file="admin/_foot.tpl"}

View File

@ -17,24 +17,13 @@ if (!$client)
throw new UserException("Ce client n'existe pas.");
}
if (f('delete'))
{
$form->check('delete_client_'.$c->id);
$csrf_key = 'delete_client_'.$c->id;
if (!$form->hasErrors())
{
try {
$form->runIf('delete', function () use ($client, $c) {
$client->delete($c->id);
Utils::redirect(PLUGIN_URL . 'clients.php');
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
}
}
}, $csrf_key, PLUGIN_URL . 'clients.php');
$tpl->assign('deletable', $client->isDeletable($id));
$tpl->assign('client', $c);
$tpl->assign(compact('csrf_key'));
$tpl->display(PLUGIN_ROOT . '/templates/client_supprimer.tpl');

View File

@ -40,17 +40,9 @@ if(f('add'))
}
$tpl->assign('clients', $client->listAll());
$tpl->assign('champs',
[
'id' => 'id',
'nom' => 'Nom',
'adresse' => 'Adresse',
'code_postal' => 'Code postal',
'ville' => 'Ville',
'telephone' => 'Numéro de téléphone',
'email' => 'Adresse mail'
]
);
$list = $client->list();
$list->loadFromQueryString();
$tpl->assign(compact('list'));
$tpl->display(PLUGIN_ROOT . '/templates/clients.tpl');

View File

@ -119,7 +119,7 @@ if (f('select_cotis'))
{
$form->check('add_cotis_1',[
'numero_facture' => 'required|string',
'date_emission' => 'required|date',
'date_emission' => 'required|date_format:d/m/Y',
'membre_cotis' => 'required|numeric',
]);
@ -129,7 +129,7 @@ elseif (f('add_cotis'))
{
$form->check('add_cotis_2',[
'numero_facture' => 'required|string',
'date_emission' => 'required|date',
'date_emission' => 'required|date_format:d/m/Y',
'membre_cotis' => 'required|numeric',
'cotisation' => 'required',
]);
@ -216,6 +216,9 @@ $tpl->assign('membre_id', f('membre') ?: -1);
$tpl->assign(compact('liste', 'radio', 'step'));
$designations = [];
$prix = [];
// C'est un peu l'équivalent de form_field, mais j'avais écrit ça avant
// et oulala, c'est un peu complexe, faudrait réfléchir keskivomieux
$from_user = false;

View File

@ -6,18 +6,10 @@ require_once __DIR__ . '/_inc.php';
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);
$membres = new Membres;
$tpl->assign('moyens_paiement', $facture->listMoyensPaiement());
$list = $facture->list();
$list->loadFromQueryString();
foreach($factures = $facture->listAll() as $k=>$f)
{
$factures[$k]->receveur = $f->receveur_membre? $membres->get($f->receveur_id) : $client->get($f->receveur_id);
$factures[$k]->moyen_paiement = $facture->getMoyenPaiement($f->moyen_paiement);
}
$tpl->assign('identite', $identite);
$tpl->assign('factures', $factures);
$tpl->assign('clients', $client->listAll());
$tpl->assign(compact('list'));
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl');

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 KiB

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 72 KiB