From MAILER-DAEMON Wed Jun 01 17:40:28 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QRt9P-0004IY-Ef
	for mharc-phpcompta-dev@gnu.org; Wed, 01 Jun 2011 17:40:27 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Wed,  1 Jun 2011 23:44:55 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.4376.1306964426.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4150 - in phpcompta/branches/rel560:
	html/admin/sql/account_repository html/admin/sql/patch include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 01 Jun 2011 21:40:26 -0000

Author: danydb
Date: 2011-06-01 23:44:53 +0200 (Wed, 01 Jun 2011)
New Revision: 4150

Added:
   phpcompta/branches/rel560/html/admin/sql/patch/upgrade94.sql
Modified:
   phpcompta/branches/rel560/html/admin/sql/account_repository/schema.sql
   phpcompta/branches/rel560/include/class_database.php
Log:
update SQL script

Modified: phpcompta/branches/rel560/html/admin/sql/account_repository/sch=
ema.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/admin/sql/account_repository/schema.sq=
l	2011-06-01 00:12:08 UTC (rev 4149)
+++ phpcompta/branches/rel560/html/admin/sql/account_repository/schema.sq=
l	2011-06-01 21:44:53 UTC (rev 4150)
@@ -81,7 +81,3 @@
 );
 CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id);
 CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id);
-REVOKE ALL ON SCHEMA public FROM PUBLIC;
-REVOKE ALL ON SCHEMA public FROM postgres;
-GRANT ALL ON SCHEMA public TO postgres;
-GRANT ALL ON SCHEMA public TO PUBLIC;

Added: phpcompta/branches/rel560/html/admin/sql/patch/upgrade94.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/admin/sql/patch/upgrade94.sql	        =
                (rev 0)
+++ phpcompta/branches/rel560/html/admin/sql/patch/upgrade94.sql	2011-06-=
01 21:44:53 UTC (rev 4150)
@@ -0,0 +1,93 @@
+begin;
+
+--
+-- Name: account_insert(integer, text); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION account_insert(p_f_id integer, p_account text) RETURNS i=
nteger
+    AS $_$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	nNew tmp_pcmn.pcm_val%type;
+	bAuto bool;
+	nFd_id integer;
+	sClass_Base fiche_def.fd_class_base%TYPE;
+	nCount integer;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+	-- if there is coma in p_account, treat normally
+		if position (',' in p_account) =3D 0 then
+			raise info 'p_account is not empty';
+				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
+				raise notice 'found in tmp_pcm %',nCount;
+				if nCount !=3D0  then
+					raise info 'this account exists in tmp_pcmn ';
+					perform attribut_insert(p_f_id,5,p_account);
+				   else
+				       -- account doesn't exist, create it
+					select ad_value into sName from
+						fiche_detail
+					where
+					ad_id=3D1 and f_id=3Dp_f_id;
+
+					nParent:=3Daccount_parent(p_account::account_type);
+					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
+					perform attribut_insert(p_f_id,5,p_account);
+
+				end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		perform attribut_insert(p_f_id,5,p_account);
+		end if;
+	else
+	raise info 'p_account is  empty';
+		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
+		bAuto:=3D account_auto(nFd_id);
+
+		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
+raise info 'sClass_Base : %',sClass_base;
+		if bAuto =3D true and sClass_base similar to '^[[:digit:]]*$'  then
+			raise info 'account generated automatically';
+			nNew:=3Daccount_compute(p_f_id);
+			raise info 'nNew %', nNew;
+			select ad_value into sName from
+				fiche_detail
+			where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(nNew);
+			perform account_add  (nNew,sName);
+			perform attribut_insert(p_f_id,5,nNew);
+
+		else
+		-- if there is an account_base then it is the default
+		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
+			if nNew is null or length(trim(nNew)) =3D 0 then
+				raise notice 'count is null';
+				 perform attribut_insert(p_f_id,5,null);
+			else
+				 perform attribut_insert(p_f_id,5,nNew);
+			end if;
+		end if;
+	end if;
+
+return 0;
+end;
+$_$    =20
+LANGUAGE plpgsql;
+
+update version set val=3D95;
+
+commit;
\ No newline at end of file

Modified: phpcompta/branches/rel560/include/class_database.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_database.php	2011-06-01 00:12=
:08 UTC (rev 4149)
+++ phpcompta/branches/rel560/include/class_database.php	2011-06-01 21:44=
:53 UTC (rev 4150)
@@ -274,7 +274,7 @@
             if ( $flag_function )
             {
                 if ( strpos(strtolower($buffer), "language plpgsql") =3D=
=3D=3D false &&
-                        strpos(strtolower($buffer), "language 'plpgsql'"=
) =3D=3D=3D false )
+                     strpos(strtolower($buffer), "language 'plpgsql'") =3D=
=3D=3D false )
                 {
                     $sql.=3D$buffer;
                     continue;
@@ -457,7 +457,7 @@
         if ( pg_NumRows($this->ret) > 1 )
 	  {
 	    $array=3Dpg_fetch_all($this->ret);
-          throw new Exception( "Attention $p_sql retourne ".pg_NumRows($=
this->ret)."  valeurs ".
+	    throw new Exception( "Attention $p_sql retourne ".pg_NumRows($this-=
>ret)."  valeurs ".
 			       var_export($p_array,true)." values=3D".var_export($array,true)=
);
 	  }
         $r=3Dpg_fetch_row($this->ret,0);



From MAILER-DAEMON Wed Jun 01 17:41:51 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QRtAk-0004bA-Ux
	for mharc-phpcompta-dev@gnu.org; Wed, 01 Jun 2011 17:41:50 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Wed,  1 Jun 2011 23:46:26 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.4378.1306964510.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4151 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 01 Jun 2011 21:41:49 -0000

Author: danydb
Date: 2011-06-01 23:46:25 +0200 (Wed, 01 Jun 2011)
New Revision: 4151

Modified:
   phpcompta/branches/rel560/include/constant.php
Log:
update database version


Modified: phpcompta/branches/rel560/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/constant.php	2011-06-01 21:44:53 UT=
C (rev 4150)
+++ phpcompta/branches/rel560/include/constant.php	2011-06-01 21:46:25 UT=
C (rev 4151)
@@ -35,16 +35,14 @@
 /* set to none for production */
 /* uncomment for production */
=20
-$version_phpcompta=3DSVNINFO;=20
-define ("DEBUG",false);
+//$version_phpcompta=3DSVNINFO;=20
+//define ("DEBUG",false);
=20
-/*
 define ("DEBUG",true);
 $version_phpcompta=3D4014;
-*/
=20
=20
-define ("DBVERSION",94);
+define ("DBVERSION",95);
 define ("DBVERSIONREPO",13);
 define ('NOTFOUND','--not found--');
=20



From MAILER-DAEMON Sat Jun 04 06:34:48 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QSoBs-0007Q9-2l
	for mharc-phpcompta-dev@gnu.org; Sat, 04 Jun 2011 06:34:48 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat,  4 Jun 2011 12:39:21 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.11785.1307183687.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4152 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 04 Jun 2011 10:34:47 -0000

Author: danydb
Date: 2011-06-04 12:39:20 +0200 (Sat, 04 Jun 2011)
New Revision: 4152

Modified:
   phpcompta/branches/rel560/include/ac_common.php
Log:
 0000281: Ajax : d?\195?\169connect?\195?\169

Modified: phpcompta/branches/rel560/include/ac_common.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/ac_common.php	2011-06-01 21:46:25 U=
TC (rev 4151)
+++ phpcompta/branches/rel560/include/ac_common.php	2011-06-04 10:39:20 U=
TC (rev 4152)
@@ -695,8 +695,17 @@
  */
 if ( ! isset($_SESSION['g_user']))
   {
-    $html=3Dalert("Utilisateur d=C3=A9connect=C3=A9",true);
+    $script=3D'var a=3D$("'.$div.'");a.style.height=3D"70%";a.style.widt=
h=3D"70%";';
+    $script.=3D'a.style.top=3DposY-20+offsetY;a.style.left=3DposX+offset=
X;';
+    $script=3Dcreate_script($script);
+    $html=3D$script;
+    $html.=3DHtmlInput::anchor_close($div);
+    $html.=3D'<div>';
+    $html.=3Dh2('Donn=C3=A9es non disponibles','class=3D"info" style=3D"=
width:auto"');
+    $html.=3Dh2('Veuillez vous reconnecter','');
+    $html.=3Dalert("D=C3=A9connect=C3=A9",true);
     $html=3Descape_xml($html);
+
     header('Content-type: text/xml; charset=3DUTF-8');
 echo <<<EOF
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>



From MAILER-DAEMON Sat Jun 04 06:35:59 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QSoD1-0007Vz-5J
	for mharc-phpcompta-dev@gnu.org; Sat, 04 Jun 2011 06:35:59 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat,  4 Jun 2011 12:40:37 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.11786.1307183758.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4153 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 04 Jun 2011 10:35:57 -0000

Author: danydb
Date: 2011-06-04 12:40:37 +0200 (Sat, 04 Jun 2011)
New Revision: 4153

Modified:
   phpcompta/branches/rel560/include/class_acc_operation.php
   phpcompta/branches/rel560/include/class_database.php
Log:
Better error message=20

Modified: phpcompta/branches/rel560/include/class_acc_operation.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_acc_operation.php	2011-06-04 =
10:39:20 UTC (rev 4152)
+++ phpcompta/branches/rel560/include/class_acc_operation.php	2011-06-04 =
10:40:37 UTC (rev 4153)
@@ -87,7 +87,7 @@
=20
     function insert_jrnx()
     {
-        if ( $this->poste =3D=3D "") return false;
+      if ( $this->poste =3D=3D "") { return false; throw new  Exception =
(__FILE__.':'.__LINE__.' Poste comptable vide');}
         /* for negative amount the operation is reversed */
         if ( $this->amount < 0 )
         {
@@ -109,7 +109,7 @@
                                      $this->periode, //$8
                                      $this->qcode, // $9
                                      $this->desc)); //$10
-        if ( $Res=3D=3Dfalse) return $Res;
+        if ( $Res=3D=3D=3Dfalse) return $Res;
         $this->jrnx_id=3D$this->db->get_current_seq('s_jrn_op');
         return $this->jrnx_id;
=20

Modified: phpcompta/branches/rel560/include/class_database.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_database.php	2011-06-04 10:39=
:20 UTC (rev 4152)
+++ phpcompta/branches/rel560/include/class_database.php	2011-06-04 10:40=
:37 UTC (rev 4153)
@@ -125,13 +125,16 @@
 	 =20
             $this->sql=3D$p_string;
             $this->array=3D$p_array;
+
             if ( $p_array=3D=3Dnull )
             {
-	      $this->ret=3D@pg_query($this->db,$p_string);
+	      $PG_QUERY=3D(DEBUG=3D=3Dfalse)?'@pg_query':'pg_query';
+	      $this->ret=3D$PG_QUERY($this->db,$p_string);
             }
             else
             {
-                $this->ret=3D@pg_query_params($this->db,$p_string,$p_arr=
ay);
+	      $PG_QUERY=3D(DEBUG=3D=3Dfalse)?'@pg_query_params':'pg_query_param=
s';
+                $this->ret=3D$PG_QUERY($this->db,$p_string,$p_array);
             }
             if ( ! $this->ret )
             {



From MAILER-DAEMON Sat Jun 04 06:36:59 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QSoDy-0007Wj-St
	for mharc-phpcompta-dev@gnu.org; Sat, 04 Jun 2011 06:36:58 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat,  4 Jun 2011 12:41:31 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.11787.1307183817.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4154 - phpcompta/branches/rel560/sql
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 04 Jun 2011 10:36:56 -0000

Author: danydb
Date: 2011-06-04 12:41:30 +0200 (Sat, 04 Jun 2011)
New Revision: 4154

Added:
   phpcompta/branches/rel560/sql/comptaproc.sql
Log:
Bug for MacOSX

Added: phpcompta/branches/rel560/sql/comptaproc.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/sql/comptaproc.sql	                        =
(rev 0)
+++ phpcompta/branches/rel560/sql/comptaproc.sql	2011-06-04 10:41:30 UTC =
(rev 4154)
@@ -0,0 +1,1972 @@
+--
+-- PostgreSQL database dump
+--
+
+SET statement_timeout =3D 0;
+SET client_encoding =3D 'UTF8';
+SET standard_conforming_strings =3D off;
+SET check_function_bodies =3D false;
+SET client_min_messages =3D warning;
+SET escape_string_warning =3D off;
+
+--
+-- Name: comptaproc; Type: SCHEMA; Schema: -; Owner: -
+--
+
+CREATE SCHEMA comptaproc;
+
+
+SET search_path =3D comptaproc, pg_catalog;
+
+--
+-- Name: account_add(public.account_type, character varying); Type: FUNC=
TION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION account_add(p_id public.account_type, p_name character v=
arying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	nCount integer;
+begin
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_id;
+	if nCount =3D 0 then
+		nParent=3Daccount_parent(p_id);
+		insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent)
+			values (p_id, p_name,nParent);
+	end if;
+return;
+end ;
+$$;
+
+
+--
+-- Name: account_auto(integer); Type: FUNCTION; Schema: comptaproc; Owne=
r: -
+--
+
+CREATE FUNCTION account_auto(p_fd_id integer) RETURNS boolean
+    LANGUAGE plpgsql
+    AS $$
+declare
+	l_auto bool;
+begin
+
+	select fd_create_account into l_auto from fiche_def where fd_id=3Dp_fd_=
id;
+	if l_auto is null then
+		l_auto:=3Dfalse;
+	end if;
+	return l_auto;
+end;
+$$;
+
+
+--
+-- Name: account_compute(integer); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION account_compute(p_f_id integer) RETURNS public.account_t=
ype
+    LANGUAGE plpgsql
+    AS $$
+declare
+	class_base fiche_def.fd_class_base%type;
+	maxcode numeric;
+	sResult account_type;
+begin
+	select fd_class_base into class_base
+	from
+		fiche_def join fiche using (fd_id)
+	where
+		f_id=3Dp_f_id;
+	raise notice 'account_compute class base %',class_base;
+	select count (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent =
=3D class_base;
+	if maxcode =3D 0	then
+		maxcode:=3Dclass_base::numeric;
+	else
+		select max (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent =3D=
 class_base;
+		maxcode:=3Dmaxcode::numeric;
+	end if;
+	if maxcode::text =3D class_base then
+		maxcode:=3Dclass_base::numeric*1000;
+	end if;
+	maxcode:=3Dmaxcode+1;
+	raise notice 'account_compute Max code %',maxcode;
+	sResult:=3Dmaxcode::account_type;
+	return sResult;
+end;
+$$;
+
+
+--
+-- Name: account_insert(integer, text); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION account_insert(p_f_id integer, p_account text) RETURNS i=
nteger
+    LANGUAGE plpgsql
+    AS $_$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	nNew tmp_pcmn.pcm_val%type;
+	bAuto bool;
+	nFd_id integer;
+	sClass_Base fiche_def.fd_class_base%TYPE;
+	nCount integer;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+	-- if there is coma in p_account, treat normally
+		if position (',' in p_account) =3D 0 then
+			raise info 'p_account is not empty';
+				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
+				raise notice 'found in tmp_pcm %',nCount;
+				if nCount !=3D0  then
+					raise info 'this account exists in tmp_pcmn ';
+					perform attribut_insert(p_f_id,5,p_account);
+				   else
+				       -- account doesn't exist, create it
+					select ad_value into sName from
+						fiche_detail
+					where
+					ad_id=3D1 and f_id=3Dp_f_id;
+
+					nParent:=3Daccount_parent(p_account::account_type);
+					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
+					perform attribut_insert(p_f_id,5,p_account);
+
+				end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		perform attribut_insert(p_f_id,5,p_account);
+		end if;
+	else
+	raise info 'p_account is  empty';
+		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
+		bAuto:=3D account_auto(nFd_id);
+
+		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
+raise info 'sClass_Base : %',sClass_base;
+		if bAuto =3D true and sClass_base similar to '^[[:digit:]]*$'  then
+			raise info 'account generated automatically';
+			nNew:=3Daccount_compute(p_f_id);
+			raise info 'nNew %', nNew;
+			select ad_value into sName from
+				fiche_detail
+			where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(nNew);
+			perform account_add  (nNew,sName);
+			perform attribut_insert(p_f_id,5,nNew);
+
+		else
+		-- if there is an account_base then it is the default
+		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
+			if nNew is null or length(trim(nNew)) =3D 0 then
+				raise notice 'count is null';
+				 perform attribut_insert(p_f_id,5,null);
+			else
+				 perform attribut_insert(p_f_id,5,nNew);
+			end if;
+		end if;
+	end if;
+
+return 0;
+end;
+$_$;
+
+
+--
+-- Name: account_parent(public.account_type); Type: FUNCTION; Schema: co=
mptaproc; Owner: -
+--
+
+CREATE FUNCTION account_parent(p_account public.account_type) RETURNS pu=
blic.account_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	sSubParent tmp_pcmn.pcm_val_parent%type;
+	sResult tmp_pcmn.pcm_val_parent%type;
+	nCount integer;
+begin
+	if p_account is NULL then
+		return NULL;
+	end if;
+	sSubParent:=3Dp_account;
+	while true loop
+		select count(*) into nCount
+		from tmp_pcmn
+		where
+		pcm_val =3D sSubParent;
+		if nCount !=3D 0 then
+			sResult:=3D sSubParent;
+			exit;
+		end if;
+		sSubParent:=3D substr(sSubParent,1,length(sSubParent)-1);
+		if length(sSubParent) <=3D 0 then
+			raise exception 'Impossible de trouver le compte parent pour %',p_acc=
ount;
+		end if;
+		raise notice 'sSubParent % % ',sSubParent,length(sSubParent);
+	end loop;
+	raise notice 'account_parent : Parent is %',sSubParent;
+	return sSubParent;
+end;
+$$;
+
+
+--
+-- Name: account_update(integer, public.account_type); Type: FUNCTION; S=
chema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION account_update(p_f_id integer, p_account public.account_=
type) RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+declare
+	nMax fiche.f_id%type;
+	nCount integer;
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	first text;
+	second text;
+begin
+
+	if length(trim(p_account)) !=3D 0 then
+		if position (',' in p_account) =3D 0 then
+			select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_account;
+			if nCount =3D 0 then
+			select ad_value into sName from
+				fiche_detail
+				where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(p_account);
+			insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_accoun=
t,sName,nParent);
+			end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		end if;
+	end if;
+=09
+	update fiche_detail set ad_value=3Dp_account where f_id=3Dp_f_id and ad=
_id=3D5 ;
+
+return 0;
+end;
+$$;
+
+
+--
+-- Name: action_gestion_ins_upd(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION action_gestion_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+begin
+NEW.ag_title :=3D substr(trim(NEW.ag_title),1,70);
+NEW.ag_hour :=3D substr(trim(NEW.ag_hour),1,5);
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: action_get_tree(bigint); Type: FUNCTION; Schema: comptaproc; Ow=
ner: -
+--
+
+CREATE FUNCTION action_get_tree(p_id bigint) RETURNS SETOF bigint
+    LANGUAGE plpgsql
+    AS $$
+
+declare
+   e bigint;
+   i bigint;
+begin
+   for e in select ag_id from action_gestion where ag_ref_ag_id=3Dp_id
+   loop
+        for i in select action_get_tree from  comptaproc.action_get_tree=
(e)
+        loop
+                raise notice ' =3D=3D i %', i;
+                return next i;
+        end loop;
+    raise notice ' =3D e %', e;
+    return next e;
+   end loop;
+   return;
+
+end;
+$$;
+
+
+--
+-- Name: attribut_insert(integer, integer, character varying); Type: FUN=
CTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION attribut_insert(p_f_id integer, p_ad_id integer, p_value=
 character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+begin
+	insert into fiche_detail (f_id,ad_id, ad_value) values (p_f_id,p_ad_id,=
p_value);
+=09
+return;
+end;
+$$;
+
+
+--
+-- Name: attribute_correct_order(); Type: FUNCTION; Schema: comptaproc; =
Owner: -
+--
+
+CREATE FUNCTION attribute_correct_order() RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+    crs_correct cursor for select A.jnt_id,A.jnt_order from jnt_fic_attr=
 as A join jnt_fic_attr as B using (fd_id) where A.jnt_order=3DB.jnt_orde=
r and A.jnt_id > B.jnt_id;
+    rec record;
+begin
+	open crs_correct;
+	loop
+	fetch crs_correct into rec;
+	if NOT FOUND then
+		close crs_correct;
+		return;
+	end if;
+	update jnt_fic_attr set jnt_order=3Djnt_order + 1 where jnt_id =3D rec.=
jnt_id;
+	end loop;
+	close crs_correct;
+	perform attribute_correct_order ();
+end;
+$$;
+
+
+--
+-- Name: card_after_delete(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION card_after_delete() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+
+begin
+
+	delete from action_gestion where f_id_dest =3D OLD.f_id;
+	return OLD;
+
+end;
+$$;
+
+
+--
+-- Name: card_class_base(integer); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION card_class_base(p_f_id integer) RETURNS text
+    LANGUAGE plpgsql
+    AS $$
+declare
+	n_poste fiche_def.fd_class_base%type;
+begin
+
+	select fd_class_base into n_poste from fiche_def join fiche using
+(fd_id)
+	where f_id=3Dp_f_id;
+	if not FOUND then
+		raise exception 'Invalid fiche card_class_base(%)',p_f_id;
+	end if;
+return n_poste;
+end;
+$$;
+
+
+--
+-- Name: check_balance(integer); Type: FUNCTION; Schema: comptaproc; Own=
er: -
+--
+
+CREATE FUNCTION check_balance(p_grpt integer) RETURNS numeric
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	amount_jrnx_debit numeric;
+	amount_jrnx_credit numeric;
+	amount_jrn numeric;
+begin
+	select sum (j_montant) into amount_jrnx_credit=20
+	from jrnx=20
+		where=20
+	j_grpt=3Dp_grpt
+	and j_debit=3Dfalse;
+
+	select sum (j_montant) into amount_jrnx_debit=20
+	from jrnx=20
+		where=20
+	j_grpt=3Dp_grpt
+	and j_debit=3Dtrue;
+
+	select jr_montant into amount_jrn=20
+	from jrn
+	where
+	jr_grpt_id=3Dp_grpt;
+
+	if ( amount_jrnx_debit !=3D amount_jrnx_credit )=20
+		then
+		return abs(amount_jrnx_debit-amount_jrnx_credit);
+		end if;
+	if ( amount_jrn !=3D amount_jrnx_credit)
+		then
+		return -1*abs(amount_jrn - amount_jrnx_credit);
+		end if;
+	return 0;
+end;
+$$;
+
+
+--
+-- Name: correct_sequence(text, text, text); Type: FUNCTION; Schema: com=
ptaproc; Owner: -
+--
+
+CREATE FUNCTION correct_sequence(p_sequence text, p_col text, p_table te=
xt) RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+declare
+last_sequence int8;
+max_sequence int8;
+n integer;
+begin
+	select count(*) into n from pg_class where relkind=3D'S' and relname=3D=
lower(p_sequence);
+	if n =3D 0 then
+		raise exception  ' Unknow sequence  % ',p_sequence;
+	end if;
+	select count(*) into n from pg_class where relkind=3D'r' and relname=3D=
lower(p_table);
+	if n =3D 0 then
+		raise exception ' Unknow table  % ',p_table;
+	end if;
+
+	execute 'select last_value   from '||p_sequence into last_sequence;
+	raise notice 'Last value of the sequence is %', last_sequence;
+
+	execute 'select max('||p_col||')  from '||p_table into max_sequence;
+	if  max_sequence is null then
+		max_sequence :=3D 0;
+	end if;
+	raise notice 'Max value of the sequence is %', max_sequence;
+	max_sequence:=3D max_sequence +1;=09
+	execute 'alter sequence '||p_sequence||' restart with '||max_sequence;
+return 0;
+
+end;
+$$;
+
+
+--
+-- Name: FUNCTION correct_sequence(p_sequence text, p_col text, p_table =
text); Type: COMMENT; Schema: comptaproc; Owner: -
+--
+
+COMMENT ON FUNCTION correct_sequence(p_sequence text, p_col text, p_tabl=
e text) IS ' Often the primary key is a sequence number and sometimes the=
 value of the sequence is not synchronized with the primary key ( p_seque=
nce : sequence name, p_col : col of the pk,p_table : concerned table';
+
+
+--
+-- Name: create_missing_sequence(); Type: FUNCTION; Schema: comptaproc; =
Owner: -
+--
+
+CREATE FUNCTION create_missing_sequence() RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+declare
+p_sequence text;
+nSeq integer;
+c1 cursor for select jrn_def_id from jrn_def;
+begin
+	open c1;
+	loop
+	   fetch c1 into nSeq;
+	   if not FOUND THEN
+	   	close c1;
+	   	return 0;
+	   end if;
+	   p_sequence:=3D's_jrn_pj'||nSeq::text;
+	execute 'create sequence '||p_sequence;
+	end loop;
+close c1;
+return 0;
+
+end;
+$$;
+
+
+--
+-- Name: drop_index(character varying); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION drop_index(p_constraint character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	nCount integer;
+begin
+	select count(*) into nCount from pg_indexes where indexname=3Dp_constra=
int;
+	if nCount =3D 1 then
+	execute 'drop index '||p_constraint ;
+	end if;
+end;
+$$;
+
+
+--
+-- Name: drop_it(character varying); Type: FUNCTION; Schema: comptaproc;=
 Owner: -
+--
+
+CREATE FUNCTION drop_it(p_constraint character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	nCount integer;
+begin
+	select count(*) into nCount from pg_constraint where conname=3Dp_constr=
aint;
+	if nCount =3D 1 then
+	execute 'alter table parm_periode drop constraint '||p_constraint ;
+	end if;
+end;
+$$;
+
+
+--
+-- Name: extension_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION extension_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+ sCode text;
+ sFile text;
+begin
+sCode:=3Dtrim(upper(NEW.ex_code));
+sCode:=3Dreplace(sCode,' ','_');
+sCode:=3Dsubstr(sCode,1,15);
+sCode=3Dupper(sCode);
+NEW.ex_code:=3DsCode;
+sFile:=3DNEW.ex_file;
+sFile:=3Dreplace(sFile,';','_');
+sFile:=3Dreplace(sFile,'<','_');
+sFile:=3Dreplace(sFile,'>','_');
+sFile:=3Dreplace(sFile,'..','');
+sFile:=3Dreplace(sFile,'&','');
+sFile:=3Dreplace(sFile,'|','');
+
+
+
+return NEW;
+
+end;
+
+$$;
+
+
+--
+-- Name: fiche_account_parent(integer); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION fiche_account_parent(p_f_id integer) RETURNS public.acco=
unt_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+ret tmp_pcmn.pcm_val%TYPE;
+begin
+	select fd_class_base into ret from fiche_def join fiche using (fd_id) w=
here f_id=3Dp_f_id;
+	if not FOUND then
+		raise exception '% N''existe pas',p_f_id;
+	end if;
+	return ret;
+end;
+$$;
+
+
+--
+-- Name: fiche_attribut_synchro(integer); Type: FUNCTION; Schema: compta=
proc; Owner: -
+--
+
+CREATE FUNCTION fiche_attribut_synchro(p_fd_id integer) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	-- this sql gives the f_id and the missing attribute (ad_id)
+	list_missing cursor for select f_id,fd_id,ad_id,jnt_order from jnt_fic_=
attr join fiche as A using (fd_id) where fd_id=3Dp_fd_id and ad_id not in=
 (select ad_id from fiche join fiche_detail using (f_id) where fd_id=3Djn=
t_fic_attr.fd_id and A.f_id=3Df_id);
+	rec record;
+begin
+	open list_missing;
+	loop
+=09
+	fetch list_missing into rec;
+	IF NOT FOUND then
+		exit;
+	end if;
+=09
+	-- now we insert into attr_value
+	insert into fiche_detail (f_id,ad_id,ad_value) values (rec.f_id,rec.ad_=
id,null);
+	end loop;
+	close list_missing;
+end;=20
+$$;
+
+
+--
+-- Name: fiche_def_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION fiche_def_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+begin
+
+if position (',' in NEW.fd_class_base) !=3D 0 then
+   NEW.fd_create_account=3D'f';
+
+end if;
+return NEW;
+end;$$;
+
+
+--
+-- Name: fill_quant_fin(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION fill_quant_fin() RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+   sBank text;
+   sCassa text;
+   sCustomer text;
+   sSupplier text;
+   rec record;
+   recBank record;
+   recSupp_Cust record;
+   nCount integer;
+   nAmount numeric;
+   nBank integer;
+   nOther integer;
+   nSupp_Cust integer;
+begin
+	select p_value into sBank from parm_code where p_code=3D'BANQUE';
+	select p_value into sCassa from parm_code where p_code=3D'CAISSE';
+	select p_value into sSupplier from parm_code where p_code=3D'SUPPLIER';
+	select p_value into sCustomer from parm_code where p_code=3D'CUSTOMER';
+=09
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN')
+		and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nBank :=3D 0; nOther:=3D0;
+		for recBank in select  j_id, j_montant,j_debit,j_qcode,j_poste from jr=
nx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recBank.j_poste like sBank||'%' then
+			-- retrieve f_id for bank
+			select f_id into nBank from vw_poste_qcode where j_qcode=3DrecBank.j_=
qcode;
+			if recBank.j_debit =3D false then
+				nAmount=3DrecBank.j_montant*(-1);
+			else=20
+				nAmount=3DrecBank.j_montant;
+			end if;
+		else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecBank.j=
_qcode;
+		end if;
+		end loop;
+		if nBank !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nBank,nOther,nAmount);
+		end if;
+	end loop;
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN') and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nBank :=3D 0; nOther:=3D0;
+		for recBank in select  j_id, j_montant,j_debit,j_qcode,j_poste from jr=
nx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recBank.j_poste like sCassa||'%' then
+			-- retrieve f_id for bank
+			select f_id into nBank from vw_poste_qcode where j_qcode=3DrecBank.j_=
qcode;
+			if recBank.j_debit =3D false then
+				nAmount=3DrecBank.j_montant*(-1);
+			else=20
+				nAmount=3DrecBank.j_montant;
+			end if;
+		else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecBank.j=
_qcode;
+		end if;
+		end loop;
+		if nBank !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nBank,nOther,nAmount);
+		end if;
+	end loop;
+
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN') and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nSupp_Cust :=3D 0; nOther:=3D0;
+		for recSupp_Cust in select  j_id, j_montant,j_debit,j_qcode,j_poste fr=
om jrnx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recSupp_Cust.j_poste like sSupplier||'%'  then
+			-- retrieve f_id for bank
+			select f_id into nSupp_Cust from vw_poste_qcode where j_qcode=3DrecSu=
pp_Cust.j_qcode;
+			if recSupp_Cust.j_debit =3D true then
+				nAmount=3DrecSupp_Cust.j_montant*(-1);
+			else=20
+				nAmount=3DrecSupp_Cust.j_montant;
+			end if;
+		else if  recSupp_Cust.j_poste like sCustomer||'%' then
+			select f_id into nSupp_Cust from vw_poste_qcode where j_qcode=3DrecSu=
pp_Cust.j_qcode;
+			if recSupp_Cust.j_debit =3D false then
+				nAmount=3DrecSupp_Cust.j_montant*(-1);
+			else=20
+				nAmount=3DrecSupp_Cust.j_montant;
+			end if;
+			else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecSupp_C=
ust.j_qcode;
+		=09
+			end if;
+		end if;
+		end loop;
+		if nSupp_Cust !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nOther,nSupp_Cust,nAmount);
+		end if;
+	end loop;
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN') and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nSupp_Cust :=3D 0; nOther:=3D0;
+		for recSupp_Cust in select  j_id, j_montant,j_debit,j_qcode,j_poste fr=
om jrnx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recSupp_Cust.j_poste like '441%'  then
+			-- retrieve f_id for bank
+			select f_id into nSupp_Cust from vw_poste_qcode where j_qcode=3DrecSu=
pp_Cust.j_qcode;
+			if recSupp_Cust.j_debit =3D false then
+				nAmount=3DrecSupp_Cust.j_montant*(-1);
+			else=20
+				nAmount=3DrecSupp_Cust.j_montant;
+			end if;
+			else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecSupp_C=
ust.j_qcode;
+		=09
+		=09
+		end if;
+		end loop;
+		if nSupp_Cust !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nOther,nSupp_Cust,nAmount);
+		end if;
+	end loop;
+	return;
+end;
+$$;
+
+
+--
+-- Name: find_pcm_type(public.account_type); Type: FUNCTION; Schema: com=
ptaproc; Owner: -
+--
+
+CREATE FUNCTION find_pcm_type(pp_value public.account_type) RETURNS text
+    LANGUAGE plpgsql
+    AS $$
+declare
+	str_type parm_poste.p_type%TYPE;
+	str_value parm_poste.p_type%TYPE;
+	nLength integer;
+begin
+	str_value:=3Dpp_value;
+	nLength:=3Dlength(str_value::text);
+	while nLength > 0 loop
+		select p_type into str_type from parm_poste where p_value=3Dstr_value;
+		if FOUND then
+			return str_type;
+		end if;
+		nLength:=3DnLength-1;
+		str_value:=3Dsubstring(str_value::text from 1 for nLength)::account_ty=
pe;
+	end loop;
+return 'CON';
+end;
+$$;
+
+
+--
+-- Name: find_periode(text); Type: FUNCTION; Schema: comptaproc; Owner: =
-
+--
+
+CREATE FUNCTION find_periode(p_date text) RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+
+declare n_p_id int4;
+begin
+
+select p_id into n_p_id
+	from parm_periode
+	where
+		p_start <=3D to_date(p_date,'DD.MM.YYYY')
+		and
+		p_end >=3D to_date(p_date,'DD.MM.YYYY');
+
+if NOT FOUND then
+	return -1;
+end if;
+
+return n_p_id;
+
+end;$$;
+
+
+--
+-- Name: get_letter_jnt(bigint); Type: FUNCTION; Schema: comptaproc; Own=
er: -
+--
+
+CREATE FUNCTION get_letter_jnt(a bigint) RETURNS bigint
+    LANGUAGE plpgsql
+    AS $$
+declare
+ nResult bigint;
+begin
+   select jl_id into nResult from jnt_letter join letter_deb using (jl_i=
d) where j_id =3D a;
+   if NOT FOUND then
+	select jl_id into nResult from jnt_letter join letter_cred using (jl_id=
) where j_id =3D a;
+	if NOT found then
+		return null;
+	end if;
+    end if;
+return nResult;
+end;
+$$;
+
+
+--
+-- Name: get_pcm_tree(public.account_type); Type: FUNCTION; Schema: comp=
taproc; Owner: -
+--
+
+CREATE FUNCTION get_pcm_tree(source public.account_type) RETURNS SETOF p=
ublic.account_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	i account_type;
+	e account_type;
+begin
+	for i in select pcm_val from tmp_pcmn where pcm_val_parent=3Dsource
+	loop
+		return next i;
+		for e in select get_pcm_tree from get_pcm_tree(i)
+		loop
+			return next e;
+		end loop;
+
+	end loop;
+	return;
+end;
+$$;
+
+
+--
+-- Name: group_analytic_ins_upd(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION group_analytic_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+name text;
+begin
+name:=3Dupper(NEW.ga_id);
+name:=3Dtrim(name);
+name:=3Dreplace(name,' ','');
+NEW.ga_id:=3Dname;
+return NEW;
+end;$$;
+
+
+--
+-- Name: group_analytique_del(); Type: FUNCTION; Schema: comptaproc; Own=
er: -
+--
+
+CREATE FUNCTION group_analytique_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+begin
+update poste_analytique set ga_id=3Dnull
+where ga_id=3DOLD.ga_id;
+return OLD;
+end;$$;
+
+
+--
+-- Name: html_quote(text); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION html_quote(p_string text) RETURNS text
+    LANGUAGE plpgsql
+    AS $$
+declare
+	r text;
+begin
+	r:=3Dp_string;
+	r:=3Dreplace(r,'<','&lt;');
+	r:=3Dreplace(r,'>','&gt;');
+	r:=3Dreplace(r,'''','&quot;');
+	return r;
+end;$$;
+
+
+--
+-- Name: FUNCTION html_quote(p_string text); Type: COMMENT; Schema: comp=
taproc; Owner: -
+--
+
+COMMENT ON FUNCTION html_quote(p_string text) IS 'remove harmfull HTML c=
har';
+
+
+--
+-- Name: info_def_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner: =
-
+--
+
+CREATE FUNCTION info_def_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	row_info_def info_def%ROWTYPE;
+	str_type text;
+begin
+row_info_def:=3DNEW;
+str_type:=3Dupper(trim(NEW.id_type));
+str_type:=3Dreplace(str_type,' ','');
+str_type:=3Dreplace(str_type,',','');
+str_type:=3Dreplace(str_type,';','');
+if  length(str_type) =3D0 then
+	raise exception 'id_type cannot be null';
+end if;
+row_info_def.id_type:=3Dstr_type;
+return row_info_def;
+end;
+$$;
+
+
+--
+-- Name: insert_jrnx(character varying, numeric, public.account_type, in=
teger, integer, boolean, text, integer, text, text); Type: FUNCTION; Sche=
ma: comptaproc; Owner: -
+--
+
+CREATE FUNCTION insert_jrnx(p_date character varying, p_montant numeric,=
 p_poste public.account_type, p_grpt integer, p_jrn_def integer, p_debit =
boolean, p_tech_user text, p_tech_per integer, p_qcode text, p_comment te=
xt) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+begin
+	insert into jrnx
+	(
+		j_date,
+		j_montant,
+		j_poste,
+		j_grpt,
+		j_jrn_def,
+		j_debit,
+		j_text,
+		j_tech_user,
+		j_tech_per,
+		j_qcode
+	) values
+	(
+		to_date(p_date,'DD.MM.YYYY'),
+		p_montant,
+		p_poste,
+		p_grpt,
+		p_jrn_def,
+		p_debit,
+		p_comment,
+		p_tech_user,
+		p_tech_per,
+		p_qcode
+	);
+
+return;
+end;
+$$;
+
+
+--
+-- Name: insert_quant_purchase(text, numeric, character varying, numeric=
, numeric, numeric, integer, numeric, numeric, numeric, numeric, characte=
r varying); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION insert_quant_purchase(p_internal text, p_j_id numeric, p=
_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric=
, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_rec=
up numeric, p_dep_priv numeric, p_client character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	fid_client integer;
+	fid_good   integer;
+begin
+	select f_id into fid_client from
+		fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_client));
+	select f_id into fid_good from
+		 fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_fiche));
+	insert into quant_purchase
+		(qp_internal,
+		j_id,
+		qp_fiche,
+		qp_quantite,
+		qp_price,
+		qp_vat,
+		qp_vat_code,
+		qp_nd_amount,
+		qp_nd_tva,
+		qp_nd_tva_recup,
+		qp_supplier,
+		qp_dep_priv)
+	values
+		(p_internal,
+		p_j_id,
+		fid_good,
+		p_quant,
+		p_price,
+		p_vat,
+		p_vat_code,
+		p_nd_amount,
+		p_nd_tva,
+		p_nd_tva_recup,
+		fid_client,
+		p_dep_priv);
+	return;
+end;
+ $$;
+
+
+--
+-- Name: insert_quant_sold(text, numeric, character varying, numeric, nu=
meric, numeric, integer, character varying); Type: FUNCTION; Schema: comp=
taproc; Owner: -
+--
+
+CREATE FUNCTION insert_quant_sold(p_internal text, p_jid numeric, p_fich=
e character varying, p_quant numeric, p_price numeric, p_vat numeric, p_v=
at_code integer, p_client character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	fid_client integer;
+	fid_good   integer;
+begin
+
+	select f_id into fid_client from
+		fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_client));
+	select f_id into fid_good from
+		fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_fiche));
+	insert into quant_sold
+		(qs_internal,j_id,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_=
client,qs_valid)
+	values
+		(p_internal,p_jid,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client=
,'Y');
+	return;
+end;
+ $$;
+
+
+--
+-- Name: insert_quick_code(integer, text); Type: FUNCTION; Schema: compt=
aproc; Owner: -
+--
+
+CREATE FUNCTION insert_quick_code(nf_id integer, tav_text text) RETURNS =
integer
+    LANGUAGE plpgsql
+    AS $$
+	declare
+	ns integer;
+	nExist integer;
+	tText text;
+	begin
+	tText :=3D upper(trim(tav_text));
+	tText :=3D replace(tText,' ','');
+=09
+	loop
+		-- take the next sequence
+		select nextval('s_jnt_fic_att_value') into ns;
+		if length (tText) =3D 0 or tText is null then
+			tText :=3D 'FID'||ns;
+		end if;
+		-- av_text already used ?
+		select count(*) into nExist=20
+			from fiche_detail
+		where=20
+			ad_id=3D23 and  ad_value=3Dupper(tText);
+
+		if nExist =3D 0 then
+			exit;
+		end if;
+		tText:=3D'FID'||ns;
+	end loop;
+
+
+	insert into fiche_detail(jft_id,f_id,ad_id,ad_value) values (ns,nf_id,2=
3,upper(tText));
+	return ns;
+	end;
+$$;
+
+
+--
+-- Name: is_closed(integer, integer); Type: FUNCTION; Schema: comptaproc=
; Owner: -
+--
+
+CREATE FUNCTION is_closed(p_periode integer, p_jrn_def_id integer) RETUR=
NS boolean
+    LANGUAGE plpgsql
+    AS $$
+declare
+bClosed bool;
+str_status text;
+begin
+select p_closed into bClosed from parm_periode
+	where p_id=3Dp_periode;
+
+if bClosed =3D true then
+	return bClosed;
+end if;
+
+select status into str_status from jrn_periode
+       where p_id =3Dp_periode and jrn_def_id=3Dp_jrn_def_id;
+
+if str_status <> 'OP' then
+   return bClosed;
+end if;
+return false;
+end;
+$$;
+
+
+--
+-- Name: jnt_fic_attr_ins(); Type: FUNCTION; Schema: comptaproc; Owner: =
-
+--
+
+CREATE FUNCTION jnt_fic_attr_ins() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+   r_record jnt_fic_attr%ROWTYPE;
+   i_max integer;
+begin
+r_record=3DNEW;
+perform comptaproc.fiche_attribut_synchro(r_record.fd_id);
+select coalesce(max(jnt_order),0) into i_max from jnt_fic_attr where fd_=
id=3Dr_record.fd_id;
+i_max :=3D i_max + 10;
+NEW.jnt_order=3Di_max;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: jrn_add_note(bigint, text); Type: FUNCTION; Schema: comptaproc;=
 Owner: -
+--
+
+CREATE FUNCTION jrn_add_note(p_jrid bigint, p_note text) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	tmp bigint;
+begin
+	if length(trim(p_note)) =3D 0 then
+	   delete from jrn_note where jr_id=3D p_jrid;
+	   return;
+	end if;
+=09
+	select n_id into tmp from jrn_note where jr_id =3D p_jrid;
+=09
+	if FOUND then
+	   update jrn_note set n_text=3Dtrim(p_note) where jr_id =3D p_jrid;
+	else=20
+	   insert into jrn_note (jr_id,n_text) values ( p_jrid, p_note);
+
+	end if;
+=09
+	return;
+end;
+$$;
+
+
+--
+-- Name: jrn_check_periode(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION jrn_check_periode() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+bClosed bool;
+str_status text;
+ljr_tech_per jrn.jr_tech_per%TYPE;
+ljr_def_id jrn.jr_def_id%TYPE;
+lreturn jrn%ROWTYPE;
+begin
+if TG_OP=3D'UPDATE' then
+	ljr_tech_per :=3DOLD.jr_tech_per ;
+	NEW.jr_tech_per :=3D comptaproc.find_periode(to_char(NEW.jr_date,'DD.MM=
.YYYY'));
+	ljr_def_id   :=3DOLD.jr_def_id;
+	lreturn      :=3DNEW;
+	if NEW.jr_date =3D OLD.jr_date then
+		return NEW;
+	end if;
+	if comptaproc.is_closed(NEW.jr_tech_per,NEW.jr_def_id) =3D true then
+	      	raise exception 'Periode fermee';
+	end if;
+end if;
+
+if TG_OP=3D'INSERT' then
+	NEW.jr_tech_per :=3D comptaproc.find_periode(to_char(NEW.jr_date,'DD.MM=
.YYYY'));
+	ljr_tech_per :=3DNEW.jr_tech_per ;
+	ljr_def_id   :=3DNEW.jr_def_id;
+	lreturn      :=3DNEW;
+end if;
+
+if TG_OP=3D'DELETE' then
+	ljr_tech_per :=3DOLD.jr_tech_per;
+	ljr_def_id   :=3DOLD.jr_def_id;
+	lreturn      :=3DOLD;
+end if;
+
+if comptaproc.is_closed (ljr_def_id,ljr_def_id) =3D true then
+   	raise exception 'Periode fermee';
+end if;
+
+return lreturn;
+end;$$;
+
+
+--
+-- Name: jrn_def_add(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrn_def_add() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$begin
+execute 'insert into jrn_periode(p_id,jrn_def_id,status) select p_id,'||=
NEW.jrn_def_id||',
+	case when p_central=3Dtrue then ''CE''
+	      when p_closed=3Dtrue then ''CL''
+	else ''OP''
+	end
+from
+parm_periode ';
+return NEW;
+end;$$;
+
+
+--
+-- Name: jrn_def_delete(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrn_def_delete() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+nb numeric;
+begin
+select count(*) into nb from jrn where jr_def_id=3DOLD.jrn_def_id;
+
+if nb <> 0 then
+	raise exception 'EFFACEMENT INTERDIT: JOURNAL UTILISE';
+end if;
+return OLD;
+end;$$;
+
+
+--
+-- Name: jrn_del(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrn_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+row jrn%ROWTYPE;
+begin
+row:=3DOLD;
+insert into del_jrn ( jr_id,
+       jr_def_id,
+       jr_montant,
+       jr_comment,
+       jr_date,
+       jr_grpt_id,
+       jr_internal,
+       jr_tech_date,
+       jr_tech_per,
+       jrn_ech,
+       jr_ech,
+       jr_rapt,
+       jr_valid,
+       jr_opid,
+       jr_c_opid,
+       jr_pj,
+       jr_pj_name,
+       jr_pj_type,
+       jr_pj_number,
+       del_jrn_date)=20
+       select  jr_id,
+	      jr_def_id,
+	      jr_montant,
+	      jr_comment,
+	      jr_date,
+	      jr_grpt_id,
+	      jr_internal,
+	      jr_tech_date,
+	      jr_tech_per,
+	      jrn_ech,
+	      jr_ech,
+	      jr_rapt,
+	      jr_valid,
+	      jr_opid,
+	      jr_c_opid,
+	      jr_pj,
+	      jr_pj_name,
+	      jr_pj_type,
+	      jr_pj_number
+	      ,now() from jrn where jr_id=3Drow.jr_id;
+return row;
+end;
+$$;
+
+
+--
+-- Name: jrnx_del(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrnx_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+row jrnx%ROWTYPE;
+begin
+row:=3DOLD;
+
+
+insert into del_jrnx(
+            j_id, j_date, j_montant, j_poste, j_grpt, j_rapt, j_jrn_def,=
=20
+            j_debit, j_text, j_centralized, j_internal, j_tech_user, j_t=
ech_date,=20
+            j_tech_per, j_qcode, f_id)  SELECT j_id, j_date, j_montant, =
j_poste, j_grpt, j_rapt, j_jrn_def,=20
+       j_debit, j_text, j_centralized, j_internal, j_tech_user, j_tech_d=
ate,=20
+       j_tech_per, j_qcode, f_id from jrnx where j_id=3Drow.j_id;
+return row;
+end;
+$$;
+
+
+--
+-- Name: jrnx_ins(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrnx_ins() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+n_fid bigint;
+begin
+
+NEW.j_tech_per :=3D comptaproc.find_periode(to_char(NEW.j_date,'DD.MM.YY=
YY'));
+if NEW.j_tech_per =3D -1 then
+	raise exception 'P=C3=A9riode invalide';
+end if;
+
+if NEW.j_qcode is NULL then
+   return NEW;
+end if;
+
+NEW.j_qcode=3Dtrim(upper(NEW.j_qcode));
+
+if length (NEW.j_qcode) =3D 0 then
+    NEW.j_qcode=3DNULL;
+    else
+   select f_id into n_fid from fiche_detail  where ad_id=3D23 and ad_val=
ue=3DNEW.j_qcode;
+	if NOT FOUND then
+		raise exception 'La fiche dont le quick code est % n''existe pas',NEW.=
j_qcode;
+	end if;
+end if;
+NEW.f_id:=3Dn_fid;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: jrnx_letter_del(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrnx_letter_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+row jrnx%ROWTYPE;
+begin
+row:=3DOLD;
+delete from jnt_letter=20
+	where (jl_id in (select jl_id from letter_deb) and jl_id not in(select =
jl_id from letter_cred ))=20
+		or (jl_id not in (select jl_id from letter_deb  ) and jl_id  in(select=
 jl_id from letter_cred ));
+return row;
+end;
+$$;
+
+
+--
+-- Name: plan_analytic_ins_upd(); Type: FUNCTION; Schema: comptaproc; Ow=
ner: -
+--
+
+CREATE FUNCTION plan_analytic_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+   name text;
+begin
+   name:=3Dupper(NEW.pa_name);
+   name:=3Dtrim(name);
+   name:=3Dreplace(name,' ','');
+   NEW.pa_name:=3Dname;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: poste_analytique_ins_upd(); Type: FUNCTION; Schema: comptaproc;=
 Owner: -
+--
+
+CREATE FUNCTION poste_analytique_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$declare
+name text;
+rCount record;
+
+begin
+name:=3Dupper(NEW.po_name);
+name:=3Dtrim(name);
+name:=3Dreplace(name,' ','');	=09
+NEW.po_name:=3Dname;
+
+if NEW.ga_id is NULL then
+return NEW;
+end if;
+
+if length(trim(NEW.ga_id)) =3D 0 then
+  NEW.ga_id:=3DNULL;
+  return NEW;
+end if;
+perform 'select ga_id from groupe_analytique where ga_id=3D'||NEW.ga_id;
+if NOT FOUND then
+   raise exception' Inexistent Group Analytic %',NEW.ga_id;
+end if;
+return NEW;
+end;$$;
+
+
+--
+-- Name: proc_check_balance(); Type: FUNCTION; Schema: comptaproc; Owner=
: -
+--
+
+CREATE FUNCTION proc_check_balance() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	diff numeric;
+	tt integer;
+begin
+	if TG_OP =3D 'INSERT' or TG_OP=3D'UPDATE' then
+	tt=3DNEW.jr_grpt_id;
+	diff:=3Dcheck_balance(tt);
+	if diff !=3D 0 then
+		raise exception 'balance error %',diff ;
+	end if;
+	return NEW;
+	end if;
+end;
+$$;
+
+
+--
+-- Name: quant_purchase_ins_upd(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION quant_purchase_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+	begin
+		if NEW.qp_price < 0 OR NEW.qp_quantite <0 THEN
+			NEW.qp_price :=3D abs (NEW.qp_price)*(-1);
+			NEW.qp_quantite :=3D abs (NEW.qp_quantite)*(-1);
+		end if;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: quant_sold_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner=
: -
+--
+
+CREATE FUNCTION quant_sold_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+	begin
+		if NEW.qs_price < 0 OR NEW.qs_quantite <0 THEN
+			NEW.qs_price :=3D abs (NEW.qs_price)*(-1);
+			NEW.qs_quantite :=3D abs (NEW.qs_quantite)*(-1);
+		end if;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: t_document_modele_validate(); Type: FUNCTION; Schema: comptapro=
c; Owner: -
+--
+
+CREATE FUNCTION t_document_modele_validate() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+    lText text;
+    modified document_modele%ROWTYPE;
+begin
+    modified:=3DNEW;
+
+	modified.md_filename:=3Dreplace(NEW.md_filename,' ','_');
+	return modified;
+end;
+$$;
+
+
+--
+-- Name: t_document_type_insert(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION t_document_type_insert() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+nCounter integer;
+    BEGIN
+select count(*) into nCounter from pg_class where relname=3D'seq_doc_typ=
e_'||NEW.dt_id;
+if nCounter =3D 0 then
+        execute  'create sequence seq_doc_type_'||NEW.dt_id;
+end if;
+        RETURN NEW;
+    END;
+$$;
+
+
+--
+-- Name: t_document_validate(); Type: FUNCTION; Schema: comptaproc; Owne=
r: -
+--
+
+CREATE FUNCTION t_document_validate() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+  lText text;
+  modified document%ROWTYPE;
+begin
+    	modified:=3DNEW;
+	modified.d_filename:=3Dreplace(NEW.d_filename,' ','_');
+	return modified;
+end;
+$$;
+
+
+--
+-- Name: t_jrn_def_sequence(); Type: FUNCTION; Schema: comptaproc; Owner=
: -
+--
+
+CREATE FUNCTION t_jrn_def_sequence() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+nCounter integer;
+
+    BEGIN
+    select count(*) into nCounter=20
+       from pg_class where relname=3D's_jrn_'||NEW.jrn_def_id;
+       if nCounter =3D 0 then
+       	   execute  'create sequence s_jrn_'||NEW.jrn_def_id;
+	   raise notice 'Creating sequence s_jrn_%',NEW.jrn_def_id;
+	 end if;
+
+        RETURN NEW;
+    END;
+$$;
+
+
+--
+-- Name: table_analytic_account(text, text); Type: FUNCTION; Schema: com=
ptaproc; Owner: -
+--
+
+CREATE FUNCTION table_analytic_account(p_from text, p_to text) RETURNS S=
ETOF public.anc_table_account_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	ret ANC_table_account_type%ROWTYPE;
+	sql_from text:=3D'';
+	sql_to text:=3D'';
+	sWhere text:=3D'';
+	sAnd text:=3D'';
+	sResult text:=3D'';
+begin
+if p_from <> '' and p_from is not null then
+	sql_from:=3D'oa_date >=3D to_date('''||p_from::text||''',''DD.MM.YYYY''=
)';
+	sWhere:=3D' where ';
+end if;
+
+if p_to <> '' and p_to is not null then
+	sql_to=3D' oa_date <=3D to_date('''||p_to::text||''',''DD.MM.YYYY'')';
+	sWhere :=3D ' where ';
+end if;
+
+if sql_to <> '' and sql_from <> '' then
+	sAnd:=3D' and ';
+end if;
+
+sResult :=3D sWhere || sql_from || sAnd || sql_to;
+
+for ret in EXECUTE 'SELECT po.po_id,
+			    po.pa_id, po.po_name,=20
+			    po.po_description,sum(
+        CASE
+            WHEN operation_analytique.oa_debit =3D true THEN operation_a=
nalytique.oa_amount * (-1)::numeric
+            ELSE operation_analytique.oa_amount
+        END) AS sum_amount, jrnx.j_poste, tmp_pcmn.pcm_lib AS name
+   FROM operation_analytique
+   JOIN poste_analytique po USING (po_id)
+   JOIN jrnx USING (j_id)
+   JOIN tmp_pcmn ON jrnx.j_poste::text =3D tmp_pcmn.pcm_val::text
+'|| sResult ||'
+  GROUP BY po.po_id, po.po_name, po.pa_id, jrnx.j_poste, tmp_pcmn.pcm_li=
b, po.po_description
+ HAVING sum(
+CASE
+    WHEN operation_analytique.oa_debit =3D true THEN operation_analytiqu=
e.oa_amount * (-1)::numeric
+    ELSE operation_analytique.oa_amount
+END) <> 0::numeric '
+	loop
+	return next ret;
+end loop;
+end;
+$$;
+
+
+--
+-- Name: table_analytic_card(text, text); Type: FUNCTION; Schema: compta=
proc; Owner: -
+--
+
+CREATE FUNCTION table_analytic_card(p_from text, p_to text) RETURNS SETO=
F public.anc_table_card_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	ret ANC_table_card_type%ROWTYPE;
+	sql_from text:=3D'';
+	sql_to text:=3D'';
+	sWhere text:=3D'';
+	sAnd text:=3D'';
+	sResult text:=3D'';
+begin
+if p_from <> '' and p_from is not null then
+	sql_from:=3D'oa_date >=3D to_date('''||p_from::text||''',''DD.MM.YYYY''=
)';
+	sWhere:=3D' where ';
+end if;
+
+if p_to <> '' and p_to is not null then
+	sql_to=3D' oa_date <=3D to_date('''||p_to::text||''',''DD.MM.YYYY'')';
+	sWhere :=3D ' where ';
+end if;
+
+if sql_to <> '' and sql_from <> '' then
+	sAnd :=3D' and ';
+end if;
+
+sResult :=3D sWhere || sql_from || sAnd || sql_to;
+
+for ret in EXECUTE ' SELECT po.po_id, po.pa_id, po.po_name, po.po_descri=
ption,  sum(
+        CASE
+            WHEN operation_analytique.oa_debit =3D true THEN operation_a=
nalytique.oa_amount * (-1)::numeric
+            ELSE operation_analytique.oa_amount
+        END) AS sum_amount, jrnx.f_id, jrnx.j_qcode, ( SELECT fiche_deta=
il.ad_value
+           FROM fiche_detail
+          WHERE fiche_detail.ad_id =3D 1 AND fiche_detail.f_id =3D jrnx.=
f_id) AS name
+   FROM operation_analytique
+   JOIN poste_analytique po USING (po_id)
+   JOIN jrnx USING (j_id)'|| sResult ||'
+  GROUP BY po.po_id, po.po_name, po.pa_id, jrnx.f_id, jrnx.j_qcode, ( SE=
LECT fiche_detail.ad_value
+   FROM fiche_detail
+  WHERE fiche_detail.ad_id =3D 1 AND fiche_detail.f_id =3D jrnx.f_id), p=
o.po_description
+ HAVING sum(
+CASE
+    WHEN operation_analytique.oa_debit =3D true THEN operation_analytiqu=
e.oa_amount * (-1)::numeric
+    ELSE operation_analytique.oa_amount
+END) <> 0::numeric;'
+
+
+	loop
+	return next ret;
+end loop;
+end;
+$$;
+
+
+--
+-- Name: tmp_pcmn_ins(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION tmp_pcmn_ins() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+   r_record tmp_pcmn%ROWTYPE;
+begin
+r_record=3DNEW;
+if  length(trim(r_record.pcm_type))=3D0 or r_record.pcm_type is NULL the=
n=20
+   r_record.pcm_type:=3Dfind_pcm_type(NEW.pcm_val);
+   return r_record;
+end if;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: trim_cvs_quote(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION trim_cvs_quote() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+        modified import_tmp%ROWTYPE;
+begin
+	modified:=3DNEW;
+	modified.devise=3Dreplace(new.devise,'"','');
+	modified.poste_comptable=3Dreplace(new.poste_comptable,'"','');
+        modified.compte_ordre=3Dreplace(NEW.COMPTE_ORDRE,'"','');
+        modified.detail=3Dreplace(NEW.DETAIL,'"','');
+        modified.num_compte=3Dreplace(NEW.NUM_COMPTE,'"','');
+        return modified;
+end;
+$$;
+
+
+--
+-- Name: trim_space_format_csv_banque(); Type: FUNCTION; Schema: comptap=
roc; Owner: -
+--
+
+CREATE FUNCTION trim_space_format_csv_banque() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+        modified format_csv_banque%ROWTYPE;
+begin
+        modified.name=3Dtrim(NEW.NAME);
+        modified.include_file=3Dtrim(new.include_file);
+		if ( length(modified.name) =3D 0 ) then
+			modified.name=3Dnull;
+		end if;
+		if ( length(modified.include_file) =3D 0 ) then
+			modified.include_file=3Dnull;
+		end if;
+
+        return modified;
+end;
+$$;
+
+
+--
+-- Name: tva_delete(integer); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION tva_delete(integer) RETURNS void
+    LANGUAGE plpgsql
+    AS $_$=20
+declare
+	p_tva_id alias for $1;
+	nCount integer;
+begin
+	nCount=3D0;
+	select count(*) into nCount from quant_sold where qs_vat_code=3Dp_tva_i=
d;
+	if nCount !=3D 0 then
+                 return;
+	=09
+	end if;
+	select count(*) into nCount from quant_purchase where qp_vat_code=3Dp_t=
va_id;
+	if nCount !=3D 0 then
+                 return;
+	=09
+	end if;
+
+delete from tva_rate where tva_id=3Dp_tva_id;
+	return;
+end;
+$_$;
+
+
+--
+-- Name: tva_insert(text, numeric, text, text); Type: FUNCTION; Schema: =
comptaproc; Owner: -
+--
+
+CREATE FUNCTION tva_insert(text, numeric, text, text) RETURNS integer
+    LANGUAGE plpgsql
+    AS $_$
+declare
+	l_tva_id integer;
+	p_tva_label alias for $1;
+	p_tva_rate alias for $2;
+	p_tva_comment alias for $3;
+	p_tva_poste alias for $4;
+	debit text;
+	credit text;
+	nCount integer;
+begin
+if length(trim(p_tva_label)) =3D 0 then
+	return 3;
+end if;
+
+if length(trim(p_tva_poste)) !=3D 0 then
+	if position (',' in p_tva_poste) =3D 0 then return 4; end if;
+	debit  =3D split_part(p_tva_poste,',',1);
+	credit	=3D split_part(p_tva_poste,',',2);
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Ddebit::accoun=
t_type;
+	if nCount =3D 0 then return 4; end if;
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Dcredit::accou=
nt_type;
+	if nCount =3D 0 then return 4; end if;
+
+end if;
+select into l_tva_id nextval('s_tva') ;
+insert into tva_rate(tva_id,tva_label,tva_rate,tva_comment,tva_poste)
+	values (l_tva_id,p_tva_label,p_tva_rate,p_tva_comment,p_tva_poste);
+return 0;
+end;
+$_$;
+
+
+--
+-- Name: tva_modify(integer, text, numeric, text, text); Type: FUNCTION;=
 Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION tva_modify(integer, text, numeric, text, text) RETURNS i=
nteger
+    LANGUAGE plpgsql
+    AS $_$
+declare
+	p_tva_id alias for $1;
+	p_tva_label alias for $2;
+	p_tva_rate alias for $3;
+	p_tva_comment alias for $4;
+	p_tva_poste alias for $5;
+	debit text;
+	credit text;
+	nCount integer;
+begin
+if length(trim(p_tva_label)) =3D 0 then
+	return 3;
+end if;
+
+if length(trim(p_tva_poste)) !=3D 0 then
+	if position (',' in p_tva_poste) =3D 0 then return 4; end if;
+	debit  =3D split_part(p_tva_poste,',',1);
+	credit	=3D split_part(p_tva_poste,',',2);
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Ddebit::accoun=
t_type;
+	if nCount =3D 0 then return 4; end if;
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Dcredit::accou=
nt_type;
+	if nCount =3D 0 then return 4; end if;
+
+end if;
+update tva_rate set tva_label=3Dp_tva_label,tva_rate=3Dp_tva_rate,tva_co=
mment=3Dp_tva_comment,tva_poste=3Dp_tva_poste
+	where tva_id=3Dp_tva_id;
+return 0;
+end;
+$_$;
+
+
+--
+-- Name: update_quick_code(integer, text); Type: FUNCTION; Schema: compt=
aproc; Owner: -
+--
+
+CREATE FUNCTION update_quick_code(njft_id integer, tav_text text) RETURN=
S integer
+    LANGUAGE plpgsql
+    AS $$
+	declare
+	ns integer;
+	nExist integer;
+	tText text;
+	old_qcode varchar;
+	begin
+	-- get current value
+	select ad_value into old_qcode from fiche_detail where jft_id=3Dnjft_id=
;
+	-- av_text didn't change so no update
+	if tav_text =3D upper( trim(old_qcode)) then
+		return 0;
+	end if;
+=09
+	tText :=3D trim(upper(tav_text));
+	tText :=3D replace(tText,' ','');
+	if length ( tText) =3D 0 or tText is null then
+		return 0;
+	end if;
+	=09
+	ns :=3D njft_id;
+
+	loop
+		-- av_text already used ?
+		select count(*) into nExist=20
+			from fiche_detail
+		where=20
+			ad_id=3D23 and ad_value=3DtText;
+
+		if nExist =3D 0 then
+			exit;
+		end if;=09
+		if tText =3D 'FID'||ns then
+			-- take the next sequence
+			select nextval('s_jnt_fic_att_value') into ns;
+		end if;
+		tText  :=3D'FID'||ns;
+	=09
+	end loop;
+	update fiche_detail set ad_value =3D tText where jft_id=3Dnjft_id;
+
+	-- update also the contact
+	update fiche_detail set ad_value =3D tText=20
+		where jft_id in=20
+			( select jft_id=20
+				from fiche_detail=20
+			where ad_id=3D25 and ad_value=3Dold_qcode);
+
+
+	update jrnx set j_qcode=3DtText where j_qcode =3D old_qcode;
+	return ns;
+	end;
+$$;
+
+
+--
+-- PostgreSQL database dump complete
+--
+



From MAILER-DAEMON Sat Jun 04 06:53:38 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QSoU6-0000mY-7R
	for mharc-phpcompta-dev@gnu.org; Sat, 04 Jun 2011 06:53:38 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat,  4 Jun 2011 12:58:16 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.11800.1307184817.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4155 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 04 Jun 2011 10:53:37 -0000

Author: danydb
Date: 2011-06-04 12:58:06 +0200 (Sat, 04 Jun 2011)
New Revision: 4155

Modified:
   phpcompta/branches/rel560/include/constant.php
Log:
remove debug info

Modified: phpcompta/branches/rel560/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/constant.php	2011-06-04 10:41:30 UT=
C (rev 4154)
+++ phpcompta/branches/rel560/include/constant.php	2011-06-04 10:58:06 UT=
C (rev 4155)
@@ -38,7 +38,7 @@
 //$version_phpcompta=3DSVNINFO;=20
 //define ("DEBUG",false);
=20
-define ("DEBUG",true);
+define ("DEBUG",false);
 $version_phpcompta=3D4014;
=20
=20



From MAILER-DAEMON Sat Jun 04 10:20:22 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QSri9-0006wO-SY
	for mharc-phpcompta-dev@gnu.org; Sat, 04 Jun 2011 10:20:21 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat,  4 Jun 2011 16:24:59 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.12016.1307197221.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4156 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 04 Jun 2011 14:20:20 -0000

Author: danydb
Date: 2011-06-04 16:24:57 +0200 (Sat, 04 Jun 2011)
New Revision: 4156

Modified:
   phpcompta/branches/rel560/include/class_database.php
Log:
Fix bug with debug flag


Modified: phpcompta/branches/rel560/include/class_database.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_database.php	2011-06-04 10:58=
:06 UTC (rev 4155)
+++ phpcompta/branches/rel560/include/class_database.php	2011-06-04 14:24=
:57 UTC (rev 4156)
@@ -126,15 +126,20 @@
             $this->sql=3D$p_string;
             $this->array=3D$p_array;
=20
-            if ( $p_array=3D=3Dnull )
+           if ( $p_array=3D=3Dnull )
             {
-	      $PG_QUERY=3D(DEBUG=3D=3Dfalse)?'@pg_query':'pg_query';
-	      $this->ret=3D$PG_QUERY($this->db,$p_string);
+	      if ( ! DEBUG )=20
+		$this->ret=3Dpg_query($this->db,$p_string);
+	      else
+		$this->ret=3D@pg_query($this->db,$p_string);
             }
             else
             {
-	      $PG_QUERY=3D(DEBUG=3D=3Dfalse)?'@pg_query_params':'pg_query_param=
s';
-                $this->ret=3D$PG_QUERY($this->db,$p_string,$p_array);
+	      if ( ! DEBUG )=20
+		$this->ret=3Dpg_query_params($this->db,$p_string,$p_array);
+	      else
+		$this->ret=3D@pg_query_params($this->db,$p_string,$p_array);
+
             }
             if ( ! $this->ret )
             {



From MAILER-DAEMON Sat Jun 04 10:21:08 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QSrit-00071p-Tl
	for mharc-phpcompta-dev@gnu.org; Sat, 04 Jun 2011 10:21:07 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat,  4 Jun 2011 16:25:45 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.12017.1307197267.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4157 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 04 Jun 2011 14:21:06 -0000

Author: danydb
Date: 2011-06-04 16:25:44 +0200 (Sat, 04 Jun 2011)
New Revision: 4157

Modified:
   phpcompta/branches/rel560/include/constant.php
Log:
remove debug=20

Modified: phpcompta/branches/rel560/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/constant.php	2011-06-04 14:24:57 UT=
C (rev 4156)
+++ phpcompta/branches/rel560/include/constant.php	2011-06-04 14:25:44 UT=
C (rev 4157)
@@ -35,13 +35,13 @@
 /* set to none for production */
 /* uncomment for production */
=20
-//$version_phpcompta=3DSVNINFO;=20
-//define ("DEBUG",false);
-
+$version_phpcompta=3DSVNINFO;=20
 define ("DEBUG",false);
-$version_phpcompta=3D4014;
=20
+//define ("DEBUG",true);
+//$version_phpcompta=3D4014;
=20
+
 define ("DBVERSION",95);
 define ("DBVERSIONREPO",13);
 define ('NOTFOUND','--not found--');



From MAILER-DAEMON Mon Jun 06 15:25:36 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QTfQd-0000lo-TV
	for mharc-phpcompta-dev@gnu.org; Mon, 06 Jun 2011 15:25:36 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Mon,  6 Jun 2011 21:30:09 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.16810.1307388334.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4158 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Mon, 06 Jun 2011 19:25:34 -0000

Author: danydb
Date: 2011-06-06 21:30:08 +0200 (Mon, 06 Jun 2011)
New Revision: 4158

Modified:
   phpcompta/branches/rel560/include/class_acc_ledger_purchase.php
Log:
Alert : show the missing accounting


Modified: phpcompta/branches/rel560/include/class_acc_ledger_purchase.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_acc_ledger_purchase.php	2011-=
06-04 14:25:44 UTC (rev 4157)
+++ phpcompta/branches/rel560/include/class_acc_ledger_purchase.php	2011-=
06-06 19:30:08 UTC (rev 4158)
@@ -234,7 +234,7 @@
                 {
                     $a=3Dnew Acc_Parm_Code($this->db,$key[1]);
                     if ( $this->db->count_sql('select pcm_val from tmp_p=
cmn where pcm_val=3D$1',array($a->p_value))=3D=3D0)
-                        throw new Exception ($key._("ce code n'a pas de =
poste comptable, cr=C3=A9ez ce poste : [".$a->p_value."]"));
+                        throw new Exception ($key[1]._("ce code n'a pas =
de poste comptable, cr=C3=A9ez ce poste : [".$a->p_value."]"));
                 }
             }
 	    /*



From MAILER-DAEMON Mon Jun 06 17:25:31 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QThIg-0006Kw-UQ
	for mharc-phpcompta-dev@gnu.org; Mon, 06 Jun 2011 17:25:31 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Mon,  6 Jun 2011 23:30:10 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.17002.1307395529.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4159 -
	phpcompta/branches/rel560/dev/manage-code/create-file
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Mon, 06 Jun 2011 21:25:29 -0000

Author: danydb
Date: 2011-06-06 23:30:08 +0200 (Mon, 06 Jun 2011)
New Revision: 4159

Modified:
   phpcompta/branches/rel560/dev/manage-code/create-file/create_phpclass.=
py
Log:
bug fixed : settype transform SQL NULL into 0


Modified: phpcompta/branches/rel560/dev/manage-code/create-file/create_ph=
pclass.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/dev/manage-code/create-file/create_phpclass=
.py	2011-06-06 19:30:08 UTC (rev 4158)
+++ phpcompta/branches/rel560/dev/manage-code/create-file/create_phpclass=
.py	2011-06-06 21:30:08 UTC (rev 4159)
@@ -544,7 +544,7 @@
                col_id=3Dcol_id.strip()
                col_type=3Dcol_type.strip()
                if col_type in ('float','integer','numeric','bigint') :
-                   verify_data_type+=3D"if ( settype($this->"+col_id+",'=
float') =3D=3D false )\n \
+                   verify_data_type+=3D"if ( $this->"+col_id+"!=3D=3D nu=
ll && settype($this->"+col_id+",'float') =3D=3D false )\n \
             throw new Exception('DATATYPE "+col_id+" $this->"+col_id+" n=
on numerique');\n"
                    if col_type in ('date',' timestamp without time zone'=
,'timestamp with time zone'):
                        verify_data_type+=3D" if (isDate($this->"+col_id+=
") =3D=3D null )\n \



From MAILER-DAEMON Tue Jun 07 17:20:25 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QU3hJ-00047V-2C
	for mharc-phpcompta-dev@gnu.org; Tue, 07 Jun 2011 17:20:25 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Tue,  7 Jun 2011 23:24:56 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.20630.1307481622.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4160 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Tue, 07 Jun 2011 21:20:21 -0000

Author: danydb
Date: 2011-06-07 23:24:54 +0200 (Tue, 07 Jun 2011)
New Revision: 4160

Modified:
   phpcompta/branches/rel560/include/class_acc_ledger_purchase.php
Log:
0000283: Compte contrepartie


Modified: phpcompta/branches/rel560/include/class_acc_ledger_purchase.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_acc_ledger_purchase.php	2011-=
06-06 21:30:08 UTC (rev 4159)
+++ phpcompta/branches/rel560/include/class_acc_ledger_purchase.php	2011-=
06-07 21:24:54 UTC (rev 4160)
@@ -225,32 +225,26 @@
              "ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP"
             */
             foreach (array(
-                         array(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE,'DNA'),
-                         array(ATTR_DEF_DEP_PRIV,'DEP_PRIV'),
-                         array(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP,'TVA_DE=
D_IMPOT'),
-                         array(ATTR_DEF_TVA_NON_DEDUCTIBLE,'TVA_DNA')) a=
s $key)
-            {
-                if ( ! $fiche->empty_attribute($key[0]))
-                {
+			   array(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE,'DNA',ATTR_DEF_ACCOUNT_ND),
+			   array(ATTR_DEF_DEP_PRIV,'DEP_PRIV',ATTR_DEF_ACCOUNT_ND_PERSO),
+			   array(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP,'TVA_DED_IMPOT',ATTR_DEF_A=
CCOUNT_ND_TVA),
+			   array(ATTR_DEF_TVA_NON_DEDUCTIBLE,'TVA_DNA',ATTR_DEF_ACCOUNT_ND_TV=
A_ND)) as $key)
+	      {
+                if ( ! $fiche->empty_attribute($key[0]) &&  $fiche->empt=
y_attribute($key[2]))
+		  {
                     $a=3Dnew Acc_Parm_Code($this->db,$key[1]);
                     if ( $this->db->count_sql('select pcm_val from tmp_p=
cmn where pcm_val=3D$1',array($a->p_value))=3D=3D0)
-                        throw new Exception ($key[1]._("ce code n'a pas =
de poste comptable, cr=C3=A9ez ce poste : [".$a->p_value."]"));
-                }
-            }
-	    /*
-	     * Check that the compensation entry does exist
-	     */
-	    foreach (array(ATTR_DEF_ACCOUNT_ND_TVA,ATTR_DEF_ACCOUNT_ND_TVA_ND,A=
TTR_DEF_ACCOUNT_ND_PERSO,ATTR_DEF_ACCOUNT_ND) as $nd)
-	      {
-		if ( ! $fiche->empty_attribute($nd))
+		      throw new Exception ($key[1]._("ce code n'a pas de poste comptab=
le, cr=C3=A9ez ce poste : [".$a->p_value."]"));
+		  }=20
+		if ( ! $fiche->empty_attribute($key[0]) &&  ! $fiche->empty_attribute(=
$key[2]))
 		  {
-		    $nd_str=3D$fiche->strAttribut($nd);
+		    $nd_str=3D$fiche->strAttribut($key[2]);
 		    if ( $nd_str !=3D '')
-		      {
+		      {=09
 			$poste_nd=3Dnew Acc_Account_Ledger($this->db,$nd_str);
 			if ( $poste_nd->load() =3D=3D false)
 			  {
-			    $nd_msg=3Dsprintf(_("Pour la fiche %s, le compte %s n'existe pas"=
),
+			    $nd_msg=3Dsprintf(_("Pour la fiche %s, le compte contrepartie %s =
n'existe pas"),
 					    $fiche->getName(),$poste_nd->id);
 			    $nd_msg=3Dh($nd_msg);
 			    throw new Exception ($nd_msg);
@@ -258,7 +252,7 @@
 		      }
 		  }
 	      }
-            $nb++;
+	    $nb++;
         }
         if ( $nb =3D=3D 0 )
             throw new Exception(_('Il n\'y a aucune marchandise'),12);
@@ -490,7 +484,7 @@
                     $op->oa_group=3D$group;
                     $op->j_id=3D$j_id;
                     $op->oa_date=3D$e_date;
-		    echo $amount;
+
                     $op->oa_debit=3D($amount > 0 )?'t':'f';
                     $op->oa_description=3DFormatString($e_comm);
                     $op->save_form_plan($_POST,$i,$j_id);



From MAILER-DAEMON Wed Jun 08 13:54:21 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QUMxQ-0006CM-Iv
	for mharc-phpcompta-dev@gnu.org; Wed, 08 Jun 2011 13:54:20 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Wed,  8 Jun 2011 19:58:49 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.24321.1307555659.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4161 - in phpcompta/trunk: .
	dev/manage-code/create-file html
	html/admin/sql/account_repository html/admin/sql/mod1
	html/admin/sql/patch include sql
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 08 Jun 2011 17:54:18 -0000

Author: danydb
Date: 2011-06-08 19:58:47 +0200 (Wed, 08 Jun 2011)
New Revision: 4161

Added:
   phpcompta/trunk/html/admin/sql/patch/upgrade94.sql
   phpcompta/trunk/sql/comptaproc.sql
Modified:
   phpcompta/trunk/
   phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py
   phpcompta/trunk/html/admin/sql/account_repository/schema.sql
   phpcompta/trunk/html/admin/sql/mod1/schema.sql
   phpcompta/trunk/html/ajax_card.php
   phpcompta/trunk/html/ajax_ledger.php
   phpcompta/trunk/html/ajax_poste.php
   phpcompta/trunk/include/ac_common.php
   phpcompta/trunk/include/class_acc_ledger_purchase.php
   phpcompta/trunk/include/class_acc_operation.php
   phpcompta/trunk/include/class_database.php
   phpcompta/trunk/include/constant.php
Log:
Merged revisions 4147-4160 via svnmerge from=20
svn+ssh://danydb@svn/svn/phpcompta/branches/rel560

........
  r4147 | danydb | 2011-05-31 21:27:49 +0200 (Tue, 31 May 2011) | 2 lines
 =20
  revoke from ... cause problem on MAC
........
  r4148 | danydb | 2011-05-31 23:36:28 +0200 (Tue, 31 May 2011) | 1 line
 =20
  better error message with database::get_value
........
  r4149 | danydb | 2011-06-01 02:12:08 +0200 (Wed, 01 Jun 2011) | 1 line
 =20
  Ajax disconnected
........
  r4150 | danydb | 2011-06-01 23:44:53 +0200 (Wed, 01 Jun 2011) | 1 line
 =20
  update SQL script
........
  r4151 | danydb | 2011-06-01 23:46:25 +0200 (Wed, 01 Jun 2011) | 2 lines
 =20
  update database version
........
  r4152 | danydb | 2011-06-04 12:39:20 +0200 (Sat, 04 Jun 2011) | 1 line
 =20
   0000281: Ajax : d?\195?\169connect?\195?\169
........
  r4153 | danydb | 2011-06-04 12:40:37 +0200 (Sat, 04 Jun 2011) | 1 line
 =20
  Better error message=20
........
  r4154 | danydb | 2011-06-04 12:41:30 +0200 (Sat, 04 Jun 2011) | 1 line
 =20
  Bug for MacOSX
........
  r4155 | danydb | 2011-06-04 12:58:06 +0200 (Sat, 04 Jun 2011) | 1 line
 =20
  remove debug info
........
  r4156 | danydb | 2011-06-04 16:24:57 +0200 (Sat, 04 Jun 2011) | 2 lines
 =20
  Fix bug with debug flag
........
  r4157 | danydb | 2011-06-04 16:25:44 +0200 (Sat, 04 Jun 2011) | 1 line
 =20
  remove debug=20
........
  r4158 | danydb | 2011-06-06 21:30:08 +0200 (Mon, 06 Jun 2011) | 2 lines
 =20
  Alert : show the missing accounting
........
  r4159 | danydb | 2011-06-06 23:30:08 +0200 (Mon, 06 Jun 2011) | 2 lines
 =20
  bug fixed : settype transform SQL NULL into 0
........
  r4160 | danydb | 2011-06-07 23:24:54 +0200 (Tue, 07 Jun 2011) | 2 lines
 =20
  0000283: Compte contrepartie
........



Property changes on: phpcompta/trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /phpcompta/branches/rel560:1-4145
   + /phpcompta/branches/rel560:1-4160

Modified: phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py	2011-0=
6-07 21:24:54 UTC (rev 4160)
+++ phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py	2011-0=
6-08 17:58:47 UTC (rev 4161)
@@ -544,7 +544,7 @@
                col_id=3Dcol_id.strip()
                col_type=3Dcol_type.strip()
                if col_type in ('float','integer','numeric','bigint') :
-                   verify_data_type+=3D"if ( settype($this->"+col_id+",'=
float') =3D=3D false )\n \
+                   verify_data_type+=3D"if ( $this->"+col_id+"!=3D=3D nu=
ll && settype($this->"+col_id+",'float') =3D=3D false )\n \
             throw new Exception('DATATYPE "+col_id+" $this->"+col_id+" n=
on numerique');\n"
                    if col_type in ('date',' timestamp without time zone'=
,'timestamp with time zone'):
                        verify_data_type+=3D" if (isDate($this->"+col_id+=
") =3D=3D null )\n \

Modified: phpcompta/trunk/html/admin/sql/account_repository/schema.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/admin/sql/account_repository/schema.sql	2011-06-=
07 21:24:54 UTC (rev 4160)
+++ phpcompta/trunk/html/admin/sql/account_repository/schema.sql	2011-06-=
08 17:58:47 UTC (rev 4161)
@@ -81,7 +81,3 @@
 );
 CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id);
 CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id);
-REVOKE ALL ON SCHEMA public FROM PUBLIC;
-REVOKE ALL ON SCHEMA public FROM postgres;
-GRANT ALL ON SCHEMA public TO postgres;
-GRANT ALL ON SCHEMA public TO PUBLIC;

Modified: phpcompta/trunk/html/admin/sql/mod1/schema.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/admin/sql/mod1/schema.sql	2011-06-07 21:24:54 UT=
C (rev 4160)
+++ phpcompta/trunk/html/admin/sql/mod1/schema.sql	2011-06-08 17:58:47 UT=
C (rev 4161)
@@ -3738,145 +3738,3 @@
     BEFORE INSERT OR UPDATE ON format_csv_banque
     FOR EACH ROW
     EXECUTE PROCEDURE comptaproc.trim_space_format_csv_banque();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-REVOKE ALL ON SCHEMA public FROM PUBLIC;
-REVOKE ALL ON SCHEMA public FROM postgres;
-GRANT ALL ON SCHEMA public TO postgres;
-GRANT ALL ON SCHEMA public TO PUBLIC;
-
-
-

Copied: phpcompta/trunk/html/admin/sql/patch/upgrade94.sql (from rev 4160=
, phpcompta/branches/rel560/html/admin/sql/patch/upgrade94.sql)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/admin/sql/patch/upgrade94.sql	                  =
      (rev 0)
+++ phpcompta/trunk/html/admin/sql/patch/upgrade94.sql	2011-06-08 17:58:4=
7 UTC (rev 4161)
@@ -0,0 +1,93 @@
+begin;
+
+--
+-- Name: account_insert(integer, text); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION account_insert(p_f_id integer, p_account text) RETURNS i=
nteger
+    AS $_$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	nNew tmp_pcmn.pcm_val%type;
+	bAuto bool;
+	nFd_id integer;
+	sClass_Base fiche_def.fd_class_base%TYPE;
+	nCount integer;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+	-- if there is coma in p_account, treat normally
+		if position (',' in p_account) =3D 0 then
+			raise info 'p_account is not empty';
+				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
+				raise notice 'found in tmp_pcm %',nCount;
+				if nCount !=3D0  then
+					raise info 'this account exists in tmp_pcmn ';
+					perform attribut_insert(p_f_id,5,p_account);
+				   else
+				       -- account doesn't exist, create it
+					select ad_value into sName from
+						fiche_detail
+					where
+					ad_id=3D1 and f_id=3Dp_f_id;
+
+					nParent:=3Daccount_parent(p_account::account_type);
+					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
+					perform attribut_insert(p_f_id,5,p_account);
+
+				end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		perform attribut_insert(p_f_id,5,p_account);
+		end if;
+	else
+	raise info 'p_account is  empty';
+		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
+		bAuto:=3D account_auto(nFd_id);
+
+		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
+raise info 'sClass_Base : %',sClass_base;
+		if bAuto =3D true and sClass_base similar to '^[[:digit:]]*$'  then
+			raise info 'account generated automatically';
+			nNew:=3Daccount_compute(p_f_id);
+			raise info 'nNew %', nNew;
+			select ad_value into sName from
+				fiche_detail
+			where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(nNew);
+			perform account_add  (nNew,sName);
+			perform attribut_insert(p_f_id,5,nNew);
+
+		else
+		-- if there is an account_base then it is the default
+		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
+			if nNew is null or length(trim(nNew)) =3D 0 then
+				raise notice 'count is null';
+				 perform attribut_insert(p_f_id,5,null);
+			else
+				 perform attribut_insert(p_f_id,5,nNew);
+			end if;
+		end if;
+	end if;
+
+return 0;
+end;
+$_$    =20
+LANGUAGE plpgsql;
+
+update version set val=3D95;
+
+commit;
\ No newline at end of file

Modified: phpcompta/trunk/html/ajax_card.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/ajax_card.php	2011-06-07 21:24:54 UTC (rev 4160)
+++ phpcompta/trunk/html/ajax_card.php	2011-06-08 17:58:47 UTC (rev 4161)
@@ -73,8 +73,12 @@
         $cont=3D1;
     }
 }
+extract($_REQUEST );
+
+ajax_disconnected($ctl);
+
 if ( $cont !=3D 0 ) exit();
-extract($_REQUEST );
+
 set_language();
 /*
  *echo a warning if disconnected

Modified: phpcompta/trunk/html/ajax_ledger.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/ajax_ledger.php	2011-06-07 21:24:54 UTC (rev 416=
0)
+++ phpcompta/trunk/html/ajax_ledger.php	2011-06-08 17:58:47 UTC (rev 416=
1)
@@ -53,20 +53,8 @@
 /**
  *if $_SESSION['g_user'] is not set : echo a warning
  */
-if ( ! isset($_SESSION['g_user']))
-  {
-    $html=3Dalert("D=C3=A9connect=C3=A9",true);
-    $html=3Descape_xml($html);
-    header('Content-type: text/xml; charset=3DUTF-8');
-echo <<<EOF
-<?xml version=3D"1.0" encoding=3D"UTF-8"?>
-<data>
-<ctl>$div</ctl>
-<code>D=C3=A9connect=C3=A9</code>
-</data>
-EOF;
-exit();
-  }
+ajax_disconnected($div);
+
 $cn=3Dnew Database(dossier::id());
=20
 // check if the user is valid and can access this folder

Modified: phpcompta/trunk/html/ajax_poste.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/ajax_poste.php	2011-06-07 21:24:54 UTC (rev 4160=
)
+++ phpcompta/trunk/html/ajax_poste.php	2011-06-08 17:58:47 UTC (rev 4161=
)
@@ -51,6 +51,8 @@
         $cont=3D1;
     }
 }
+ajax_disconnected($ctl);
+
 set_language();
=20
 if ( $cont !=3D 0 ) exit();

Modified: phpcompta/trunk/include/ac_common.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/ac_common.php	2011-06-07 21:24:54 UTC (rev 41=
60)
+++ phpcompta/trunk/include/ac_common.php	2011-06-08 17:58:47 UTC (rev 41=
61)
@@ -695,8 +695,17 @@
  */
 if ( ! isset($_SESSION['g_user']))
   {
-    $html=3Dalert("Utilisateur d=C3=A9connect=C3=A9",true);
+    $script=3D'var a=3D$("'.$div.'");a.style.height=3D"70%";a.style.widt=
h=3D"70%";';
+    $script.=3D'a.style.top=3DposY-20+offsetY;a.style.left=3DposX+offset=
X;';
+    $script=3Dcreate_script($script);
+    $html=3D$script;
+    $html.=3DHtmlInput::anchor_close($div);
+    $html.=3D'<div>';
+    $html.=3Dh2('Donn=C3=A9es non disponibles','class=3D"info" style=3D"=
width:auto"');
+    $html.=3Dh2('Veuillez vous reconnecter','');
+    $html.=3Dalert("D=C3=A9connect=C3=A9",true);
     $html=3Descape_xml($html);
+
     header('Content-type: text/xml; charset=3DUTF-8');
 echo <<<EOF
 <?xml version=3D"1.0" encoding=3D"UTF-8"?>

Modified: phpcompta/trunk/include/class_acc_ledger_purchase.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/class_acc_ledger_purchase.php	2011-06-07 21:2=
4:54 UTC (rev 4160)
+++ phpcompta/trunk/include/class_acc_ledger_purchase.php	2011-06-08 17:5=
8:47 UTC (rev 4161)
@@ -225,32 +225,26 @@
              "ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP"
             */
             foreach (array(
-                         array(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE,'DNA'),
-                         array(ATTR_DEF_DEP_PRIV,'DEP_PRIV'),
-                         array(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP,'TVA_DE=
D_IMPOT'),
-                         array(ATTR_DEF_TVA_NON_DEDUCTIBLE,'TVA_DNA')) a=
s $key)
-            {
-                if ( ! $fiche->empty_attribute($key[0]))
-                {
+			   array(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE,'DNA',ATTR_DEF_ACCOUNT_ND),
+			   array(ATTR_DEF_DEP_PRIV,'DEP_PRIV',ATTR_DEF_ACCOUNT_ND_PERSO),
+			   array(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP,'TVA_DED_IMPOT',ATTR_DEF_A=
CCOUNT_ND_TVA),
+			   array(ATTR_DEF_TVA_NON_DEDUCTIBLE,'TVA_DNA',ATTR_DEF_ACCOUNT_ND_TV=
A_ND)) as $key)
+	      {
+                if ( ! $fiche->empty_attribute($key[0]) &&  $fiche->empt=
y_attribute($key[2]))
+		  {
                     $a=3Dnew Acc_Parm_Code($this->db,$key[1]);
                     if ( $this->db->count_sql('select pcm_val from tmp_p=
cmn where pcm_val=3D$1',array($a->p_value))=3D=3D0)
-                        throw new Exception ($key._("ce code n'a pas de =
poste comptable, cr=C3=A9ez ce poste : [".$a->p_value."]"));
-                }
-            }
-	    /*
-	     * Check that the compensation entry does exist
-	     */
-	    foreach (array(ATTR_DEF_ACCOUNT_ND_TVA,ATTR_DEF_ACCOUNT_ND_TVA_ND,A=
TTR_DEF_ACCOUNT_ND_PERSO,ATTR_DEF_ACCOUNT_ND) as $nd)
-	      {
-		if ( ! $fiche->empty_attribute($nd))
+		      throw new Exception ($key[1]._("ce code n'a pas de poste comptab=
le, cr=C3=A9ez ce poste : [".$a->p_value."]"));
+		  }=20
+		if ( ! $fiche->empty_attribute($key[0]) &&  ! $fiche->empty_attribute(=
$key[2]))
 		  {
-		    $nd_str=3D$fiche->strAttribut($nd);
+		    $nd_str=3D$fiche->strAttribut($key[2]);
 		    if ( $nd_str !=3D '')
-		      {
+		      {=09
 			$poste_nd=3Dnew Acc_Account_Ledger($this->db,$nd_str);
 			if ( $poste_nd->load() =3D=3D false)
 			  {
-			    $nd_msg=3Dsprintf(_("Pour la fiche %s, le compte %s n'existe pas"=
),
+			    $nd_msg=3Dsprintf(_("Pour la fiche %s, le compte contrepartie %s =
n'existe pas"),
 					    $fiche->getName(),$poste_nd->id);
 			    $nd_msg=3Dh($nd_msg);
 			    throw new Exception ($nd_msg);
@@ -258,7 +252,7 @@
 		      }
 		  }
 	      }
-            $nb++;
+	    $nb++;
         }
         if ( $nb =3D=3D 0 )
             throw new Exception(_('Il n\'y a aucune marchandise'),12);
@@ -490,7 +484,7 @@
                     $op->oa_group=3D$group;
                     $op->j_id=3D$j_id;
                     $op->oa_date=3D$e_date;
-		    echo $amount;
+
                     $op->oa_debit=3D($amount > 0 )?'t':'f';
                     $op->oa_description=3DFormatString($e_comm);
                     $op->save_form_plan($_POST,$i,$j_id);

Modified: phpcompta/trunk/include/class_acc_operation.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/class_acc_operation.php	2011-06-07 21:24:54 U=
TC (rev 4160)
+++ phpcompta/trunk/include/class_acc_operation.php	2011-06-08 17:58:47 U=
TC (rev 4161)
@@ -87,7 +87,7 @@
=20
     function insert_jrnx()
     {
-        if ( $this->poste =3D=3D "") return false;
+      if ( $this->poste =3D=3D "") { return false; throw new  Exception =
(__FILE__.':'.__LINE__.' Poste comptable vide');}
         /* for negative amount the operation is reversed */
         if ( $this->amount < 0 )
         {
@@ -109,7 +109,7 @@
                                      $this->periode, //$8
                                      $this->qcode, // $9
                                      $this->desc)); //$10
-        if ( $Res=3D=3Dfalse) return $Res;
+        if ( $Res=3D=3D=3Dfalse) return $Res;
         $this->jrnx_id=3D$this->db->get_current_seq('s_jrn_op');
         return $this->jrnx_id;
=20

Modified: phpcompta/trunk/include/class_database.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/class_database.php	2011-06-07 21:24:54 UTC (r=
ev 4160)
+++ phpcompta/trunk/include/class_database.php	2011-06-08 17:58:47 UTC (r=
ev 4161)
@@ -125,13 +125,21 @@
 	 =20
             $this->sql=3D$p_string;
             $this->array=3D$p_array;
-            if ( $p_array=3D=3Dnull )
+
+           if ( $p_array=3D=3Dnull )
             {
-	      $this->ret=3D@pg_query($this->db,$p_string);
+	      if ( ! DEBUG )=20
+		$this->ret=3Dpg_query($this->db,$p_string);
+	      else
+		$this->ret=3D@pg_query($this->db,$p_string);
             }
             else
             {
-                $this->ret=3D@pg_query_params($this->db,$p_string,$p_arr=
ay);
+	      if ( ! DEBUG )=20
+		$this->ret=3Dpg_query_params($this->db,$p_string,$p_array);
+	      else
+		$this->ret=3D@pg_query_params($this->db,$p_string,$p_array);
+
             }
             if ( ! $this->ret )
             {
@@ -274,7 +282,7 @@
             if ( $flag_function )
             {
                 if ( strpos(strtolower($buffer), "language plpgsql") =3D=
=3D=3D false &&
-                        strpos(strtolower($buffer), "language 'plpgsql'"=
) =3D=3D=3D false )
+                     strpos(strtolower($buffer), "language 'plpgsql'") =3D=
=3D=3D false )
                 {
                     $sql.=3D$buffer;
                     continue;
@@ -454,7 +462,12 @@
     {
         $this->ret=3D$this->exec_sql($p_sql,$p_array);
         if ( pg_NumRows($this->ret) =3D=3D 0 ) return "";
-        if ( pg_NumRows($this->ret) > 1 ) throw new Exception( "Attentio=
n $p_sql retourne plusieurs valeurs");
+        if ( pg_NumRows($this->ret) > 1 )
+	  {
+	    $array=3Dpg_fetch_all($this->ret);
+	    throw new Exception( "Attention $p_sql retourne ".pg_NumRows($this-=
>ret)."  valeurs ".
+			       var_export($p_array,true)." values=3D".var_export($array,true)=
);
+	  }
         $r=3Dpg_fetch_row($this->ret,0);
         return $r[0];
=20

Modified: phpcompta/trunk/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/constant.php	2011-06-07 21:24:54 UTC (rev 416=
0)
+++ phpcompta/trunk/include/constant.php	2011-06-08 17:58:47 UTC (rev 416=
1)
@@ -38,13 +38,11 @@
 $version_phpcompta=3DSVNINFO;=20
 define ("DEBUG",false);
=20
-/*
-define ("DEBUG",true);
-$version_phpcompta=3D4014;
-*/
+//define ("DEBUG",true);
+//$version_phpcompta=3D4014;
=20
=20
-define ("DBVERSION",94);
+define ("DBVERSION",95);
 define ("DBVERSIONREPO",13);
 define ('NOTFOUND','--not found--');
=20

Copied: phpcompta/trunk/sql/comptaproc.sql (from rev 4160, phpcompta/bran=
ches/rel560/sql/comptaproc.sql)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/sql/comptaproc.sql	                        (rev 0)
+++ phpcompta/trunk/sql/comptaproc.sql	2011-06-08 17:58:47 UTC (rev 4161)
@@ -0,0 +1,1972 @@
+--
+-- PostgreSQL database dump
+--
+
+SET statement_timeout =3D 0;
+SET client_encoding =3D 'UTF8';
+SET standard_conforming_strings =3D off;
+SET check_function_bodies =3D false;
+SET client_min_messages =3D warning;
+SET escape_string_warning =3D off;
+
+--
+-- Name: comptaproc; Type: SCHEMA; Schema: -; Owner: -
+--
+
+CREATE SCHEMA comptaproc;
+
+
+SET search_path =3D comptaproc, pg_catalog;
+
+--
+-- Name: account_add(public.account_type, character varying); Type: FUNC=
TION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION account_add(p_id public.account_type, p_name character v=
arying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	nCount integer;
+begin
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_id;
+	if nCount =3D 0 then
+		nParent=3Daccount_parent(p_id);
+		insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent)
+			values (p_id, p_name,nParent);
+	end if;
+return;
+end ;
+$$;
+
+
+--
+-- Name: account_auto(integer); Type: FUNCTION; Schema: comptaproc; Owne=
r: -
+--
+
+CREATE FUNCTION account_auto(p_fd_id integer) RETURNS boolean
+    LANGUAGE plpgsql
+    AS $$
+declare
+	l_auto bool;
+begin
+
+	select fd_create_account into l_auto from fiche_def where fd_id=3Dp_fd_=
id;
+	if l_auto is null then
+		l_auto:=3Dfalse;
+	end if;
+	return l_auto;
+end;
+$$;
+
+
+--
+-- Name: account_compute(integer); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION account_compute(p_f_id integer) RETURNS public.account_t=
ype
+    LANGUAGE plpgsql
+    AS $$
+declare
+	class_base fiche_def.fd_class_base%type;
+	maxcode numeric;
+	sResult account_type;
+begin
+	select fd_class_base into class_base
+	from
+		fiche_def join fiche using (fd_id)
+	where
+		f_id=3Dp_f_id;
+	raise notice 'account_compute class base %',class_base;
+	select count (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent =
=3D class_base;
+	if maxcode =3D 0	then
+		maxcode:=3Dclass_base::numeric;
+	else
+		select max (pcm_val) into maxcode from tmp_pcmn where pcm_val_parent =3D=
 class_base;
+		maxcode:=3Dmaxcode::numeric;
+	end if;
+	if maxcode::text =3D class_base then
+		maxcode:=3Dclass_base::numeric*1000;
+	end if;
+	maxcode:=3Dmaxcode+1;
+	raise notice 'account_compute Max code %',maxcode;
+	sResult:=3Dmaxcode::account_type;
+	return sResult;
+end;
+$$;
+
+
+--
+-- Name: account_insert(integer, text); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION account_insert(p_f_id integer, p_account text) RETURNS i=
nteger
+    LANGUAGE plpgsql
+    AS $_$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	nNew tmp_pcmn.pcm_val%type;
+	bAuto bool;
+	nFd_id integer;
+	sClass_Base fiche_def.fd_class_base%TYPE;
+	nCount integer;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+	-- if there is coma in p_account, treat normally
+		if position (',' in p_account) =3D 0 then
+			raise info 'p_account is not empty';
+				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
+				raise notice 'found in tmp_pcm %',nCount;
+				if nCount !=3D0  then
+					raise info 'this account exists in tmp_pcmn ';
+					perform attribut_insert(p_f_id,5,p_account);
+				   else
+				       -- account doesn't exist, create it
+					select ad_value into sName from
+						fiche_detail
+					where
+					ad_id=3D1 and f_id=3Dp_f_id;
+
+					nParent:=3Daccount_parent(p_account::account_type);
+					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
+					perform attribut_insert(p_f_id,5,p_account);
+
+				end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		perform attribut_insert(p_f_id,5,p_account);
+		end if;
+	else
+	raise info 'p_account is  empty';
+		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
+		bAuto:=3D account_auto(nFd_id);
+
+		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
+raise info 'sClass_Base : %',sClass_base;
+		if bAuto =3D true and sClass_base similar to '^[[:digit:]]*$'  then
+			raise info 'account generated automatically';
+			nNew:=3Daccount_compute(p_f_id);
+			raise info 'nNew %', nNew;
+			select ad_value into sName from
+				fiche_detail
+			where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(nNew);
+			perform account_add  (nNew,sName);
+			perform attribut_insert(p_f_id,5,nNew);
+
+		else
+		-- if there is an account_base then it is the default
+		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
+			if nNew is null or length(trim(nNew)) =3D 0 then
+				raise notice 'count is null';
+				 perform attribut_insert(p_f_id,5,null);
+			else
+				 perform attribut_insert(p_f_id,5,nNew);
+			end if;
+		end if;
+	end if;
+
+return 0;
+end;
+$_$;
+
+
+--
+-- Name: account_parent(public.account_type); Type: FUNCTION; Schema: co=
mptaproc; Owner: -
+--
+
+CREATE FUNCTION account_parent(p_account public.account_type) RETURNS pu=
blic.account_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	sSubParent tmp_pcmn.pcm_val_parent%type;
+	sResult tmp_pcmn.pcm_val_parent%type;
+	nCount integer;
+begin
+	if p_account is NULL then
+		return NULL;
+	end if;
+	sSubParent:=3Dp_account;
+	while true loop
+		select count(*) into nCount
+		from tmp_pcmn
+		where
+		pcm_val =3D sSubParent;
+		if nCount !=3D 0 then
+			sResult:=3D sSubParent;
+			exit;
+		end if;
+		sSubParent:=3D substr(sSubParent,1,length(sSubParent)-1);
+		if length(sSubParent) <=3D 0 then
+			raise exception 'Impossible de trouver le compte parent pour %',p_acc=
ount;
+		end if;
+		raise notice 'sSubParent % % ',sSubParent,length(sSubParent);
+	end loop;
+	raise notice 'account_parent : Parent is %',sSubParent;
+	return sSubParent;
+end;
+$$;
+
+
+--
+-- Name: account_update(integer, public.account_type); Type: FUNCTION; S=
chema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION account_update(p_f_id integer, p_account public.account_=
type) RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+declare
+	nMax fiche.f_id%type;
+	nCount integer;
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	first text;
+	second text;
+begin
+
+	if length(trim(p_account)) !=3D 0 then
+		if position (',' in p_account) =3D 0 then
+			select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_account;
+			if nCount =3D 0 then
+			select ad_value into sName from
+				fiche_detail
+				where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(p_account);
+			insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_accoun=
t,sName,nParent);
+			end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		end if;
+	end if;
+=09
+	update fiche_detail set ad_value=3Dp_account where f_id=3Dp_f_id and ad=
_id=3D5 ;
+
+return 0;
+end;
+$$;
+
+
+--
+-- Name: action_gestion_ins_upd(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION action_gestion_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+begin
+NEW.ag_title :=3D substr(trim(NEW.ag_title),1,70);
+NEW.ag_hour :=3D substr(trim(NEW.ag_hour),1,5);
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: action_get_tree(bigint); Type: FUNCTION; Schema: comptaproc; Ow=
ner: -
+--
+
+CREATE FUNCTION action_get_tree(p_id bigint) RETURNS SETOF bigint
+    LANGUAGE plpgsql
+    AS $$
+
+declare
+   e bigint;
+   i bigint;
+begin
+   for e in select ag_id from action_gestion where ag_ref_ag_id=3Dp_id
+   loop
+        for i in select action_get_tree from  comptaproc.action_get_tree=
(e)
+        loop
+                raise notice ' =3D=3D i %', i;
+                return next i;
+        end loop;
+    raise notice ' =3D e %', e;
+    return next e;
+   end loop;
+   return;
+
+end;
+$$;
+
+
+--
+-- Name: attribut_insert(integer, integer, character varying); Type: FUN=
CTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION attribut_insert(p_f_id integer, p_ad_id integer, p_value=
 character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+begin
+	insert into fiche_detail (f_id,ad_id, ad_value) values (p_f_id,p_ad_id,=
p_value);
+=09
+return;
+end;
+$$;
+
+
+--
+-- Name: attribute_correct_order(); Type: FUNCTION; Schema: comptaproc; =
Owner: -
+--
+
+CREATE FUNCTION attribute_correct_order() RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+    crs_correct cursor for select A.jnt_id,A.jnt_order from jnt_fic_attr=
 as A join jnt_fic_attr as B using (fd_id) where A.jnt_order=3DB.jnt_orde=
r and A.jnt_id > B.jnt_id;
+    rec record;
+begin
+	open crs_correct;
+	loop
+	fetch crs_correct into rec;
+	if NOT FOUND then
+		close crs_correct;
+		return;
+	end if;
+	update jnt_fic_attr set jnt_order=3Djnt_order + 1 where jnt_id =3D rec.=
jnt_id;
+	end loop;
+	close crs_correct;
+	perform attribute_correct_order ();
+end;
+$$;
+
+
+--
+-- Name: card_after_delete(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION card_after_delete() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+
+begin
+
+	delete from action_gestion where f_id_dest =3D OLD.f_id;
+	return OLD;
+
+end;
+$$;
+
+
+--
+-- Name: card_class_base(integer); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION card_class_base(p_f_id integer) RETURNS text
+    LANGUAGE plpgsql
+    AS $$
+declare
+	n_poste fiche_def.fd_class_base%type;
+begin
+
+	select fd_class_base into n_poste from fiche_def join fiche using
+(fd_id)
+	where f_id=3Dp_f_id;
+	if not FOUND then
+		raise exception 'Invalid fiche card_class_base(%)',p_f_id;
+	end if;
+return n_poste;
+end;
+$$;
+
+
+--
+-- Name: check_balance(integer); Type: FUNCTION; Schema: comptaproc; Own=
er: -
+--
+
+CREATE FUNCTION check_balance(p_grpt integer) RETURNS numeric
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	amount_jrnx_debit numeric;
+	amount_jrnx_credit numeric;
+	amount_jrn numeric;
+begin
+	select sum (j_montant) into amount_jrnx_credit=20
+	from jrnx=20
+		where=20
+	j_grpt=3Dp_grpt
+	and j_debit=3Dfalse;
+
+	select sum (j_montant) into amount_jrnx_debit=20
+	from jrnx=20
+		where=20
+	j_grpt=3Dp_grpt
+	and j_debit=3Dtrue;
+
+	select jr_montant into amount_jrn=20
+	from jrn
+	where
+	jr_grpt_id=3Dp_grpt;
+
+	if ( amount_jrnx_debit !=3D amount_jrnx_credit )=20
+		then
+		return abs(amount_jrnx_debit-amount_jrnx_credit);
+		end if;
+	if ( amount_jrn !=3D amount_jrnx_credit)
+		then
+		return -1*abs(amount_jrn - amount_jrnx_credit);
+		end if;
+	return 0;
+end;
+$$;
+
+
+--
+-- Name: correct_sequence(text, text, text); Type: FUNCTION; Schema: com=
ptaproc; Owner: -
+--
+
+CREATE FUNCTION correct_sequence(p_sequence text, p_col text, p_table te=
xt) RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+declare
+last_sequence int8;
+max_sequence int8;
+n integer;
+begin
+	select count(*) into n from pg_class where relkind=3D'S' and relname=3D=
lower(p_sequence);
+	if n =3D 0 then
+		raise exception  ' Unknow sequence  % ',p_sequence;
+	end if;
+	select count(*) into n from pg_class where relkind=3D'r' and relname=3D=
lower(p_table);
+	if n =3D 0 then
+		raise exception ' Unknow table  % ',p_table;
+	end if;
+
+	execute 'select last_value   from '||p_sequence into last_sequence;
+	raise notice 'Last value of the sequence is %', last_sequence;
+
+	execute 'select max('||p_col||')  from '||p_table into max_sequence;
+	if  max_sequence is null then
+		max_sequence :=3D 0;
+	end if;
+	raise notice 'Max value of the sequence is %', max_sequence;
+	max_sequence:=3D max_sequence +1;=09
+	execute 'alter sequence '||p_sequence||' restart with '||max_sequence;
+return 0;
+
+end;
+$$;
+
+
+--
+-- Name: FUNCTION correct_sequence(p_sequence text, p_col text, p_table =
text); Type: COMMENT; Schema: comptaproc; Owner: -
+--
+
+COMMENT ON FUNCTION correct_sequence(p_sequence text, p_col text, p_tabl=
e text) IS ' Often the primary key is a sequence number and sometimes the=
 value of the sequence is not synchronized with the primary key ( p_seque=
nce : sequence name, p_col : col of the pk,p_table : concerned table';
+
+
+--
+-- Name: create_missing_sequence(); Type: FUNCTION; Schema: comptaproc; =
Owner: -
+--
+
+CREATE FUNCTION create_missing_sequence() RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+declare
+p_sequence text;
+nSeq integer;
+c1 cursor for select jrn_def_id from jrn_def;
+begin
+	open c1;
+	loop
+	   fetch c1 into nSeq;
+	   if not FOUND THEN
+	   	close c1;
+	   	return 0;
+	   end if;
+	   p_sequence:=3D's_jrn_pj'||nSeq::text;
+	execute 'create sequence '||p_sequence;
+	end loop;
+close c1;
+return 0;
+
+end;
+$$;
+
+
+--
+-- Name: drop_index(character varying); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION drop_index(p_constraint character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	nCount integer;
+begin
+	select count(*) into nCount from pg_indexes where indexname=3Dp_constra=
int;
+	if nCount =3D 1 then
+	execute 'drop index '||p_constraint ;
+	end if;
+end;
+$$;
+
+
+--
+-- Name: drop_it(character varying); Type: FUNCTION; Schema: comptaproc;=
 Owner: -
+--
+
+CREATE FUNCTION drop_it(p_constraint character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	nCount integer;
+begin
+	select count(*) into nCount from pg_constraint where conname=3Dp_constr=
aint;
+	if nCount =3D 1 then
+	execute 'alter table parm_periode drop constraint '||p_constraint ;
+	end if;
+end;
+$$;
+
+
+--
+-- Name: extension_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION extension_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+ sCode text;
+ sFile text;
+begin
+sCode:=3Dtrim(upper(NEW.ex_code));
+sCode:=3Dreplace(sCode,' ','_');
+sCode:=3Dsubstr(sCode,1,15);
+sCode=3Dupper(sCode);
+NEW.ex_code:=3DsCode;
+sFile:=3DNEW.ex_file;
+sFile:=3Dreplace(sFile,';','_');
+sFile:=3Dreplace(sFile,'<','_');
+sFile:=3Dreplace(sFile,'>','_');
+sFile:=3Dreplace(sFile,'..','');
+sFile:=3Dreplace(sFile,'&','');
+sFile:=3Dreplace(sFile,'|','');
+
+
+
+return NEW;
+
+end;
+
+$$;
+
+
+--
+-- Name: fiche_account_parent(integer); Type: FUNCTION; Schema: comptapr=
oc; Owner: -
+--
+
+CREATE FUNCTION fiche_account_parent(p_f_id integer) RETURNS public.acco=
unt_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+ret tmp_pcmn.pcm_val%TYPE;
+begin
+	select fd_class_base into ret from fiche_def join fiche using (fd_id) w=
here f_id=3Dp_f_id;
+	if not FOUND then
+		raise exception '% N''existe pas',p_f_id;
+	end if;
+	return ret;
+end;
+$$;
+
+
+--
+-- Name: fiche_attribut_synchro(integer); Type: FUNCTION; Schema: compta=
proc; Owner: -
+--
+
+CREATE FUNCTION fiche_attribut_synchro(p_fd_id integer) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	-- this sql gives the f_id and the missing attribute (ad_id)
+	list_missing cursor for select f_id,fd_id,ad_id,jnt_order from jnt_fic_=
attr join fiche as A using (fd_id) where fd_id=3Dp_fd_id and ad_id not in=
 (select ad_id from fiche join fiche_detail using (f_id) where fd_id=3Djn=
t_fic_attr.fd_id and A.f_id=3Df_id);
+	rec record;
+begin
+	open list_missing;
+	loop
+=09
+	fetch list_missing into rec;
+	IF NOT FOUND then
+		exit;
+	end if;
+=09
+	-- now we insert into attr_value
+	insert into fiche_detail (f_id,ad_id,ad_value) values (rec.f_id,rec.ad_=
id,null);
+	end loop;
+	close list_missing;
+end;=20
+$$;
+
+
+--
+-- Name: fiche_def_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION fiche_def_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+begin
+
+if position (',' in NEW.fd_class_base) !=3D 0 then
+   NEW.fd_create_account=3D'f';
+
+end if;
+return NEW;
+end;$$;
+
+
+--
+-- Name: fill_quant_fin(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION fill_quant_fin() RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+   sBank text;
+   sCassa text;
+   sCustomer text;
+   sSupplier text;
+   rec record;
+   recBank record;
+   recSupp_Cust record;
+   nCount integer;
+   nAmount numeric;
+   nBank integer;
+   nOther integer;
+   nSupp_Cust integer;
+begin
+	select p_value into sBank from parm_code where p_code=3D'BANQUE';
+	select p_value into sCassa from parm_code where p_code=3D'CAISSE';
+	select p_value into sSupplier from parm_code where p_code=3D'SUPPLIER';
+	select p_value into sCustomer from parm_code where p_code=3D'CUSTOMER';
+=09
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN')
+		and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nBank :=3D 0; nOther:=3D0;
+		for recBank in select  j_id, j_montant,j_debit,j_qcode,j_poste from jr=
nx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recBank.j_poste like sBank||'%' then
+			-- retrieve f_id for bank
+			select f_id into nBank from vw_poste_qcode where j_qcode=3DrecBank.j_=
qcode;
+			if recBank.j_debit =3D false then
+				nAmount=3DrecBank.j_montant*(-1);
+			else=20
+				nAmount=3DrecBank.j_montant;
+			end if;
+		else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecBank.j=
_qcode;
+		end if;
+		end loop;
+		if nBank !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nBank,nOther,nAmount);
+		end if;
+	end loop;
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN') and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nBank :=3D 0; nOther:=3D0;
+		for recBank in select  j_id, j_montant,j_debit,j_qcode,j_poste from jr=
nx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recBank.j_poste like sCassa||'%' then
+			-- retrieve f_id for bank
+			select f_id into nBank from vw_poste_qcode where j_qcode=3DrecBank.j_=
qcode;
+			if recBank.j_debit =3D false then
+				nAmount=3DrecBank.j_montant*(-1);
+			else=20
+				nAmount=3DrecBank.j_montant;
+			end if;
+		else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecBank.j=
_qcode;
+		end if;
+		end loop;
+		if nBank !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nBank,nOther,nAmount);
+		end if;
+	end loop;
+
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN') and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nSupp_Cust :=3D 0; nOther:=3D0;
+		for recSupp_Cust in select  j_id, j_montant,j_debit,j_qcode,j_poste fr=
om jrnx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recSupp_Cust.j_poste like sSupplier||'%'  then
+			-- retrieve f_id for bank
+			select f_id into nSupp_Cust from vw_poste_qcode where j_qcode=3DrecSu=
pp_Cust.j_qcode;
+			if recSupp_Cust.j_debit =3D true then
+				nAmount=3DrecSupp_Cust.j_montant*(-1);
+			else=20
+				nAmount=3DrecSupp_Cust.j_montant;
+			end if;
+		else if  recSupp_Cust.j_poste like sCustomer||'%' then
+			select f_id into nSupp_Cust from vw_poste_qcode where j_qcode=3DrecSu=
pp_Cust.j_qcode;
+			if recSupp_Cust.j_debit =3D false then
+				nAmount=3DrecSupp_Cust.j_montant*(-1);
+			else=20
+				nAmount=3DrecSupp_Cust.j_montant;
+			end if;
+			else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecSupp_C=
ust.j_qcode;
+		=09
+			end if;
+		end if;
+		end loop;
+		if nSupp_Cust !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nOther,nSupp_Cust,nAmount);
+		end if;
+	end loop;
+	for rec in select jr_id,jr_grpt_id from jrn=20
+	    where jr_def_id in (select jrn_def_id from jrn_def where jrn_def_ty=
pe=3D'FIN') and jr_id not in (select jr_id from quant_fin)
+	loop
+		-- there are only 2 lines for bank operations
+		-- first debit
+		select count(j_id) into nCount from jrnx where j_grpt=3Drec.jr_grpt_id=
;
+		if nCount > 2 then=20
+			raise notice 'Trop de valeur pour jr_grpt_id % count %',rec.jr_grpt_i=
d,nCount;
+			return;
+		end if;
+		nSupp_Cust :=3D 0; nOther:=3D0;
+		for recSupp_Cust in select  j_id, j_montant,j_debit,j_qcode,j_poste fr=
om jrnx where j_grpt=3Drec.jr_grpt_id
+		loop
+		if recSupp_Cust.j_poste like '441%'  then
+			-- retrieve f_id for bank
+			select f_id into nSupp_Cust from vw_poste_qcode where j_qcode=3DrecSu=
pp_Cust.j_qcode;
+			if recSupp_Cust.j_debit =3D false then
+				nAmount=3DrecSupp_Cust.j_montant*(-1);
+			else=20
+				nAmount=3DrecSupp_Cust.j_montant;
+			end if;
+			else
+			select f_id into nOther from vw_poste_qcode where j_qcode=3DrecSupp_C=
ust.j_qcode;
+		=09
+		=09
+		end if;
+		end loop;
+		if nSupp_Cust !=3D 0 and nOther !=3D 0 then
+			insert into quant_fin (jr_id,qf_bank,qf_other,qf_amount) values (rec.=
jr_id,nOther,nSupp_Cust,nAmount);
+		end if;
+	end loop;
+	return;
+end;
+$$;
+
+
+--
+-- Name: find_pcm_type(public.account_type); Type: FUNCTION; Schema: com=
ptaproc; Owner: -
+--
+
+CREATE FUNCTION find_pcm_type(pp_value public.account_type) RETURNS text
+    LANGUAGE plpgsql
+    AS $$
+declare
+	str_type parm_poste.p_type%TYPE;
+	str_value parm_poste.p_type%TYPE;
+	nLength integer;
+begin
+	str_value:=3Dpp_value;
+	nLength:=3Dlength(str_value::text);
+	while nLength > 0 loop
+		select p_type into str_type from parm_poste where p_value=3Dstr_value;
+		if FOUND then
+			return str_type;
+		end if;
+		nLength:=3DnLength-1;
+		str_value:=3Dsubstring(str_value::text from 1 for nLength)::account_ty=
pe;
+	end loop;
+return 'CON';
+end;
+$$;
+
+
+--
+-- Name: find_periode(text); Type: FUNCTION; Schema: comptaproc; Owner: =
-
+--
+
+CREATE FUNCTION find_periode(p_date text) RETURNS integer
+    LANGUAGE plpgsql
+    AS $$
+
+declare n_p_id int4;
+begin
+
+select p_id into n_p_id
+	from parm_periode
+	where
+		p_start <=3D to_date(p_date,'DD.MM.YYYY')
+		and
+		p_end >=3D to_date(p_date,'DD.MM.YYYY');
+
+if NOT FOUND then
+	return -1;
+end if;
+
+return n_p_id;
+
+end;$$;
+
+
+--
+-- Name: get_letter_jnt(bigint); Type: FUNCTION; Schema: comptaproc; Own=
er: -
+--
+
+CREATE FUNCTION get_letter_jnt(a bigint) RETURNS bigint
+    LANGUAGE plpgsql
+    AS $$
+declare
+ nResult bigint;
+begin
+   select jl_id into nResult from jnt_letter join letter_deb using (jl_i=
d) where j_id =3D a;
+   if NOT FOUND then
+	select jl_id into nResult from jnt_letter join letter_cred using (jl_id=
) where j_id =3D a;
+	if NOT found then
+		return null;
+	end if;
+    end if;
+return nResult;
+end;
+$$;
+
+
+--
+-- Name: get_pcm_tree(public.account_type); Type: FUNCTION; Schema: comp=
taproc; Owner: -
+--
+
+CREATE FUNCTION get_pcm_tree(source public.account_type) RETURNS SETOF p=
ublic.account_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	i account_type;
+	e account_type;
+begin
+	for i in select pcm_val from tmp_pcmn where pcm_val_parent=3Dsource
+	loop
+		return next i;
+		for e in select get_pcm_tree from get_pcm_tree(i)
+		loop
+			return next e;
+		end loop;
+
+	end loop;
+	return;
+end;
+$$;
+
+
+--
+-- Name: group_analytic_ins_upd(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION group_analytic_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+name text;
+begin
+name:=3Dupper(NEW.ga_id);
+name:=3Dtrim(name);
+name:=3Dreplace(name,' ','');
+NEW.ga_id:=3Dname;
+return NEW;
+end;$$;
+
+
+--
+-- Name: group_analytique_del(); Type: FUNCTION; Schema: comptaproc; Own=
er: -
+--
+
+CREATE FUNCTION group_analytique_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+begin
+update poste_analytique set ga_id=3Dnull
+where ga_id=3DOLD.ga_id;
+return OLD;
+end;$$;
+
+
+--
+-- Name: html_quote(text); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION html_quote(p_string text) RETURNS text
+    LANGUAGE plpgsql
+    AS $$
+declare
+	r text;
+begin
+	r:=3Dp_string;
+	r:=3Dreplace(r,'<','&lt;');
+	r:=3Dreplace(r,'>','&gt;');
+	r:=3Dreplace(r,'''','&quot;');
+	return r;
+end;$$;
+
+
+--
+-- Name: FUNCTION html_quote(p_string text); Type: COMMENT; Schema: comp=
taproc; Owner: -
+--
+
+COMMENT ON FUNCTION html_quote(p_string text) IS 'remove harmfull HTML c=
har';
+
+
+--
+-- Name: info_def_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner: =
-
+--
+
+CREATE FUNCTION info_def_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	row_info_def info_def%ROWTYPE;
+	str_type text;
+begin
+row_info_def:=3DNEW;
+str_type:=3Dupper(trim(NEW.id_type));
+str_type:=3Dreplace(str_type,' ','');
+str_type:=3Dreplace(str_type,',','');
+str_type:=3Dreplace(str_type,';','');
+if  length(str_type) =3D0 then
+	raise exception 'id_type cannot be null';
+end if;
+row_info_def.id_type:=3Dstr_type;
+return row_info_def;
+end;
+$$;
+
+
+--
+-- Name: insert_jrnx(character varying, numeric, public.account_type, in=
teger, integer, boolean, text, integer, text, text); Type: FUNCTION; Sche=
ma: comptaproc; Owner: -
+--
+
+CREATE FUNCTION insert_jrnx(p_date character varying, p_montant numeric,=
 p_poste public.account_type, p_grpt integer, p_jrn_def integer, p_debit =
boolean, p_tech_user text, p_tech_per integer, p_qcode text, p_comment te=
xt) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+begin
+	insert into jrnx
+	(
+		j_date,
+		j_montant,
+		j_poste,
+		j_grpt,
+		j_jrn_def,
+		j_debit,
+		j_text,
+		j_tech_user,
+		j_tech_per,
+		j_qcode
+	) values
+	(
+		to_date(p_date,'DD.MM.YYYY'),
+		p_montant,
+		p_poste,
+		p_grpt,
+		p_jrn_def,
+		p_debit,
+		p_comment,
+		p_tech_user,
+		p_tech_per,
+		p_qcode
+	);
+
+return;
+end;
+$$;
+
+
+--
+-- Name: insert_quant_purchase(text, numeric, character varying, numeric=
, numeric, numeric, integer, numeric, numeric, numeric, numeric, characte=
r varying); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION insert_quant_purchase(p_internal text, p_j_id numeric, p=
_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric=
, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_rec=
up numeric, p_dep_priv numeric, p_client character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	fid_client integer;
+	fid_good   integer;
+begin
+	select f_id into fid_client from
+		fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_client));
+	select f_id into fid_good from
+		 fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_fiche));
+	insert into quant_purchase
+		(qp_internal,
+		j_id,
+		qp_fiche,
+		qp_quantite,
+		qp_price,
+		qp_vat,
+		qp_vat_code,
+		qp_nd_amount,
+		qp_nd_tva,
+		qp_nd_tva_recup,
+		qp_supplier,
+		qp_dep_priv)
+	values
+		(p_internal,
+		p_j_id,
+		fid_good,
+		p_quant,
+		p_price,
+		p_vat,
+		p_vat_code,
+		p_nd_amount,
+		p_nd_tva,
+		p_nd_tva_recup,
+		fid_client,
+		p_dep_priv);
+	return;
+end;
+ $$;
+
+
+--
+-- Name: insert_quant_sold(text, numeric, character varying, numeric, nu=
meric, numeric, integer, character varying); Type: FUNCTION; Schema: comp=
taproc; Owner: -
+--
+
+CREATE FUNCTION insert_quant_sold(p_internal text, p_jid numeric, p_fich=
e character varying, p_quant numeric, p_price numeric, p_vat numeric, p_v=
at_code integer, p_client character varying) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	fid_client integer;
+	fid_good   integer;
+begin
+
+	select f_id into fid_client from
+		fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_client));
+	select f_id into fid_good from
+		fiche_detail where ad_id=3D23 and ad_value=3Dupper(trim(p_fiche));
+	insert into quant_sold
+		(qs_internal,j_id,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_=
client,qs_valid)
+	values
+		(p_internal,p_jid,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client=
,'Y');
+	return;
+end;
+ $$;
+
+
+--
+-- Name: insert_quick_code(integer, text); Type: FUNCTION; Schema: compt=
aproc; Owner: -
+--
+
+CREATE FUNCTION insert_quick_code(nf_id integer, tav_text text) RETURNS =
integer
+    LANGUAGE plpgsql
+    AS $$
+	declare
+	ns integer;
+	nExist integer;
+	tText text;
+	begin
+	tText :=3D upper(trim(tav_text));
+	tText :=3D replace(tText,' ','');
+=09
+	loop
+		-- take the next sequence
+		select nextval('s_jnt_fic_att_value') into ns;
+		if length (tText) =3D 0 or tText is null then
+			tText :=3D 'FID'||ns;
+		end if;
+		-- av_text already used ?
+		select count(*) into nExist=20
+			from fiche_detail
+		where=20
+			ad_id=3D23 and  ad_value=3Dupper(tText);
+
+		if nExist =3D 0 then
+			exit;
+		end if;
+		tText:=3D'FID'||ns;
+	end loop;
+
+
+	insert into fiche_detail(jft_id,f_id,ad_id,ad_value) values (ns,nf_id,2=
3,upper(tText));
+	return ns;
+	end;
+$$;
+
+
+--
+-- Name: is_closed(integer, integer); Type: FUNCTION; Schema: comptaproc=
; Owner: -
+--
+
+CREATE FUNCTION is_closed(p_periode integer, p_jrn_def_id integer) RETUR=
NS boolean
+    LANGUAGE plpgsql
+    AS $$
+declare
+bClosed bool;
+str_status text;
+begin
+select p_closed into bClosed from parm_periode
+	where p_id=3Dp_periode;
+
+if bClosed =3D true then
+	return bClosed;
+end if;
+
+select status into str_status from jrn_periode
+       where p_id =3Dp_periode and jrn_def_id=3Dp_jrn_def_id;
+
+if str_status <> 'OP' then
+   return bClosed;
+end if;
+return false;
+end;
+$$;
+
+
+--
+-- Name: jnt_fic_attr_ins(); Type: FUNCTION; Schema: comptaproc; Owner: =
-
+--
+
+CREATE FUNCTION jnt_fic_attr_ins() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+   r_record jnt_fic_attr%ROWTYPE;
+   i_max integer;
+begin
+r_record=3DNEW;
+perform comptaproc.fiche_attribut_synchro(r_record.fd_id);
+select coalesce(max(jnt_order),0) into i_max from jnt_fic_attr where fd_=
id=3Dr_record.fd_id;
+i_max :=3D i_max + 10;
+NEW.jnt_order=3Di_max;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: jrn_add_note(bigint, text); Type: FUNCTION; Schema: comptaproc;=
 Owner: -
+--
+
+CREATE FUNCTION jrn_add_note(p_jrid bigint, p_note text) RETURNS void
+    LANGUAGE plpgsql
+    AS $$
+declare
+	tmp bigint;
+begin
+	if length(trim(p_note)) =3D 0 then
+	   delete from jrn_note where jr_id=3D p_jrid;
+	   return;
+	end if;
+=09
+	select n_id into tmp from jrn_note where jr_id =3D p_jrid;
+=09
+	if FOUND then
+	   update jrn_note set n_text=3Dtrim(p_note) where jr_id =3D p_jrid;
+	else=20
+	   insert into jrn_note (jr_id,n_text) values ( p_jrid, p_note);
+
+	end if;
+=09
+	return;
+end;
+$$;
+
+
+--
+-- Name: jrn_check_periode(); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION jrn_check_periode() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+bClosed bool;
+str_status text;
+ljr_tech_per jrn.jr_tech_per%TYPE;
+ljr_def_id jrn.jr_def_id%TYPE;
+lreturn jrn%ROWTYPE;
+begin
+if TG_OP=3D'UPDATE' then
+	ljr_tech_per :=3DOLD.jr_tech_per ;
+	NEW.jr_tech_per :=3D comptaproc.find_periode(to_char(NEW.jr_date,'DD.MM=
.YYYY'));
+	ljr_def_id   :=3DOLD.jr_def_id;
+	lreturn      :=3DNEW;
+	if NEW.jr_date =3D OLD.jr_date then
+		return NEW;
+	end if;
+	if comptaproc.is_closed(NEW.jr_tech_per,NEW.jr_def_id) =3D true then
+	      	raise exception 'Periode fermee';
+	end if;
+end if;
+
+if TG_OP=3D'INSERT' then
+	NEW.jr_tech_per :=3D comptaproc.find_periode(to_char(NEW.jr_date,'DD.MM=
.YYYY'));
+	ljr_tech_per :=3DNEW.jr_tech_per ;
+	ljr_def_id   :=3DNEW.jr_def_id;
+	lreturn      :=3DNEW;
+end if;
+
+if TG_OP=3D'DELETE' then
+	ljr_tech_per :=3DOLD.jr_tech_per;
+	ljr_def_id   :=3DOLD.jr_def_id;
+	lreturn      :=3DOLD;
+end if;
+
+if comptaproc.is_closed (ljr_def_id,ljr_def_id) =3D true then
+   	raise exception 'Periode fermee';
+end if;
+
+return lreturn;
+end;$$;
+
+
+--
+-- Name: jrn_def_add(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrn_def_add() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$begin
+execute 'insert into jrn_periode(p_id,jrn_def_id,status) select p_id,'||=
NEW.jrn_def_id||',
+	case when p_central=3Dtrue then ''CE''
+	      when p_closed=3Dtrue then ''CL''
+	else ''OP''
+	end
+from
+parm_periode ';
+return NEW;
+end;$$;
+
+
+--
+-- Name: jrn_def_delete(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrn_def_delete() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+nb numeric;
+begin
+select count(*) into nb from jrn where jr_def_id=3DOLD.jrn_def_id;
+
+if nb <> 0 then
+	raise exception 'EFFACEMENT INTERDIT: JOURNAL UTILISE';
+end if;
+return OLD;
+end;$$;
+
+
+--
+-- Name: jrn_del(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrn_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+row jrn%ROWTYPE;
+begin
+row:=3DOLD;
+insert into del_jrn ( jr_id,
+       jr_def_id,
+       jr_montant,
+       jr_comment,
+       jr_date,
+       jr_grpt_id,
+       jr_internal,
+       jr_tech_date,
+       jr_tech_per,
+       jrn_ech,
+       jr_ech,
+       jr_rapt,
+       jr_valid,
+       jr_opid,
+       jr_c_opid,
+       jr_pj,
+       jr_pj_name,
+       jr_pj_type,
+       jr_pj_number,
+       del_jrn_date)=20
+       select  jr_id,
+	      jr_def_id,
+	      jr_montant,
+	      jr_comment,
+	      jr_date,
+	      jr_grpt_id,
+	      jr_internal,
+	      jr_tech_date,
+	      jr_tech_per,
+	      jrn_ech,
+	      jr_ech,
+	      jr_rapt,
+	      jr_valid,
+	      jr_opid,
+	      jr_c_opid,
+	      jr_pj,
+	      jr_pj_name,
+	      jr_pj_type,
+	      jr_pj_number
+	      ,now() from jrn where jr_id=3Drow.jr_id;
+return row;
+end;
+$$;
+
+
+--
+-- Name: jrnx_del(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrnx_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+row jrnx%ROWTYPE;
+begin
+row:=3DOLD;
+
+
+insert into del_jrnx(
+            j_id, j_date, j_montant, j_poste, j_grpt, j_rapt, j_jrn_def,=
=20
+            j_debit, j_text, j_centralized, j_internal, j_tech_user, j_t=
ech_date,=20
+            j_tech_per, j_qcode, f_id)  SELECT j_id, j_date, j_montant, =
j_poste, j_grpt, j_rapt, j_jrn_def,=20
+       j_debit, j_text, j_centralized, j_internal, j_tech_user, j_tech_d=
ate,=20
+       j_tech_per, j_qcode, f_id from jrnx where j_id=3Drow.j_id;
+return row;
+end;
+$$;
+
+
+--
+-- Name: jrnx_ins(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrnx_ins() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+n_fid bigint;
+begin
+
+NEW.j_tech_per :=3D comptaproc.find_periode(to_char(NEW.j_date,'DD.MM.YY=
YY'));
+if NEW.j_tech_per =3D -1 then
+	raise exception 'P=C3=A9riode invalide';
+end if;
+
+if NEW.j_qcode is NULL then
+   return NEW;
+end if;
+
+NEW.j_qcode=3Dtrim(upper(NEW.j_qcode));
+
+if length (NEW.j_qcode) =3D 0 then
+    NEW.j_qcode=3DNULL;
+    else
+   select f_id into n_fid from fiche_detail  where ad_id=3D23 and ad_val=
ue=3DNEW.j_qcode;
+	if NOT FOUND then
+		raise exception 'La fiche dont le quick code est % n''existe pas',NEW.=
j_qcode;
+	end if;
+end if;
+NEW.f_id:=3Dn_fid;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: jrnx_letter_del(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION jrnx_letter_del() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+row jrnx%ROWTYPE;
+begin
+row:=3DOLD;
+delete from jnt_letter=20
+	where (jl_id in (select jl_id from letter_deb) and jl_id not in(select =
jl_id from letter_cred ))=20
+		or (jl_id not in (select jl_id from letter_deb  ) and jl_id  in(select=
 jl_id from letter_cred ));
+return row;
+end;
+$$;
+
+
+--
+-- Name: plan_analytic_ins_upd(); Type: FUNCTION; Schema: comptaproc; Ow=
ner: -
+--
+
+CREATE FUNCTION plan_analytic_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+   name text;
+begin
+   name:=3Dupper(NEW.pa_name);
+   name:=3Dtrim(name);
+   name:=3Dreplace(name,' ','');
+   NEW.pa_name:=3Dname;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: poste_analytique_ins_upd(); Type: FUNCTION; Schema: comptaproc;=
 Owner: -
+--
+
+CREATE FUNCTION poste_analytique_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$declare
+name text;
+rCount record;
+
+begin
+name:=3Dupper(NEW.po_name);
+name:=3Dtrim(name);
+name:=3Dreplace(name,' ','');	=09
+NEW.po_name:=3Dname;
+
+if NEW.ga_id is NULL then
+return NEW;
+end if;
+
+if length(trim(NEW.ga_id)) =3D 0 then
+  NEW.ga_id:=3DNULL;
+  return NEW;
+end if;
+perform 'select ga_id from groupe_analytique where ga_id=3D'||NEW.ga_id;
+if NOT FOUND then
+   raise exception' Inexistent Group Analytic %',NEW.ga_id;
+end if;
+return NEW;
+end;$$;
+
+
+--
+-- Name: proc_check_balance(); Type: FUNCTION; Schema: comptaproc; Owner=
: -
+--
+
+CREATE FUNCTION proc_check_balance() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+	diff numeric;
+	tt integer;
+begin
+	if TG_OP =3D 'INSERT' or TG_OP=3D'UPDATE' then
+	tt=3DNEW.jr_grpt_id;
+	diff:=3Dcheck_balance(tt);
+	if diff !=3D 0 then
+		raise exception 'balance error %',diff ;
+	end if;
+	return NEW;
+	end if;
+end;
+$$;
+
+
+--
+-- Name: quant_purchase_ins_upd(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION quant_purchase_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+	begin
+		if NEW.qp_price < 0 OR NEW.qp_quantite <0 THEN
+			NEW.qp_price :=3D abs (NEW.qp_price)*(-1);
+			NEW.qp_quantite :=3D abs (NEW.qp_quantite)*(-1);
+		end if;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: quant_sold_ins_upd(); Type: FUNCTION; Schema: comptaproc; Owner=
: -
+--
+
+CREATE FUNCTION quant_sold_ins_upd() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+	begin
+		if NEW.qs_price < 0 OR NEW.qs_quantite <0 THEN
+			NEW.qs_price :=3D abs (NEW.qs_price)*(-1);
+			NEW.qs_quantite :=3D abs (NEW.qs_quantite)*(-1);
+		end if;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: t_document_modele_validate(); Type: FUNCTION; Schema: comptapro=
c; Owner: -
+--
+
+CREATE FUNCTION t_document_modele_validate() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare=20
+    lText text;
+    modified document_modele%ROWTYPE;
+begin
+    modified:=3DNEW;
+
+	modified.md_filename:=3Dreplace(NEW.md_filename,' ','_');
+	return modified;
+end;
+$$;
+
+
+--
+-- Name: t_document_type_insert(); Type: FUNCTION; Schema: comptaproc; O=
wner: -
+--
+
+CREATE FUNCTION t_document_type_insert() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+nCounter integer;
+    BEGIN
+select count(*) into nCounter from pg_class where relname=3D'seq_doc_typ=
e_'||NEW.dt_id;
+if nCounter =3D 0 then
+        execute  'create sequence seq_doc_type_'||NEW.dt_id;
+end if;
+        RETURN NEW;
+    END;
+$$;
+
+
+--
+-- Name: t_document_validate(); Type: FUNCTION; Schema: comptaproc; Owne=
r: -
+--
+
+CREATE FUNCTION t_document_validate() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+  lText text;
+  modified document%ROWTYPE;
+begin
+    	modified:=3DNEW;
+	modified.d_filename:=3Dreplace(NEW.d_filename,' ','_');
+	return modified;
+end;
+$$;
+
+
+--
+-- Name: t_jrn_def_sequence(); Type: FUNCTION; Schema: comptaproc; Owner=
: -
+--
+
+CREATE FUNCTION t_jrn_def_sequence() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+nCounter integer;
+
+    BEGIN
+    select count(*) into nCounter=20
+       from pg_class where relname=3D's_jrn_'||NEW.jrn_def_id;
+       if nCounter =3D 0 then
+       	   execute  'create sequence s_jrn_'||NEW.jrn_def_id;
+	   raise notice 'Creating sequence s_jrn_%',NEW.jrn_def_id;
+	 end if;
+
+        RETURN NEW;
+    END;
+$$;
+
+
+--
+-- Name: table_analytic_account(text, text); Type: FUNCTION; Schema: com=
ptaproc; Owner: -
+--
+
+CREATE FUNCTION table_analytic_account(p_from text, p_to text) RETURNS S=
ETOF public.anc_table_account_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	ret ANC_table_account_type%ROWTYPE;
+	sql_from text:=3D'';
+	sql_to text:=3D'';
+	sWhere text:=3D'';
+	sAnd text:=3D'';
+	sResult text:=3D'';
+begin
+if p_from <> '' and p_from is not null then
+	sql_from:=3D'oa_date >=3D to_date('''||p_from::text||''',''DD.MM.YYYY''=
)';
+	sWhere:=3D' where ';
+end if;
+
+if p_to <> '' and p_to is not null then
+	sql_to=3D' oa_date <=3D to_date('''||p_to::text||''',''DD.MM.YYYY'')';
+	sWhere :=3D ' where ';
+end if;
+
+if sql_to <> '' and sql_from <> '' then
+	sAnd:=3D' and ';
+end if;
+
+sResult :=3D sWhere || sql_from || sAnd || sql_to;
+
+for ret in EXECUTE 'SELECT po.po_id,
+			    po.pa_id, po.po_name,=20
+			    po.po_description,sum(
+        CASE
+            WHEN operation_analytique.oa_debit =3D true THEN operation_a=
nalytique.oa_amount * (-1)::numeric
+            ELSE operation_analytique.oa_amount
+        END) AS sum_amount, jrnx.j_poste, tmp_pcmn.pcm_lib AS name
+   FROM operation_analytique
+   JOIN poste_analytique po USING (po_id)
+   JOIN jrnx USING (j_id)
+   JOIN tmp_pcmn ON jrnx.j_poste::text =3D tmp_pcmn.pcm_val::text
+'|| sResult ||'
+  GROUP BY po.po_id, po.po_name, po.pa_id, jrnx.j_poste, tmp_pcmn.pcm_li=
b, po.po_description
+ HAVING sum(
+CASE
+    WHEN operation_analytique.oa_debit =3D true THEN operation_analytiqu=
e.oa_amount * (-1)::numeric
+    ELSE operation_analytique.oa_amount
+END) <> 0::numeric '
+	loop
+	return next ret;
+end loop;
+end;
+$$;
+
+
+--
+-- Name: table_analytic_card(text, text); Type: FUNCTION; Schema: compta=
proc; Owner: -
+--
+
+CREATE FUNCTION table_analytic_card(p_from text, p_to text) RETURNS SETO=
F public.anc_table_card_type
+    LANGUAGE plpgsql
+    AS $$
+declare
+	ret ANC_table_card_type%ROWTYPE;
+	sql_from text:=3D'';
+	sql_to text:=3D'';
+	sWhere text:=3D'';
+	sAnd text:=3D'';
+	sResult text:=3D'';
+begin
+if p_from <> '' and p_from is not null then
+	sql_from:=3D'oa_date >=3D to_date('''||p_from::text||''',''DD.MM.YYYY''=
)';
+	sWhere:=3D' where ';
+end if;
+
+if p_to <> '' and p_to is not null then
+	sql_to=3D' oa_date <=3D to_date('''||p_to::text||''',''DD.MM.YYYY'')';
+	sWhere :=3D ' where ';
+end if;
+
+if sql_to <> '' and sql_from <> '' then
+	sAnd :=3D' and ';
+end if;
+
+sResult :=3D sWhere || sql_from || sAnd || sql_to;
+
+for ret in EXECUTE ' SELECT po.po_id, po.pa_id, po.po_name, po.po_descri=
ption,  sum(
+        CASE
+            WHEN operation_analytique.oa_debit =3D true THEN operation_a=
nalytique.oa_amount * (-1)::numeric
+            ELSE operation_analytique.oa_amount
+        END) AS sum_amount, jrnx.f_id, jrnx.j_qcode, ( SELECT fiche_deta=
il.ad_value
+           FROM fiche_detail
+          WHERE fiche_detail.ad_id =3D 1 AND fiche_detail.f_id =3D jrnx.=
f_id) AS name
+   FROM operation_analytique
+   JOIN poste_analytique po USING (po_id)
+   JOIN jrnx USING (j_id)'|| sResult ||'
+  GROUP BY po.po_id, po.po_name, po.pa_id, jrnx.f_id, jrnx.j_qcode, ( SE=
LECT fiche_detail.ad_value
+   FROM fiche_detail
+  WHERE fiche_detail.ad_id =3D 1 AND fiche_detail.f_id =3D jrnx.f_id), p=
o.po_description
+ HAVING sum(
+CASE
+    WHEN operation_analytique.oa_debit =3D true THEN operation_analytiqu=
e.oa_amount * (-1)::numeric
+    ELSE operation_analytique.oa_amount
+END) <> 0::numeric;'
+
+
+	loop
+	return next ret;
+end loop;
+end;
+$$;
+
+
+--
+-- Name: tmp_pcmn_ins(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION tmp_pcmn_ins() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+   r_record tmp_pcmn%ROWTYPE;
+begin
+r_record=3DNEW;
+if  length(trim(r_record.pcm_type))=3D0 or r_record.pcm_type is NULL the=
n=20
+   r_record.pcm_type:=3Dfind_pcm_type(NEW.pcm_val);
+   return r_record;
+end if;
+return NEW;
+end;
+$$;
+
+
+--
+-- Name: trim_cvs_quote(); Type: FUNCTION; Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION trim_cvs_quote() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+        modified import_tmp%ROWTYPE;
+begin
+	modified:=3DNEW;
+	modified.devise=3Dreplace(new.devise,'"','');
+	modified.poste_comptable=3Dreplace(new.poste_comptable,'"','');
+        modified.compte_ordre=3Dreplace(NEW.COMPTE_ORDRE,'"','');
+        modified.detail=3Dreplace(NEW.DETAIL,'"','');
+        modified.num_compte=3Dreplace(NEW.NUM_COMPTE,'"','');
+        return modified;
+end;
+$$;
+
+
+--
+-- Name: trim_space_format_csv_banque(); Type: FUNCTION; Schema: comptap=
roc; Owner: -
+--
+
+CREATE FUNCTION trim_space_format_csv_banque() RETURNS trigger
+    LANGUAGE plpgsql
+    AS $$
+declare
+        modified format_csv_banque%ROWTYPE;
+begin
+        modified.name=3Dtrim(NEW.NAME);
+        modified.include_file=3Dtrim(new.include_file);
+		if ( length(modified.name) =3D 0 ) then
+			modified.name=3Dnull;
+		end if;
+		if ( length(modified.include_file) =3D 0 ) then
+			modified.include_file=3Dnull;
+		end if;
+
+        return modified;
+end;
+$$;
+
+
+--
+-- Name: tva_delete(integer); Type: FUNCTION; Schema: comptaproc; Owner:=
 -
+--
+
+CREATE FUNCTION tva_delete(integer) RETURNS void
+    LANGUAGE plpgsql
+    AS $_$=20
+declare
+	p_tva_id alias for $1;
+	nCount integer;
+begin
+	nCount=3D0;
+	select count(*) into nCount from quant_sold where qs_vat_code=3Dp_tva_i=
d;
+	if nCount !=3D 0 then
+                 return;
+	=09
+	end if;
+	select count(*) into nCount from quant_purchase where qp_vat_code=3Dp_t=
va_id;
+	if nCount !=3D 0 then
+                 return;
+	=09
+	end if;
+
+delete from tva_rate where tva_id=3Dp_tva_id;
+	return;
+end;
+$_$;
+
+
+--
+-- Name: tva_insert(text, numeric, text, text); Type: FUNCTION; Schema: =
comptaproc; Owner: -
+--
+
+CREATE FUNCTION tva_insert(text, numeric, text, text) RETURNS integer
+    LANGUAGE plpgsql
+    AS $_$
+declare
+	l_tva_id integer;
+	p_tva_label alias for $1;
+	p_tva_rate alias for $2;
+	p_tva_comment alias for $3;
+	p_tva_poste alias for $4;
+	debit text;
+	credit text;
+	nCount integer;
+begin
+if length(trim(p_tva_label)) =3D 0 then
+	return 3;
+end if;
+
+if length(trim(p_tva_poste)) !=3D 0 then
+	if position (',' in p_tva_poste) =3D 0 then return 4; end if;
+	debit  =3D split_part(p_tva_poste,',',1);
+	credit	=3D split_part(p_tva_poste,',',2);
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Ddebit::accoun=
t_type;
+	if nCount =3D 0 then return 4; end if;
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Dcredit::accou=
nt_type;
+	if nCount =3D 0 then return 4; end if;
+
+end if;
+select into l_tva_id nextval('s_tva') ;
+insert into tva_rate(tva_id,tva_label,tva_rate,tva_comment,tva_poste)
+	values (l_tva_id,p_tva_label,p_tva_rate,p_tva_comment,p_tva_poste);
+return 0;
+end;
+$_$;
+
+
+--
+-- Name: tva_modify(integer, text, numeric, text, text); Type: FUNCTION;=
 Schema: comptaproc; Owner: -
+--
+
+CREATE FUNCTION tva_modify(integer, text, numeric, text, text) RETURNS i=
nteger
+    LANGUAGE plpgsql
+    AS $_$
+declare
+	p_tva_id alias for $1;
+	p_tva_label alias for $2;
+	p_tva_rate alias for $3;
+	p_tva_comment alias for $4;
+	p_tva_poste alias for $5;
+	debit text;
+	credit text;
+	nCount integer;
+begin
+if length(trim(p_tva_label)) =3D 0 then
+	return 3;
+end if;
+
+if length(trim(p_tva_poste)) !=3D 0 then
+	if position (',' in p_tva_poste) =3D 0 then return 4; end if;
+	debit  =3D split_part(p_tva_poste,',',1);
+	credit	=3D split_part(p_tva_poste,',',2);
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Ddebit::accoun=
t_type;
+	if nCount =3D 0 then return 4; end if;
+	select count(*) into nCount from tmp_pcmn where pcm_val=3Dcredit::accou=
nt_type;
+	if nCount =3D 0 then return 4; end if;
+
+end if;
+update tva_rate set tva_label=3Dp_tva_label,tva_rate=3Dp_tva_rate,tva_co=
mment=3Dp_tva_comment,tva_poste=3Dp_tva_poste
+	where tva_id=3Dp_tva_id;
+return 0;
+end;
+$_$;
+
+
+--
+-- Name: update_quick_code(integer, text); Type: FUNCTION; Schema: compt=
aproc; Owner: -
+--
+
+CREATE FUNCTION update_quick_code(njft_id integer, tav_text text) RETURN=
S integer
+    LANGUAGE plpgsql
+    AS $$
+	declare
+	ns integer;
+	nExist integer;
+	tText text;
+	old_qcode varchar;
+	begin
+	-- get current value
+	select ad_value into old_qcode from fiche_detail where jft_id=3Dnjft_id=
;
+	-- av_text didn't change so no update
+	if tav_text =3D upper( trim(old_qcode)) then
+		return 0;
+	end if;
+=09
+	tText :=3D trim(upper(tav_text));
+	tText :=3D replace(tText,' ','');
+	if length ( tText) =3D 0 or tText is null then
+		return 0;
+	end if;
+	=09
+	ns :=3D njft_id;
+
+	loop
+		-- av_text already used ?
+		select count(*) into nExist=20
+			from fiche_detail
+		where=20
+			ad_id=3D23 and ad_value=3DtText;
+
+		if nExist =3D 0 then
+			exit;
+		end if;=09
+		if tText =3D 'FID'||ns then
+			-- take the next sequence
+			select nextval('s_jnt_fic_att_value') into ns;
+		end if;
+		tText  :=3D'FID'||ns;
+	=09
+	end loop;
+	update fiche_detail set ad_value =3D tText where jft_id=3Dnjft_id;
+
+	-- update also the contact
+	update fiche_detail set ad_value =3D tText=20
+		where jft_id in=20
+			( select jft_id=20
+				from fiche_detail=20
+			where ad_id=3D25 and ad_value=3Dold_qcode);
+
+
+	update jrnx set j_qcode=3DtText where j_qcode =3D old_qcode;
+	return ns;
+	end;
+$$;
+
+
+--
+-- PostgreSQL database dump complete
+--
+



From MAILER-DAEMON Fri Jun 10 20:09:46 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QVBlq-0002y6-9L
	for mharc-phpcompta-dev@gnu.org; Fri, 10 Jun 2011 20:09:46 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat, 11 Jun 2011 02:14:23 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.30564.1307750985.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4162 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 11 Jun 2011 00:09:44 -0000

Author: danydb
Date: 2011-06-11 02:14:22 +0200 (Sat, 11 Jun 2011)
New Revision: 4162

Modified:
   phpcompta/branches/rel560/include/class_html_table.php
Log:
Fix bug=20

Modified: phpcompta/branches/rel560/include/class_html_table.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_html_table.php	2011-06-08 17:=
58:47 UTC (rev 4161)
+++ phpcompta/branches/rel560/include/class_html_table.php	2011-06-11 00:=
14:22 UTC (rev 4162)
@@ -73,10 +73,10 @@
   }
 @endcode
    */
-  static function sql2table($cn,$a_col,$sql,$table_style=3D"result",$a_s=
ql_var=3Dnull)
+  static function sql2table($cn,$a_col,$sql,$table_style=3D'class=3D"res=
ult"',$a_sql_var=3Dnull)
   {
     $r=3D'';
-    $r=3Dsprintf('<table style=3D"%s">',$table_style);
+    $r=3Dsprintf('<table %s>',$table_style);
     $r.=3D'<tr>';
     for ( $i=3D0;$i <count($a_col);$i++)
       {
@@ -96,7 +96,7 @@
 	  $r.=3D th($content);
       }
     $r.=3D'</tr>';
-    $ret=3D$cn->exec_sql($sql);
+    $ret=3D$cn->exec_sql($sql,$a_sql_var);
     for ($i=3D0;$i<Database::num_row($ret);$i++)
       {
 	$r.=3D'<tr>';



From MAILER-DAEMON Fri Jun 10 20:11:09 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QVBnA-000350-Pw
	for mharc-phpcompta-dev@gnu.org; Fri, 10 Jun 2011 20:11:08 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat, 11 Jun 2011 02:15:53 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.30565.1307751067.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4163 -
	phpcompta/branches/rel560/dev/manage-code/create-file
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 11 Jun 2011 00:11:06 -0000

Author: danydb
Date: 2011-06-11 02:15:52 +0200 (Sat, 11 Jun 2011)
New Revision: 4163

Modified:
   phpcompta/branches/rel560/dev/manage-code/create-file/create_phpclass.=
py
Log:
Improve creation of php script

Modified: phpcompta/branches/rel560/dev/manage-code/create-file/create_ph=
pclass.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/dev/manage-code/create-file/create_phpclass=
.py	2011-06-11 00:14:22 UTC (rev 4162)
+++ phpcompta/branches/rel560/dev/manage-code/create-file/create_phpclass=
.py	2011-06-11 00:15:52 UTC (rev 4163)
@@ -14,6 +14,8 @@
 # second line =3D pk
=20
 import sys, getopt
+import pdb
+
 def help():
     print """
     option are -h for help
@@ -77,7 +79,7 @@
        =20
         if ( $p_id =3D=3D -1 ) {
         /* Initialize an empty object */
-            foreach ($this->variable as $key=3D>$value) $this->$value=3D=
'DEFAULT';
+            foreach ($this->variable as $key=3D>$value) $this->$value=3D=
null;
             $this->@id@=3D$p_id;
         } else {
          /* load it */
@@ -543,6 +545,7 @@
                (col_id,col_type,default)=3De.split('|')
                col_id=3Dcol_id.strip()
                col_type=3Dcol_type.strip()
+               verify_data_type+=3D" if ( trim($this->"+col_id+") =3D=3D=
 '') $this->"+col_id+"=3Dnull;\n"
                if col_type in ('float','integer','numeric','bigint') :
                    verify_data_type+=3D"if ( $this->"+col_id+"!=3D=3D nu=
ll && settype($this->"+col_id+",'float') =3D=3D false )\n \
             throw new Exception('DATATYPE "+col_id+" $this->"+col_id+" n=
on numerique');\n"



From MAILER-DAEMON Tue Jun 14 12:32:11 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QWWXC-0005hG-U6
	for mharc-phpcompta-dev@gnu.org; Tue, 14 Jun 2011 12:32:11 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Tue, 14 Jun 2011 18:36:50 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.41005.1308069130.835.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4164 - phpcompta/branches/rel560/html
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Tue, 14 Jun 2011 16:32:09 -0000

Author: danydb
Date: 2011-06-14 18:36:48 +0200 (Tue, 14 Jun 2011)
New Revision: 4164

Modified:
   phpcompta/branches/rel560/html/style-print.css
Log:
Align numeric to right

Modified: phpcompta/branches/rel560/html/style-print.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/style-print.css	2011-06-11 00:15:52 UT=
C (rev 4163)
+++ phpcompta/branches/rel560/html/style-print.css	2011-06-14 16:36:48 UT=
C (rev 4164)
@@ -240,4 +240,8 @@
 .ipop_card_fond {
 		display:none;
 }
+.num {
+	text-align:right;
+}
+
 /* </style> */



From MAILER-DAEMON Fri Jun 17 16:21:44 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QXfXz-0001B2-IQ
	for mharc-phpcompta-dev@gnu.org; Fri, 17 Jun 2011 16:21:43 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Fri, 17 Jun 2011 22:26:23 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.13.1308342102.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4166 - phpcompta/branches/rel560/sql
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Fri, 17 Jun 2011 20:21:41 -0000

Author: danydb
Date: 2011-06-17 22:26:23 +0200 (Fri, 17 Jun 2011)
New Revision: 4166

Modified:
   phpcompta/branches/rel560/sql/upgrade.sql
Log:
0000296: Calcul automatique fiche

Modified: phpcompta/branches/rel560/sql/upgrade.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/sql/upgrade.sql	2011-06-17 19:55:06 UTC (re=
v 4165)
+++ phpcompta/branches/rel560/sql/upgrade.sql	2011-06-17 20:26:23 UTC (re=
v 4166)
@@ -9,3 +9,131 @@
=20
 create unique index fiche_Detail_f_id_ad_id on fiche_detail (f_id,ad_id)=
;
=20
+CREATE OR REPLACE FUNCTION comptaproc.account_insert(p_f_id integer, p_a=
ccount text)
+  RETURNS integer AS
+$BODY$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	nNew tmp_pcmn.pcm_val%type;
+	bAuto bool;
+	nFd_id integer;
+	sClass_Base fiche_def.fd_class_base%TYPE;
+	nCount integer;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+	-- if there is coma in p_account, treat normally
+		if position (',' in p_account) =3D 0 then
+			raise info 'p_account is not empty';
+				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
+				raise notice 'found in tmp_pcm %',nCount;
+				if nCount !=3D0  then
+					raise info 'this account exists in tmp_pcmn ';
+					perform attribut_insert(p_f_id,5,p_account);
+				   else
+				       -- account doesn't exist, create it
+					select ad_value into sName from
+						fiche_detail
+					where
+					ad_id=3D1 and f_id=3Dp_f_id;
+
+					nParent:=3Daccount_parent(p_account::account_type);
+					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
+					perform attribut_insert(p_f_id,5,p_account);
+
+				end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		perform attribut_insert(p_f_id,5,p_account);
+		end if;
+	else
+	raise info 'p_account is  empty';
+		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
+		bAuto:=3D account_auto(nFd_id);
+
+		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
+raise info 'sClass_Base : %',sClass_base;
+		if bAuto =3D true and sClass_base similar to '[[:digit:]]*'  then
+			raise info 'account generated automatically';
+			nNew:=3Daccount_compute(p_f_id);
+			raise info 'nNew %', nNew;
+			select ad_value into sName from
+				fiche_detail
+			where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(nNew);
+			perform account_add  (nNew,sName);
+			perform attribut_insert(p_f_id,5,nNew);
+
+		else
+		-- if there is an account_base then it is the default
+		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
+			if nNew is null or length(trim(nNew)) =3D 0 then
+				raise notice 'count is null';
+				 perform attribut_insert(p_f_id,5,null);
+			else
+				 perform attribut_insert(p_f_id,5,nNew);
+			end if;
+		end if;
+	end if;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION comptaproc.account_update(p_f_id integer, p_a=
ccount account_type)
+  RETURNS integer AS
+$BODY$
+declare
+	nMax fiche.f_id%type;
+	nCount integer;
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+		if position (',' in p_account) =3D 0 then
+			select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_account;
+			if nCount =3D 0 then
+			select ad_value into sName from
+				fiche_detail
+				where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(p_account);
+			insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_accoun=
t,sName,nParent);
+			end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		end if;
+	end if;
+=09
+	update fiche_detail set ad_value=3Dp_account where f_id=3Dp_f_id and ad=
_id=3D5 ;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
\ No newline at end of file



From MAILER-DAEMON Fri Jun 17 16:25:52 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QXfc0-00027B-CW
	for mharc-phpcompta-dev@gnu.org; Fri, 17 Jun 2011 16:25:52 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Fri, 17 Jun 2011 21:55:08 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.23.1308342351.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4165 - in phpcompta/branches/rel560: include sql
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Fri, 17 Jun 2011 20:25:50 -0000

Author: danydb
Date: 2011-06-17 21:55:06 +0200 (Fri, 17 Jun 2011)
New Revision: 4165

Modified:
   phpcompta/branches/rel560/include/class_fiche.php
   phpcompta/branches/rel560/sql/upgrade.sql
Log:
0000297: Bug dans contact

Modified: phpcompta/branches/rel560/include/class_fiche.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_fiche.php	2011-06-14 16:36:48=
 UTC (rev 4164)
+++ phpcompta/branches/rel560/include/class_fiche.php	2011-06-17 19:55:06=
 UTC (rev 4165)
@@ -728,10 +728,11 @@
             foreach ($p_array as $name=3D>$value )
             {
                 /* avoid the button for searching an accounting item */
-                if ( $name=3D=3D'av_text5_bt') continue;
-                list ($id) =3D sscanf ($name,"av_text%d");
-                if ( $id =3D=3D null ) continue;
+	      if ( preg_match('/^av_text[0-9]+$/',$name) =3D=3D 0) continue;
=20
+	      list ($id) =3D sscanf ($name,"av_text%d");
+	      if ( $id =3D=3D null ) continue;
+	     =20
                 // Special traitement
                 // quickcode
                 if ( $id =3D=3D ATTR_DEF_QUICKCODE)
@@ -831,18 +832,21 @@
             // parse the $p_array array
             foreach ($p_array as $name=3D>$value )
             {
+		if ( preg_match('/^av_text[0-9]+$/',$name) =3D=3D 0) continue;
+	     =20
                 list ($id) =3D sscanf ($name,"av_text%d");
+
                 if ( $id =3D=3D null ) continue;
=20
                 // retrieve jft_id to update table attr_value
                 $sql=3D" select jft_id from fiche_detail where ad_id=3D$=
id and f_id=3D$this->id";
                 $Ret=3D$this->cn->exec_sql($sql);
-                if ( Database::num_row($Ret) !=3D 1 )
+                if ( Database::num_row($Ret) =3D=3D 0 )
                 {
                     // we need to insert this new attribut
                     $jft_id=3D$this->cn->get_next_seq('s_jnt_fic_att_val=
ue');
=20
-                    $sql2=3Dsprintf("insert into fiche_detail(jft_id,ad_=
id,f_id,ad_value) values ($1,$2,$3,NULL)");
+                    $sql2=3D"insert into fiche_detail(jft_id,ad_id,f_id,=
ad_value) values ($1,$2,$3,NULL)";
=20
                     $ret2=3D$this->cn->exec_sql($sql2,array($jft_id,$id,=
$this->id));
=20
@@ -956,23 +960,22 @@
                 }
                 if ( $id =3D=3D ATTR_DEF_COMPANY )
                 {
-                    $exist=3D$this->cn->count_sql("select f_id from fich=
e join fiche_def using (fd_id) ".
+                    $exist=3D$this->cn->exec_sql("select f_id from fiche=
 join fiche_def using (fd_id) ".
                                                 " join fiche_detail usin=
g (f_id)  ".
-                                                " where frd_id in (8,9,1=
4) and ad_id=3D".ATTR_DEF_QUICKCODE.
-                                                " and ad_value=3D'".Form=
atString($value)."'");
+                                                " where frd_id in (8,9,1=
4) and ad_id=3D$1 ".
+                                                " and ad_value=3Dupper($=
2)",
+					       array(ATTR_DEF_QUICKCODE,$value));
=20
=20
-                    if ( $exist =3D=3D 0 && FormatString($value) !=3D nu=
ll )
+                    if ( Database::num_row($exist) =3D=3D 0  && FormatSt=
ring($value) !=3D null )
                     {
                         $value=3D"Attention : pas de soci=C3=A9t=C3=A9 "=
;
                     }
                 }
=20
                 // Normal traitement
-                $value2=3DFormatString($value);
-                $sql=3Dsprintf("update fiche_detail set ad_value=3D'%s' =
where jft_id=3D%d",
-                             trim($value2),$jft_id);
-                $this->cn->exec_sql($sql);
+                $sql=3D"update fiche_detail set ad_value=3Dupper($1) whe=
re jft_id=3D$2";
+		$this->cn->exec_sql($sql,array($value,$jft_id));
             }
         }
         catch (Exception $e )

Modified: phpcompta/branches/rel560/sql/upgrade.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/sql/upgrade.sql	2011-06-14 16:36:48 UTC (re=
v 4164)
+++ phpcompta/branches/rel560/sql/upgrade.sql	2011-06-17 19:55:06 UTC (re=
v 4165)
@@ -0,0 +1,11 @@
+delete from fiche_detail where jft_id in (
+    select a.jft_id
+from fiche_detail as a ,fiche_detail as b
+where
+a.f_id=3Db.f_id
+and a.ad_id =3D b.ad_id
+and a.jft_id > b.jft_id);
+
+
+create unique index fiche_Detail_f_id_ad_id on fiche_detail (f_id,ad_id)=
;
+



From MAILER-DAEMON Fri Jun 17 16:45:12 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QXfuh-0007Jw-DX
	for mharc-phpcompta-dev@gnu.org; Fri, 17 Jun 2011 16:45:11 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Fri, 17 Jun 2011 22:49:54 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.67.1308343510.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4167 - phpcompta/branches/rel560/include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Fri, 17 Jun 2011 20:45:10 -0000

Author: danydb
Date: 2011-06-17 22:49:53 +0200 (Fri, 17 Jun 2011)
New Revision: 4167

Modified:
   phpcompta/branches/rel560/include/class_anc_operation.php
Log:
fix bug if not plan proposed


Modified: phpcompta/branches/rel560/include/class_anc_operation.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/class_anc_operation.php	2011-06-17 =
20:26:23 UTC (rev 4166)
+++ phpcompta/branches/rel560/include/class_anc_operation.php	2011-06-17 =
20:49:53 UTC (rev 4167)
@@ -536,6 +536,7 @@
     function save_form_plan($p_array,$p_item,$j_id)
     {
         extract($p_array);
+	if (! isset ($hplan) ) return;
         /* variable for in array
            pa_id array of existing pa_id
            hplan double array with the pa_id (column)



From MAILER-DAEMON Fri Jun 17 16:52:43 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QXg1z-0001Dz-0G
	for mharc-phpcompta-dev@gnu.org; Fri, 17 Jun 2011 16:52:43 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Fri, 17 Jun 2011 22:57:30 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.83.1308343962.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4168 - in phpcompta/branches/rel560:
	html/admin/sql/patch include sql
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Fri, 17 Jun 2011 20:52:42 -0000

Author: danydb
Date: 2011-06-17 22:57:29 +0200 (Fri, 17 Jun 2011)
New Revision: 4168

Added:
   phpcompta/branches/rel560/html/admin/sql/patch/upgrade95.sql
Modified:
   phpcompta/branches/rel560/include/constant.php
   phpcompta/branches/rel560/sql/upgrade.sql
Log:
0000305: Charge au cr?\195?\169dit

new sql script

Added: phpcompta/branches/rel560/html/admin/sql/patch/upgrade95.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/admin/sql/patch/upgrade95.sql	        =
                (rev 0)
+++ phpcompta/branches/rel560/html/admin/sql/patch/upgrade95.sql	2011-06-=
17 20:57:29 UTC (rev 4168)
@@ -0,0 +1,147 @@
+begin;
+
+delete from fiche_detail where jft_id in (
+    select a.jft_id
+from fiche_detail as a ,fiche_detail as b
+where
+a.f_id=3Db.f_id
+and a.ad_id =3D b.ad_id
+and a.jft_id > b.jft_id);
+
+
+create unique index fiche_Detail_f_id_ad_id on fiche_detail (f_id,ad_id)=
;
+
+CREATE OR REPLACE FUNCTION comptaproc.account_insert(p_f_id integer, p_a=
ccount text)
+  RETURNS integer AS
+$BODY$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	nNew tmp_pcmn.pcm_val%type;
+	bAuto bool;
+	nFd_id integer;
+	sClass_Base fiche_def.fd_class_base%TYPE;
+	nCount integer;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+	-- if there is coma in p_account, treat normally
+		if position (',' in p_account) =3D 0 then
+			raise info 'p_account is not empty';
+				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
+				raise notice 'found in tmp_pcm %',nCount;
+				if nCount !=3D0  then
+					raise info 'this account exists in tmp_pcmn ';
+					perform attribut_insert(p_f_id,5,p_account);
+				   else
+				       -- account doesn't exist, create it
+					select ad_value into sName from
+						fiche_detail
+					where
+					ad_id=3D1 and f_id=3Dp_f_id;
+
+					nParent:=3Daccount_parent(p_account::account_type);
+					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
+					perform attribut_insert(p_f_id,5,p_account);
+
+				end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		perform attribut_insert(p_f_id,5,p_account);
+		end if;
+	else
+	raise info 'p_account is  empty';
+		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
+		bAuto:=3D account_auto(nFd_id);
+
+		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
+raise info 'sClass_Base : %',sClass_base;
+		if bAuto =3D true and sClass_base similar to '[[:digit:]]*'  then
+			raise info 'account generated automatically';
+			nNew:=3Daccount_compute(p_f_id);
+			raise info 'nNew %', nNew;
+			select ad_value into sName from
+				fiche_detail
+			where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(nNew);
+			perform account_add  (nNew,sName);
+			perform attribut_insert(p_f_id,5,nNew);
+
+		else
+		-- if there is an account_base then it is the default
+		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
+			if nNew is null or length(trim(nNew)) =3D 0 then
+				raise notice 'count is null';
+				 perform attribut_insert(p_f_id,5,null);
+			else
+				 perform attribut_insert(p_f_id,5,nNew);
+			end if;
+		end if;
+	end if;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION comptaproc.account_update(p_f_id integer, p_a=
ccount account_type)
+  RETURNS integer AS
+$BODY$
+declare
+	nMax fiche.f_id%type;
+	nCount integer;
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+		if position (',' in p_account) =3D 0 then
+			select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_account;
+			if nCount =3D 0 then
+			select ad_value into sName from
+				fiche_detail
+				where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(p_account);
+			insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_accoun=
t,sName,nParent);
+			end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		end if;
+	end if;
+=09
+	update fiche_detail set ad_value=3Dp_account where f_id=3Dp_f_id and ad=
_id=3D5 ;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
+
+update operation_analytique set oa_debit=3Dj_debit from jrnx where jrnx.=
j_id =3D operation_analytique.j_id;
+
+update version set val=3D96;
+
+commit;
\ No newline at end of file

Modified: phpcompta/branches/rel560/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/constant.php	2011-06-17 20:49:53 UT=
C (rev 4167)
+++ phpcompta/branches/rel560/include/constant.php	2011-06-17 20:57:29 UT=
C (rev 4168)
@@ -38,11 +38,11 @@
 $version_phpcompta=3DSVNINFO;=20
 define ("DEBUG",false);
=20
-//define ("DEBUG",true);
-//$version_phpcompta=3D4014;
+/*define ("DEBUG",true);
+$version_phpcompta=3D4014;
+*/
=20
-
-define ("DBVERSION",95);
+define ("DBVERSION",96);
 define ("DBVERSIONREPO",13);
 define ('NOTFOUND','--not found--');
=20

Modified: phpcompta/branches/rel560/sql/upgrade.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/sql/upgrade.sql	2011-06-17 20:49:53 UTC (re=
v 4167)
+++ phpcompta/branches/rel560/sql/upgrade.sql	2011-06-17 20:57:29 UTC (re=
v 4168)
@@ -1,139 +0,0 @@
-delete from fiche_detail where jft_id in (
-    select a.jft_id
-from fiche_detail as a ,fiche_detail as b
-where
-a.f_id=3Db.f_id
-and a.ad_id =3D b.ad_id
-and a.jft_id > b.jft_id);
-
-
-create unique index fiche_Detail_f_id_ad_id on fiche_detail (f_id,ad_id)=
;
-
-CREATE OR REPLACE FUNCTION comptaproc.account_insert(p_f_id integer, p_a=
ccount text)
-  RETURNS integer AS
-$BODY$
-declare
-	nParent tmp_pcmn.pcm_val_parent%type;
-	sName varchar;
-	nNew tmp_pcmn.pcm_val%type;
-	bAuto bool;
-	nFd_id integer;
-	sClass_Base fiche_def.fd_class_base%TYPE;
-	nCount integer;
-	first text;
-	second text;
-begin
-
-	if p_account is not null and length(trim(p_account)) !=3D 0 then
-	-- if there is coma in p_account, treat normally
-		if position (',' in p_account) =3D 0 then
-			raise info 'p_account is not empty';
-				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
-				raise notice 'found in tmp_pcm %',nCount;
-				if nCount !=3D0  then
-					raise info 'this account exists in tmp_pcmn ';
-					perform attribut_insert(p_f_id,5,p_account);
-				   else
-				       -- account doesn't exist, create it
-					select ad_value into sName from
-						fiche_detail
-					where
-					ad_id=3D1 and f_id=3Dp_f_id;
-
-					nParent:=3Daccount_parent(p_account::account_type);
-					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
-					perform attribut_insert(p_f_id,5,p_account);
-
-				end if;
-		else
-		raise info 'presence of a comma';
-		-- there is 2 accounts separated by a comma
-		first :=3D split_part(p_account,',',1);
-		second :=3D split_part(p_account,',',2);
-		-- check there is no other coma
-		raise info 'first value % second value %', first, second;
-
-		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
-			raise exception 'Too many comas, invalid account';
-		end if;
-		perform attribut_insert(p_f_id,5,p_account);
-		end if;
-	else
-	raise info 'p_account is  empty';
-		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
-		bAuto:=3D account_auto(nFd_id);
-
-		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
-raise info 'sClass_Base : %',sClass_base;
-		if bAuto =3D true and sClass_base similar to '[[:digit:]]*'  then
-			raise info 'account generated automatically';
-			nNew:=3Daccount_compute(p_f_id);
-			raise info 'nNew %', nNew;
-			select ad_value into sName from
-				fiche_detail
-			where
-				ad_id=3D1 and f_id=3Dp_f_id;
-			nParent:=3Daccount_parent(nNew);
-			perform account_add  (nNew,sName);
-			perform attribut_insert(p_f_id,5,nNew);
-
-		else
-		-- if there is an account_base then it is the default
-		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
-			if nNew is null or length(trim(nNew)) =3D 0 then
-				raise notice 'count is null';
-				 perform attribut_insert(p_f_id,5,null);
-			else
-				 perform attribut_insert(p_f_id,5,nNew);
-			end if;
-		end if;
-	end if;
-
-return 0;
-end;
-$BODY$
-  LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION comptaproc.account_update(p_f_id integer, p_a=
ccount account_type)
-  RETURNS integer AS
-$BODY$
-declare
-	nMax fiche.f_id%type;
-	nCount integer;
-	nParent tmp_pcmn.pcm_val_parent%type;
-	sName varchar;
-	first text;
-	second text;
-begin
-
-	if p_account is not null and length(trim(p_account)) !=3D 0 then
-		if position (',' in p_account) =3D 0 then
-			select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_account;
-			if nCount =3D 0 then
-			select ad_value into sName from
-				fiche_detail
-				where
-				ad_id=3D1 and f_id=3Dp_f_id;
-			nParent:=3Daccount_parent(p_account);
-			insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_accoun=
t,sName,nParent);
-			end if;
-		else
-		raise info 'presence of a comma';
-		-- there is 2 accounts separated by a comma
-		first :=3D split_part(p_account,',',1);
-		second :=3D split_part(p_account,',',2);
-		-- check there is no other coma
-		raise info 'first value % second value %', first, second;
-
-		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
-			raise exception 'Too many comas, invalid account';
-		end if;
-		end if;
-	end if;
-=09
-	update fiche_detail set ad_value=3Dp_account where f_id=3Dp_f_id and ad=
_id=3D5 ;
-
-return 0;
-end;
-$BODY$
-  LANGUAGE plpgsql;
\ No newline at end of file



From MAILER-DAEMON Fri Jun 17 17:22:41 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QXgUz-0000HY-DD
	for mharc-phpcompta-dev@gnu.org; Fri, 17 Jun 2011 17:22:41 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Fri, 17 Jun 2011 23:27:28 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.118.1308345760.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4169 - in phpcompta/branches/rel560:
	html/admin/sql/patch include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Fri, 17 Jun 2011 21:22:39 -0000

Author: danydb
Date: 2011-06-17 23:27:27 +0200 (Fri, 17 Jun 2011)
New Revision: 4169

Added:
   phpcompta/branches/rel560/html/admin/sql/patch/upgrade96.sql
Modified:
   phpcompta/branches/rel560/include/constant.php
Log:
remove useless psql function public.account_insert

Added: phpcompta/branches/rel560/html/admin/sql/patch/upgrade96.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/admin/sql/patch/upgrade96.sql	        =
                (rev 0)
+++ phpcompta/branches/rel560/html/admin/sql/patch/upgrade96.sql	2011-06-=
17 21:27:27 UTC (rev 4169)
@@ -0,0 +1,7 @@
+begin;
+
+drop function if exists  public.account_insert(integer,text);
+
+update version set val=3D97;
+
+commit;
\ No newline at end of file

Modified: phpcompta/branches/rel560/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/include/constant.php	2011-06-17 20:57:29 UT=
C (rev 4168)
+++ phpcompta/branches/rel560/include/constant.php	2011-06-17 21:27:27 UT=
C (rev 4169)
@@ -37,12 +37,12 @@
=20
 $version_phpcompta=3DSVNINFO;=20
 define ("DEBUG",false);
-
-/*define ("DEBUG",true);
+/*
+define ("DEBUG",true);
 $version_phpcompta=3D4014;
 */
=20
-define ("DBVERSION",96);
+define ("DBVERSION",97);
 define ("DBVERSIONREPO",13);
 define ('NOTFOUND','--not found--');
=20



From MAILER-DAEMON Fri Jun 17 20:59:41 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QXjsz-0000SS-Jw
	for mharc-phpcompta-dev@gnu.org; Fri, 17 Jun 2011 20:59:41 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Sat, 18 Jun 2011 03:04:30 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.401.1308358779.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4170 - phpcompta/branches/rel560/html
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Sat, 18 Jun 2011 00:59:39 -0000

Author: danydb
Date: 2011-06-18 03:04:28 +0200 (Sat, 18 Jun 2011)
New Revision: 4170

Modified:
   phpcompta/branches/rel560/html/style-color.css
   phpcompta/branches/rel560/html/style-light.css
   phpcompta/branches/rel560/html/style-test.css
   phpcompta/branches/rel560/html/style.css
Log:
Update style

Modified: phpcompta/branches/rel560/html/style-color.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/style-color.css	2011-06-17 21:27:27 UT=
C (rev 4169)
+++ phpcompta/branches/rel560/html/style-color.css	2011-06-18 01:04:28 UT=
C (rev 4170)
@@ -911,4 +911,9 @@
               width:50%;
               display:none;
 	      background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}

Modified: phpcompta/branches/rel560/html/style-light.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/style-light.css	2011-06-17 21:27:27 UT=
C (rev 4169)
+++ phpcompta/branches/rel560/html/style-light.css	2011-06-18 01:04:28 UT=
C (rev 4170)
@@ -34,7 +34,7 @@
 =20
   color:#25238F;
   text-align: left;
-  	      background-color:#EDF3FF;
+  	      background-color:#bdbaba;
   	     =20
 	      font-style: italic;
 	     =20
@@ -941,4 +941,9 @@
               width:50%;
               display:none;
 	      background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}

Modified: phpcompta/branches/rel560/html/style-test.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/style-test.css	2011-06-17 21:27:27 UTC=
 (rev 4169)
+++ phpcompta/branches/rel560/html/style-test.css	2011-06-18 01:04:28 UTC=
 (rev 4170)
@@ -60,3 +60,8 @@
    color:blue;
    background-color:white;
 }
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}

Modified: phpcompta/branches/rel560/html/style.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/branches/rel560/html/style.css	2011-06-17 21:27:27 UTC (rev=
 4169)
+++ phpcompta/branches/rel560/html/style.css	2011-06-18 01:04:28 UTC (rev=
 4170)
@@ -34,7 +34,7 @@
 =20
   color:#25238F;
   text-align: left;
-  	      background-color:#EDF3FF;
+  	     // background-color:#EDF3FF;
   	     =20
 	      font-style: italic;
 	     =20
@@ -941,4 +941,10 @@
               width:50%;
               display:none;
 	      background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}



From MAILER-DAEMON Tue Jun 28 17:05:40 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1QbfTY-0005vu-Ku
	for mharc-phpcompta-dev@gnu.org; Tue, 28 Jun 2011 17:05:40 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Tue, 28 Jun 2011 23:10:28 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.33334.1309295140.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4171 - in phpcompta/trunk: .
	dev/manage-code/create-file html html/admin/sql/patch include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Tue, 28 Jun 2011 21:05:39 -0000

Author: danydb
Date: 2011-06-28 23:10:26 +0200 (Tue, 28 Jun 2011)
New Revision: 4171

Added:
   phpcompta/trunk/html/admin/sql/patch/upgrade95.sql
   phpcompta/trunk/html/admin/sql/patch/upgrade96.sql
Modified:
   phpcompta/trunk/
   phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py
   phpcompta/trunk/html/style-color.css
   phpcompta/trunk/html/style-light.css
   phpcompta/trunk/html/style-print.css
   phpcompta/trunk/html/style-test.css
   phpcompta/trunk/html/style.css
   phpcompta/trunk/include/class_anc_operation.php
   phpcompta/trunk/include/class_fiche.php
   phpcompta/trunk/include/class_html_table.php
   phpcompta/trunk/include/constant.php
Log:
Merged revisions 4162-4170 via svnmerge from=20
svn+ssh://danydb@svn/svn/phpcompta/branches/rel560

........
  r4162 | danydb | 2011-06-11 02:14:22 +0200 (Sat, 11 Jun 2011) | 1 line
 =20
  Fix bug=20
........
  r4163 | danydb | 2011-06-11 02:15:52 +0200 (Sat, 11 Jun 2011) | 1 line
 =20
  Improve creation of php script
........
  r4164 | danydb | 2011-06-14 18:36:48 +0200 (Tue, 14 Jun 2011) | 1 line
 =20
  Align numeric to right
........
  r4165 | danydb | 2011-06-17 21:55:06 +0200 (Fri, 17 Jun 2011) | 1 line
 =20
  0000297: Bug dans contact
........
  r4166 | danydb | 2011-06-17 22:26:23 +0200 (Fri, 17 Jun 2011) | 1 line
 =20
  0000296: Calcul automatique fiche
........
  r4167 | danydb | 2011-06-17 22:49:53 +0200 (Fri, 17 Jun 2011) | 2 lines
 =20
  fix bug if not plan proposed
........
  r4168 | danydb | 2011-06-17 22:57:29 +0200 (Fri, 17 Jun 2011) | 3 lines
 =20
  0000305: Charge au cr?\195?\169dit
 =20
  new sql script
........
  r4169 | danydb | 2011-06-17 23:27:27 +0200 (Fri, 17 Jun 2011) | 1 line
 =20
  remove useless psql function public.account_insert
........
  r4170 | danydb | 2011-06-18 03:04:28 +0200 (Sat, 18 Jun 2011) | 1 line
 =20
  Update style
........



Property changes on: phpcompta/trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /phpcompta/branches/rel560:1-4160
   + /phpcompta/branches/rel560:1-4170

Modified: phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py	2011-0=
6-18 01:04:28 UTC (rev 4170)
+++ phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py	2011-0=
6-28 21:10:26 UTC (rev 4171)
@@ -14,6 +14,8 @@
 # second line =3D pk
=20
 import sys, getopt
+import pdb
+
 def help():
     print """
     option are -h for help
@@ -77,7 +79,7 @@
        =20
         if ( $p_id =3D=3D -1 ) {
         /* Initialize an empty object */
-            foreach ($this->variable as $key=3D>$value) $this->$value=3D=
'DEFAULT';
+            foreach ($this->variable as $key=3D>$value) $this->$value=3D=
null;
             $this->@id@=3D$p_id;
         } else {
          /* load it */
@@ -543,6 +545,7 @@
                (col_id,col_type,default)=3De.split('|')
                col_id=3Dcol_id.strip()
                col_type=3Dcol_type.strip()
+               verify_data_type+=3D" if ( trim($this->"+col_id+") =3D=3D=
 '') $this->"+col_id+"=3Dnull;\n"
                if col_type in ('float','integer','numeric','bigint') :
                    verify_data_type+=3D"if ( $this->"+col_id+"!=3D=3D nu=
ll && settype($this->"+col_id+",'float') =3D=3D false )\n \
             throw new Exception('DATATYPE "+col_id+" $this->"+col_id+" n=
on numerique');\n"

Copied: phpcompta/trunk/html/admin/sql/patch/upgrade95.sql (from rev 4170=
, phpcompta/branches/rel560/html/admin/sql/patch/upgrade95.sql)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/admin/sql/patch/upgrade95.sql	                  =
      (rev 0)
+++ phpcompta/trunk/html/admin/sql/patch/upgrade95.sql	2011-06-28 21:10:2=
6 UTC (rev 4171)
@@ -0,0 +1,147 @@
+begin;
+
+delete from fiche_detail where jft_id in (
+    select a.jft_id
+from fiche_detail as a ,fiche_detail as b
+where
+a.f_id=3Db.f_id
+and a.ad_id =3D b.ad_id
+and a.jft_id > b.jft_id);
+
+
+create unique index fiche_Detail_f_id_ad_id on fiche_detail (f_id,ad_id)=
;
+
+CREATE OR REPLACE FUNCTION comptaproc.account_insert(p_f_id integer, p_a=
ccount text)
+  RETURNS integer AS
+$BODY$
+declare
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	nNew tmp_pcmn.pcm_val%type;
+	bAuto bool;
+	nFd_id integer;
+	sClass_Base fiche_def.fd_class_base%TYPE;
+	nCount integer;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+	-- if there is coma in p_account, treat normally
+		if position (',' in p_account) =3D 0 then
+			raise info 'p_account is not empty';
+				select count(*)  into nCount from tmp_pcmn where pcm_val=3Dp_account=
::account_type;
+				raise notice 'found in tmp_pcm %',nCount;
+				if nCount !=3D0  then
+					raise info 'this account exists in tmp_pcmn ';
+					perform attribut_insert(p_f_id,5,p_account);
+				   else
+				       -- account doesn't exist, create it
+					select ad_value into sName from
+						fiche_detail
+					where
+					ad_id=3D1 and f_id=3Dp_f_id;
+
+					nParent:=3Daccount_parent(p_account::account_type);
+					insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_acco=
unt::account_type,sName,nParent);
+					perform attribut_insert(p_f_id,5,p_account);
+
+				end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		perform attribut_insert(p_f_id,5,p_account);
+		end if;
+	else
+	raise info 'p_account is  empty';
+		select fd_id into nFd_id from fiche where f_id=3Dp_f_id;
+		bAuto:=3D account_auto(nFd_id);
+
+		select fd_class_base into sClass_base from fiche_def where fd_id=3DnFd=
_id;
+raise info 'sClass_Base : %',sClass_base;
+		if bAuto =3D true and sClass_base similar to '[[:digit:]]*'  then
+			raise info 'account generated automatically';
+			nNew:=3Daccount_compute(p_f_id);
+			raise info 'nNew %', nNew;
+			select ad_value into sName from
+				fiche_detail
+			where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(nNew);
+			perform account_add  (nNew,sName);
+			perform attribut_insert(p_f_id,5,nNew);
+
+		else
+		-- if there is an account_base then it is the default
+		      select fd_class_base::account_type into nNew from fiche_def join=
 fiche using (fd_id) where f_id=3Dp_f_id;
+			if nNew is null or length(trim(nNew)) =3D 0 then
+				raise notice 'count is null';
+				 perform attribut_insert(p_f_id,5,null);
+			else
+				 perform attribut_insert(p_f_id,5,nNew);
+			end if;
+		end if;
+	end if;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION comptaproc.account_update(p_f_id integer, p_a=
ccount account_type)
+  RETURNS integer AS
+$BODY$
+declare
+	nMax fiche.f_id%type;
+	nCount integer;
+	nParent tmp_pcmn.pcm_val_parent%type;
+	sName varchar;
+	first text;
+	second text;
+begin
+
+	if p_account is not null and length(trim(p_account)) !=3D 0 then
+		if position (',' in p_account) =3D 0 then
+			select count(*) into nCount from tmp_pcmn where pcm_val=3Dp_account;
+			if nCount =3D 0 then
+			select ad_value into sName from
+				fiche_detail
+				where
+				ad_id=3D1 and f_id=3Dp_f_id;
+			nParent:=3Daccount_parent(p_account);
+			insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_accoun=
t,sName,nParent);
+			end if;
+		else
+		raise info 'presence of a comma';
+		-- there is 2 accounts separated by a comma
+		first :=3D split_part(p_account,',',1);
+		second :=3D split_part(p_account,',',2);
+		-- check there is no other coma
+		raise info 'first value % second value %', first, second;
+
+		if  position (',' in first) !=3D 0 or position (',' in second) !=3D 0 =
then
+			raise exception 'Too many comas, invalid account';
+		end if;
+		end if;
+	end if;
+=09
+	update fiche_detail set ad_value=3Dp_account where f_id=3Dp_f_id and ad=
_id=3D5 ;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
+
+update operation_analytique set oa_debit=3Dj_debit from jrnx where jrnx.=
j_id =3D operation_analytique.j_id;
+
+update version set val=3D96;
+
+commit;
\ No newline at end of file

Copied: phpcompta/trunk/html/admin/sql/patch/upgrade96.sql (from rev 4170=
, phpcompta/branches/rel560/html/admin/sql/patch/upgrade96.sql)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/admin/sql/patch/upgrade96.sql	                  =
      (rev 0)
+++ phpcompta/trunk/html/admin/sql/patch/upgrade96.sql	2011-06-28 21:10:2=
6 UTC (rev 4171)
@@ -0,0 +1,7 @@
+begin;
+
+drop function if exists  public.account_insert(integer,text);
+
+update version set val=3D97;
+
+commit;
\ No newline at end of file

Modified: phpcompta/trunk/html/style-color.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/style-color.css	2011-06-18 01:04:28 UTC (rev 417=
0)
+++ phpcompta/trunk/html/style-color.css	2011-06-28 21:10:26 UTC (rev 417=
1)
@@ -911,4 +911,9 @@
               width:50%;
               display:none;
 	      background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}

Modified: phpcompta/trunk/html/style-light.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/style-light.css	2011-06-18 01:04:28 UTC (rev 417=
0)
+++ phpcompta/trunk/html/style-light.css	2011-06-28 21:10:26 UTC (rev 417=
1)
@@ -34,7 +34,7 @@
 =20
   color:#25238F;
   text-align: left;
-  	      background-color:#EDF3FF;
+  	      background-color:#bdbaba;
   	     =20
 	      font-style: italic;
 	     =20
@@ -941,4 +941,9 @@
               width:50%;
               display:none;
 	      background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}

Modified: phpcompta/trunk/html/style-print.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/style-print.css	2011-06-18 01:04:28 UTC (rev 417=
0)
+++ phpcompta/trunk/html/style-print.css	2011-06-28 21:10:26 UTC (rev 417=
1)
@@ -240,4 +240,8 @@
 .ipop_card_fond {
 		display:none;
 }
+.num {
+	text-align:right;
+}
+
 /* </style> */

Modified: phpcompta/trunk/html/style-test.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/style-test.css	2011-06-18 01:04:28 UTC (rev 4170=
)
+++ phpcompta/trunk/html/style-test.css	2011-06-28 21:10:26 UTC (rev 4171=
)
@@ -60,3 +60,8 @@
    color:blue;
    background-color:white;
 }
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}

Modified: phpcompta/trunk/html/style.css
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/style.css	2011-06-18 01:04:28 UTC (rev 4170)
+++ phpcompta/trunk/html/style.css	2011-06-28 21:10:26 UTC (rev 4171)
@@ -34,7 +34,7 @@
 =20
   color:#25238F;
   text-align: left;
-  	      background-color:#EDF3FF;
+  	     // background-color:#EDF3FF;
   	     =20
 	      font-style: italic;
 	     =20
@@ -941,4 +941,10 @@
               width:50%;
               display:none;
 	      background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+
+table.result td=20
+{
+	padding-left:5px;
+	padding-right:5px;
+}

Modified: phpcompta/trunk/include/class_anc_operation.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/class_anc_operation.php	2011-06-18 01:04:28 U=
TC (rev 4170)
+++ phpcompta/trunk/include/class_anc_operation.php	2011-06-28 21:10:26 U=
TC (rev 4171)
@@ -536,6 +536,7 @@
     function save_form_plan($p_array,$p_item,$j_id)
     {
         extract($p_array);
+	if (! isset ($hplan) ) return;
         /* variable for in array
            pa_id array of existing pa_id
            hplan double array with the pa_id (column)

Modified: phpcompta/trunk/include/class_fiche.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/class_fiche.php	2011-06-18 01:04:28 UTC (rev =
4170)
+++ phpcompta/trunk/include/class_fiche.php	2011-06-28 21:10:26 UTC (rev =
4171)
@@ -728,10 +728,11 @@
             foreach ($p_array as $name=3D>$value )
             {
                 /* avoid the button for searching an accounting item */
-                if ( $name=3D=3D'av_text5_bt') continue;
-                list ($id) =3D sscanf ($name,"av_text%d");
-                if ( $id =3D=3D null ) continue;
+	      if ( preg_match('/^av_text[0-9]+$/',$name) =3D=3D 0) continue;
=20
+	      list ($id) =3D sscanf ($name,"av_text%d");
+	      if ( $id =3D=3D null ) continue;
+	     =20
                 // Special traitement
                 // quickcode
                 if ( $id =3D=3D ATTR_DEF_QUICKCODE)
@@ -831,18 +832,21 @@
             // parse the $p_array array
             foreach ($p_array as $name=3D>$value )
             {
+		if ( preg_match('/^av_text[0-9]+$/',$name) =3D=3D 0) continue;
+	     =20
                 list ($id) =3D sscanf ($name,"av_text%d");
+
                 if ( $id =3D=3D null ) continue;
=20
                 // retrieve jft_id to update table attr_value
                 $sql=3D" select jft_id from fiche_detail where ad_id=3D$=
id and f_id=3D$this->id";
                 $Ret=3D$this->cn->exec_sql($sql);
-                if ( Database::num_row($Ret) !=3D 1 )
+                if ( Database::num_row($Ret) =3D=3D 0 )
                 {
                     // we need to insert this new attribut
                     $jft_id=3D$this->cn->get_next_seq('s_jnt_fic_att_val=
ue');
=20
-                    $sql2=3Dsprintf("insert into fiche_detail(jft_id,ad_=
id,f_id,ad_value) values ($1,$2,$3,NULL)");
+                    $sql2=3D"insert into fiche_detail(jft_id,ad_id,f_id,=
ad_value) values ($1,$2,$3,NULL)";
=20
                     $ret2=3D$this->cn->exec_sql($sql2,array($jft_id,$id,=
$this->id));
=20
@@ -956,23 +960,22 @@
                 }
                 if ( $id =3D=3D ATTR_DEF_COMPANY )
                 {
-                    $exist=3D$this->cn->count_sql("select f_id from fich=
e join fiche_def using (fd_id) ".
+                    $exist=3D$this->cn->exec_sql("select f_id from fiche=
 join fiche_def using (fd_id) ".
                                                 " join fiche_detail usin=
g (f_id)  ".
-                                                " where frd_id in (8,9,1=
4) and ad_id=3D".ATTR_DEF_QUICKCODE.
-                                                " and ad_value=3D'".Form=
atString($value)."'");
+                                                " where frd_id in (8,9,1=
4) and ad_id=3D$1 ".
+                                                " and ad_value=3Dupper($=
2)",
+					       array(ATTR_DEF_QUICKCODE,$value));
=20
=20
-                    if ( $exist =3D=3D 0 && FormatString($value) !=3D nu=
ll )
+                    if ( Database::num_row($exist) =3D=3D 0  && FormatSt=
ring($value) !=3D null )
                     {
                         $value=3D"Attention : pas de soci=C3=A9t=C3=A9 "=
;
                     }
                 }
=20
                 // Normal traitement
-                $value2=3DFormatString($value);
-                $sql=3Dsprintf("update fiche_detail set ad_value=3D'%s' =
where jft_id=3D%d",
-                             trim($value2),$jft_id);
-                $this->cn->exec_sql($sql);
+                $sql=3D"update fiche_detail set ad_value=3Dupper($1) whe=
re jft_id=3D$2";
+		$this->cn->exec_sql($sql,array($value,$jft_id));
             }
         }
         catch (Exception $e )

Modified: phpcompta/trunk/include/class_html_table.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/class_html_table.php	2011-06-18 01:04:28 UTC =
(rev 4170)
+++ phpcompta/trunk/include/class_html_table.php	2011-06-28 21:10:26 UTC =
(rev 4171)
@@ -73,10 +73,10 @@
   }
 @endcode
    */
-  static function sql2table($cn,$a_col,$sql,$table_style=3D"result",$a_s=
ql_var=3Dnull)
+  static function sql2table($cn,$a_col,$sql,$table_style=3D'class=3D"res=
ult"',$a_sql_var=3Dnull)
   {
     $r=3D'';
-    $r=3Dsprintf('<table style=3D"%s">',$table_style);
+    $r=3Dsprintf('<table %s>',$table_style);
     $r.=3D'<tr>';
     for ( $i=3D0;$i <count($a_col);$i++)
       {
@@ -96,7 +96,7 @@
 	  $r.=3D th($content);
       }
     $r.=3D'</tr>';
-    $ret=3D$cn->exec_sql($sql);
+    $ret=3D$cn->exec_sql($sql,$a_sql_var);
     for ($i=3D0;$i<Database::num_row($ret);$i++)
       {
 	$r.=3D'<tr>';

Modified: phpcompta/trunk/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/constant.php	2011-06-18 01:04:28 UTC (rev 417=
0)
+++ phpcompta/trunk/include/constant.php	2011-06-28 21:10:26 UTC (rev 417=
1)
@@ -37,12 +37,12 @@
=20
 $version_phpcompta=3DSVNINFO;=20
 define ("DEBUG",false);
+/*
+define ("DEBUG",true);
+$version_phpcompta=3D4014;
+*/
=20
-//define ("DEBUG",true);
-//$version_phpcompta=3D4014;
-
-
-define ("DBVERSION",95);
+define ("DBVERSION",97);
 define ("DBVERSIONREPO",13);
 define ('NOTFOUND','--not found--');
=20



From MAILER-DAEMON Tue Jun 28 17:17:18 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Qbfeo-0006cE-0m
	for mharc-phpcompta-dev@gnu.org; Tue, 28 Jun 2011 17:17:18 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Tue, 28 Jun 2011 23:22:10 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.33342.1309295835.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4172 - in phpcompta/trunk: html include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Tue, 28 Jun 2011 21:17:14 -0000

Author: danydb
Date: 2011-06-28 23:22:09 +0200 (Tue, 28 Jun 2011)
New Revision: 4172

Removed:
   phpcompta/trunk/html/import.php
   phpcompta/trunk/include/import_inc.php
Modified:
   phpcompta/trunk/include/user_menu.php
Log:
Remove import bank from the main=20

Deleted: phpcompta/trunk/html/import.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/import.php	2011-06-28 21:10:26 UTC (rev 4171)
+++ phpcompta/trunk/html/import.php	2011-06-28 21:22:09 UTC (rev 4172)
@@ -1,164 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
- */
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-// Author Olivier Dzwoniarkiewicz
-/*! \file
- * \brief for importing Bank operations
- */
-
-include_once("ac_common.php");
-include_once("user_menu.php");
-include_once ("constant.php");
-require_once('class_database.php');
-require_once('function_javascript.php');
-load_all_script();
-require_once('class_dossier.php');
-$gDossier=3Ddossier::id();
-
-$cn=3Dnew Database($gDossier);
-
-include ('class_user.php');
-$User=3Dnew User($cn);
-$User->Check();
-$User->check_dossier(dossier::id());
-
-html_page_start($User->theme);
-
-
-/* Admin. Dossier */
-
-include_once("import_inc.php");
-
-include_once ("user_menu.php");
-echo '<div class=3D"u_tmenu">';
-echo ShowMenuCompta("user_advanced.php?".dossier::get());
-echo '</div>';
-
-
-echo ShowMenuAdvanced(7);
-$User->can_request(GEBQ,1);
-
-echo '</div>';
-echo '<div class=3D"content"> <h2> Ce module est obsol=C3=A8te et est re=
mplac=C3=A9 par un plugin. Il sera d=C3=A9finitivement enlev=C3=A9 dans l=
a prochaine
- version. Si possible ne l\'utilisez plus</h2>';
-echo '</div>';
-
-echo '<div class=3D"lmenu">';
-ShowMenuImport();
-
-// if action is set proceed to it
-if ( isset ($_GET["action"]) )
-{
-    $action=3D$_GET["action"];
-    // menu =3D import cvs
-    if ($action =3D=3D "import" )
-    {
-        if(isset($_FILES['fupload']))
-        {
-            // load the table with the cvs' content
-            echo '<DIV class=3D"u_redcontent">';
-            ImportCSV($cn,$_FILES['fupload']['tmp_name'],$_POST['import_=
bq'],$_POST['format_csv'],$_POST['import_jrn']);
-            echo "</DIV>";
-        }
-        else
-        {
-            echo '<DIV class=3D"u_redcontent">';
-            ShowFormTransfert($cn);
-            echo "</DIV>";
-        }
-    }
-    if ($action =3D=3D "verif" )
-    {
-        echo '<DIV class=3D"u_redcontent">';
-        VerifImport($cn);
-        echo "</DIV>";
-    }
-
-    if ($action =3D=3D "transfer" )
-    {
-
-        echo '<DIV class=3D"u_redcontent">';
-        /* show the possible period */
-        $default_period=3D$User->get_periode();
-        $ip=3Dnew IPeriod('period');
-        $ip->filter_year=3Dtrue;
-        $ip->user=3D$User;
-        $ip->value=3D(isset($_GET['period']))?$_GET['period']:$default_p=
eriod;
-        $ip->cn=3D$cn;
-        $ip->type=3DOPEN;
-        $ip->javascript=3D"onchange=3Dsubmit(this)";
-        echo '<form method=3D"get" action=3D"import.php" >';
-        echo dossier::hidden();
-        echo HtmlInput::hidden('action','transfer');
-        echo _('Choississez la p=C3=A9riode =C3=A0 transf=C3=A8rer');
-        echo $ip->input();
-        echo '</form>';
-        //   TransferCSV($cn,
-        ConfirmTransfert($cn,$ip->value);
-        echo "</DIV>";
-    }
-}
-/*-----------------------------------------------
- * transfert or remove the wrong record=20
- *
- *-----------------------------------------------*/
-if ( isset ($_POST['action']))
-{
-    $action=3D$_POST['action'];
-    if ($action =3D=3D "transfer" )
-    {
-        echo '<DIV class=3D"u_redcontent">';
-        TransferCSV($cn, $User->get_periode());
-        echo "</DIV>";
-    }
-
-    if ($action =3D=3D "remove" )
-    {
-        echo '<DIV class=3D"u_redcontent">';
-        RemoveCSV($cn);
-        ConfirmTransfert($cn,$User->get_periode());
-        echo "</DIV>";
-    }
-
-}
-if ( isset($_REQUEST['action']) && $_REQUEST['action']=3D=3D'purge')
-{
-    if ( isset($_POST['ok']))
-    {
-        echo '<div class=3D"u_redcontent">';
-        echo h2info('Toutes  les donn=C3=A9es CSV sont effac=C3=A9es');
-        $cn->exec_sql('truncate import_tmp');
-        echo '</DIV>';
-
-    }
-    else
-    {
-        echo '<div class=3D"u_redcontent">';
-        echo '<p> En purgeant la table, vous effacez toutes les donn=C3=A9=
es des fichiers CSV que vous avez import=C3=A9s,
-        cela n\' affecte pas les op=C3=A9rations d=C3=A9j=C3=A0 transf=C3=
=A8r=C3=A9es dans la comptabilit=C3=A9</p>';
-        echo '<form method=3D"POST">';
-        echo HtmlInput::hidden('action','purge');
-        echo HtmlInput::submit('ok','Purger');
-        echo '</FORM>';
-        echo '</DIV>';
-    }
-}
-html_page_stop();
-?>

Deleted: phpcompta/trunk/include/import_inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/import_inc.php	2011-06-28 21:10:26 UTC (rev 4=
171)
+++ phpcompta/trunk/include/import_inc.php	2011-06-28 21:22:09 UTC (rev 4=
172)
@@ -1,417 +0,0 @@
-
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/*!\file
- * \brief import operation into the accountancy
- */
-// Copyright Author Olivier Dzwoniarkiewicz
-// Modified Dany De Bontridder ddebontridder@yahoo.fr
-// $Revision$
-include_once("user_common.php");
-require_once("class_icard.php");
-require_once("class_iconcerned.php");
-require_once("class_ispan.php");
-require_once("class_iselect.php");
-require_once('class_user.php');
-require_once('class_fiche.php');
-require_once('class_acc_ledger.php');
-require_once("class_acc_parm_code.php");
-require_once('class_acc_operation.php');
-require_once('class_ipopup.php');
-
-/*!
- * \brief  Parse the file and insert the record
- *          into the table import_tmp. Insert in a temporary table, if
- *          no confirmation is given then the data are removed otherwise
- *          records are inserted into import_tmp. Following
- *          the choosen bank a different file is included to=20
- *          to parse the CSV, take the cbc_be.inc.php as template
- *       =20
- * \param $p_cn database connection
- * \param $file  the uploaded file
- * \param $p_bq_account the bank account (target)
- * \param $p_format_csv file to include (depending of the bank)
- *@todo this function doesn't update the table quant_fin, it must be don=
e
- * Run first the fill_quant_fin=20
- *@see upgrade76.sql
- */
-function ImportCSV($p_cn,$file,$p_bq_account,$p_format_csv,$p_jrn)
-{
-    if(!$handle =3D fopen($file, "r"))
-    {
-        print 'could not open file. quitting';
-        die;
-    }
-
-    $p_cn->start();
-
-
-// include the right format for CSV --> given by the <form
-    require_once($p_format_csv);
-
-
-    echo _("Importation termin=C3=A9e");
-
-// if importation succeeds then we can commit the change
-    $p_cn->commit();
-
-}
-
-/*!\brief This function show a record from the table import_tmp, the tag=
 for the form
- *        are not included in the function and must set in the calling p=
roc.
- * \param $p_val array (row from import_type)
- * \param $counter a counter used in the form
- * \param $p_cn database connection
- * \param $p_form indicates if the button for the form is enable,
- *        modify the Quick Code or remove record poss.value are form, re=
move
- */
-function ShowBox($p_val,$counter,$p_cn,$p_form=3D'form')
-{
-    $w=3Dnew ICard();
-    $w->jrn=3D$p_val['jrn'];
-    $w->name=3D'poste'.$counter;
-    $w->extra=3D'filter';
-    $w->typecard=3D'deb';
-    $w->set_dblclick("fill_ipopcard(this);");
-    $w->set_attribute('ipopup','ipopcard');
-    $w->set_callback('filter_card');
-    $w->set_function('fill_data');
-
-    $w->table=3D0;
-    if ( $p_form =3D=3D 'remove' )
-        $w->readOnly=3Dtrue;
-
-    $oJrn=3Dnew Acc_Ledger($p_cn,$p_val['jrn']);
-    // widget concerned
-    $wConcerned=3Dnew IConcerned();
-    $wConcerned->name=3D"e_concerned"+$counter;
-    $wConcerned->extra=3Dabs($p_val['montant']);
-    $wConcerned->extra2=3D'paid';
-    $wConcerned->label=3D_('op. concern=C3=A9e');
-    $wConcerned->table=3D0;
-    $wConcerned->value=3D$p_val['jr_rapt'];
-
-    $s=3Dnew ISpan();
-
-    // if in readonly retrieve the conc. ope
-    if ( $p_form=3D=3D 'remove')
-    {
-        $wConcerned->readOnly=3Dtrue;
-    }
-
-    if ( isset($p_val['poste_comptable']))
-    {
-        $w->value=3D$p_val['poste_comptable'];
-        $cn=3Dnew Database(dossier::id());
-        $f=3Dnew Fiche($p_cn);
-        $f->get_by_qcode($p_val['poste_comptable']);
-        $s->value=3D$f->strAttribut(ATTR_DEF_NAME);
-    }
-    echo '<input type=3D"hidden" id=3D"code'.$counter.'" value=3D"'.$p_v=
al['code'].'">';
-    echo '<input type=3D"hidden" name=3D"count" value=3D"'.$counter.'">'=
;
-    echo HtmlInput::hidden('p_jrn',$p_val['jrn']);
-    echo '<table border=3D"1" width=3D"500">';
-    echo '<tr><td width=3D"200">'.$p_val['code'].'</td><td width=3D"200"=
>'.$p_val['date_exec'].'</td><td width=3D"100">'.$p_val['montant'].' EUR<=
/td><tr/>';
-    echo "<tr><td>"._('Journal')." : ".$oJrn->get_name()."</TD><TD>"._('=
poste comptable Destination')." : ".$p_val['bq_account']."</td><tr>";
-    echo '<tr colspan=3D"3"><td height=3D"50" colspan=3D"3">'.$p_val['de=
tail'].'</td></tr>';
-    echo '<tr><td  colspan=3D"3"> '.$wConcerned->input("e_concerned".$co=
unter).'</td></tr>';
-    echo '<tr><td>'.$w->search().$w->input().' '.$s->input('poste'.$coun=
ter.'_label').
-    "</TD>";
-
-    echo "<td>n=C2=B0 compte : ".$p_val['num_compte']."</td>";
-    if ( $p_form =3D=3D 'form')
-    {
-        $str_update=3Dsprintf("import_update('%s','%s');",
-                            dossier::id(),
-                            $counter);
-        $str_remove=3Dsprintf("import_remove('%s','%s');",
-                            dossier::id(),
-                            $counter);
-
-        echo '<td><input type=3D"button" value=3D"Modifier" onClick=3D"'=
.$str_update.'">';
-        echo '<input type=3D"button" name=3D"trashit" value=3D"Effacer..=
"'.
-        ' onClick=3D"'.$str_remove.'" >'.
-        '</td><tr/>';
-    }
-    if ($p_form =3D=3D 'remove' )
-    {
-        $str_notconfi=3Dsprintf("import_not_confirmed('%s','%s');",
-                              dossier::id(),
-                              $counter);
-
-        echo '<td><input type=3D"button" value=3D'._("Enlever").' onClic=
k=3D"'.$str_notconfi.'"'.
-        '></td><tr/>';
-    }
-
-    echo '</table>';
-
-}
-/*!\brief Verify the import
- */
-
-function VerifImport($p_cn)
-{
-    $sql =3D "select * from import_tmp where status=3D'n' ".
-           " order by date_exec,code";
-    $Res=3D$p_cn->exec_sql($sql);
-    $Num=3DDatabase::num_row($Res);
-    echo $Num._(" op=C3=A9rations =C3=A0 compl=C3=A8ter")."<br/><br/>";
-    // include javascript for popup
-
-    for ( $i=3D0;$i< $Num;$i++)
-    {
-        $val =3D Database::fetch_array($Res,$i);
-        echo '<form METHOD=3D"POST" id=3D"form_'.$i.'"action=3D"import.p=
hp?action=3Dverif">';
-        echo dossier::hidden();
-        ShowBox($val,$i,$p_cn,'form');
-        echo '</form>';
-    }
-
-}
-/*!\brief ConfirmCSV shows the operation which are going to be transfere=
d
- * =20
- * \param $p_cn database conx      =20
- * \param $periode user's periode
- */
-function ConfirmTransfert($p_cn,$periode)
-{
-
-    $sql =3D "select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_=
end,'DD-MM-YYYY') as p_end".
-           " from parm_periode where p_id =3D '".$periode."'";
-    $Res=3D$p_cn->exec_sql($sql);
-    $val =3D Database::fetch_array($Res);
-    if ( $val =3D=3D false )
-    {
-        alert (_('Vous devez selectionner votre p=C3=A9riode dans vos pr=
=C3=A9f=C3=A9rences'));
-        exit();
-    }
-    $start =3D"to_date('".$val['p_start']."','DD-MM-YYYY')";
-    $end =3D "to_date('".$val['p_end']."','DD-MM-YYYY')";
-
-    $sql =3D "select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, =
".
-           " montant,num_compte,poste_comptable,bq_account,jrn,detail,jr=
_rapt ".
-           " from import_tmp where
-           status =3D 'w' AND date_exec BETWEEN ".$start." and ".$end;
-
-
-
-    $Res=3D$p_cn->exec_sql($sql);
-    $Num=3DDatabase::num_row($Res);
-    echo $Num." "._("op=C3=A9rations =C3=A0 transf=C3=A8rer")."<br/><br/=
>";
-    if ( $Num =3D=3D 0 ) return;
-
-    for ( $i=3D0;$i<$Num;$i++)
-    {
-        $val =3D Database::fetch_array($Res,$i);
-        echo '<form method=3D"post" id=3D"form_'.$i.'" action=3D"import.=
php">';
-        echo dossier::hidden();
-        echo '<input type=3D"hidden" name=3D"action" value=3D"remove">';
-        ShowBox($val,$i,$p_cn,'remove');
-        echo '</form>';
-    }
-    echo '<form method=3D"post" id=3D"form_'.$i.'" action=3D"import.php"=
>';
-    echo dossier::hidden();
-    /*  to avoid double post */
-    $mt=3Dmicrotime(true);
-    echo HtmlInput::hidden('mt',$mt);
-    echo HtmlInput::hidden("action" ,"transfer");
-    echo HtmlInput::hidden("period" ,$periode);
-    echo HtmlInput::submit("sub",_("Commencer le transfert"));
-    echo '</form>';
-
-}
-
-/*!\brief Transfert data into the ledger
- *        set the column import_tmp.status to w (wait) if the account is=
 not correct
- *        otherwise transfert it to the ledger and set the column import=
_tmp.status
- *        to t (transfert)
- * \param $p_cn connx
- * \param $periode periode=20
- */
-
-function TransferCSV($p_cn, $periode)
-{
-    //on obtient la p=C3=A9riode courante
-    $User=3Dnew User($p_cn);
-    $periode =3D $User->get_periode();
-
-    // on trouve les dates fronti=C3=A8res de cette p=C3=A9riode
-    $sql =3D "select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_=
end,'DD-MM-YYYY') as p_end".
-           " from parm_periode where p_id =3D '".$periode."'";
-
-    $Res=3D$p_cn->exec_sql($sql);
-    $val =3D Database::fetch_array($Res);
-    if ( $val =3D=3D false )
-    {
-        alert (_('Vous devez selectionner votre p=C3=A9riode dans vos pr=
=C3=A9f=C3=A9rences'));
-        exit();
-    }
-
-    $start =3D"to_date('".$val['p_start']."','DD-MM-YYYY')";
-    $end =3D "to_date('".$val['p_end']."','DD-MM-YYYY')";
-    $sql =3D "select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, =
".
-           " montant,num_compte,poste_comptable,bq_account,jrn,detail,jr=
_rapt,it_pj ".
-           " from import_tmp where ".
-           " status=3D 'w' AND date_exec BETWEEN ".$start." and ".$end;
-
-    try
-    {
-        $p_cn->start();
-        $ResAll=3D$p_cn->exec_sql($sql);
-        $Max=3DDatabase::num_row($ResAll);
-        echo $Max." op=C3=A9rations =C3=A0 transf=C3=A9rer.<br/>";
-        for ($i =3D 0;$i < $Max;$i++)
-        {
-            $val=3DDatabase::fetch_array($ResAll,$i);
-
-            $code=3D$val['code'];
-            $date_exec=3D$val['date_exec'];
-            $montant=3D$val['montant'];
-            $num_compte=3D$val['num_compte'];
-            $poste_comptable=3D$val['poste_comptable'];
-            $bq_account=3D$val['bq_account'];
-            $jrn=3D$val['jrn'];
-            $oJrn=3Dnew Acc_Ledger($p_cn,$jrn);
-            $detail=3D$val['detail'];
-            $jr_rapt=3D$val['jr_rapt'];
-
-            // Retrieve the account thx the quick code
-            $f=3Dnew Fiche($p_cn);
-            $quick_code=3D$poste_comptable;
-            $f->get_by_qcode($poste_comptable,false);
-            $poste_comptable=3D$f->strAttribut(ATTR_DEF_ACCOUNT);
-            $f->get_by_qcode($bq_account);
-            $bq_poste=3D$f->strAttribut(ATTR_DEF_ACCOUNT);
-            // V=C3=A9rification que le poste comptable trouv=C3=A9 exis=
te
-            if ( $poste_comptable =3D=3D NOTFOUND || strlen(trim($poste_=
comptable))=3D=3D0)
-                $test=3D0;
-            else
-            {
-                $sqltest =3D "select * from tmp_pcmn WHERE pcm_val=3D$1"=
;
-                $Restest=3D$p_cn->exec_sql($sqltest,array($poste_comptab=
le));
-                $test=3DDatabase::num_row($Restest);
-            }
-
-            // Test it
-            if($test =3D=3D 0)
-            {
-                $sqlupdate =3D "update import_tmp set status=3D'n' WHERE=
 code=3D$1  or num_compte is null";
-                $Resupdate=3D$p_cn->exec_sql($sqlupdate,array($code));
-                echo _("Poste comptable erronn=C3=A9 pour l'op=C3=A9rati=
on ").$num_compte."-".$code.", ".("r=C3=A9initialisation du poste comptab=
le")."<br/>";
-                continue;
-            }
-
-
-            // Finances
-
-            $seq=3D$p_cn->get_next_seq('s_grpt');
-            $p_user =3D $_SESSION['g_user'];
-
-            $acc_op=3Dnew Acc_Operation($p_cn);
-            $acc_op->amount=3D$montant;
-            $acc_op->desc=3D$detail;
-            $acc_op->type=3D"d";
-            $acc_op->date=3D$date_exec;
-            $acc_op->user=3D$p_user;
-            $acc_op->poste=3D$bq_poste;
-            $acc_op->grpt=3D$seq;
-            $acc_op->jrn=3D$jrn;
-            $acc_op->periode=3D$periode;
-            $acc_op->qcode=3D$bq_account;
-            $acc_op->mt=3D$_REQUEST['mt'];
-            $r=3D$acc_op->insert_jrnx();
-
-
-            $acc_op->type=3D"c";
-            $acc_op->poste=3D$poste_comptable;
-            $acc_op->amount=3D$montant;
-            $acc_op->qcode=3D$quick_code;
-            $r=3D$acc_op->insert_jrnx();
-
-
-
-            //remove annoying double-quote
-            $num_compte=3Dstr_replace('"','',$num_compte);
-            $code=3Dstr_replace('\"','',$code);
-            $acc_op->comment=3D$detail.$num_compte." ".$code;
-
-            $jr_id=3D$acc_op->insert_jrn();
-            $sql=3D"update jrn set jr_pj_number=3D$1 where jr_id=3D$2";
-            $p_cn->exec_sql($sql,array($val['it_pj'],$jr_id));
-
-            $internal=3D$oJrn->compute_internal_code($seq);
-
-            $Res=3D$p_cn->exec_sql("update jrn set jr_internal=3D$1 wher=
e jr_id =3D $2",array($internal,$jr_id));
-
-            // insert rapt
-
-            $acc_reconc=3Dnew Acc_Reconciliation($p_cn);
-            $acc_reconc->set_jr_id=3D$jr_id;
-            $acc_reconc->insert($jr_rapt);
-
-            echo _("Tranfert de l'op=C3=A9ration ").$code._(" effectu=C3=
=A9")."<br/>";
-            $sql2 =3D "update import_tmp set status=3D't' where code=3D'=
".$code."'";
-            $Res2=3D$p_cn->exec_sql($sql2);
-        }
-    }
-    catch (Exception $e)
-    {
-        $p_cn->rollback();
-        echo '<span class=3D"error">'.
-        'Erreur dans '.__FILE__.':'.__LINE__.
-        ' Message =3D '.$e->getMessage().
-        '</span>';
-    }
-
-    $p_cn->commit();
-
-}
-/*!
-* \brief  ShowForm for getting data about=20
-*           the bank transfert in cvs
-*       =20
-* \param  $p_cn  database connection
-*/
-
-function ShowFormTransfert($p_cn)
-{
-    $w=3Dnew ISelect();
-    echo '<FORM METHOD=3D"POST" action=3D"import.php?action=3Dimport" en=
ctype=3D"multipart/form-data">';
-    echo dossier::hidden();
-    echo '<INPUT TYPE=3D"file" name=3D"fupload" size=3D"20"><br>';
-    // ask for the journal target
-    $jrn=3D$p_cn->make_array ("select jrn_def_id,jrn_def_name from jrn_d=
ef where jrn_def_type=3D'FIN';");
-    $w->label=3D_('Journal');
-    echo $w->label." :".$w->input('import_jrn',$jrn)."<br>";
-    // choose the bank account
-    $banque=3Dnew Acc_Parm_Code($p_cn,'BANQUE');
-    $caisse=3Dnew Acc_Parm_Code($p_cn,'CAISSE');
-    $sql=3D"select j_qcode,vw_name from vw_poste_qcode join vw_fiche_att=
r on (j_qcode=3Dquick_code) where j_poste::text like ".$caisse->p_value."=
||'%'
-         or j_poste::text like ".$banque->p_value."::text||'%'";
-    $bq=3D$p_cn->make_array($sql);
-    $w->label=3D'Banque';
-    echo "Compte en banque :".$w->input('import_bq',$bq)."<br>";
-    $format_csv=3D$p_cn->make_array("select include_file,name from forma=
t_csv_banque;");
-    $w->label=3D"Format import";
-    echo $w->label.$w->input('format_csv',$format_csv).'<br>';
-    echo HtmlInput::submit("Import fiche",_("Import fiche"));
-    echo '</FORM>';
-}
-
-?>

Modified: phpcompta/trunk/include/user_menu.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/user_menu.php	2011-06-28 21:10:26 UTC (rev 41=
71)
+++ phpcompta/trunk/include/user_menu.php	2011-06-28 21:22:09 UTC (rev 41=
72)
@@ -238,7 +238,6 @@
                   =20
                             array('compta.php?p_action=3Dstock&'.$str_do=
ssier,'Stock',_("Gestion des stocks"),5),
                             array('user_advanced.php?p_action=3Ddefrepor=
t&'.$str_dossier,_('Rapport'),_("Rapport"),6),
-                            array('import.php?'.$str_dossier,_('Import B=
anque'),_("Banque"),7),
                             array('user_advanced.php?p_action=3Douv&'.$s=
tr_dossier,_('Ecriture ouverture'),"",8),
                             array('user_advanced.php?p_action=3Dverif&'.=
$str_dossier,_('V=C3=A9rification'),"",10)
                         ),



From MAILER-DAEMON Wed Jun 29 12:45:53 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Qbxtg-0007j6-Qs
	for mharc-phpcompta-dev@gnu.org; Wed, 29 Jun 2011 12:45:53 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Wed, 29 Jun 2011 18:50:40 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.35433.1309365951.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4173 - in phpcompta/trunk: include sql
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Jun 2011 16:45:51 -0000

Author: danydb
Date: 2011-06-29 18:50:38 +0200 (Wed, 29 Jun 2011)
New Revision: 4173

Removed:
   phpcompta/trunk/include/argenta_be.inc.php
   phpcompta/trunk/include/cbc_be.inc.php
   phpcompta/trunk/include/cbc_be_ol.inc.php
   phpcompta/trunk/include/dexia.inc.php
   phpcompta/trunk/include/dexia_be.inc.php
   phpcompta/trunk/include/eub_be.inc.php
   phpcompta/trunk/include/fortis_be.inc.php
   phpcompta/trunk/include/ing_be.inc.php
   phpcompta/trunk/include/keytrade_be.inc.php
Modified:
   phpcompta/trunk/sql/upgrade.sql
Log:
#10 replace import bank by plugin


Deleted: phpcompta/trunk/include/argenta_be.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/argenta_be.inc.php	2011-06-28 21:22:09 UTC (r=
ev 4172)
+++ phpcompta/trunk/include/argenta_be.inc.php	2011-06-29 16:50:38 UTC (r=
ev 4173)
@@ -1,127 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-/*! \file
- * \brief This file must be included to parse the CVS from the CBC Bank
- */
-
-
-
-//-----------------------------------------------------
-// Bank Argenta
-//-----------------------------------------------------
-$line=3D0;
-$p_cn->set_encoding('latin1');
-
-while (($data =3D fgetcsv($handle, 2000,"!")) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-    for ($c=3D0; $c < $num; $c++)
-    {
-        if ( $line=3D=3D1)
-        {
-            $row=3Dexplode(';',$data[$c]);
-            $num_compte=3D$row[1];
-        }
-        if ( $line < 2 )
-            continue;
-//-----------------------------------------------------
-// Parsing CSV comes here
-//-----------------------------------------------------
-        $row=3Dexplode(';',$data[$c]);
-        echo 'ici sizeof $row =3D '.sizeof($row);
-        if ( sizeof ($row) < 9 )
-            continue;
-
-
-        $date_exec=3D$row[5];
-        $date_val=3D$row[5];
-        $code=3D$row[1]."/".$row[0];
-        // remove first the thousand sep.
-        $montant=3Dstr_replace('.','',$row[3]);
-        // replace the coma by a period
-        $montant=3Dstr_replace(',','.',$montant);
-        // remove the sign
-        $montant=3Dstr_replace('+','',$montant);
-        $devise=3D$row[4];
-        $compte_ordre=3D$row[6];
-        $detail=3D'virement du compte:'.$compte_ordre.trim($row[2]).' '.=
trim($row[7]).' '.trim($row[8]).' '.trim($row[9]);
-
-//----------------------------------------------------
-// Skip dubbel
-//----------------------------------------------------
-        $code=3DFormatString($code);
-        $num_compte=3DFormatString($num_compte);
-        if ( $p_cn->count_sql(utf8_encode("select * from import_tmp wher=
e code=3D'$code' and num_compte=3D'$num_compte' limit 2")) !=3D 0 )
-        {
-            /* Skip it it already encoded */
-            echo "Doublon =C3=A9limin=C3=A9 ".$detail;
-            echo "<br>";
-            continue;
-        }
-        echo "Ajout de $detail";
-        echo "<br>";
-
-//-----------------------------------------------------
-// insert into import_tmp
-//-----------------------------------------------------
-        $Sql=3D"insert into import_tmp (code,
-             date_exec ,
-             date_valeur,
-             montant,
-             devise,
-             compte_ordre,
-             num_compte,
-             detail,
-             bq_account ,
-             jrn,
-             status)
-             values ('$code',
-             to_date('$date_exec','DD-MM-YYYY'),
-             to_date('$date_exec','DD-MM-YYYY'),
-             $montant,
-             '$devise',
-             '".addslashes($compte_ordre)."',
-             '".$num_compte."',
-             '".addslashes($detail)."	',
-             '$p_bq_account',
-             $p_jrn,
-             'n')";
-        try
-        {
-            $p_cn->exec_sql($Sql);
-        }
-
-
-        catch(Exception $e)
-        {
-            echo(__FILE__.":".__LINE__." Erreur : ".$e->getCode()." msg =
".$e->getMessage());
-            rollback($p_cn);
-            break;
-        }
-
-    } // for ($c=3D0;$c<$num;$c++)
-    $line++;
-
-} // file is read
-
-fclose($handle);
-$p_cn->commit();
-?>

Deleted: phpcompta/trunk/include/cbc_be.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/cbc_be.inc.php	2011-06-28 21:22:09 UTC (rev 4=
172)
+++ phpcompta/trunk/include/cbc_be.inc.php	2011-06-29 16:50:38 UTC (rev 4=
173)
@@ -1,96 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-/*! \file
- * \brief This file must be included to parse the CVS from the CBC Bank
- */
-
-//-----------------------------------------------------
-// Bank CBC
-//-----------------------------------------------------
-$row=3D1;
-$p_cn->start();
-$p_cn->set_encoding('latin1');
-while (($data =3D fgetcsv($handle, 2000,'@')) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-    for ($c=3D0; $c < $num; $c++)
-    {
-//-----------------------------------------------------
-// Parsing CSV comes here
-//-----------------------------------------------------
-        $row=3Dexplode(';',$data[$c]);
-        if ( sizeof ($row) < 13 )
-            continue;
-
-        $num_compte=3D$row[0];
-        $date_exec=3D$row[3];
-        $date_val=3D$row[4];
-        // remove first the thousand sep.
-        $montant=3Dstr_replace('.','',$row[6]);
-        // replace the coma by a period
-        $montant=3Dstr_replace(',','.',$montant);
-        // remove the sign
-        $montant=3Dstr_replace('+','',$montant);
-        $devise=3D$row[1];
-        $compte_ordre=3D$row[0];
-        $detail=3Dtrim($row[7]).' '.trim($row[8]).' '.trim($row[9]).' '.=
trim($row[10]);
-        if (  myereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[7],$r) )
-        {
-            $compte_ordre=3D$r[0];
-        }
-//-----------------------------------------------------
-// insert into import_tmp
-//-----------------------------------------------------
-        $Sql=3D"insert into import_tmp (code,
-             date_exec ,
-             date_valeur,
-             montant,
-             devise,
-             compte_ordre,
-             detail,
-             bq_account ,
-             jrn,
-             status)
-             values (nextval('s_cbc'),
-             to_date('$date_exec','YYYYMMDD'),
-             to_date('$date_exec','YYYYMMDD'),
-             $montant,
-             '$devise',
-             '".addslashes($compte_ordre)."',
-             '".addslashes($detail).$num_compte."	',
-             '$p_bq_account',
-             $p_jrn,
-             'n')";
-        try
-        {
-            $p_cn->exec_sql($Sql) ;
-        }
-        catch(Exception $e)
-        {
-            $p_cn->rollback();
-            break;
-        }
-    } // for ($c=3D0;$c<$num;$c++)
-    $row++;
-} // file is read
-fclose($handle);
-echo "Encore rien d=C3=A9sol=C3=A9";
-?>

Deleted: phpcompta/trunk/include/cbc_be_ol.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/cbc_be_ol.inc.php	2011-06-28 21:22:09 UTC (re=
v 4172)
+++ phpcompta/trunk/include/cbc_be_ol.inc.php	2011-06-29 16:50:38 UTC (re=
v 4173)
@@ -1,93 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
- */
-/* $Revision: 3151 $ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-/*! \file
- * \brief This file must be included to parse the CVS from the CBC Bank
- */
-
-//-----------------------------------------------------
-// Bank CBC
-//-----------------------------------------------------
-$line=3D0;
-$p_cn->start();
-$p_cn->set_encoding('latin1');
-while (($row =3D fgetcsv($handle, 2000,';')) !=3D=3D FALSE)
-{
-
-    $num =3D count($row);
-    if ( $num !=3D 11 ) continue;
-    if (  $row[3] !=3D 'EUR') continue;
-    $line++;
-    //-----------------------------------------------------
-    // Parsing CSV comes here
-    //-----------------------------------------------------
-    $num_compte=3D$row[0];
-    $date_exec=3D$row[5];
-    $date_val=3D$row[7];
-    // remove first the thousand sep.
-    $montant=3Dstr_replace(' ','',$row[8]);
-    // replace the coma by a period
-    $montant=3Dstr_replace(',','.',$montant);
-    // remove the sign
-    $montant=3Dstr_replace('+','',$montant);
-    $devise=3D$row[3];
-    $ref_extrait=3D$row[4].'-'.$line;
-    $detail=3D$line.'/'.$row[4].' '.$row[6];
-    $pj=3D$row[10];
-    //
-    //-----------------------------------------------------
-    // insert into import_tmp
-    //-----------------------------------------------------
-    $Sql=3D"insert into import_tmp (code,
-         date_exec ,
-         date_valeur,
-         montant,
-         devise,
-         detail,
-         bq_account ,
-         jrn,
-         status,
-         it_pj)
-         values ('$ref_extrait',
-         to_date('$date_exec','DD/MM/YYYY'),
-         to_date('$date_exec','DD/MM/YYYY'),
-         $montant,
-         '$devise',
-         '$detail',
-         '$p_bq_account',
-         $p_jrn,
-         'n',$pj)";
-    try
-    {
-        $p_cn->exec_sql($Sql) ;
-    }
-    catch(Exception $e)
-    {
-        $p_cn->rollback();
-        break;
-    }
-} // file is read
-fclose($handle);
-if ($line =3D=3D0 )
-    echo "Encore rien d=C3=A9sol=C3=A9";
-else
-    echo "$line lignes sont import=C3=A9es";
-echo '<br>';
-?>

Deleted: phpcompta/trunk/include/dexia.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/dexia.inc.php	2011-06-28 21:22:09 UTC (rev 41=
72)
+++ phpcompta/trunk/include/dexia.inc.php	2011-06-29 16:50:38 UTC (rev 41=
73)
@@ -1,149 +0,0 @@
-<?php
-/*
- * This file is part of PhpCompta.
- *
- * PhpCompta is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * PhpCompta is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with PhpCompta; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U=
SA
-*/
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-// Author DEXIA Adaptation Guy Moins
-/*! \file
- * \brief This file must be included to parse the CVS from the DEXIA Ban=
k
- */
-
-
-
-//-----------------------------------------------------
-// Bank DEXIA
-//-----------------------------------------------------
-$LinesSkipped=3D0;
-$LinesImported=3D0;
-$LinesDup=3D0;
-$row=3D1;
-$p_cn->start();
-while (($data =3D fgetcsv($handle, 2000,'@')) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-
-    //-----------------------------------------------------
-    // Parsing CSV comes here
-    //-----------------------------------------------------
-
-    $row=3Dexplode(';',$data[0]);
-    //to avoid a level of if
-    if (!(isset($row[2]))) $row[2]=3D'';
-
-
-    // Skipping all the lines whith a blank operation reference ('num=C3=
=A9ro extrait')
-    if ( $row[2] =3D=3D '' ||
-            !(myereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
-    {
-        $LinesSkipped++;
-        continue;
-    }
-    // Alternative filter : import all the operations even without a ref=
erence
-    // !! Disable check of doubles as all the unreferenced operations ha=
ve hte smae
-    //NULL' reference
-    // Just use the following test : if (
-    //!(myereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
-
-    // Parsing the remaining lines
-    $num_compte=3D$row[3]; // Third party bank account
-    $date_exec=3D$row[1]; // Execution date of the operation
-    $date_val=3D$row[8]; // Effective date of the operation
-    // remove the thousand sep. ** UNUSED by DEXIA
-    //$montant=3Dstr_replace('.','',$row[9]);
-    // remove the sign ** UNUSED by DEXIA
-    //$montant=3Dstr_replace('+','',$montant);
-    // replace the coma by a period
-    $montant=3Dstr_replace(',','.',$row[9]); // Amount of the operation
-    $ref_extrait=3D$row[2]; // Operation reference
-    $devise=3D$row[10]; // Curency used
-    $compte_ordre=3D$row[0]; // Your own bank account
-    $detail=3Dtrim($row[4]).' '.trim($row[5]).' '.trim($row[6]).'
-            '.trim($row[7]);
-    //Details-Communicaion
-
-    //----------------------------------------------------
-    // Skip dubbel
-    //----------------------------------------------------
-    $Sql=3D"select * from import_tmp where code=3D'$ref_extrait' and
-         compte_ordre=3D'$compte_ordre' limit 2";
-    if ( $p_cn->count_sql($Sql) > 0)
-    {
-        /* Skip it it already encoded */
-        echo "Double skipped : $ref_extrait $detail <BR>";
-        $LinesDup++;
-        continue;
-    }
-
-
-    //------------------------------------------------------------------=
--
-    // SQL request to insert into import_tmp
-    // Adapt the format of the import's date in the ** to_date ** functi=
on
-    //------------------------------------------------------------------=
--
-    $Sql=3D"insert into import_tmp (code,
-         date_exec ,
-         date_valeur,
-         montant,
-         devise,
-         compte_ordre,
-         detail,
-         num_compte,
-         bq_account ,
-         jrn,
-         status)
-         values ( '$ref_extrait',
-         to_date('$date_exec','DD/MM/YYYY'),
-         to_date('$date_val' ,'DD/MM/YYYY'),
-         $montant,
-         '$devise',
-         '" . addslashes($compte_ordre). "',
-         '".addslashes($detail)."','" .$num_compte." ',
-         '$p_bq_account',
-         $p_jrn,
-         'n')";
-
-//-----------------------------------------------------
-// Check if no need to rollback when executing the SQL
-//-----------------------------------------------------
-    try
-    {
-        $p_cn->exec_sql($Sql);
-    }
-    catch (Exception $e)
-    {
-        $p_cn->rollback();
-        echo "Rollbacking : $ref_extrait $detail <BR>";
-        $LinesSkipped++;
-        continue;
-    }
-//-----------------------------------------------------
-// The import is OK
-//-----------------------------------------------------
-
-    $LinesImported++;
-    $row++;
-    echo "Record imported: $ref_extrait $detail <BR>";
-
-}
-//-----------------------------------------------------
-// Close and summary
-//-----------------------------------------------------
-
-fclose($handle);
-echo "<BR><B>$LinesImported operation(s) imported, $LinesSkipped text or=
 invalid
-line(s) skipped, $LinesDup operation(s) skipped as already imported<BR>"=
;
-?>

Deleted: phpcompta/trunk/include/dexia_be.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/dexia_be.inc.php	2011-06-28 21:22:09 UTC (rev=
 4172)
+++ phpcompta/trunk/include/dexia_be.inc.php	2011-06-29 16:50:38 UTC (rev=
 4173)
@@ -1,138 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-//		 Author DEXIA Adaptation Guy Moins
-/*! \file
- * \brief This file must be included to parse the CVS from the DEXIA Ban=
k
- */
-
-
-
-//-----------------------------------------------------
-// Bank DEXIA
-//-----------------------------------------------------
-$LinesSkipped=3D0;
-$LinesImported=3D0;
-$LinesDup=3D0;
-$row=3D1;
-$p_cn->start();
-while (($data =3D fgetcsv($handle, 2000,'@')) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-
-//-----------------------------------------------------
-// Parsing CSV comes here
-//-----------------------------------------------------
-
-    $row=3Dexplode(';',$data[0]);
-    //to avoid a level of if
-    if (!(isset($row[2]))) $row[2]=3D'';
-
-
-    // Skipping all the lines whith a blank operation reference ('num=C3=
=A9ro extrait')
-    if (  $row[2] =3D=3D '' || !(myereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$ro=
w[0],$r)))
-    {
-        $LinesSkipped++;
-        continue;
-    }
-    // Alternative filter : import all the operations even without a ref=
erence
-    // !! Disable check of doubles as all the unreferenced operations ha=
ve hte smae 'NULL' reference
-    // Just use the following test : if ( !(myereg('[0-9]{3}-[0-9]{7}-[0=
-9]{2}',$row[0],$r)))
-
-    // Parsing the remaining lines
-    $num_compte=3D$row[3];		// Third party bank account
-    $date_exec=3D$row[1];		// Execution date of the operation
-    $date_val=3D$row[8];		// Effective date of the operation
-    $montant=3Dstr_replace(',','.',$row[9]);		// Amount of the operation
-    $ref_extrait=3D$row[2];			        // Operation reference
-    $devise=3D$row[10];				// Curency used
-    $compte_ordre=3D$row[0];				// Your own bank account
-    $detail=3Dtrim($row[4]).' '.trim($row[5]).' '.trim($row[6]).' '.trim=
($row[7]);
-    //Details-Communicaion
-
-//----------------------------------------------------
-// Skip dubbel
-//----------------------------------------------------
-    $Sql=3D"select * from import_tmp where code=3D'$ref_extrait' and com=
pte_ordre=3D'$compte_ordre' limit 2";
-    if ( $p_cn->count_sql(utf8_encode($Sql)) > 0)
-    {
-        /* Skip it it already encoded */
-        echo "Double skipped : $ref_extrait $detail <BR>";
-        $LinesDup++;
-        continue;
-    }
-
-
-//--------------------------------------------------------------------
-// SQL request to insert into import_tmp
-// Adapt the format of the import's date in the ** to_date ** function
-//--------------------------------------------------------------------
-    $Sql=3D"insert into import_tmp (code,
-         date_exec ,
-         date_valeur,
-         montant,
-         devise,
-         compte_ordre,
-         detail,
-         num_compte,
-         bq_account ,
-         jrn,
-         status)
-         values ( '$ref_extrait',
-         to_date('$date_exec','DD/MM/YYYY'),
-         to_date('$date_val' ,'DD/MM/YYYY'),
-         $montant,
-         '$devise',
-         '" . addslashes($compte_ordre). "',
-         '".addslashes($detail)."','" .$num_compte."	',
-         '$p_bq_account',
-         $p_jrn,
-         'n')";
-
-//-----------------------------------------------------
-// Check if no need to rollback when executing the SQL
-//-----------------------------------------------------
-    try
-    {
-        $p_cn->exec_sql($Sql,'latin1') ;
-    }
-    catch (Exception $e)
-    {
-        $p_cn->rollback();
-        echo "Rollbacking    : $ref_extrait $detail <BR>";
-        $LinesSkipped++;
-        break;
-    }
-//-----------------------------------------------------
-// The import is OK
-//-----------------------------------------------------
-    $LinesImported++;
-    $row++;
-    echo "Record imported: $ref_extrait $detail <BR>";
-
-
-}
-//-----------------------------------------------------
-// Close and summary
-//-----------------------------------------------------
-
-fclose($handle);
-echo "<BR><B>$LinesImported operation(s) imported, $LinesSkipped text or=
 invalid line(s) skipped, $LinesDup operation(s) skipped as already impor=
ted<BR>";
-?>

Deleted: phpcompta/trunk/include/eub_be.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/eub_be.inc.php	2011-06-28 21:22:09 UTC (rev 4=
172)
+++ phpcompta/trunk/include/eub_be.inc.php	2011-06-29 16:50:38 UTC (rev 4=
173)
@@ -1,87 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-// Author Olivier Dzwoniarkiewicz
-/*! \file
- * \brief File included to parse CSV from EUB Bank
- */
-
-//-----------------------------------------------------
-// Bank type =3D eub
-//-----------------------------------------------------
-$row=3D1;
-$p_cn->set_encoding('latin1');
-while (($data =3D fgetcsv($handle, 2000,'@')) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-    for ($c=3D0; $c < $num; $c++)
-    {
-
-        // first line is skipped
-        if ( $row > 1)
-        {
-            $code=3D"";
-            $date_exec=3D"";
-            $detail=3D"";
-            $montant=3D"";
-            list($code, $date_exec, $detail, $montant) =3D explode(";", =
$data[$c]);
-
-            $date_exec =3D str_replace("\t", "", $date_exec);
-            $date_exec =3D str_replace(" ", "", $date_exec);
-
-            list($annee,$mois,$jour) =3D explode("-", $date_exec);
-
-            $montant =3D str_replace(".", "", $montant);
-            $montant =3D str_replace(",", ".", $montant);
-            $montant =3D str_replace("+", "", $montant);
-
-            if($code < 10) $code =3D "000".$code;
-            if($code >=3D 10 and $code < 100) $code =3D "00".$code;
-            if($code >=3D 100) $code =3D "0".$code;
-
-            $code =3D $annee."-".$code;
-
-
-            $Sql=3D"insert into import_tmp (code,
-                 date_exec ,
-                 date_valeur,
-                 montant,
-                 devise,
-                 detail,
-                 num_compte,
-                 bq_account 	,
-                 jrn,
-                 status)
-                 values ('$code',
-                 '$date_exec',
-                 '$date_exec',
-                 '$montant',
-                 'EUR',
-                 '".addslashes($detail)."',
-                 '$p_bq_account',
-                 $p_jrn,
-                 'n')";
-            $Res=3D$p_cn->exec_sql($Sql);
-        }
-    } // for ($c=3D0;$c<$num;$c++)
-    $row++;
-} // file is read
-fclose($handle);
-?>

Deleted: phpcompta/trunk/include/fortis_be.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/fortis_be.inc.php	2011-06-28 21:22:09 UTC (re=
v 4172)
+++ phpcompta/trunk/include/fortis_be.inc.php	2011-06-29 16:50:38 UTC (re=
v 4173)
@@ -1,137 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-// Author Olivier Dzwoniarkiewicz
-/*! \file
- * \brief File to include : parse the CSV file from fortis Bank Belgium
- */
-
-//-----------------------------------------------------
-// Fortis Bank
-//-----------------------------------------------------
-$row=3D1;
-$must_field=3D7; // The mandatory number of fields
-while (($data =3D fgetcsv($handle, 2000,'@')) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-
-    for ($c=3D0; $c < $num; $c++)
-    {
-        $nb_field=3Dsubstr_count($data[$c],";");
-// first line is skipped
-        if ( $row>1  &&  $nb_field =3D=3D $must_field)
-        {
-
-            $code=3D"";
-            $date_exec=3D"";
-            $date_valeur=3D"";
-            $montant=3D"";
-            $devise=3D"";
-            $compte_ordre=3D"";
-            $detail=3D"";
-            $num_compte=3D"";
-            $iduser=3D"";
-
-
-
-            list($code, $date_exec, $date_valeur, $montant, $devise, $co=
mpte_ordre, $detail, $num_compte) =3D explode(";", $data[$c]);
-            echo "line : $row > ".$data[$c]."<hr>";
-
-            //corrige un bug de date
-            $date_exec =3D str_replace(chr(34),"", $date_exec);
-
-            // Si LTXXXXX ou LT XXXXX dans le d=C3=A9tail
-            if ((myereg ("LT+([0-9]{5})", $detail, $regs)) || (myereg ("=
LT+[ ]+([0-9]{5})", $detail, $regs)))
-            {
-                $iduser =3D $regs[1];
-            }
-
-            // Si 00000XXXXXXX
-            if (myereg ("[0-9]{12}", $detail, $regs))
-            {
-                if($regs[0] !=3D "000000000000")
-                {
-                    $id =3D substr($regs[0], 5, 5);
-                    $check =3D substr($regs[0], 10, 2);
-                    if (($id % 97) =3D=3D $check) $iduser =3D $id;
-                }
-            }
-
-            if($iduser !=3D "" ) $poste_comptable =3D "400".$iduser;
-            else $poste_comptable =3D "";
-
-            list($jour,$mois,$annee) =3D explode("/", $date_exec);
-            $date_exec =3D $annee."-".$mois."-".$jour;
-            list($jour,$mois,$annee) =3D explode("/", $date_valeur);
-            $date_valeur =3D $annee."-".$mois."-".$jour;
-
-            $montant =3D str_replace(",", ".", $montant);
-            $montant =3D str_replace("+", "", $montant);
-            $montant =3D str_replace("\"", "", $montant);
-
-            $detail=3Dstr_replace("\"","",$detail);
-
-            $sql =3D "select * from import_tmp
-                   where
-                   code=3D'".$code."' and
-                   num_compte=3D'".$num_compte."'";
-            $sql=3Dutf8_encode($sql);
-            $Res=3D$p_cn->exec_sql($sql);
-            $Num=3DDatabase::num_row($Res);
-
-            if($Num > 0 )
-            {
-                echo "Op&eacute;ration FORTIS ".$code." d&eacute;j&eagra=
ve; import&eacute;e.<br/>";
-            }
-            else
-            {
-                $Sql=3D"insert into import_tmp (code ,
-                     date_exec ,
-                     date_valeur,
-                     montant,
-                     devise,
-                     compte_ordre,
-                     detail,
-                     num_compte,
-                     bq_account ,
-                     jrn,
-                     status)
-                     values ('$code',
-                     '$date_exec',
-                     '$date_exec',
-                     '$montant',
-                     '$devise',
-                     '".addslashes($compte_ordre)."',
-                     '".addslashes($detail)."',
-                     '$num_compte',
-                     '$p_bq_account',
-                     $p_jrn,
-                     'n')";
-
-                $Res=3D$p_cn->exec_sql($Sql);
-
-            }
-        }
-
-    } // for ($c=3D0;$c<$num;$c++)
-    $row++;
-} // file is read
-fclose($handle);
-?>

Deleted: phpcompta/trunk/include/ing_be.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/ing_be.inc.php	2011-06-28 21:22:09 UTC (rev 4=
172)
+++ phpcompta/trunk/include/ing_be.inc.php	2011-06-29 16:50:38 UTC (rev 4=
173)
@@ -1,143 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/* $Revision$ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-// Author Olivier Dzwoniarkiewicz
-/*! \file
- * \brief File to be included to parse CSV from ING Belgium
- */
-
-//-----------------------------------------------------
-// Bank ING
-//-----------------------------------------------------
-$row=3D1;
-$p_cn->set_encoding('latin1');
-while (($data =3D fgetcsv($handle, 2000,'@')) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-    for ($c=3D0; $c < $num; $c++)
-    {
-
-        // first line is skipped
-        if ( $row > 1 )
-        {
-
-            $code=3D"";
-            $date_exec=3D"";
-            $date_valeur=3D"";
-            $montant=3D"";
-            $devise=3D"";
-            $compte_ordre=3D"";
-            $detail=3D"";
-            $num_compte=3D"";
-            $iduser=3D"";
-            list($num_compte, $code, $date_exec, $date_valeur, $montant,=
 $devise, $montant2, $devise2, $rubriques, $detail, $zzz, $zzz, $date_com=
ptable) =3D explode(";", $data[$c]);
-
-# Bug CSV ING : "424 au lieu de 424
-#"
-            $code =3D str_replace("\"", "", $code);
-
-# Bug CSV ING : espace apres la date
-            $date_exec =3D str_replace(" ", "", $date_exec);
-            $date_valeur =3D str_replace(" ", "", $date_valeur);
-            $date_exec =3D str_replace("\"", "", $date_exec);
-            $date_valeur =3D str_replace("\"", "", $date_valeur);
-            $montant =3D str_replace("\"", "", $montant);
-            if ((myereg ("([0-9]{3})-([0-9]{7})-([0-9]{2})", $num_compte=
, $regs)))
-            {
-                $num_compte =3D $regs[0];
-            }
-
-            // Si LTXXXXX ou LT XXXXX dans le d=C3=A9tail
-            if ((myereg ("LT+([0-9]{5})", $detail, $regs)) || (myereg ("=
LT+[ ]+([0-9]{5})", $detail, $regs)))
-            {
-                $iduser =3D $regs[1];
-            }
-
-            // Si XXXXXXXXXXXX
-            if (myereg ("[0-9]{12}", $detail, $regs))
-            {
-                if($regs[0] !=3D "000000000000")
-                {
-                    $id =3D substr($regs[0], 2, 5);
-                    $longchiffre =3D substr($regs[0], 0, 10);
-                    $check =3D substr($regs[0], 10, 2);
-                    if (($longchiffre % 97) =3D=3D $check) $iduser =3D $=
id;
-                }
-            }
-
-            if($iduser !=3D "" ) $poste_comptable =3D "400".$iduser;
-            else $poste_comptable =3D "";
-
-            list($jour,$mois,$annee) =3D explode("/", $date_valeur);
-            $date_valeur =3D $annee."-".$mois."-".$jour;
-            list($jour,$mois,$annee) =3D explode("/", $date_exec);
-            $date_exec =3D $annee."-".$mois."-".$jour;
-
-            $montant =3D str_replace(",", ".", $montant);
-            $montant =3D str_replace("+", "", $montant);
-
-            if($code < 10) $code =3D "000".$code;
-            if($code >=3D 10 and $code < 100) $code =3D "00".$code;
-            if($code >=3D 100) $code =3D "0".$code;
-
-            $code =3D $annee."-".$code;
-
-            $sql =3D "select * from import_tmp where code=3D'".$code."' =
and num_compte=3D'".$num_compte."'";
-            $Res=3D$p_cn->exec_sql($sql);
-            $Num=3DDatabase::num_row($Res);
-
-            if($Num > 0)
-            {
-                echo "Op&eacute;ration FORTIS ".$code." d&eacute;j&eagra=
ve; import&eacute;e.<br/>";
-            }
-            else
-            {
-                //echo $code." ".$date_exec." ".$date_valeur." ".$montan=
t." ".$devise." ".$compte_ordre." detail ".$num_compte." <b>".$poste_comp=
table."</b><br/>";
-                //$Sql=3D"insert into import_tmp values ('$code','$date_=
exec','$date_valeur','$montant','$devise','".addslashes($compte_ordre)."'=
,'".addslashes($detail)."','$num_compte','$poste_comptable')";
-                $Sql=3D"insert into import_tmp (code,
-                     date_exec ,
-                     date_valeur,
-                     montant,
-                     devise,
-                     compte_ordre,
-                     detail,
-                     bq_account ,
-                     jrn,
-                     status)
-                     values ('$code',
-                     '$date_exec',
-                     '$date_exec',
-                     $montant,
-                     '$devise',
-                     '".addslashes($compte_ordre)."',
-                     '".addslashes($detail).$num_compte."	',
-                     '$p_bq_account',
-                     $p_jrn,
-                     'n')";
-                echo $sql;
-                $Res=3D$p_cn->exec_sql($Sql);
-            }
-        }
-
-    } // for ($c=3D0;$c<$num;$c++)
-    $row++;
-} // file is read
-fclose($handle);
-?>

Deleted: phpcompta/trunk/include/keytrade_be.inc.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/keytrade_be.inc.php	2011-06-28 21:22:09 UTC (=
rev 4172)
+++ phpcompta/trunk/include/keytrade_be.inc.php	2011-06-29 16:50:38 UTC (=
rev 4173)
@@ -1,129 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-/* $Revision: ??2162?? $ */
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-/*! \file
- * \brief This file must be included to parse the CVS from the Keytrade =
Bank
- */
-
-
-
-//-----------------------------------------------------
-// Bank Keytrade
-//-----------------------------------------------------
-$line=3D0;
-$p_cn->set_encoding('latin1');
-
-while (($data =3D fgetcsv($handle, 2000,"!")) !=3D=3D FALSE)
-{
-    $num =3D count($data);
-    for ($c=3D0; $c < $num; $c++)
-    {
-        // skip the first line
-        if ( $line < 1 )
-            continue;
-
-//-----------------------------------------------------
-// Parsing CSV comes here
-//-----------------------------------------------------
-        $row=3Dexplode(';',$data[$c]);
-        if ( sizeof ($row) < 7 )
-            continue;
-
-        // Your own bank account
-        $compte_ordre=3D'';
-
-        // Execution date of the operation
-        $date_exec=3Dstr_replace('/','-',$row[0]);
-        // Operation reference, it must be unique, so we take the datum
-        // the line number and a random number
-        $r=3Drand(1,1000);
-        $code=3D$date_exec.'-'.$line.$r;
-        // Effective date of the operation
-        $date_val=3Dstr_replace('/','-',$row[1]);
-        // Third party bank account
-        $num_compte=3D$row[2];
-        //
-        $detail=3Dtrim($row[3]);
-        //
-        $signe=3Dtrim($row[4]);
-        //
-        // remove first the thousand sep.
-        $montant=3Dstr_replace('.','',$row[5]);
-        // replace the coma by a period
-        $montant=3Dstr_replace(',','.',$montant);
-        // remove the sign
-        //$montant=3Dstr_replace('+','',$montant);
-        // use the sign
-        if ($signe =3D=3D '-')
-            $montant=3D'-'.$montant;
-        // Curency used
-        $devise=3Dtrim($row[6]);
-
-//----------------------------------------------------
-// Skip dubbel impossible
-//----------------------------------------------------
-
-        echo "Ajout de $detail";
-        echo "<br>";
-
-//-----------------------------------------------------
-// insert into import_tmp
-//-----------------------------------------------------
-        $Sql=3D"insert into import_tmp (code,
-             date_exec ,
-             date_valeur,
-             montant,
-             devise,
-             num_compte,
-             detail,
-             bq_account ,
-             jrn,
-             status)
-             values ('$code',
-             to_date('$date_exec','DD-MM-YYYY'),
-             to_date('$date_exec','DD-MM-YYYY'),
-             $montant,
-             '$devise',
-             '".$num_compte."',
-             '".addslashes($detail)."	',
-             '$p_bq_account',
-             $p_jrn,
-             'n')";
-        try
-        {
-            $p_cn->exec_sql($Sql);
-        }
-
-
-        catch(Exception $e)
-        {
-            echo(__FILE__.":".__LINE__." Erreur : ".$e->getCode()." msg =
".$e->getMessage());
-            rollback($p_cn);
-            break;
-        }
-
-    } // for ($c=3D0;$c<$num;$c++)
-    $line++;
-
-} // file is read
-
-fclose($handle);
-commit($p_cn);
-?>

Modified: phpcompta/trunk/sql/upgrade.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/sql/upgrade.sql	2011-06-28 21:22:09 UTC (rev 4172)
+++ phpcompta/trunk/sql/upgrade.sql	2011-06-29 16:50:38 UTC (rev 4173)
@@ -0,0 +1,2 @@
+drop table public.import_tmp;
+drop table public.format_csv_banque;



From MAILER-DAEMON Wed Jun 29 12:54:01 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Qby1Y-0001oh-7N
	for mharc-phpcompta-dev@gnu.org; Wed, 29 Jun 2011 12:54:00 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Wed, 29 Jun 2011 18:58:57 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.35450.1309366439.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4174 - in phpcompta/trunk: html include
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Jun 2011 16:53:58 -0000

Author: danydb
Date: 2011-06-29 18:58:55 +0200 (Wed, 29 Jun 2011)
New Revision: 4174

Removed:
   phpcompta/trunk/html/show_tva.php
Modified:
   phpcompta/trunk/include/class_html_input.php
   phpcompta/trunk/include/constant.php
Log:
#318 remove code cleaning

Deleted: phpcompta/trunk/html/show_tva.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/html/show_tva.php	2011-06-29 16:50:38 UTC (rev 4173)
+++ phpcompta/trunk/html/show_tva.php	2011-06-29 16:58:55 UTC (rev 4174)
@@ -1,67 +0,0 @@
-<?php
-/*
- *   This file is part of PhpCompta.
- *
- *   PhpCompta is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published b=
y
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   PhpCompta is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with PhpCompta; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-130=
7  USA
-*/
-// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
-/* $Revision$ */
-/*! \file
- * \brief Popup window to let the user choose the vat
- */
-
-include_once ("ac_common.php");
-require_once('class_database.php');
-/* Admin. Dossier */
-$rep=3Dnew Database();
-include_once ("class_user.php");
-$User=3Dnew User($rep);
-$User->Check();
-require_once('class_dossier.php');
-$gDossier=3Ddossier::id();
-
-html_min_page_start($User->theme,"onLoad=3D'window.focus();'");
-?>
-<script>
-function GetIt(ctl,tva_id)
-{
-    set_inparent(ctl,tva_id);
-    window.close();
-}
-</script>
-<?php
-
-$condition=3D"";
-$cn=3Dnew Database($gDossier);
-$Res=3D$cn->exec_sql("select * from tva_rate order by tva_rate desc");
-$Max=3DDatabase::num_row($Res);
-echo "<TABLE BORDER=3D\"1\">";
-for ($i=3D0;$i<$Max;$i++)
-{
-    $row=3DDatabase::fetch_array($Res,$i);
-    $set=3Dsprintf( '<INPUT TYPE=3D"BUTTON" class=3D"button" Value=3D"se=
lect" onClick=3D"GetIt(\'%s\',\'%s\');">',
-                  $_GET['ctl'],$row['tva_id']);
-    printf("<tr><TD>%s %d</TD><TD>%s</TD><TD>%s</TD></TR>",
-           $set,
-           $row['tva_id'],
-           $row['tva_label'],
-           $row['tva_comment']);
-}
-echo '</TABLE>';
-?>
-<input type=3D'button' class=3D"button" Value=3D"fermer" onClick=3D'wind=
ow.close();'>
-                                       <?php
-                                       html_page_stop();
-?>

Modified: phpcompta/trunk/include/class_html_input.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/class_html_input.php	2011-06-29 16:50:38 UTC =
(rev 4173)
+++ phpcompta/trunk/include/class_html_input.php	2011-06-29 16:58:55 UTC =
(rev 4174)
@@ -54,7 +54,6 @@
  *      - JS_SEARCH_ONLY like JS_SEARCH but without adding a quickcode
  *      - JS_LEDGER_CTRL like js_search_only but the tag to update is gi=
ven
  *      - SPAN
- *      - JS_TVA        open a popup window for the VAT
  *      - JS_CONCERNED  open a popup window for search a operation, if e=
xtra =3D=3D 0 then
  *                      get the amount thx javascript
  *      - js_DATE show a calendar

Modified: phpcompta/trunk/include/constant.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- phpcompta/trunk/include/constant.php	2011-06-29 16:50:38 UTC (rev 417=
3)
+++ phpcompta/trunk/include/constant.php	2011-06-29 16:58:55 UTC (rev 417=
4)
@@ -184,28 +184,7 @@
 define ("JS_COMPUTE_ODS",
         "<SCRIPT language=3D\"javascript\" src=3D\"js/compute.js\">	</SC=
RIPT>");
=20
-define ("JS_SHOW_TVA","<SCRIPT language=3D\"javascript\">
-        function ShowTva(p_dossier,ctl)
-        {
-        var win=3Dwindow.open('show_tva.php?ctl=3D'+ctl+'&gDossier=3D'+p=
_dossier,'Montre','scrollbar,toolbar=3Dno,width=3D300,height=3D300,resiza=
ble=3Dyes');
-        }
-        function GetIt(ctl,tva_id) {
-        self.opener.SetValue(ctl,tva_id)
-        window.close();
-        }
-        </script>");
=20
-define ("JS_TVA","<script  language=3D\"javascript\">
-        function ChangeTVA(p_ctl,p_value) {
-        if (document.getElementById(p_ctl) ) {
-        var f=3Ddocument.getElementsByName(p_value);
-        for ( var i=3D0; i < f.length ; i++) {
-        document.getElementById(p_ctl).innerHTML=3Df[i].value;
-        }
-        }
-        }
-
-        </script>");
 define ("JS_AJAX_FICHE",'<script language=3D"javascript" src=3D"js/ajax_=
fiche.js"></script>');
 define ("JS_TODO",'<script language=3D"javascript" src=3D"js/todo_list.j=
s"></script>');
 define ("JS_PROTOTYPE",'<script language=3D"javascript" src=3D"js/protot=
ype.js"></script>');



From MAILER-DAEMON Wed Jun 29 12:59:11 2011
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Qby6Y-00038z-Qg
	for mharc-phpcompta-dev@gnu.org; Wed, 29 Jun 2011 12:59:11 -0400
To: phpcompta-dev@nongnu.org
Content-Type: text/plain; charset=UTF-8
Date: Wed, 29 Jun 2011 19:04:08 +0200 (CEST)
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 91.121.80.190
Message-ID: <mailman.35453.1309366749.784.phpcompta-dev@nongnu.org>
From: phpcompta-dev@nongnu.org
Subject: [Phpcompta-dev] r4175 - phpcompta/trunk/dev
X-BeenThere: phpcompta-dev@nongnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: phpcompta-dev@nongnu.org
List-Id: <phpcompta-dev.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/phpcompta-dev>
List-Post: <mailto:phpcompta-dev@nongnu.org>
List-Help: <mailto:phpcompta-dev-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/phpcompta-dev>,
	<mailto:phpcompta-dev-request@nongnu.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Jun 2011 16:59:08 -0000

Author: danydb
Date: 2011-06-29 19:04:07 +0200 (Wed, 29 Jun 2011)
New Revision: 4175

Removed:
   phpcompta/trunk/dev/csv-tools/
Log:
#10 replace import bank by plugin




