Duplication de document pour transformer rapidement un devis en facture
This commit is contained in:
parent
92408f663c
commit
8e2ddf19c6
@ -81,7 +81,7 @@
|
||||
<legend>Contenu</legend>
|
||||
|
||||
<dl>
|
||||
{input type="select" name="moyen_paiement" required=1 label="Moyen de paiement" source=$doc options=$moyens_paiement}
|
||||
{input type="select" name="moyen_paiement" required=1 label="Moyen de paiement" source=$doc options=$moyens_paiement default="ES"}
|
||||
|
||||
<dt><label for="f_contenu">Contenu du document</label><dt>
|
||||
<dd>
|
||||
@ -143,7 +143,7 @@
|
||||
<dl>
|
||||
<dt><label>Reçu adressée à :</label></dt>
|
||||
<dd>
|
||||
{input type="select" name="membre_cotis" label="Membre" options=$membres required=1 source=$doc}
|
||||
{input type="select" name="membre_cotis" label="Membre" options=$membres required=1 default=$doc.membre}
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
{if $session->canAccess($session::SECTION_ACCOUNTING, $session::ACCESS_WRITE)}
|
||||
{linkbutton shape="edit" href="%sfacture_modifier.php?id=%d"|args:$plugin_url,$facture.id label="Modifier ce document"}
|
||||
{linkbutton shape="plus" href="%sfacture_ajouter.php?copy=%d"|args:$plugin_url,$facture.id label="Dupliquer ce document"}
|
||||
{/if}
|
||||
|
||||
{linkbutton shape="download" href="%spdf.php?d&id=%d"|args:$plugin_url,$facture.id label="Télécharger ce document"}
|
||||
|
@ -13,6 +13,8 @@ $db = DB::getInstance();
|
||||
|
||||
$step = $radio = false;
|
||||
$liste = [];
|
||||
$designations = [];
|
||||
$prix = [];
|
||||
|
||||
$csrf_key = 'ajout_facture';
|
||||
$fields = $facture->recu_fields;
|
||||
@ -21,10 +23,21 @@ $moyens_paiement = $facture->listMoyensPaiement(true);
|
||||
|
||||
$doc = null;
|
||||
|
||||
if (qg('copy') !== null && $f = $facture->get((int)qg('copy'))) {
|
||||
$doc = (array) $f;
|
||||
|
||||
// Copié depuis facture_modifier.php
|
||||
$doc['type'] = $f->type_facture;
|
||||
$doc['numero_facture'] = $f->numero;
|
||||
$doc['base_receveur'] = $f->receveur_membre ? 'membre' : 'client';
|
||||
$doc['client'] = $f->receveur_id;
|
||||
$doc['membre'] = $f->receveur_id;
|
||||
}
|
||||
|
||||
$tpl->assign('moyens_paiement', $moyens_paiement);
|
||||
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
|
||||
|
||||
if (f('add'))
|
||||
if (f('save'))
|
||||
{
|
||||
$form->check($csrf_key, [
|
||||
'type' => 'required|in:'.implode(',', [DEVIS, FACT, CERFA]),
|
||||
@ -181,6 +194,9 @@ elseif (null !== f('type'))
|
||||
{
|
||||
$radio['type'] = f('type');
|
||||
}
|
||||
elseif (isset($doc['type'])) {
|
||||
$radio['type'] = $doc['type'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$radio['type'] = FACT;
|
||||
@ -192,8 +208,6 @@ $tpl->assign('types_details', $facture->types);
|
||||
$tpl->assign('client_id', f('client') ?: -1);
|
||||
$tpl->assign('membre_id', f('membre') ?: -1);
|
||||
|
||||
$designations = [];
|
||||
$prix = [];
|
||||
$from_user = false;
|
||||
if (($d = f('designation')) && ($p = f('prix')) && implode($d))
|
||||
{
|
||||
@ -208,6 +222,17 @@ if (($d = f('designation')) && ($p = f('prix')) && implode($d))
|
||||
}
|
||||
$from_user = true;
|
||||
}
|
||||
else if (!empty($doc['contenu'])) {
|
||||
foreach($doc['contenu'] as $k=>$v)
|
||||
{
|
||||
if (empty($v['designation']) && empty($v['prix']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$designations[] = $v['designation'];
|
||||
$prix[] = $v['prix'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$designations = ['Exemple'];
|
||||
$prix = [250];
|
||||
|
Loading…
Reference in New Issue
Block a user