[810] | 1 | var rules_limit = 300; |
---|
[246] | 2 | |
---|
[2] | 3 | function cfilterSh(){ |
---|
| 4 | this.filter_Sh = new Array; |
---|
| 5 | this.qvfaf = ""; |
---|
| 6 | |
---|
| 7 | // Images |
---|
| 8 | this.grp_open_img = new Image(); |
---|
[803] | 9 | this.grp_open_img.src = 'templates/'+template+'/images/filtro/group_open.gif'; |
---|
[2] | 10 | this.grp_close_img = new Image(); |
---|
[803] | 11 | this.grp_close_img.src = 'templates/'+template+'/images/filtro/group_close.gif'; |
---|
[2] | 12 | this.filter_img = new Image(); |
---|
[803] | 13 | this.filter_img.src = 'templates/'+template+'/images/filtro/filters.gif'; |
---|
[2] | 14 | this.for_email_img = new Image(); |
---|
[803] | 15 | this.for_email_img.src = 'templates/'+template+'/images/filtro/answered.gif'; |
---|
[564] | 16 | this.telephone_voip = new Image(); |
---|
[803] | 17 | this.telephone_voip.src = 'templates/'+template+'/images/filtro/telephone_voip.jpg'; |
---|
[2] | 18 | } |
---|
| 19 | |
---|
| 20 | cfilterSh.prototype.Forms = function(){ |
---|
| 21 | |
---|
| 22 | var form = document.createElement("DIV"); |
---|
| 23 | form.id = "window_ffilter_ccform"; |
---|
| 24 | form.style.visibility = "hidden"; |
---|
| 25 | form.style.position = "absolute"; |
---|
| 26 | form.style.left = "0px"; |
---|
| 27 | form.style.top = "0px"; |
---|
| 28 | form.style.width = "0px"; |
---|
| 29 | form.style.height = "0px"; |
---|
| 30 | document.body.appendChild(form); |
---|
| 31 | |
---|
| 32 | var form_cont = document.createElement("SPAN"); |
---|
| 33 | form_cont.id = "form_status"; |
---|
[564] | 34 | form_cont.style.display = "block"; |
---|
[2] | 35 | form_cont.style.position = "absolute"; |
---|
[197] | 36 | form_cont.style.top = "10px"; |
---|
[2] | 37 | form_cont.style.left = "600px"; |
---|
| 38 | form_cont.innerHTML = ""; |
---|
| 39 | form.appendChild(form_cont); |
---|
| 40 | |
---|
| 41 | var form_buttons = document.createElement("DIV"); |
---|
| 42 | form_buttons.id = "form_buttons"; |
---|
| 43 | form_buttons.style.position = "absolute"; |
---|
| 44 | form_buttons.style.display = ""; |
---|
| 45 | form_buttons.style.top = "320px"; |
---|
| 46 | form_buttons.style.left = "5px"; |
---|
| 47 | form_buttons.style.width = "655px"; |
---|
| 48 | form_buttons.innerHTML = "<input type='button' value="+get_lang("Enable")+" onclick='filter.enabled_disabled(\"ENABLED\");'>"+ |
---|
| 49 | " <input type='button' value="+get_lang("Disable")+" onclick='filter.enabled_disabled(\"DISABLED\");'>"+ |
---|
[53] | 50 | " <input type='button' value="+get_lang("Remove")+" onclick='filter.delete_r();'>"+ |
---|
| 51 | " <input type='button' value="+get_lang("Close")+" onclick='filter.close_frm();'>"; |
---|
[2] | 52 | |
---|
| 53 | form.appendChild(form_buttons); |
---|
| 54 | |
---|
| 55 | var form_body = document.createElement("DIV"); |
---|
| 56 | form_body.id = "form_body"; |
---|
| 57 | form_body.style.position = "absolute"; |
---|
| 58 | form_body.style.left = "5px"; |
---|
| 59 | form_body.style.top = "5px"; |
---|
| 60 | form_body.style.width = "668px"; |
---|
| 61 | form_body.style.height = "310px"; |
---|
| 62 | form_body.style.borderStyle = "outset"; |
---|
| 63 | form_body.style.borderColor = "black"; |
---|
| 64 | form_body.style.borderWidth = "1px"; |
---|
| 65 | form_body.style.overflow = "auto"; |
---|
| 66 | form.appendChild(form_body); |
---|
| 67 | |
---|
| 68 | this.showWindow(form); |
---|
| 69 | filter.load_rules(); |
---|
| 70 | this.list_rules(); |
---|
| 71 | |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | cfilterSh.prototype.list_rules = function(){ |
---|
| 75 | if(filter.rulest.length == 0) |
---|
| 76 | setTimeout("filters.mount_list()",2500); |
---|
| 77 | else |
---|
| 78 | this.mount_list(); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | cfilterSh.prototype.mount_list = function(){ |
---|
| 82 | |
---|
| 83 | Element('form_status').innerHTML = ""; |
---|
| 84 | var list = ""; |
---|
[564] | 85 | |
---|
[2] | 86 | // rules |
---|
| 87 | if(filter.rulest.length == 0){ |
---|
[564] | 88 | list = "<img id='set_rules_img' src='" + this.grp_close_img.src + "' border='0' /> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule()'>" + get_lang("new rule") + "</a>"; |
---|
[2] | 89 | }else{ |
---|
[564] | 90 | if ( filter.rulest.length < rules_limit ) //Limit of rules |
---|
| 91 | list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' /> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + "<a href='javascript:filters.n_rule();'>" + get_lang("new rule") + "</a>"; |
---|
[246] | 92 | else |
---|
[564] | 93 | list = "<img id='set_rules_img' src='" + this.grp_open_img.src + "' onclick='visibleRulesFalse(\"set_rules\");' border='0' /> <span><b>"+get_lang('list of the filters') + " - ( " + filter.rulest.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules"); |
---|
| 94 | |
---|
[2] | 95 | list += "<div id='set_rules'>"; |
---|
[564] | 96 | |
---|
| 97 | for(var i= 0; i < filter.rulest.length; i++) |
---|
| 98 | { |
---|
| 99 | list += "<input id=rule_"+i+" type='checkBox'> <img src='"+this.filter_img.src+"' width='16' height='16' border='0' /> " + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulest[i],i,'') + "<br>"; |
---|
[2] | 100 | } |
---|
[564] | 101 | list += "</div>"; |
---|
[2] | 102 | } |
---|
[564] | 103 | |
---|
| 104 | list += "<br/>"; |
---|
| 105 | |
---|
[2] | 106 | // out office |
---|
[197] | 107 | if(!filter.out_officeR){ |
---|
[564] | 108 | list += "<img id='set_out_img' src='"+this.grp_close_img.src+"' border='0' /> "; |
---|
[2] | 109 | list += "<span><b>"+get_lang('out office') + " - ( 0 ) </b></span> " + "<a href='javascript:filters.n_out_office()'>" + get_lang("new rule") + "</a>"; |
---|
| 110 | }else{ |
---|
[564] | 111 | list += "<img id='set_out_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"set_out\");' border='0' /> "; |
---|
[197] | 112 | list += "<span><b>"+get_lang('out office') + " - ( 1 )</b></span>"; |
---|
[2] | 113 | list += "<div id='set_out'>"; |
---|
| 114 | list += "<input id='out_0' type='checkBox'><img id='set_out_form_email_img' src='"+this.for_email_img.src+"' border='0'>"; |
---|
[197] | 115 | list += " " + this.vl_outOffice(filter.out_officeR) + " " ; |
---|
[2] | 116 | list += "</div>"; |
---|
| 117 | } |
---|
[564] | 118 | list += "<br/>"; |
---|
| 119 | |
---|
| 120 | // Voip |
---|
| 121 | if(preferences.voip_email_redirect) |
---|
| 122 | { |
---|
| 123 | if( filter.rulesVoip.length == 0) |
---|
| 124 | { |
---|
| 125 | list += "<img id='voip_rule_img' src='"+this.grp_close_img.src+"' border='0' /> <span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter();'>" + get_lang("new rule") + "</a>"; |
---|
| 126 | } |
---|
| 127 | else |
---|
| 128 | { |
---|
| 129 | if ( filter.rulest.length < rules_limit ) //Limit of rules |
---|
| 130 | list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/> <span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + "<a href='javascript:filters.n_voipFilter()'>" + get_lang("new rule") + "</a>"; |
---|
| 131 | else |
---|
| 132 | list += "<img id='voip_rule_img' src='"+this.grp_open_img.src+"' onclick='visibleRulesFalse(\"voip_rule\");' border='0'/> <span><b>" + get_lang('Phone Warnings List') + " - ( " + filter.rulesVoip.length + " ) </b></span> - " + get_lang("You have reached the maximum number of rules"); |
---|
| 133 | |
---|
| 134 | list += "<div id='voip_rule'>"; |
---|
| 135 | for(var i= 0; i < filter.rulesVoip.length; i++) |
---|
| 136 | { |
---|
| 137 | list += "<input id='voip_rule_"+i+"' type='checkBox'> <img src='"+this.telephone_voip.src+"' width='16' height='16' border='0'/> " + get_lang("Rule")+" : " + parseInt(i+1) + " -- " + this.vl_rule(filter.rulesVoip[i],i,'voip') + "<br>"; |
---|
| 138 | } |
---|
| 139 | list += "</div>"; |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | |
---|
[2] | 143 | Element("form_body").innerHTML = list; |
---|
| 144 | } |
---|
| 145 | |
---|
[564] | 146 | cfilterSh.prototype.vl_rule = function(rule,pos,type) |
---|
| 147 | { |
---|
| 148 | var fields = rule.split("&&"); |
---|
| 149 | if(type == 'voip') |
---|
| 150 | return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','voip')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - " + fields[3] + " <b>" + get_lang("Subject") + ":</b> " + fields[5] + "</a>"; |
---|
| 151 | else |
---|
| 152 | return " <a href='javascript:void(0)' onclick=filter.form_r('"+pos+"','')><b>" + get_lang("Status") + " : </b>" + "<font color='red'>" + get_lang(fields[2]) + "</font>" + " - <b>" + get_lang("E-mail rule") + ":</b> " + fields[3] + " - <b>" + get_lang("Action") + ":</b> " + fields[6] + "</a>"; |
---|
[2] | 153 | } |
---|
| 154 | |
---|
[197] | 155 | cfilterSh.prototype.vl_outOffice = function(outOffice){ |
---|
[2] | 156 | var aux = outOffice.split("&&"); |
---|
[197] | 157 | return get_lang("Rule") + " - <a href='javascript:void(0)' onclick=filter.form_out()> " + "<b>" + get_lang("Status") + " : </b><font color='red'>" + (aux[4] == "off" ? get_lang("Disabled") : get_lang("Enabled")) + "</font></a>"; |
---|
[2] | 158 | } |
---|
| 159 | |
---|
[564] | 160 | cfilterSh.prototype.n_rule = function() |
---|
| 161 | { |
---|
[2] | 162 | Element('form_body').innerHTML = ""; |
---|
| 163 | Element('form_body').innerHTML = filter.forms_(); |
---|
[564] | 164 | Element('div_rule').style.display = "block"; |
---|
[2] | 165 | filter.ac_form = "new_rule"; |
---|
| 166 | Element('form_buttons').style.display = 'none'; |
---|
| 167 | filter.sel_boxes(); |
---|
| 168 | |
---|
| 169 | } |
---|
| 170 | |
---|
[564] | 171 | cfilterSh.prototype.n_out_office = function() |
---|
| 172 | { |
---|
[2] | 173 | Element('form_body').innerHTML = ""; |
---|
| 174 | Element('form_body').innerHTML = filter.forms_(); |
---|
[564] | 175 | Element('div_vacation').style.display = "block"; |
---|
[2] | 176 | Element('form_buttons').style.display = 'none'; |
---|
| 177 | filter.ac_form = "new_out"; |
---|
[564] | 178 | } |
---|
[2] | 179 | |
---|
[564] | 180 | cfilterSh.prototype.n_voipFilter = function() |
---|
| 181 | { |
---|
| 182 | Element('form_body').innerHTML = ""; |
---|
| 183 | Element('form_body').innerHTML = filter.forms_(); |
---|
| 184 | Element('div_voipFilter').style.display = "block"; |
---|
| 185 | Element('form_buttons').style.display = 'none'; |
---|
| 186 | filter.ac_form = "new_voip"; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | function visibleRulesFalse(el) |
---|
| 190 | { |
---|
[2] | 191 | Element(el).style.display = "none"; |
---|
[564] | 192 | Element(el+"_img").src = filters.grp_close_img.src; |
---|
| 193 | Element(el+"_img").onclick = function(){visibleRulesTrue(el);}; |
---|
[2] | 194 | } |
---|
| 195 | |
---|
[564] | 196 | function visibleRulesTrue(el) |
---|
| 197 | { |
---|
[2] | 198 | Element(el).style.display = ""; |
---|
[564] | 199 | Element(el+"_img").src = filters.grp_open_img.src; |
---|
| 200 | Element(el+"_img").onclick = function(){visibleRulesFalse(el);}; |
---|
[2] | 201 | } |
---|
| 202 | |
---|
[564] | 203 | cfilterSh.prototype.showWindow = function (div) |
---|
| 204 | { |
---|
[2] | 205 | if(! this.filter_Sh[div.id]) { |
---|
| 206 | div.style.width = "680px"; |
---|
| 207 | div.style.height = "345px"; |
---|
| 208 | div.style.visibility = "hidden"; |
---|
| 209 | div.style.position = "absolute"; |
---|
| 210 | div.style.zIndex = "10000"; |
---|
[61] | 211 | var title = ':: ' + get_lang('Filters management') + ' - ' + get_lang('Filters maintenance') + ':: '; |
---|
[2] | 212 | var wHeight = div.offsetHeight + "px"; |
---|
| 213 | var wWidth = div.offsetWidth + "px"; |
---|
| 214 | |
---|
| 215 | win = new dJSWin({ |
---|
| 216 | id: 'filter'+div.id, |
---|
| 217 | content_id: div.id, |
---|
| 218 | width: wWidth, |
---|
| 219 | height: wHeight, |
---|
| 220 | title_color: '#3978d6', |
---|
| 221 | bg_color: '#eee', |
---|
| 222 | title: title, |
---|
| 223 | title_text_color: 'white', |
---|
| 224 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 225 | border: true }); |
---|
| 226 | |
---|
| 227 | this.filter_Sh[div.id] = win; |
---|
| 228 | win.draw(); |
---|
| 229 | }else{ |
---|
| 230 | div.innerHTML = ''; |
---|
| 231 | win = this.filter_Sh[div.id]; |
---|
| 232 | filter.form_m(); |
---|
| 233 | } |
---|
| 234 | win.open(); |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 238 | // build object |
---|
| 239 | var filters; |
---|
[803] | 240 | filters = new cfilterSh(); |
---|