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='Derbyshire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Shatton - Derbyshire
[region] => Derbyshire
)
Array
(
[0] => Array
(
[id] => 3788
[ref] => DE248HY-EST-3788
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Large Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Adam Estella
[address] => Tentamus-Pharma UK, Orbis 3 Building, Derby
[service_place] => Derby
[region] => Derbyshire
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 3644
[ref] => DE53EF-WES-3644
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Helen Weston
[address] => Derbyshire Carers Association 3 Park Road Ripley
[service_place] => Ripley
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[2] => Array
(
[id] => 3533
[ref] => DE30EP-LEI-3533
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Keiran Leivers
[address] => Fenton Rd, Mickleover, Derby
[service_place] => Derby
[region] => Derbyshire
[user] => DSI Services (Reports)
)
[3] => Array
(
[id] => 3244
[ref] => CO105HZ-LAK-3244
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 6 Bedroom and above
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Harsha Lakshman
[address] => Orchard House Roylands Lane Sudbury
[service_place] => Sudbury
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[4] => Array
(
[id] => 2882
[ref] => DE30TQ-LIN-2882
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Meghan Linscott
[address] => Cromer Close Mickleover, Derby
[service_place] => Derby
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[5] => Array
(
[id] => 2456
[ref] => S419LN-MOS-2456
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Lewis Moss
[address] => Brearley St Old Whittington Chesterfield
[service_place] => Chesterfield
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[6] => Array
(
[id] => 2327
[ref] => DE45FR-FRA-2327
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Andrew Fraser
[address] => Brookside Cottages, Tansley
[service_place] => Tansley
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[7] => Array
(
[id] => 2292
[ref] => DE221AH-ROB-2292
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Michael Roberson
[address] => No 149 Duffield Rd, Darley Abbey, Derby
[service_place] => Derby
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[8] => Array
(
[id] => 2253
[ref] => S425JA-BAR-2253
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Lisa Barnett
[address] => No53 Knighton Street North Wingfield Chesterfield
[service_place] => Chesterfield
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[9] => Array
(
[id] => 2233
[ref] => DE248QR-CLA-2233
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => John C/O Alten Derby
[address] => Alten 3 Pride Place Derby
[service_place] => Derby
[region] => Derbyshire
[user] => Mayowa Olaleye Surveyor
)
[10] => Array
(
[id] => 2112
[ref] => S458HT-WRI-2112
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Neil Wright
[address] => Queensway, Pilsley Chesterfield
[service_place] => Chesterfield
[region] => Derbyshire
[user] => DSI Services (Reports)
)
)
Derbyshire - Shatton - Derbyshire
Large Commercial/2 storeys - Tentamus-Pharma UK, Orbis 3 Building, Derby
Inspection: Pre-Purchase Roof Inspections
Derbyshire - Shatton - Derbyshire
Medium Commercial/3 storeys - Derbyshire Carers Association 3 Park Road Ripley
Inspection: Pre-Purchase Roof Inspections
Derbyshire - Shatton - Derbyshire
3 bedrooms/2 storeys - Fenton Rd, Mickleover, Derby
Inspection: Pre-Purchase Roof Inspections