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='West Yorkshire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Sharlston Common - West Yorkshire
[region] => West-Yorkshire
)
Array
(
[0] => Array
(
[id] => 4036
[ref] => HX39JS-DAV-4036
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 3 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Mike Davies
[address] => Siddal Ln, Siddal, Halifax
[service_place] => Halifax
[region] => West Yorkshire
[user] => DSI Services (Reports)
)
[1] => Array
(
[id] => 3839
[ref] => BD207PG-MAR-3839
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Robert Marsh
[address] => Rosemount Ct, Sutton-in-Craven, Keighley
[service_place] => Keighley
[region] => West Yorkshire
[user] => DSI Services (Reports)
)
[2] => Array
(
[id] => 3167
[ref] => HD75HH-PAR-3167
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 4 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Charlie Park
[address] => Manchester Rd, Slaithwaite, Huddersfield
[service_place] => Huddersfield
[region] => West Yorkshire
[user] => Mayowa Olaleye Surveyor
)
[3] => Array
(
[id] => 2846
[ref] => WF29UF-MOT-2846
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 1 bedroom
[roof_height] => Single level building
[job_type] => 13
[job_status] => Completed
[customer_name] => Farzin Motavesselzadeh
[address] => Heddle Rise, Alverthorpe, Wakefield
[service_place] => Wakefield
[region] => West Yorkshire
[user] => Mayowa Olaleye Surveyor
)
[4] => Array
(
[id] => 2607
[ref] => WF94BP-ROY-2607
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Adam Royston
[address] => A Victoria St, Hemsworth, Pontefract
[service_place] => Pontefract
[region] => West Yorkshire
[user] => DSI Services (Reports)
)
[5] => Array
(
[id] => 2463
[ref] => HD74ED-WIL-2463
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => Single level building
[job_type] => 13
[job_status] => Completed
[customer_name] => Gareth Williams
[address] => Station Road Golcar, Huddersfield
[service_place] => Huddersfield
[region] => West Yorkshire
[user] => Mayowa Olaleye Surveyor
)
)
West-Yorkshire - Sharlston Common - West Yorkshire
3 bedrooms/3 storeys - Siddal Ln, Siddal, Halifax
Inspection: Pre-Purchase Roof Inspections
West-Yorkshire - Sharlston Common - West Yorkshire
2 bedrooms/2 storeys - Rosemount Ct, Sutton-in-Craven, Keighley
Inspection: Pre-Purchase Roof Inspections
West-Yorkshire - Sharlston Common - West Yorkshire
4 bedrooms/2 storeys - Manchester Rd, Slaithwaite, Huddersfield
Inspection: Pre-Purchase Roof Inspections