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='Essex' ORDER BY q.id DESCArray
(
[0] => Array
(
[id] => 3815
[ref] => CM07EZ-TAY-3815
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Brian Taylor
[address] => Maple Villas The Chase, Burnham Rd, Southminster
[service_place] => Southminster
[region] => Essex
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 3132
[ref] => CO45RY-CLA-3132
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Ian Claydon
[address] => Axial Drive, Colchester
[service_place] => Colchester
[region] => Essex
[user] => DSI Services (Reports)
)
[2] => Array
(
[id] => 3014
[ref] => CM11DB-SAM-3014
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Large Commercial
[roof_height] => Other
[job_type] => 13
[job_status] => Completed
[customer_name] => Louise Samuel
[address] => Eagle House 59 Waterloo Lane Chelmsford
[service_place] => Chelmsford
[region] => Essex
[user] => Mayowa Olaleye Surveyor
)
[3] => Array
(
[id] => 2548
[ref] => CO12PY-MEA-2548
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Richard Mea
[address] => Priory St, Colchester
[service_place] => Colchester
[region] => Essex
[user] => Mayowa Olaleye Surveyor
)
[4] => Array
(
[id] => 2443
[ref] => IG76HU-CHE-2443
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => May Cheuk
[address] => Rowland Cres, Chigwell
[service_place] => Chigwell
[region] => Essex
[user] => DSI Services (Reports)
)
[5] => Array
(
[id] => 2367
[ref] => CO59TR-MUR-2367
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Dean Murray
[address] => Yew Tree Cottage The Street Messing
[service_place] => Messing
[region] => Essex
[user] => DSI Services (Reports)
)
[6] => Array
(
[id] => 2076
[ref] => CO43UN-FRA-2076
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Edward Fraser French
[address] => Britten Close Colchester
[service_place] => Colchester
[region] => Essex
[user] => DSI Services (Reports)
)
[7] => Array
(
[id] => 2025
[ref] => CO124RE-RIC-2025
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => Single level building
[job_type] => 13
[job_status] => Completed
[customer_name] => Pauline Richardson
[address] => Beryl Rd, Harwich
[service_place] => Harwich
[region] => Essex
[user] => Mayowa Olaleye Surveyor
)
)
Essex - Sewards End - Essex
4 bedrooms/2 storeys - Maple Villas The Chase, Burnham Rd, Southminster
Inspection: Pre-Purchase Roof Inspections
Essex - Sewards End - Essex
4 bedrooms/2 storeys - Axial Drive, Colchester
Inspection: Pre-Purchase Roof Inspections
Essex - Sewards End - Essex
Large Commercial/Other - Eagle House 59 Waterloo Lane Chelmsford
Inspection: Pre-Purchase Roof Inspections