2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
4 Licensed to the public under the Apache License 2.0.
10 local uci = luci.model.uci.cursor_state()
11 local ast = require "luci.asterisk"
13 function digit_pattern(s,t)
14 return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'%s>%s</code>"
15 %{ t and " title='" .. t .. "'" or "", s }
19 return "cbi-rowstyle-%i" %{
20 ( i % 2 ) == 0 and 2 or 1
24 function format_matches(z)
27 if type(z) ~= "table" then
28 z = { matches = { z } }
32 for _, m in ipairs(z.matches) do
34 digit_pattern(z.localprefix, "local prefix") .. " " ..
39 if z.intlmatches and #z.intlmatches > 0 then
40 for _, i in ipairs(z.intlmatches) do
41 for _, m in ipairs(z.matches) do
42 html[#html+1] = "%s %s" %{
43 digit_pattern("(%s)" % i, "intl. prefix"),
49 for _, m in ipairs(z.matches) do
50 html[#html+1] = digit_pattern(m)
54 return table.concat(html, "; ")
59 <form method="post" action="<%=url('admin/asterisk/dialplans')%>" enctype="multipart/form-data">
61 <input type="hidden" name="cbi.submit" value="1" />
62 <input type="submit" value="Save" class="hidden" />
65 <div class="cbi-map" id="cbi-asterisk">
66 <h2 name="content">Outgoing Call Routing</h2>
67 <div class="cbi-map-descr">
68 Here you can manage your dial plans which are used to route outgoing calls from your local extensions.<br /><br />
70 <a href="<%=url('admin/asterisk/dialplans/zones')%>" class="cbi-title-ref">Manage dialzones</a> |
71 <a href="<%=url('admin/asterisk/voicemail/mailboxes')%>" class="cbi-title-ref">Manage voicemail boxes</a> |
72 <a href="<%=url('admin/asterisk/meetme/rooms')%>" class="cbi-title-ref">Manage meetme rooms</a>
75 <fieldset class="cbi-section" id="cbi-asterisk-sip">
76 <!--<legend>Dialplans</legend>-->
77 <div class="cbi-section-descr"></div>
79 <% for i, plan in pairs(ast.dialplan.plans()) do %>
80 <div class="cbi-section-node">
81 <div class="table cbi-section-table">
82 <div class="tr cbi-section-table-titles">
83 <div style="text-align: left; padding: 3px" class="th cbi-section-table-cell">
84 <big>Dialplan <em><%=plan.name%></em></big>
87 <a href="<%=url('admin/asterisk/dialplans')%>?delplan=<%=plan.name%>">
88 <img style="border:none" alt="Remove this dialplan" title="Remove this dialplan" src="/luci-static/resources/cbi/remove.gif" />
94 <% local zones_used = { }; local row = 0 %>
95 <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %>
96 <div class="tr cbi-section-table-row <%=rowstyle(row)%>">
97 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell">
98 <strong>└ Dialzone <em><%=zone.name%></em></strong> (<%=zone.description%>)
99 <p style="padding-left: 1em; margin-bottom:0">
101 <%=ast.tools.hyperlinks(
102 zone.trunks, function(v)
103 return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
107 <%=format_matches(zone)%>
110 <div style="width:5%" class="td cbi-value-field">
111 <a href="<%=url('admin/asterisk/dialplans/out', zone.name)%>">
112 <img style="border:none" alt="Edit dialzone" title="Edit dialzone" src="/luci-static/resources/cbi/edit.gif" />
114 <a href="<%=url('admin/asterisk/dialplans')%>?delzone.<%=plan.name%>=<%=zone.name%>">
115 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
119 <% row = row + 1; end %>
123 <% local boxes_used = { } %>
124 <% for ext, box in luci.util.kspairs(plan.voicemailboxes) do boxes_used[box.id] = true %>
125 <div class="tr cbi-section-table-row <%=rowstyle(row)%>">
126 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell">
127 <strong>└ Voicemailbox <em><%=box.id%></em></strong> (<%=box.name%>)
128 <p style="padding-left: 1em; margin-bottom:0">
129 Owner: <%=box.name%> |
130 eMail: <%=#box.email > 0 and box.email or 'n/a'%> |
131 Pager: <%=#box.page > 0 and box.page or 'n/a'%><br />
132 Matches: <%=format_matches(ext)%>
135 <div style="width:5%" class="td cbi-value-field">
136 <a href="<%=url('admin/asterisk/voicemail/mailboxes')%>">
137 <img style="border:none" alt="Manage mailboxes ..." title="Manage mailboxes ..." src="/luci-static/resources/cbi/edit.gif" />
139 <a href="<%=url('admin/asterisk/dialplans')%>?delvbox.<%=plan.name%>=<%=ext%>">
140 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
144 <% row = row + 1; end %>
148 <% local rooms_used = { } %>
149 <% for ext, room in luci.util.kspairs(plan.meetmerooms) do rooms_used[room.room] = true %>
150 <div class="tr cbi-section-table-row <%=rowstyle(row)%>">
151 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell">
152 <strong>└ MeetMe Room <em><%=room.room%></em></strong>
153 <% if room.description and #room.description > 0 then %> (<%=room.description%>)<% end %>
154 <p style="padding-left: 1em; margin-bottom:0">
155 Matches: <%=format_matches(ext)%>
158 <div style="width:5%" class="td cbi-value-field">
159 <a href="<%=url('admin/asterisk/meetme/rooms')%>">
160 <img style="border:none" alt="Manage conferences ..." title="Manage conferences ..." src="/luci-static/resources/cbi/edit.gif" />
162 <a href="<%=url('admin/asterisk/dialplans')%>?delmeetme.<%=plan.name%>=<%=ext%>">
163 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
167 <% row = row + 1; end %>
170 <div class="tr cbi-section-table-row">
171 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell" colspan="2">
172 <hr style="margin-bottom:0.5em; border-width:0 0 1px 0" />
175 <select style="width:30%" name="addzone.<%=plan.name%>">
176 <option value="">-- please select --</option>
177 <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %>
178 <% if not zones_used[zone.name] then %>
179 <option value="<%=zone.name%>"><%=zone.name%> (<%=zone.description%>)</option>
185 Add Voicemailbox:<br />
186 <select style="width:20%" name="addvbox.<%=plan.name%>" onchange="this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
187 <option value="">-- please select --</option>
188 <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %>
189 <% if not boxes_used[box.id] then %>
190 <option value="<%=box.id%>"><%=box.id%> (<%=box.name%>)</option>
195 <input type="text" style="width:5%" name="addvboxext.<%=plan.name%>" />
198 Add MeetMe Conference:<br />
199 <select style="width:20%" name="addmeetme.<%=plan.name%>" onchange="this.form['addmeetmeext.<%=plan.name%>'].value=this.options[this.selectedIndex].value">
200 <option value="">-- please select --</option>
201 <% for ext, room in luci.util.kspairs(ast.meetme.rooms()) do %>
202 <%# if not rooms_used[room.room] then %>
203 <option value="<%=room.room%>">
205 <% if room.description and #room.description > 0 then %>(<%=room.description%>)<% end %>
211 <input type="text" style="width:5%" name="addmeetmeext.<%=plan.name%>" />
214 <input type="submit" class="cbi-button cbi-button-add" value="Add item »" title="Add item ..."/>
220 <div class="cbi-section-create cbi-tblsection-create"></div>
225 <div class="cbi-section-node">
226 <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
227 <h3>Create a new dialplan</h3>
228 The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
230 <%- if create_error then %>
231 <br /><span style="color:red">Invalid name given!</span><br />
235 <input type="text" class="cbi-section-create-name" name="addplan" style="width:200px" />
236 <input type="submit" class="cbi-button cbi-button-add" value="Add dialplan" title="Add dialplan"/>
243 <div class="clear"></div>