diff --git a/admin/index.php b/admin/index.php index a0acb18..0cefefb 100644 --- a/admin/index.php +++ b/admin/index.php @@ -8,12 +8,11 @@ if ($plugin->needUpgrade()) { require_once __DIR__ . '/_inc.php'; $session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_READ); +$archive = isset($_GET['archive']) && $_GET['archive'] == 1; - -$list = $facture->list(); +$list = $facture->list(! $archive); $list->loadFromQueryString(); $list->setPageSize(50); -$tpl->assign(compact('list')); - +$tpl->assign(compact('list', 'archive')); $tpl->display(PLUGIN_ROOT . '/templates/index.tpl'); diff --git a/lib/Facture.php b/lib/Facture.php index 270fca7..53e7762 100644 --- a/lib/Facture.php +++ b/lib/Facture.php @@ -318,7 +318,7 @@ class Facture return $r; } - public function list(): DynamicList + public function list($all = true): DynamicList { $id_field = \Paheko\Users\DynamicFields::getNameFieldsSQL('u'); $plugin_name = preg_replace('/^.*\/(\w+)\/$/', '${1}', \Paheko\PLUGIN_ADMIN_URL); @@ -396,7 +396,12 @@ 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'; - $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); $currency = Config::getInstance()->monnaie; diff --git a/templates/_form.tpl b/templates/_form.tpl index f533acf..4ab076e 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 disabled="disabled"} + {input type="checkbox" name="archivee" value="1" label="Archivée" source=$doc}
diff --git a/templates/_menu.tpl b/templates/_menu.tpl index 5ef07de..2245e75 100644 --- a/templates/_menu.tpl +++ b/templates/_menu.tpl @@ -5,12 +5,13 @@ - \ No newline at end of file + diff --git a/templates/index.tpl b/templates/index.tpl index b6da4de..292efd0 100644 --- a/templates/index.tpl +++ b/templates/index.tpl @@ -1,5 +1,9 @@ {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} @@ -26,7 +30,7 @@ {$facture.total|escape|money_currency} {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"} {/foreach}