Author: danydb Date: 2012-01-25 00:42:14 +0100 (Wed, 25 Jan 2012) New Revision: 4731
Modified:
phpcompta/tags/rel600/include/class_fiche.php
Log:
probleme mise à jour fiche avec double poste comptable
Modified: phpcompta/tags/rel600/include/class_fiche.php
===================================================================
--- phpcompta/tags/rel600/include/class_fiche.php 2012-01-24 12:49:31 UTC
(rev 4730)
+++ phpcompta/tags/rel600/include/class_fiche.php 2012-01-24 23:42:14 UTC
(rev 4731)
@@ -934,47 +934,51 @@
}
// account
- if ( $id == ATTR_DEF_ACCOUNT )
- {
- $v=sql_string($value);
- if ( trim($v) != '' )
- {
- if ( strpos($v,',') != 0)
- {
- $v=$this->cn->get_value('select
format_account($1)',
- array($v));
- }
- $sql=sprintf("select account_update(%d,'%s')",
- $this->id,$v);
- try
- {
- $this->cn->exec_sql($sql);
- }
- catch (Exception $e)
- {
- throw new Exception(__LINE__."Erreur : ce compte
[$v] n'a pas de compte parent.".
- "L'opération est
annulée");
- }
- continue;
- }
- if ( strlen (trim($v)) == 0 )
- {
+ if ($id == ATTR_DEF_ACCOUNT)
+ {
+ $v = sql_string($value);
+ if (trim($v) != '')
+ {
+ if (strpos($v, ',') != 0)
+ {
+ $ac_array =
explode(",", $v);
+ if (count($ac_array) <>
2)
+ throw new
Exception('Désolé, il y a trop de virgule dans le poste comptable ' . h($v));
+ $part1 = $ac_array[0];
+ $part2 = $ac_array[1];
+ $part1 =
$this->cn->get_value('select format_account($1)', array($part1));
+ $part2 =
$this->cn->get_value('select format_account($1)', array($part2));
+ $v = $part1 . ',' .
$part2;
+ }
+ $sql = sprintf("select
account_update(%d,'%s')", $this->id, $v);
+ try
+ {
+
$this->cn->exec_sql($sql);
+ }
+ catch (Exception $e)
+ {
+ throw new
Exception(__LINE__ . "Erreur : ce compte [$v] n'a pas de compte parent." .
+
"L'opération est annulée");
+ }
+ continue;
+ }
+ if (strlen(trim($v)) == 0)
+ {
- $sql=sprintf("select account_update(%d,null)",
- $this->id);
- try
- {
- $Ret=$this->cn->exec_sql($sql);
- }
- catch (Exception $e)
- {
- throw new Exception(__LINE__."Erreur : ce compte
[$v] n'a pas de compte parent.".
- "L'opération est annulée");
- }
+ $sql = sprintf("select
account_update(%d,null)", $this->id);
+ try
+ {
+ $Ret =
$this->cn->exec_sql($sql);
+ }
+ catch (Exception $e)
+ {
+ throw new
Exception(__LINE__ . "Erreur : ce compte [$v] n'a pas de compte parent." .
+
"L'opération est annulée");
+ }
- continue;
- }
- }
+ continue;
+ }
+ }
// TVA
if ( $id == ATTR_DEF_TVA )
{
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
_______________________________________________
Phpcompta est un logiciel libre de comptabilité en ligne
(http://www.phpcompta.eu)
Phpcompta-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/phpcompta-dev
