\n"
@@ -967,7 +967,7 @@ msgstr "Actie is ontoegankelijk"
#: html/ajax_misc.php:179 html/ajax_misc.php:257 html/ajax_misc.php:262
#: html/ajax_misc.php:290 html/ajax_misc.php:382 html/ajax_misc.php:384
#: html/ajax_misc.php:390 include/lib/message_javascript.php:90
-#: include/lib/message_javascript.php:92
+#: include/lib/message_javascript.php:92 html/ajax_misc.php:392
#, fuzzy
msgid "Action non autorisée"
msgstr "Bewerking Opgeslagen"
@@ -1206,6 +1206,8 @@ msgstr "Hulp voor de wiki"
#: include/lib/manage_table_sql.class.php:652
#: include/class/acc_ledger_search.class.php:248
#: include/class/acc_ledger_search.class.php:250
+#: include/lib/manage_table_sql.class.php:616
+#: include/lib/manage_table_sql.class.php:655
msgid "Ajout"
msgstr "Toevoeging"
@@ -1278,6 +1280,7 @@ msgstr "Artikel toevoegen"
#: include/lib/class_html_input.php:958 include/lib/class_html_input.php:984
#: include/lib/html_input.class.php:1037 include/lib/html_input.class.php:1095
#: include/lib/html_input.class.php:1096 include/lib/html_input.class.php:1111
+#: include/lib/html_input.class.php:1112
#, fuzzy
msgid "Ajout autres"
msgstr "Factuur toevoegen"
@@ -3225,7 +3228,7 @@ msgstr "Rekenmachine"
#: include/template/calendar-list.php:34 include/lib/html_input.class.php:943
#: include/ajax/ajax_calendar_zoom.php:26 include/lib/html_input.class.php:991
#: include/ajax/ajax_calendar_zoom.php:32 include/lib/html_input.class.php:992
-#: include/lib/html_input.class.php:1007
+#: include/lib/html_input.class.php:1007 include/lib/html_input.class.php:1008
msgid "Calendrier"
msgstr "Kalender"
@@ -3239,6 +3242,7 @@ msgstr "Kalender"
#: include/lib/manage_table_sql.class.php:1008
#: include/lib/manage_table_sql.class.php:1028
#: include/lib/manage_table_sql.class.php:1025
+#: include/lib/manage_table_sql.class.php:1069
#, fuzzy
msgid "Cancel"
msgstr "Evenwicht"
@@ -3428,7 +3432,7 @@ msgstr "Dit plan bestaat niet"
#: html/ajax_misc.php:571 html/ajax_misc.php:613 html/ajax_misc.php:408
#: html/ajax_misc.php:434 html/ajax_misc.php:546 html/ajax_misc.php:548
-#: html/ajax_misc.php:554
+#: html/ajax_misc.php:554 html/ajax_misc.php:556
#, fuzzy
msgid "Ce plugin n'existe pas "
msgstr "Dit plan bestaat niet"
@@ -3725,7 +3729,8 @@ msgstr ""
#: include/class/acc_ledger.class.php:2185
#: include/class/anc_listing.class.php:76 include/class/fiche.class.php:2246
#: html/user_login.php:158 html/ajax_misc.php:462
-#: include/class/fiche.class.php:2247
+#: include/class/fiche.class.php:2247 html/ajax_misc.php:464
+#: include/lib/manage_table_sql.class.php:634
#, fuzzy, php-format
msgid "Cherche"
msgstr "Vinden"
@@ -3774,6 +3779,7 @@ msgid ""
msgstr ""
#: html/ajax_misc.php:452 html/ajax_misc.php:454 html/ajax_misc.php:460
+#: html/ajax_misc.php:462
#, fuzzy
msgid "Choisissez la TVA"
msgstr "Kies de BTW"
@@ -3832,6 +3838,12 @@ msgstr "Kies een andere oefening"
msgid "Choisissez un dossier"
msgstr "Kies een dossier"
+#: include/class/payment_method_mtable.class.php:77
+#: include/class/payment_method_mtable.class.php:87
+#, fuzzy
+msgid "Choisissez un journal"
+msgstr "Kies uw dossier"
+
#: include/class_pre_operation.php:281
#: include/class/class_pre_operation.php:281
#: include/class/class_pre_operation.php:284
@@ -3844,6 +3856,11 @@ msgstr "Kies een dossier"
msgid "Choisissez un poste"
msgstr "Kies een dossier"
+#: include/class/payment_method_mtable.class.php:115
+#, fuzzy
+msgid "Choisissez un type de fiche"
+msgstr "Kies een andere oefening"
+
#: html/ajax_card.php:295 html/ajax_card.php:297 html/ajax_card.php:298
#: include/ajax/ajax_card.php:278 include/ajax/ajax_card.php:279
#: include/ajax/ajax_card.php:285 include/ajax/ajax_card.php:287
@@ -6284,7 +6301,7 @@ msgstr "Laatste handelingen"
#: html/ajax_misc.php:196 html/ajax_misc.php:274 html/ajax_misc.php:279
#: html/ajax_misc.php:307 html/ajax_misc.php:399 html/ajax_misc.php:401
-#: html/ajax_misc.php:407
+#: html/ajax_misc.php:407 html/ajax_misc.php:409
#, fuzzy
msgid "Des actions dépendent de cette catégorie"
msgstr "Kan dit bestand op te slaan"
@@ -7950,6 +7967,7 @@ msgstr "Erasure"
#: include/class/anc_operation.class.php:316
#: include/template/ledger_detail_bottom.php:328
#: include/class/periode.class.php:596 include/class/periode.class.php:601
+#: include/lib/manage_table_sql.class.php:768
msgid "Effacer"
msgstr "Wissen"
@@ -8036,6 +8054,7 @@ msgstr "Alle activiteiten"
#: include/lib/manage_table_sql.class.php:1075
#: include/lib/manage_table_sql.class.php:1095
#: include/lib/manage_table_sql.class.php:1092
+#: include/lib/manage_table_sql.class.php:1136
msgid "Effacé"
msgstr "Verwijderen"
@@ -8245,6 +8264,11 @@ msgstr "OPSLAAN"
msgid "Enregistrement"
msgstr "Opgeslagen"
+#: include/class/payment_method_mtable.class.php:39
+#, fuzzy
+msgid "Enregistrement dans"
+msgstr "Opgeslagen"
+
#: include/action.common.inc.php:160 include/action.common.inc.php:258
#: include/compta_ach.inc.php:222 include/compta_ven.inc.php:238
#: include/action.common.inc.php:177 include/action.common.inc.php:309
@@ -8474,6 +8498,11 @@ msgstr "Afmelden"
msgid "Erreur exercice invalide"
msgstr "Ongeldig datum"
+#: include/class/payment_method_mtable.class.php:140
+#, fuzzy, php-format
+msgid "Erreur key %s value %s"
+msgstr "Ongeldig datum"
+
#: html/do.php:196 html/do.php:224 html/do.php:237 html/do.php:239
#: html/do.php:236 html/do.php:273 html/do.php:285 html/do.php:295
#: html/do.php:264
@@ -8717,7 +8746,7 @@ msgstr "tarief is geen getal"
#: html/ajax_misc.php:197 html/ajax_misc.php:216 html/ajax_misc.php:230
#: html/ajax_misc.php:236 html/ajax_misc.php:314 html/ajax_misc.php:319
#: html/ajax_misc.php:347 html/ajax_misc.php:459 html/ajax_misc.php:461
-#: html/ajax_misc.php:467
+#: html/ajax_misc.php:467 html/ajax_misc.php:469
msgid "Explication"
msgstr "Uitleg"
@@ -9330,6 +9359,7 @@ msgstr "Dicht"
#: include/class/acc_plan_mtable.class.php:49 include/database.item.php:78
#: include/database.item.php:110 include/category_card.inc.php:75
#: include/template/stock_inv.php:67
+#: include/class/payment_method_mtable.class.php:41
msgid "Fiche"
msgstr "Blad"
@@ -9375,6 +9405,11 @@ msgstr "BTW fiche"
msgid "Fiche contenant"
msgstr "Blad Bevat"
+#: include/class/payment_method_mtable.class.php:98
+#, fuzzy
+msgid "Fiche inexistante"
+msgstr "Map niet bestaat"
+
#: include/ext/import_account/include/class_impacc_csv.php:53
#: include/ext/import_account/include/impacc_csv.class.php:53
#, fuzzy
@@ -10493,7 +10528,7 @@ msgstr ""
#: html/ajax_misc.php:572 html/ajax_misc.php:614 html/ajax_misc.php:409
#: html/ajax_misc.php:435 html/ajax_misc.php:547 html/ajax_misc.php:549
-#: html/ajax_misc.php:555
+#: html/ajax_misc.php:555 html/ajax_misc.php:557
msgid "Il y a une erreur, ce plugin n'existe pas"
msgstr ""
@@ -11086,6 +11121,7 @@ msgid "Invalide"
msgstr "Bevestigen"
#: html/ajax_misc.php:288 html/ajax_misc.php:290 html/ajax_misc.php:296
+#: html/ajax_misc.php:298
#, fuzzy
msgid "Invalide type"
msgstr "Bevestigen"
@@ -12141,6 +12177,7 @@ msgstr "smaad"
#: include/class/anc_operation.class.php:298
#: include/class/acc_ledger_history_generic.class.php:770
#: include/export/export_balance_pdf.php:127
+#: include/class/payment_method_mtable.class.php:38
#, php-format
msgid "Libellé"
msgstr "Opstellen"
@@ -12219,6 +12256,12 @@ msgstr "Regel niet geïmporteerd"
msgid "Limite dossiers"
msgstr "Records Management"
+#: include/lib/message_javascript.php:104
+msgid ""
+"Limite le type fiche si vous choisissez la fiche à la saisie, uniquement "
+"avec journaux OD"
+msgstr ""
+
#: include/fiche.inc.php:63 include/ext/rapport_avance/index.php:58
#: include/template/calendar.php:10 include/ext/rapport_avance/index.php:60
#: include/ext/listing/index.php:60 include/ext/listing/index.php:58
@@ -12954,6 +12997,7 @@ msgstr "Verandering"
#: include/class/anc_operation.class.php:324
#: include/class/anc_operation.class.php:318
#: include/class/anc_operation.class.php:319
+#: include/lib/manage_table_sql.class.php:755
msgid "Modifier"
msgstr "Veranderen"
@@ -14465,7 +14509,7 @@ msgstr "Nieuwe bankafschrift"
#: include/lib/html_input.class.php:1043
#: include/template/action_display_short.php:81
#: include/lib/html_input.class.php:1103 include/lib/html_input.class.php:1104
-#: include/lib/html_input.class.php:1119
+#: include/lib/html_input.class.php:1119 include/lib/html_input.class.php:1120
#, fuzzy
msgid "Nouvel événement"
msgstr "Voeg dit element toe"
@@ -14870,6 +14914,7 @@ msgstr "Analytische OD"
#: include/lib/manage_table_sql.class.php:1005
#: include/lib/manage_table_sql.class.php:1025
#: include/lib/manage_table_sql.class.php:1022
+#: include/lib/manage_table_sql.class.php:1066
msgid "OK"
msgstr ""
@@ -16732,6 +16777,11 @@ msgstr ""
"Om over te schakelen naar unicode, maak een back-up en vervolgens het "
"ontvangen bestand herstellen"
+#: include/lib/message_javascript.php:105
+#, fuzzy
+msgid "Pour les journaux FIN, ce sera la fiche du journal"
+msgstr "Verplicht voor FIN kranten geven hier de Data Bank gebruikt"
+
#: include/template/impress_cat_card.php:21
msgid "Pour toutes les catégories"
msgstr "Voor alle categorieën"
@@ -18584,7 +18634,7 @@ msgstr ""
#: html/ajax_misc.php:196 html/ajax_misc.php:215 html/ajax_misc.php:229
#: html/ajax_misc.php:235 html/ajax_misc.php:313 html/ajax_misc.php:318
#: html/ajax_misc.php:346 html/ajax_misc.php:458 html/ajax_misc.php:460
-#: html/ajax_misc.php:466
+#: html/ajax_misc.php:466 html/ajax_misc.php:468
msgid "Symbole"
msgstr "Symbool"
@@ -18988,7 +19038,7 @@ msgstr ""
#: html/ajax_misc.php:195 html/ajax_misc.php:214 html/ajax_misc.php:228
#: html/ajax_misc.php:234 html/ajax_misc.php:312 html/ajax_misc.php:317
#: html/ajax_misc.php:345 html/ajax_misc.php:457 html/ajax_misc.php:459
-#: html/ajax_misc.php:465
+#: html/ajax_misc.php:465 html/ajax_misc.php:467
msgid "Taux"
msgstr "Tarief"
@@ -19760,6 +19810,7 @@ msgstr "Soort document"
#: include/template/new_mod_payment.php:28 include/payment_middle.inc.php:121
#: include/payment_middle.inc.php:122
+#: include/class/payment_method_mtable.class.php:40
msgid "Type de fiche"
msgstr "Soort blad"
@@ -19863,6 +19914,12 @@ msgstr ""
msgid "Un journal avec ce nom existe déjà"
msgstr "Een journaal met deze naam bestaat al"
+#: include/class/payment_method_mtable.class.php:68
+#: include/class/payment_method_mtable.class.php:92
+#, fuzzy
+msgid "Un libellé est obligatoire"
+msgstr "Het onderwerp is verplicht"
+
#: include/profile.inc.php:322
msgid "Un menu ne peut pas dépendre de lui-même"
msgstr ""
@@ -20081,6 +20138,11 @@ msgstr "Users"
msgid "Utilisateurs qui se sont connectés"
msgstr "Gebruikers die zijn aangesloten"
+#: include/class/payment_method_mtable.class.php:42
+#, fuzzy
+msgid "Utilisation dans"
+msgstr "Gebruik van de voorraden"
+
#: include/company.inc.php:114 include/company.inc.php:133
#: include/company.inc.php:137
msgid "Utilisation de la compta. analytique"
@@ -20470,6 +20532,7 @@ msgstr "Wilt u deze transactie verwijderen"
#: include/lib/class_html_input.php:946 include/lib/class_html_input.php:972
#: include/lib/html_input.class.php:1025 include/lib/html_input.class.php:1083
#: include/lib/html_input.class.php:1084 include/lib/html_input.class.php:1099
+#: include/lib/html_input.class.php:1100
#, fuzzy, php-format
msgid "Voulez-vous effacer cette relation "
msgstr "Wilt u deze actie wilt verwijderen"
@@ -21047,7 +21110,7 @@ msgstr "kiezen"
#: include/class/acc_ledger_search.class.php:111
#: include/lib/html_input.class.php:1017 include/lib/html_input.class.php:1018
#: include/class/acc_ledger_search.class.php:112
-#: include/lib/html_input.class.php:1033
+#: include/lib/html_input.class.php:1033 include/lib/html_input.class.php:1034
msgid "choix des journaux"
msgstr "keuze van de dagboeken"
@@ -21088,7 +21151,7 @@ msgstr "Klik hier om uw voorkeuren bij te werken"
#: include/class/pdf_operation.class.php:149
#: include/class/pdf_operation.class.php:194
#: include/class/pdf_operation.class.php:247 html/ajax_misc.php:456
-#: html/ajax_misc.php:458 html/ajax_misc.php:464
+#: html/ajax_misc.php:458 html/ajax_misc.php:464 html/ajax_misc.php:466
msgid "code"
msgstr "code"
@@ -21762,6 +21825,11 @@ msgstr "Boek Naam"
msgid "non actif"
msgstr "Totale activa"
+#: include/lib/manage_table_sql.class.php:965
+#, fuzzy
+msgid "non implémenté"
+msgstr "Geletterde operaties"
+
#: include/balance_age.inc.php:40 include/balance_age.inc.php:44
#: include/balance_age.inc.php:43
#, fuzzy
@@ -22485,7 +22553,7 @@ msgstr "btw"
#: html/ajax_misc.php:372 html/ajax_misc.php:377 html/ajax_misc.php:400
#: html/ajax_misc.php:405 html/ajax_misc.php:512 html/ajax_misc.php:517
#: html/ajax_misc.php:514 html/ajax_misc.php:519 html/ajax_misc.php:520
-#: html/ajax_misc.php:525
+#: html/ajax_misc.php:525 html/ajax_misc.php:522 html/ajax_misc.php:527
msgid "tva inconnue"
msgstr "onbekend btw"
diff --git a/include/ajax/ajax_payment_method.php b/include/ajax/ajax_payment_method.php
new file mode 100644
index 000000000..a0415599d
--- /dev/null
+++ b/include/ajax/ajax_payment_method.php
@@ -0,0 +1,71 @@
+
+
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief Manage the payement method, existing variable (from ajax_misc.php)
+ * - $http
+ * - $gDossier
+ * - $cn
+ *
+ * @see Payment_Method_SQL
+ * @see Payment_Method_MTable
+ *
+ */
+require_once NOALYSS_INCLUDE."/database/payment_method_sql.class.php";
+require_once NOALYSS_INCLUDE."/class/payment_method_mtable.class.php";
+
+$id=$http->request("p_id", "number", -1);
+$action=$http->request("action");
+$ctl=$http->request("ctl");
+
+$payment_method_sql=new Payment_method_SQL($cn, $id);
+$payment_method_mtable=new Payment_Method_MTable($payment_method_sql);
+
+$payment_method_mtable->add_json_param("op", "payment_method");
+$payment_method_mtable->set_callback("ajax_misc.php");
+$payment_method_mtable->set_object_name($ctl);
+
+// Display a form for modifying or adding an element
+if ($action=="input")
+{
+ $payment_method_mtable->send_header();
+ echo $payment_method_mtable->ajax_input()->saveXML();
+ return;
+}
+// Save it
+elseif ($action=="save")
+{
+ $xml=$payment_method_mtable->ajax_save();
+ $payment_method_mtable->send_header();
+ echo $xml->saveXML();
+ return;
+}
+// delete the row
+elseif ($action=="delete")
+{
+ $payment_method_mtable->send_header();
+ echo $payment_method_mtable->ajax_delete()->saveXML();
+ return;
+}
\ No newline at end of file
diff --git a/include/class/acc_payment.class.php b/include/class/acc_payment.class.php
index 5f64c3377..6ebafc476 100644
--- a/include/class/acc_payment.class.php
+++ b/include/class/acc_payment.class.php
@@ -90,71 +90,7 @@ class Acc_Payment
{
return var_export(self::$variable,true);
}
- public function verify()
- {
- // Verify that the elt we want to add is correct
- }
- public function save()
- {
- /* please adapt */
- if ( $this->get_parameter("id") == 0 )
- $this->insert();
- else
- $this->update();
- }
-
- public function insert()
- {
- if ( $this->verify() != 0 ) return;
- $sql='INSERT INTO payment_method(
- mp_lib, mp_jrn_def_id, mp_fd_id, mp_qcode,jrn_def_id)
- VALUES ($1, $2, $3, upper($4),$5) returning mp_id';
- $this->mp_id=$this->cn->exec_sql($sql,array(
- $this->mp_lib,
- $this->mp_jrn_def_id,
- $this->mp_fd_id,
- $this->mp_qcode,
- $this->jrn_def_id));
- }
-
- public function update()
- {
- if ( $this->verify() != 0 ) return;
-
- $sql="update payment_method set mp_lib=$1,mp_qcode=$2,mp_jrn_def_id=$3,mp_fd_id=$4,jrn_def_id=$5 ".
- " where mp_id = $6";
- $res=$this->cn->exec_sql(
- $sql,
- array($this->mp_lib,
- $this->mp_qcode,
- $this->mp_jrn_def_id,
- $this->mp_fd_id,
- $this->jrn_def_id,
- $this->mp_id)
- );
- if ( strlen (trim($this->mp_jrn_def_id))==0)
- $this->cn->exec_sql(
- 'update payment_method '.
- 'set mp_jrn_def_id = null where mp_id=$1',
- array($this->mp_id));
- if ( strlen (trim($this->jrn_def_id))==0)
- $this->cn->exec_sql(
- 'update payment_method '.
- 'set mp_jrn_def_id = null where mp_id=$1',
- array($this->mp_id));
- if ( strlen (trim($this->mp_qcode))==0)
- $this->cn->exec_sql(
- 'update payment_method '.
- 'set mp_qcode = null where mp_id=$1',
- array($this->mp_id));
- if ( strlen (trim($this->mp_fd_id))==0)
- $this->cn->exec_sql(
- 'update payment_method '.
- 'set mp_fd_id = null where mp_id=$1',
- array($this->mp_id));
-
- }
-
+
public function load()
{
$sql='select mp_id,mp_lib,mp_fd_id,mp_jrn_def_id,mp_qcode,jrn_def_id from payment_method '.
@@ -172,14 +108,7 @@ class Acc_Payment
}
}
- /**
- *@brief remove a middle of payment
- */
- public function delete()
- {
- $sql="delete from payment_method where mp_id=$1";
- $this->cn->exec_sql($sql,array($this->mp_id));
- }
+
/*!\brief retrieve all the data for all ledgers
*\param non
*\return an array of row
diff --git a/include/class/payment_method_mtable.class.php b/include/class/payment_method_mtable.class.php
new file mode 100644
index 000000000..f67b60218
--- /dev/null
+++ b/include/class/payment_method_mtable.class.php
@@ -0,0 +1,144 @@
+
+
+/**
+ * @file
+ * @brief
+ * @see Payment_Method_SQL
+ * @see ajax_payment_method.php
+ */
+require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
+
+class Payment_Method_MTable extends Manage_Table_SQL
+{
+
+ function __construct(\Data_SQL $p_table)
+ {
+ parent::__construct($p_table);
+
+ // Column header
+ $this->set_col_label("mp_lib", _("Libellé"));
+ $this->set_col_label("mp_jrn_def_id", _("Enregistrement dans"));
+ $this->set_col_label("mp_fd_id", _("Type de fiche"));
+ $this->set_col_label("mp_qcode", _("Fiche"));
+ $this->set_col_label("jrn_def_id", _("Utilisation dans"));
+ // Hide id
+ $this->set_property_visible("mp_id", FALSE);
+ $this->icon_mod="right";
+
+ // Set value for col
+ $this->set_col_type("mp_qcode","custom");
+ $this->set_col_type("mp_jrn_def_id", "select",
+ $p_table->cn->make_array("select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type in ('FIN','ODS') and jrn_enable=1 order by 2",1));
+ $this->set_col_type("mp_fd_id", "select",
+ $p_table->cn->make_array("select fd_id,fd_label from fiche_def order by 2",1));
+ $this->set_col_type("jrn_def_id", "select",
+ $p_table->cn->make_array("select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type in ('ACH','VEN') and jrn_enable=1 order by 2",1));
+ $this->set_col_tips("mp_fd_id", 71);
+ $this->set_col_tips("mp_qcode", 72);
+ $this->set_order(["mp_lib","jrn_def_id","mp_jrn_def_id","mp_fd_id","mp_qcode"]);
+
+ }
+
+ function check()
+ {
+ $table=$this->get_table();
+ $cn=$table->cn;
+ $has_error=0;
+
+ if ( trim($table->mp_lib) == "") {
+ $this->set_error("mp_lib", _("Un libellé est obligatoire"));
+ $has_error++;
+ }
+ $count_ledger_target=0;
+ if ( trim($table->mp_jrn_def_id) !="") {
+ $count_ledger_target=$cn->get_value("select count(*) from jrn_def where jrn_def_id=$1",[$table->mp_jrn_def_id]);
+
+ }
+ if ($count_ledger_target == 0 ) {
+ $this->set_error("mp_jrn_def_id", _("Choisissez un journal"));
+ $has_error++;
+ }
+
+ $count_ledger_used=0;
+ if ( trim($table->jrn_def_id) != "") {
+ $count_ledger_used=$cn->get_value("select count(*) from jrn_def where jrn_def_id=$1",[$table->jrn_def_id]);
+ }
+
+ if ($count_ledger_used == 0) {
+ $this->set_error("jrn_def_id", _("Choisissez un journal"));
+ $has_error++;
+ }
+ // if the ledger is financial, the qcode MUST be the default one
+ if ( trim($table->mp_lib) == "") {
+ $this->set_error("mp_lib", _("Un libellé est obligatoire"));
+ $has_error++;
+ }
+ if (trim ($table->mp_qcode) != "" && $a_row['jrn_def_type'] != 'FIN') {
+ $fiche=new Fiche($cn);
+ if ( $fiche->get_by_qcode($table->mp_qcode,FALSE) == 1) {
+ $this->set_error("mp_qcode",_("Fiche inexistante"));
+ $has_error++;
+ }
+ }
+ // get the type of the ledger
+ $a_row= $cn->get_row("select jrn_def_type,jrn_def_bank from jrn_def where jrn_def_id = $1",[$table->mp_jrn_def_id]);
+
+ // if ledger FIN then set the mp_qcode to the right card and set mp_fd_id to the same than mp_qcode
+ if ( $a_row['jrn_def_type'] == 'FIN') {
+ $fiche=new Fiche($cn,$a_row['jrn_def_bank']);
+ $table->mp_qcode=$fiche->get_quick_code();
+ $table->mp_fd_id=$cn->get_value("select fd_id from fiche where f_id=$1",[$a_row['jrn_def_bank']]);
+ }
+
+
+ if ( $a_row['jrn_def_type'] != 'FIN' && $table->mp_fd_id == -1)
+ {
+ $this->set_error("mp_fd_id",_("Choisissez un type de fiche"));
+ $has_error++;
+ }
+ if ( $has_error > 0) return FALSE;
+ return TRUE;
+ }
+ /**
+ * For the quickcode
+ * @param type $p_key
+ * @param type $p_value
+ */
+ function input_custom($p_key,$p_value)
+ {
+ $cn=$this->get_table()->cn;
+ switch ($p_key)
+ {
+ case "mp_qcode":
+ $w=new ICard("mp_qcode",$p_value);
+ $w->set_attribute("typecard", "all");
+ $w->autocomplete=0;
+
+ echo $w->input();
+ echo $w->search();
+ break;
+ default:
+ printf (_("Erreur key %s value %s"),$p_key,$p_value);
+ break;
+ }
+ }
+}
diff --git a/include/constant.php b/include/constant.php
index 748d26496..cc27a552d 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE);
}
-define ("DBVERSION",134);
+define ("DBVERSION",135);
define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",18);
define ('NOTFOUND','--not found--');
diff --git a/include/database/payment_method_sql.class.php b/include/database/payment_method_sql.class.php
new file mode 100644
index 000000000..2154e9509
--- /dev/null
+++ b/include/database/payment_method_sql.class.php
@@ -0,0 +1,71 @@
+table="public.payment_method";
+ $this->primary_key="mp_id";
+ /*
+ * List of columns
+ */
+ $this->name=array(
+ "mp_id"=>"mp_id"
+ , "mp_lib"=>"mp_lib"
+ , "mp_jrn_def_id"=>"mp_jrn_def_id"
+ , "mp_fd_id"=>"mp_fd_id"
+ , "mp_qcode"=>"mp_qcode"
+ , "jrn_def_id"=>"jrn_def_id"
+ );
+ /*
+ * Type of columns
+ */
+ $this->type=array(
+ "mp_id"=>"numeric"
+ , "mp_lib"=>"text"
+ , "mp_jrn_def_id"=>"numeric"
+ , "mp_fd_id"=>"numeric"
+ , "mp_qcode"=>"text"
+ , "jrn_def_id"=>"numeric"
+ );
+
+
+ $this->default=array(
+ "mp_id"=>"auto"
+ );
+
+ $this->date_format="DD.MM.YYYY";
+ parent::__construct($p_cn, $p_id);
+ }
+
+}
diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php
index 5b17c7e6f..78de05b4c 100644
--- a/include/lib/message_javascript.php
+++ b/include/lib/message_javascript.php
@@ -101,6 +101,7 @@ content[67]="";
content[69]="";
content[70]="";
-
+content[71]="";
+content[72]="";
\ No newline at end of file
diff --git a/include/payment_middle.inc.php b/include/payment_middle.inc.php
index a8db6f0a9..f86f57eb4 100644
--- a/include/payment_middle.inc.php
+++ b/include/payment_middle.inc.php
@@ -19,133 +19,15 @@
// Copyright Author Dany De Bontridder danydb@aevalys.eu
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
-require_once NOALYSS_INCLUDE.'/class/acc_payment.class.php';
-require_once NOALYSS_INCLUDE.'/lib/sort_table.class.php';
-//---------------------------------------------------------------------------
-// Common variable
-$td='| ';
-$etd=' | ';
-$tr='';
-$etr='
';
-$th='';
-$eth=' | ';
-global $http;
-/*!\file
- * \brief payment mode
- */
-$sb=$http->request('sb', "string","");
-echo '';
-//----------------------------------------------------------------------
-// change
-if ( $sb=='change')
-{
- if ( !isset($_GET['id'])) exit;
- $row=new Acc_Payment($cn,$_GET['id']);
- $row->load();
- echo '';
- return;
-}
-//----------------------------------------------------------------------
-// Save the change
-//
-if ( $sb=='save')
-{
- $http=new HttpInput();
- $delete=$http->post("delete_ck","string", 0);
- if ( $delete == 0 )
- {
- $row=new Acc_Payment($cn,$_POST ['id']);
- $row->from_array($_POST);
- $row->update();
- } else {
-//---------------------------------------------------------------------------
-// Delete a card
-//---------------------------------------------------------------------------
- $row=new Acc_Payment($cn,$_POST['id']);
- $row->from_array($_POST);
- $row->delete();
-
- }
-}
-//---------------------------------------------------------------------------
-// Insert a new mod of payment
-//---------------------------------------------------------------------------
-if ( isset($_POST['insert']))
-{
- $row=new Acc_Payment($cn);
- $row->from_array($_POST);
- $row->insert();
- $sb="list";
-}
+require_once NOALYSS_INCLUDE."/database/payment_method_sql.class.php";
+require_once NOALYSS_INCLUDE."/class/payment_method_mtable.class.php";
-//---------------------------------------------------------------------------
-// Show form to enter a new one
-//---------------------------------------------------------------------------
-if ($sb=='ins')
-{
- $mp=new Acc_Payment($cn);
- $r=$mp->blank();
- echo '';
+$payment_method_sql=new Payment_method_SQL($cn);
+$payment_method_mtable=new Payment_Method_MTable($payment_method_sql);
- return;
-}
-//--------------------------------------------------------------------------------
-//LIST
-//--------------------------------------------------------------------------------
-/* Get the data from database */
-$header=new Sort_Table();
-$base_url=$_SERVER['PHP_SELF']."?".Dossier::get()."&ac=".$_REQUEST['ac'];
+$payment_method_mtable->add_json_param("op", "payment_method");
+$payment_method_mtable->set_callback("ajax_misc.php");
+$payment_method_mtable->create_js_script();
-$header->add(_("Libelle"),$base_url,"order by mp_lib asc","order by mp_lib desc",'la','ld');
-$header->add(_("Pour le journal"),$base_url,"order by jrn_def_name asc","order by jrn_def_name desc",'ja','jd');
-$header->add(_("Type de fiche"),$base_url,"order by fd_label asc","order by fd_label desc",'tc','td');
-$header->add(_("Enregistré dans le journal"),$base_url,"order by jrn_target asc","order by jrn_target desc",'jta','jtd');
-$header->add(_("Avec la fiche"),$base_url,"order by vw_name asc","order by vw_name desc",'na','nd');
-
-$order=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'la';
-
-$sql=$header->get_sql_order($order);
-
-$array=$cn->get_array("
- select
- mp_id,mp_lib,mp_jrn_def_id,mp_fd_id,mp_qcode,j.jrn_def_id,
- j.jrn_def_name as jrn_def_name,
- j2.jrn_def_name as jrn_target,
- fd_label,
- coalesce(mp_qcode,'A choisir à l''encodage') as vw_name
- from payment_method as mp
- left join jrn_def as j on (j.jrn_def_id=mp.jrn_def_id)
- left join jrn_def as j2 on (j2.jrn_def_id=mp.mp_jrn_def_id)
- left join fiche_def as fd on (mp.mp_fd_id=fd.fd_id)
- $sql
- ");
-/* if there are data show them in a table */
-if ( ! empty ($array))
-{
-
- require_once NOALYSS_TEMPLATE.'/list_mod_payment.php';
-}
-echo HtmlInput::button_anchor("Ajout", $base_url."&sb=ins","","","smallbutton");
-echo '
';
-?>
+echo $payment_method_mtable->display_table();
diff --git a/include/sql/patch/upgrade134.sql b/include/sql/patch/upgrade134.sql
new file mode 100644
index 000000000..17d4f18a8
--- /dev/null
+++ b/include/sql/patch/upgrade134.sql
@@ -0,0 +1,8 @@
+begin;
+
+update attr_def set ad_extra = '[sql] fd_id in (select fd_id from fiche_def where frd_id in (4,8,9,14))' where ad_id=25;
+
+alter table mod_payment rename to payment_method;
+
+insert into version (val,v_description) values (135,'rename table mod_payment');
+commit ;
\ No newline at end of file
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index ea4b1317b..e69de29bb 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -1,21 +0,0 @@
-update attr_def set ad_extra = '[sql] fd_id in (select fd_id from fiche_def where frd_id in (4,8,9,14))' where ad_id=25;
-
-alter table mod_payment rename to payment_method;
-
-alter table payment_method add column type_payment_id varchar(6);
-
-
-comment on column payment_method.type_payment_id is 'Type of payment method';
-
-create table type_payment_ref (id varchar(6 ) primary key,tp_description varchar(80) not null);
-
-insert into type_payment_ref (id,tp_description) values ('CACRD','Carte de crédit'),
- ('CHCK','Chèque'),
- ('CASH','Liquide'),
- ('ELECT','Electronique'),
- ('VIRT','Virement');
-update payment_method set type_payment_id = 'VIRT';
-
-alter table payment_method add constraint type_payment_ref_fk foreign key (type_payment_id) references type_payment_ref(id);
-
-alter table payment_method alter type_payment_id set not null;
\ No newline at end of file