Addressed #573 by modifying mip_quotation_document.pck so that the quotation page costs do not overlap.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@26040 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
andrew.hardy
2010-09-02 14:42:01 +00:00
parent 04696f1008
commit 053ce6148a

View File

@@ -394,9 +394,10 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
,p_line_breaks IN NUMBER := 2) IS
l_caveats_counter NUMBER;
l_cell_margin NUMBER;
l_margin NUMBER;
BEGIN
cout_assert.isnotnull(p_vertical_offset
,p_message => 'veritcal offest null!');
,p_message => 'vertical offset null!');
--set up the screen so we can have our size 4 spacing
l_cell_margin := plpdf.getcellmargin;
plpdf.setleftmargin(33.7);
@@ -417,6 +418,21 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
plpdf.setcellmargin(l_cell_margin);
plpdf.setleftmargin(31.7);
END print_caveats;
FUNCTION sentence_case(p_in VARCHAR2) RETURN VARCHAR2 IS
BEGIN
IF SUBSTR(p_in
,1
,1) != ' ' THEN
RETURN upper(SUBSTR(p_in
,1
,1)) || SUBSTR(p_in
,2);
ELSE
RETURN ' ' || sentence_case(SUBSTR(p_in
,2));
END IF;
END sentence_case;
/*
FUNCTION glue_one_line_caveat
--Concats the supplied caveats into one line of text
@@ -429,7 +445,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
l_caveats_counter := 1;
WHILE p_caveats(l_caveats_counter) IS NOT NULL LOOP
l_caveat_total_text := l_caveat_total_text || ' ' ||
p_caveats(l_caveats_counter);
sentence_case(p_caveats(l_caveats_counter));
l_caveats_counter := l_caveats_counter + 1;
END LOOP;
RETURN ltrim(l_caveat_total_text);
@@ -1313,6 +1329,11 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
l_cell_margin NUMBER;
BEGIN
plpdf.newpage;
plpdf.crbookmark(p_txt => 'Covering Letter');
l_cell_margin := plpdf.getcellmargin;
plpdf.setcellmargin(0);
--set watermark if it exists
IF p_watermark_blob IS NOT NULL THEN
pl('watermark IS NOT null'
@@ -1327,10 +1348,6 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
pl('watermark IS null'
,$$PLSQL_LINE);
END IF;
-- set margins
plpdf.setleftmargin(31.7);
plpdf.setrightmargin(31.7);
plpdf.settopmargin(25.4);
plpdf.setprintfont(p_font
,NULL
@@ -1342,6 +1359,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
,10
,52
,18);
plpdf.printtext(140
,10
,'4 Abbotts Lane ');
@@ -1360,6 +1378,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
plpdf.printtext(170
,16
,'www.nationalgrid.com');
-- And Footer stuff
plpdf.printtext(50
,280
@@ -1367,6 +1386,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
plpdf.printtext(50
,283
,'Registered Office: 1-3 Strand, London, WCZN 5EH. Registered in England and Wales, No. 3705992');
plpdf.setprintfont(p_font
,NULL
,10); -- set back to 10 pt
@@ -1388,9 +1408,12 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
,p_quote_data.supplier_address(addr_count));
END IF;
END LOOP;
plpdf.printtext(p_indent
,p_vertical_offset + 58
,'Date: ' || p_quote_data.current_date);
,'Date: ' || TO_CHAR(p_quote_data.current_date
,'FMddth Month YYYY'));
plpdf.printtext(p_indent
,p_vertical_offset + 66
,'Quotation Contact: Non Standard Customer Service Team');
@@ -1423,42 +1446,40 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
p_quote_data.site_address(7)
,', ')
,', ')); --site address
l_note_text := 'Note: National Grid Metering are a service provider working on behalf of ';
l_note_text := l_note_text || p_quote_data.mam; --mam
l_note_text := l_note_text ||
', please direct all enquiries regarding this quote to National Grid Metering.';
l_cell_margin := plpdf.getcellmargin;
plpdf.setleftmargin(33.7);
plpdf.setcellmargin(-2);
l_note_text := 'Note: National Grid Metering are a service provider working on behalf of ';
l_note_text := l_note_text || p_quote_data.mam; --mam
l_note_text := l_note_text ||
', please direct all enquiries regarding this quote to National Grid Metering.';
plpdf.setcurrenty(p_vertical_offset + 102);
plpdf.printflowingtext(4
,l_note_text);
plpdf.printflowingtext(p_h => 4
,p_txt => l_note_text);
plpdf.linebreak;
plpdf.linebreak;
plpdf.setprintfont(p_font
,NULL
,10); --unset bold
plpdf.printflowingtext(4
,'I am pleased to provide you with a quotation for works ');
plpdf.printflowingtext(p_h => 4
,p_txt => 'I am pleased to provide you with a quotation for works');
plpdf.setprintfont(p_font
,'B'
,10); --set bold
plpdf.printflowingtext(4
,' on behalf of ' || p_quote_data.mam);
plpdf.printflowingtext(p_h => 4
,p_txt => ' on behalf of ' || p_quote_data.mam);
plpdf.setprintfont(p_font
,NULL
,10); --unset bold
plpdf.printflowingtext(4
,' and in accordance with their General Conditions of Contract for Transactional Meter Works Not Exceeding 7 Bar.');
plpdf.printflowingtext(p_h => 4
,p_txt => ' and in accordance with their General Conditions of Contract for Transactional Meter Works Not Exceeding 7 Bar.');
plpdf.setprintfont(p_font
,'B'
,10); --set bold
plpdf.printflowingtext(4
,' Please note, if you accept this quotation you are agreeing to be bound by the terms of the ' ||
p_quote_data.mam ||
' and General Conditions of Contract for Transactional Meter Works Not Exceeding 7 Bar, and all subsequent work will be performed in accordance with that contract.');
-- plpdf.setcellmargin(l_cell_margin);
plpdf.setleftmargin(33.7); --31.7
plpdf.printflowingtext(p_h => 4
,p_txt => ' Please note, if you accept this quotation you are agreeing to be bound by the terms of the ' ||
p_quote_data.mam ||
' and General Conditions of Contract for Transactional Meter Works Not Exceeding 7 Bar, and all subsequent work will be performed in accordance with that contract.');
plpdf.setprintfont(p_font
,NULL
,10); --unset bold
@@ -1510,6 +1531,9 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
plpdf.printtext(p_indent
,p_vertical_offset + 242
,'National Grid Metering');
plpdf.setcellmargin(l_cell_margin);
END build_covering_letter;
/*
PROCEDURE build_costs_page
@@ -1525,17 +1549,20 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
,p_indent IN NUMBER
,p_vertical_offset IN NUMBER
,p_watermark_blob BLOB) IS
l_cell_margin NUMBER;
l_cost_line_counter NUMBER;
l_vertical_offset_for_costs NUMBER := p_vertical_offset + 126;
l_works_counter NUMBER;
l_vertical_offset_for_works NUMBER := p_vertical_offset + 52;
l_ybefore NUMBER := 0; --used to adjust the vertical offest after contract sum caveat
l_cost_totals_offset NUMBER; --used to position the cost totals after the cost line items
l_caveat_desc_works_offset NUMBER; --used to position caveat_desc_works as running calculation in
--function parameter causes error on pdf
BEGIN
--Page 2
plpdf.newpage;
plpdf.crbookmark(p_txt => 'Quotation');
l_cell_margin := plpdf.getcellmargin;
plpdf.setcellmargin(0);
--set watermark if it exists
IF p_watermark_blob IS NOT NULL THEN
plpdf.putimage('test watermark'
@@ -1545,10 +1572,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
,200
,200);
END IF;
-- set margins
plpdf.setleftmargin(31.7);
plpdf.setrightmargin(31.7);
plpdf.settopmargin(25.4);
plpdf.setprintfont(p_font
,'B'
,10); --set bold
@@ -1570,7 +1594,8 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
,'MPRN: ' || TO_CHAR(p_quote_data.mprn));
plpdf.printtext(p_indent
,p_vertical_offset + 30
,'Date: ' || p_quote_data.current_date);
,'Date: ' || TO_CHAR(p_quote_data.current_date
,'FMddth Month YYYY'));
plpdf.setprintfont(p_font
,'B'
,10); --set bold
@@ -1614,6 +1639,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
print_caveats(p_quote_data.caveat_desc_works
,l_caveat_desc_works_offset + 1);
END IF;
plpdf.setprintfont(p_font
,NULL
,10); --unset bold
@@ -1629,16 +1655,15 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
plpdf.setprintfont(p_font
,NULL
,10); --unset bold
l_ybefore := plpdf.getcurrenty;
l_vertical_offset_for_costs := l_vertical_offset_for_costs +
(plpdf.getcurrenty - l_ybefore);
plpdf.setprintfont(p_font
,NULL
,10); --unset bold
plpdf.setcurrenty(p_vertical_offset + 114);
print_costs(p_description => 'Contract sum (excluding V.A.T):'
,p_cost => p_quote_data.total_cost
,p_suffix => glue_one_line_caveat(p_quote_data.caveat_cont_sum)); -- CONT_SUM caveat here
,p_suffix => ' ' ||
glue_one_line_caveat(p_quote_data.caveat_cont_sum)); -- CONT_SUM caveat here
plpdf.linebreak(20); -- line break, height is 20
print_costs(p_description => 'Analysis of Costs (all costs exclude V.A.T)');
plpdf.setprintfont(p_font
@@ -1658,12 +1683,13 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
l_cost_line_counter := l_cost_line_counter + 1;
END LOOP;
--
l_cost_totals_offset := l_vertical_offset_for_costs +
l_cost_line_counter * 4;
print_costs(p_description => 'Total costs:'
,p_cost => p_quote_data.total_cost
,p_border => 'T'
,p_suffix => glue_one_line_caveat(p_quote_data.caveat_cont_sum)); -- CONT_SUM caveat here
,p_suffix => ' ' ||
glue_one_line_caveat(p_quote_data.caveat_cont_sum)); -- CONT_SUM caveat here
plpdf.setcellmargin(l_cell_margin);
END build_costs_page;
/*
@@ -1685,6 +1711,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
BEGIN
--Page 3
plpdf.newpage;
plpdf.crbookmark(p_txt => 'Meter housing details and caveats');
--set watermark if it exists
IF p_watermark_blob IS NOT NULL THEN
plpdf.putimage('test watermark'
@@ -1694,10 +1721,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
,200
,200);
END IF;
-- set margins
plpdf.setleftmargin(31.7);
plpdf.setrightmargin(31.7);
plpdf.settopmargin(25.4);
plpdf.setprintfont(p_font
,NULL
,10); --set font to plain
@@ -1790,6 +1814,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
--Okay here come the pretty pictures, the technical spec for the module, house & base
--this will be page 4 for the quotation
plpdf.newpage;
plpdf.crbookmark(p_txt => 'Drawings');
--set watermark if it exists
IF p_watermark_blob IS NOT NULL THEN
plpdf.putimage('test watermark'
@@ -2257,6 +2282,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
BEGIN
--this will be page 5 (part of the technical spec sheet) for the quotation
plpdf.newpage;
plpdf.crbookmark(p_txt => 'Technical specifications');
--set watermark if it exists
IF p_watermark_blob IS NOT NULL THEN
plpdf.putimage('test watermark'
@@ -2744,6 +2770,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
BEGIN
---weeeeee last page
plpdf.newpage;
plpdf.crbookmark(p_txt => 'Acceptance Letter');
--set watermark if it exists
IF p_watermark_blob IS NOT NULL THEN
plpdf.putimage('test watermark'
@@ -2969,39 +2996,41 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
l_font VARCHAR2(40) := 'Arial'; --arial not daz
l_quote_row quotes%ROWTYPE;
l_enqu_row enquiries%ROWTYPE;
CURSOR c_get_logo(cp_logo VARCHAR2) IS
SELECT blob_content
FROM wwv_flow_files
WHERE filename = cp_logo;
CURSOR c_get_signature(cp_signature VARCHAR2) IS
SELECT blob_content
FROM wwv_flow_files
WHERE filename = cp_signature;
CURSOR c_get_watermark(cp_watermark VARCHAR2) IS
SELECT blob_content
FROM wwv_flow_files
WHERE filename = cp_watermark
AND flow_id = apex_application.g_flow_id;
BEGIN
IF NOT c_get_logo%ISOPEN THEN
OPEN c_get_logo('quote_logo.jpg');
END IF;
FETCH c_get_logo
INTO l_logo_blob;
CLOSE c_get_logo;
IF NOT c_get_signature%ISOPEN THEN
OPEN c_get_signature('quote_signature.jpg');
END IF;
FETCH c_get_signature
INTO l_signature_blob;
CLOSE c_get_signature;
IF NOT c_get_watermark%ISOPEN THEN
OPEN c_get_watermark('test_watermark.jpg');
END IF;
FETCH c_get_watermark
INTO l_watermark_blob;
CLOSE c_get_watermark;
BEGIN
SELECT blob_content
INTO l_logo_blob
FROM wwv_flow_files
WHERE filename = 'quote_logo.jpg'
AND rownum < 2;
EXCEPTION
WHEN no_data_found THEN
NULL;
END;
BEGIN
SELECT blob_content
INTO l_signature_blob
FROM wwv_flow_files
WHERE filename = 'quote_signature.jpg'
AND rownum < 2;
EXCEPTION
WHEN no_data_found THEN
NULL;
END;
BEGIN
SELECT blob_content
INTO l_watermark_blob
FROM wwv_flow_files
WHERE filename = 'test_watermark.jpg'
AND flow_id = apex_application.g_flow_id
AND rownum < 2;
EXCEPTION
WHEN no_data_found THEN
NULL;
END;
l_quote_row := get_quote_row(p_quote_id);
l_enqu_row := get_enquiry_row(l_quote_row.enqu_id);
@@ -3013,6 +3042,19 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
l_module_blob := get_drawing(p_quote_data.module_diagram);
-- Initialize PDF
plpdf.init;
plpdf.setprotection(p_print_perm => TRUE
,p_copy_perm => TRUE);
-- set margins
plpdf.setleftmargin(31.7);
plpdf.setrightmargin(31.7);
plpdf.settopmargin(25.4);
plpdf.setdocauthor('National Grid Metering Online Quotation System');
plpdf.setdoctitle('Online Quotation Reference ' ||
p_quote_data.quote_ref || ' for enquiry ' ||
p_quote_data.enquiry_ref || '.');
--build the pages for the quote
build_covering_letter(p_quote_data
,l_font