Modifs ajout {form_field}
This commit is contained in:
parent
2014dff1a1
commit
8adc144bfa
5 changed files with 93 additions and 134 deletions
|
|
@ -7,6 +7,7 @@ require_once __DIR__ . '/_inc.php';
|
|||
$session->requireAccess('compta', Membres::DROIT_ECRITURE);
|
||||
|
||||
use Garradin\DB;
|
||||
use stdClass;
|
||||
|
||||
qv(['id' => 'required|numeric']);
|
||||
$id = (int) qg('id');
|
||||
|
|
@ -19,9 +20,8 @@ if (!$f)
|
|||
}
|
||||
|
||||
$cats = new Compta\Categories;
|
||||
$tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
|
||||
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: $f->moyen_paiement);
|
||||
|
||||
// Traitement
|
||||
|
||||
if(f('save'))
|
||||
{
|
||||
|
|
@ -85,12 +85,12 @@ if(f('save'))
|
|||
if (f('base_receveur') == 'client')
|
||||
{
|
||||
$truc['receveur_membre'] = 0;
|
||||
$truc['receveur_id'] = f('client');
|
||||
$truc['receveur_id'] = f('client_id');
|
||||
}
|
||||
elseif (f('base_receveur') == 'membre')
|
||||
{
|
||||
$truc['receveur_membre'] = 1;
|
||||
$truc['receveur_id'] = f('membre');
|
||||
$truc['receveur_id'] = f('membre_id');
|
||||
}
|
||||
|
||||
$r = $facture->edit($id, $truc);
|
||||
|
|
@ -105,16 +105,25 @@ if(f('save'))
|
|||
}
|
||||
}
|
||||
|
||||
$tpl->assign('type', $facture->type[$f->type_facture]);
|
||||
$tpl->assign('numero_facture', f('numero_facture') ?: $f->numero);
|
||||
$tpl->assign('date_emission', strtotime(f('date_emission')) ?: $f->date_emission);
|
||||
$tpl->assign('date_echeance', strtotime(f('date_echeance')) ?: $f->date_echeance);
|
||||
$tpl->assign('reglee', f('reglee') ?: ($f->reglee?'on':'off'));
|
||||
$tpl->assign('base_receveur', f('base_receveur') ?: ($f->receveur_membre?'membre':'client'));
|
||||
$tpl->assign('client_id', f('client') ?: $f->receveur_id);
|
||||
$tpl->assign('membre_id', f('membre') ?: $f->receveur_id);
|
||||
// Affichage
|
||||
|
||||
$doc = new stdClass();
|
||||
$doc->moyens_paiement = $cats->listMoyensPaiement();
|
||||
$doc->moyen_paiement = $f->moyen_paiement;
|
||||
$doc->type = $facture->type[$f->type_facture];
|
||||
$doc->numero_facture = $f->numero;
|
||||
$doc->reglee = $f->reglee?'on':'off';
|
||||
$doc->base_receveur = $f->receveur_membre?'membre':'client';
|
||||
$doc->client_id = $f->receveur_id;
|
||||
$doc->membre_id = $f->receveur_id;
|
||||
|
||||
$tpl->assign('date_emission', strtotime(f('date_emission')) ?: $f->date_emission); // Smarty m'a saoulé pour utiliser form_field|date_fr:---
|
||||
$tpl->assign('date_echeance', strtotime(f('date_echeance')) ?: $f->date_echeance); // Du coup j'utilise form_field pour ces champs
|
||||
|
||||
$tpl->assign('doc', $doc);
|
||||
|
||||
// C'est un peu l'équivalent de form_field, mais j'avais écrit ça avant
|
||||
// et oulala, c'est un peu complexe, faudrait réfléchir keskivomieux
|
||||
if (($d = f('designation')) && ($p = f('prix')))
|
||||
{
|
||||
foreach($d as $k=>$v)
|
||||
|
|
@ -127,7 +136,7 @@ if (($d = f('designation')) && ($p = f('prix')))
|
|||
$prix[] = $p[$k];
|
||||
}
|
||||
}
|
||||
else/*if ($f->contenu)*/
|
||||
else
|
||||
{
|
||||
foreach($f->contenu as $k=>$v)
|
||||
{
|
||||
|
|
@ -140,12 +149,9 @@ else/*if ($f->contenu)*/
|
|||
}
|
||||
}
|
||||
$tpl->assign('designations', $designations);
|
||||
// $tpl->assign('designations', [0=>'',1=>'']);
|
||||
$tpl->assign('prix', $prix);
|
||||
// $tpl->assign('prix', ['','']);
|
||||
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, nom FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
$tpl->assign('clients', $client->listAll());
|
||||
|
||||
$tpl->assign('facture', $f);
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/facture_modifier.tpl');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue