diff --git a/html/admin/setup.php b/html/admin/setup.php
index 169e38850..bd5144c13 100644
--- a/html/admin/setup.php
+++ b/html/admin/setup.php
@@ -148,7 +148,7 @@ function ExecuteScript($p_cn,$script) {
$buffer=str_replace (';','',$buffer);
}
$sql.=$buffer;
- if ( ExecSql($p_cn,$sql) == false ) {
+ if ( ExecSql($p_cn,$sql,false) == false ) {
Rollback($p_cn);
if ( DEBUG=='false' ) ob_end_flush();
print "ERROR : $sql";
@@ -218,13 +218,11 @@ if ( $flag_php==0 ) {
echo '
php mal configuré
';
exit -1;
}
-$cn=DbConnect(-2,'phpcompta');
+$cn=DbConnect(-2,'template1');
if ($cn == false ) {
- print " Vous devez absolument taper dans une console la commande 'createuser -A -d -P phpcompta et vous donnez dany comme mot de passe (voir la documentation)'
- puis la commande 'createdb -O phpcompta phpcompta'.
-Ces commandes créeront l'utilisateur phpcompta
-puis la base de données par défaut de phpcompta.
";
+ print " Vous devez absolument taper dans une console la commande 'createuser -A -d -P phpcompta et vous donnez dany comme mot de passe (voir la documentation)'
+Ces commandes créeront l'utilisateur phpcompta avec le droit de créer des bases de donné.
";
exit();
}
?>
@@ -329,7 +327,7 @@ if ($account == 0 ) {
ExecuteScript($cn,"sql/account_repository/constraint.sql");
Commit($cn);
if ( DEBUG=='false') ob_end_clean();
- echo "Creation of Démo";
+ echo "Creation of Démo";
if ( DEBUG=='false') ob_start();
ExecSql($cn,"create database ".domaine."dossier1 encoding='latin1'");
$cn=DbConnect(1,'dossier');
@@ -517,6 +515,9 @@ if ( DEBUG=='false' ) ob_start();
if ( GetVersion($db) == 28 ) {
ExecuteScript($db,'sql/patch/upgrade28.sql');
} // version
+ if ( GetVersion($db) == 29 ) {
+ ExecuteScript($db,'sql/patch/upgrade29.sql');
+ } // version
if ( DEBUG == 'false') ob_end_clean();
}//for
@@ -639,6 +640,9 @@ if (DEBUG == 'false' ) ob_start();
if ( GetVersion($db) == 28 ) {
ExecuteScript($db,'sql/patch/upgrade28.sql');
} // version
+ if ( GetVersion($db) == 29 ) {
+ ExecuteScript($db,'sql/patch/upgrade29.sql');
+ } // version
if ( DEBUG == 'false') ob_end_clean();
}
@@ -660,4 +664,4 @@ if ( GetVersion($cn) == 7 ) {
}
if (DEBUG=='false') ob_end_clean();
-echo "Voilà tout est installé ;-)
";
+echo "Voilà tout est installé ;-)
";
diff --git a/html/admin/sql/patch/upgrade29.sql b/html/admin/sql/patch/upgrade29.sql
new file mode 100644
index 000000000..b8a09ec33
--- /dev/null
+++ b/html/admin/sql/patch/upgrade29.sql
@@ -0,0 +1,31 @@
+begin;
+CREATE or REPLACE FUNCTION account_update(p_f_id integer, p_account poste_comptable) RETURNS integer
+ AS $$
+declare
+nMax fiche.f_id%type;
+nCount integer;
+nParent tmp_pcmn.pcm_val_parent%type;
+sName varchar;
+nJft_id attr_value.jft_id%type;
+begin
+
+ if length(trim(p_account)) != 0 then
+ select count(*) into nCount from tmp_pcmn where pcm_val=p_account;
+ if nCount = 0 then
+ select av_text into sName from
+ attr_value join jnt_fic_att_value using (jft_id)
+ where
+ ad_id=1 and f_id=p_f_id;
+ nParent:=account_parent(p_account);
+ insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_account,sName,nParent);
+ end if;
+ end if;
+ select jft_id into njft_id from jnt_fic_att_value where f_id=p_f_id and ad_id=5;
+ update attr_value set av_text=p_account where jft_id=njft_id;
+
+return njft_id;
+end;
+$$
+ LANGUAGE plpgsql;
+update version set val=30;
+commit;
diff --git a/html/style-color.css b/html/style-color.css
index 40e65aa4c..064c91caa 100644
--- a/html/style-color.css
+++ b/html/style-color.css
@@ -206,6 +206,11 @@ span.even {
background-color:#DDE6FF;
display:block;
}
+span.error {
+ color:black;
+ background-color:red;
+ font-size:120%;
+}
tr.odd {
background-color:#DDE6FF;
diff --git a/html/style-light.css b/html/style-light.css
index c66f7e963..3884eb382 100644
--- a/html/style-light.css
+++ b/html/style-light.css
@@ -200,8 +200,9 @@ span.even {
display:block;
}
span.error {
- background-color:white;
- font-color:red;
+color:black;
+background-color:red;
+font-size:120%;
}
tr.odd {
background-color:#DDE6FF;
diff --git a/include/class_fiche.php b/include/class_fiche.php
index 6318c049b..0168d1282 100644
--- a/include/class_fiche.php
+++ b/include/class_fiche.php
@@ -456,9 +456,9 @@ class fiche {
{
echo_debug("insert ATTR_DEF_ACCOUNT");
$v=FormatString($value);
+ ob_start();
if (
- isNumber($v) == 1 &&
- CountSql($this->cn,"select * from tmp_pcmn where pcm_val=$v")
+ isNumber($v) == 1
)
{
$sql=sprintf("select account_insert(%d,%f)",
@@ -469,8 +469,14 @@ class fiche {
$sql=sprintf("select account_insert(%d,null)",
$this->id);
}
- ExecSql($this->cn,$sql);
-
+ $ret=ExecSql($this->cn,$sql,false);
+ ob_end_clean();
+ if ( $ret == false ) {
+ echo "";
+ Rollback($this->cn);
+ return;
+ }
continue;
}
// TVA
@@ -571,11 +577,23 @@ class fiche {
{
echo_debug("Modify ATTR_DEF_ACCOUNT");
$v=FormatString($value);
+ echo_debug("Value = $v");
if ( isNumber($v) == 1 )
{
+ ob_start();
+
$sql=sprintf("select account_update(%d,%d)",
$this->id,$v);
- $Ret=ExecSql($this->cn,$sql);
+ $Ret=ExecSql($this->cn,$sql,false);
+
+ ob_end_clean();
+ if ( $Ret == false ) {
+ echo "Erreur : ce compte [$v] n'a pas de compte parent.".
+ "L'opération est annulée";
+ Rollback($this->cn);
+ return;
+ }
+ continue;
}
if ( strlen (trim($v)) == 0 )
{