diff --git a/admin/_facture_common.php b/admin/_facture_common.php index 09d2e1a..b729f34 100644 --- a/admin/_facture_common.php +++ b/admin/_facture_common.php @@ -344,6 +344,7 @@ $tpl->assign('date', $date->format('d/m/Y')); $tpl->assign(compact('liste', 'radio', 'step', 'designations', 'prix', 'from_user', 'identite', 'csrf_key', 'doc')); $tpl->assign('users', toArray($db->get('SELECT id, '.$identite.' FROM users WHERE id_category != -2 NOT IN (SELECT id FROM users_categories WHERE hidden = 1) ORDER BY ' .$identite. ';'), 'id', " ")); $tpl->assign('clients', $db->getAssoc('SELECT id, nom FROM plugin_facturation_clients;')); +$tpl->assign('contacts', $db->getAssoc('SELECT id, nom_contact FROM plugin_facturation_clients;')); $tpl->assign('require_number', $require_number); $tpl->assign('number_pattern', PATTERNS_LIST[$plugin->getConfig('pattern')]); diff --git a/admin/client_modifier.php b/admin/client_modifier.php index 5f98dd1..587f9f3 100644 --- a/admin/client_modifier.php +++ b/admin/client_modifier.php @@ -29,6 +29,7 @@ $form->runIf(f('save') && !$form->hasErrors(), 'siret' => f('siret'), 'telephone' => f('telephone'), 'email' => f('email'), + 'nom_contact' => f('nom_contact'), 'note' => f('note') ]); diff --git a/admin/clients.php b/admin/clients.php index c8c1a4c..ae8808f 100644 --- a/admin/clients.php +++ b/admin/clients.php @@ -19,6 +19,7 @@ $form->runIf(f('add') && !$form->hasErrors(), 'siret' => f('siret'), 'telephone' => f('telephone'), 'email' => f('email'), + 'nom_contact' => f('nom_contact'), 'note' => f('note') ]); diff --git a/data/schema.sql b/data/schema.sql index 3263c43..923b4eb 100644 --- a/data/schema.sql +++ b/data/schema.sql @@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS plugin_facturation_clients ( date_creation TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date_creation) IS NOT NULL AND date(date_creation) = date_creation), -- Date d\'inscription telephone TEXT, email TEXT, + nom_contact TEXT, note TEXT ); diff --git a/lib/Client.php b/lib/Client.php index edb4994..66e7d75 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -18,6 +18,7 @@ class Client 'siret', 'telephone', 'email', + 'nom_contact', 'note' ]; @@ -41,7 +42,7 @@ class Client { $data[$key] = trim($data[$key]); - if($data[$key] == '' && ($key != 'siret' && $key != 'telephone' && $key != 'email')) + if($data[$key] == '' && ! in_array($key, ['siret', 'telephone', 'email', 'nom_contact', 'note'])) { throw new UserException('Le champs '.$key.' doit être renseigné.'); } @@ -137,6 +138,9 @@ class Client 'email' => [ 'label' => 'E-Mail', ], + 'nom_contact' => [ + 'label' => 'Contact', + ], 'note' => [ 'label' => 'Note', ], diff --git a/plugin.ini b/plugin.ini index dc6f8e1..db7f979 100644 --- a/plugin.ini +++ b/plugin.ini @@ -2,7 +2,7 @@ name="Facturation" description="Permet d'éditer des factures et devis à ses membres ainsi qu'à une base de clients supplémentaire." author="zou ; adapté par jce" url="https://git.roflcopter.fr/lesanges/paheko-plugin-facturation" -version="0.14" +version="0.15" menu=true restrict_section="accounting" restrict_level="read" diff --git a/templates/_form.tpl b/templates/_form.tpl index 6410a2b..f533acf 100644 --- a/templates/_form.tpl +++ b/templates/_form.tpl @@ -70,12 +70,12 @@
- {input type="select" name="membre" label="Membre" options=$users required=1 source=$doc} + {input type="select" name="membre" label="Membre" options=$users required=1 source=$doc default_empty="— Choisir un membre —"}
{if !empty($clients)}
- {input type="select" name="client" label="Client" options=$clients required=1 class="type_client" source=$doc} + {input type="select" name="client" label="Client" options=$clients required=1 class="type_client" source=$doc default_empty="— Choisir un client —"}
{else} @@ -85,6 +85,9 @@
Autres informations {input type="text" name="nom_contact" label="Nom du contact" source=$doc} +
{input type="text" name="numero_commande" label="Numéro de commande" source=$doc} {input type="text" name="reference_acheteur" label="Référence acheteur" source=$doc} diff --git a/templates/_js.tpl b/templates/_js.tpl index 5c63c5f..ed7feeb 100644 --- a/templates/_js.tpl +++ b/templates/_js.tpl @@ -51,6 +51,18 @@ } } + function modifierContact(client, idlist, idcontact) + { + let contactlist = document.querySelector(idlist); + let options = contactlist.querySelectorAll('option'); + for (i=0; i < options.length; ++i) { + if (options[i].value == client.value) { + break; + } + } + document.querySelector(idcontact).value = options[i].textContent; + } + const form = document.querySelector('#f_numero_facture').form; changeTypeSaisie(form.base_receveur.value); @@ -63,6 +75,11 @@ }; } + const selclient = document.querySelector('#f_client'); + selclient.addEventListener("change", () => { + modifierContact(selclient, '#f_contact_list', '#f_nom_contact'); + }); + } ()); diff --git a/templates/client.tpl b/templates/client.tpl index 0d72337..6f689a8 100644 --- a/templates/client.tpl +++ b/templates/client.tpl @@ -48,6 +48,15 @@ {/if} +
Nom du contact
+
+ {if empty($client.nom_contact)} + (Non renseigné) + {else} + {$client.nom_contact} + {/if} +
+
Note
{if empty($client.note)} diff --git a/templates/client_modifier.tpl b/templates/client_modifier.tpl index ba611dd..b00c2cb 100644 --- a/templates/client_modifier.tpl +++ b/templates/client_modifier.tpl @@ -14,6 +14,7 @@ {input type="text" name="siret" label="SIREN/SIRET" source=$client} {input type="tel" name="telephone" label="Téléphone" source=$client} {input type="email" name="email" label="Adresse e-mail" source=$client} + {input type="text" name="nom_contact" label="Nom du contact" source=$client} {input type="textarea" cols="60" rows="3" name="note" label="Note" source=$client}
diff --git a/templates/clients.tpl b/templates/clients.tpl index 9514d68..06fea3d 100644 --- a/templates/clients.tpl +++ b/templates/clients.tpl @@ -61,6 +61,7 @@ {input type="text" name="siret" label="SIREN/SIRET"} {input type="tel" name="telephone" label="Téléphone"} {input type="email" name="email" label="Adresse e-mail"} + {input type="text" name="nom_contact" label="Nom contact"} {input type="textarea" cols="60" rows="3" name="note" label="Note"} diff --git a/upgrade.php b/upgrade.php index 309d569..f47ac27 100644 --- a/upgrade.php +++ b/upgrade.php @@ -252,10 +252,10 @@ EOT ); } -// version 0.14 -// Ajout champ note à la table clients +// version 0.15 +// Ajout champs note et contact à la table clients // Ajout divers champs à la table factures -if (version_compare($old_version, '0.14', '<')) +if (version_compare($old_version, '0.15', '<')) { $db->exec(<<