rendered paste body [query] => SELECT DISTINCT i.invoice_id, i.strata_id, i.status_code, i.opened_by, i.date_opened, i.date_closed, i.internal_description, i.service_notes, i.office_code, i.office_notes, i.workloc_name, i.workloc_unit, i.workloc_address, i.workloc_phone, i.workloc_email, z.date_started, z.date_completed, s.corp AS strata_corp, s.name AS strata_name, s.address AS strata_address, s.city AS strata_city, s.province AS strata_province, s.postal AS strata_postal, b.name AS billto_name, b.unit AS billto_unit, b.address AS billto_address, b.city AS billto_city, b.province AS billto_province, b.postal AS billto_postal, b.country AS billto_country, b.phone AS billto_phone, b.email AS billto_email, e.name service_person, ii.qty item_qty, ii.code item_code, ii.name item_name, ii.description item_description, ii.price item_price, ii.date_started item_date_started, ii.date_completed item_date_completed FROM invoices i LEFT JOIN invoice_billto b USING (invoice_id) LEFT JOIN stratas s USING (strata_id) LEFT JOIN invoice_status_codes c USING (status_code) LEFT JOIN invoice_service_persons sp USING (invoice_id) LEFT JOIN employees e USING (employee_id) LEFT JOIN ( (SELECT invoice_id, min(date_started) date_started, max(date_completed) date_completed FROM invoice_items z GROUP BY invoice_id) z) USING (invoice_id) LEFT JOIN invoice_items ii USING (invoice_id) WHERE i.invoice_id = 1002 [row] => Array ( [0] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Hilton Janfield [item_qty] => 1 [item_code] => MONTHLY [item_name] => Monthly Fire Safety Equipment Test [item_description] => Regular monthly check of all fire related systems as per contract.- Fire Extinguishers: PASS- Fire Alarm System: PASS- Emergency Lighting Systems: PASS (after repairs, noted below)- Exit Signage: PASS- Fire Doors: PASS- Other Systems: PASSNo other deficiencies noted. [item_price] => -999 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) [1] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Hilton Janfield [item_qty] => 2 [item_code] => FIRE-ROD [item_name] => Glass Rods for Fire Pull Stations [item_description] => Two spare pull station rods placed inside the fire panel. [item_price] => 4 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) [2] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Hilton Janfield [item_qty] => 0.5 [item_code] => NO-CHARGE [item_name] => Replace E/L Bulbs [item_description] => Found two dead E/L bulbs, both at the lobby level of the north stairwell. Replaced. [item_price] => 0 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) [3] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Hilton Janfield [item_qty] => 2 [item_code] => EL-BULB-915 [item_name] => #915 12v Emergency Lighting Bulb [item_description] => [item_price] => 1.5 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) [4] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Gerry Rooyakkers [item_qty] => 1 [item_code] => MONTHLY [item_name] => Monthly Fire Safety Equipment Test [item_description] => Regular monthly check of all fire related systems as per contract.- Fire Extinguishers: PASS- Fire Alarm System: PASS- Emergency Lighting Systems: PASS (after repairs, noted below)- Exit Signage: PASS- Fire Doors: PASS- Other Systems: PASSNo other deficiencies noted. [item_price] => -999 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) [5] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Gerry Rooyakkers [item_qty] => 2 [item_code] => FIRE-ROD [item_name] => Glass Rods for Fire Pull Stations [item_description] => Two spare pull station rods placed inside the fire panel. [item_price] => 4 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) [6] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Gerry Rooyakkers [item_qty] => 0.5 [item_code] => NO-CHARGE [item_name] => Replace E/L Bulbs [item_description] => Found two dead E/L bulbs, both at the lobby level of the north stairwell. Replaced. [item_price] => 0 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) [7] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Gerry Rooyakkers [item_qty] => 2 [item_code] => EL-BULB-915 [item_name] => #915 12v Emergency Lighting Bulb [item_description] => [item_price] => 1.5 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 ) ) [result] => Array ( [invoice_id] => 1002 [strata_id] => 3122 [status_code] => Z [opened_by] => hilton [date_opened] => 2011-12-29 [date_closed] => [internal_description] => December 2011 Fire Safety Check [service_notes] => [office_code] => [office_notes] => [workloc_name] => Strata [workloc_unit] => [workloc_address] => [workloc_phone] => [workloc_email] => [date_started] => 2011-12-29 [date_completed] => 2011-12-29 [strata_corp] => KAS3122 [strata_name] => Asher Place [strata_address] => 140 Asher Road [strata_city] => Kelowna [strata_province] => BC [strata_postal] => V1X 3H6 [billto_name] => [billto_unit] => [billto_address] => [billto_city] => [billto_province] => [billto_postal] => [billto_country] => [billto_phone] => [billto_email] => [service_person] => Hilton Janfield [item_qty] => 1 [item_code] => MONTHLY [item_name] => Monthly Fire Safety Equipment Test [item_description] => Regular monthly check of all fire related systems as per contract.- Fire Extinguishers: PASS- Fire Alarm System: PASS- Emergency Lighting Systems: PASS (after repairs, noted below)- Exit Signage: PASS- Fire Doors: PASS- Other Systems: PASSNo other deficiencies noted. [item_price] => -999 [item_date_started] => 2011-12-29 [item_date_completed] => 2011-12-29 )