Ajout suppression doc + amélioration ui
This commit is contained in:
parent
d852c3c680
commit
2fda7a9db3
|
@ -343,5 +343,10 @@ class Facture
|
||||||
$db = DB::getInstance();
|
$db = DB::getInstance();
|
||||||
return $db->firstColumn('SELECT nom FROM plugin_facturation_paiement WHERE code = ?;', $code);
|
return $db->firstColumn('SELECT nom FROM plugin_facturation_paiement WHERE code = ?;', $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
return DB::getInstance()->delete('plugin_facturation_factures', 'id = '. (int)$id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
{form_errors}
|
{form_errors}
|
||||||
|
|
||||||
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)}
|
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)}
|
||||||
<a href="{plugin_url file="facture_modifier.php"}?id={$facture.id}">
|
{linkbutton shape="edit" href="%sfacture_modifier.php?id=%d"|args:$plugin_url,$facture.id label="Modifier ce document"}
|
||||||
<button type="button" class="btn btn-primary">Modifier ce document</button></a>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<a href="{plugin_url file="pdf.php"}?d&id={$facture.id}">
|
{linkbutton shape="download" href="%spdf.php?d&id=%d"|args:$plugin_url,$facture.id label="Télécharger ce document"}
|
||||||
<button type="button" class="btn btn-primary">Télécharger ce document</button></a>
|
|
||||||
|
{linkbutton shape="delete" href="%sfacture_supprimer.php?id=%d"|args:$plugin_url,$facture.id label="Supprimer ce document"}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<embed src="pdf.php?id={$id}" type="application/pdf" width="100%" height="800px;" style="max-width: 900px;">
|
<embed src="pdf.php?id={$id}" type="application/pdf" width="100%" height="800px;" style="max-width: 900px;">
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
{include file="admin/_head.tpl" title="Supprimer un document — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=0}
|
||||||
|
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"}
|
||||||
|
|
||||||
|
{form_errors}
|
||||||
|
|
||||||
|
<form method="post" action="{$self_url}">
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Supprimer ce document ?</legend>
|
||||||
|
<h3 class="warning">
|
||||||
|
Êtes-vous sûr de vouloir supprimer le document numéro « {$doc.numero} » ?
|
||||||
|
</h3>
|
||||||
|
<p class="alert">
|
||||||
|
<strong>Attention</strong> : cette action est irréversible.
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p class="submit">
|
||||||
|
{csrf_field key="delete_doc_"|cat:$doc.id}
|
||||||
|
<input type="submit" name="delete" value="Supprimer →" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{include file="admin/_foot.tpl"}
|
|
@ -17,6 +17,7 @@
|
||||||
<td>Moyen paiement</td>
|
<td>Moyen paiement</td>
|
||||||
<td>Contenu</td>
|
<td>Contenu</td>
|
||||||
<td>Total</td>
|
<td>Total</td>
|
||||||
|
<td></td>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{foreach from=$factures item=facture}
|
{foreach from=$factures item=facture}
|
||||||
|
@ -50,11 +51,17 @@
|
||||||
<td><?= $facture->archivee?'Archivée':'Non' ?></td>
|
<td><?= $facture->archivee?'Archivée':'Non' ?></td>
|
||||||
<td>{$facture.moyen_paiement}</td>
|
<td>{$facture.moyen_paiement}</td>
|
||||||
<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}
|
{foreach from=$facture.contenu item=contenu}
|
||||||
<p>{$contenu.designation} : {$contenu.prix|escape|money:false} {$config.monnaie}</p>
|
<p>{$contenu.designation} : {$contenu.prix|escape|money:false} {$config.monnaie}</p>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>{$facture.total|escape|money} {$config.monnaie}</td>
|
<td>{$facture.total|escape|money} {$config.monnaie}</td>
|
||||||
|
<td>{linkbutton shape="delete" href="%sfacture_supprimer.php?id=%d"|args:$plugin_url,$facture.id label="Supprimer"}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -15,6 +15,7 @@ $client = new Client;
|
||||||
$facture = new Facture;
|
$facture = new Facture;
|
||||||
|
|
||||||
$tpl->assign('f_obj', $facture);
|
$tpl->assign('f_obj', $facture);
|
||||||
|
$tpl->assign('plugin_url', Utils::plugin_url());
|
||||||
|
|
||||||
$identite = (string) Config::getInstance()->get('champ_identite');
|
$identite = (string) Config::getInstance()->get('champ_identite');
|
||||||
|
|
||||||
|
|
|
@ -36,5 +36,5 @@ if (f('delete'))
|
||||||
|
|
||||||
|
|
||||||
$tpl->assign('deletable', $client->isDeletable($id));
|
$tpl->assign('deletable', $client->isDeletable($id));
|
||||||
$tpl->assign('client', $client->get($id));
|
$tpl->assign('client', $c);
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/client_supprimer.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/client_supprimer.tpl');
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Garradin;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
|
$session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE);
|
||||||
|
|
||||||
|
qv(['id' => 'required|numeric']);
|
||||||
|
|
||||||
|
$id = (int) qg('id');
|
||||||
|
|
||||||
|
$f = $facture->get($id);
|
||||||
|
|
||||||
|
if (!$client)
|
||||||
|
{
|
||||||
|
throw new UserException("Ce document n'existe pas.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f('delete'))
|
||||||
|
{
|
||||||
|
$form->check('delete_doc_'.$f->id);
|
||||||
|
|
||||||
|
if (!$form->hasErrors())
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$facture->delete($f->id);
|
||||||
|
Utils::redirect(PLUGIN_URL . 'index.php');
|
||||||
|
}
|
||||||
|
catch (UserException $e)
|
||||||
|
{
|
||||||
|
$form->addError($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl->assign('doc', $f);
|
||||||
|
$tpl->display(PLUGIN_ROOT . '/templates/facture_supprimer.tpl');
|
Loading…
Reference in New Issue