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='Somerset' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Sharpstone - Somerset
[region] => Somerset
)
Array
(
[0] => Array
(
[id] => 4053
[ref] => BA23NN-AND-4053
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Lucy Anderson
[address] => Second Ave, Bath
[service_place] => Bath
[region] => Somerset
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 3974
[ref] => BS216TN-JEN-3974
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 5 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Heather Jenkins
[address] => Coxhay Kenn Street Kenn Clevedon
[service_place] => Clevedon
[region] => Somerset
[user] => Mayowa Olaleye Surveyor
)
[2] => Array
(
[id] => 3447
[ref] => TA65ET-IER-3447
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Ilie Ieremie
[address] => Edward St, Bridgwater
[service_place] => Bridgwater
[region] => Somerset
[user] => DSI Services (Reports)
)
[3] => Array
(
[id] => 3116
[ref] => BA34NZ-FRE-3116
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 5 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Sally Freeman
[address] => Heartfelt Homes - Greendown House Chewton Mendip, Radstock
[service_place] => Radstock
[region] => Somerset
[user] => Mayowa Olaleye Surveyor
)
[4] => Array
(
[id] => 2757
[ref] => BA20LN-MID-2757
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => James Midgely
[address] => Bloomfield Park Rd, Timsbury, Bath
[service_place] => Bath
[region] => Somerset
[user] => DSI Services (Reports)
)
[5] => Array
(
[id] => 2577
[ref] => BA213JS-PRI-2577
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Anne Priscott
[address] => Cedar Grove, Yeovil Yeovil
[service_place] => Yeovil
[region] => Somerset
[user] => Mayowa Olaleye Surveyor
)
)
Somerset - Sharpstone - Somerset
4 bedrooms/2 storeys - Second Ave, Bath
Inspection: Pre-Purchase Roof Inspections
Somerset - Sharpstone - Somerset
5 bedrooms/2 storeys - Coxhay Kenn Street Kenn Clevedon
Inspection: Pre-Purchase Roof Inspections
Somerset - Sharpstone - Somerset
4 bedrooms/2 storeys - Edward St, Bridgwater
Inspection: Pre-Purchase Roof Inspections