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='North Yorkshire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Seph - North Yorkshire
[region] => North-Yorkshire
)
Array
(
[0] => Array
(
[id] => 4139
[ref] => YO306EN-BRY-4139
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Paul - Steve Bryce
[address] => Ratcliffe St, York
[service_place] => York
[region] => North Yorkshire
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 3652
[ref] => YO233US-DEA-3652
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Heather Deane
[address] => College Rd, Copmanthorpe, York
[service_place] => York
[region] => North Yorkshire
[user] => DSI Services (Reports)
)
[2] => Array
(
[id] => 3445
[ref] => YO127TR-MAY-3445
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Sarah Mayrose
[address] => Victoria Park Ave Scarborough
[service_place] => Scarborough
[region] => North Yorkshire
[user] => DSI Services (Reports)
)
[3] => Array
(
[id] => 3321
[ref] => HG43BY-PHI-3321
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => Single level building
[job_type] => 13
[job_status] => Completed
[customer_name] => Trevor Philips
[address] => Magaill Grewelthorpe Ripon
[service_place] => Ripon
[region] => North Yorkshire
[user] => DSI Services (Reports)
)
[4] => Array
(
[id] => 3082
[ref] => HG20AQ-FOX-3082
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Joseph Fox
[address] => 20 College Rd, Harrogate
[service_place] => Harrogate
[region] => North Yorkshire
[user] => DSI Services (Reports)
)
[5] => Array
(
[id] => 2718
[ref] => HG15HJ-MAT-2718
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Large Commercial
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Jacqueline Matthews
[address] => Ascot House Hotel 53 Kings Road Harrogate
[service_place] => Harrogate
[region] => North Yorkshire
[user] => DSI Services (Reports)
)
[6] => Array
(
[id] => 2594
[ref] => YO306DT-VEN-2594
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Paul Ventress
[address] => 4 Surtees St, Clifton, York
[service_place] => York
[region] => North Yorkshire
[user] => DSI Services (Reports)
)
[7] => Array
(
[id] => 2525
[ref] => YO324AS-FOS-2525
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Liz Foster
[address] => 1 Hawthorn Terrace N, New Earswick, York
[service_place] => York
[region] => North Yorkshire
[user] => Mayowa Olaleye Surveyor
)
)
North-Yorkshire - Seph - North Yorkshire
2 bedrooms/2 storeys - Ratcliffe St, York
Inspection: Pre-Purchase Roof Inspections
North-Yorkshire - Seph - North Yorkshire
3 bedrooms/2 storeys - College Rd, Copmanthorpe, York
Inspection: Pre-Purchase Roof Inspections
North-Yorkshire - Seph - North Yorkshire
4 bedrooms/3 storeys - Victoria Park Ave Scarborough
Inspection: Pre-Purchase Roof Inspections