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='Nottinghamshire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Serlby - Nottinghamshire
[region] => Nottinghamshire
)
Array
(
[0] => Array
(
[id] => 4084
[ref] => NG103GJ-SPE-4084
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Henry Speckman
[address] => Lakeside Ave, Long Eaton, Nottingham
[service_place] => Nottingham
[region] => Nottinghamshire
[user] => Mayowa Olaleye Surveyor
)
[1] => Array
(
[id] => 4081
[ref] => NG104AZ-RIL-4081
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => Single level building
[job_type] => 13
[job_status] => Completed
[customer_name] => John Riley
[address] => Trowell Grove, Long Eaton, Nottingham
[service_place] => Nottingham
[region] => Nottinghamshire
[user] => Mayowa Olaleye Surveyor
)
[2] => Array
(
[id] => 3577
[ref] => NG182PS-SIM-3577
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Cipriani Simotta
[address] => Bolsover St, Mansfield
[service_place] => Mansfield
[region] => Nottinghamshire
[user] => Mayowa Olaleye Surveyor
)
[3] => Array
(
[id] => 3422
[ref] => NG41PX-BIS-3422
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Martin Bishop
[address] => Foxhill Rd Carlton Nottingham
[service_place] => Nottingham
[region] => Nottinghamshire
[user] => DSI Services (Reports)
)
[4] => Array
(
[id] => 3209
[ref] => NG55AH-BER-3209
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Lyndon Berry
[address] => Revelstoke Way, Nottingham
[service_place] => Nottingham
[region] => Nottinghamshire
[user] => DSI Services (Reports)
)
[5] => Array
(
[id] => 3007
[ref] => NG13BE-RIG-3007
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Raymond Right
[address] => Nottingham Arts Theatre George St, Nottingham
[service_place] => Nottingham
[region] => Nottinghamshire
[user] => Mayowa Olaleye Surveyor
)
[6] => Array
(
[id] => 2501
[ref] => NG13NE-MAN-2501
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Dan Mannion
[address] => Victoria Centre, 178 Huntingdon Street, Nottingham
[service_place] => Nottingham
[region] => Nottinghamshire
[user] => DSI Services (Reports)
)
[7] => Array
(
[id] => 2411
[ref] => NG24DN-HAL-2411
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Colin Hallahan
[address] => Portside Street Nottingham
[service_place] => Nottingham
[region] => Nottinghamshire
[user] => DSI Services (Reports)
)
)
Nottinghamshire - Serlby - Nottinghamshire
3 bedrooms/2 storeys - Lakeside Ave, Long Eaton, Nottingham
Inspection: Pre-Purchase Roof Inspections
Nottinghamshire - Serlby - Nottinghamshire
3 bedrooms/Single level building - Trowell Grove, Long Eaton, Nottingham
Inspection: Pre-Purchase Roof Inspections
Nottinghamshire - Serlby - Nottinghamshire
2 bedrooms/2 storeys - Bolsover St, Mansfield
Inspection: Pre-Purchase Roof Inspections