CREATE OR REPLACE PACKAGE mip_quotation_document IS -- Author : HARDYA -- Created : 15/11/2007 11:27:58 -- Purpose : Handle life-cycle of quotations -- Public type declarations --type is ; type cost_line is record( cost_description varchar2(80), cost_price number); type address is varray(7) of varchar2(160); type works is varray(20) of varchar2(160); type costs is varray(20) of cost_line; type caveats is varray(20) of varchar2(2000); type dimensions is varray(10) of number; type quote_data is record (quote_ref NUMBER, transaction_ref VARCHAR2(80), mprn number(30), supplier_address address := address(null,null,null,null,null,null,null), current_date DATE, agent_first_name varchar2(80), 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), lead_time number, total_cost number, 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, house_height number, house_ventilation number, base_length number, 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), liquid_damage_day number, liquid_damage_cap number, base_dimensions dimensions := dimensions(null,null,null,null,null,null,null,null,null,null), base_diagram varchar2(80), house_dimensions dimensions := dimensions(null,null,null,null,null,null,null,null,null,null), house_diagram varchar2(80), module_dimensions dimensions := dimensions(null,null,null,null,null,null,null,null,null,null), module_reference varchar2(80), module_diagram varchar2(80), requested_qmax number, module_qmax number, module_qmin number, module_inlet_height number, module_outlet_height number, module_inlet_size number, module_outlet_size number, module_inlet_type varchar2(80), module_outlet_type varchar2(80), module_inlet_orientation varchar2(80), module_outlet_orientation varchar2(80) ); -- Public constant declarations -- constant := ; -- Public variable declarations -- ; -- Public function and procedure declarations -- function ( ) return ; function get_mam(p_region_code varchar2) return varchar2; function get_module_row(p_code varchar2) return modules%ROWTYPE; function get_max_lead_time(p_quoteid number) return number; FUNCTION determine_caveats(p_enquiryid in number) RETURN BOOLEAN; PROCEDURE set_quote_items_data (p_quote_data in out quote_data, p_quoteid number, p_enqu_row enquiries%ROWTYPE); FUNCTION get_detailed_quote_data(p_quoteid in number) RETURN quote_data; FUNCTION generate_detailed_quote_pdf(p_quote_data in quote_data) RETURN NUMBER; END mip_quotation_document; / CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS /* FUNCTION get_mam --The get_mam function returns a meter asset manager description for the supplied region code. %param p_region_code - the code of the region you want to get the mam description of. %return varchar(80)description of the supplied regions code mam */ function get_mam(p_region_code varchar2) return varchar2 is l_mam_desc varchar2(80); CURSOR c_get_mam(cp_region_code varchar2) IS SELECT description FROM regions WHERE code = cp_region_code; begin IF NOT c_get_mam%ISOPEN THEN OPEN c_get_mam(p_region_code); END IF; FETCH c_get_mam INTO l_mam_desc; CLOSE c_get_mam; return l_mam_desc; end get_mam; /* FUNCTION get_meter_row --The get_meter_row function returns a meter record for the supplied meter code. %param p_code - the code of the meter you want to get a record of. %return meters row of the supplied meter code */ function get_meter_row(p_code varchar2) return meters%ROWTYPE is l_meter_row meters%ROWTYPE; CURSOR c_get_meter(cp_meter_code varchar2) IS SELECT * FROM meters WHERE code = cp_meter_code; begin IF NOT c_get_meter%ISOPEN THEN OPEN c_get_meter(p_code); END IF; FETCH c_get_meter INTO l_meter_row; CLOSE c_get_meter; return l_meter_row; end get_meter_row; /* FUNCTION get_module_row --The get_module_row function returns a module record for the supplied module code. %param p_code - the code of the module you want to get a record of. %return modules row of the supplied module code */ function get_module_row(p_code varchar2) return modules%ROWTYPE is l_module_row modules%ROWTYPE; CURSOR c_get_module(cp_module_code varchar2) IS SELECT * FROM modules WHERE code = cp_module_code; begin IF NOT c_get_module%ISOPEN THEN OPEN c_get_module(p_code); END IF; FETCH c_get_module INTO l_module_row; CLOSE c_get_module; return l_module_row; end get_module_row; /* FUNCTION get_housing_row --The get_housing_row function returns a housing record for the supplied housing code. %param p_code - the code of the housing you want to get a record of. %return housings row of the supplied housing code */ function get_housing_row(p_code varchar2) return housings%ROWTYPE is l_housing_row housings%ROWTYPE; CURSOR c_get_housing(cp_housing_code varchar2) IS SELECT * FROM housings WHERE code = cp_housing_code; begin IF NOT c_get_housing%ISOPEN THEN OPEN c_get_housing(p_code); END IF; FETCH c_get_housing INTO l_housing_row; CLOSE c_get_housing; return l_housing_row; end get_housing_row; /* FUNCTION get_base_row --The get_base_row function returns a base record for the supplied base code. %param p_code - the code of the base you want to get a record of. %return bases row of the supplied base code */ function get_base_row(p_code varchar2) return bases%ROWTYPE is l_base_row bases%ROWTYPE; CURSOR c_get_base(cp_base_code varchar2) IS SELECT * FROM bases WHERE code = cp_base_code; begin IF NOT c_get_base%ISOPEN THEN OPEN c_get_base(p_code); END IF; FETCH c_get_base INTO l_base_row; CLOSE c_get_base; return l_base_row; end get_base_row; /* FUNCTION get_additional_item --The get_additional_item function returns an additional_item record for the supplied additional --item code. %param p_code - the code of the additional item you want to get a record of. %return additional_items row of the supplied item code */ function get_additional_item(p_code varchar2) return additional_items%ROWTYPE is --Additional Items l_add_item_row additional_items%ROWTYPE; CURSOR c_get_add_item(cp_additid varchar2) IS SELECT * FROM additional_items WHERE code = cp_additid; begin --get additional item IF NOT c_get_add_item%ISOPEN THEN OPEN c_get_add_item(p_code); END IF; FETCH c_get_add_item INTO l_add_item_row; CLOSE c_get_add_item; return l_add_item_row; end get_additional_item; /* FUNCTION get_max_lead_time --The get_max lead_time function returns the contracted lead time for the provided quotation. --It takes the largest lead time of all the quotation items (modules, addons, housings bases) --hence the max bit %param p_quoteid - the id of the quote you want to get the lead time. %return number the maximum contacted lead time for the supplied quotation */ function get_max_lead_time(p_quoteid number) return number is l_quote_item_maxlt number; CURSOR c_get_max_lead_time (cp_id number) is SELECT MAX(lead_time) FROM quote_items WHERE qute_id = cp_id; begin IF NOT c_get_max_lead_time%ISOPEN THEN OPEN c_get_max_lead_time(p_quoteid); END IF; FETCH c_get_max_lead_time INTO l_quote_item_maxlt; CLOSE c_get_max_lead_time; return l_quote_item_maxlt; end get_max_lead_time; /* FUNCTION get_total_cost --The get_total_cost function returns the total cost for a quotation (excluding lifting gear) %param p_quoteid - the id of the quote you want to get the total cost for. %return number the total cost */ function get_total_cost(p_quoteid number) return number is l_quote_total_cost number; CURSOR c_get_total_cost (cp_id number) is SELECT SUM(selling_price + delivery_price) FROM quote_items WHERE qute_id = cp_id; begin IF NOT c_get_total_cost%ISOPEN THEN OPEN c_get_total_cost(p_quoteid); END IF; FETCH c_get_total_cost INTO l_quote_total_cost; CLOSE c_get_total_cost; 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. */ procedure set_quote_items_data (p_quote_data in out quote_data, p_quoteid number, p_enqu_row enquiries%ROWTYPE) is --Enquiry type l_enqu_type_row enquiry_types%ROWTYPE; CURSOR c_get_enquiry_type(cp_enty_code varchar2) IS SELECT * FROM enquiry_types WHERE code = cp_enty_code; --Quote Items l_quote_item_row quote_items%ROWTYPE; CURSOR c_get_quote_item(cp_quoteid number) IS SELECT * FROM quote_items WHERE qute_id = cp_quoteid; --Module data l_module_row modules%ROWTYPE; --Additional Items l_add_item_row additional_items%ROWTYPE; l_works works := works(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null); --list of works for the quote l_addons varchar(300); --list of addons for the quote l_housing_row housings%ROWTYPE; l_base_row bases%ROWTYPE; l_meter_row meters%ROWTYPE; -- used to get the qmax and qmin of the meter l_total_cost number; --used to figure out the liquidated damages costs l_counter number; begin --cycle through the quote items picking up each item to display on the --description of works section l_counter := 0; FOR quote_item_rec IN c_get_quote_item(p_quoteid) LOOP l_counter := l_counter + 1; case quote_item_rec.quit_type when 'BQI' then --base item l_addons := l_addons || ', Base'; --Set the costs p_quote_data.quote_costs(l_counter).cost_description := 'Base Materials cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.selling_price; if not (quote_item_rec.delivery_price is null) then l_counter:=l_counter +1; p_quote_data.quote_costs(l_counter).cost_description := 'Base Delivery cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.delivery_price; end if; --get the base details l_base_row := get_base_row(quote_item_rec.bas_code); p_quote_data.base_length := l_base_row.dim_a; p_quote_data.base_depth := l_base_row.dim_b; p_quote_data.base_height := l_base_row.depth; --get base technical details p_quote_data.base_dimensions(1) := l_base_row.depth; p_quote_data.base_dimensions(2) := l_base_row.dim_a; p_quote_data.base_dimensions(3) := l_base_row.dim_b; p_quote_data.base_dimensions(4) := l_base_row.dim_c; p_quote_data.base_dimensions(5) := l_base_row.dim_d; p_quote_data.base_dimensions(6) := l_base_row.dim_e; p_quote_data.base_dimensions(7) := l_base_row.dim_f; p_quote_data.base_dimensions(8) := l_base_row.dim_g; p_quote_data.base_dimensions(9) := l_base_row.dim_h; p_quote_data.base_dimensions(10) := l_base_row.dim_i; p_quote_data.base_diagram := l_base_row.drwg_code; when 'HQI' then --housing item l_addons := l_addons || ', Housing'; --Set up the costs p_quote_data.quote_costs(l_counter).cost_description := 'Housing Materials cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.selling_price; if not (quote_item_rec.delivery_price is null) then l_counter:=l_counter +1; p_quote_data.quote_costs(l_counter).cost_description := 'Housing Delivery cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.delivery_price; end if; --get the housing code and return the housing details into p_quote_data l_housing_row := get_housing_row(quote_item_rec.hou_code); p_quote_data.house_length := l_housing_row.dim_l; p_quote_data.house_depth := l_housing_row.dim_w; p_quote_data.house_height := l_housing_row.dim_h; p_quote_data.house_ventilation := ((l_housing_row.dim_l*l_housing_row.dim_w)/100)*3; --get housing technical details p_quote_data.house_dimensions(1) := l_housing_row.dim_l; p_quote_data.house_dimensions(2) := l_housing_row.dim_w; p_quote_data.house_dimensions(3) := l_housing_row.dim_h; p_quote_data.house_dimensions(4) := l_housing_row.weight; p_quote_data.house_diagram := l_housing_row.drwg_code; when 'AQI' then --add-on item --If we get time add an if statement round this that checks if the --Additional Item is lifting gear that it only appears for --LP Diaphgram install/std install jobs --Get costs l_add_item_row := get_additional_item(quote_item_rec.adit_code); p_quote_data.quote_costs(l_counter).cost_description := l_add_item_row.description||' Materials cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.selling_price; if not(quote_item_rec.delivery_price is null) then l_counter:=l_counter +1; p_quote_data.quote_costs(l_counter).cost_description := l_add_item_row.description||' Delivery cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.delivery_price; end if; --set the list of add-ons for this quote l_addons := l_addons || ', '||l_add_item_row.description; when 'MQI' then --module item --get costs p_quote_data.quote_costs(l_counter).cost_description := 'Module Materials cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.selling_price; if not(quote_item_rec.delivery_price is null) then l_counter:=l_counter +1; p_quote_data.quote_costs(l_counter).cost_description := 'Module Delivery cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.delivery_price; end if; --other module details l_module_row := get_module_row (quote_item_rec.modu_code); l_works(3) := 'Meter Type: '|| l_module_row.svcp_code || ' ' || l_module_row.metr_code; p_quote_data.outlet_termninal_size := l_module_row.outlet_size; --module technical details p_quote_data.module_dimensions(1) := l_module_row.dim_a; p_quote_data.module_dimensions(2) := l_module_row.dim_b; p_quote_data.module_dimensions(3) := l_module_row.dim_c; p_quote_data.module_dimensions(4) := l_module_row.dim_d; p_quote_data.module_dimensions(5) := l_module_row.dim_e; p_quote_data.module_dimensions(6) := l_module_row.dim_h; p_quote_data.module_dimensions(7) := l_module_row.inlet_height; p_quote_data.module_dimensions(8) := l_module_row.outlet_height; p_quote_data.module_dimensions(9) := l_module_row.weight; p_quote_data.module_reference := l_module_row.code; p_quote_data.module_inlet_height := l_module_row.inlet_height; p_quote_data.module_outlet_height := l_module_row.outlet_height; p_quote_data.module_inlet_size := l_module_row.inlet_size; p_quote_data.module_outlet_size := l_module_row.outlet_size; p_quote_data.module_inlet_type := l_module_row.inlet_cnty_code; p_quote_data.module_outlet_type := l_module_row.outlet_cnty_code; 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 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; when 'LQI' then --Labour cost --get costs p_quote_data.quote_costs(l_counter).cost_description := 'Labour Costs'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.selling_price; if not(quote_item_rec.delivery_price is null) then l_counter:=l_counter +1; p_quote_data.quote_costs(l_counter).cost_description := 'Labour Delivery cost'; p_quote_data.quote_costs(l_counter).cost_price := quote_item_rec.delivery_price; end if; end case; END LOOP; --get type of enquiry to display as works type IF NOT c_get_enquiry_type%ISOPEN THEN OPEN c_get_enquiry_type(p_enqu_row.enty_code); END IF; FETCH c_get_enquiry_type INTO l_enqu_type_row; CLOSE c_get_enquiry_type; l_works(1) := 'Works Type: '||l_enqu_type_row.description; --get service pressure l_works(2) := 'Service Pressure: '|| p_enqu_row.required_svcp_code; --may need to get this from quote items table instead --get existing meter if appropriate if l_quote_item_row.enty_code <>'INSTALL' and l_quote_item_row.enty_code <>'STD INSTALL' then l_works(4) := 'Existing Meter Type: '|| p_enqu_row.existing_mesc_code ||', '|| p_enqu_row.existing_meter_model; end if; if l_quote_item_row.enty_code <> 'OFMAT' and l_quote_item_row.enty_code <> 'ADVERSARIAL'then l_total_cost := p_quote_data.total_cost; if l_total_cost <= 1000 then p_quote_data.liquid_damage_day := 20; p_quote_data.liquid_damage_cap := 200; else p_quote_data.liquid_damage_day := (l_total_cost/100)*2.5; p_quote_data.liquid_damage_cap := (l_total_cost/100)*25; end if; end if; -- --add up all the addons and format the string l_works(5) := 'Add-Ons: '|| l_addons; p_quote_data.quote_works := l_works; end set_quote_items_data; /* FUNCTION get_detailed_quote_data --This function should return all required data for the quotation. --The return value could be a type variable or perhaps an array? %param p_quoteid - the quotation we want to build a pdf for. %param possibly a few more params to get the required data in or change format of pdf %return return the quote data in the quote_data reocrd type */ 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_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 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; --Party name l_party_row parties%ROWTYPE; CURSOR c_get_party(cp_party_id number) IS SELECT * FROM parties WHERE id = cp_party_id; --Agent Name l_agent_first_name varchar2(80); 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 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; 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'); END IF; FETCH c_get_address INTO l_addr_row; CLOSE c_get_address; --get current supplier and agent ids for enquiry l_supplier_id := mip_enquiry.get_enquiry_role(l_enqu_row.id,'ENQ SUPP'); l_agent_id := mip_enquiry.get_enquiry_role(l_enqu_row.id,'ENQ OWN'); --supplier IF NOT c_get_party%ISOPEN THEN OPEN c_get_party(l_supplier_id); END IF; FETCH c_get_party INTO l_party_row; CLOSE c_get_party; l_supplier_name := l_party_row.name; --agent IF NOT c_get_party%ISOPEN THEN OPEN c_get_party(l_agent_id); END IF; FETCH c_get_party INTO l_party_row; CLOSE c_get_party; l_agent_first_name := l_party_row.first_name; l_agent_last_name := l_party_row.last_name; l_quote_data.quote_ref := l_quote_row.id; l_quote_data.transaction_ref := l_enqu_row.transaction_reference; l_quote_data.mprn := l_enqu_row.mprn; l_quote_data.supplier_address(1) := l_agent_first_name||' '||l_agent_last_name; l_quote_data.supplier_address(2) := l_supplier_name; l_quote_data.supplier_address(3) := l_addr_row.sub_building; l_quote_data.supplier_address(4) := l_addr_row.building; l_quote_data.supplier_address(5) := l_addr_row.street; l_quote_data.supplier_address(6) := l_addr_row.city; l_quote_data.supplier_address(7) := l_addr_row.postcode; l_quote_data.current_date := sysdate; l_quote_data.agent_first_name := l_agent_first_name; l_quote_data.site_address(1) := l_enqu_row.install_sub_building; l_quote_data.site_address(2) := l_enqu_row.install_building; 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 l_quote_data.mam := get_mam(mip_regions.get_region_for_postcode(l_enqu_row.install_postcode)); --l_quote_data.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; --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) --phew, lets return all that lovely data we captured then... return l_quote_data; end get_detailed_quote_data; /* PROCEDURE build_covering_letter --This procedure builds the covering letter for the quotation, it writes data --to an existing plpdf document %param p_quote_data in - The current data for this quote %param p_font - the type of font to use - typically 'Arial'. %param p_indent - the left margin measurement. %param p_vertical_offset - the top margin measurement. %param p_logo_blob - the logo(image) to display at the top of the page %param p_signature_blob - the signature(image) to display at the bottom of the page */ PROCEDURE build_covering_letter(p_quote_data in quote_data, p_font in varchar2, p_indent in number, p_vertical_offset in number,p_logo_blob blob,p_signature_blob blob) is l_contracts_text varchar2(500); begin plpdf.NewPage; -- set margins plpdf.SetLeftMargin(31.7); plpdf.SetRightMargin(31.7); plpdf.SetTopMargin(25.4); plpdf.SetPrintFont(p_font,null,7); -- Set header stuff up plpdf.PutImage('ngmlogo',p_logo_blob,p_indent,10,52,18); plpdf.PrintText(140,10,'4 Abbotts Lane '); plpdf.PrintText(140,13,'Coventry'); plpdf.PrintText(140,16,'CV1 4AY'); plpdf.PrintText(170,10,'T +44 (0) 24 7628 6000'); plpdf.PrintText(170,13,'F +44 (0) 24 7628 6022'); plpdf.PrintText(170,16,'www.nationalgrid.com'); -- And Footer stuff plpdf.PrintText(50,280,'National Grid Metering is the trading name for National Grid Metering Ltd.'); 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 plpdf.PrintText(p_indent,p_vertical_offset+10,'National Grid Metering''s Ref: '|| to_char(p_quote_data.quote_ref)); plpdf.PrintText(p_indent,p_vertical_offset+14,'Customer Reference: '|| p_quote_data.transaction_ref); plpdf.PrintText(p_indent,p_vertical_offset+18,'MPRN: '|| to_char(p_quote_data.mprn)); plpdf.PrintText(p_indent,p_vertical_offset+26,p_quote_data.supplier_address(1)); plpdf.PrintText(p_indent,p_vertical_offset+30,p_quote_data.supplier_address(2)); plpdf.PrintText(p_indent,p_vertical_offset+34,p_quote_data.supplier_address(3)); plpdf.PrintText(p_indent,p_vertical_offset+38,p_quote_data.supplier_address(4)); plpdf.PrintText(p_indent,p_vertical_offset+42,p_quote_data.supplier_address(5)); plpdf.PrintText(p_indent,p_vertical_offset+46,p_quote_data.supplier_address(6)); plpdf.PrintText(p_indent,p_vertical_offset+50,p_quote_data.supplier_address(7)); plpdf.PrintText(p_indent,p_vertical_offset+58,'Date: '||p_quote_data.current_date); plpdf.PrintText(p_indent,p_vertical_offset+66,'Quotation Contact: Customer Services Team 1'); plpdf.PrintText(p_indent,p_vertical_offset+70,'Telephone Number: 02476 286 320'); plpdf.PrintText(p_indent,p_vertical_offset+74,'Fax Number: 02476 286 044'); plpdf.PrintText(p_indent,p_vertical_offset+78,'E-mail address: iandcrequests1@uk.ngrid.com'); plpdf.PrintText(p_indent,p_vertical_offset+90,'Dear '|| p_quote_data.agent_first_name); --agent first name plpdf.SetPrintFont(p_font,'B',10); --set bold plpdf.PrintText(p_indent,p_vertical_offset+98,'Re: '||p_quote_data.site_address(1)||', '||p_quote_data.site_address(2)||', '||p_quote_data.site_address(3)||', '||p_quote_data.site_address(4)||', '||p_quote_data.site_address(5)||', '||p_quote_data.site_address(6)||', '||p_quote_data.site_address(7)); --site address plpdf.SetPrintFont(p_font,null,10); --unset bold l_contracts_text :='I am pleased to provide you with a quotation for works in accordance with the '||p_quote_data.mam;--mam l_contracts_text := l_contracts_text||' General Conditions of Contract for Transactional Meter Works not Exceeding 7 Bar.'; plpdf.SetCurrentY(p_vertical_offset+106); plpdf.PrintFlowingText(6,l_contracts_text); plpdf.LineBreak; plpdf.PrintText(p_indent,p_vertical_offset+128,'This quotation is produced on the basis that, the information provided in the request is correct.'); plpdf.PrintText(p_indent,p_vertical_offset+132,'Your acceptance of the quotation will be taken to mean that you also accept that the stated'); plpdf.PrintText(p_indent,p_vertical_offset+136,'assumptions are correct. If it is later determined, by either party prior to works commencing on'); plpdf.PrintText(p_indent,p_vertical_offset+140,'site, that any stated assumption is significantly incorrect, National Grid Metering will determine'); plpdf.PrintText(p_indent,p_vertical_offset+144,'whether the quotation shall be varied or withdrawn. Works will only then commence if any'); plpdf.PrintText(p_indent,p_vertical_offset+148,'variation is agreed in line with the relevant General Conditions of Contract.'); -- plpdf.PrintText(p_indent,p_vertical_offset+156,'To accept the quotation please submit a work request via IX, as outlined in the Rainbow Manual,'); plpdf.PrintText(p_indent,p_vertical_offset+160,'or complete the enclosed Acceptance Form and return it to the above National Grid Metering'''); plpdf.PrintText(p_indent,p_vertical_offset+164,'office.'); -- plpdf.PrintText(p_indent,p_vertical_offset+172,'Please note that this quotation is valid for 90 days from the date specified in the quotation.'); plpdf.PrintText(p_indent,p_vertical_offset+176,'Please use National Grid Metering''s Reference, which is at the top of the letter, on any future'); plpdf.PrintText(p_indent,p_vertical_offset+180,'correspondence relating to this request.'); -- plpdf.PrintText(p_indent,p_vertical_offset+188,'If you have any queries, please contact the team on the number above'); plpdf.PrintText(p_indent,p_vertical_offset+196,'Yours sincerely'); --put on daves signature plpdf.PutImage('dhsignature',p_signature_blob,p_indent,230,40,10); plpdf.PrintText(p_indent,p_vertical_offset+216,'David Harper'); plpdf.PrintText(p_indent,p_vertical_offset+220,'I&C Technical Manager'); plpdf.PrintText(p_indent,p_vertical_offset+224,'National Grid Metering'); end build_covering_letter; /* PROCEDURE build_costs_page --This procedure builds the costs page for the quotation, it writes data --to an existing plpdf document %param p_quote_data in - The current data for this quote %param p_font - the type of font to use - typically 'Arial'. %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 l_cost_line_counter number; l_vertical_offset_for_costs number := p_vertical_offset+110; l_works_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; -- set margins plpdf.SetLeftMargin(31.7); plpdf.SetRightMargin(31.7); plpdf.SetTopMargin(25.4); plpdf.SetPrintFont(p_font,'B',10); --set bold plpdf.PrintText(p_indent,p_vertical_offset+10,'QUOTATION'); plpdf.SetPrintFont(p_font,null,10); --unset bold plpdf.PrintText(p_indent,p_vertical_offset+18,'National Grid Metering''s Ref: '|| to_char(p_quote_data.quote_ref)); plpdf.PrintText(p_indent,p_vertical_offset+22,'Customer Reference: '|| p_quote_data.transaction_ref); plpdf.PrintText(p_indent,p_vertical_offset+30,'Date: '||p_quote_data.current_date); plpdf.SetPrintFont(p_font,'B',10); --set bold plpdf.PrintText(p_indent,p_vertical_offset+38,'Re: '||p_quote_data.site_address(1)||', '||p_quote_data.site_address(2)||', '||p_quote_data.site_address(3)||', '||p_quote_data.site_address(4)||', '||p_quote_data.site_address(5)||', '||p_quote_data.site_address(6)||', '||p_quote_data.site_address(7)); --site address plpdf.SetPrintFont(p_font,'U',10); --set underline plpdf.PrintText(p_indent,p_vertical_offset+48,'Full Description of Works to be carried out by National Grid Metering:'); plpdf.SetPrintFont(p_font,'B',10); --set bold l_works_counter := 1; while p_quote_data.quote_works(l_works_counter) is not null 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; 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 plpdf.PrintText(140,p_vertical_offset+90, p_quote_data.lead_time||' working days'); plpdf.SetPrintFont(p_font,null,10); --unset bold 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,'£'||to_char(p_quote_data.total_cost,'FM999999D90')); 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 l_cost_line_counter:=1; while p_quote_data.quote_costs(l_cost_line_counter).cost_description is not null loop plpdf.PrintText(p_indent,l_vertical_offset_for_costs+l_cost_line_counter*4,p_quote_data.quote_costs(l_cost_line_counter).cost_description); plpdf.PrintText(120,l_vertical_offset_for_costs+l_cost_line_counter*4,'£'||to_char(p_quote_data.quote_costs(l_cost_line_counter).cost_price,'FM999999D90')); 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; --think this line supposed to be in the cost items collection rather than hardcoded --also delivery cost price does not seem to be available on the example I've been using plpdf.PrintText(p_indent,l_cost_totals_offset,'Lifting Gear if required'); plpdf.PrintText(120,l_cost_totals_offset,'£220'); plpdf.DrawLine(p_indent,l_cost_totals_offset+2,185,l_cost_totals_offset+2); plpdf.PrintText(p_indent,l_cost_totals_offset+6,'Total costs:'); plpdf.PrintText(120,l_cost_totals_offset+6,'£'||to_char(p_quote_data.total_cost,'FM999999D90')||' excluding lifting gear if required'); end build_costs_page; /* PROCEDURE build_caveats_page --This procedure builds the caveats page for the quotation, it writes data --to an existing plpdf document %param p_quote_data in - The current data for this quote %param p_font - the type of font to use - typically 'Arial'. %param p_indent - the left margin measurement. %param p_vertical_offset - the top margin measurement. */ PROCEDURE build_caveats_page(p_quote_data in quote_data, p_font in varchar2, p_indent in number, p_vertical_offset in number) is begin --Page 3 plpdf.NewPage; -- set margins plpdf.SetLeftMargin(31.7); plpdf.SetRightMargin(31.7); plpdf.SetTopMargin(25.4); plpdf.SetPrintFont(p_font,null,10); --set font to plain --house plpdf.PrintText(p_indent,p_vertical_offset+10,'Meter Housing Details (if required):'); plpdf.PrintText(p_indent,p_vertical_offset+18,'Length: '||p_quote_data.house_length||' mm'); plpdf.PrintText(p_indent+40,p_vertical_offset+18,'Depth: '||p_quote_data.house_depth||' mm'); plpdf.PrintText(p_indent+80,p_vertical_offset+18,'Height: '||p_quote_data.house_height||' mm'); plpdf.PrintText(p_indent,p_vertical_offset+26,'Minimum Ventilation: '||p_quote_data.house_ventilation/10||' sq. cm'); --base plpdf.PrintText(p_indent,p_vertical_offset+42,'Meter Housing Base (if required):'); plpdf.PrintText(p_indent,p_vertical_offset+50,'Length: '||p_quote_data.base_length||' mm'); plpdf.PrintText(p_indent+40,p_vertical_offset+50,'Depth: '||p_quote_data.base_depth||' mm'); 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 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) plpdf.SetPrintFont(p_font,null,10); --unset bold plpdf.PrintText(p_indent,p_vertical_offset+200,'Liquidated Damages (sum per day)(excluding V.A.T):'); plpdf.PrintText(130,p_vertical_offset+200,'£'||p_quote_data.liquid_damage_day); plpdf.PrintText(p_indent,p_vertical_offset+208,'Liquidated Damages (monetary cap)(excluding V.A.T):'); plpdf.PrintText(130,p_vertical_offset+208,'£'||p_quote_data.liquid_damage_cap); end build_caveats_page; /* PROCEDURE build_drawings_page --This procedure builds the drawings page for the quotation, it writes data --to an existing plpdf document %param p_quote_data in - The current data for this quote %param p_font - the type of font to use - typically 'Arial'. %param p_indent - the left margin measurement. %param p_vertical_offset - the top margin measurement. */ PROCEDURE build_drawings_page(p_quote_data in quote_data, p_font in varchar2, p_indent in number, p_vertical_offset in number) is begin --Okay here come the pretty pictures, the technical spec for the module, house & base --this will be page 4 for the quotation plpdf.NewPage; -- set margins plpdf.SetLeftMargin(31.7); plpdf.SetRightMargin(31.7); plpdf.SetTopMargin(25.4); plpdf.SetPrintFont(p_font,'B',18); --set bold and 18pt plpdf.PrintText(p_indent,p_vertical_offset,'Technical Specification for '||p_quote_data.quote_ref); plpdf.SetPrintFont(p_font,'B',10); --set back to 10pt plpdf.PrintText(p_indent,p_vertical_offset+6,'Re: '||p_quote_data.site_address(1)||', '||p_quote_data.site_address(2)||', '||p_quote_data.site_address(3)||', '||p_quote_data.site_address(4)||', '||p_quote_data.site_address(5)||', '||p_quote_data.site_address(6)||', '||p_quote_data.site_address(7)); --site address --Base Details plpdf.SetPrintFont(p_font,'BU',12); --set bold,underline and 12pt plpdf.PrintText(p_indent,p_vertical_offset+12,'Floor Area/Base Requirements'); plpdf.SetPrintFont(p_font,null,10); --set back to 10pt plain plpdf.SetCurrentXY(p_indent,p_vertical_offset+25); plpdf.PrintCell(15,6,'Depth:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(1),1,1,'R',0); plpdf.PrintCell(15,6,'Dim A:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(2),1,1,'R',0); plpdf.PrintCell(15,6,'Dim B:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(3),1,1,'R',0); plpdf.PrintCell(15,6,'Dim C:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(4),1,1,'R',0); plpdf.PrintCell(15,6,'Dim D:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(5),1,1,'R',0); plpdf.PrintCell(15,6,'Dim E:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(6),1,1,'R',0); plpdf.PrintCell(15,6,'Dim F:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(7),1,1,'R',0); plpdf.PrintCell(15,6,'Dim G:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(8),1,1,'R',0); plpdf.PrintCell(15,6,'Dim H:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(9),1,1,'R',0); plpdf.PrintCell(15,6,'Dim I:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.base_dimensions(10),1,1,'R',0); --House Details plpdf.SetPrintFont(p_font,'BU',12); --set bold,underline and 12pt plpdf.PrintText(p_indent,p_vertical_offset+100,'Housing / Work Area'); plpdf.SetPrintFont(p_font,null,10); --set back to 10pt plain plpdf.SetCurrentXY(p_indent,p_vertical_offset+108); plpdf.PrintCell(15,6,'Length:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.house_dimensions(1),1,1,'R',0); plpdf.PrintCell(15,6,'Width:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.house_dimensions(2),1,1,'R',0); plpdf.PrintCell(15,6,'Height:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.house_dimensions(3),1,1,'R',0); plpdf.PrintCell(15,6,'Weight:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.house_dimensions(4),1,1,'R',0); --Module details plpdf.SetPrintFont(p_font,'BU',12); --set bold,underline and 12pt plpdf.PrintText(p_indent,p_vertical_offset+168,'Module Dimensions'); plpdf.SetPrintFont(p_font,null,10); --set back to 10pt plain plpdf.SetCurrentXY(p_indent,p_vertical_offset+180); plpdf.PrintCell(15,6,'Dim A:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(1),1,1,'R',0); plpdf.PrintCell(15,6,'Dim B:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(2),1,1,'R',0); plpdf.PrintCell(15,6,'Dim C:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(3),1,1,'R',0); plpdf.PrintCell(15,6,'Dim D:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(4),1,1,'R',0); plpdf.PrintCell(15,6,'Dim E:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(5),1,1,'R',0); plpdf.PrintCell(15,6,'Dim H:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(6),1,1,'R',0); plpdf.PrintCell(15,6,'Dim I:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(7),1,1,'R',0); plpdf.PrintCell(15,6,'Dim O:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(8),1,1,'R',0); plpdf.PrintCell(15,6,'Weight:',1,0,'L',0); plpdf.PrintCell(15,6,p_quote_data.module_dimensions(9),1,1,'R',0); plpdf.SetPrintFont(p_font,null,9); --set to 9pt plpdf.PrintText(p_indent,p_vertical_offset+245,'Note: All weights are in kg and all dimensions in mm Module Ref: '||p_quote_data.module_reference); plpdf.PrintText(p_indent,p_vertical_offset+260,'National Grid Metering, Abbotts Lane, Coventry, West Midlands, CV1 4AY Tel 02476 286000 Fax 02476 286022'); end build_drawings_page; /* PROCEDURE build_module_specs_page --This procedure builds the module specification page for the quotation, it writes data --to an existing plpdf document %param p_quote_data in - The current data for this quote %param p_font - the type of font to use - typically 'Arial'. %param p_indent - the left margin measurement. %param p_vertical_offset - the top margin measurement. */ PROCEDURE build_module_specs_page(p_quote_data in quote_data, p_font in varchar2, p_indent in number, p_vertical_offset in number) is begin --this will be page 5 (part of the technical spec sheet) for the quotation plpdf.NewPage; -- set margins plpdf.SetLeftMargin(31.7); plpdf.SetRightMargin(31.7); plpdf.SetTopMargin(25.4); plpdf.SetPrintFont(p_font,'B',18); --set bold and 18pt plpdf.PrintText(p_indent,p_vertical_offset,'Technical Specification for '||p_quote_data.quote_ref); plpdf.SetPrintFont(p_font,'B',10); --set back to 10pt plpdf.PrintText(p_indent,p_vertical_offset+6,'Re: '||p_quote_data.site_address(1)||', '||p_quote_data.site_address(2)||', '||p_quote_data.site_address(3)||', '||p_quote_data.site_address(4)||', '||p_quote_data.site_address(5)||', '||p_quote_data.site_address(6)||', '||p_quote_data.site_address(7)); --site address plpdf.SetPrintFont(p_font,null,10); --set back to plain plpdf.PrintText(p_indent,p_vertical_offset+14,'The supply point must be of a suitable size and capacity to provide the specified Lowest'); plpdf.PrintText(p_indent,p_vertical_offset+18,'Operating Pressure(LOP-from table1) at the Emergency Control Valve(ECV) outlet'); plpdf.PrintText(p_indent,p_vertical_offset+22,'under the requested Q Max load as detailed below in table 2'); --table 1 plpdf.SetCurrentXY(p_indent,p_vertical_offset+30); plpdf.SetPrintFont(p_font,'B',10); --set to bold plpdf.PrintCell(90,6,'Table 1',1,0,'L',0); plpdf.PrintCell(30,6,'ECV Outlet (u)',1,0,'C',0); plpdf.PrintCell(40,6,'Consumer Outlet (c)',1,1,'C',0); plpdf.SetPrintFont(p_font,null,10); --set back to plain plpdf.PrintCell(90,6,'Design Minimum Pressure (DMP)',1,0,'L',0); plpdf.PrintCell(30,6,'19 mbar',1,0,'C',0); plpdf.PrintCell(40,6,'15 mbar',1,1,'C',0); plpdf.PrintCell(90,6,'Lowest Operating Pressure (LOP)',1,0,'L',0); plpdf.PrintCell(30,6,'25 mbar',1,0,'C',0); plpdf.PrintCell(40,6,'21 mbar',1,1,'C',0); plpdf.PrintCell(90,6,'Pressure Tier',1,0,'L',0); plpdf.PrintCell(30,6,'75 mbar',1,0,'C',0); plpdf.PrintCell(40,6,'21 mbar',1,1,'C',0); --table 2 plpdf.SetCurrentXY(p_indent,p_vertical_offset+60); plpdf.SetPrintFont(p_font,'B',10); --set to bold plpdf.PrintCell(90,6,'Table 2',1,0,'L',0); plpdf.PrintCell(70,6,'Meter Module Design',1,1,'C',0); plpdf.SetPrintFont(p_font,null,10); --set back to plain plpdf.PrintCell(90,6,'Requested Q Max (kw/h)',1,0,'L',0); plpdf.PrintCell(70,6,p_quote_data.requested_qmax,1,1,'C',0); plpdf.PrintCell(90,6,'Q Max of the meter module (kw/h)',1,0,'L',0); plpdf.PrintCell(70,6,p_quote_data.module_qmax,1,1,'C',0); plpdf.PrintCell(90,6,'Q Min of the meter module (kw/h)',1,0,'L',0); plpdf.PrintCell(70,6,p_quote_data.module_qmin,1,1,'C',0); --table 3 plpdf.SetCurrentXY(p_indent,p_vertical_offset+90); plpdf.SetPrintFont(p_font,'B',10); --set to bold plpdf.PrintCell(90,6,'Table 3',1,0,'L',0); plpdf.PrintCell(70,6,'Module Design Parameters',1,1,'C',0); plpdf.SetPrintFont(p_font,null,10); --set back to plain 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 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); plpdf.PrintCell(35,6,'Outlet',1,1,'C',0); plpdf.SetCurrentX(91.7); plpdf.PrintCell(30,6,'Height',1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_inlet_height||'mm',1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_outlet_height||'mm',1,1,'C',0); plpdf.SetCurrentX(91.7); plpdf.PrintCell(30,6,'Size',1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_inlet_size||'mm',1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_outlet_size||'mm',1,1,'C',0); plpdf.SetCurrentX(91.7); plpdf.PrintCell(30,6,'Type',1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_inlet_type||'mm',1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_outlet_type||'mm',1,1,'C',0); plpdf.SetCurrentX(91.7); plpdf.PrintCell(30,6,'Orientation',1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_inlet_orientation,1,0,'C',0); plpdf.PrintCell(35,6,p_quote_data.module_outlet_orientation,1,1,'C',0); plpdf.PrintText(p_indent,p_vertical_offset+134,'The meter module offered is a single stream supply with only a nominal maintenance'); plpdf.PrintText(p_indent,p_vertical_offset+138,'bypass facility. The bypass connections are for use during maintenance, and are only'); plpdf.PrintText(p_indent,p_vertical_offset+142,'sized to maintain gas pressure downstream under no load conditions. Therefore'); plpdf.PrintText(p_indent,p_vertical_offset+146,'during maintenance it will be necessary to disrupt supplies.'); --next para plpdf.PrintText(p_indent,p_vertical_offset+154,'Electric Connections to gas meters are subject to the assesment of the hazardous'); plpdf.PrintText(p_indent,p_vertical_offset+158,'area around the meter, this is largely affected by the ventilation of the housing. Should'); plpdf.PrintText(p_indent,p_vertical_offset+162,'the ventilation be found to be inadequate, the connection will not be made and the'); plpdf.PrintText(p_indent,p_vertical_offset+166,'requirements to allow the connection reported to you. The quotation does not include'); plpdf.PrintText(p_indent,p_vertical_offset+170,'the provision of a separate instrumentation cabinet.'); plpdf.SetPrintFont(p_font,null,7); --set to 7 pt plpdf.PrintText(p_indent,p_vertical_offset+178,'Definitions'); plpdf.PrintText(p_indent,p_vertical_offset+182,'DMP - The minimum pressure that may occur at the point of reference at the time of system design flow rate under extreme gas supply conditions'); plpdf.PrintText(p_indent,p_vertical_offset+186,'LOP - The lowest pressure that may occur under normal operating conditions'); plpdf.PrintText(p_indent,p_vertical_offset+190,'Conversion calculations are based on an average CV of 38.4 MJ/m3'); plpdf.SetPrintFont(p_font,null,9); --set to 9 pt plpdf.PrintText(p_indent,p_vertical_offset+260,'National Grid Metering, Abbotts Lane, Coventry, West Midlands, CV1 4AY Tel 02476 286000 Fax 02476 286022'); end build_module_specs_page; /* PROCEDURE build_acceptance_page --This procedure builds the acceptance form page for the quotation, it writes data --to an existing plpdf document %param p_quote_data in - The current data for this quote %param p_font - the type of font to use - typically 'Arial'. %param p_indent - the left margin measurement. %param p_vertical_offset - the top margin measurement. %param p_logo_blob - the logo(image) to display at the top of the page */ PROCEDURE build_acceptance_page(p_quote_data in quote_data, p_font in varchar2, p_indent in number, p_vertical_offset in number,p_logo_blob blob) is begin ---weeeeee last page plpdf.NewPage; -- set margins plpdf.SetLeftMargin(31.7); plpdf.SetRightMargin(31.7); plpdf.SetTopMargin(25.4); -- Set header stuff up plpdf.PutImage('ngmlogo',p_logo_blob,p_indent,10,52,18); plpdf.SetPrintFont(p_font,null,7); plpdf.PrintText(140,10,'4 Abbotts Lane '); plpdf.PrintText(140,13,'Coventry'); plpdf.PrintText(140,16,'CV1 4AY'); plpdf.PrintText(170,10,'T +44 (0) 24 7628 6000'); plpdf.PrintText(170,13,'F +44 (0) 24 7628 6022'); plpdf.PrintText(170,16,'www.nationalgrid.com'); -- And Footer stuff plpdf.PrintText(50,280,'National Grid Metering is the trading name for National Grid Metering Ltd.'); 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); -- big text please plpdf.PrintText(p_indent,p_vertical_offset+10,'National Grid Metering''s Ref: '|| to_char(p_quote_data.quote_ref)); plpdf.PrintText(p_indent,p_vertical_offset+14,'Customer Reference: '|| p_quote_data.transaction_ref); plpdf.PrintText(p_indent,p_vertical_offset+18,'MPRN: '|| to_char(p_quote_data.mprn)); plpdf.PrintText(p_indent,p_vertical_offset+26,'F.A.O'); plpdf.PrintText(p_indent,p_vertical_offset+30,'I&C Work Planning Team'); plpdf.PrintText(p_indent,p_vertical_offset+34,'National Grid Metering Ltd'); plpdf.PrintText(p_indent,p_vertical_offset+38,'Abbott''s Lane'); plpdf.PrintText(p_indent,p_vertical_offset+42,'Coventry'); plpdf.PrintText(p_indent,p_vertical_offset+46,'CV1 4AY'); plpdf.SetPrintFont(p_font,'B',10); --set bold plpdf.PrintText(p_indent,p_vertical_offset+54,'Re: '||p_quote_data.site_address(1)||', '||p_quote_data.site_address(2)||', '||p_quote_data.site_address(3)||', '||p_quote_data.site_address(4)||', '||p_quote_data.site_address(5)||', '||p_quote_data.site_address(6)||', '||p_quote_data.site_address(7)); --site address plpdf.SetPrintFont(p_font,null,10); --unset bold 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,'£'||p_quote_data.total_cost||' excluding lifting gear if required.'); 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'); plpdf.PrintText(p_indent,p_vertical_offset+82,'terms and conditions (other than those set out in the quotation) are required.'); plpdf.PrintText(p_indent,p_vertical_offset+90,'OR'); plpdf.PrintText(p_indent,p_vertical_offset+98,'* I confirm on behalf of my Company that the above referenced quotation for the conduct or works'); plpdf.PrintText(p_indent,p_vertical_offset+102,'as detailed therein is acceptable to my Company provided that (in addition to the conditions set'); plpdf.PrintText(p_indent,p_vertical_offset+106,'out in the quotation [if any]) the General Conditions of Contract for Transactional Meter Works'); plpdf.PrintText(p_indent,p_vertical_offset+110,'Not Exceeding 7 Bar in respect of the works are modified by the incorporation of the terms and'); plpdf.PrintText(p_indent,p_vertical_offset+114,'conditions annexed hereto.'); plpdf.PrintText(p_indent,p_vertical_offset+122,'(* Delete as appropriate)'); plpdf.PrintText(p_indent,p_vertical_offset+130,'Save as set out above, I confirm that my Company agrees to be bound in connection with the'); plpdf.PrintText(p_indent,p_vertical_offset+134,'works by the General Conditions of Contract for Transactional Meter Works Not'); plpdf.PrintText(p_indent,p_vertical_offset+138,'Exceeding 7 Bar (as ammended by the quotation).'); plpdf.PrintText(p_indent,p_vertical_offset+146,'Commencement'); plpdf.PrintText(p_indent,p_vertical_offset+154,'Permission to organise directly with site contact'); plpdf.PrintText(p_indent+120,p_vertical_offset+154,'Yes / No'); plpdf.PrintText(p_indent,p_vertical_offset+162,'Earliest date site ready for work to commence'); plpdf.PrintText(p_indent+120,p_vertical_offset+162,'___/___/___'); plpdf.PrintText(p_indent,p_vertical_offset+170,'Anticipated date gas required on site'); plpdf.PrintText(p_indent+120,p_vertical_offset+170,'___/___/___'); plpdf.PrintText(p_indent,p_vertical_offset+178,'Signed on behalf of the Company'); plpdf.PrintText(p_indent,p_vertical_offset+186,'Name:________________________________'); plpdf.PrintText(p_indent+85,p_vertical_offset+186,'Position:____________________________'); plpdf.PrintText(p_indent,p_vertical_offset+194,'Company:_____________________________'); plpdf.PrintText(p_indent+85,p_vertical_offset+194,'Date:_______________________________'); plpdf.PrintText(p_indent,p_vertical_offset+202,'Signature:_____________________________________________________________________'); end build_acceptance_page; /* FUNCTION generate_detailed_quote_pdf --The generate_detailed_quote_pdf builds the pdf document for the quotation from --the supplied data and stores the resulting pdf document in the database. %param p_quote_data - the data to build into the quote. %return - l_pdf_id the id of the pdf file we have created */ FUNCTION generate_detailed_quote_pdf(p_quote_data in quote_data) RETURN NUMBER is l_blob blob; l_logo_blob blob; l_signature_blob blob; l_pdf_id number; -- 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 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; 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; -- Initialize PDF 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_caveats_page(p_quote_data,l_font,l_indent,l_vertical_offset); --3 build_drawings_page(p_quote_data,l_font,l_indent,l_vertical_offset); --4 build_module_specs_page(p_quote_data,l_font,l_indent,l_vertical_offset); --5 build_acceptance_page(p_quote_data,l_font,l_indent,l_vertical_offset,l_logo_blob); --6 --get our beautiful pdf into the local var l_blob plpdf.SendDoc(l_blob); --punt the created pdf into the APEX files table insert into wwv_flow_files( name, filename, title, mime_type, flow_id, doc_size ,description, blob_content ) values (TO_CHAR(SYSDATE,'SSSSS')||'/quote',p_quote_data.quote_ref||'_quote.pdf', 'Quotation - '||p_quote_data.quote_ref, 'application/pdf', 190, DBMS_LOB.GETLENGTH(l_blob),'this is an auto generated quotation from mip_quotation_document.generate_detailed_quote for quotation '||p_quote_data.quote_ref, l_blob) returning id into l_pdf_id; return l_pdf_id; -- return the id of the newly created blob pdf record end generate_detailed_quote_pdf; BEGIN -- Initialization NULL; END mip_quotation_document; /