;

[CDR]
dsn=asteriskcdr
writesql=INSERT INTO cdr3(accountcode,src,dst,dcontext,clid,channel,dstchannel,lastapp,lastdata,start,answer,end,duration,billsec,disposition,op_answer,operator,ans_duration,amaflags,userfield,uniqueid,linkedid,peeraccount,direct,sequence) VALUES('${SQL_ESC(${VAL1})}','${SQL_ESC(${VAL2})}','${SQL_ESC(${VAL3})}','${SQL_ESC(${VAL4})}','${SQL_ESC(${VAL5})}','${SQL_ESC(${VAL6})}','${SQL_ESC(${VAL7})}','${SQL_ESC(${VAL8})}','${SQL_ESC(${VAL9})}','${SQL_ESC(${VAL10})}','${SQL_ESC(${VAL11})}','${SQL_ESC(${VAL12})}','${SQL_ESC(${VAL13})}','${SQL_ESC(${VAL14})}','${SQL_ESC(${VAL15})}','${SQL_ESC(${VAL16})}','${SQL_ESC(${VAL17})}','${SQL_ESC(${VAL18})}','${SQL_ESC(${VAL19})}','${SQL_ESC(${VAL20})}','${SQL_ESC(${VAL21})}','${SQL_ESC(${VAL22})}','${SQL_ESC(${VAL23})}','${SQL_ESC(${VAL24})}','${SQL_ESC(${VAL25})}')

;writesql=INSERT INTO cdr3 SET accountcode='${SQL_ESC(${VAL1})}', src='${SQL_ESC(${VAL2})}', dst='${SQL_ESC(${VAL3})}', dcontext='${SQL_ESC(${VAL4})}', clid='${SQL_ESC(${VAL5})}' ,channel='${SQL_ESC(${VAL6})}', dstchannel='${SQL_ESC(${VAL7})}',lastapp='${SQL_ESC(${VAL8})}', lastdata='${SQL_ESC(${VAL9})}', start='${SQL_ESC(${VAL10})}', answer='${SQL_ESC(${VAL11})}', end='${SQL_ESC(${VAL12})}', duration='${SQL_ESC(${VAL13})}', billsec='${SQL_ESC(${VAL14})}', disposition='${SQL_ESC(${VAL15})}', op_answer='${SQL_ESC(${VAL16})}', operator='${SQL_ESC(${VAL17})}', ans_duration='${SQL_ESC(${VAL18})}', amaflags='${SQL_ESC(${VAL19})}', userfield='${SQL_ESC(${VAL20})}', uniqueid='${SQL_ESC(${VAL21})}', linkedid='${SQL_ESC(${VAL22})}', peeraccount='${SQL_ESC(${VAL23})}', direct='${SQL_ESC(${VAL24})}', sequence='${SQL_ESC(${VAL25})}'
;escapecommas=yes


[AD_CUR_STATE]
dsn=asteriskcdr
writesql=UPDATE autodial SET cl_online='${SQL_ESC(${VAL1})}' WHERE src='${SQL_ESC(${ARG1})}' AND call_date > NOW() - INTERVAL '${SQL_ESC(${ARG2})}' SECOND AND type='missed_call'
;escapecommas=yes


[AD_CL_OFF]
dsn=asteriskcdr
writesql=UPDATE autodial SET cl_online='${SQL_ESC(${VAL1})}', disposition='${SQL_ESC(${VAL2})}' WHERE src='${SQL_ESC(${ARG1})}' AND call_date > NOW() - INTERVAL '${SQL_ESC(${ARG2})}' SECOND AND type='missed_call'
;escapecommas=yes


[REDIR_TO_CLINIC]
dsn=asteriskcdr
readsql=SELECT clinic FROM redir_to_clinic WHERE number='${SQL_ESC(${ARG1})}' AND NOW() > date_from AND NOW() < date ORDER BY date_from,date LIMIT 1
;escapecommas=yes
