[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 43/107: fixup! Code cleaning : split database
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 43/107: fixup! Code cleaning : split database into database (for noalyss) and databasecore , with the functions |
Date: |
Mon, 26 Aug 2019 10:31:54 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit be6d21610931be377f99d1b925a9eac2f66e8b00
Author: Dany De Bontridder <address@hidden>
Date: Thu Jul 25 19:30:35 2019 +0200
fixup! Code cleaning : split database into database (for noalyss) and
databasecore , with the functions
---
include/class/database.class.php | 109 ++++++++++++++++++++++++++++++++++++
include/lib/database_core.class.php | 109 ------------------------------------
2 files changed, 109 insertions(+), 109 deletions(-)
diff --git a/include/class/database.class.php b/include/class/database.class.php
index 23f67da..eed0e60 100644
--- a/include/class/database.class.php
+++ b/include/class/database.class.php
@@ -112,5 +112,114 @@ class Database extends DatabaseCore
return $Res;
}
+ /**
+ * \brief loop to apply all the path to a folder or
+ * a template
+ * \param $p_name database name
+ *
+ */
+
+ function apply_patch($p_name)
+ {
+ if (!$this->exist_table('version')) {
+ echo _('Base de donnée vide');
+ return;
+ }
+ $MaxVersion = DBVERSION - 1;
+ $succeed = "<span
style=\"font-size:18px;color:green\">✓</span>";
+ echo '<ul style="list-type-style:square">';
+ for ($i = 4; $i <= $MaxVersion; $i++) {
+ $to = $i + 1;
+
+ if ($this->get_version() <= $i) {
+ if ($this->get_version() == 97) {
+ if ($this->exist_schema("amortissement")) {
+ $this->exec_sql('ALTER TABLE
amortissement.amortissement_histo
+ ADD CONSTRAINT
internal_fk FOREIGN KEY (jr_internal) REFERENCES jrn (jr_internal)
+ ON UPDATE CASCADE ON
DELETE SET NULL');
+ }
+ }
+ echo "<li>Patching " . $p_name .
+ " from the version " . $this->get_version() . " to $to ";
+
+ $this->execute_script(NOALYSS_INCLUDE . '/sql/patch/upgrade' .
$i . '.sql');
+ echo $succeed;
+
+ if (!DEBUG)
+ ob_start();
+ // specific for version 4
+ if ($i == 4) {
+ $sql = "select jrn_def_id from jrn_def ";
+ $Res = $this->exec_sql($sql);
+ $Max = $this->size();
+ for ($seq = 0; $seq < $Max; $seq++) {
+ $row = pg_fetch_array($Res, $seq);
+ $sql = sprintf("create sequence s_jrn_%d",
$row['jrn_def_id']);
+ $this->exec_sql($sql);
+ }
+ }
+ // specific to version 7
+ if ($i == 7) {
+ // now we use sequence instead of computing a max
+ //
+ $Res2 = $this->exec_sql('select
coalesce(max(jr_grpt_id),1) as l from jrn');
+ $Max2 = pg_NumRows($Res2);
+ if ($Max2 == 1) {
+ $Row = pg_fetch_array($Res2, 0);
+ var_dump($Row);
+ $M = $Row['l'];
+ $this->exec_sql("select setval('s_grpt',$M,true)");
+ }
+ }
+ // specific to version 17
+ if ($i == 17) {
+ $this->execute_script(NOALYSS_INCLUDE .
'/sql/patch/upgrade17.sql');
+ $max = $this->get_value('select last_value from
s_jnt_fic_att_value');
+ $this->alter_seq($p_cn, 's_jnt_fic_att_value', $max + 1);
+ } // version
+ // reset sequence in the modele
+ //--
+ if ($i == 30 && $p_name == "mod") {
+ $a_seq = array('s_jrn', 's_jrn_op', 's_centralized',
+ 's_stock_goods', 'c_order', 's_central');
+ foreach ($a_seq as $seq) {
+ $sql = sprintf("select setval('%s',1,false)", $seq);
+ $Res = $this->exec_sql($sql);
+ }
+ $sql = "select jrn_def_id from jrn_def ";
+ $Res = $this->exec_sql($sql);
+ $Max = pg_NumRows($Res);
+ for ($seq = 0; $seq < $Max; $seq++) {
+ $row = pg_fetch_array($Res, $seq);
+ $sql = sprintf("select setval('s_jrn_%d',1,false)",
$row['jrn_def_id']);
+ $this->exec_sql($sql);
+ }
+ }
+ if ($i == 36) {
+ /* check the country and apply the path */
+ $res = $this->exec_sql("select pr_value from parameter
where pr_id='MY_COUNTRY'");
+ $country = pg_fetch_result($res, 0, 0);
+ $this->execute_script(NOALYSS_INCLUDE .
"/sql/patch/upgrade36." . $country . ".sql");
+ $this->exec_sql('update tmp_pcmn set
pcm_type=find_pcm_type(pcm_val)');
+ }
+ if ($i == 59) {
+ $res = $this->exec_sql("select pr_value from parameter
where pr_id='MY_COUNTRY'");
+ $country = pg_fetch_result($res, 0, 0);
+ if ($country == 'BE')
+ $this->exec_sql("insert into parm_code values
('SUPPLIER',440,'Poste par défaut pour les fournisseurs')");
+ if ($country == 'FR')
+ $this->exec_sql("insert into parm_code values
('SUPPLIER',400,'Poste par défaut pour les fournisseurs')");
+ }
+ if ($i == 61) {
+ $country = $this->get_value("select pr_value from
parameter where pr_id='MY_COUNTRY'");
+ $this->execute_script(NOALYSS_INCLUDE .
"/sql/patch/upgrade61." . $country . ".sql");
+ }
+
+ if (!DEBUG)
+ ob_end_clean();
+ }
+ }
+ echo '</ul>';
+ }
}
\ No newline at end of file
diff --git a/include/lib/database_core.class.php
b/include/lib/database_core.class.php
index a38725d..2b3bd9e 100644
--- a/include/lib/database_core.class.php
+++ b/include/lib/database_core.class.php
@@ -390,115 +390,6 @@ class DatabaseCore
return $this->size($p_ret);
}
- /**
- * \brief loop to apply all the path to a folder or
- * a template
- * \param $p_name database name
- *
- */
-
- function apply_patch($p_name)
- {
- if (!$this->exist_table('version')) {
- echo _('Base de donnée vide');
- return;
- }
- $MaxVersion = DBVERSION - 1;
- $succeed = "<span
style=\"font-size:18px;color:green\">✓</span>";
- echo '<ul style="list-type-style:square">';
- for ($i = 4; $i <= $MaxVersion; $i++) {
- $to = $i + 1;
-
- if ($this->get_version() <= $i) {
- if ($this->get_version() == 97) {
- if ($this->exist_schema("amortissement")) {
- $this->exec_sql('ALTER TABLE
amortissement.amortissement_histo
- ADD CONSTRAINT
internal_fk FOREIGN KEY (jr_internal) REFERENCES jrn (jr_internal)
- ON UPDATE CASCADE ON
DELETE SET NULL');
- }
- }
- echo "<li>Patching " . $p_name .
- " from the version " . $this->get_version() . " to $to ";
-
- $this->execute_script(NOALYSS_INCLUDE . '/sql/patch/upgrade' .
$i . '.sql');
- echo $succeed;
-
- if (!DEBUG)
- ob_start();
- // specific for version 4
- if ($i == 4) {
- $sql = "select jrn_def_id from jrn_def ";
- $Res = $this->exec_sql($sql);
- $Max = $this->size();
- for ($seq = 0; $seq < $Max; $seq++) {
- $row = pg_fetch_array($Res, $seq);
- $sql = sprintf("create sequence s_jrn_%d",
$row['jrn_def_id']);
- $this->exec_sql($sql);
- }
- }
- // specific to version 7
- if ($i == 7) {
- // now we use sequence instead of computing a max
- //
- $Res2 = $this->exec_sql('select
coalesce(max(jr_grpt_id),1) as l from jrn');
- $Max2 = pg_NumRows($Res2);
- if ($Max2 == 1) {
- $Row = pg_fetch_array($Res2, 0);
- var_dump($Row);
- $M = $Row['l'];
- $this->exec_sql("select setval('s_grpt',$M,true)");
- }
- }
- // specific to version 17
- if ($i == 17) {
- $this->execute_script(NOALYSS_INCLUDE .
'/sql/patch/upgrade17.sql');
- $max = $this->get_value('select last_value from
s_jnt_fic_att_value');
- $this->alter_seq($p_cn, 's_jnt_fic_att_value', $max + 1);
- } // version
- // reset sequence in the modele
- //--
- if ($i == 30 && $p_name == "mod") {
- $a_seq = array('s_jrn', 's_jrn_op', 's_centralized',
- 's_stock_goods', 'c_order', 's_central');
- foreach ($a_seq as $seq) {
- $sql = sprintf("select setval('%s',1,false)", $seq);
- $Res = $this->exec_sql($sql);
- }
- $sql = "select jrn_def_id from jrn_def ";
- $Res = $this->exec_sql($sql);
- $Max = pg_NumRows($Res);
- for ($seq = 0; $seq < $Max; $seq++) {
- $row = pg_fetch_array($Res, $seq);
- $sql = sprintf("select setval('s_jrn_%d',1,false)",
$row['jrn_def_id']);
- $this->exec_sql($sql);
- }
- }
- if ($i == 36) {
- /* check the country and apply the path */
- $res = $this->exec_sql("select pr_value from parameter
where pr_id='MY_COUNTRY'");
- $country = pg_fetch_result($res, 0, 0);
- $this->execute_script(NOALYSS_INCLUDE .
"/sql/patch/upgrade36." . $country . ".sql");
- $this->exec_sql('update tmp_pcmn set
pcm_type=find_pcm_type(pcm_val)');
- }
- if ($i == 59) {
- $res = $this->exec_sql("select pr_value from parameter
where pr_id='MY_COUNTRY'");
- $country = pg_fetch_result($res, 0, 0);
- if ($country == 'BE')
- $this->exec_sql("insert into parm_code values
('SUPPLIER',440,'Poste par défaut pour les fournisseurs')");
- if ($country == 'FR')
- $this->exec_sql("insert into parm_code values
('SUPPLIER',400,'Poste par défaut pour les fournisseurs')");
- }
- if ($i == 61) {
- $country = $this->get_value("select pr_value from
parameter where pr_id='MY_COUNTRY'");
- $this->execute_script(NOALYSS_INCLUDE .
"/sql/patch/upgrade61." . $country . ".sql");
- }
-
- if (!DEBUG)
- ob_end_clean();
- }
- }
- echo '</ul>';
- }
/**
*
- [Noalyss-commit] [noalyss] 20/107: Bug with javascript global variable width is undefined, (continued)
- [Noalyss-commit] [noalyss] 20/107: Bug with javascript global variable width is undefined, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 31/107: translation, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 25/107: correct js for error, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 29/107: Bug in exception : gettext cannot accept 2 args, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 33/107: Small bug use the date instead of now for table version, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 40/107: PHPUnit : adapt to new version, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 61/107: Documentation, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 62/107: #1316: Notes tableau de bord - pas de limite ou choix., Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 69/107: Fix test, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 50/107: Documentation : automatic format breaks doxygen tag, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 43/107: fixup! Code cleaning : split database into database (for noalyss) and databasecore , with the functions,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 65/107: Code cleaning : remove obsolete, and direct access to, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 74/107: New : manage_table_sql has new function (input_custom and display_row_custom) for handling special data, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 73/107: Cosmetic & bug fix for SELECT_BOX, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 28/107: Debug : add function tracedebug, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 32/107: Cosmetic : font new symbol Cosmetic : CSS padding for div.menu2 a.mtitle, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 58/107: javascript Add new function json_response, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 52/107: Adapt Unit Test, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 76/107: fixup! Improve message progress bar + translation, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 78/107: Purpose is to contain all the prepared query called from different locations, Dany De Bontridder, 2019/08/26
- [Noalyss-commit] [noalyss] 83/107: Task#1734 New : Add PRINTTVA to have a summary of VAT by ledger, Dany De Bontridder, 2019/08/26