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='Shropshire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Severn - Shropshire
[region] => Shropshire
)
Array
(
[0] => Array
(
[id] => 2983
[ref] => SY38AD-ALE-2983
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Michael Alexander
[address] => Oakfield Rd Shrewsbury
[service_place] => Shrewsbury
[region] => Shropshire
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 2976
[ref] => TF33BL-MOO-2976
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Large Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Anne Moore
[address] => Schneider Electric, Stafford Park 5, Telford
[service_place] => Telford
[region] => Shropshire
[user] => Mayowa Olaleye Surveyor
)
[2] => Array
(
[id] => 2826
[ref] => TF31UE-VAU-2826
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Gary Vaughan
[address] => Castlecroft Stirchley Telford
[service_place] => Telford
[region] => Shropshire
[user] => DSI Services (Reports)
)
[3] => Array
(
[id] => 2746
[ref] => TF13NU-DON-2746
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Ash Donnelly
[address] => Stokesay Rd, Wellington, Telford
[service_place] => Telford
[region] => Shropshire
[user] => Mayowa Olaleye Surveyor
)
[4] => Array
(
[id] => 2357
[ref] => SY45UZ-STE-2357
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Daniel Stevens
[address] => Hawkston Cottage Weston Shrewsbury
[service_place] => Shrewsbury
[region] => Shropshire
[user] => DSI Services (Reports)
)
)
Shropshire - Severn - Shropshire
3 bedrooms/2 storeys - Oakfield Rd Shrewsbury
Inspection: Pre-Purchase Roof Inspections
Shropshire - Severn - Shropshire
Large Commercial/2 storeys - Schneider Electric, Stafford Park 5, Telford
Inspection: Pre-Purchase Roof Inspections
Shropshire - Severn - Shropshire
3 bedrooms/2 storeys - Castlecroft Stirchley Telford
Inspection: Pre-Purchase Roof Inspections