diff --git a/include/class/database.class.php b/include/class/database.class.php
index 71dce9ccc..216d3f400 100644
--- a/include/class/database.class.php
+++ b/include/class/database.class.php
@@ -113,8 +113,11 @@ class Database extends DatabaseCore
}
/**
- * \brief loop to apply all the path to a folder or
- * a template
+ * \brief loop to apply all the path to a folder or a template
+ * Upgrade check if the folder $p_name needs to be upgrade thanks the variable DBVERSION
+ * and run all the SQL script named upgradeX.sql from the folder noalyss/include/sql/patch
+ * until X equal DBVERSION-1
+ *
* \param $p_name database name
*
*/
@@ -142,8 +145,7 @@ class Database extends DatabaseCore
echo "
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();
@@ -214,9 +216,17 @@ class Database extends DatabaseCore
$country = $this->get_value("select pr_value from parameter where pr_id='MY_COUNTRY'");
$this->execute_script(NOALYSS_INCLUDE . "/sql/patch/upgrade61." . $country . ".sql");
}
+ /**
+ * Bug in parm_code for FRANCE
+ */
+ if ($i == 141 ) {
+ $country = $this->get_value("select pr_value from parameter where pr_id='MY_COUNTRY'");
+ $this->execute_script(NOALYSS_INCLUDE . "/sql/patch/upgrade141." . $country . ".sql");
+ }
if (!DEBUG)
ob_end_clean();
+
}
}
echo '';
diff --git a/include/class/dossier.class.php b/include/class/dossier.class.php
index 3d2cde9aa..ecd439e1a 100644
--- a/include/class/dossier.class.php
+++ b/include/class/dossier.class.php
@@ -330,7 +330,13 @@ class Dossier
$cn->rollback();
}
}
-
+ /**
+ * Upgrade check if the folder ACCOUNT_REPOSITORY needs to be upgrade thanks the variable DBVERSIONREPO
+ * and run all the SQL script named ac-upgradeX.sql from the folder noalyss/include/sql/patch
+ * until X equal DBVERSIONREPO-1
+ * After it will call the function apply_patch, remove_inexistant_user and clean_orphan_log for each folder
+ *
+ */
static function upgrade()
{
$rep=new Database();
diff --git a/include/constant.php b/include/constant.php
index 1625f70c4..a10f5bb39 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -107,7 +107,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
if ( ! defined ("SYSINFO_DISPLAY")) {
define ("SYSINFO_DISPLAY",TRUE);
}
-define ("DBVERSION",141);
+define ("DBVERSION",143);
define ("MONO_DATABASE",25);
define ("DBVERSIONREPO",18);
define ('NOTFOUND','--not found--');
diff --git a/include/sql/patch/upgrade141.BE.sql b/include/sql/patch/upgrade141.BE.sql
new file mode 100644
index 000000000..34478623e
--- /dev/null
+++ b/include/sql/patch/upgrade141.BE.sql
@@ -0,0 +1,3 @@
+begin;
+insert into version (val,v_description) values (142,'Bug dans PARM_POSTE');
+commit ;
diff --git a/include/sql/patch/upgrade141.FR.sql b/include/sql/patch/upgrade141.FR.sql
new file mode 100644
index 000000000..1e7c566eb
--- /dev/null
+++ b/include/sql/patch/upgrade141.FR.sql
@@ -0,0 +1,5 @@
+begin;
+update parm_poste set p_type='PAS' where p_value='40';
+
+insert into version (val,v_description) values (142,'Bug dans PARM_POSTE');
+commit ;
diff --git a/include/sql/patch/upgrade141.sql b/include/sql/patch/upgrade141.sql
new file mode 100644
index 000000000..e69de29bb
diff --git a/include/sql/patch/upgrade142.sql b/include/sql/patch/upgrade142.sql
new file mode 100644
index 000000000..3afaed6c0
--- /dev/null
+++ b/include/sql/patch/upgrade142.sql
@@ -0,0 +1,43 @@
+begin;
+
+CREATE OR REPLACE FUNCTION comptaproc.find_pcm_type(pp_value account_type)
+ RETURNS text
+AS $function$
+declare
+ str_type parm_poste.p_type%TYPE;
+ str_value parm_poste.p_type%TYPE;
+ nLength integer;
+begin
+ str_value:=pp_value;
+ nLength:=length(str_value::text);
+
+ while nLength > 0 loop
+ select p_type into str_type from parm_poste where p_value=str_value;
+ if FOUND then
+ raise info 'Type of %s is %s',str_value,str_type;
+ return str_type;
+ end if;
+ nLength:=nLength-1;
+ str_value:=substring(str_value::text from 1 for nLength)::account_type;
+ end loop;
+-- Si non trouvé dans PARM_POSTE, prend le type du premier parent trouvé
+--
+ str_value := pp_value;
+ nLength:=length(str_value::text);
+ str_value:=substring(str_value::text from 1 for nLength)::account_type;
+ while nLength > 0 loop
+ select pcm_type into str_type from tmp_pcmn tp where pcm_val=str_value;
+ if FOUND then
+ raise info 'Type of %s is %s',str_value,str_type;
+ return str_type;
+ end if;
+ nLength:=nLength-1;
+ str_value:=substring(str_value::text from 1 for nLength)::account_type;
+ end loop;
+-- si ni parent ou parm_poste alors return CON
+return 'CON';
+end;
+$function$
+ LANGUAGE plpgsql;
+insert into version (val,v_description) values (143,'Corrige function find_pcm_type');
+commit ;