SELECT
q.id,
q.ref,
q.job_desc,
q.roof_size,
q.roof_height,
q.job_type,
(SELECT status
FROM tracker_quote_status
WHERE id = q.quote_status) AS job_status,
CONCAT(c.fname, ' ', c.sname) AS customer_name,
TRIM(REGEXP_REPLACE(
CASE
WHEN q.existing = 0 THEN
CONCAT_WS(' ', c.street, c.street2, c.town, c.county)
ELSE
CONCAT_WS(' ', q.street, q.street2, q.town, q.county)
END,
'^[0-9]+\s*',
''
)) AS address,
CASE
WHEN q.existing = 0 THEN c.town
ELSE q.town
END AS service_place,
CASE
WHEN q.existing = 0 THEN
(SELECT region FROM places_uk WHERE place = c.town LIMIT 1)
ELSE
(SELECT region FROM places_uk WHERE place = q.town LIMIT 1)
END AS region,
CASE
WHEN JSON_CONTAINS(q.rooferID, '417') THEN 'Mayowa Olaleye Surveyor'
WHEN JSON_CONTAINS(q.rooferID, '428') THEN 'DSI Services (Reports)'
ELSE ''
END AS user
FROM tracker_quotes q
INNER JOIN tracker_customers c
ON q.customerID = c.id
WHERE
(
JSON_CONTAINS(q.rooferID, '417')
OR JSON_CONTAINS(q.rooferID, '428')
)
AND q.deleted_at IS NULL
AND q.job_type IN (13,36)
AND q.quote_status=4 HAVING region='Hampshire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Setley - Hampshire
[region] => Hampshire
)
Array
(
[0] => Array
(
[id] => 3797
[ref] => SP103EH-GAL-3797
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => John Gallagher
[address] => Bishops Way Andover
[service_place] => Andover
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
[1] => Array
(
[id] => 3343
[ref] => PO122UP-COU-3343
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Porch or outbuilding
[roof_height] => Other
[job_type] => 13
[job_status] => Completed
[customer_name] => Gareth Cousins
[address] => Long Water Dr, Gosport
[service_place] => Gosport
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
[2] => Array
(
[id] => 3271
[ref] => PO76SU-BAN-3271
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Andy Banting
[address] => 6 Creech View Denmead Waterlooville
[service_place] => Waterlooville
[region] => Hampshire
[user] => DSI Services (Reports)
)
[3] => Array
(
[id] => 3210
[ref] => SO181BE-BUR-3210
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Adam Burt
[address] => Bitterne Rd W, Southampton
[service_place] => Southampton
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
[4] => Array
(
[id] => 3180
[ref] => PO51QY-RIC-3180
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Chris Rich
[address] => Outram Rd, Southsea, , Southsea, Portsmouth
[service_place] => Portsmouth
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
[5] => Array
(
[id] => 3084
[ref] => SO192FT-PHI-3084
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => David Phillips
[address] => Leighton Rd, Southampton
[service_place] => Southampton
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
[6] => Array
(
[id] => 2743
[ref] => SO316NN-CHA-2743
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Heather Chandos-adams
[address] => 20 Summerfields, Locks Heath, Park Gate, Southampton
[service_place] => Southampton
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
[7] => Array
(
[id] => 2635
[ref] => SO172GS-CAR-2635
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Flats
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Phil Caraher
[address] => a Thackeray Rd, Southampton
[service_place] => Southampton
[region] => Hampshire
[user] => DSI Services (Reports)
)
[8] => Array
(
[id] => 2527
[ref] => SO152JY-REE-2527
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Flats
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Kerry Reece
[address] => Hilder Court Hulse Road Southampton
[service_place] => Southampton
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
[9] => Array
(
[id] => 2101
[ref] => PO61NE-BUR-2101
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Emily Burn
[address] => Alexander Rose Care Home 358 Havant Rd, Farlington, Portsmouth
[service_place] => Portsmouth
[region] => Hampshire
[user] => Mayowa Olaleye Surveyor
)
)
Hampshire - Setley - Hampshire
3 bedrooms/2 storeys - Bishops Way Andover
Inspection: Pre-Purchase Roof Inspections
Hampshire - Setley - Hampshire
Porch or outbuilding/Other - Long Water Dr, Gosport
Inspection: Pre-Purchase Roof Inspections
Hampshire - Setley - Hampshire
4 bedrooms/2 storeys - 6 Creech View Denmead Waterlooville
Inspection: Pre-Purchase Roof Inspections