Hello,
As a newbie, I need your help. I have tried to add two date pickers in a report, to define dynamically a period as a filter to the sql query below without reloading the webpage.
Can you help me to create this dynamic filter please ?
Thanks for your help
My code is :
select 'dbr.css', 'body {background:#00a8b5}';
select 'dbr.css', '.report_top {background-color:#00a8b5}';
select 'dbr.css', '#dbr_rt3 td {border:1px solid #a9a9a9;}';
select 'dbr.css', '.align_r {text-align:center}';
select 'dbr.css', '.align_l {text-align:center}';
select 'dbr.css', '.row_header, .drill_header, .cell_header, .dbr_calendar .fc-day-header, .dbr_calendar .fc-basic-view th.fc-week-number, .dbr_calendar .fc-week-number.fc-widget-header, .fc-head-container.fc-widget-header {background:linear-gradient(to bottom, rgba(76,76,76,1) 0%,rgba(93, 93, 93, 1) 100%)}';
select 'dbr.search', 1;
select 'dbr.header.group', 'Synthesis', 'Num of Calls 1to1','Total call time';
select 'dbr.header.group', 'Calls 1to1', 'Total call 1to1','1to1>30d';
select 'dbr.header.group', 'Calls Conf', 'Total call Conf','Conf>30d'; SELECT REPLACE(UPPER(o.COMPANY),'_',' ') as CUSTOMER,
(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CALL_ID e WHERE e.COMPANY=o.COMPANY) as 'Num of Calls 1to1',
(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CONF_ID m WHERE m.COMPANY=o.COMPANY) as 'Num of Conf',
SEC_TO_TIME((SELECT COALESCE(SUM(a.DURATION_MAX),0) FROM v5.MAX_DURATION_BY_CALL_ID a WHERE a.COMPANY=o.COMPANY)+(SELECT COALESCE(SUM(m.DURATION_MAX),0) FROM v5.MAX_DURATION_BY_CONF_ID m WHERE m.COMPANY=o.COMPANY)) as 'Total call time',
(SELECT SEC_TO_TIME(SUM(a.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CALL_ID a WHERE a.COMPANY=o.COMPANY) as 'Total call 1to1',
SEC_TO_TIME((SELECT SUM(a.DURATION_MAX) FROM v5.MAX_DURATION_BY_CALL_ID a WHERE a.COMPANY=o.COMPANY)/(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CALL_ID e WHERE e.COMPANY=o.COMPANY)) as 'Avg Call 1to1 duration',
CONCAT((SELECT SEC_TO_TIME(SUM(b.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CALL_ID b WHERE b.COMPANY=o.COMPANY and (`CALL_DATE` > (NOW() - INTERVAL 7 DAY)) ),' (',(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CALL_ID f WHERE f.COMPANY=o.COMPANY and (`CALL_DATE` > (NOW() - INTERVAL 7 DAY))) ,')') as '1to1<7d',
CONCAT((SELECT SEC_TO_TIME(SUM(c.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CALL_ID c WHERE c.COMPANY=o.COMPANY and (`CALL_DATE` < (NOW() - INTERVAL 7 DAY)) and (`CALL_DATE` >= (NOW() - INTERVAL 30 DAY))),' (',(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CALL_ID g WHERE g.COMPANY=o.COMPANY and (`CALL_DATE` < (NOW() - INTERVAL 7 DAY)) and (`CALL_DATE` >= (NOW() - INTERVAL 30 DAY))) ,')') as '7d < 1to1 < 30d',
CONCAT((SELECT SEC_TO_TIME(SUM(d.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CALL_ID d WHERE d.COMPANY=o.COMPANY and (`CALL_DATE` < (NOW() - INTERVAL 30 DAY)) ),' (',(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CALL_ID h WHERE h.COMPANY=o.COMPANY and (`CALL_DATE` < (NOW() - INTERVAL 30 DAY))) ,')') as '1to1>30d',
INTERVAL 7 DAY)) and (`CALL_DATE` >= (NOW() - INTERVAL 30 DAY))) as y,
/*CONCAT(*/(SELECT SEC_TO_TIME(SUM(m.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CONF_ID m WHERE m.COMPANY=o.COMPANY)/*,' (', (SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CONF_ID m WHERE m.COMPANY=o.COMPANY),')')*/ as 'Total call Conf',
SEC_TO_TIME((SELECT SUM(m.DURATION_MAX) FROM v5.MAX_DURATION_BY_CONF_ID m WHERE m.COMPANY=o.COMPANY)/(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CONF_ID m WHERE m.COMPANY=o.COMPANY)) as 'Avg Conf duration',
CONCAT((SELECT SEC_TO_TIME(SUM(n.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CONF_ID n WHERE n.COMPANY=o.COMPANY and (`CONF_DATE` > (NOW() - INTERVAL 7 DAY)) ),' (',(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CONF_ID n WHERE n.COMPANY=o.COMPANY and (`CONF_DATE` > (NOW() - INTERVAL 7 DAY))) ,')') as 'Conf<7d',
CONCAT((SELECT SEC_TO_TIME(SUM(p.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CONF_ID p WHERE p.COMPANY=o.COMPANY and (`CALL_DATE` < (NOW() - INTERVAL 7 DAY)) and (`CALL_DATE` >= (NOW() - INTERVAL 30 DAY)) ),' (',(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CONF_ID p WHERE p.COMPANY=o.COMPANY and (`CONF_DATE` < (NOW() - INTERVAL 7 DAY)) and (`CONF_DATE` >= (NOW() - INTERVAL 30 DAY))) ,')') as '7d < Conf < 30d',
CONCAT((SELECT SEC_TO_TIME(SUM(q.DURATION_MAX)) FROM v5.MAX_DURATION_BY_CONF_ID q WHERE q.COMPANY=o.COMPANY and (`CONF_DATE` < (NOW() - INTERVAL 30 DAY)) ),' (',(SELECT COUNT(*) FROM v5.MAX_DURATION_BY_CONF_ID q WHERE q.COMPANY=o.COMPANY and (`CONF_DATE` < (NOW() - INTERVAL 30 DAY))) ,')') as 'Conf>30d' FROM
v5.MAX_DURATION_BY_CALL_ID o
GROUP BY o.COMPANY;