<div dir="ltr"><div class="gmail_signature"><div dir="ltr"><div><span style="color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px;line-height:21.3px">Hi Guys,</span></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">Wonder if anyone can help.</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">I am testing with time of day routing, and I want to be able to check yearly/monthly conditions before weekly conditions are picked up.</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">I can do this successfully by just inputting XML into the dialplan, and works as expected, my issue is now when extracting the detail required from a database using lua.</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">I for example have 3 entries below for different times of the year;</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">+------------+-------+------+----------------+</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">| dayofmonth | month | year | dayofmonthtime |</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">+------------+-------+------+----------------+</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">| 25 | 12 | 0 | 0 |</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">| 1 | 1 | 2016 | 540-1050 |</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">| 10-18 | 9 | 2015 | 600-840 |</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">So when creating directly using xml I get;</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<condition mon="12" mday="25" break="on-true">]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<action application="set" data="TOD=sales" inline="true"/>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<action application="set" data="Status=closed inline="true"/>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[</condition>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<condition year="2016" mon="1" mday="1" break="on-true">]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<action application="set" data="TOD=sales" inline="true"/>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<action application="set" data="Status=closed inline="true"/>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[</condition>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<condition year="2015" mon="9" mday="10-18" break="on-true">]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<action application="set" data="TOD=sales" inline="true"/>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[<action application="set" data="Status=closed inline="true"/>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">table.insert(xml, [[</condition>]]);</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">However my issue is when my lua script extracts them, it loops through the 3 entries (each row) , so that only the 3rd entry is available for on-wards routing as it is populating the dialplan 3 separate times.</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">Can someone let me know what Im doing wrong? The data return is fine and I can implement lua and freeswitch for all other scenarios, its just this one which I am having issue with.</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">Im just doing a query as;</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">local todnew_query = string.format("select * from timeofday_new where todname='sales' and context_name='xx.xx.xx' order by priority")</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"> assert (dbh:query(todnew_query,function(todresult)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">And using the result with some if statements, I wondered if anyone had any advice on this?</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">Thanks</div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-family:Calibri,sans-serif;font-size:15px">Jon</div></div></div>
</div>