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='Leicestershire' ORDER BY q.id DESCArray
(
[keyword] => pre-purchase-roof-inspections
[location] => Sewstern - Leicestershire
[region] => Leicestershire
)
Array
(
[0] => Array
(
[id] => 3594
[ref] => LE679PX-MAR-3594
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Joanne lowe Markfield Parish Council
[address] => Sporting Markfield, Markfield, Markfield
[service_place] => Markfield
[region] => Leicestershire
[user] => Mayowa Olaleye Surveyor
)
[1] => Array
(
[id] => 3593
[ref] => LE679TB-MAR-3593
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Joanne lowe Markfield Parish Council
[address] => Markfield Cemetery Chapel Markfield
[service_place] => Markfield
[region] => Leicestershire
[user] => Mayowa Olaleye Surveyor
)
[2] => Array
(
[id] => 3592
[ref] => LE679ST-MAR-3592
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => Medium Commercial
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Joanne lowe Markfield Parish Council
[address] => Markfield Community Centre, Markfield
[service_place] => Markfield
[region] => Leicestershire
[user] => Mayowa Olaleye Surveyor
)
[3] => Array
(
[id] => 3246
[ref] => LE23BB-STR-3246
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 5 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Matthew Strommen
[address] => Springfield Rd, Leicester
[service_place] => Leicester
[region] => Leicestershire
[user] => DSI Services (Reports)
)
[4] => Array
(
[id] => 3075
[ref] => LE21LD-ISM-3075
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Afif Ismail
[address] => Herschell Street Leicester
[service_place] => Leicester
[region] => Leicestershire
[user] => Mayowa Olaleye Surveyor
)
[5] => Array
(
[id] => 2989
[ref] => LE54NA-NAI-2989
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 2 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Hina Naik
[address] => Freeman North Rowlatts Hill, Leicester
[service_place] => Leicester
[region] => Leicestershire
[user] => Mayowa Olaleye Surveyor
)
[6] => Array
(
[id] => 2881
[ref] => LE39NP-BRI-2881
[job_desc] => Drone Roof Inspections and Surveys
[roof_size] => 3 bedrooms
[roof_height] => 2 storeys
[job_type] => 13
[job_status] => Completed
[customer_name] => Aaron Bridgman
[address] => 27 Caledine Rd, Leicester
[service_place] => Leicester
[region] => Leicestershire
[user] => DSI Services (Reports)
)
)
Leicestershire - Sewstern - Leicestershire
Medium Commercial/2 storeys - Sporting Markfield, Markfield, Markfield
Inspection: Pre-Purchase Roof Inspections
Leicestershire - Sewstern - Leicestershire
Medium Commercial/2 storeys - Markfield Cemetery Chapel Markfield
Inspection: Pre-Purchase Roof Inspections
Leicestershire - Sewstern - Leicestershire
Medium Commercial/2 storeys - Markfield Community Centre, Markfield
Inspection: Pre-Purchase Roof Inspections