tried to get caveats in, having troubles so code is broken until monday sorry...
git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3208 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
@@ -6,6 +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 img_props is record(width number,
|
||||
height number);
|
||||
type cost_line is record(
|
||||
@@ -59,7 +60,9 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
|
||||
module_outlet_type varchar2(80),
|
||||
module_inlet_orientation varchar2(80),
|
||||
module_outlet_orientation varchar2(80),
|
||||
meter_reference varchar(80)
|
||||
meter_reference varchar(80),
|
||||
mety_code varchar(80),
|
||||
svcpt_code varchar(10)
|
||||
);
|
||||
|
||||
FUNCTION generate_quote_pdf(p_quote_id in number) RETURN VARCHAR2;
|
||||
@@ -110,6 +113,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
l_new_dimensions.height := l_new_height;
|
||||
return l_new_dimensions;
|
||||
end scale_image_dimensions;
|
||||
|
||||
/*
|
||||
FUNCTION get_drawing
|
||||
--The get_drawing function returns a blob of the drawing code
|
||||
@@ -156,6 +160,57 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
CLOSE c_get_mam;
|
||||
return l_mam_desc;
|
||||
end get_mam;
|
||||
/*
|
||||
FUNCTION get_enquiry_row
|
||||
--The get_enquiry_row function returns an enquiry record for the supplied enquiry id.
|
||||
%param p_enquiry_id - the id of the enquiry you want to get a record of.
|
||||
%return enquiry row of the supplied enquiry id
|
||||
*/
|
||||
function get_enquiry_row(p_enquiry_id number) return enquiries%ROWTYPE is
|
||||
--Enquiry data
|
||||
l_enqu_row enquiries%ROWTYPE;
|
||||
CURSOR c_get_enquiry(cp_enqu_id number) IS
|
||||
SELECT *
|
||||
FROM enquiries
|
||||
WHERE id = cp_enqu_id;
|
||||
begin
|
||||
--get the enquiry data
|
||||
IF NOT c_get_enquiry%ISOPEN THEN
|
||||
OPEN c_get_enquiry(p_enquiry_id);
|
||||
END IF;
|
||||
|
||||
FETCH c_get_enquiry
|
||||
INTO l_enqu_row;
|
||||
CLOSE c_get_enquiry;
|
||||
|
||||
return l_enqu_row;
|
||||
end get_enquiry_row;
|
||||
/*
|
||||
FUNCTION get_quote_row
|
||||
--The get_quote_row funcdsf sdfsdfsd fsdfsdfsdftion returns an enquiry record for the supplied enquiry id.
|
||||
%param p_enquiry_id - the id of the enquiry you want to get a record of.
|
||||
%return enquiry row of the supplied enquiry id
|
||||
*/
|
||||
function get_quote_row(p_quote_id number) return quotes%ROWTYPE is
|
||||
--Quote data
|
||||
l_quote_row quotes%ROWTYPE;
|
||||
CURSOR c_get_quote(cp_quote_id number) IS
|
||||
SELECT *
|
||||
FROM quotes
|
||||
WHERE id = cp_quote_id;
|
||||
begin
|
||||
--get the quote data
|
||||
IF NOT c_get_quote%ISOPEN THEN
|
||||
OPEN c_get_quote(p_quote_id);
|
||||
END IF;
|
||||
|
||||
FETCH c_get_quote
|
||||
INTO l_quote_row;
|
||||
CLOSE c_get_quote;
|
||||
|
||||
return l_quote_row;
|
||||
end get_quote_row;
|
||||
|
||||
/*
|
||||
FUNCTION get_meter_row
|
||||
--The get_meter_row function returns a meter record for the supplied meter code.
|
||||
@@ -302,7 +357,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
SELECT SUM(selling_price + nvl(delivery_price,0))
|
||||
into l_quote_total_cost
|
||||
FROM quote_items
|
||||
WHERE qute_id = p_quoteid and not (quit_type = 'AQI' and adit_code <> 'LIFTING GEAR');
|
||||
WHERE qute_id = p_quoteid and not (quit_type = 'AQI' and adit_code in ('LIFTING GEAR','PURGING'));
|
||||
|
||||
return l_quote_total_cost;
|
||||
end get_total_cost;
|
||||
@@ -476,10 +531,11 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
p_quote_data.module_inlet_orientation := l_module_row.inlet_cnor_code;
|
||||
p_quote_data.module_outlet_orientation := l_module_row.outlet_cnor_code;
|
||||
p_quote_data.module_diagram := l_module_row.drwg_code;
|
||||
--get meters qmax/qmin
|
||||
--get meters qmax/qmin tech specs
|
||||
l_meter_row := get_meter_row(l_module_row.metr_code);
|
||||
p_quote_data.module_qmax := l_meter_row.qmax;
|
||||
p_quote_data.module_qmin := l_meter_row.qmin;
|
||||
p_quote_data.mety_code := l_meter_row.mety_code;
|
||||
--get the min base details for this module
|
||||
l_base_row := get_base_row(l_module_row.bas_code);
|
||||
p_quote_data.base_length := l_base_row.dim_a;
|
||||
@@ -509,6 +565,11 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
if quote_item_rec.enty_code <>'INSTALL' and quote_item_rec.enty_code <>'STD INSTALL' then
|
||||
l_works(5) := 'Existing Meter Type: '|| p_enqu_row.existing_mesc_code ||' '||p_enqu_row.mety_code||', '|| p_enqu_row.existing_meter_model ||', MSN: '||p_enqu_row.existing_meter_serial_no ;
|
||||
end if;
|
||||
--if it's not an install or exchange get the existing meter type (will overwrite
|
||||
--current value if already set in the code above)
|
||||
if quote_item_rec.enty_code not in('STD EXCHANGE','EXCHANGE','INSTALL','STD INSTALL') then
|
||||
p_quote_data.mety_code := p_enqu_row.mety_code;
|
||||
end if;
|
||||
if quote_item_rec.enty_code <> 'OFMAT' and quote_item_rec.enty_code <> 'ADVERSARIAL' then
|
||||
l_total_cost := p_quote_data.total_cost;
|
||||
if l_total_cost <= 1000 then
|
||||
@@ -552,17 +613,17 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document 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;
|
||||
--CURSOR c_get_quote(cp_quote_id number) IS
|
||||
-- SELECT *
|
||||
-- FROM quotes
|
||||
-- WHERE id = cp_quote_id;
|
||||
--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;
|
||||
--CURSOR c_get_enquiry(cp_enqu_id number) IS
|
||||
-- SELECT *
|
||||
-- FROM enquiries
|
||||
-- WHERE id = cp_enqu_id;
|
||||
--supplier address data
|
||||
l_addr_row v_current_party_addresses%ROWTYPE;
|
||||
CURSOR c_get_address(cp_party_id number, cp_rt_type varchar2) IS
|
||||
@@ -583,41 +644,22 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
l_agent_last_name varchar2(80);
|
||||
--suppler name
|
||||
l_supplier_name varchar2(80);
|
||||
--Meter data
|
||||
--l_meter_row meters%ROWTYPE;
|
||||
--CURSOR c_get_meter(cp_meter_id number) IS
|
||||
-- SELECT *
|
||||
-- FROM meters
|
||||
-- WHERE id = cp_meter_id;
|
||||
--housing data
|
||||
--l_housing_row housings%ROWTYPE;
|
||||
|
||||
begin
|
||||
--probably call determine caveats here
|
||||
--we can start filling all the data for the quotation
|
||||
--will need data from the following tables
|
||||
--quotes
|
||||
--enquiries
|
||||
--parties
|
||||
--get the quote's data record
|
||||
IF NOT c_get_quote%ISOPEN THEN
|
||||
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;
|
||||
CLOSE c_get_quote;*/
|
||||
|
||||
--get the enquiry data
|
||||
l_enquiry_id := l_quote_row.enqu_id;
|
||||
l_enqu_row := get_enquiry_row(l_enquiry_id);
|
||||
|
||||
IF NOT c_get_enquiry%ISOPEN THEN
|
||||
OPEN c_get_enquiry(l_enquiry_id);
|
||||
END IF;
|
||||
|
||||
FETCH c_get_enquiry
|
||||
INTO l_enqu_row;
|
||||
CLOSE c_get_enquiry;
|
||||
--get the latest supplier address
|
||||
IF NOT c_get_address%ISOPEN THEN
|
||||
OPEN c_get_address(l_supplier_id,'OFFICE');
|
||||
@@ -668,12 +710,16 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
l_quote_data.site_address(3) := l_enqu_row.install_street;
|
||||
l_quote_data.site_address(4) := l_enqu_row.install_city;
|
||||
l_quote_data.site_address(5) := l_enqu_row.install_postcode;
|
||||
--need to find out how to get the mam
|
||||
--need get the mam
|
||||
l_quote_data.mam := get_mam(mip_regions.get_region_for_postcode(l_enqu_row.install_postcode));
|
||||
--l_quote_data.mam := '<need to write routine to get mam>';
|
||||
l_quote_data.lead_time := get_max_lead_time(l_quote_row.id);
|
||||
l_quote_data.total_cost := get_total_cost(l_quote_row.id);
|
||||
l_quote_data.requested_qmax := l_enqu_row.qmax;
|
||||
if l_enqu_row.required_svcp_code = 'LP' then
|
||||
l_quote_data.svcpt_code := 'LP';
|
||||
else
|
||||
l_quote_data.svcpt_code := 'MP';
|
||||
end if;
|
||||
--get individual quote item details
|
||||
set_quote_items_data(l_quote_data, l_quote_row.id,l_enqu_row);
|
||||
--get caveats
|
||||
@@ -776,12 +822,14 @@ 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) is
|
||||
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
|
||||
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
|
||||
|
||||
begin
|
||||
--Page 2
|
||||
plpdf.NewPage;
|
||||
@@ -805,6 +853,14 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
loop
|
||||
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;
|
||||
plpdf.SetPrintFont(p_font,null,10); --unset bold
|
||||
plpdf.PrintText(p_indent,p_vertical_offset+90, 'Indicative Lead Time from Acceptance to Physical Commencement: ');
|
||||
@@ -860,7 +916,7 @@ 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:');
|
||||
--CAVEATS GO HERE DUDES/DUDETTES
|
||||
--Terms and condition CAVEATS GO HERE DUDES/DUDETTES
|
||||
plpdf.SetPrintFont(p_font,'B',10); --set bold
|
||||
--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)
|
||||
@@ -925,8 +981,8 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
if p_base_blob is null then
|
||||
plpdf.PrintText(p_indent+50,p_vertical_offset+50,'No Base Diagram Available');
|
||||
else
|
||||
l_img_props := scale_image_dimensions(100, 60, p_module_blob );
|
||||
plpdf.PutImage('base',p_base_blob,p_indent,10,l_img_props.width,l_img_props.height);
|
||||
l_img_props := scale_image_dimensions(100, 60, p_base_blob );
|
||||
plpdf.PutImage('base',p_base_blob,p_indent+50,p_vertical_offset+25,l_img_props.width,l_img_props.height);
|
||||
end if;
|
||||
--House Details
|
||||
plpdf.SetPrintFont(p_font,'BU',12); --set bold,underline and 12pt
|
||||
@@ -942,10 +998,11 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
plpdf.PrintCell(15,6,'Weight:',1,0,'L',0);
|
||||
plpdf.PrintCell(15,6,p_quote_data.house_dimensions(4),1,1,'R',0);
|
||||
if p_house_blob is null then
|
||||
plpdf.PrintText(p_indent+50,p_vertical_offset+132,'No House Diagram Available');
|
||||
plpdf.PrintText(p_indent+50,p_vertical_offset+132,'No Housing Diagram Available');
|
||||
else
|
||||
l_img_props := scale_image_dimensions(100, 60, p_module_blob );
|
||||
plpdf.PutImage('house',p_house_blob,p_indent+50,108,l_img_props.width,l_img_props.height);
|
||||
|
||||
l_img_props := scale_image_dimensions(100, 60, p_house_blob );
|
||||
plpdf.PutImage('house',p_house_blob,p_indent+50,p_vertical_offset+108,l_img_props.width,l_img_props.height);
|
||||
end if;
|
||||
--Module details
|
||||
plpdf.SetPrintFont(p_font,'BU',12); --set bold,underline and 12pt
|
||||
@@ -1166,17 +1223,23 @@ 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 varchar(80); --the type of enquiry
|
||||
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_base_blob blob; --the base drawing
|
||||
l_house_blob blob; --the house drawing
|
||||
l_module_blob blob; --the module drawing
|
||||
l_pdf_name varchar(90); -- the id of the quote we generate
|
||||
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_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;
|
||||
CURSOR c_get_logo(cp_logo varchar2) IS
|
||||
SELECT blob_content
|
||||
FROM wwv_flow_files
|
||||
@@ -1188,8 +1251,16 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
|
||||
CURSOR c_get_enty(cp_quid varchar2) IS
|
||||
SELECT enty_code
|
||||
FROM quote_items
|
||||
WHERE qute_id = cp_quid and quit_type = 'LQI' ;
|
||||
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');
|
||||
@@ -1209,6 +1280,42 @@ 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);
|
||||
l_house_blob := get_drawing(p_quote_data.house_diagram);
|
||||
@@ -1217,7 +1324,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); --2
|
||||
build_costs_page(p_quote_data,l_font,l_indent,l_vertical_offset, l_caveat_texts); --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