Compare commits
2 commits
cb3d201aec
...
79b3a72cca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79b3a72cca | ||
|
|
a80bebcc4e |
9 changed files with 78 additions and 26 deletions
|
|
@ -69,7 +69,10 @@ if ( !$target ) {
|
||||||
throw new UserException("Ce document n'existe pas.");
|
throw new UserException("Ce document n'existe pas.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($f->archivee)
|
||||||
|
{
|
||||||
|
throw new UserException("Ce document est archivé, vous n'avez pas le droit de le modifier");
|
||||||
|
}
|
||||||
// Traitement
|
// Traitement
|
||||||
$data=[];
|
$data=[];
|
||||||
$form->runIf(f('save') && !$form->hasErrors(),
|
$form->runIf(f('save') && !$form->hasErrors(),
|
||||||
|
|
@ -227,7 +230,6 @@ if (! $form->hasErrors())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage
|
// Affichage
|
||||||
|
|
||||||
if ($target)
|
if ($target)
|
||||||
{
|
{
|
||||||
$doc = null;
|
$doc = null;
|
||||||
|
|
@ -274,6 +276,7 @@ else
|
||||||
$doc['type'] = $f->type_facture;
|
$doc['type'] = $f->type_facture;
|
||||||
$doc['numero_facture'] = $f->numero;
|
$doc['numero_facture'] = $f->numero;
|
||||||
$doc['reglee'] = $f->reglee;
|
$doc['reglee'] = $f->reglee;
|
||||||
|
$doc['archivee'] = $f->archivee;
|
||||||
$doc['base_receveur'] = $f->receveur_membre?'membre':'client';
|
$doc['base_receveur'] = $f->receveur_membre?'membre':'client';
|
||||||
$doc['client'] = $f->receveur_id;
|
$doc['client'] = $f->receveur_id;
|
||||||
$doc['membre'] = $f->receveur_id;
|
$doc['membre'] = $f->receveur_id;
|
||||||
|
|
@ -294,6 +297,7 @@ else
|
||||||
|
|
||||||
$radio['type'] = f('type')??$doc['type'];
|
$radio['type'] = f('type')??$doc['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl->assign('types_details', $facture->types);
|
$tpl->assign('types_details', $facture->types);
|
||||||
|
|
||||||
$tpl->assign('client_id', f('client') ?: -1);
|
$tpl->assign('client_id', f('client') ?: -1);
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,12 @@ if (!$f)
|
||||||
throw new UserException("Ce document n'existe pas.");
|
throw new UserException("Ce document n'existe pas.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$archive = $f->archivee;
|
||||||
$tpl->assign('type', $f->type_facture);
|
$tpl->assign('type', $f->type_facture);
|
||||||
$tpl->assign('facture', $f);
|
$tpl->assign('facture', $f);
|
||||||
$tpl->assign('id', $id);
|
$tpl->assign('id', $id);
|
||||||
$tpl->assign('footer', $plugin->getConfig('footer')?:'');
|
$tpl->assign('footer', $plugin->getConfig('footer')?:'');
|
||||||
$tpl->assign('siret_asso', $plugin->getConfig('siret_asso')?:'');
|
$tpl->assign('siret_asso', $plugin->getConfig('siret_asso')?:'');
|
||||||
|
$tpl->assign('archive', $archive);
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/facture.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/facture.tpl');
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,20 @@ require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);
|
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ);
|
||||||
|
|
||||||
|
$form->runIf(f('archiver') && !$form->hasErrors(),
|
||||||
|
function () use($facture)
|
||||||
|
{
|
||||||
|
foreach(f('selected') as $f) {
|
||||||
|
$facture->archiver($f);
|
||||||
|
}
|
||||||
|
|
||||||
$list = $facture->list();
|
}, 'archiver_factures');
|
||||||
|
|
||||||
|
|
||||||
|
$archive = isset($_GET['archive']) && $_GET['archive'] == 1;
|
||||||
|
$list = $facture->list(! $archive);
|
||||||
$list->loadFromQueryString();
|
$list->loadFromQueryString();
|
||||||
$list->setPageSize(50);
|
$list->setPageSize(50);
|
||||||
|
|
||||||
$tpl->assign(compact('list'));
|
$tpl->assign(compact('list', 'archive'));
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl');
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ class Facture
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function list(): DynamicList
|
public function list($all = true): DynamicList
|
||||||
{
|
{
|
||||||
$id_field = \Paheko\Users\DynamicFields::getNameFieldsSQL('u');
|
$id_field = \Paheko\Users\DynamicFields::getNameFieldsSQL('u');
|
||||||
$plugin_name = preg_replace('/^.*\/(\w+)\/$/', '${1}', \Paheko\PLUGIN_ADMIN_URL);
|
$plugin_name = preg_replace('/^.*\/(\w+)\/$/', '${1}', \Paheko\PLUGIN_ADMIN_URL);
|
||||||
|
|
@ -343,6 +343,9 @@ class Facture
|
||||||
'receveur_id' => [
|
'receveur_id' => [
|
||||||
],
|
],
|
||||||
// Créer une colonne virtuelle
|
// Créer une colonne virtuelle
|
||||||
|
'select' => [
|
||||||
|
'label' => '',
|
||||||
|
],
|
||||||
'type' => [
|
'type' => [
|
||||||
'label' => 'Type',
|
'label' => 'Type',
|
||||||
'select' => null,
|
'select' => null,
|
||||||
|
|
@ -376,9 +379,6 @@ class Facture
|
||||||
'reglee' => [
|
'reglee' => [
|
||||||
'label' => 'Réglée',
|
'label' => 'Réglée',
|
||||||
],
|
],
|
||||||
'archivee' => [
|
|
||||||
'label' => 'Archivée',
|
|
||||||
],
|
|
||||||
'moyen_paiement' => [
|
'moyen_paiement' => [
|
||||||
'label' => 'Moyen de paiement',
|
'label' => 'Moyen de paiement',
|
||||||
'select' => 'mp.nom',
|
'select' => 'mp.nom',
|
||||||
|
|
@ -396,7 +396,12 @@ class Facture
|
||||||
LEFT JOIN users AS u ON f.receveur_membre = 1 AND u.id = f.receveur_id
|
LEFT JOIN users 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';
|
LEFT JOIN plugin_facturation_clients AS c ON f.receveur_membre = 0 AND c.id = f.receveur_id';
|
||||||
|
|
||||||
$list = new DynamicList($columns, $tables);
|
if ($all) {
|
||||||
|
$where = "f.archivee != TRUE";
|
||||||
|
} else {
|
||||||
|
$where = "f.archivee == TRUE";
|
||||||
|
}
|
||||||
|
$list = new DynamicList($columns, $tables, $where);
|
||||||
$list->orderBy('date_emission', true);
|
$list->orderBy('date_emission', true);
|
||||||
|
|
||||||
$currency = Config::getInstance()->monnaie;
|
$currency = Config::getInstance()->monnaie;
|
||||||
|
|
@ -405,7 +410,6 @@ class Facture
|
||||||
// Remplir la colonne virtuelle
|
// Remplir la colonne virtuelle
|
||||||
$row->type = self::TYPES_NAMES[$row->type_facture] ?? null;
|
$row->type = self::TYPES_NAMES[$row->type_facture] ?? null;
|
||||||
$row->reglee = $row->reglee ? 'Réglée' : 'Non';
|
$row->reglee = $row->reglee ? 'Réglée' : 'Non';
|
||||||
$row->archivee = $row->archivee ? 'Archivée' : 'Non';
|
|
||||||
|
|
||||||
// Remplir le contenu
|
// Remplir le contenu
|
||||||
$content = json_decode((string)$row->contenu);
|
$content = json_decode((string)$row->contenu);
|
||||||
|
|
@ -554,4 +558,19 @@ class Facture
|
||||||
{
|
{
|
||||||
return DB::getInstance()->delete('plugin_facturation_factures', 'id = '. (int)$id);
|
return DB::getInstance()->delete('plugin_facturation_factures', 'id = '. (int)$id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function archiver($id)
|
||||||
|
{
|
||||||
|
$f = $this->get($id);
|
||||||
|
$f->archivee = 1;
|
||||||
|
$f->date_emission = $f->date_emission->format('d/m/Y');
|
||||||
|
$f->date_echeance = $f->date_echeance->format('d/m/Y');
|
||||||
|
$id = $f->id;
|
||||||
|
unset($f->id);
|
||||||
|
$datas = (array)$f;
|
||||||
|
$this->_checkFields($datas);
|
||||||
|
$datas["id"] = $id;
|
||||||
|
$db = DB::getInstance();
|
||||||
|
return $db->update('plugin_facturation_factures', $datas, $db->where('id', (int)$id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
name="Facturation"
|
name="Facturation"
|
||||||
description="Permet d'éditer des factures et devis à ses membres ainsi qu'à une base de clients supplémentaire."
|
description="Permet d'éditer des factures et devis à ses membres ainsi qu'à une base de clients supplémentaire."
|
||||||
author="zou ; adapté par jce"
|
author="zou ; adapté par Jean-Christophe Engel"
|
||||||
url="https://git.roflcopter.fr/lesanges/paheko-plugin-facturation"
|
url="https://gitea.zaclys.com/lesanges/facturation"
|
||||||
version="0.16"
|
version="0.17"
|
||||||
menu=true
|
menu=true
|
||||||
restrict_section="accounting"
|
restrict_section="accounting"
|
||||||
restrict_level="read"
|
restrict_level="read"
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
{input type="checkbox" name="reglee" value="1" label="Réglée" source=$doc data-types="t1"}
|
{input type="checkbox" name="reglee" value="1" label="Réglée" source=$doc data-types="t1"}
|
||||||
<div data-types="t0 t1 t2">
|
<div data-types="t0 t1 t2">
|
||||||
{input type="checkbox" name="archivee" value="1" label="Archivée" source=$doc disabled="disabled"}
|
{input type="checkbox" name="archivee" value="1" label="Archivée" source=$doc}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<li{if $current == 'facture'} class="current"{/if}><a href="{$plugin_admin_url}facture_ajouter.php">Nouveau document</a></li>
|
<li{if $current == 'facture'} class="current"{/if}><a href="{$plugin_admin_url}facture_ajouter.php">Nouveau document</a></li>
|
||||||
{/if}
|
{/if}
|
||||||
<li{if $current == 'clients'} class="current"{/if}><a href="{$plugin_admin_url}clients.php">Liste clients</a></li>
|
<li{if $current == 'clients'} class="current"{/if}><a href="{$plugin_admin_url}clients.php">Liste clients</a></li>
|
||||||
|
<li{if $current == 'archives'} class="current"{/if}><a href="{$plugin_admin_url}index.php?archive=1">Archives</a></li>
|
||||||
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN)}
|
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN)}
|
||||||
<li{if $current == 'config'} class="current"{/if}><a href="{$plugin_admin_url}config.php">Configuration</a></li>
|
<li{if $current == 'config'} class="current"{/if}><a href="{$plugin_admin_url}config.php">Configuration</a></li>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
{include file="_head.tpl" title="Document — %s"|args:$plugin.name current="plugin_%s"|args:$plugin.name}
|
{include file="_head.tpl" title="Document — %s"|args:$plugin.name current="plugin_%s"|args:$plugin.name}
|
||||||
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"}
|
{if $archive}
|
||||||
|
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="archives"}
|
||||||
|
{else}
|
||||||
|
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{form_errors}
|
{form_errors}
|
||||||
|
|
||||||
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)}
|
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)}
|
||||||
{linkbutton shape="edit" href="%sfacture_modifier.php?id=%d"|args:$plugin_admin_url,$facture.id label="Modifier ce document"}
|
{if ! $archive}
|
||||||
|
{linkbutton shape="edit" href="%sfacture_modifier.php?id=%d"|args:$plugin_admin_url,$facture.id label="Modifier ce document"}
|
||||||
|
{/if}
|
||||||
{linkbutton shape="plus" href="%sfacture_ajouter.php?copy=%d"|args:$plugin_admin_url,$facture.id label="Dupliquer ce document"}
|
{linkbutton shape="plus" href="%sfacture_ajouter.php?copy=%d"|args:$plugin_admin_url,$facture.id label="Dupliquer ce document"}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,21 @@
|
||||||
{include file="_head.tpl" title="Documents — %s"|args:$plugin.name current="plugin_%s"|args:$plugin.name}
|
{include file="_head.tpl" title="Documents — %s"|args:$plugin.name current="plugin_%s"|args:$plugin.name}
|
||||||
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"}
|
{if $archive}
|
||||||
|
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="archives"}
|
||||||
|
{else}
|
||||||
|
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{form_errors}
|
{form_errors}
|
||||||
|
|
||||||
|
<form method="post" action="{$self_url}">
|
||||||
{if $list->count()}
|
{if $list->count()}
|
||||||
{include file="common/dynamic_list_head.tpl"}
|
{include file="common/dynamic_list_head.tpl"}
|
||||||
|
|
||||||
{foreach from=$list->iterate() item="facture"}
|
{foreach from=$list->iterate() item="facture"}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{if ! $archive}{input type="checkbox" name="selected[]" value=$facture.id}{/if}</td>
|
||||||
<td>{$facture.type}</td>
|
<td>{$facture.type}</td>
|
||||||
<th><a href="facture.php?id={$facture.id}">{$facture.numero}</a></th>
|
<th><a href="facture.php?id={$facture.id}&archive={$archive}">{$facture.numero}</a></th>
|
||||||
{if $facture.receveur_membre}
|
{if $facture.receveur_membre}
|
||||||
<td>{link href="!users/details.php?id=%d"|args:$facture.receveur_id label=$facture.receveur}</td>
|
<td>{link href="!users/details.php?id=%d"|args:$facture.receveur_id label=$facture.receveur}</td>
|
||||||
{else}
|
{else}
|
||||||
|
|
@ -20,13 +26,12 @@
|
||||||
<td>{$facture.date_emission|date:'d/m/Y'}</td>
|
<td>{$facture.date_emission|date:'d/m/Y'}</td>
|
||||||
<td>{$facture.date_echeance|date:'d/m/Y'}</td>
|
<td>{$facture.date_echeance|date:'d/m/Y'}</td>
|
||||||
<td>{$facture.reglee}</td>
|
<td>{$facture.reglee}</td>
|
||||||
<td>{$facture.archivee}</td>
|
|
||||||
<td>{$facture.moyen_paiement}</td>
|
<td>{$facture.moyen_paiement}</td>
|
||||||
<td>{$facture.contenu|escape|nl2br}</td>
|
<td>{$facture.contenu|escape|nl2br}</td>
|
||||||
<td>{$facture.total|escape|money_currency}</td>
|
<td>{$facture.total|escape|money_currency}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{linkbutton shape="download" href="pdf.php?id=%d&d"|args:$facture.id label="Télécharger"}
|
{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"}
|
{linkbutton shape="eye" href="facture.php?id=%d"|args:$facture.id label="Voir"}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
@ -40,8 +45,14 @@
|
||||||
{linkbutton href="?export=csv" label="Export CSV" shape="download"}
|
{linkbutton href="?export=csv" label="Export CSV" shape="download"}
|
||||||
{linkbutton href="?export=ods" label="Export tableur" shape="download"}
|
{linkbutton href="?export=ods" label="Export tableur" shape="download"}
|
||||||
</p>
|
</p>
|
||||||
|
{if !$archive}
|
||||||
|
<p class="submit">
|
||||||
|
{csrf_field key="archiver_factures"}
|
||||||
|
{button type="submit" name="archiver" label="Archiver les factures sélectionnées" shape="right" class="main"}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
<p class="help">Aucun document, vous pouvez commencer par {link href="facture_ajouter.php" label="créer un nouveau document"}.</p>
|
<p class="help">Aucun document, vous pouvez commencer par {link href="facture_ajouter.php" label="créer un nouveau document"}.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
</form>
|
||||||
{include file="_foot.tpl"}
|
{include file="_foot.tpl"}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue