Upgrade pour Garradin 1.0
This commit is contained in:
parent
9c52dc8b4e
commit
3001646e37
|
@ -10,9 +10,9 @@ CREATE TABLE IF NOT EXISTS plugin_facturation_factures (
|
|||
archivee INTEGER DEFAULT 0, -- bool
|
||||
moyen_paiement TEXT NOT NULL,
|
||||
contenu TEXT NOT NULL,
|
||||
total REAL DEFAULT 0,
|
||||
total REAL DEFAULT 0
|
||||
|
||||
FOREIGN KEY(moyen_paiement) REFERENCES compta_moyens_paiement(code)
|
||||
-- FOREIGN KEY(moyen_paiement) REFERENCES compta_moyens_paiement(code)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS plugin_facturation_clients (
|
||||
|
@ -27,6 +27,22 @@ CREATE TABLE IF NOT EXISTS plugin_facturation_clients (
|
|||
email TEXT
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS plugin_facturation_paiement
|
||||
-- Moyens de paiement
|
||||
(
|
||||
code TEXT NOT NULL PRIMARY KEY,
|
||||
nom TEXT NOT NULL
|
||||
);
|
||||
|
||||
--INSERT INTO compta_moyens_paiement (code, nom) VALUES ('AU', 'Autre');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('CB', 'Carte bleue');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('CH', 'Chèque');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('ES', 'Espèces');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('PR', 'Prélèvement');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('TI', 'TIP');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('VI', 'Virement');
|
||||
|
||||
-- CREATE TABLE IF NOT EXISTS plugin_facturation_produits (
|
||||
-- id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
-- designation TEXT,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
DROP TABLE `plugin_facturation_factures`;
|
||||
DROP TABLE `plugin_facturation_clients`;
|
||||
DROP TABLE `plugin_facturation_paiement`;
|
||||
-- DROP TABLE `plugin_facturation_produits`;
|
|
@ -2,7 +2,7 @@ nom="Facturation"
|
|||
description="Permet d'éditer des factures, devis et reçus à ses membres ainsi qu'à une base de clients supplémentaire."
|
||||
auteur="zou"
|
||||
url="https://gitlab.com/ramoloss/garradin-plugin-facturation/"
|
||||
version="0.3.0"
|
||||
version="0.4.0"
|
||||
menu=1
|
||||
config=1
|
||||
min_version="0.9.2"
|
|
@ -45,7 +45,7 @@ class Client
|
|||
|
||||
if($key == 'ville')
|
||||
{
|
||||
$data[$key] = mb_strtoupper($data[$key]);
|
||||
$data[$key] = strtoupper($data[$key]);
|
||||
}
|
||||
elseif ($key == 'code_postal')
|
||||
{
|
||||
|
|
117
lib/Facture.php
117
lib/Facture.php
|
@ -2,8 +2,10 @@
|
|||
|
||||
namespace Garradin\Plugin\Facturation;
|
||||
|
||||
use DateTime;
|
||||
use Garradin\DB;
|
||||
use Garradin\UserException;
|
||||
use Garradin\Services\Services_User;
|
||||
|
||||
class Facture
|
||||
{
|
||||
|
@ -21,12 +23,28 @@ class Facture
|
|||
'total'
|
||||
];
|
||||
|
||||
public $type = [
|
||||
0 => 'devis',
|
||||
1 => 'facture',
|
||||
2 => 'cerfa',
|
||||
3 => 'cotis',
|
||||
];
|
||||
public $types = [
|
||||
DEVIS => [
|
||||
'id' => DEVIS,
|
||||
'accounts' => [],
|
||||
'label' => 'Devis',
|
||||
'help' => ''],
|
||||
FACT => [
|
||||
'id' => FACT,
|
||||
'accounts' => [],
|
||||
'label' => 'Facture',
|
||||
'help' => ''],
|
||||
CERFA => [
|
||||
'id' => CERFA,
|
||||
'accounts' => [],
|
||||
'label' => 'Reçu fiscal',
|
||||
'help' => 'Reçu fiscal pour un don (membre ou client)'],
|
||||
COTIS => [
|
||||
'id' => COTIS,
|
||||
'accounts' => [],
|
||||
'label' => 'Reçu de cotisation',
|
||||
'help' => 'Reçu pour une cotisation payée par un·e membre'],
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -51,11 +69,10 @@ class Facture
|
|||
throw new UserException("La valeur de $k est vide");
|
||||
}
|
||||
|
||||
|
||||
switch($k)
|
||||
{
|
||||
case 'type_facture':
|
||||
if (!array_key_exists($datas[$k], $this->type)) {
|
||||
if (!array_key_exists($datas[$k], $this->types)) {
|
||||
throw new UserException("$k est de type non-attendue ($data).");
|
||||
}
|
||||
if ($datas[$k] < 2) {
|
||||
|
@ -87,24 +104,19 @@ class Facture
|
|||
}
|
||||
break;
|
||||
case 'date_emission':
|
||||
if (!strtotime($datas[$k])) {
|
||||
throw new UserException("La date d'émission est non-attendue ($data).");
|
||||
}
|
||||
$datas[$k] = \DateTime::createFromFormat('!d/m/Y', $data)->format('Y-m-d');
|
||||
break;
|
||||
case 'date_echeance':
|
||||
if (!strtotime($datas[$k])) {
|
||||
throw new UserException("La date d'émission est non-attendue ($data).");
|
||||
}
|
||||
if (isset($datas['date_emission']) && (strtotime($datas[$k]) < strtotime($datas['date_emission']))) {
|
||||
$datas[$k] = \DateTime::createFromFormat('!d/m/Y', $data)->format('Y-m-d');
|
||||
if (DateTime::createFromFormat('!Y-m-d', $datas[$k])->format('U') < DateTime::createFromFormat('!Y-m-d', $datas['date_emission'])->format('U'))
|
||||
{
|
||||
throw new UserException("La date d'échéance est antérieure à la date d'émission ($data).");
|
||||
}
|
||||
break;
|
||||
case 'moyen_paiement':
|
||||
$cats = new \Garradin\Compta\Categories;
|
||||
if (!array_key_exists($datas[$k], $cats->listMoyensPaiement())) {
|
||||
if (!array_key_exists($datas[$k], $this->listMoyensPaiement())) {
|
||||
throw new UserException("Le moyen de paiement ne correspond pas à la liste interne ($data).");
|
||||
}
|
||||
unset($cats);
|
||||
break;
|
||||
case 'contenu':
|
||||
if ($fac)
|
||||
|
@ -176,9 +188,7 @@ class Facture
|
|||
{
|
||||
$db = DB::getInstance();
|
||||
|
||||
$r = $db->first('SELECT *, strftime(\'%s\', date_emission) AS date_emission,
|
||||
strftime(\'%s\', date_echeance) AS date_echeance
|
||||
FROM plugin_facturation_factures WHERE id = ? LIMIT 1;', (int)$id);
|
||||
$r = $db->first('SELECT * FROM plugin_facturation_factures WHERE id = ? LIMIT 1;', (int)$id);
|
||||
|
||||
if(!$r)
|
||||
{
|
||||
|
@ -190,6 +200,12 @@ class Facture
|
|||
$r->contenu = json_decode($r->contenu, true);
|
||||
}
|
||||
|
||||
$r->date_emission = \DateTime::createFromFormat('!Y-m-d', $r->date_emission);
|
||||
if ($r->date_echeance)
|
||||
{
|
||||
$r->date_echeance= \DateTime::createFromFormat('!Y-m-d', $r->date_echeance);
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
@ -276,26 +292,47 @@ class Facture
|
|||
|
||||
// ** Pour type reçu **
|
||||
|
||||
public $recu_fields = ['id', 'intitule', 'montant', 'date', 'expiration'];
|
||||
public $recu_fields = ['id', 'label', 'amount', 'date', 'expiry', 'paid', 'paid_amount'];
|
||||
|
||||
public function getCotis($membre_id = 1)
|
||||
public function getCotis(int $user_id, int $su_id = null)
|
||||
{
|
||||
// C un peu overkill nn?
|
||||
// Copié/modifié de Membres\Cotisations::listSubscriptionsForMember($id)
|
||||
$db = DB::getInstance();
|
||||
return $db->get('SELECT cm.id, c.intitule, strftime(\'%s\', c.debut) AS debut, strftime(\'%s\', c.fin) AS fin, c.montant, strftime(\'%s\', cm.date) AS date,
|
||||
CASE WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\') >= date()
|
||||
WHEN c.fin IS NOT NULL THEN (cm.id IS NOT NULL AND cm.date <= c.fin AND cm.date >= c.debut)
|
||||
WHEN cm.id IS NOT NULL THEN 1 ELSE 0 END AS a_jour,
|
||||
strftime(\'%s\', CASE WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\')
|
||||
WHEN c.fin IS NOT NULL THEN c.fin ELSE 1 END ) AS expiration,
|
||||
(julianday(date()) - julianday(CASE WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\')
|
||||
WHEN c.fin IS NOT NULL THEN c.fin END)) AS nb_jours
|
||||
FROM cotisations_membres AS cm
|
||||
INNER JOIN cotisations AS c ON c.id = cm.id_cotisation
|
||||
WHERE cm.id_membre = ?
|
||||
AND ((c.fin IS NOT NULL AND cm.date <= c.fin AND cm.date >= c.debut) OR c.fin IS NULL)
|
||||
GROUP BY cm.id_cotisation
|
||||
ORDER BY cm.date DESC;', (int)$membre_id);
|
||||
$where = 'WHERE su.id_user = ?';
|
||||
if (null !== $su_id)
|
||||
{
|
||||
$where .= ' AND su.id = '.$su_id;
|
||||
}
|
||||
|
||||
$sql = 'SELECT su.id, s.label, su.date, MAX(su.expiry_date) as expiry, sf.label as fee, sf.amount as amount, su.paid, SUM(tl.debit) as paid_amount
|
||||
FROM services_users su
|
||||
INNER JOIN services s ON s.id = su.id_service
|
||||
LEFT JOIN services_fees sf ON sf.id = su.id_fee
|
||||
LEFT JOIN acc_transactions_users tu ON tu.id_service_user = su.id
|
||||
LEFT JOIN acc_transactions_lines tl ON tl.id_transaction = tu.id_transaction
|
||||
'.$where.'
|
||||
GROUP BY su.id
|
||||
ORDER BY su.date;';
|
||||
|
||||
return DB::getInstance()->get($sql, $user_id);
|
||||
}
|
||||
|
||||
public function listMoyensPaiement($assoc = false)
|
||||
{
|
||||
$db = DB::getInstance();
|
||||
|
||||
$query = 'SELECT code, nom FROM plugin_facturation_paiement ORDER BY nom COLLATE NOCASE;';
|
||||
|
||||
if ($assoc) {
|
||||
return $db->getAssoc($query);
|
||||
}
|
||||
else {
|
||||
return $db->getGrouped($query);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMoyenPaiement($code)
|
||||
{
|
||||
$db = DB::getInstance();
|
||||
return $db->firstColumn('SELECT nom FROM plugin_facturation_paiement WHERE code = ?;', $code);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,12 +15,26 @@
|
|||
function plus(){
|
||||
var newdiv = document.createElement('tr');
|
||||
newdiv.innerHTML = document.getElementById('Line1').innerHTML;
|
||||
newdiv.querySelector('.fact_rm_line button').onclick = function(){
|
||||
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
|
||||
updateSum();
|
||||
};
|
||||
document.getElementById('Lines').appendChild(newdiv);
|
||||
}
|
||||
plus();
|
||||
updateSum();
|
||||
|
||||
$('#ajouter_ligne').onclick = plus;
|
||||
|
||||
a = document.querySelectorAll('[name="remove_line"]');
|
||||
l = a.length;
|
||||
for(i = 0; i < l; i++) {
|
||||
a[i].onclick = function(){
|
||||
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
|
||||
updateSum();
|
||||
};
|
||||
}
|
||||
|
||||
function changeTypeSaisie(type)
|
||||
{
|
||||
g.toggle(['.type_client', '.type_membre'], false);
|
||||
|
@ -39,5 +53,40 @@
|
|||
}
|
||||
|
||||
} ());
|
||||
|
||||
|
||||
// Hide type specific parts of the form
|
||||
function hideAllTypes() {
|
||||
g.toggle('[data-types]', false);
|
||||
}
|
||||
|
||||
// Toggle parts of the form when a type is selected
|
||||
function selectType(v) {
|
||||
hideAllTypes();
|
||||
g.toggle('[data-types~=t' + v + ']', true);
|
||||
g.toggle('[data-types=all-but-advanced]', v != 0);
|
||||
// Disable required form elements, or the form won't be able to be submitted
|
||||
$('[data-types=all-but-advanced] input[required]').forEach((e) => {
|
||||
e.disabled = v == 'advanced' ? true : false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
var radios = $('fieldset input[type=radio][name=type]');
|
||||
|
||||
radios.forEach((e) => {
|
||||
e.onchange = () => {
|
||||
document.querySelectorAll('fieldset').forEach((e, k) => {
|
||||
if (k == 0 || e.dataset.types) return;
|
||||
g.toggle(e, true);
|
||||
g.toggle('p.submit', true);
|
||||
});
|
||||
console.log(e.value);
|
||||
selectType(e.value);
|
||||
};
|
||||
});
|
||||
|
||||
hideAllTypes();
|
||||
{/literal}
|
||||
selectType({$radio.type});
|
||||
</script>
|
|
@ -1,13 +1,13 @@
|
|||
<tfoot>
|
||||
<tr>
|
||||
{if $session->canAccess('membres', Membres::DROIT_ADMIN)}<td class="check"><input type="checkbox" value="Tout cocher / décocher" /></td>{/if}
|
||||
<td class="actions" colspan="{$colspan}">
|
||||
<em>Pour les membres cochés :</em>
|
||||
<td class="check"><input type="checkbox" value="Tout cocher / décocher" id="f_all2" /><label for="f_all2"></label></td>
|
||||
<td></td>
|
||||
<td class="tabs" colspan={$colspan}>
|
||||
<em>PAS FONCTIONNEL - Pour les client·es coché·es :</em>
|
||||
{csrf_field key="membres_action"}
|
||||
<select name="action">
|
||||
<option value="">— Choisir une action à effectuer —</option>
|
||||
<option value="csv">Exporter en tableau CSV</option>
|
||||
<option value="ods">Exporter en classeur Office</option>
|
||||
<option value="delete">Supprimer</option>
|
||||
</select>
|
||||
<noscript>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<ul class="actions">
|
||||
<style>
|
||||
{include file="%s/templates/_style.css"|args:$plugin_root}
|
||||
</style>
|
||||
<nav class="tabs">
|
||||
<ul>
|
||||
<li{if $current == 'index'} class="current"{/if}><a href="{plugin_url file=""}">Liste documents</a></li>
|
||||
{if $session->canAccess('compta', Membres::DROIT_ECRITURE)}
|
||||
<li{if $current == 'facture'} class="current"{/if}><a href="{plugin_url file="facture_ajouter.php"}">Nouveau document</a></li>
|
||||
|
@ -9,3 +13,4 @@
|
|||
{/if}
|
||||
<li{if $current == 'aide'} class="current"{/if}><a href="{plugin_url file="aide.php"}">Aide</a></li>
|
||||
</ul>
|
||||
</nav>
|
|
@ -1,4 +1,5 @@
|
|||
<ul class="actions">
|
||||
<nav class="tabs">
|
||||
<ul>
|
||||
<li{if $current == 'clients'} class="current"{/if}><a href="{plugin_url file="clients.php"}">Liste clients</a></li>
|
||||
<li{if $current == 'client'} class="current"{/if}><a href="{plugin_url file="client.php"}?id={$client.id}">{$client.nom}</a></li>
|
||||
{if $session->canAccess('compta', Membres::DROIT_ECRITURE)}
|
||||
|
@ -8,3 +9,4 @@
|
|||
<li{if $current == 'client_supprimer'} class="current"{/if}>
|
||||
<a href="{plugin_url file="client_supprimer.php"}?id={$client.id}">Supprimer</a></li>{/if}
|
||||
</ul>
|
||||
</nav>
|
|
@ -0,0 +1,10 @@
|
|||
{literal}
|
||||
.tabs {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#Line1 > .fact_rm_line {
|
||||
display: none;
|
||||
}
|
||||
|
||||
{/literal}
|
|
@ -8,25 +8,6 @@
|
|||
<p>Pour l'instant, il y a des choses encore brouillonnes. Notamment, dans les factures et devis, c'est l'adresse postale renseignée dans la configuration de Garradin qui fait foi plutôt que celle dans le plugin (qui sert en revanche pour les reçus).</p>
|
||||
<p>Pensez à mettre une image en signature aussi, il me semble que les reçus fiscales peuvent méfonctionner sans ça :o (j'ai copié cette partie d'un ancien plugin, alors je connais pas bien).</p>
|
||||
<br>
|
||||
<p>Il y a un problème entre les bibliothèques pour importer le cerfa (reçu fiscal) et l'autoloader de Garradin. Il faut pour cela, en attendant la nouvelle version, faire une petite modif dans le fichier include/init.php, au niveau de la ligne 111:</p>
|
||||
<pre>{literal}
|
||||
|
||||
if (!file_exists($path))
|
||||
{
|
||||
<b>return false;</b>
|
||||
}
|
||||
</pre>
|
||||
à la place de la ligne :
|
||||
<pre>
|
||||
|
||||
if (!file_exists($path))
|
||||
{
|
||||
<b>throw new \Exception('File '.$path.' doesn\'t exists');</b>
|
||||
};
|
||||
{/literal}
|
||||
</pre>
|
||||
<p>Ne vous en faites pas, ça va pas tout casser, et c'est réglé dans la version 1.0 de Garradin, et ça sert seulement pour éditer des reçus fiscaux.</p>
|
||||
<br>
|
||||
<p>- Pour créer un reçu sur une cotisation, il faut pour le moment que cette cotisation soit attachée à la compta.</p>
|
||||
<p>- Pour créer un reçu fiscal, l'interface est pour l'instant la même que pour créer une facture/devis. Les champs correspondent mais les noms/labels autour ne sont pas adaptés. Vous pouvez de toutes façons tester, et si le résultat est pas celui attendu, remodifiez derrière :)</p>
|
||||
<p>- La partie « Droit à la réduction d'impôt » peut faire peur, elle correspond simplement à des cases du cerfa pour les reçus fiscaux. Je n'y connais pas grand chose pour le moment, je ne peux vous éclairer davantage, il va falloir se retourner vers légifrance :(</p>
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<tbody>
|
||||
{foreach from=$docs item=facture}
|
||||
<tr>
|
||||
<td>{if $facture.type_facture == 1}Facture{else}Devis{/if}</td>
|
||||
<td>{$f_obj->types[$facture.type_facture]['label'] }</td>
|
||||
<td><a href="{plugin_url file="facture.php"}?id={$facture.id}">{$facture.numero}</a></td>
|
||||
<td>{$facture.date_emission|date_fr:'d/m/Y'}</td>
|
||||
<td>{$facture.date_echeance|date_fr:'d/m/Y'}</td>
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
<tbody>
|
||||
{foreach from=$clients item="membre"}
|
||||
<tr>
|
||||
{if $session->canAccess('membres', Membres::DROIT_ADMIN)}<td class="check"><input type="checkbox" name="selected[]" value="{$membre.id}" /></td>{/if}
|
||||
{if $session->canAccess('membres', Membres::DROIT_ADMIN)}<td class="check">
|
||||
{input type="checkbox" name="selected" value=$membre.id default=0}
|
||||
</td>
|
||||
{/if}
|
||||
{foreach from=$champs key="c" item="cfg"}
|
||||
<td>
|
||||
{if $c == 'nom'}<a href="{plugin_url file="client.php"}?id={$membre.id}">{/if}
|
||||
|
@ -28,7 +31,7 @@
|
|||
{if $c == 'nom'}</a>{/if}
|
||||
</td>
|
||||
{/foreach}
|
||||
<td class="actions">
|
||||
<td class="tabs">
|
||||
<a class="icn" href="{plugin_url file="client.php"}?id={$membre.id}" title="Fiche membre">👤</a>
|
||||
{if $session->canAccess('membres', Membres::DROIT_ECRITURE)}<a class="icn" href="{plugin_url file="client_modifier.php"}?id={$membre.id}" title="Modifier la fiche membre">✎</a>{/if}
|
||||
</td>
|
||||
|
@ -36,7 +39,7 @@
|
|||
{/foreach}
|
||||
</tbody>
|
||||
{if $session->canAccess('membres', Membres::DROIT_ADMIN)}
|
||||
{include file="%s/templates/_list_actions.tpl"|args:$plugin_root colspan=count((array)$champs)+1}
|
||||
{include file="%s/templates/_list_actions.tpl"|args:$plugin_root colspan=count((array)$champs)}
|
||||
{/if}
|
||||
</table>
|
||||
{else}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="config"}
|
||||
|
||||
{if $ok && !$form->hasErrors()}
|
||||
<p class="confirm">
|
||||
<p class="block confirm">
|
||||
La configuration a bien été enregistrée.
|
||||
</p>
|
||||
{/if}
|
||||
|
@ -13,38 +13,26 @@
|
|||
<fieldset>
|
||||
<legend>Informations de l'association</legend>
|
||||
<dl>
|
||||
<dt><label for="f_siret">RNA de l'assocation</label></dt>
|
||||
<dd><input type="text" id="f_rna" name="rna_asso" value="{form_field data=$plugin.config name=rna_asso}"></dd>
|
||||
|
||||
<dt><label for="f_siret">SIRET de l'assocation</label></dt>
|
||||
<dd><input type="text" id="f_siret" name="siret_asso" value="{form_field data=$plugin.config name=siret_asso}"></dd>
|
||||
{input type="text" name="rna_asso" label="RNA de l'association" source=$plugin.config}
|
||||
{input type="text" name="siret_asso" label="SIRET de l'association" source=$plugin.config}
|
||||
</dl>
|
||||
<br>
|
||||
<fieldset>
|
||||
<legend>Adresse</legend>
|
||||
<dl>
|
||||
|
||||
<dt><label for="f_numero_rue">Numéro de rue</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="text" id="f_numero_rue" maxlength=5 name="numero_rue" value="{form_field data=$plugin.config name=numero_rue_asso}" /></dd>
|
||||
|
||||
<dt><label for="f_rue">Rue</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="text" id="f_rue" name="rue" value="{form_field data=$plugin.config name=rue_asso}" /></dd>
|
||||
|
||||
<dt><label for="f_codepostal">Code postal</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="text" id="f_codepostal" name="codepostal" value="{form_field data=$plugin.config name=cp_asso}" /></dd>
|
||||
|
||||
<dt><label for="f_ville">Ville</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="text" id="f_ville" name="ville" value="{form_field data=$plugin.config name=ville_asso}" /></dd>
|
||||
|
||||
{input type="text" name="numero_rue_asso" source=$plugin.config label="Numéro de rue" required=1 maxlength=5}
|
||||
{input type="text" name="rue_asso" source=$plugin.config label="Nom de rue" required=1}
|
||||
{input type="text" name="cp_asso" source=$plugin.config label="Code postal" required=1}
|
||||
{input type="text" name="ville_asso" source=$plugin.config label="Ville" required=1}
|
||||
</dl>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Objet</legend>
|
||||
<dl>
|
||||
<dt><label>L'objet (but) de l'association doit tenir sur 3 lignes, chaque ligne pouvant accueillir un maximum de 100 caractères.</label><b title="(Champ obligatoire)">obligatoire pour reçus fiscaux</b></dt>
|
||||
<dd><input type="text" maxlength=95 name="objet_0" value="{form_field data=$plugin.config name=objet_0}" /></dd>
|
||||
<dd><input type="text" maxlength=95 name="objet_1" value="{form_field data=$plugin.config name=objet_1}" /></dd>
|
||||
<dd><input type="text" maxlength=95 name="objet_2" value="{form_field data=$plugin.config name=objet_2}" /></dd>
|
||||
{input type="text" name="objet_0" source=$plugin.config label="Ligne 1" maxlength=95}
|
||||
{input type="text" name="objet_1" source=$plugin.config label="Ligne 2" maxlength=95}
|
||||
{input type="text" name="objet_2" source=$plugin.config label="Ligne 3" maxlength=95}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
@ -52,9 +40,9 @@
|
|||
<legend>Droit à la réduction d'impôt</legend>
|
||||
<dl>
|
||||
<dt><label>Articles concernés par l'association :</label> <b title="(Champ obligatoire)">obligatoire pour reçus fiscaux</b></dt>
|
||||
<dt><input type="checkbox" name="droit_art200" {form_field name="droit_art200" checked=1 data=$plugin.config } /><label>Article 200</label></dt>
|
||||
<dt><input type="checkbox" name="droit_art238bis" {form_field name="droit_art238bis" checked=1 data=$plugin.config } /><label>Article 238 bis</label></dt>
|
||||
<dt><input type="checkbox" name="droit_art885-0VbisA" {form_field name="droit_art885-0VbisA" checked=1 data=$plugin.config } /><label>Article 885-0V bis A</label></dt>
|
||||
{input type="checkbox" name="droit_art200" value="1" source=$plugin.config label="Article 200"}
|
||||
{input type="checkbox" name="droit_art238bis" value="1" source=$plugin.config label="Article 238 bis"}
|
||||
{input type="checkbox" name="droit_art885-0VbisA" value="1" source=$plugin.config label="Article 885-0V bis A"}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
@ -72,16 +60,15 @@
|
|||
<fieldset>
|
||||
<legend>Configuration du plugin</legend>
|
||||
<dl>
|
||||
<dt><input type="checkbox" name="validate_cp" id="f_validate_cp" {form_field data=$plugin.config name=validate_cp checked=1}> <label for="f_validate_cp">Vérifier le code postal lors de saisie/modification de client (seulement FR)</label></dt>
|
||||
<dt><input type="checkbox" name="unique_name" id="f_unique_name" {form_field data=$plugin.config name=unique_client_name checked=1}> <label for="f_unique_name">Noms des clients uniques</label></dt>
|
||||
|
||||
{input type="checkbox" name="validate_cp" value="1" source=$plugin.config label="Vérifier le code postal lors de saisie/modification de client (seulement FR)"}
|
||||
{input type="checkbox" name="unique_client_name" value="1" source=$plugin.config label="Noms des clients uniques"}
|
||||
</dl>
|
||||
<i>Pour personnaliser l'apparence de la facture, il faut pour l'instant se retrousser les manches et éditer soi-même le fichier www/admin/pdf.php du plugin ! </i>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{csrf_field key="facturation_config"}
|
||||
<input type="submit" name="save" value="Enregistrer →" />
|
||||
{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
@ -102,7 +89,7 @@
|
|||
</dl>
|
||||
<p class="submit">
|
||||
{csrf_field key="signature_config"}
|
||||
<input type="submit" name="upload" id="f_submit" value="Envoyer le fichier" />
|
||||
{button type="submit" name="upload" label="Envoyer le fichier" shape="right" class="main"}
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
{include file="admin/_head.tpl" title="Créer un reçu — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=1}
|
||||
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="facture"}
|
||||
|
||||
<style>
|
||||
{literal}
|
||||
#Line1 > .fact_rm_line {
|
||||
display: none;
|
||||
}
|
||||
{{/literal}}
|
||||
</style>
|
||||
|
||||
{form_errors}
|
||||
|
||||
<form method="post" action="{$self_url}">
|
||||
<ul class="actions">
|
||||
<li><a href="{plugin_url file="facture_ajouter.php?t=1"}">Facture</a></li>
|
||||
<li><a href="{plugin_url file="facture_ajouter.php?t=0"}">Devis</a></li>
|
||||
<li><a href="{plugin_url file="facture_ajouter.php?t=2"}">Reçu fiscal</a></li>
|
||||
<li class="current"><a href="{$self_url}">Reçu de cotisaition</a></li>
|
||||
</ul>
|
||||
|
||||
<fieldset>
|
||||
<legend>Créer une reçu de cotisation</legend>
|
||||
<dl>
|
||||
<dt><label for="f_numero_facture">Numéro de reçu</label> <b title="(Champ obligatoire et unique)">obligatoire et unique</b></dt>
|
||||
<dd><input type="numero" name="numero_facture" maxlength="12" id="f_numero_facture" value="{form_field name=numero_facture}"/></dd>
|
||||
<p> Chaque facture doit comporter un numéro unique délivré chronologiquement et de façon continue.<br>Il faut que le système adopté par l'association garantisse que deux factures émises la même année ne peuvent pas porter le même numéro. </p>
|
||||
<br>
|
||||
|
||||
<dt><label for="f_date_emission">Date d'édition</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="date" name="date_emission" id="f_date_emission" size="10" required="required" value="{form_field name=date_emission}"/></dd>
|
||||
|
||||
<dt><label for="f_archivee">Archivé</label></dt>
|
||||
<dd><input type="checkbox" name="archivee" id="f_archivee" disabled></dd>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Membre</legend>
|
||||
<dl>
|
||||
<dt><label>Reçu adressée à :</label></dt>
|
||||
<dd>
|
||||
<select class="type_membre" name="membre" id="f_membre" required="required">
|
||||
{foreach from=$membres item="membre"}
|
||||
<option value="{$membre.id}"{if $membre.id == $membre_id} selected="selected"{/if}>{$membre->$identite}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{csrf_field key="add_cotis_1"}
|
||||
<input type="submit" name="select" value="Sélectionner →" />
|
||||
</p>
|
||||
|
||||
|
||||
{if $step}
|
||||
|
||||
<fieldset>
|
||||
<legend>Cotisation</legend>
|
||||
<dl>
|
||||
<dt>Sélectionnez la cotisation concernée :</dt>
|
||||
|
||||
<table class='list'>
|
||||
<thead>
|
||||
<td></td>
|
||||
<td>Id</td>
|
||||
<td>Intitulé</td>
|
||||
<td>Montant</td>
|
||||
<td>Date (souscrit)</td>
|
||||
<td>Expiration (calculée)</td>
|
||||
</thead>
|
||||
|
||||
{foreach from=$liste item=cotis key=i}
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" name="cotisation" value="cotis_{$i}" id="f_cotis_{$i}"{if $radio == "cotis_{$i}"} checked{/if} >
|
||||
</td>
|
||||
{foreach from=$cotis item=element key=key}
|
||||
<td>
|
||||
<label for="f_cotis_{$i}">
|
||||
{if ($key == 'date' || $key == 'expiration') && $element > 0}
|
||||
{$element|date_fr:'d/m/Y'}
|
||||
{else}
|
||||
{$element}
|
||||
{/if}
|
||||
|
||||
<input type="hidden" name="{$key}_{$i}" value="{$element}">
|
||||
</label>
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{csrf_field key="add_cotis_2"}
|
||||
<input type="submit" name="add" value="Enregistrer →" />
|
||||
</p>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
{include file="%s/templates/_js.tpl"|args:$plugin_root}
|
||||
{include file="admin/_foot.tpl"}
|
|
@ -1,109 +0,0 @@
|
|||
{include file="admin/_head.tpl" title="Modifier un reçu — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=1}
|
||||
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="index"}
|
||||
|
||||
<style>
|
||||
{literal}
|
||||
#Line1 > .fact_rm_line {
|
||||
display: none;
|
||||
}
|
||||
{{/literal}}
|
||||
</style>
|
||||
|
||||
{form_errors}
|
||||
|
||||
<form method="post" action="{$self_url}">
|
||||
<ul class="actions">
|
||||
<li><a href="{plugin_url file="facture_ajouter.php?t=1"}">Facture</a></li>
|
||||
<li><a href="{plugin_url file="facture_ajouter.php?t=0"}">Devis</a></li>
|
||||
<li><a href="{plugin_url file="facture_ajouter.php?t=2"}">Reçu fiscal</a></li>
|
||||
<li class="current"><a href="{$self_url}">Reçu de cotisaition</a></li>
|
||||
</ul>
|
||||
|
||||
<fieldset>
|
||||
<legend>Créer une reçu de cotisation</legend>
|
||||
<dl>
|
||||
<dt><label for="f_numero_facture">Numéro de reçu</label> <b title="(Champ obligatoire et unique)">obligatoire et unique</b></dt>
|
||||
<dd><input type="numero" name="numero_facture" maxlength="12" id="f_numero_facture" value="{form_field data=$values name=numero_facture}"/></dd>
|
||||
<p> Chaque facture doit comporter un numéro unique délivré chronologiquement et de façon continue.<br>Il faut que le système adopté par l'association garantisse que deux factures émises la même année ne peuvent pas porter le même numéro. </p>
|
||||
<br>
|
||||
|
||||
<dt><label for="f_date_emission">Date d'édition</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="date" name="date_emission" id="f_date_emission" size="10" required="required" value="{form_field data=$values name=date_emission}"/></dd>
|
||||
|
||||
<dt><label for="f_archivee">Archivé</label></dt>
|
||||
<dd><input type="checkbox" name="archivee" id="f_archivee" disabled></dd>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Membre</legend>
|
||||
<dl>
|
||||
<dt><label>Reçu adressée à :</label></dt>
|
||||
<dd>
|
||||
<select class="type_membre" name="membre" id="f_membre" required="required">
|
||||
{foreach from=$membres item="membre"}
|
||||
<option value="{$membre.id}"{if $membre.id == $membre_id} selected="selected"{/if}>{$membre->$identite}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{csrf_field key="add_cotis_1"}
|
||||
<input type="submit" name="select" value="Sélectionner →" />
|
||||
</p>
|
||||
|
||||
|
||||
{* {if $step} *}
|
||||
|
||||
<fieldset>
|
||||
<legend>Cotisation</legend>
|
||||
<dl>
|
||||
<dt>Sélectionnez la cotisation concernée :</dt>
|
||||
|
||||
<table class='list'>
|
||||
<thead>
|
||||
<td></td>
|
||||
<td>Id</td>
|
||||
<td>Intitulé</td>
|
||||
<td>Montant</td>
|
||||
<td>Date (souscrit)</td>
|
||||
<td>Expiration (calculée)</td>
|
||||
</thead>
|
||||
|
||||
{foreach from=$liste item=cotis key=i}
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" name="cotisation" value="cotis_{$i}" id="f_cotis_{$i}"{if $radio == "cotis_{$i}"} checked{/if} >
|
||||
</td>
|
||||
{foreach from=$cotis item=element key=key}
|
||||
<td>
|
||||
<label for="f_cotis_{$i}">
|
||||
{if ($key == 'date' || $key == 'expiration') && $element > 0}
|
||||
{$element|date_fr:'d/m/Y'}
|
||||
{else}
|
||||
{$element}
|
||||
{/if}
|
||||
|
||||
<input type="hidden" name="{$key}_{$i}" value="{$element}">
|
||||
</label>
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{csrf_field key="add_cotis_2"}
|
||||
<input type="submit" name="add" value="Enregistrer →" />
|
||||
</p>
|
||||
</form>
|
||||
{* {/if} *}
|
||||
|
||||
{include file="%s/templates/_js.tpl"|args:$plugin_root}
|
||||
{include file="admin/_foot.tpl"}
|
|
@ -4,11 +4,7 @@
|
|||
{form_errors}
|
||||
|
||||
{if $session->canAccess('compta', Membres::DROIT_ECRITURE)}
|
||||
{if $type == 3}
|
||||
<a href="{plugin_url file="cotis_modifier.php"}?id={$facture.id}">
|
||||
{else}
|
||||
<a href="{plugin_url file="facture_modifier.php"}?id={$facture.id}">
|
||||
{/if}
|
||||
<a href="{plugin_url file="facture_modifier.php"}?id={$facture.id}">
|
||||
<button type="button" class="btn btn-primary">Modifier ce document</button></a>
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -1,75 +1,84 @@
|
|||
{include file="admin/_head.tpl" title="Créer un document — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id js=1}
|
||||
{include file="%s/templates/_menu.tpl"|args:$plugin_root current="facture"}
|
||||
|
||||
<style>
|
||||
{literal}
|
||||
#Line1 > .fact_rm_line {
|
||||
display: none;
|
||||
}
|
||||
{{/literal}}
|
||||
</style>
|
||||
|
||||
{form_errors}
|
||||
|
||||
<form method="post" action="{$self_url}">
|
||||
<ul class="actions">
|
||||
<li><input type="radio" name="type" value="facture" {form_field data=$radio name=type checked=facture default=facture} id="f_type_facture"/><label for="f_type_facture">Facture</label></li>
|
||||
<li><input type="radio" name="type" value="devis" {form_field data=$radio name=type checked=devis} id="f_type_devis" /><label for="f_type_devis">Devis</label></li>
|
||||
<li><input type="radio" name="type" value="cerfa" {form_field data=$radio name=type checked=cerfa} id="f_type_cerfa"/><label for="f_type_cerfa">Reçu fiscal</label></li>
|
||||
<li><a href="{plugin_url file="cotis_ajouter.php"}"/>Reçu de cotisaition</a></li>
|
||||
</ul>
|
||||
|
||||
<fieldset>
|
||||
<legend>Créer une facture</legend>
|
||||
<legend>Type d'écriture</legend>
|
||||
<dl>
|
||||
|
||||
<dt><label for="f_numero_facture">Numéro facture</label> <b title="(Champ obligatoire et unique)">obligatoire et unique</b></dt>
|
||||
<dd><input type="numero" name="numero_facture" maxlength="12" id="f_numero_facture" value="{form_field name=numero_facture}"/></dd>
|
||||
<p> Chaque facture doit comporter un numéro unique délivré chronologiquement et de façon continue.<br>Il faut que le système adopté par l'association garantisse que deux factures émises la même année ne peuvent pas porter le même numéro. </p>
|
||||
<br>
|
||||
|
||||
<dt><label for="f_date_emission">Date d'émission</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="date" name="date_emission" id="f_date_emission" size="10" required="required" value="{form_field name=date_emission}"/></dd>
|
||||
|
||||
<dt><label for="f_date_echeance">Date d'échéance</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="date" name="date_echeance" id="f_date_echeance" size="10" required="required" value="{form_field name=date_echeance}"/></dd>
|
||||
|
||||
<dt><label for="f_reglee">Réglée</label></dt>
|
||||
<dd><input type="checkbox" name="reglee" id="f_reglee" {form_field name=reglee checked=on default=off}></dd>
|
||||
|
||||
<dt><label for="f_archivee">Archivée</label></dt>
|
||||
<dd><input type="checkbox" name="archivee" id="f_archivee" disabled></dd>
|
||||
|
||||
{foreach from=$types_details item="type"}
|
||||
<dd class="radio-btn">
|
||||
{input type="radio" name="type" value=$type.id source=$radio label=null}
|
||||
<label for="f_type_{$type.id}">
|
||||
<div>
|
||||
<h3>{$type.label}</h3>
|
||||
{if !empty($type.help)}
|
||||
<p>{$type.help}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</label>
|
||||
</dd>
|
||||
{/foreach}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend data-types="t0">Créer un devis</legend>
|
||||
<legend data-types="t1">Créer une facture</legend>
|
||||
<legend data-types="t2">Créer un reçu fiscal</legend>
|
||||
<legend data-types="t3">Créer un reçu de cotisation</legend>
|
||||
<dl>
|
||||
|
||||
{input type="text" name="numero_facture" maxlength=12 label="Numéro du document" required=1 help="Chaque document doit comporter un numéro unique délivré chronologiquement et de façon continue. Il faut que le système adopté par l'association garantisse que deux factures émises la même année ne peuvent pas porter le même numéro."}
|
||||
|
||||
{input type="date" name="date_emission" default=$date label="Date d'émission" required=1 }
|
||||
<dd class="help" data-types="t2">
|
||||
<p>Date du versemen du don</p>
|
||||
</dd>
|
||||
<div data-types="t0 t1 t2">
|
||||
{input type="date" name="date_echeance" default=$date label="Date d'échéance" required=1 }
|
||||
<dd class="help" data-types="t2">
|
||||
<p>Date d'établissement du document</p>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<dt><label>Statut</label></dt>
|
||||
|
||||
{input type="checkbox" name="reglee" value="" label="Réglée" data-types="t1"}
|
||||
<div data-types="t0 t1 t2">
|
||||
{input type="checkbox" name="archivee" value="" label="Archivée" disabled="disabled"}
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset data-types="t0 t1 t2">
|
||||
<legend>Client</legend>
|
||||
|
||||
<dl>
|
||||
<dt><label>Facture adressée à un·e :</label></dt>
|
||||
<dt><label>Document adressée à :</label></dt>
|
||||
{if !empty($clients)}
|
||||
<dd>
|
||||
<input type="radio" name="base_receveur" value="membre" id="f_base_membre" {form_field name=base_receveur checked=membre}/><label for="f_base_membre"> Membre</label>
|
||||
<input type="radio" name="base_receveur" value="client" id="f_base_client" {form_field name=base_receveur checked=client default=client}/><label for="f_base_client"> Client·e</label>
|
||||
{input type="radio" name="base_receveur" value="membre" label="Un·e membre" default=1}
|
||||
{input type="radio" name="base_receveur" value="client" label="Un·e client·e"}
|
||||
</dd>
|
||||
{/if}
|
||||
|
||||
<dt><label>Client</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd>
|
||||
<select class="type_membre" name="membre" id="f_membre" required="required">
|
||||
{foreach from=$membres item="membre"}
|
||||
<option value="{$membre.id}"{if $membre.id == $membre_id} selected="selected"{/if}>{$membre->$identite}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<select class="type_client" name="client" id="f_client" required="required">
|
||||
{foreach from=$clients item="client"}
|
||||
<option value="{$client.id}"{if $client.id == $client_id} selected="selected"{/if}>{$client.nom}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
<div class="type_membre">
|
||||
{input type="select" name="membre" label="Membre" options=$membres required=1}
|
||||
</div>
|
||||
|
||||
{if !empty($clients)}
|
||||
<div class="type_client">
|
||||
{input type="select" name="client" label="Client" options=$clients required=1 class="type_client"}
|
||||
</div>
|
||||
{/if}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<fieldset data-types="t0 t1 t2">
|
||||
<legend>Contenu</legend>
|
||||
|
||||
<dl>
|
||||
|
@ -102,7 +111,7 @@
|
|||
<tr id="Line1" class="hidden">
|
||||
<td><textarea name="designation[]" style="width:98%;"></textarea></td>
|
||||
<td><input type="number" step="0.01" value="0" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
|
||||
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
|
||||
<td class="fact_rm_line">{button label="Enlever" title="Enlever la ligne" shape="minus" min="2" name="remove_line"}</td>
|
||||
</tr>
|
||||
|
||||
{foreach from=$designations item=designation key=key}
|
||||
|
@ -110,7 +119,7 @@
|
|||
<tr>
|
||||
<td><textarea name="designation[]" style="width:98%;">{$designation}</textarea></td>
|
||||
<td><input type="number" step="0.01" value="{$prix[$key]}" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
|
||||
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
|
||||
<td class="fact_rm_line">{button label="Enlever" title="Enlever la ligne" shape="minus" min="2" name="remove_line"}</td>
|
||||
</tr>
|
||||
|
||||
{/foreach}
|
||||
|
@ -120,7 +129,7 @@
|
|||
<tr id="Line1">
|
||||
<td><textarea name="designation[]" style="width:98%;"></textarea></td>
|
||||
<td><input type="number" step="0.01" value="0" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
|
||||
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
|
||||
<td class="fact_rm_line">{button label="Enlever" title="Enlever la ligne" shape="minus" min="2" name="remove_line"}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
|
@ -128,21 +137,99 @@
|
|||
<tr>
|
||||
<td style="text-align: right;">Total :</td>
|
||||
<td><span id="total">0.00</span> €</td>
|
||||
<td></td>
|
||||
<td>{button label="Ajouter" title="Ajouter une ligne" id="ajouter_ligne" shape="plus"}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<button type="button" id="ajouter_ligne">Ajouter une ligne</button>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
{include file="%s/templates/_js.tpl"|args:$plugin_root}
|
||||
|
||||
<p class="submit">
|
||||
<p class="submit" data-types="t0 t1 t2">
|
||||
{csrf_field key="ajout_facture"}
|
||||
<input type="submit" name="add" value="Enregistrer →" />
|
||||
{button type="submit" name="add" label="Enregistrer" shape="right" class="main"}
|
||||
</p>
|
||||
|
||||
<fieldset data-types="t3">
|
||||
<legend>Membre</legend>
|
||||
<dl>
|
||||
<dt><label>Reçu adressée à :</label></dt>
|
||||
<dd>
|
||||
{input type="select" name="membre" label="Membre" options=$membres required=1}
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit" data-types="t3">
|
||||
{csrf_field key="add_cotis_1"}
|
||||
{button type="submit" name="select_cotis" label="Sélectionner" shape="right" class="main"}
|
||||
</p>
|
||||
|
||||
|
||||
{if $step}
|
||||
<fieldset data-types="t3">
|
||||
<legend>Cotisation</legend>
|
||||
{if count($liste)}
|
||||
<dl>
|
||||
<dt>Sélectionnez la cotisation concernée :</dt>
|
||||
|
||||
<table class='list'>
|
||||
<thead>
|
||||
<td></td>
|
||||
<td>Id</td>
|
||||
<td>Intitulé</td>
|
||||
<td>Date d'inscription</td>
|
||||
<td>Expiration d'expiration</td>
|
||||
<td>Tarif</td>
|
||||
<td>Montant</td>
|
||||
<td>Somme payée</td>
|
||||
</thead>
|
||||
|
||||
{foreach from=$liste item=cotis key=i}
|
||||
{if !$cotis.paid}
|
||||
{continue}
|
||||
{/if}
|
||||
<tr>
|
||||
<td>
|
||||
{input type="radio" name="cotisation" value="%s"|args:$i}
|
||||
</td>
|
||||
{foreach from=$cotis item=element key=key}
|
||||
{if $key == 'paid'}
|
||||
{continue}
|
||||
{/if}
|
||||
<td>
|
||||
<label for="f_cotisation_{$i}">
|
||||
{if ($key == 'date' || $key == 'expiry') && $element > 0}
|
||||
{$element|date_short}
|
||||
{elseif $key == 'amount' OR $key == 'paid_amount'}
|
||||
{$element|raw|money_currency}
|
||||
{else}
|
||||
{$element}
|
||||
{/if}
|
||||
|
||||
<input type="hidden" name="{$key}_{$i}" value="{$element}">
|
||||
</label>
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit" data-types="t3">
|
||||
{csrf_field key="add_cotis_2"}
|
||||
{button type="submit" name="add_cotis" label="Enregistrer" shape="right" class="main"}
|
||||
</p>
|
||||
{else}
|
||||
<p>Ce membre n'a aucune cotisation payée.</p>
|
||||
</fieldset>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</form>
|
||||
|
||||
{include file="%s/templates/_js.tpl"|args:$plugin_root}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
||||
|
|
|
@ -3,86 +3,86 @@
|
|||
|
||||
{form_errors}
|
||||
|
||||
<style>
|
||||
{literal}
|
||||
#Line1 > .fact_rm_line {
|
||||
display: none;
|
||||
}
|
||||
{{/literal}}
|
||||
</style>
|
||||
|
||||
{form_errors}
|
||||
|
||||
<form method="post" action="{$self_url}">
|
||||
<ul class="actions">
|
||||
<li><input type="radio" name="type" value="facture" {form_field name=type data=$doc checked=facture default=facture} id="f_type_facture"/><label for="f_type_facture">Facture</label></li>
|
||||
<li><input type="radio" name="type" value="devis" {form_field name=type data=$doc checked=devis} id="f_type_devis"/><label for="f_type_devis">Devis</label></li>
|
||||
<li><input type="radio" name="type" value="cerfa" {form_field name=type data=$doc checked=cerfa} id="f_type_cerfa"/><label for="f_type_cerfa">Reçu fiscal</label></li>
|
||||
<li><input type="radio" name="type" value="cotis" {form_field name=type data=$doc checked=cotis} id="f_type_cotis"/><label for="f_type_cotis">Reçu de cotisation</label></li>
|
||||
</ul>
|
||||
|
||||
<fieldset>
|
||||
<legend>Créer une facture</legend>
|
||||
<legend>Type d'écriture</legend>
|
||||
<dl>
|
||||
|
||||
<dt><label for="f_numero_facture">Numéro facture</label> <b title="(Champ obligatoire et unique)">obligatoire et unique</b></dt>
|
||||
<dd><input type="numero" name="numero_facture" maxlength="12" id="f_numero_facture" value="{form_field name=numero_facture data=$doc}"/></dd>
|
||||
<p>Chaque facture doit comporter un numéro unique délivré chronologiquement et de façon continue.<br>Il faut que le système adopté par l'association garantisse que deux factures émises la même année ne peuvent pas porter le même numéro. </p>
|
||||
<br>
|
||||
|
||||
<dt><label for="f_date_emission">Date d'émission</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="date" name="date_emission" id="f_date_emission" size="10" required="required" value="{$date_emission|date_fr:'Y-m-d'}"/></dd>
|
||||
|
||||
<dt><label for="f_date_echeance">Date d'échéance</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd><input type="date" name="date_echeance" id="f_date_echeance" size="10" required="required" value="{$date_echeance|date_fr:'Y-m-d'}"/></dd>
|
||||
|
||||
<dt><label for="f_reglee">Réglée</label></dt>
|
||||
<dd><input type="checkbox" name="reglee" id="f_reglee" {form_field data=$doc name=reglee checked=on}></dd>
|
||||
|
||||
<dt><label for="f_archivee">Archivée</label></dt>
|
||||
<dd><input type="checkbox" name="archivee" id="f_archivee" {form_field data=$doc name=archivee checked=on} disabled></dd>
|
||||
|
||||
{foreach from=$types_details item="type"}
|
||||
<dd class="radio-btn">
|
||||
{input type="radio" name="type" value=$type.id source=$radio label=null}
|
||||
<label for="f_type_{$type.id}">
|
||||
<div>
|
||||
<h3>{$type.label}</h3>
|
||||
{if !empty($type.help)}
|
||||
<p>{$type.help}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</label>
|
||||
</dd>
|
||||
{/foreach}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend data-types="t0">Créer un devis</legend>
|
||||
<legend data-types="t1">Créer une facture</legend>
|
||||
<legend data-types="t2">Créer un reçu fiscal</legend>
|
||||
<legend data-types="t3">Créer un reçu de cotisation</legend>
|
||||
<dl>
|
||||
|
||||
{input type="text" name="numero_facture" maxlength=12 label="Numéro du document" required=1 source=$doc help="Chaque document doit comporter un numéro unique délivré chronologiquement et de façon continue. Il faut que le système adopté par l'association garantisse que deux factures émises la même année ne peuvent pas porter le même numéro."}
|
||||
|
||||
{input type="date" name="date_emission" default=$date label="Date d'émission" required=1 source=$doc}
|
||||
<dd class="help" data-types="t2">
|
||||
<p>Date du versemen du don</p>
|
||||
</dd>
|
||||
<div data-types="t0 t1 t2">
|
||||
{input type="date" name="date_echeance" default=$date label="Date d'échéance" required=1 source=$doc}
|
||||
<dd class="help" data-types="t2">
|
||||
<p>Date d'établissement du document</p>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<dt><label>Statut</label></dt>
|
||||
|
||||
{input type="checkbox" name="reglee" value="1" label="Réglée" source=$doc data-types="t1"}
|
||||
<div data-types="t0 t1 t2">
|
||||
{input type="checkbox" name="archivee" value="1" label="Archivée" source=$doc disabled="disabled"}
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset data-types="t0 t1 t2">
|
||||
<legend>Client</legend>
|
||||
|
||||
<dl>
|
||||
<dt><label>Facture adressée à un·e :</label></dt>
|
||||
<dt><label>Document adressée à :</label></dt>
|
||||
{if !empty($clients)}
|
||||
<dd>
|
||||
<input type="radio" name="base_receveur" value="membre" id="f_base_membre"{form_field data=$doc name=base_receveur checked=membre default=membre}/><label for="f_base_membre"> Membre</label>
|
||||
<input type="radio" name="base_receveur" value="client" id="f_base_client" {form_field data=$doc name=base_receveur checked=client}/><label for="f_base_client"> Client·e</label>
|
||||
{input type="radio" name="base_receveur" value="membre" source=$doc label="Un·e membre"}
|
||||
{input type="radio" name="base_receveur" value="client" source=$doc label="Un·e client·e"}
|
||||
</dd>
|
||||
|
||||
<dt><label>Client</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd>
|
||||
<select class="type_membre" name="membre_id" id="f_membre" required="required">
|
||||
{foreach from=$membres item="membre"}
|
||||
<option value="{$membre.id}"{form_field data=$doc name=membre_id selected=$membre.id}>{$membre->$identite}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<select class="type_client" name="client_id" id="f_client" required="required">
|
||||
{foreach from=$clients item="client"}
|
||||
<option value="{$client.id}"{form_field data=$doc name=client_id selected=$client.id}>{$client.nom}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{/if}
|
||||
<div class="type_membre">
|
||||
{input type="select" name="membre" label="Membre" options=$membres required=1 source=$doc}
|
||||
</div>
|
||||
|
||||
{if !empty($clients)}
|
||||
<div class="type_client">
|
||||
{input type="select" name="client" label="Client" options=$clients required=1 source=$doc class="type_client"}
|
||||
</div>
|
||||
{/if}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<fieldset data-types="t0 t1 t2">
|
||||
<legend>Contenu</legend>
|
||||
|
||||
<dl>
|
||||
<dt><label for="f_moyen_paiement">Moyen de paiement</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
|
||||
<dd>
|
||||
<select name="moyen_paiement" id="f_moyen_paiement" required="required">
|
||||
{foreach from=$doc.moyens_paiement item="moyen"}
|
||||
<option value="{$moyen.code}"{form_field data=$doc name=moyen_paiement selected=$moyen.code}>{$moyen.nom}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{input type="select" name="moyen_paiement" required=1 label="Moyen de paiement" source=$doc options=$doc.moyens_paiement}
|
||||
|
||||
<dt><label for="f_contenu">Contenu du document</label><dt>
|
||||
<dd>
|
||||
|
@ -104,7 +104,7 @@
|
|||
<tr id="Line1" class="hidden">
|
||||
<td><textarea name="designation[]" style="width:98%;"></textarea></td>
|
||||
<td><input type="number" step="0.01" value="0" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
|
||||
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
|
||||
<td class="fact_rm_line">{button label="Enlever" title="Enlever la ligne" shape="minus" min="2" name="remove_line"}</td>
|
||||
</tr>
|
||||
|
||||
{foreach from=$designations item=designation key=key}
|
||||
|
@ -112,7 +112,7 @@
|
|||
<tr>
|
||||
<td><textarea name="designation[]" style="width:98%;">{$designation}</textarea></td>
|
||||
<td><input type="number" step="0.01" value="{$prix[$key]}" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
|
||||
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
|
||||
<td class="fact_rm_line">{button label="Enlever" title="Enlever la ligne" shape="minus" min="2" name="remove_line"}</td>
|
||||
</tr>
|
||||
|
||||
{/foreach}
|
||||
|
@ -122,7 +122,7 @@
|
|||
<tr id="Line1">
|
||||
<td><textarea name="designation[]" style="width:98%;"></textarea></td>
|
||||
<td><input type="number" step="0.01" value="0" style="width: 60%" onchange="updateSum();" name="prix[]"><span style="position: relative;right: 50px;">€</span></td>
|
||||
<td class="fact_rm_line"><button type="button" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);updateSum();">Supprimer</button></td>
|
||||
<td class="fact_rm_line">{button label="Enlever" title="Enlever la ligne" shape="minus" min="2" name="remove_line"}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
|
@ -130,22 +130,99 @@
|
|||
<tr>
|
||||
<td style="text-align: right;">Total :</td>
|
||||
<td><span id="total">0.00</span> €</td>
|
||||
<td></td>
|
||||
<td>{button label="Ajouter" title="Ajouter une ligne" id="ajouter_ligne" shape="plus"}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<button type="button" id="ajouter_ligne">Ajouter une ligne</button>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
{include file="%s/templates/_js.tpl"|args:$plugin_root}
|
||||
|
||||
<p class="submit">
|
||||
<p class="submit" data-types="t0 t1 t2">
|
||||
{csrf_field key="modifier_facture"}
|
||||
<input type="submit" name="save" value="Enregistrer →" />
|
||||
{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}
|
||||
</p>
|
||||
|
||||
<fieldset data-types="t3">
|
||||
<legend>Membre</legend>
|
||||
<dl>
|
||||
<dt><label>Reçu adressée à :</label></dt>
|
||||
<dd>
|
||||
{input type="select" name="membre" label="Membre" options=$membres required=1 source=$doc}
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit" data-types="t3">
|
||||
{csrf_field key="add_cotis_1"}
|
||||
{button type="submit" name="select_cotis" label="Sélectionner" shape="right" class="main"}
|
||||
</p>
|
||||
|
||||
|
||||
{if $step}
|
||||
<fieldset data-types="t3">
|
||||
<legend>Cotisation</legend>
|
||||
{if count($liste)}
|
||||
<dl>
|
||||
<dt>Sélectionnez la cotisation concernée :</dt>
|
||||
|
||||
<table class='list'>
|
||||
<thead>
|
||||
<td></td>
|
||||
<td>Id</td>
|
||||
<td>Intitulé</td>
|
||||
<td>Date d'inscription</td>
|
||||
<td>Expiration d'expiration</td>
|
||||
<td>Tarif</td>
|
||||
<td>Montant</td>
|
||||
<td>Somme payée</td>
|
||||
</thead>
|
||||
|
||||
{foreach from=$liste item=cotis key=i}
|
||||
{if !$cotis.paid}
|
||||
{continue}
|
||||
{/if}
|
||||
<tr>
|
||||
<td>
|
||||
{input type="radio" name="cotisation" value="%s"|args:$i}
|
||||
</td>
|
||||
{foreach from=$cotis item=element key=key}
|
||||
{if $key == 'paid'}
|
||||
{continue}
|
||||
{/if}
|
||||
<td>
|
||||
<label for="f_cotisation_{$i}">
|
||||
{if ($key == 'date' || $key == 'expiry') && $element > 0}
|
||||
{$element|date_short}
|
||||
{elseif $key == 'amount' OR $key == 'paid_amount'}
|
||||
{$element|raw|money_currency}
|
||||
{else}
|
||||
{$element}
|
||||
{/if}
|
||||
|
||||
<input type="hidden" name="{$key}_{$i}" value="{$element}">
|
||||
</label>
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit" data-types="t3">
|
||||
{csrf_field key="add_cotis_2"}
|
||||
{button type="submit" name="add_cotis" label="Enregistrer" shape="right" class="main"}
|
||||
</p>
|
||||
{else}
|
||||
<p>Ce membre n'a aucune cotisation payée.</p>
|
||||
</fieldset>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</form>
|
||||
|
||||
{include file="%s/templates/_js.tpl"|args:$plugin_root}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
45
upgrade.php
45
upgrade.php
|
@ -31,3 +31,48 @@ if (version_compare($infos->version, '0.3.0', '<'))
|
|||
}
|
||||
$db->exec('DROP TABLE `plugin_facturation_config`;');
|
||||
}
|
||||
|
||||
// 0.3.0 - Migration Facturation\Config vers la table plugins
|
||||
if (version_compare($infos->version, '0.4.0', '<'))
|
||||
{
|
||||
$db->exec(<<<EOT
|
||||
CREATE TABLE IF NOT EXISTS plugin_facturation_paiement
|
||||
-- Moyens de paiement
|
||||
(
|
||||
code TEXT NOT NULL PRIMARY KEY,
|
||||
nom TEXT NOT NULL
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('CB', 'Carte bleue');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('CH', 'Chèque');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('ES', 'Espèces');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('PR', 'Prélèvement');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('TI', 'TIP');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('VI', 'Virement');
|
||||
INSERT OR IGNORE INTO plugin_facturation_paiement (code, nom) VALUES ('AU', 'Autre');
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS plugin_facturation_factures_tmp
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
type_facture INTEGER NOT NULL DEFAULT 0,
|
||||
numero TEXT NOT NULL UNIQUE,
|
||||
receveur_membre INTEGER NOT NULL, -- bool
|
||||
receveur_id INTEGER NOT NULL,
|
||||
date_emission TEXT NOT NULL, -- CHECK (date(date_emission) IS NOT NULL AND date(date_emission) = date_emission),
|
||||
date_echeance TEXT NOT NULL, -- CHECK (date(date_echeance) IS NOT NULL AND date(date_echeance) = date_echeance),
|
||||
reglee INTEGER DEFAULT 0, -- bool
|
||||
archivee INTEGER DEFAULT 0, -- bool
|
||||
moyen_paiement TEXT NOT NULL,
|
||||
contenu TEXT NOT NULL,
|
||||
total REAL DEFAULT 0
|
||||
|
||||
-- FOREIGN KEY(moyen_paiement) REFERENCES plugin_facturation_paiement(code)
|
||||
);
|
||||
|
||||
INSERT INTO plugin_facturation_factures_tmp SELECT * FROM plugin_facturation_factures;
|
||||
DROP TABLE plugin_facturation_factures;
|
||||
ALTER TABLE plugin_facturation_factures_tmp RENAME TO plugin_facturation_factures;
|
||||
|
||||
EOT );
|
||||
}
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
namespace Garradin;
|
||||
|
||||
define('DEVIS', 0);
|
||||
define('FACT', 1);
|
||||
define('CERFA', 2);
|
||||
define('COTIS', 3);
|
||||
|
||||
use Garradin\Plugin\Facturation\Facture;
|
||||
use Garradin\Plugin\Facturation\Client;
|
||||
use Garradin\Plugin\Facturation\GenDon;
|
||||
|
@ -9,4 +14,6 @@ use Garradin\Plugin\Facturation\GenDon;
|
|||
$client = new Client;
|
||||
$facture = new Facture;
|
||||
|
||||
$tpl->assign('f_obj', $facture);
|
||||
|
||||
$identite = (string) Config::getInstance()->get('champ_identite');
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace Garradin;
|
||||
|
||||
// Trick to migrate from v0.3 to v0.4, before upgrading Garradin to 1.0
|
||||
// Remove in future versions?
|
||||
$plugin = new Plugin('facturation');
|
||||
|
||||
if ($plugin->needUpgrade())
|
||||
{
|
||||
$plugin->upgrade();
|
||||
}
|
||||
|
||||
unset($plugin);
|
|
@ -12,10 +12,10 @@ if (f('save') && $form->check('facturation_config'))
|
|||
$plugin->setConfig('rna_asso', trim(f('rna_asso')));
|
||||
$plugin->setConfig('siret_asso', trim(f('siret_asso')));
|
||||
|
||||
$plugin->setConfig('numero_rue_asso', trim(f('numero_rue')));
|
||||
$plugin->setConfig('rue_asso', trim(f('rue')));
|
||||
$plugin->setConfig('cp_asso', trim(f('codepostal')));
|
||||
$plugin->setConfig('ville_asso', trim(f('ville')));
|
||||
$plugin->setConfig('numero_rue_asso', trim(f('numero_rue_asso')));
|
||||
$plugin->setConfig('rue_asso', trim(f('rue_asso')));
|
||||
$plugin->setConfig('cp_asso', trim(f('cp_asso')));
|
||||
$plugin->setConfig('ville_asso', trim(f('ville_asso')));
|
||||
|
||||
$plugin->setConfig('droit_art200', (bool)f('droit_art200'));
|
||||
$plugin->setConfig('droit_art238bis', (bool)f('droit_art238bis'));
|
||||
|
@ -27,7 +27,7 @@ if (f('save') && $form->check('facturation_config'))
|
|||
$plugin->setConfig('footer', f('footer'));
|
||||
|
||||
$plugin->setConfig('validate_cp', (bool)f('validate_cp'));
|
||||
$plugin->setConfig('unique_client_name', (bool)f('unique_name'));
|
||||
$plugin->setConfig('unique_client_name', (bool)f('unique_client_name'));
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'config.php?ok');
|
||||
}
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ECRITURE);
|
||||
|
||||
use Garradin\DB;
|
||||
|
||||
$db = DB::getInstance();
|
||||
|
||||
|
||||
$step = $radio = false;
|
||||
$liste = [];
|
||||
|
||||
$fields = $facture->recu_fields;
|
||||
|
||||
if (f('select'))
|
||||
{
|
||||
$form->check('add_cotis_1',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
]);
|
||||
|
||||
$step = true;
|
||||
}
|
||||
elseif (f('add'))
|
||||
{
|
||||
$form->check('add_cotis_2',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
'cotisation' => 'required',
|
||||
]);
|
||||
|
||||
$radio = f('cotisation');
|
||||
|
||||
if (!$form->hasErrors())
|
||||
{
|
||||
try
|
||||
{
|
||||
$num = (int) str_replace('cotis_', '', $radio);
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$cotis[$field] = f($field.'_'.$num);
|
||||
}
|
||||
|
||||
$cotis['date'] = date('Y-m-d', $cotis['date']);
|
||||
$cotis['expiration'] = date('Y-m-d', $cotis['expiration']);
|
||||
|
||||
$r = $db->get('SELECT moyen_paiement, montant FROM membres_operations AS mo INNER JOIN compta_journal AS cj ON cj.id = mo.id_operation
|
||||
WHERE mo.id_cotisation = ?;', (int)$cotis['id']);
|
||||
$r = $r[0];
|
||||
|
||||
$data = [
|
||||
'type_facture' => 3,
|
||||
'numero' => f('numero_facture'),
|
||||
'receveur_membre' => 1,
|
||||
'receveur_id' => f('membre'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'moyen_paiement' => $r->moyen_paiement,
|
||||
'total' => $r->montant,
|
||||
'contenu' => ['id' => $cotis['id'],
|
||||
'intitule' => $cotis['intitule'],
|
||||
'souscription' => $cotis['date'],
|
||||
'expiration' => $cotis['expiration'] ]
|
||||
];
|
||||
|
||||
$id = $facture->add($data);
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$step = true;
|
||||
}
|
||||
|
||||
|
||||
if ($step)
|
||||
{
|
||||
try
|
||||
{
|
||||
$r = $facture->getCotis((int)f('membre'));
|
||||
// Passe les expiration nulles (cotis ponctuelle) à 0 pour avoir moins d'embrouilles
|
||||
foreach ($r as $i=>$cotis)
|
||||
{
|
||||
foreach($cotis as $k=>$v)
|
||||
{
|
||||
if (in_array($k, $fields))
|
||||
{
|
||||
$liste[$i][$k] = $v;
|
||||
}
|
||||
}
|
||||
if($liste[$i]['expiration'] < 0)
|
||||
{
|
||||
$liste[$i]['expiration'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tpl->assign('liste', $liste);
|
||||
$tpl->assign('radio', $radio);
|
||||
|
||||
$tpl->assign('step', $step);
|
||||
$tpl->assign('identite', $identite);
|
||||
$tpl->assign('membre_id', f('membre') ?: -1);
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/cotis_ajouter.tpl');
|
|
@ -1,141 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ECRITURE);
|
||||
|
||||
use Garradin\DB;
|
||||
|
||||
$db = DB::getInstance();
|
||||
|
||||
|
||||
qv(['id' => 'required|numeric']);
|
||||
$id = (int) qg('id');
|
||||
|
||||
if (!$f = $facture->get($id))
|
||||
{
|
||||
throw new UserException("Ce document n'existe pas.");
|
||||
}
|
||||
|
||||
$fields = $facture->recu_fields;
|
||||
|
||||
$membre_id = f('membre') ?: $f->receveur_id;
|
||||
|
||||
$values['numero_facture'] = $f->numero;
|
||||
$values['date_emission'] = date('Y-m-d', $f->date_emission);
|
||||
|
||||
$radio = '';
|
||||
$liste = [];
|
||||
|
||||
|
||||
if (f('select'))
|
||||
{
|
||||
$form->check('add_cotis_1',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
]);
|
||||
|
||||
}
|
||||
elseif (f('add'))
|
||||
{
|
||||
$form->check('add_cotis_2',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
'cotisation' => 'required',
|
||||
]);
|
||||
|
||||
$radio = f('cotisation');
|
||||
|
||||
if (!$form->hasErrors())
|
||||
{
|
||||
try
|
||||
{
|
||||
$num = (int) str_replace('cotis_', '', $radio);
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$cotis[$field] = f($field.'_'.$num);
|
||||
}
|
||||
|
||||
$cotis['date'] = date('Y-m-d', $cotis['date']);
|
||||
$cotis['expiration'] = date('Y-m-d', $cotis['expiration']);
|
||||
|
||||
$r = $db->get('SELECT moyen_paiement, montant FROM membres_operations AS mo INNER JOIN compta_journal AS cj ON cj.id = mo.id_operation
|
||||
WHERE mo.id_cotisation = ?;', (int)$cotis['id']);
|
||||
$r = $r[0];
|
||||
|
||||
$data = [
|
||||
'type_facture' => 3,
|
||||
'numero' => f('numero_facture'),
|
||||
'receveur_membre' => 1,
|
||||
'receveur_id' => f('membre'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'moyen_paiement' => $r->moyen_paiement,
|
||||
'total' => $r->montant,
|
||||
'contenu' => ['id' => $cotis['id'],
|
||||
'intitule' => $cotis['intitule'],
|
||||
'souscription' => $cotis['date'],
|
||||
'expiration' => $cotis['expiration'] ]
|
||||
];
|
||||
|
||||
if($facture->edit($id, $data))
|
||||
{
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
}
|
||||
throw new UserException('Erreur d\'édition du reçu');
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
$r = $facture->getCotis((int)$membre_id);
|
||||
// Garde seulement les champs requis
|
||||
// Rattrape le bouton radio à pré-sélectionner
|
||||
// Passe les expiration nulles (cotis ponctuelle) à 0 pour avoir moins d'embrouilles
|
||||
foreach ($r as $i=>$cotis)
|
||||
{
|
||||
foreach($cotis as $k=>$v)
|
||||
{
|
||||
if (in_array($k, $fields))
|
||||
{
|
||||
$liste[$i][$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if($liste[$i]['id'] == $f->contenu['id'])
|
||||
{
|
||||
$radio = 'cotis_'.$i;
|
||||
}
|
||||
|
||||
if($liste[$i]['expiration'] < 0)
|
||||
{
|
||||
$liste[$i]['expiration'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
$tpl->assign('liste', $liste);
|
||||
$tpl->assign('radio', $radio);
|
||||
$tpl->assign('values', $values);
|
||||
|
||||
// $tpl->assign('step', $step);
|
||||
$tpl->assign('identite', $identite);
|
||||
$tpl->assign('membre_id', $membre_id);
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/cotis_modifier.tpl');
|
|
@ -7,24 +7,31 @@ require_once __DIR__ . '/_inc.php';
|
|||
$session->requireAccess('compta', Membres::DROIT_ECRITURE);
|
||||
|
||||
use Garradin\DB;
|
||||
use stdClass;
|
||||
|
||||
$cats = new Compta\Categories;
|
||||
$tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
|
||||
$db = DB::getInstance();
|
||||
|
||||
$step = $radio = false;
|
||||
$liste = [];
|
||||
|
||||
$fields = $facture->recu_fields;
|
||||
|
||||
$tpl->assign('moyens_paiement', $facture->listMoyensPaiement());
|
||||
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
|
||||
|
||||
if (f('add'))
|
||||
{
|
||||
$form->check('ajout_facture', [
|
||||
'type' => 'required|in:facture,devis,cerfa,cotis',
|
||||
'type' => 'required|in:'.implode(',', [DEVIS, FACT, CERFA]),
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'date_echeance' => 'required|date',
|
||||
'date_emission' => 'required|date_format:d/m/Y',
|
||||
'date_echeance' => 'required|date_format:d/m/Y',
|
||||
// 'reglee' => '',
|
||||
// 'archivee' => '',
|
||||
'base_receveur' => 'required|in:membre,client',
|
||||
// 'client' => '',
|
||||
// 'membre' => '',
|
||||
'moyen_paiement' => 'required|in:' . implode(',', array_keys($cats->listMoyensPaiement())),
|
||||
'moyen_paiement' => 'required|in:' . implode(',', array_keys($facture->listMoyensPaiement())),
|
||||
'designation' => 'array|required',
|
||||
'prix' => 'array|required'
|
||||
]);
|
||||
|
@ -36,33 +43,29 @@ if (f('add'))
|
|||
if ( count(f('designation')) !== count(f('prix')) )
|
||||
{
|
||||
throw new UserException('Nombre de désignations et de prix reçus différent.');
|
||||
}
|
||||
}
|
||||
|
||||
$truc = [
|
||||
$truc = [
|
||||
'numero' =>f('numero_facture'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'date_echeance' => f('date_echeance'),
|
||||
'reglee' => f('reglee') == 'on'?1:0,
|
||||
'archivee' => f('archivee') == 'on'?1:0,
|
||||
'reglee' => f('reglee') == 1?1:0,
|
||||
'archivee' => f('archivee') == 1?1:0,
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'toto' => 0
|
||||
];
|
||||
|
||||
if (f('type') == 'devis')
|
||||
if (f('type') == DEVIS)
|
||||
{
|
||||
$truc['type_facture'] = 0;
|
||||
$truc['type_facture'] = DEVIS;
|
||||
}
|
||||
elseif (f('type') == 'facture')
|
||||
elseif (f('type') == FACT)
|
||||
{
|
||||
$truc['type_facture'] = 1;
|
||||
$truc['type_facture'] = FACT;
|
||||
}
|
||||
elseif (f('type') == 'cerfa')
|
||||
elseif (f('type') == CERFA)
|
||||
{
|
||||
$truc['type_facture'] = 2;
|
||||
}
|
||||
elseif (f('type') == 'cotis')
|
||||
{
|
||||
$truc['type_facture'] = 3;
|
||||
$truc['type_facture'] = CERFA;
|
||||
}
|
||||
|
||||
foreach(f('designation') as $k=>$value)
|
||||
|
@ -97,26 +100,97 @@ if (f('add'))
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
$type = qg('t');
|
||||
$radio = [];
|
||||
if (is_numeric($type))
|
||||
elseif (f('select_cotis'))
|
||||
{
|
||||
switch($type)
|
||||
$form->check('add_cotis_1',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date_format:d/m/Y',
|
||||
'membre' => 'required|numeric',
|
||||
]);
|
||||
|
||||
$step = true;
|
||||
}
|
||||
elseif (f('add_cotis'))
|
||||
{
|
||||
$form->check('add_cotis_2',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date_format:d/m/Y',
|
||||
'membre' => 'required|numeric',
|
||||
'cotisation' => 'required',
|
||||
]);
|
||||
|
||||
$radio['type'] = f('cotisation');
|
||||
|
||||
if (!$form->hasErrors())
|
||||
{
|
||||
case 0:
|
||||
$radio['type'] = 'devis';
|
||||
break;
|
||||
case 2:
|
||||
$radio['type'] = 'cerfa';
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
$radio['type'] = 'facture';
|
||||
break;
|
||||
try
|
||||
{
|
||||
$num = (int) str_replace('cotis_', '', $radio['type']);
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$cotis[$field] = f($field.'_'.$num);
|
||||
}
|
||||
|
||||
$r = $facture->getCotis(f('membre'), $cotis['id']);
|
||||
$r = $r[0];
|
||||
|
||||
$data = [
|
||||
'type_facture' => COTIS,
|
||||
'numero' => f('numero_facture'),
|
||||
'receveur_membre' => 1,
|
||||
'receveur_id' => f('membre'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'total' => $r->paid_amount ?? $r->amount,
|
||||
'contenu' => ['id' => $cotis['id'],
|
||||
'intitule' => $cotis['label'],
|
||||
'souscription' => $cotis['date'],
|
||||
'expiration' => $cotis['expiry'] ]
|
||||
];
|
||||
|
||||
$id = $facture->add($data);
|
||||
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$step = true;
|
||||
}
|
||||
|
||||
if ($step)
|
||||
{
|
||||
try
|
||||
{
|
||||
$liste = $facture->getCotis((int)f('membre'));
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
$tpl->assign('radio', $radio);
|
||||
|
||||
|
||||
$type = qg('t') ? (int) qg('t') : null;
|
||||
|
||||
if (in_array($type, [DEVIS, FACT, CERFA, COTIS], true))
|
||||
{
|
||||
$radio['type'] = $type;
|
||||
}
|
||||
elseif (null !== f('type'))
|
||||
{
|
||||
$radio['type'] = f('type');
|
||||
}
|
||||
else
|
||||
{
|
||||
$radio['type'] = FACT;
|
||||
}
|
||||
|
||||
|
||||
$tpl->assign('types_details', $facture->types);
|
||||
|
||||
$tpl->assign('client_id', f('client') ?: -1);
|
||||
$tpl->assign('membre_id', f('membre') ?: -1);
|
||||
|
@ -139,10 +213,17 @@ else {
|
|||
$designations = ['Exemple'];
|
||||
$prix = [1.5];
|
||||
}
|
||||
|
||||
$tpl->assign(compact('liste', 'radio', 'step'));
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$tpl->assign('date', $date->format('d/m/Y'));
|
||||
|
||||
$tpl->assign('designations', $designations);
|
||||
$tpl->assign('prix', $prix);
|
||||
$tpl->assign('identite', $identite);
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
$tpl->assign('clients', $client->listAll());
|
||||
$tpl->assign('membres', $db->getAssoc('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
$tpl->assign('clients', $db->getAssoc('SELECT id, nom FROM plugin_facturation_clients;'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/facture_ajouter.tpl');
|
||||
|
|
|
@ -8,6 +8,16 @@ $session->requireAccess('compta', Membres::DROIT_ECRITURE);
|
|||
|
||||
use Garradin\DB;
|
||||
|
||||
$db = DB::getInstance();
|
||||
|
||||
$step = false;
|
||||
$liste = [];
|
||||
|
||||
$fields = $facture->recu_fields;
|
||||
|
||||
$tpl->assign('moyens_paiement', $facture->listMoyensPaiement());
|
||||
$tpl->assign('moyen_paiement', f('moyen_paiement') ?: 'ES');
|
||||
|
||||
qv(['id' => 'required|numeric']);
|
||||
$id = (int) qg('id');
|
||||
|
||||
|
@ -16,23 +26,21 @@ if (!$f = $facture->get($id))
|
|||
throw new UserException("Ce document n'existe pas.");
|
||||
}
|
||||
|
||||
$cats = new Compta\Categories;
|
||||
|
||||
// Traitement
|
||||
|
||||
if(f('save'))
|
||||
{
|
||||
$form->check('modifier_facture', [
|
||||
'type' => 'required|in:facture,devis,cerfa,cotis',
|
||||
'type' => 'required|in:'.implode(',', [DEVIS, FACT, CERFA]),
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'date_echeance' => 'required|date',
|
||||
'date_emission' => 'required|date_format:d/m/Y',
|
||||
'date_echeance' => 'required|date_format:d/m/Y',
|
||||
// 'reglee' => '',
|
||||
// 'archivee' => '',
|
||||
'base_receveur' => 'required|in:membre,client',
|
||||
// 'client' => '',
|
||||
// 'membre' => '',
|
||||
'moyen_paiement' => 'required|in:' . implode(',', array_keys($cats->listMoyensPaiement())),
|
||||
'moyen_paiement' => 'required|in:' . implode(',', array_keys($facture->listMoyensPaiement())),
|
||||
'designation' => 'array|required',
|
||||
'prix' => 'array|required'
|
||||
]);
|
||||
|
@ -51,27 +59,27 @@ if(f('save'))
|
|||
'numero' => f('numero_facture'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'date_echeance' => f('date_echeance'),
|
||||
'reglee' => f('reglee') == 'on'?1:0,
|
||||
'archivee' => f('archivee') == 'on'?1:0,
|
||||
'reglee' => f('reglee') == 1?1:0,
|
||||
'archivee' => f('archivee') == 1?1:0,
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'toto' => 0
|
||||
];
|
||||
|
||||
if (f('type') == 'devis')
|
||||
if (f('type') == DEVIS)
|
||||
{
|
||||
$truc['type_facture'] = 0;
|
||||
$truc['type_facture'] = DEVIS;
|
||||
}
|
||||
elseif (f('type') == 'facture')
|
||||
elseif (f('type') == FACT)
|
||||
{
|
||||
$truc['type_facture'] = 1;
|
||||
$truc['type_facture'] = FACT;
|
||||
}
|
||||
elseif (f('type') == 'cerfa')
|
||||
elseif (f('type') == CERFA)
|
||||
{
|
||||
$truc['type_facture'] = 2;
|
||||
$truc['type_facture'] = CERFA;
|
||||
}
|
||||
elseif (f('type') == 'cotis')
|
||||
elseif (f('type') == COTIS)
|
||||
{
|
||||
$truc['type_facture'] = 3;
|
||||
$truc['type_facture'] = COTIS;
|
||||
}
|
||||
|
||||
foreach(f('designation') as $k=>$value)
|
||||
|
@ -86,12 +94,12 @@ if(f('save'))
|
|||
if (f('base_receveur') == 'client')
|
||||
{
|
||||
$truc['receveur_membre'] = 0;
|
||||
$truc['receveur_id'] = f('client_id');
|
||||
$truc['receveur_id'] = f('client');
|
||||
}
|
||||
elseif (f('base_receveur') == 'membre')
|
||||
{
|
||||
$truc['receveur_membre'] = 1;
|
||||
$truc['receveur_id'] = f('membre_id');
|
||||
$truc['receveur_id'] = f('membre');
|
||||
}
|
||||
|
||||
$r = $facture->edit($id, $truc);
|
||||
|
@ -106,53 +114,159 @@ if(f('save'))
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Cotis
|
||||
|
||||
$fields = $facture->recu_fields;
|
||||
|
||||
$membre_id = f('membre') ?: $f->receveur_id;
|
||||
|
||||
$values['numero_facture'] = $f->numero;
|
||||
$values['date_emission'] = $f->date_emission;
|
||||
|
||||
$radio = $liste = [];
|
||||
|
||||
if (f('select_cotis'))
|
||||
{
|
||||
$form->check('add_cotis_1',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
]);
|
||||
|
||||
$step = true;
|
||||
}
|
||||
elseif (f('add_cotis'))
|
||||
{
|
||||
$form->check('add_cotis_2',[
|
||||
'numero_facture' => 'required|string',
|
||||
'date_emission' => 'required|date',
|
||||
'membre' => 'required|numeric',
|
||||
'cotisation' => 'required',
|
||||
]);
|
||||
|
||||
$radio['type'] = f('cotisation');
|
||||
|
||||
if (!$form->hasErrors())
|
||||
{
|
||||
try
|
||||
{
|
||||
$num = (int) str_replace('cotis_', '', $radio['type']);
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$cotis[$field] = f($field.'_'.$num);
|
||||
}
|
||||
|
||||
$r = $facture->getCotis(f('membre'), $cotis['id']);
|
||||
$r = $r[0];
|
||||
|
||||
$data = [
|
||||
'type_facture' => 3,
|
||||
'numero' => f('numero_facture'),
|
||||
'receveur_membre' => 1,
|
||||
'receveur_id' => f('membre'),
|
||||
'date_emission' => f('date_emission'),
|
||||
'moyen_paiement' => f('moyen_paiement'),
|
||||
'total' => $r->paid_amount ?? $r->amount,
|
||||
'contenu' => ['id' => $cotis['id'],
|
||||
'intitule' => $cotis['label'],
|
||||
'souscription' => $cotis['date'],
|
||||
'expiration' => $cotis['expiry'] ]
|
||||
];
|
||||
|
||||
if($facture->edit($id, $data))
|
||||
{
|
||||
Utils::redirect(PLUGIN_URL . 'facture.php?id='.(int)$id);
|
||||
}
|
||||
throw new UserException('Erreur d\'édition du reçu');
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$step = true;
|
||||
}
|
||||
|
||||
if ($step)
|
||||
{
|
||||
try
|
||||
{
|
||||
$liste = $facture->getCotis((int)f('membre'));
|
||||
}
|
||||
catch (UserException $e)
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Affichage
|
||||
|
||||
$doc['moyens_paiement'] = $cats->listMoyensPaiement();
|
||||
$doc['moyens_paiement'] = $facture->listMoyensPaiement(true);
|
||||
// $doc['moyen_paiement'] = $doc['moyens_paiement'][$f->moyen_paiement];
|
||||
$doc['moyen_paiement'] = $f->moyen_paiement;
|
||||
$doc['type'] = $facture->type[$f->type_facture];
|
||||
$doc['type'] = $f->type_facture;
|
||||
$doc['numero_facture'] = $f->numero;
|
||||
$doc['reglee'] = $f->reglee?'on':'off';
|
||||
$doc['reglee'] = $f->reglee;
|
||||
$doc['base_receveur'] = $f->receveur_membre?'membre':'client';
|
||||
$doc['client_id'] = $f->receveur_id;
|
||||
$doc['membre_id'] = $f->receveur_id;
|
||||
$doc['client'] = $f->receveur_id;
|
||||
$doc['membre'] = $f->receveur_id;
|
||||
|
||||
$doc['date_emission'] = strtotime(f('date_emission')) ?: $f->date_emission;
|
||||
$doc['date_echeance'] = strtotime(f('date_echeance')) ?: $f->date_echeance; // Smarty m'a saoulé pour utiliser form_field|date_fr:---
|
||||
|
||||
$tpl->assign('doc', $doc);
|
||||
|
||||
$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
|
||||
$radio['type'] = f('type')??$doc['type'];
|
||||
$tpl->assign('types_details', $facture->types);
|
||||
|
||||
$tpl->assign('client_id', f('client') ?: -1);
|
||||
$tpl->assign('membre_id', f('membre') ?: -1);
|
||||
|
||||
$tpl->assign(compact('liste', 'radio', 'step'));
|
||||
|
||||
// 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')))
|
||||
if ($f->type_facture != COTIS)
|
||||
{
|
||||
foreach($d as $k=>$v)
|
||||
|
||||
|
||||
if (($d = f('designation')) && ($p = f('prix')))
|
||||
{
|
||||
if ($v == '' && $p[$k] == 0)
|
||||
foreach($d as $k=>$v)
|
||||
{
|
||||
continue;
|
||||
if ($v == '' && $p[$k] == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$designations[] = $v;
|
||||
$prix[] = $p[$k];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($f->contenu as $k=>$v)
|
||||
{
|
||||
if ($v['designation'] == '' && $v['prix'] == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$designations[] = $v['designation'];
|
||||
$prix[] = $v['prix'];
|
||||
}
|
||||
$designations[] = $v;
|
||||
$prix[] = $p[$k];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($f->contenu as $k=>$v)
|
||||
{
|
||||
if ($v['designation'] == '' && $v['prix'] == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$designations[] = $v['designation'];
|
||||
$prix[] = $v['prix'];
|
||||
}
|
||||
}
|
||||
$tpl->assign('designations', $designations);
|
||||
$tpl->assign('prix', $prix);
|
||||
|
||||
$tpl->assign('designations', $designations??[]);
|
||||
$tpl->assign('prix', $prix??[]);
|
||||
$tpl->assign('identite', $identite);
|
||||
$tpl->assign('membres', (array)DB::getInstance()->get('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
$tpl->assign('clients', $client->listAll());
|
||||
$tpl->assign('membres', $db->getAssoc('SELECT id, '.$identite.' FROM membres WHERE id_categorie != -2 NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);'));
|
||||
$tpl->assign('clients', $db->getAssoc('SELECT id, nom FROM plugin_facturation_clients;'));
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$tpl->assign('date', $date->format('d/m/Y'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/facture_modifier.tpl');
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
namespace Garradin;
|
||||
|
||||
require_once __DIR__ . '/_upgrade_trick.php';
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
$session->requireAccess('compta', Membres::DROIT_ACCES);
|
||||
|
||||
$membres = new Membres;
|
||||
$cats = new Compta\Categories;
|
||||
|
||||
$tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
|
||||
$tpl->assign('moyens_paiement', $facture->listMoyensPaiement());
|
||||
|
||||
foreach($factures = $facture->listAll() as $k=>$f)
|
||||
{
|
||||
$factures[$k]->receveur = $f->receveur_membre? $membres->get($f->receveur_id) : $client->get($f->receveur_id);
|
||||
$factures[$k]->moyen_paiement = $cats->getMoyenPaiement($f->moyen_paiement);
|
||||
$factures[$k]->moyen_paiement = $facture->getMoyenPaiement($f->moyen_paiement);
|
||||
}
|
||||
|
||||
$tpl->assign('identite', $identite);
|
||||
|
|
|
@ -17,8 +17,7 @@ if (!$f = $facture->get($id))
|
|||
throw new UserException("Ce document n'existe pas.");
|
||||
}
|
||||
|
||||
$cats = new Compta\Categories;
|
||||
$moyen_paiement = $cats->getMoyenPaiement($f->moyen_paiement);
|
||||
$moyen_paiement = $facture->getMoyenPaiement($f->moyen_paiement);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -55,6 +54,11 @@ $pdf = new \Mpdf\Mpdf([
|
|||
$pdf->SetAuthor($config->get('nom_asso'));
|
||||
|
||||
|
||||
$emission = $f->date_emission->format('d/m/Y');
|
||||
if (isset($f->date_echeance))
|
||||
{
|
||||
$echeance = $f->date_echeance->format('d/m/Y');
|
||||
}
|
||||
// Génération factures et devis
|
||||
|
||||
if ($f->type_facture < 2)
|
||||
|
@ -62,7 +66,6 @@ if ($f->type_facture < 2)
|
|||
ob_start();
|
||||
|
||||
$doc = ($f->type_facture?'Facture':'Devis').' n°'.$f->numero;
|
||||
$emission = date('d/m/Y' ,$f->date_emission);
|
||||
$pdf->SetTitle($doc.' - '.$emission);
|
||||
|
||||
$asso =
|
||||
|
@ -83,7 +86,6 @@ if ($f->type_facture < 2)
|
|||
(($t = $c->telephone)?"Tel : $t<br>":'');
|
||||
|
||||
$total = number_format($f->total, 2, ',', ' ');
|
||||
$echeance = date('d/m/Y' ,$f->date_echeance);
|
||||
$echeance = ($f->type_facture?'Échéance de paiement':'Échéance du devis')." : ".$echeance;
|
||||
$reglee = !$f->reglee?'Cette facture est en attente de règlement.':'Cette facture a été reglée.';
|
||||
$footer = str_replace("\n", '<br>', $plugin->getConfig('footer'));
|
||||
|
@ -263,11 +265,11 @@ elseif ($f->type_facture == 2)
|
|||
$pdf->WriteText(81, 45, $c->ville);
|
||||
$pdf->WriteText(90, 70, utf8_decode("***".$f->total."***"));
|
||||
// numfmt a l'air de patauger avec des valeurs < 1
|
||||
$pdf->WriteText(62, 80, utf8_decode(numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($f->total)) . ' euros');
|
||||
$pdf->WriteText(62, 80, numfmt_create('fr_FR', \NumberFormatter::SPELLOUT)->format($f->total) . ' euros');
|
||||
|
||||
$pdf->WriteText(73, 89.5, utf8_decode(strftime('%d', $f->date_emission)));
|
||||
$pdf->WriteText(84, 89.5, utf8_decode(strftime('%m', $f->date_emission)));
|
||||
$pdf->WriteText(100, 89.5, utf8_decode(strftime('%Y', $f->date_emission)));
|
||||
$pdf->WriteText(73, 89.5, utf8_decode($f->date_emission->format('d')));
|
||||
$pdf->WriteText(84, 89.5, utf8_decode($f->date_emission->format('m')));
|
||||
$pdf->WriteText(100, 89.5, utf8_decode($f->date_emission->format('Y')));
|
||||
|
||||
if($plugin->getConfig('droit_art200')){
|
||||
$pdf->WriteText(57.5, 103.5, "X");
|
||||
|
@ -299,9 +301,9 @@ elseif ($f->type_facture == 2)
|
|||
}
|
||||
|
||||
// Date d'édition du document
|
||||
$pdf->WriteText(144.4, 246.2, utf8_decode(strftime('%d', $f->date_echeance)));
|
||||
$pdf->WriteText(152.2, 246.2, utf8_decode(strftime('%m', $f->date_echeance)));
|
||||
$pdf->WriteText(160, 246.2, utf8_decode(strftime('%Y', $f->date_echeance)));
|
||||
$pdf->WriteText(144.4, 246.2, utf8_decode($f->date_echeance->format('d')));
|
||||
$pdf->WriteText(152.2, 246.2, utf8_decode($f->date_echeance->format('m')));
|
||||
$pdf->WriteText(160, 246.2, utf8_decode($f->date_echeance->format('Y')));
|
||||
|
||||
// Signature
|
||||
$img = new Fichiers($plugin->getConfig('signaturetxt'));
|
||||
|
@ -322,7 +324,6 @@ elseif ($f->type_facture == 3)
|
|||
ob_start();
|
||||
|
||||
$doc = 'Reçu n°'.$f->numero;
|
||||
$emission = date('d/m/Y',$f->date_emission);
|
||||
$pdf->SetTitle($doc.' - '.$emission);
|
||||
|
||||
$asso =
|
||||
|
@ -342,7 +343,8 @@ elseif ($f->type_facture == 3)
|
|||
(($t = $c->email)?"Email : $t<br>":'').
|
||||
(($t = $c->telephone)?"Tel : $t<br>":'');
|
||||
|
||||
$total = number_format($f->total, 2, ',', ' ');
|
||||
$total = $f->total / 100;
|
||||
$total = number_format($total, 2, ',', ' ');
|
||||
|
||||
$lieu = $plugin->getConfig('ville_asso');
|
||||
$intitule = $f->contenu['intitule'];
|
||||
|
@ -445,7 +447,7 @@ Bonjour,
|
|||
|
||||
Nous accusons réception de votre cotisation « $intitule » reçue le $emission et nous vous en remercions.
|
||||
<br><br>
|
||||
Nous reconnaissons que vous avez acquitté la somme de $total € par $moyen_paiement .
|
||||
Nous reconnaissons que vous avez acquitté la somme de {$total} €.
|
||||
<br>
|
||||
Votre adhésion sera donc effective à compter du $souscription jusqu’au $expiration.
|
||||
<br><br><br>
|
||||
|
@ -474,5 +476,5 @@ else
|
|||
|
||||
$pdf->Output(
|
||||
($f->type_facture?'Facture':'Devis').' '.$f->numero
|
||||
. ' du '.date('d-m-Y' ,$f->date_emission)
|
||||
. ' du '.$emission
|
||||
.'.pdf', $t);
|
||||
|
|
Loading…
Reference in New Issue