diff --git a/admin/_facture_common.php b/admin/_facture_common.php index 8b93c95..b729f34 100644 --- a/admin/_facture_common.php +++ b/admin/_facture_common.php @@ -69,10 +69,7 @@ if ( !$target ) { 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 $data=[]; $form->runIf(f('save') && !$form->hasErrors(), @@ -230,6 +227,7 @@ if (! $form->hasErrors()) } // Affichage + if ($target) { $doc = null; @@ -276,7 +274,6 @@ else $doc['type'] = $f->type_facture; $doc['numero_facture'] = $f->numero; $doc['reglee'] = $f->reglee; - $doc['archivee'] = $f->archivee; $doc['base_receveur'] = $f->receveur_membre?'membre':'client'; $doc['client'] = $f->receveur_id; $doc['membre'] = $f->receveur_id; @@ -297,7 +294,6 @@ else $radio['type'] = f('type')??$doc['type']; } - $tpl->assign('types_details', $facture->types); $tpl->assign('client_id', f('client') ?: -1); diff --git a/admin/facture.php b/admin/facture.php index 565b53c..e375bf3 100644 --- a/admin/facture.php +++ b/admin/facture.php @@ -20,12 +20,10 @@ if (!$f) throw new UserException("Ce document n'existe pas."); } -$archive = $f->archivee; $tpl->assign('type', $f->type_facture); $tpl->assign('facture', $f); $tpl->assign('id', $id); $tpl->assign('footer', $plugin->getConfig('footer')?:''); $tpl->assign('siret_asso', $plugin->getConfig('siret_asso')?:''); -$tpl->assign('archive', $archive); $tpl->display(PLUGIN_ROOT . '/templates/facture.tpl'); diff --git a/admin/index.php b/admin/index.php index 29d2d99..a0acb18 100644 --- a/admin/index.php +++ b/admin/index.php @@ -9,20 +9,11 @@ require_once __DIR__ . '/_inc.php'; $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); - } - }, 'archiver_factures'); - - -$archive = isset($_GET['archive']) && $_GET['archive'] == 1; -$list = $facture->list(! $archive); +$list = $facture->list(); $list->loadFromQueryString(); $list->setPageSize(50); -$tpl->assign(compact('list', 'archive')); +$tpl->assign(compact('list')); + $tpl->display(PLUGIN_ROOT . '/templates/index.tpl'); diff --git a/lib/Facture.php b/lib/Facture.php index 761683f..270fca7 100644 --- a/lib/Facture.php +++ b/lib/Facture.php @@ -318,7 +318,7 @@ class Facture return $r; } - public function list($all = true): DynamicList + public function list(): DynamicList { $id_field = \Paheko\Users\DynamicFields::getNameFieldsSQL('u'); $plugin_name = preg_replace('/^.*\/(\w+)\/$/', '${1}', \Paheko\PLUGIN_ADMIN_URL); @@ -343,9 +343,6 @@ class Facture 'receveur_id' => [ ], // Créer une colonne virtuelle - 'select' => [ - 'label' => '', - ], 'type' => [ 'label' => 'Type', 'select' => null, @@ -379,6 +376,9 @@ class Facture 'reglee' => [ 'label' => 'Réglée', ], + 'archivee' => [ + 'label' => 'Archivée', + ], 'moyen_paiement' => [ 'label' => 'Moyen de paiement', 'select' => 'mp.nom', @@ -396,12 +396,7 @@ class Facture 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'; - if ($all) { - $where = "f.archivee != TRUE"; - } else { - $where = "f.archivee == TRUE"; - } - $list = new DynamicList($columns, $tables, $where); + $list = new DynamicList($columns, $tables); $list->orderBy('date_emission', true); $currency = Config::getInstance()->monnaie; @@ -410,6 +405,7 @@ class Facture // 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); @@ -558,19 +554,4 @@ class Facture { 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)); - } } diff --git a/plugin.ini b/plugin.ini index acd3b80..c75a449 100644 --- a/plugin.ini +++ b/plugin.ini @@ -1,8 +1,8 @@ name="Facturation" description="Permet d'éditer des factures et devis à ses membres ainsi qu'à une base de clients supplémentaire." -author="zou ; adapté par Jean-Christophe Engel" -url="https://gitea.zaclys.com/lesanges/facturation" -version="0.17" +author="zou ; adapté par jce" +url="https://git.roflcopter.fr/lesanges/paheko-plugin-facturation" +version="0.16" menu=true restrict_section="accounting" restrict_level="read" diff --git a/templates/_form.tpl b/templates/_form.tpl index 4ab076e..f533acf 100644 --- a/templates/_form.tpl +++ b/templates/_form.tpl @@ -50,7 +50,7 @@ {input type="checkbox" name="reglee" value="1" label="Réglée" source=$doc data-types="t1"}
- {input type="checkbox" name="archivee" value="1" label="Archivée" source=$doc} + {input type="checkbox" name="archivee" value="1" label="Archivée" source=$doc disabled="disabled"}
diff --git a/templates/_menu.tpl b/templates/_menu.tpl index 2245e75..5ef07de 100644 --- a/templates/_menu.tpl +++ b/templates/_menu.tpl @@ -5,13 +5,12 @@ - + \ No newline at end of file diff --git a/templates/facture.tpl b/templates/facture.tpl index e169014..1464bc4 100644 --- a/templates/facture.tpl +++ b/templates/facture.tpl @@ -1,16 +1,10 @@ {include file="_head.tpl" title="Document — %s"|args:$plugin.name current="plugin_%s"|args:$plugin.name} -{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} +{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"} {form_errors} {if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)} -{if ! $archive} - {linkbutton shape="edit" href="%sfacture_modifier.php?id=%d"|args:$plugin_admin_url,$facture.id label="Modifier ce document"} -{/if} +{linkbutton shape="edit" href="%sfacture_modifier.php?id=%d"|args:$plugin_admin_url,$facture.id label="Modifier ce document"} {linkbutton shape="plus" href="%sfacture_ajouter.php?copy=%d"|args:$plugin_admin_url,$facture.id label="Dupliquer ce document"} {/if} diff --git a/templates/index.tpl b/templates/index.tpl index 92d727c..b6da4de 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -1,21 +1,15 @@ {include file="_head.tpl" title="Documents — %s"|args:$plugin.name current="plugin_%s"|args:$plugin.name} -{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} +{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"} {form_errors} -
{if $list->count()} {include file="common/dynamic_list_head.tpl"} {foreach from=$list->iterate() item="facture"} - - {if ! $archive}{input type="checkbox" name="selected[]" value=$facture.id}{/if} - {$facture.type} - {$facture.numero} + + {$facture.type} + {$facture.numero} {if $facture.receveur_membre} {link href="!users/details.php?id=%d"|args:$facture.receveur_id label=$facture.receveur} {else} @@ -26,12 +20,13 @@ {$facture.date_emission|date:'d/m/Y'} {$facture.date_echeance|date:'d/m/Y'} {$facture.reglee} + {$facture.archivee} {$facture.moyen_paiement} {$facture.contenu|escape|nl2br} {$facture.total|escape|money_currency} {linkbutton shape="download" href="pdf.php?id=%d&d"|args:$facture.id label="Télécharger"} - {linkbutton shape="eye" href="facture.php?id=%d"|args:$facture.id label="Voir"} + {linkbutton shape="menu" href="facture.php?id=%d"|args:$facture.id label="Voir"} {/foreach} @@ -45,14 +40,8 @@ {linkbutton href="?export=csv" label="Export CSV" shape="download"} {linkbutton href="?export=ods" label="Export tableur" shape="download"}

-{if !$archive} -

- {csrf_field key="archiver_factures"} - {button type="submit" name="archiver" label="Archiver les factures sélectionnées" shape="right" class="main"} -

-{/if} {else}

Aucun document, vous pouvez commencer par {link href="facture_ajouter.php" label="créer un nouveau document"}.

{/if} -
+ {include file="_foot.tpl"}