added code to get and display caveats
git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3225 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
@@ -6,7 +6,7 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
|
||||
|
||||
-- Public type declarations
|
||||
--type <TypeName> is <Datatype>;
|
||||
type caveat_texts_array is varray(20) of varchar2(4000);
|
||||
type caveat_text is varray(20) of varchar2(4000);
|
||||
type img_props is record(width number,
|
||||
height number);
|
||||
type cost_line is record(
|
||||
@@ -28,8 +28,10 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
|
||||
site_address address := address(null,null,null,null,null,null,null),
|
||||
mam varchar2(80),
|
||||
quote_works works := works(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
|
||||
caveat_desc_works caveat_text:= caveat_text(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
|
||||
lead_time number,
|
||||
total_cost number,
|
||||
caveat_cont_sum caveat_text:= caveat_text(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
|
||||
quote_costs costs := costs(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
|
||||
house_length number,
|
||||
house_depth number,
|
||||
@@ -39,7 +41,7 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
|
||||
base_depth number,
|
||||
base_height number,
|
||||
outlet_termninal_size number,
|
||||
quote_caveats caveats := caveats(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
|
||||
caveat_term_cond caveat_text:= caveat_text(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
|
||||
liquid_damage_day number,
|
||||
liquid_damage_cap number,
|
||||
base_dimensions dimensions := dimensions(null,null,null,null,null,null,null,null,null,null),
|
||||
@@ -61,6 +63,7 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
|
||||
module_inlet_orientation varchar2(80),
|
||||
module_outlet_orientation varchar2(80),
|
||||
meter_reference varchar(80),
|
||||
caveat_cont_sum_qa caveat_text:= caveat_text(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
|
||||
mety_code varchar(80),
|
||||
svcpt_code varchar(10)
|
||||
);
|
||||
@@ -70,7 +73,35 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
|
||||
END mip_quotation_document;
|
||||
/
|
||||
CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
|
||||
/*
|
||||
PROCEDURE print_caveats
|
||||
--Prints the supplied caveats to the current PLPDF page
|
||||
%param p_caveats - an array of caveat paragraphs to print
|
||||
%param p_vertical_offset - how far down the page we start printing
|
||||
%param p_line_spacing - the line spacing to use, defaults to 4
|
||||
*/
|
||||
procedure print_caveats(p_caveats in caveat_text, p_vertical_offset in number, p_line_spacing in number :=4) is
|
||||
l_caveats_counter number;
|
||||
l_cell_margin number;
|
||||
begin
|
||||
--set up the screen so we can have our size 4 spacing
|
||||
l_cell_margin:= plpdf.GetCellMargin;
|
||||
plpdf.SetLeftMargin(33.7);
|
||||
plpdf.SetCellMargin(-2);
|
||||
plpdf.SetCurrentY(p_vertical_offset);
|
||||
|
||||
l_caveats_counter :=1;
|
||||
while p_caveats(l_caveats_counter) is not null
|
||||
loop
|
||||
plpdf.PrintFlowingText(p_line_spacing, p_caveats(l_caveats_counter));
|
||||
plpdf.LineBreak;
|
||||
plpdf.LineBreak;
|
||||
l_caveats_counter := l_caveats_counter +1;
|
||||
end loop;
|
||||
--revert back to the original screen settings
|
||||
plpdf.SetCellMargin(l_cell_margin);
|
||||
plpdf.SetLeftMargin(31.7);
|
||||
end print_caveats;
|
||||
/*
|
||||
FUNCTION scale_image_dimensions
|
||||
--The scale_image_dimensions provides the width and height of an image to
|
||||
@@ -90,7 +121,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
begin
|
||||
--Get the properties for the image from plpdf
|
||||
l_image_props:=plpdf_img.getimageprops(p_image_blob);
|
||||
--if the image is too heigh cut it down to the limit and record the ratio
|
||||
--if the image is too high cut it down to the limit and record the ratio
|
||||
--and cutting the width by the recored ratio
|
||||
if l_image_props.height > p_req_height then
|
||||
l_new_height := p_req_height;
|
||||
@@ -362,24 +393,9 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
return l_quote_total_cost;
|
||||
end get_total_cost;
|
||||
|
||||
/*
|
||||
FUNCTION determine_caveats
|
||||
--This function should return a list of caveats, probably in an array, required for
|
||||
--the quotation. It will need to be passed relevent data so that it can make the
|
||||
--determinations
|
||||
%param p_enquiryid - the current enquiry to make determinations against.
|
||||
%param possibly a few more params to get the required data in
|
||||
*/
|
||||
FUNCTION determine_caveats(p_enquiryid in number) RETURN BOOLEAN is
|
||||
|
||||
begin
|
||||
null;
|
||||
end determine_caveats;
|
||||
/*
|
||||
PROCEDURE set_quote_items
|
||||
--This procedure sets the data for each of the items associated with the quotation.
|
||||
--may want to break it up a bit using individual functions for each type of items
|
||||
--just to make it more legible(it's rather a large procedure)
|
||||
%param p_quote_data in out - The current data for this enquiry(what write our data values to)
|
||||
%param p_quoteid - used to list all the quote items.
|
||||
%param p_enqu_row - the current enquiry row to get data only available in the enquiry.
|
||||
@@ -421,11 +437,9 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
l_enqu_type := quote_item_rec.enty_code;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
|
||||
--cycle through the quote items picking up each item to display on the
|
||||
--description of works section
|
||||
|
||||
|
||||
--cycle through the quote items picking up each item to store in the
|
||||
--p_quote_data record
|
||||
l_counter := 0;
|
||||
FOR quote_item_rec IN c_get_quote_item(p_quoteid) LOOP
|
||||
--get the meter type, pressure and job type so we can
|
||||
@@ -599,6 +613,9 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
--add up all the addons and format the string
|
||||
l_works(4) := 'Add-Ons: '|| ltrim(l_addons, ',');
|
||||
p_quote_data.quote_works := l_works;
|
||||
|
||||
--get caveats
|
||||
|
||||
end set_quote_items_data;
|
||||
|
||||
/*
|
||||
@@ -612,49 +629,44 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
FUNCTION get_detailed_quote_data(p_quoteid in number) RETURN quote_data is
|
||||
--Quote data
|
||||
l_quote_data quote_data;
|
||||
l_quote_row quotes%ROWTYPE;
|
||||
--CURSOR c_get_quote(cp_quote_id number) IS
|
||||
-- SELECT *
|
||||
-- FROM quotes
|
||||
-- WHERE id = cp_quote_id;
|
||||
--Enquiry data
|
||||
l_quote_row quotes%ROWTYPE;
|
||||
--Enquiry data
|
||||
l_enquiry_id number;
|
||||
l_enqu_row enquiries%ROWTYPE;
|
||||
--CURSOR c_get_enquiry(cp_enqu_id number) IS
|
||||
-- SELECT *
|
||||
-- FROM enquiries
|
||||
-- WHERE id = cp_enqu_id;
|
||||
--supplier address data
|
||||
--Address data
|
||||
l_addr_row v_current_party_addresses%ROWTYPE;
|
||||
CURSOR c_get_address(cp_party_id number, cp_rt_type varchar2) IS
|
||||
SELECT *
|
||||
FROM v_current_party_addresses
|
||||
WHERE id = cp_party_id and rt_code=cp_rt_type;
|
||||
l_supplier_id number;
|
||||
l_agent_id number;
|
||||
--l_address_id number;
|
||||
l_agent_id number;
|
||||
--Party name
|
||||
l_party_row parties%ROWTYPE;
|
||||
CURSOR c_get_party(cp_party_id number) IS
|
||||
SELECT *
|
||||
FROM parties
|
||||
WHERE id = cp_party_id;
|
||||
--The caveats
|
||||
CURSOR c_get_caveats(cp_enty_code varchar2, cp_mety_code varchar2, cp_svcpt_code varchar2) IS
|
||||
select *
|
||||
from caveat_texts t
|
||||
where enty_code = cp_enty_code and mety_code = cp_mety_code and svcpt_code = cp_svcpt_code
|
||||
order by 1,2,3,4,5;
|
||||
--Agent Name
|
||||
l_agent_first_name varchar2(80);
|
||||
l_agent_last_name varchar2(80);
|
||||
--suppler name
|
||||
l_supplier_name varchar2(80);
|
||||
--caveat counters
|
||||
l_dw_counter number;
|
||||
l_tc_counter number;
|
||||
l_cs_counter number;
|
||||
l_csqa_counter number;
|
||||
|
||||
begin
|
||||
--get the quote's data record
|
||||
l_quote_row := get_quote_row(p_quoteid);
|
||||
/* IF NOT c_get_quote%ISOPEN THEN
|
||||
OPEN c_get_quote(p_quoteid);
|
||||
END IF;
|
||||
|
||||
FETCH c_get_quote
|
||||
INTO l_quote_row;
|
||||
CLOSE c_get_quote;*/
|
||||
|
||||
--get the enquiry data
|
||||
l_enquiry_id := l_quote_row.enqu_id;
|
||||
@@ -723,7 +735,27 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
--get individual quote item details
|
||||
set_quote_items_data(l_quote_data, l_quote_row.id,l_enqu_row);
|
||||
--get caveats
|
||||
--determine_caveats call (this could be a procedure, depends on what GW gives us)
|
||||
l_dw_counter := 1;
|
||||
l_tc_counter := 1;
|
||||
l_cs_counter := 1;
|
||||
l_csqa_counter := 1;
|
||||
for rec in c_get_caveats(l_enqu_row.enty_code, l_quote_data.mety_code, l_quote_data.svcpt_code)
|
||||
loop
|
||||
case rec.document_position
|
||||
when 'TERM_COND' then --terms and conditions/specialfeatures caveat point
|
||||
l_quote_data.caveat_term_cond(l_tc_counter) := rec.text;
|
||||
l_tc_counter := l_tc_counter +1;
|
||||
when 'DESC_WORK' then --description of works caveat point
|
||||
l_quote_data.caveat_desc_works(l_dw_counter) := rec.text;
|
||||
l_dw_counter := l_dw_counter +1;
|
||||
when 'CONT_SUM' then --description of works caveat point
|
||||
l_quote_data.caveat_cont_sum(l_cs_counter) := rec.text;
|
||||
l_cs_counter := l_cs_counter +1;
|
||||
when 'CONT_SUM_QA' then --description of works caveat point
|
||||
l_quote_data.caveat_cont_sum_qa(l_csqa_counter) := rec.text;
|
||||
l_csqa_counter := l_csqa_counter +1;
|
||||
end case;
|
||||
end loop;
|
||||
--phew, lets return all that lovely data we captured then...
|
||||
return l_quote_data;
|
||||
end get_detailed_quote_data;
|
||||
@@ -822,11 +854,10 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
%param p_indent - the left margin measurement.
|
||||
%param p_vertical_offset - the top margin measurement.
|
||||
*/
|
||||
PROCEDURE build_costs_page(p_quote_data in quote_data, p_font in varchar2, p_indent in number, p_vertical_offset in number,p_caveat_texts caveat_texts_array) is
|
||||
PROCEDURE build_costs_page(p_quote_data in quote_data, p_font in varchar2, p_indent in number, p_vertical_offset in number) is
|
||||
l_cost_line_counter number;
|
||||
l_vertical_offset_for_costs number := p_vertical_offset+110;
|
||||
l_works_counter number;
|
||||
l_caveats_counter number;
|
||||
l_vertical_offset_for_works number := p_vertical_offset+52;
|
||||
l_cost_totals_offset number; --used to position the cost totals after the cost line items
|
||||
|
||||
@@ -854,14 +885,10 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
plpdf.PrintText(p_indent,l_vertical_offset_for_works+(l_works_counter*4), p_quote_data.quote_works(l_works_counter));
|
||||
l_works_counter := l_works_counter +1;
|
||||
end loop;
|
||||
--PUT DESC_WORK caveat here
|
||||
l_caveats_counter :=1;
|
||||
while p_caveat_texts(l_caveats_counter) is not null
|
||||
loop
|
||||
plpdf.PrintText(p_indent,l_vertical_offset_for_works+(l_works_counter*4), p_caveat_texts(l_caveats_counter));
|
||||
l_caveats_counter := l_caveats_counter +1;
|
||||
l_works_counter := l_works_counter +1;
|
||||
end loop;
|
||||
-- DESC_WORK caveat here
|
||||
if p_quote_data.caveat_desc_works is not null then
|
||||
print_caveats(p_quote_data.caveat_desc_works, l_vertical_offset_for_works+(l_works_counter*4));
|
||||
end if;
|
||||
plpdf.SetPrintFont(p_font,null,10); --unset bold
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+90, 'Indicative Lead Time from Acceptance to Physical Commencement: ');
|
||||
plpdf.SetPrintFont(p_font,'B',10); --set bold
|
||||
@@ -870,6 +897,10 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+98,'Contract sum (excluding V.A.T): ');
|
||||
plpdf.SetPrintFont(p_font,'B',10); --set bold
|
||||
plpdf.PrintText(85,p_vertical_offset+98,'<27>'||to_char(p_quote_data.total_cost,'FM999999D90'));
|
||||
-- CONT_SUM caveat here
|
||||
if p_quote_data.caveat_cont_sum is not null then
|
||||
print_caveats(p_quote_data.caveat_cont_sum, p_vertical_offset+102);
|
||||
end if;
|
||||
plpdf.SetPrintFont(p_font,null,10); --unset bold
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+106,'Analysis of Costs (all costs exclude V.A.T)');
|
||||
plpdf.SetPrintFont(p_font,'B',10); --set bold
|
||||
@@ -916,8 +947,11 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
plpdf.PrintText(p_indent+80,p_vertical_offset+50,'Height: '||p_quote_data.base_height||' mm');
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+58,'Minimum Ventilation: '||p_quote_data.outlet_termninal_size||' mm');
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+74,'Special Features/Terms/Conditions:');
|
||||
--Terms and condition CAVEATS GO HERE DUDES/DUDETTES
|
||||
plpdf.SetPrintFont(p_font,'B',10); --set bold
|
||||
-- TERM_COND caveat here
|
||||
if p_quote_data.caveat_term_cond is not null then
|
||||
print_caveats(p_quote_data.caveat_term_cond, p_vertical_offset+78);
|
||||
end if;
|
||||
--the caveats will be looped in so the positioning of the the following items will
|
||||
--need to be dynamic (see the quote costs code above for an example)
|
||||
plpdf.SetPrintFont(p_font,null,10); --unset bold
|
||||
@@ -1100,7 +1134,8 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
plpdf.PrintMultilineCell(60,6,'Note: Inlet connection size and location details must be checked against supply point details supplied by GT to ensure compatibility ',1,'L',0);
|
||||
--Multi line cell thing is a bit annoying the printcell will not wrap to
|
||||
--the edge of the multi-line cell so we have to set the cursor for the
|
||||
--remaining parts of the table
|
||||
--remaining parts of the table, have found a fix for this will do if we
|
||||
--have any time
|
||||
plpdf.SetCurrentXY(91.7,p_vertical_offset+96);
|
||||
plpdf.PrintCell(30,6,'',1,0,'C',0);
|
||||
plpdf.PrintCell(35,6,'Inlet',1,0,'C',0);
|
||||
@@ -1185,6 +1220,10 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+62,'Contract sum (excluding V.A.T): ');
|
||||
plpdf.SetPrintFont(p_font,'B',10); --set bold
|
||||
plpdf.PrintText(85,p_vertical_offset+62,'<27>'||p_quote_data.total_cost||' excluding lifting gear if required.');
|
||||
-- CONT_SUM_QA caveat here
|
||||
if p_quote_data.caveat_cont_sum_qa is not null then
|
||||
print_caveats(p_quote_data.caveat_cont_sum_qa, p_vertical_offset+66);
|
||||
end if;
|
||||
plpdf.SetPrintFont(p_font,null,10); --unset bold
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+74,'* I confirm on behalf of my Company that I accept the above referenced quotation for the conduct');
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+78,'of works as detailed therein, and here by certify on behalf of my Company that no additional');
|
||||
@@ -1224,22 +1263,16 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
FUNCTION generate_detailed_quote_pdf(p_quote_data in quote_data,p_quote_id in number) RETURN VARCHAR2 is
|
||||
l_blob blob;
|
||||
l_enty_code varchar2(80); --the type of enquiry
|
||||
l_rec_counter number;
|
||||
l_caveat_texts := caveat_texts_array(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null);
|
||||
l_logo_blob blob;
|
||||
l_signature_blob blob;
|
||||
l_success boolean; --holds whether the quote was saved i nthe docuemnts tables or not
|
||||
l_success boolean; --holds whether the quote was saved in the docuemnts tables or not
|
||||
l_base_blob blob; --the base drawing
|
||||
l_house_blob blob; --the house drawing
|
||||
l_module_blob blob; --the module drawing
|
||||
l_pdf_name varchar2(90); -- the id of the quote we generate
|
||||
l_indent number := 31.7;
|
||||
l_vertical_offset number := 30;
|
||||
l_font varchar2(40) := 'Arial'; --arial not daz
|
||||
l_desc_work_row caveat_texts%ROWTYPE;
|
||||
l_term_cond_row caveat_texts%ROWTYPE;
|
||||
l_cont_sum_row caveat_texts%ROWTYPE;
|
||||
l_cont_sum_qa_row caveat_texts%ROWTYPE;
|
||||
l_font varchar2(40) := 'Arial'; --arial not daz
|
||||
CURSOR c_get_logo(cp_logo varchar2) IS
|
||||
SELECT blob_content
|
||||
FROM wwv_flow_files
|
||||
@@ -1253,14 +1286,6 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
FROM quote_items
|
||||
WHERE qute_id = cp_quid and quit_type = 'LQI' ;
|
||||
|
||||
CURSOR c_get_caveats(cp_enty_code varchar2, cp_mety_code varchar2, cp_svcpt_code varchar2, cp_document_position varchar2) IS
|
||||
select *
|
||||
from caveat_texts t
|
||||
where enty_code = cp_enty_code and mety_code = cp_mety_code and svcpt_code = cp_svcpt_code and document_position = cp_document_position
|
||||
order by 2;
|
||||
|
||||
---built cursor above now need to get it into either separate variables or a record!
|
||||
|
||||
begin
|
||||
IF NOT c_get_logo%ISOPEN THEN
|
||||
OPEN c_get_logo('quote_logo.jpg');
|
||||
@@ -1280,41 +1305,6 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
FETCH c_get_enty
|
||||
INTO l_enty_code;
|
||||
CLOSE c_get_enty;
|
||||
--Get all the caveats
|
||||
--Description of works caveats
|
||||
/* IF NOT c_get_caveats%ISOPEN THEN
|
||||
OPEN c_get_caveats(l_enty_code, p_quote_data.mety_code, p_quote_data.svcpt_code, 'DESC_WORK');
|
||||
END IF;*/
|
||||
l_rec_counter := 1;
|
||||
for rec in c_get_caveats(l_enty_code, p_quote_data.mety_code, p_quote_data.svcpt_code, 'DESC_WORK')
|
||||
loop
|
||||
l_caveat_texts(l_rec_counter) := rec.text;
|
||||
l_rec_counter := l_rec_counter +1;
|
||||
end loop;
|
||||
/* FETCH c_get_caveats
|
||||
INTO l_desc_work_row;
|
||||
CLOSE c_get_caveats;
|
||||
--Terms and Conditions
|
||||
IF NOT c_get_caveats%ISOPEN THEN
|
||||
OPEN c_get_caveats(l_enty_code, p_quote_data.mety_code,p_quote_data.svcpt_code,'DESC_WORK');
|
||||
END IF;
|
||||
FETCH c_get_caveats
|
||||
INTO l_term_cond_row;
|
||||
CLOSE c_get_caveats;
|
||||
--Contract Sum
|
||||
IF NOT c_get_caveats%ISOPEN THEN
|
||||
OPEN c_get_caveats(l_enty_code, p_quote_data.mety_code,p_quote_data.svcpt_code,'CONT_SUM');
|
||||
END IF;
|
||||
FETCH c_get_caveats
|
||||
INTO l_cont_sum_row;
|
||||
CLOSE c_get_caveats;
|
||||
--Contract Sum Quote Acceptance
|
||||
IF NOT c_get_caveats%ISOPEN THEN
|
||||
OPEN c_get_caveats(l_enty_code, p_quote_data.mety_code,p_quote_data.svcpt_code,'CONT_SUM_QA');
|
||||
END IF;
|
||||
FETCH c_get_caveats
|
||||
INTO l_cont_sum_qa_row;
|
||||
CLOSE c_get_caveats; */
|
||||
|
||||
--get the quote diagrams
|
||||
l_base_blob := get_drawing(p_quote_data.base_diagram);
|
||||
@@ -1324,7 +1314,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
plpdf.init;
|
||||
--build the pages for the quote
|
||||
build_covering_letter(p_quote_data,l_font,l_indent,l_vertical_offset,l_logo_blob, l_signature_blob);--1
|
||||
build_costs_page(p_quote_data,l_font,l_indent,l_vertical_offset, l_caveat_texts); --2
|
||||
build_costs_page(p_quote_data,l_font,l_indent,l_vertical_offset); --2
|
||||
build_caveats_page(p_quote_data,l_font,l_indent,l_vertical_offset); --3
|
||||
--OFMAT, Addon jobs don't have module diagrams
|
||||
if not (l_enty_code = 'OFMAT' or l_enty_code = 'AMR' or l_enty_code = 'EMS') then
|
||||
|
||||
Reference in New Issue
Block a user