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='East Sussex' ORDER BY q.id DESCArray
(
[0] => Array
(
[id] => 4011
[ref] => BN27HL-MIN-4011
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Russell Minton
[address] => A Park Rd, Rottingdean, Brighton
[service_place] => Brighton
[region] => East Sussex
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 3994
[ref] => BN33EN-FOX-3994
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Jessica Fox
[address] => Lorna Rd, Brighton And Hove, Brighton And Hove
[service_place] => Brighton And Hove
[region] => East Sussex
[user] => DSI Services (Reports)
)
[2] => Array
(
[id] => 3864
[ref] => BN228BT-HAR-3864
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Dylan Harris
[address] => New Rd, Eastbourne
[service_place] => Eastbourne
[region] => East Sussex
[user] => DSI Services (Reports)
)
[3] => Array
(
[id] => 3109
[ref] => TN376QT-HAR-3109
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Abigal Harrison
[address] => Alma Terrace Hastings
[service_place] => Hastings
[region] => East Sussex
[user] => DSI Services (Reports)
)
[4] => Array
(
[id] => 2637
[ref] => BN16JS-SPE-2637
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Yvonne Spencer
[address] => Hythe Rd Brighton
[service_place] => Brighton
[region] => East Sussex
[user] => Mayowa Olaleye Surveyor
)
[5] => Array
(
[id] => 2604
[ref] => BN18YG-CAR-2604
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => Single level building
[job_type] => 13
[job_status] => Completed
[customer_name] => Richard Carr
[address] => Court Close Brighton And Hove
[service_place] => Brighton And Hove
[region] => East Sussex
[user] => DSI Services (Reports)
)
[6] => Array
(
[id] => 2245
[ref] => BN424NW-ORT-2245
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Elisa Ortiz
[address] => Manor Cl, Southwick Brighton
[service_place] => Brighton
[region] => East Sussex
[user] => Mayowa Olaleye Surveyor
)
[7] => Array
(
[id] => 2240
[ref] => BN29UP-PRI-2240
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Dave Price
[address] => Ewart St Brighton
[service_place] => Brighton
[region] => East Sussex
[user] => Mayowa Olaleye Surveyor
)
[8] => Array
(
[id] => 2049
[ref] => BN23PD-AND-2049
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Helen Anderson
[address] => Brading Rd Brighton
[service_place] => Brighton
[region] => East Sussex
[user] => DSI Services (Reports)
)
)
East-Sussex - Sharpsbridge - East Sussex
3 bedrooms/3 storeys - A Park Rd, Rottingdean, Brighton
Inspection: Pre-Purchase Roof Inspections
East-Sussex - Sharpsbridge - East Sussex
4 bedrooms/3 storeys - Lorna Rd, Brighton And Hove, Brighton And Hove
Inspection: Pre-Purchase Roof Inspections
East-Sussex - Sharpsbridge - East Sussex
2 bedrooms/2 storeys - New Rd, Eastbourne
Inspection: Pre-Purchase Roof Inspections