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