Fix problem with account in card

This commit is contained in:
sparkyx 2007-05-31 21:52:33 +00:00
parent bcd0577828
commit c7547258f5
5 changed files with 74 additions and 15 deletions

View file

@ -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 '<p class="error"> php mal configuré</p>';
exit -1;
}
$cn=DbConnect(-2,'phpcompta');
$cn=DbConnect(-2,'template1');
if ($cn == false ) {
print "<p> 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'. </p>
<p>Ces commandes cr&eacute;eront l'utilisateur phpcompta
puis la base de donn&eacute;es par d&eacute;faut de phpcompta.</p>";
print "<p> 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)' </p>
<p>Ces commandes cr&eacute;eront l'utilisateur phpcompta avec le droit de cr&eacute;er des bases de donn&eacute;.</p>";
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&eacute;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 "<h2 class=\"info\">Voilà tout est installé ;-)</h2>";
echo "<h2 class=\"info\">Voilà tout est install&eacute; ;-)</h2>";

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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 "<span class=\"error\"Erreur : ce compte [$v] n'a pas de compte parent.".
"L'op&eacute;ration est annul&eacute;</span>";
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 "<span class=\"error\">Erreur : ce compte [$v] n'a pas de compte parent.".
"L'op&eacute;ration est annul&eacute;e</span>";
Rollback($this->cn);
return;
}
continue;
}
if ( strlen (trim($v)) == 0 )
{