phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4927 - phpcompta/trunk/sql


From: phpcompta-dev
Subject: [Phpcompta-dev] r4927 - phpcompta/trunk/sql
Date: Mon, 18 Jun 2012 14:25:39 +0200 (CEST)

Author: danydb
Date: 2012-06-18 14:25:39 +0200 (Mon, 18 Jun 2012)
New Revision: 4927

Modified:
   phpcompta/trunk/sql/upgrade.sql
Log:
0000632: Si changement d'un quick-code adaptation

Modified: phpcompta/trunk/sql/upgrade.sql
===================================================================
--- phpcompta/trunk/sql/upgrade.sql     2012-06-18 11:38:23 UTC (rev 4926)
+++ phpcompta/trunk/sql/upgrade.sql     2012-06-18 12:25:39 UTC (rev 4927)
@@ -332,4 +332,33 @@
 
 create table tmp_stockgood (s_id bigserial primary key,s_date timestamp 
default now());
 create table tmp_stockgood_detail(d_id bigserial primary key,s_id bigint 
references tmp_stockgood(s_id) on delete cascade,
-sg_code text,s_qin numeric(20,4),s_qout numeric(20,4),r_id bigint);
\ No newline at end of file
+sg_code text,s_qin numeric(20,4),s_qout numeric(20,4),r_id bigint);
+
+
+
+CREATE OR REPLACE FUNCTION comptaproc.fiche_detail_qcode_upd()
+  RETURNS trigger AS
+$BODY$
+declare
+       i record;
+begin
+       if NEW.ad_id=23 and NEW.ad_value != OLD.ad_value then
+               RAISE NOTICE 'new qcode [%] old qcode 
[%]',NEW.ad_value,OLD.ad_value;
+
+               for i in select ad_id from attr_def where ad_type = 'card' loop
+                       update fiche_detail set ad_value=NEW.ad_value where 
ad_value=OLD.ad_value and ad_id=i.ad_id;
+                       RAISE NOTICE 'change for ad_id [%] ',i.ad_id;
+                       if i.ad_id=19 then
+                               RAISE NOTICE 'Change in stock_goods OLD[%] by 
NEW[%]',OLD.ad_value,NEW.ad_value;
+                               update stock_goods set sg_code=NEW.ad_value 
where sg_code=OLD.ad_value;
+                       end if;
+
+               end loop;
+       end if;
+return NEW;
+end;
+$BODY$
+  LANGUAGE plpgsql VOLATILE;
+
+
+CREATE TRIGGER fiche_detail_upd_trg   BEFORE UPDATE   ON fiche_detail   FOR 
EACH ROW   EXECUTE PROCEDURE comptaproc.fiche_detail_qcode_upd();
\ No newline at end of file



---
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]