phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r5299 - in phpcompta/trunk: html/admin/sql/patch include


From: phpcompta-dev
Subject: [Phpcompta-dev] r5299 - in phpcompta/trunk: html/admin/sql/patch include
Date: Tue, 21 May 2013 23:59:49 +0200 (CEST)

Author: danydb
Date: 2013-05-21 23:59:49 +0200 (Tue, 21 May 2013)
New Revision: 5299

Modified:
   phpcompta/trunk/html/admin/sql/patch/upgrade106.sql
   phpcompta/trunk/include/constant.php
Log:
task #0000848: Creation d un trigger pour empecher periode qui se chevauchent

Modified: phpcompta/trunk/html/admin/sql/patch/upgrade106.sql
===================================================================
--- phpcompta/trunk/html/admin/sql/patch/upgrade106.sql 2013-05-21 21:37:22 UTC 
(rev 5298)
+++ phpcompta/trunk/html/admin/sql/patch/upgrade106.sql 2013-05-21 21:59:49 UTC 
(rev 5299)
@@ -14,17 +14,46 @@
 
 update jrn_def set jrn_deb_max_line=5 where jrn_deb_max_line is null;
 
+CREATE OR REPLACE FUNCTION comptaproc.periode_exist(p_date text,p_periode_id 
bigint)
+ RETURNS integer
+AS $function$
+
+declare n_p_id int4;
+begin
+
+select p_id into n_p_id
+        from parm_periode
+        where
+                p_start <= to_date(p_date,'DD.MM.YYYY')
+                and
+                p_end >= to_date(p_date,'DD.MM.YYYY')
+                and
+                p_id <> p_periode_id;
+
+if NOT FOUND then
+        return -1;
+end if;
+
+return n_p_id;
+
+end;$function$
+ LANGUAGE plpgsql;
+
 create or replace function comptaproc.check_periode () returns trigger
 as
 $$
+declare 
+  nPeriode int;
 begin
-if find_periode(to_char(NEW.p_start,'DD.MM.YYYY')) <> -1 then
-        raise info 'Overlap periode start % ',NEW.p_start;
+if periode_exist(to_char(NEW.p_start,'DD.MM.YYYY'),NEW.p_id) <> -1 then
+       nPeriode:=periode_exist(to_char(NEW.p_start,'DD.MM.YYYY'),NEW.p_id) ;
+        raise info 'Overlap periode start % periode %',NEW.p_start,a;
        return null;
 end if;
 
-if find_periode(to_char(NEW.p_end,'DD.MM.YYYY')) <> -1 then
-        raise info 'Overlap periode end % ',NEW.p_end;
+if periode_exist(to_char(NEW.p_end,'DD.MM.YYYY'),NEW.p_id) <> -1 then
+       nPeriode:=periode_exist(to_char(NEW.p_start,'DD.MM.YYYY'),NEW.p_id) ;
+        raise info 'Overlap periode end % periode %',NEW.p_end,nPeriode;
        return null;
 end if;
 return NEW;

Modified: phpcompta/trunk/include/constant.php
===================================================================
--- phpcompta/trunk/include/constant.php        2013-05-21 21:37:22 UTC (rev 
5298)
+++ phpcompta/trunk/include/constant.php        2013-05-21 21:59:49 UTC (rev 
5299)
@@ -61,9 +61,9 @@
 $g_succeed="<span style=\"font-size:18px;color:green\">&#x2713;</span>";
 /*set to none for production */
 /* uncomment for production */
-// define ('SVNINFO',5900);
+define ('SVNINFO',5900);
 $version_phpcompta=SVNINFO;
-define ("DEBUG",false);
+define ("DEBUG",true);
 /* define ('SVNINFO',5015);
  * $version_phpcompta=SVNINFO;
  * define ("DEBUG",true);



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]