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='Gloucestershire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Sevenhampton - Gloucestershire
[region] => Gloucestershire
)
Array
(
[0] => Array
(
[id] => 3995
[ref] => S704SY-HAR-3995
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Cory Harding
[address] => a Station Rd, Worsbrough, Barnsley
[service_place] => Barnsley
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 3951
[ref] => SN34AD-CAL-3951
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => Single level building
[job_type] => 13
[job_status] => Completed
[customer_name] => Terry Callaghan
[address] => Constantine Close Swindon
[service_place] => Swindon
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[2] => Array
(
[id] => 3517
[ref] => GL502TT-LAN-3517
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Eleanor Lane
[address] => Hatherley St, Cheltenham
[service_place] => Cheltenham
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[3] => Array
(
[id] => 3423
[ref] => GL44DD-HEN-3423
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Emma Hensley
[address] => Painswick Rd, Matson, Abbeydale, Gloucester
[service_place] => Gloucester
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[4] => Array
(
[id] => 3386
[ref] => S755PF-SYK-3386
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Kat Sykes
[address] => Meadow Lane, Darton, Barnsley
[service_place] => Barnsley
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[5] => Array
(
[id] => 3378
[ref] => GL539NP-CHA-3378
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 6 Bedroom and above
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Chris Chatterton
[address] => The Tree House, Colesbourne, Cheltenham
[service_place] => Cheltenham
[region] => Gloucestershire
[user] => Mayowa Olaleye Surveyor
)
[6] => Array
(
[id] => 3312
[ref] => GL529HU-FRY-3312
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Joel Fryer
[address] => Greenway Woodmancote Cheltenham
[service_place] => Cheltenham
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[7] => Array
(
[id] => 3074
[ref] => SN36GB-GUR-3074
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Ajaya Kumar Gurung
[address] => Cottles Close Coate, Swindon
[service_place] => Swindon
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[8] => Array
(
[id] => 2610
[ref] => S756EG-OCA-2610
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Andrew OCallaghan
[address] => 2 Kingsway Mapplewell, Barnsley
[service_place] => Barnsley
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[9] => Array
(
[id] => 2581
[ref] => GL503BB-KNA-2581
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 6 Bedroom and above
[roof_height] => Other
[job_type] => 13
[job_status] => Completed
[customer_name] => Bonnie Knapp
[address] => Queens Parade Cheltenham
[service_place] => Cheltenham
[region] => Gloucestershire
[user] => Mayowa Olaleye Surveyor
)
[10] => Array
(
[id] => 2177
[ref] => GL28AA-PEA-2177
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 6 Bedroom and above
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Matthew Pearce
[address] => Edgewood House Churcham Gloucester
[service_place] => Gloucester
[region] => Gloucestershire
[user] => DSI Services (Reports)
)
[11] => Array
(
[id] => 2167
[ref] => SN67EB-ROW-2167
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Nicola Rowen
[address] => Windrush Highworth Swindon
[service_place] => Swindon
[region] => Gloucestershire
[user] => Mayowa Olaleye Surveyor
)
[12] => Array
(
[id] => 2006
[ref] => TW119NH-WIN-2006
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => Other
[job_type] => 13
[job_status] => Completed
[customer_name] => Patricia Winter
[address] => Quay West Court, 19 Ferry Road Teddington
[service_place] => Teddington
[region] => Gloucestershire
[user] => Mayowa Olaleye Surveyor
)
)
Gloucestershire - Sevenhampton - Gloucestershire
4 bedrooms/3 storeys - a Station Rd, Worsbrough, Barnsley
Inspection: Pre-Purchase Roof Inspections
Gloucestershire - Sevenhampton - Gloucestershire
2 bedrooms/Single level building - Constantine Close Swindon
Inspection: Pre-Purchase Roof Inspections
Gloucestershire - Sevenhampton - Gloucestershire
3 bedrooms/2 storeys - Hatherley St, Cheltenham
Inspection: Pre-Purchase Roof Inspections