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='Lancashire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Sharneyford - Lancashire
[region] => Lancashire
)
Array
(
[0] => Array
(
[id] => 3712
[ref] => BB16EA-AML-3712
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Small Commercial
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Osment Amla
[address] => Whalley Range, Blackburn
[service_place] => Blackburn
[region] => Lancashire
[user] => Mayowa Olaleye Surveyor
)
[1] => Array
(
[id] => 3237
[ref] => BB126QD-BIR-3237
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Katheline Birch
[address] => Gannow Ln, Burnley
[service_place] => Burnley
[region] => Lancashire
[user] => DSI Services (Reports)
)
[2] => Array
(
[id] => 3234
[ref] => BB104AS-PRO-3234
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Neil Proctor
[address] => Dawson Drive Burnley
[service_place] => Burnley
[region] => Lancashire
[user] => Mayowa Olaleye Surveyor
)
[3] => Array
(
[id] => 3170
[ref] => WN59BY-BUL-3170
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Kara Bulpitt
[address] => Mitchell St, Newtown, Wigan
[service_place] => Wigan
[region] => Lancashire
[user] => DSI Services (Reports)
)
[4] => Array
(
[id] => 2785
[ref] => OL102BZ-AIN-2785
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Mr Ainsworth
[address] => 2 Gleneagles Ave, Heywood
[service_place] => Heywood
[region] => Lancashire
[user] => DSI Services (Reports)
)
[5] => Array
(
[id] => 2680
[ref] => LA13DQ-BUR-2680
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Dillan Burkatch
[address] => Dunkeld St, Lancaster
[service_place] => Lancaster
[region] => Lancashire
[user] => Mayowa Olaleye Surveyor
)
[6] => Array
(
[id] => 2392
[ref] => FY77BD-WEL-2392
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Damion Weller
[address] => GALLOWAY ROAD Fleetwood
[service_place] => Fleetwood
[region] => Lancashire
[user] => DSI Services (Reports)
)
[7] => Array
(
[id] => 2068
[ref] => BB11NT-JAN-2068
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Imran Jangda
[address] => Cherry St Blackburn
[service_place] => Blackburn
[region] => Lancashire
[user] => Mayowa Olaleye Surveyor
)
)
Lancashire - Sharneyford - Lancashire
Small Commercial/3 storeys - Whalley Range, Blackburn
Inspection: Pre-Purchase Roof Inspections
Lancashire - Sharneyford - Lancashire
Medium Commercial/2 storeys - Gannow Ln, Burnley
Inspection: Pre-Purchase Roof Inspections
Lancashire - Sharneyford - Lancashire
4 bedrooms/2 storeys - Dawson Drive Burnley
Inspection: Pre-Purchase Roof Inspections