· 9 years ago · Oct 06, 2016, 09:12 AM
1/**********************************************
2 Report : Form - Receipt
3
4 Wut, 2016-09-29
5***********************************************/
6
7drop table if exists "dbFinance".rpPRecForm cascade;
8create table if not exists "dbFinance".rpPRecForm (
9 --* Constant
10 tbn_par text not null default '"dbFinance".tbPRec'
11 ,tbn_item text not null default '"dbFinance".tbPRecItem'
12 ,tbn_chq text not null default '"dbFinance".tbPRecChq'
13 --*
14
15
16--) INHERITS ("dbSysRPT".tbReportParam ) ;
17) INHERITS ( "dbFinance".rpPQuoForm ) ;
18--) INHERITS ( "dbFinance".rpPInvForm ) ;
19
20
21select "dbSys".tblRegistration( '"dbFinance".rpPRecForm', true );
22
23/**********************************
24 Function : Report Data
25 21-10-2014, Wut.
26
27 select * from "dbBase".tbaccconf
28
29***********************************/
30drop function if exists "dbFinance".rpPRecForm( in prm "dbFinance".rpPRecForm );
31create or replace function "dbFinance".rpPRecForm( in prm "dbFinance".rpPRecForm
32 ,out sql text, out sql_createtemp text ) returns record as $$
33begin
34 select a.sql, a.sql_createtemp from "dbFinance".rpPQuoForm( prm ) a into sql, sql_createtemp;
35
36 -- return sql ;
37end $$ language plpgsql;
38
39/****************************
40 Trigger : Report Data - Before Insert
41 26-10-2014
42*****************************/
43create or replace function "dbFinance".reportdata_beforeinsert() returns trigger as $$
44declare
45 paramid int = tg_argv[0]; --*** id of parameter record ***
46 rec record;
47begin
48 --* get variables , get the whole record
49 -- select * from "dbFinance".rpPRecForm where id = paramid into rec;
50
51 --* update variables
52 /*
53 update "dbFinance".rpPRecForm
54 set var_item = rec.var_item
55 ,var_balance = rec.var_balance
56 where id = paramid; */
57
58 return new;
59end $$ language plpgsql;
60
61/************************************************
62 Registration
63**************************************************/
64select "dbSysRPT".rptRegistration(
65 '"dbFinance".rpPRecForm'
66 ,_ReportName :=
67'ใบเสร็จรับเงิน/
68Receipt'
69--,tblTrigger := '"dbFinance".rpPRecForm_Validate()'
70 ,tblTrigger := '"dbFinance".rpPQuoForm_Validate()'
71 ,tgBeforeInsertWork := '"dbFinance".reportdata_beforeinsert()'
72 ,_InitParam := 'Default'
73 ,ValidateInsUpd := false -- only validate on execute report, not inserting parementer
74
75 --,fnReport := '"dbFinance".rpPQuoForm'
76
77 );