Ignore:
Timestamp:
01/05/09 17:20:41 (15 years ago)
Author:
niltonneto
Message:

resolve #381

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/js/filter.js

    r377 r564  
    1 function charCounter(form) 
    2 { 
    3         if (form.value.length >= 300) { 
    4                 alert(get_lang("You have exceeded the number of allowed characters")); 
    5                 return false; 
    6         } 
    7  
    8 } 
     1 
     2        function charCounter(form) 
     3        { 
     4                if (form.value.length >= 300) 
     5                { 
     6                        alert(get_lang("You have exceeded the number of allowed characters")); 
     7                        return false; 
     8                } 
     9        } 
    910 
    1011        function cfilter(){ 
     
    1213                this.mode_in   = ""; 
    1314                this.rulest              = new Array; 
     15                this.rulesVoip   = new Array; 
    1416                this.out_officeR = ""; 
    1517                this.out_officeF = false; 
     
    3739                 
    3840        } 
    39          
    40         cfilter.prototype.load_rules = function(){ 
     41 
     42         
     43        cfilter.prototype.load_rules = function() 
     44        { 
    4145                var _this = this; 
    42                 if(_this.rulest.length == 0){ 
    43                         var handler_sieve = function(data){ 
     46                var cont1 = parseInt(0); 
     47                var cont2 = parseInt(0); 
     48                                 
     49                if( _this.rulest.length == 0 ) 
     50                { 
     51                        var handler_sieve = function(data) 
     52                        { 
    4453                                if(data.rule.length > 0){ 
    45                                         for(var i=0 ; i < data.rule.length; i++){ 
    46                                                 _this.rulest[_this.rulest.length] = data.rule[i]; 
     54                                        for(var i=0 ; i < data.rule.length; i++) 
     55                                        { 
     56                                                var fields = data.rule[i].split("&&"); 
     57                                                if( fields[6] == 'notify' && fields[7] == preferences.voip_email_redirect ) 
     58                                                        _this.rulesVoip[cont1++] = data.rule[i]; 
     59                                                else 
     60                                                        _this.rulest[cont2++] = data.rule[i]; 
    4761                                        } 
    4862                                } 
     
    7387        } 
    7488         
    75         cfilter.prototype.form_r = function(pos){ 
     89        cfilter.prototype.form_r = function(pos,type) 
     90        { 
    7691                Element('form_body').innerHTML = ""; 
    7792                Element('form_body').innerHTML = this.forms_(); 
    78                 Element('div_rule').style.display = "";  
    79                 this.ac_form = "old_rule"; 
    80                 this.ind = pos; 
    81                 this.r_rules_form(pos); 
    82         } 
    83          
    84         cfilter.prototype.get_email = function(){ 
     93                this.ind = pos;          
     94                 
     95                if( type === 'voip') 
     96                { 
     97                        this.ac_form = "old_voip"; 
     98                        Element('div_voipFilter').style.display = ""; 
     99                        this.r_rules_form(pos, type);    
     100                } 
     101                else 
     102                { 
     103                        this.ac_form = "old_rule"; 
     104                        Element('div_rule').style.display = "";  
     105                        this.r_rules_form(pos, type); 
     106                } 
     107        } 
     108         
     109        cfilter.prototype.get_email = function() 
     110        { 
    85111                var _this = this; 
    86                 var handler_get_email = function(data){ 
     112                var handler_get_email = function(data) 
     113                { 
    87114                        _this.email_ld = data ? data : ""; 
    88115                } 
     
    90117        } 
    91118         
    92         cfilter.prototype.sel_boxes = function(){ 
     119        cfilter.prototype.sel_boxes = function() 
     120        { 
    93121                var nm_folders = tree_folders.getNodesList(cyrus_delimiter); 
    94122                if(document.getElementById("select_mailboxes") != null){ 
     
    100128                                } 
    101129                        } 
    102                         for(var i=0; i < nm_folders.length; i++){ 
    103                                 if(nm_folders[i].id != "root"){ 
     130                        for(var i=0; i < nm_folders.length; i++) 
     131                        { 
     132                                if(nm_folders[i].id != "root") 
     133                                { 
    104134                                        var opt = new Option(nm_folders[i].caption,nm_folders[i].id,false,true); 
    105135                                        sel_nm[sel_nm.length] = opt; 
     
    125155        } 
    126156 
    127         cfilter.prototype.r_rules_form = function(ind){ 
     157        cfilter.prototype.r_rules_form = function(ind, type) 
     158        { 
     159                var fields = new Array; 
     160                var _this = this; 
    128161                 
    129162                // hide buttons 
    130163                Element('form_buttons').style.display = 'none'; 
    131  
    132                 this.sel_boxes(); 
    133                 var aux = new Array; 
    134                 var _this = this; 
    135                 if(this.rulest.length == 0){ 
    136                         return false; 
    137                 } 
    138                 aux = _this.rulest[ind].split("&&"); 
    139                 document.getElementById("field1").value = aux[3]; 
    140                 document.getElementById("field2").value = aux[4]; 
    141                 document.getElementById("field3").value = aux[5]; 
    142                 document.getElementById("field4").value = aux[11];                               
    143                  
    144                 switch(aux[6]){ 
    145                         case "folder": 
    146                                 document.getElementById("radio1").checked  = true; 
    147                                 var name_mb = aux[7]; 
    148                                 var sel_mb = document.getElementById("select_mailboxes"); 
    149                                 for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) ==  name_mb){sel_mb.options[i].selected = true;}} 
    150                                 break; 
    151                         case "address": 
    152                                 document.getElementById("radio2").checked   = true; 
    153                                 document.getElementById("field5").value         = aux[7]; 
    154                                 break; 
    155                         case "reject": 
    156                                  document.getElementById("radio3").checked  = true; 
    157                                  var text0 = aux[7].split("\\n");                                        
    158                                  for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";} 
    159                                  break; 
    160                         case "discard": 
    161                                 document.getElementById("radio4").checked       = true; 
    162                                 break; 
    163                 } 
    164                 var mark_values = this.values[aux[8]].split(","); 
    165                 for(var i=0; i < mark_values.length; i++){ 
    166                         if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){ 
    167                                 document.getElementById(mark_values[i]).checked = true; 
    168                         } 
    169                         if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){ 
    170                                 var mark_val = mark_values[i].split("="); 
    171                                 document.getElementById(mark_val[0]).options[mark_val[1]].selected = true; 
     164                 
     165                if( type === 'voip') 
     166                { 
     167                        fields = _this.rulesVoip[ind].split("&&"); 
     168                        document.getElementById("field9").value = fields[5];                     
     169                } 
     170                else 
     171                { 
     172                        this.sel_boxes(); 
     173                        if(this.rulest.length == 0){ 
     174                                return false; 
     175                        } 
     176                        fields = _this.rulest[ind].split("&&"); 
     177                        document.getElementById("field1").value = fields[3]; 
     178                        document.getElementById("field2").value = fields[4]; 
     179                        document.getElementById("field3").value = fields[5]; 
     180                        document.getElementById("field4").value = fields[11];                            
     181                         
     182                        switch(fields[6]){ 
     183                                case "folder": 
     184                                        document.getElementById("radio1").checked  = true; 
     185                                        var name_mb = fields[7]; 
     186                                        var sel_mb = document.getElementById("select_mailboxes"); 
     187                                        for(var i=0; i < sel_mb.options.length; i++){if((sel_mb.options[i].value) ==  name_mb){sel_mb.options[i].selected = true;}} 
     188                                        break; 
     189                                case "address": 
     190                                        document.getElementById("radio2").checked   = true; 
     191                                        document.getElementById("field5").value         = fields[7]; 
     192                                        break; 
     193                                case "reject": 
     194                                         document.getElementById("radio3").checked  = true; 
     195                                         var text0 = fields[7].split("\\n");                                     
     196                                         for(var i=0; i < text0.length; i++){document.getElementById("field6").value += text0[i] + "\n";} 
     197                                         break; 
     198                                case "discard": 
     199                                        document.getElementById("radio4").checked       = true; 
     200                                        break; 
     201                        } 
     202                        var mark_values = this.values[fields[8]].split(","); 
     203                        for(var i=0; i < mark_values.length; i++){ 
     204                                if( mark_values[i] == "checkBox1" || mark_values[i] == "checkBox2"){ 
     205                                        document.getElementById(mark_values[i]).checked = true; 
     206                                } 
     207                                if( mark_values[i] == "select_size=1" || mark_values[i] == "select_rules=1"){ 
     208                                        var mark_val = mark_values[i].split("="); 
     209                                        document.getElementById(mark_val[0]).options[mark_val[1]].selected = true; 
     210                                } 
    172211                        } 
    173212                } 
     
    224263         * quando a caixa de seleção para manter o e-mail na caixa de entrada do usuário for selecionada 
    225264         */ 
    226         cfilter.prototype.disable_radio3 =  function(){ 
    227  
     265        cfilter.prototype.disable_radio3 =  function() 
     266        { 
    228267                radio3 = Element('radio3'); 
    229268                field6 = Element('field6'); 
    230269                cb2 = Element('checkBox2'); 
    231270 
    232                 if (cb2.checked){ 
     271                if (cb2.checked) 
     272                { 
    233273                        radio3.disabled = true; 
    234274                        field6.disabled = true; 
    235275 
    236                         if (radio3.checked){ 
     276                        if (radio3.checked) 
     277                        { 
    237278                                radio3.checked = false; 
    238279                        } 
    239280                } 
    240                 else{ 
     281                else 
     282                { 
    241283                        radio3.disabled = false; 
    242284                        field6.disabled = false; 
     
    245287        } 
    246288 
    247         cfilter.prototype.forms_ = function(){ 
    248                         var form   = ""; 
    249                         form       = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
    250                                                  "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+ 
    251                                                  "<tr><td colspan='2'><input type='checkBox' id='checkBox2' onclick='filter.disable_radio3();' name='checkb'>"+get_lang('Keep a copy of the message at your Inbox')+ "</td><tr>"+ 
    252                                                  "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+ 
    253                                                  "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+ 
    254                                                  "<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+ 
    255                                                  "</select></td><td>"+get_lang('The field \"%1\" of the message it contains',get_lang('From'))+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+ 
    256                                                  "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('To'))+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+ 
    257                                                  "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('Subject'))+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+ 
    258                                                  "</tr><tr><td>"+get_lang('The size of the message is')+".: &nbsp<select id='select_size' name='select_size'>"+ 
    259                                                  "<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+                                           
    260                                                  "</select>&nbsp;<input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+ 
    261                                                  "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+ 
    262                                                  "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
    263                                                  "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+ 
    264                                                  "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+ 
    265                                                  "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+ 
    266                                                  "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+ 
    267                                                  "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+ 
    268                                                  "<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+ 
    269                                                  "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+ 
    270                                                  "</tr></table></div><div id='div_vacation' style='display:none'>"+ 
    271                                                  "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
    272                                                  "<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+ 
    273                                                  //"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+ 
    274                                                  "<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+ 
    275                                                  "</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>"+ 
    276                                                  "<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+ 
    277                                                  "<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>";                                            
     289        cfilter.prototype.forms_ = function() 
     290        { 
     291                         var form = ""; 
     292                                 form = "<div id='div_rule' style='display:none'><table id='table_rule' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
     293                                                "<tr><td colspan='2'><input type='checkBox' id='checkBox1' name='checkb'>"+get_lang('Also check message against next rule') + "</td></tr>"+ 
     294                                                "<tr><td colspan='2'><input type='checkBox' id='checkBox2' onclick='filter.disable_radio3();' name='checkb'>"+get_lang('Keep a copy of the message at your Inbox')+ "</td><tr>"+ 
     295                                                "<tr><td colspan='2'><hr size='1' width='100%'></td></tr><tr>"+ 
     296                                                "<td rowspan='4' width='20%'>"+get_lang('Coincident')+"<br><select id='select_rules' name='select_rules'>"+ 
     297                                                "<option value='0'>"+get_lang("with all")+"</option><option value='1'>"+get_lang("with some")+"</option>"+ 
     298                                                "</select></td><td>"+get_lang('The field \"%1\" of the message it contains',get_lang('From'))+".: <input type='text' id='field1' name='field1' size='35' maxlength='200'></td>"+ 
     299                                                "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('To'))+".: <input type='text' id='field2' name='field2' size='35' maxlength='200'></td>"+ 
     300                                                "</tr><tr><td>"+get_lang('The field \"%1\" of the message it contains', get_lang('Subject'))+".: <input type='text' id='field3' name='field3' size='35' maxlength='200'></td>"+ 
     301                                                "</tr><tr><td>"+get_lang('The size of the message is')+".: &nbsp<select id='select_size' name='select_size'>"+ 
     302                                                "<option value='0'>"+get_lang("Less than")+"</option><option value='1'>"+get_lang("Greater than")+"</option>"+                                            
     303                                                "</select>&nbsp;<input type='text' id='field4' name='field4' size='8' maxlength='8'> Kb</td>"+ 
     304                                                "</tr><tr><td colspan='2'><hr size='1' width='100%'></td></tr>"+ 
     305                                                "</table><table id='table_rule1' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
     306                                                "<tr><td width='50%'><input type='radio' id='radio1' name='radio' value='folder'>"+get_lang('Store at')+".:</td>"+ 
     307                                                "<td width='50%'><select id='select_mailboxes' name='select_mailboxes'></select></td>"+ 
     308                                                "</tr><tr><td width='50%'><input type='radio' id='radio2' name='radio' value='address'>"+get_lang('Forward to the address')+".:</td>"+ 
     309                                                "<td width='50%'><input type='text' id='field5' name='field5' size='35' maxlength='70'></td>"+ 
     310                                                "</tr><tr><td width='50%'><input type='radio' id='radio3' name='radio' value='reject'>"+get_lang('Send a rejection message')+".:</td>"+ 
     311                                                "<td width='50%'><textarea id='field6' onkeypress='return charCounter(this);' name='field6' rows='3' cols='25'></textarea></td>"+ 
     312                                                "</tr><tr><td colspan='2'><input type='radio' id='radio4' name='radio' value='discard'>"+get_lang('Erase the message')+"</td>"+ 
     313                                                "</tr></table></div><div id='div_vacation' style='display:none'>"+ 
     314                                                "<table id='table_vacation' border='0' cellpading='0' cellspacing='0' width='100%'>"+ 
     315                                                "<tr><td colspan='3'><br><b>"+get_lang('out office')+"</b></td></tr>"+ 
     316                                                //"<tr><td colspan='3'><br>"+get_lang('Subject')+".: <input type='text' id='field7' name='field7' size='35' maxlength='200'/></td></tr>"+ 
     317                                                "<tr><td colspan='3'><br>"+get_lang('With the following message')+".:</td>"+ 
     318                                                "</tr><tr><td colspan='3'><textarea id='field8' onkeypress='return charCounter(this);' rows='8' cols='50'></textarea></td></tr></table></div>" + 
     319                                                "<div id='div_voipFilter' style='display:none'>" + 
     320                                                "<br/><table id='table_voipFilter'>" + 
     321                                                "<tr><td>"+get_lang("Type the subject of the message for receiving a phone warning")+" .:"+ 
     322                                                "</td></tr><tr><td><input type='text' id='field9' size='50' maxlength='200'>" + 
     323                                                "</td></tr><br/></table></div>" + 
     324                                                "<span align='right'><input type='button' value="+get_lang("Back")+" onclick='filter.form_m()'></span>"+ 
     325                                                "<span align='right'><input type='button' value="+get_lang("Save")+" onclick='filter.saved_rules()'></span>"; 
    278326                return form; 
    279327        } 
     
    314362                        } 
    315363                } 
     364 
     365                // Voip 
     366                if(Element("voip_rule_0") != null){ 
     367                        for(var i=0; i < this.rulesVoip.length; i++){ 
     368                                if(Element("voip_rule_"+i).checked){ 
     369                                        var aux_rul = this.rulesVoip[i].split("&&"); 
     370                                        if(aux_rul[2] != param){ 
     371                                                aux_rul[2] = param;                                      
     372                                                var rl = ""; 
     373                                                for(var j=0; j < aux_rul.length; j++){ 
     374                                                        rl += aux_rul[j] + "&&"; 
     375                                                } 
     376                                                rl = rl.substr(0,(rl.length - 2)); 
     377                                                this.rulesVoip[i] = rl;                                  
     378                                        } 
     379                                } 
     380                        } 
     381                } 
     382                 
    316383                this.reload_rules(); 
    317384        } 
     
    347414        } 
    348415         
    349         cfilter.prototype.e_newrule = function(nw_rule){ 
     416        cfilter.prototype.e_newrule = function(nw_rule) 
     417        { 
    350418 
    351419                var new_rl = ""; 
     
    399467                        } 
    400468                } 
     469                 
     470                // Voip 
     471                if(Element("voip_rule_0") != null){ 
     472                        for(var i=0; i < _this.rulesVoip.length; i++){ 
     473                                if(Element("voip_rule_"+i).checked){_this.rulesVoip[i] = "delete";} 
     474                        } 
     475                        for(var i=0; i < _this.rulesVoip.length; i++){ 
     476                                if(_this.rulesVoip[i] == "delete"){_this.rulesVoip.splice(i,1);i--;} 
     477                        } 
     478                } 
     479         
     480                if(_this.rulesVoip.length > 0){ 
     481                        var cont = parseInt(1); 
     482                        for(var i=0; i < _this.rulesVoip.length ; i++){ 
     483                                var n_rulest = _this.rulesVoip[i].split("&&"); 
     484                                n_rulest[1] = cont; 
     485                                cont = cont + parseInt(2); 
     486                                var aux = ""; 
     487                                for(var j=0; j < n_rulest.length; j++){aux += n_rulest[j] + "&&";} 
     488                                aux = aux.substr(0,(aux.length - 2)); 
     489                                _this.rulesVoip[i] = aux; 
     490                        } 
     491                }  
     492 
    401493                _this.reload_rules(); 
    402494        } 
    403495         
    404         cfilter.prototype.reload_rules = function(){ 
     496        cfilter.prototype.reload_rules = function() 
     497        { 
    405498                this.saved_all(); 
    406499                Element('form_body').innerHTML = ""; 
    407500                this.load_rules(); 
    408                  
    409                 if(this.out_officeF){ 
     501 
     502                if(this.out_officeF) 
     503                { 
    410504                        write_msg(get_lang("Attention, you are in out of office mode."), true); 
    411                 }else { 
     505                }else{ 
    412506                        clean_msg(); 
    413507                        this.out_officeF = false; 
     
    422516                var n_rule = ""; 
    423517 
    424                 if(form[1] == "rule"){ 
     518                if(form[1] == "rule") 
     519                { 
    425520                        mount_rule = "#rule&&"; 
    426                         if(form[0] == "new"){ 
     521                        if(form[0] == "new") 
     522                        { 
    427523                                n_rule = "1&&"; 
    428                                 if(this.rulest.length > 0){ 
     524                                if(this.rulest.length > 0) 
     525                                { 
    429526                                        aux = this.rulest[this.rulest.length - parseInt(1)].split("&&"); 
    430527                                        n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; 
    431528                                } 
    432529                                mount_rule += n_rule + "ENABLED&&"; 
    433                         }else{ 
     530                        } 
     531                        else 
     532                        { 
    434533                                n_rule = this.rulest[this.ind].split("&&"); 
    435534                                mount_rule += n_rule[1] + "&&"; 
     
    503602                        } 
    504603                        if(form[0] == "new") 
     604                        { 
    505605                                this.rulest[this.rulest.length] = mount_rule; 
     606                        } 
    506607                        else 
    507608                                this.rulest[this.ind] = mount_rule; 
    508                 }else{ 
     609                } 
     610                else if(form[1] == "out") 
     611                { 
    509612                        mount_rule = ""; 
    510613                        var fld_emails = this.email_ld; // Get first email of list! 
     
    522625                        this.out_officeR = mount_rule; 
    523626                } 
     627                else if(form[1] == "voip") 
     628                { 
     629                        if( Element("field9").value != "" && LTrim(Element("field9").value) != "" ) 
     630                        { 
     631                                mount_rule = "#rule&&"; 
     632                                if(form[0] == "new") 
     633                                { 
     634                                        n_rule = "1&&"; 
     635                                        if( this.rulesVoip.length > 0 ) 
     636                                        { 
     637                                                aux = this.rulesVoip[this.rulesVoip.length - parseInt(1)].split("&&"); 
     638                                                n_rule = (parseInt(aux[1]) + parseInt(2)) + "&&"; 
     639                                        } 
     640                                        mount_rule += n_rule + "ENABLED&&"; 
     641                                } 
     642                                else 
     643                                { 
     644                                        n_rule = this.rulesVoip[this.ind].split("&&"); 
     645                                        mount_rule += n_rule[1] + "&&"; 
     646                                        mount_rule += n_rule[2] + "&&"; 
     647                                } 
     648 
     649                                if ( Element("field9").value.indexOf("#") >= 0 ) 
     650                                { 
     651                                        alert(get_lang('Caracter "#" is not allowed!')); 
     652                                        return false; 
     653                                } 
     654                                 
     655                                mount_rule = mount_rule + "&&&&" + Element("field9").value + "&&notify&&" + preferences.voip_email_redirect + "&&8&&&&&&0"; 
     656 
     657                                if( form[0] == "new" ) 
     658                                { 
     659                                        this.rulesVoip[this.rulesVoip.length] = mount_rule; 
     660                                } 
     661                                else 
     662                                { 
     663                                        this.rulesVoip[this.ind] = mount_rule; 
     664                                } 
     665                        } 
     666                        else 
     667                        { 
     668                                alert( 'CAMPOS EM BRANCO !!' ); 
     669                                return false; 
     670                        } 
     671                } 
     672                 
    524673                Element('form_buttons').style.display = ''; 
    525674                this.reload_rules(); 
    526675        } 
    527676 
    528         cfilter.prototype.close_frm= function(){ 
     677        cfilter.prototype.close_frm= function() 
     678        { 
    529679                filters.filter_Sh['window_ffilter_ccform'].close(); 
    530680        } 
    531681         
    532         cfilter.prototype.saved_all = function(){ 
     682        cfilter.prototype.saved_all = function() 
     683        { 
    533684                var aux_rul = ""; 
    534685                var _this = this; 
    535                 if(_this.rulest.length > 0){ 
    536                         for(var i=0; i < _this.rulest.length; i++){ 
    537                                 var aux = _this.rulest[i].split("&&");                           
     686                var cont = 0; 
     687                 
     688                // Regras Gerais 
     689                if(_this.rulest.length > 0) 
     690                { 
     691                        for(var i=0; i < _this.rulest.length; i++) 
     692                        { 
     693                                var fieldsNormal = _this.rulest[i].split("&&");                          
    538694                                aux_rul += "_begin_##"; 
    539                                 for(var j=0 ; j < aux.length; j++){ 
    540                                         if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);} 
    541                                         else{aux_rul += url_encode(aux[j]) + "##";} 
     695                                for(var j=0 ; j < fieldsNormal.length; j++) 
     696                                { 
     697                                        aux_rul += url_encode(fieldsNormal[j]) + "##"; 
     698                                        cont = parseInt(fieldsNormal[1]);                                        
    542699                                }        
    543700                                aux_rul += "_end_\n"; 
    544701                        } 
    545702                } 
    546                 if(_this.out_officeR.length > 0){ 
     703         
     704                // Voip 
     705                if(_this.rulesVoip.length > 0) 
     706                { 
     707                        for(var i=0; i < _this.rulesVoip.length; i++) 
     708                        { 
     709                                var fieldsVoip = _this.rulesVoip[i].split("&&"); 
     710                                aux_rul += "_begin_##"; 
     711                                for(var j=0 ; j < fieldsVoip.length; j++) 
     712                                { 
     713                                        if(j == 1) 
     714                                        { 
     715                                                if( cont == 0 ) 
     716                                                        cont = parseInt(1); 
     717                                                else 
     718                                                        cont = parseInt(cont) + parseInt(2); 
     719                                                aux_rul += cont; 
     720                                                aux_rul += "##"; 
     721                                        } 
     722                                        else 
     723                                                aux_rul += url_encode(fieldsVoip[j]) + "##"; 
     724                                } 
     725                                aux_rul += "_end_\n"; 
     726                        } 
     727                } 
     728                 
     729                // Fora do Escritório 
     730                if(_this.out_officeR.length > 0) 
     731                { 
    547732                                var aux = _this.out_officeR.split("&&");                                 
    548733                                aux_rul += "_begin_##"; 
    549                                 for(var j=0 ; j < aux.length; j++){ 
    550                                         if( (j +1) > aux.length){aux_rul += url_encode(aux[j]);} 
    551                                         else{aux_rul += url_encode(aux[j]) + "##";} 
     734                                for(var j=0 ; j < aux.length; j++) 
     735                                { 
     736                                        aux_rul += url_encode(aux[j]) + "##";                                    
    552737                                }        
    553738                                aux_rul += "_end_\n"; 
    554                                 _this.out_officeF = (aux[4].replace("\n","") == "off") ? false : true; 
     739                                _this.out_officeF = (aux[4].replace("\n","") === "off") ? false : true; 
    555740                                //Save outoffice in prefs: 
    556741                                connector.loadScript("preferences"); 
    557742                                prefe.save("outoffice", _this.out_officeF); 
    558743                } 
    559                 var h_filter = function(data){ 
     744                 
     745                var h_filter = function(data) 
     746                { 
    560747                        if(data != "Ok"){alert("Erro : \n" + data);} 
    561748                } 
Note: See TracChangeset for help on using the changeset viewer.