[6392] | 1 | /* Verifica se a regra fora de escritório está ativa */ |
---|
[6452] | 2 | function outOfficeVerify() { |
---|
[5950] | 3 | DataLayer.remove('filter', false); |
---|
| 4 | var filters = DataLayer.get("filter"); |
---|
| 5 | var outoffice_active = false; |
---|
[6021] | 6 | outoffice = false; |
---|
[5950] | 7 | for(var index in filters){ |
---|
| 8 | if(filters[index].id == "vacation") |
---|
| 9 | outoffice = true; |
---|
| 10 | if(filters[index].id == "vacation" && filters[index].enabled == "true"){ |
---|
[6452] | 11 | write_msg(get_lang("Attention, you are in out of office mode."), true); |
---|
[5950] | 12 | outoffice_active = true; |
---|
| 13 | break; |
---|
| 14 | } |
---|
| 15 | } |
---|
[6021] | 16 | if(!outoffice_active) |
---|
| 17 | clean_msg(); |
---|
[5950] | 18 | } |
---|
| 19 | |
---|
[6392] | 20 | /* Valida as informações do formulário de filtro de mensagens */ |
---|
[5591] | 21 | valid_save = function(){ |
---|
[5662] | 22 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
[5598] | 23 | if(list_container.find('[name="name"]').attr("disabled") != "disabled") |
---|
[5591] | 24 | { |
---|
[5598] | 25 | if($.trim(list_container.find('[name="name"]').val()) == ""){ |
---|
[5801] | 26 | $.Zebra_Dialog(get_lang("No name filled"),{ |
---|
[5662] | 27 | 'onClose': function(caption) { |
---|
| 28 | list_container.find('[name="name"]').focus(); |
---|
| 29 | } |
---|
| 30 | }); |
---|
| 31 | accord.accordion('activate',0); |
---|
[5591] | 32 | return false; |
---|
[5598] | 33 | }else if($.trim(list_container.find('[name="name"]').val()) == "vacation"){ |
---|
[5801] | 34 | $.Zebra_Dialog(get_lang("Invalid name, 'vacation' is a reserved word"),{ |
---|
[5662] | 35 | 'onClose': function(caption) { |
---|
| 36 | list_container.find('[name="name"]').val("").focus(); |
---|
| 37 | } |
---|
| 38 | }); |
---|
| 39 | accord.accordion('activate',0); |
---|
[5591] | 40 | return false; |
---|
| 41 | }else{ |
---|
| 42 | filter_list = DataLayer.get("filter", true); |
---|
| 43 | var error = false; |
---|
| 44 | $.each(filter_list, function(index, value){ |
---|
[5598] | 45 | if(filter_list[index].name == list_container.find('[name="name"]').val()){ |
---|
[5801] | 46 | $.Zebra_Dialog(get_lang("There is already a filter with this name"),{ |
---|
[5662] | 47 | 'onClose': function(caption) { |
---|
| 48 | list_container.find('[name="name"]').val("").focus(); |
---|
| 49 | } |
---|
| 50 | }); |
---|
| 51 | accord.accordion('activate',0); |
---|
[5591] | 52 | error = true; |
---|
| 53 | return; |
---|
[6452] | 54 | } |
---|
[5591] | 55 | }); |
---|
| 56 | if(error){ |
---|
| 57 | return false; |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | var criteria = ""; |
---|
[5598] | 62 | var criteria_list = list_container.find('[name="criteriaValue[]"]'); |
---|
[6126] | 63 | var er_num = /^[0-9]+$/; |
---|
[6452] | 64 | |
---|
[6126] | 65 | if($(".sizeRule").val() != "" && er_num.test($(".sizeRule").val()) == false) { |
---|
| 66 | $.Zebra_Dialog(get_lang("Size rule must be a number"),{ |
---|
| 67 | 'onClose': function(caption) { |
---|
| 68 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 69 | } |
---|
| 70 | }); |
---|
| 71 | accord.accordion('activate',0); |
---|
| 72 | return false; |
---|
| 73 | } |
---|
[5591] | 74 | $.each(criteria_list, function(index, value){ |
---|
| 75 | criteria += $.trim($(criteria_list[index]).val()); |
---|
| 76 | }); |
---|
[6144] | 77 | if(criteria == ""){ |
---|
[5801] | 78 | $.Zebra_Dialog(get_lang("No criteria filled"),{ |
---|
[5662] | 79 | 'onClose': function(caption) { |
---|
| 80 | list_container.find('[name="criteriaValue[]"]:first').focus(); |
---|
| 81 | } |
---|
| 82 | }); |
---|
| 83 | accord.accordion('activate',0); |
---|
[5591] | 84 | return false; |
---|
| 85 | } |
---|
[5598] | 86 | if(list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").length){ |
---|
| 87 | if($.trim(list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").val()) == ""){ |
---|
[5801] | 88 | $.Zebra_Dialog(get_lang("Fill the action value"),{ |
---|
[5662] | 89 | 'onClose': function(caption) { |
---|
| 90 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 91 | } |
---|
| 92 | }); |
---|
[5591] | 93 | return false; |
---|
| 94 | } |
---|
[6126] | 95 | var er_mail = RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/); |
---|
[6392] | 96 | if(er_mail.test($.trim(list_container.find('[value="redirect"]:checked').parent().find("input:text").val())) == false && list_container.find('[name="actionType[]"]:checked').val() == 'redirect'){ |
---|
[6126] | 97 | $.Zebra_Dialog(get_lang("Invalid mail"),{ |
---|
| 98 | 'onClose': function(caption) { |
---|
| 99 | list_container.find('[name="actionType[]"]:checked').parent().find("input:text, textarea").focus(); |
---|
| 100 | } |
---|
| 101 | }); |
---|
| 102 | return false; |
---|
| 103 | } |
---|
[5591] | 104 | } |
---|
| 105 | return true; |
---|
| 106 | }; |
---|
| 107 | |
---|
[6392] | 108 | function urlencode (str) { |
---|
| 109 | str = (str + '').toString(); |
---|
| 110 | return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28'). |
---|
| 111 | replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+'); |
---|
| 112 | } |
---|
| 113 | |
---|
[5341] | 114 | bytes2Size = function(bytes) { |
---|
| 115 | var sizes = ['B', 'KB', 'MB', 'GB', 'TB']; |
---|
| 116 | if (bytes === 0) return 'n/a'; |
---|
| 117 | var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); |
---|
| 118 | var size = (i<2) ? Math.round((bytes / Math.pow(1024, i))) : Math.round((bytes / Math.pow(1024, i)) * 100)/100; |
---|
| 119 | return size + ' ' + sizes[i]; |
---|
| 120 | }; |
---|
| 121 | |
---|
| 122 | flags2Class = function(cellvalue) { |
---|
| 123 | var flags_enum = cellvalue.split(','); |
---|
| 124 | var classes = ''; |
---|
| 125 | for (var i=0; i<flags_enum.length; i++){ |
---|
| 126 | classes += '<span class="icon-'+flags_enum[i].toLowerCase()+'"> </span>'; |
---|
| 127 | } |
---|
| 128 | return classes; |
---|
| 129 | }; |
---|
| 130 | |
---|
| 131 | date2Time = function (timestamp) { |
---|
| 132 | var date = new Date(); |
---|
[6452] | 133 | if( typeof timestamp === "string" ) |
---|
| 134 | timestamp = parseInt( timestamp, 10 ); |
---|
[5341] | 135 | if ((date.getTime() - timestamp) < (24*60*60*1000)) { |
---|
| 136 | return '<span class="timable" title="'+timestamp+'"> </span>'; |
---|
| 137 | } else { |
---|
| 138 | date = new Date(timestamp); |
---|
| 139 | var b = date.toISOString().split("T")[0].split("-"); |
---|
| 140 | var c = b[2] + "/" + b[1] + "/" + b[0]; |
---|
| 141 | return '<span class="datable">' + c + '</span>'; |
---|
| 142 | } |
---|
| 143 | }; |
---|
| 144 | |
---|
| 145 | keys = function( object ){ |
---|
[6452] | 146 | |
---|
[5341] | 147 | var array = []; |
---|
[6452] | 148 | |
---|
[5341] | 149 | for( var key in object ) |
---|
| 150 | array[ array.length ] = key; |
---|
[6452] | 151 | |
---|
[5341] | 152 | return( array ); |
---|
| 153 | |
---|
| 154 | } |
---|
| 155 | |
---|
[6392] | 156 | /* Mostra os detalhes do filtro para edição */ |
---|
[5341] | 157 | showDetails = function( filter ){ |
---|
[6452] | 158 | |
---|
[5341] | 159 | form.get(0).reset(); |
---|
| 160 | |
---|
| 161 | nameObj.val( filter.name ); |
---|
[5539] | 162 | nameObj.attr("disabled", "disabled"); |
---|
[5341] | 163 | for( var i = 0; i < filter.criteria.length; i++ ){ |
---|
[6348] | 164 | if(filter.criteria[i].field == 'hasAttachment') { |
---|
| 165 | $(".hasAttachment").attr("checked", "True"); |
---|
| 166 | continue; |
---|
| 167 | } |
---|
[5630] | 168 | criterias.filter( '[value="' + filter.criteria[i].field + '"]' ) |
---|
| 169 | .siblings( '[name="criteriaOperator[]"]' ).val( filter.criteria[i].operator ).end() |
---|
| 170 | .siblings( '[name="criteriaValue[]"]' ).val( filter.criteria[i].value ); |
---|
[5341] | 171 | } |
---|
| 172 | for( var i = 0; i < filter.actions.length; i++ ){ |
---|
[5539] | 173 | actions.filter( '[value="' + filter.actions[i].type + '"]' ).attr("checked", "True"); |
---|
| 174 | actions.filter( '[value="' + filter.actions[i].type + '"]' ).val( filter.actions[i].type ) |
---|
| 175 | .siblings( '[name="actionParameter[]"]' ).val( filter.actions[i].parameter ); |
---|
| 176 | if(filter.actions[i].type == "redirect") |
---|
| 177 | actions.siblings('[name="addressRedirect"]').val(filter.actions[i].parameter); |
---|
[6452] | 178 | if(filter.actions[i].type == "reject") |
---|
[5539] | 179 | actions.siblings('[name="messageReject"]').val(filter.actions[i].parameter); |
---|
[5632] | 180 | if(filter.actions[i].type == "fileinto" || filter.actions[i].type == "setflag") |
---|
| 181 | actions.parent().find('[value="'+filter.actions[i].parameter+'"]').attr("selected", "selected"); |
---|
[5341] | 182 | } |
---|
[6452] | 183 | isExact.filter('[value="'+(filter.isExact != "false"? "and" : "or")+'"]').attr("checked", "True"); |
---|
[5341] | 184 | } |
---|
| 185 | |
---|
| 186 | |
---|
| 187 | DataLayer.codec( "filter", "detail", { |
---|
[6452] | 188 | |
---|
[5341] | 189 | decoder: function( form ){ |
---|
| 190 | if( form.vacation ) |
---|
| 191 | return { |
---|
[5539] | 192 | criteria: [{ value: "vacation", operator: "", field: "vacation" }], |
---|
| 193 | actions: [{ parameter: form.vacation, type: "vacation" }], |
---|
[5341] | 194 | id: "vacation", |
---|
| 195 | name: "vacation", |
---|
[5627] | 196 | isExact: false, |
---|
| 197 | applyMessages : "", |
---|
[5902] | 198 | enabled : true |
---|
[5341] | 199 | } |
---|
| 200 | |
---|
[6143] | 201 | var apply_messages_ = keys(selectedMessages); |
---|
[6452] | 202 | |
---|
[6392] | 203 | action = ''; |
---|
[6452] | 204 | |
---|
[6143] | 205 | return { |
---|
[6168] | 206 | name: form.name ? form.name.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') : nameObj.val().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), |
---|
[5341] | 207 | isExact: ( form.isExact === "and" ), |
---|
[6452] | 208 | criteria: $.map( form.criteriaOperator || [], function( criteriaOperator, i ){ |
---|
[5341] | 209 | return (!form.criteriaValue[i]) ? null: |
---|
[6452] | 210 | { |
---|
[6168] | 211 | value: form.criteriaValue[i].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'), |
---|
[6143] | 212 | operator: criteriaOperator, |
---|
[6168] | 213 | field: form.criteriaType[i].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') |
---|
[6143] | 214 | }; |
---|
[5341] | 215 | }), |
---|
| 216 | actions: $.map( form.actionType || [], function( type, i ){ |
---|
[5539] | 217 | var the_parameter = form.actionParameter[i]; |
---|
[6452] | 218 | |
---|
[5539] | 219 | !the_parameter ? the_parameter = form.actionParameter[i+1] : ""; |
---|
[6452] | 220 | if (type == 'fileinto') { |
---|
[5539] | 221 | the_parameter = form.valueFileInto; |
---|
| 222 | } |
---|
| 223 | if (type == 'reject') { |
---|
| 224 | the_parameter = form.messageReject; |
---|
| 225 | } |
---|
[6452] | 226 | if (type == 'fileintoInbox') { |
---|
[5591] | 227 | if(!$('[value="fileintoInbox"]').parent().hasClass("hidden")){ |
---|
| 228 | type = 'fileinto'; |
---|
| 229 | the_parameter = 'INBOX'; |
---|
| 230 | }else{ |
---|
| 231 | return; |
---|
| 232 | } |
---|
[5539] | 233 | } |
---|
| 234 | if (type == 'fileintoTrash') { |
---|
| 235 | type = 'fileinto'; |
---|
[6363] | 236 | the_parameter = 'INBOX' + cyrus_delimiter + 'Trash'; |
---|
[5539] | 237 | } |
---|
| 238 | if (type == 'redirect') { |
---|
| 239 | the_parameter = form.addressRedirect; |
---|
| 240 | } |
---|
[6452] | 241 | if (type == 'setflag') { |
---|
[5539] | 242 | the_parameter = form.valueSetFlag; |
---|
[6392] | 243 | action = form.valueSetFlag; |
---|
[5539] | 244 | } |
---|
[5341] | 245 | return (!type) ? null: |
---|
[5539] | 246 | {parameter: the_parameter, type: type }; |
---|
[5341] | 247 | |
---|
| 248 | }), |
---|
[5902] | 249 | enabled : true, |
---|
[6452] | 250 | applyMessages: apply_messages_ |
---|
[6143] | 251 | }; |
---|
[5341] | 252 | }, |
---|
[6452] | 253 | |
---|
[5341] | 254 | encoder: function( filters ){ |
---|
| 255 | var rules = []; |
---|
| 256 | |
---|
| 257 | for( var id in filters ) |
---|
| 258 | rules[ rules.length ] = filters[id]; |
---|
| 259 | |
---|
| 260 | return { rules: rules }; |
---|
| 261 | |
---|
| 262 | } |
---|
[6452] | 263 | |
---|
[5341] | 264 | }); |
---|
| 265 | |
---|
[6392] | 266 | /* Codec do datalayer */ |
---|
[5341] | 267 | DataLayer.codec( "folder", "select", { |
---|
[6452] | 268 | |
---|
[5341] | 269 | decoder:function(){ |
---|
[6452] | 270 | |
---|
[5341] | 271 | }, |
---|
| 272 | encoder:function( data ){ |
---|
[6452] | 273 | |
---|
[5341] | 274 | var tree1 = [], tree2 = [], tree3 = []; |
---|
| 275 | |
---|
| 276 | for (var i=0; i<data.length; i++) { |
---|
| 277 | |
---|
| 278 | if (/^INBOX/.test(data[i].id)) { |
---|
| 279 | if (!unorphanize(tree1, data[i])) { |
---|
| 280 | data[i].children = []; |
---|
| 281 | tree1.push(data[i]); |
---|
| 282 | } |
---|
| 283 | } |
---|
| 284 | else if (/^user/.test(data[i].id)) { |
---|
| 285 | if (!unorphanize(tree2, data[i])) { |
---|
| 286 | data[i].children = []; |
---|
| 287 | tree2.push(data[i]); |
---|
| 288 | } |
---|
| 289 | } |
---|
| 290 | else if (/^local_messages/.test(data[i].id)) { |
---|
| 291 | if (!unorphanize(tree3, data[i])) { |
---|
| 292 | data[i].children = []; |
---|
| 293 | tree3.push(data[i]); |
---|
| 294 | } |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | } |
---|
[6452] | 298 | |
---|
[5341] | 299 | return {folders: [ tree1, tree2, tree3 ]}; |
---|
| 300 | |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | }); |
---|
| 304 | |
---|
| 305 | var BASE_PATH = '../prototype/'; |
---|
| 306 | |
---|
| 307 | DataLayer.basePath = BASE_PATH + "REST.php?q="; |
---|
| 308 | DataLayer.dispatchPath = BASE_PATH; |
---|
| 309 | |
---|
| 310 | var selectedMessages = {}; |
---|
| 311 | var allMessages = false; |
---|
| 312 | |
---|
[6392] | 313 | /* Bloqueio de usuários na tela de mensagem do ExpressoMail */ |
---|
[6452] | 314 | function block_user_email(email) { |
---|
[6392] | 315 | delete selectedMessages; |
---|
| 316 | var idd = urlencode(email); |
---|
[5762] | 317 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 318 | DataLayer.remove('filter', false); |
---|
| 319 | var filters = DataLayer.get('filter'); |
---|
[5654] | 320 | for(var index in filters){ |
---|
| 321 | if(filters[index].name == email) { |
---|
[5801] | 322 | if(confirm(get_lang("This user is already blocked. Would you like to unlock it?"))) { |
---|
[5655] | 323 | DataLayer.remove( 'filter', filters[index].id ); |
---|
[5762] | 324 | DataLayer.commit("filter", false, function(){ |
---|
[5801] | 325 | $.Zebra_Dialog(get_lang("Lock User") + " " + email + " " + get_lang("removed")); |
---|
[5762] | 326 | list_filters(); |
---|
| 327 | }); |
---|
[5654] | 328 | return true; |
---|
[5662] | 329 | }else |
---|
| 330 | return true; |
---|
[5654] | 331 | } |
---|
| 332 | } |
---|
[5801] | 333 | if(confirm(get_lang("Want to block the user") + " " + email + "?")){ |
---|
[6452] | 334 | DataLayer.put( 'filter', idd, |
---|
| 335 | { name: email, isExact: false, |
---|
[5630] | 336 | criteria:{ 0: {value: email, operator: "=", field: "from"} }, |
---|
[6452] | 337 | actions: { 0: {parameter: "INBOX" + cyrus_delimiter + "Spam", type: "fileinto"}}, |
---|
| 338 | enabled: true, |
---|
[5630] | 339 | id: email, |
---|
[6452] | 340 | block: true |
---|
[5630] | 341 | }); |
---|
[5762] | 342 | DataLayer.commit("filter", false, function(){ |
---|
[5801] | 343 | $.Zebra_Dialog(get_lang("User") + " " + email + " " + get_lang("blocked")); |
---|
[5762] | 344 | list_filters(); |
---|
| 345 | }); |
---|
[6452] | 346 | |
---|
[5762] | 347 | } |
---|
[5630] | 348 | } |
---|
| 349 | |
---|
[6443] | 350 | |
---|
| 351 | DataLayer.codec( 'message', 'jqGrid', { |
---|
[6452] | 352 | |
---|
[6443] | 353 | encoder: function( data ){ |
---|
| 354 | |
---|
| 355 | return( data ); |
---|
| 356 | |
---|
| 357 | } |
---|
| 358 | }); |
---|
| 359 | |
---|
[6392] | 360 | /* Gerencia o grid das mensagens da caixa de entrada */ |
---|
[6048] | 361 | function showGridMessages(thiss) { |
---|
| 362 | var criteria_list = list_container.find('[name="criteriaValue[]"]'); |
---|
| 363 | var criteria_operator_list = list_container.find('[name="criteriaOperator[]"]'); |
---|
| 364 | var criteria_value = ""; |
---|
| 365 | var criteria = ""; |
---|
| 366 | $.each(criteria_list, function(index, value){ |
---|
| 367 | criteria += $.trim($(criteria_list[index]).val()) + ","; |
---|
| 368 | }); |
---|
| 369 | var criteria_ = criteria.split(","); |
---|
| 370 | var criteria_operator = ""; |
---|
| 371 | $.each(criteria_operator_list, function(index, value){ |
---|
| 372 | criteria_operator += $.trim($(criteria_list[index]).val()) != "" ? index + "," : ","; |
---|
| 373 | criteria_value += $.trim($(criteria_operator_list[index]).val()) + ","; |
---|
| 374 | }); |
---|
| 375 | var criteria_operator_ = criteria_operator.split(","); |
---|
| 376 | var criteria_value_ = criteria_value.split(","); |
---|
| 377 | var options = ["from", "to", "subject", "body", "size"]; |
---|
| 378 | var criterias_ = new Array(); |
---|
[6443] | 379 | |
---|
| 380 | for (i in criteria_) |
---|
| 381 | if(criteria_[i] != "") |
---|
[6452] | 382 | criterias_.push( criterias_.length ? {"0": "OR", "1": options[i], "2": criteria_value_[i], "3": criteria_[i]} : {"0": options[i], "1": criteria_value_[i], "2": criteria_[i]} ); |
---|
[6443] | 383 | |
---|
[6048] | 384 | showGridButton = thiss.parent(); |
---|
[6443] | 385 | |
---|
[6452] | 386 | showGridButton.siblings("#filtergrid-container").block({ |
---|
| 387 | message: '<div id="loading-content"><div class="image"></div></div>', |
---|
| 388 | css: { |
---|
| 389 | backgroundImage: 'url('+BASE_PATH+'modules/attach_message/images/loading.gif)', |
---|
| 390 | backgroundRepeat: 'no-repeat', |
---|
| 391 | backgroundPosition: 'center', |
---|
| 392 | backgroundColor: 'transparent', |
---|
| 393 | width: '32px', |
---|
| 394 | height: '32px', |
---|
| 395 | border:'none' |
---|
| 396 | }, |
---|
| 397 | overlayCSS: { |
---|
| 398 | backgroundColor: '#CCC', |
---|
| 399 | opacity: 0.5 |
---|
| 400 | } |
---|
[6443] | 401 | }); |
---|
[6387] | 402 | |
---|
[6443] | 403 | var data = DataLayer.get( 'message', { filter: criterias_, criteria: { properties: { context: { folder: 'INBOX' } } } }, true ); |
---|
[6452] | 404 | |
---|
[6443] | 405 | DataLayer.register( 'criterias', 'message:jqGrid', function( crit ){ |
---|
[6048] | 406 | |
---|
[6443] | 407 | crit.properties = { context: { folder: 'INBOX' } }; |
---|
[6452] | 408 | |
---|
[6443] | 409 | return { filter: [ "msgNumber", "IN", data ], criteria: crit }; |
---|
| 410 | }); |
---|
| 411 | |
---|
| 412 | allMessages = data; |
---|
[6452] | 413 | |
---|
| 414 | if (typeof grid !== "undefined") { |
---|
| 415 | grid.jqGrid( 'setGridParam', { url: 'message:jqGrid', postData: data } ).trigger( 'reloadGrid' ); |
---|
[6443] | 416 | //return; |
---|
| 417 | } |
---|
| 418 | grid = showGridButton.siblings("#filtergrid-container").removeClass('empty-container') |
---|
| 419 | .html('<table class="hidden fields-search-messages-grid" id="fields-search-messages-grid"><tr><td/></tr></table><div class="hidden fields-search-messages-grid-pager" id="fields-search-messages-grid-pager"></div>') |
---|
| 420 | .children(".fields-search-messages-grid, .fields-search-messages-grid-pager").removeClass('hidden').filter(".fields-search-messages-grid").trigger( 'reloadGrid' ).jqGrid({ |
---|
| 421 | url: 'message:jqGrid', |
---|
| 422 | datatype: "json", |
---|
| 423 | mtype: 'GET', |
---|
| 424 | colNames:['#', 'De', 'Assunto', 'Data', 'Tamanho'], |
---|
| 425 | colModel:[ |
---|
| 426 | {name:'msg_number',index:'msg_number', width:45, hidden:true, sortable:false}, |
---|
| 427 | {name:'from.email',index:'msg_number', width:130, sortable:false}, |
---|
| 428 | {name:'subject',index:'subject', width:250, sortable:false}, |
---|
| 429 | {name:'timestamp',index:'timestamp', width:65, align:"center", sortable:false, formatter:date2Time}, |
---|
| 430 | {name:'size',index:'size', width:50, align:"right", sortable:false, formatter:bytes2Size} |
---|
| 431 | ], |
---|
| 432 | jsonReader : { |
---|
| 433 | root:"rows", |
---|
| 434 | page: "page", |
---|
| 435 | total: "total", |
---|
| 436 | records: "records", |
---|
| 437 | repeatitems: false, |
---|
| 438 | id: "0" |
---|
| 439 | }, |
---|
| 440 | rowNum:10, |
---|
| 441 | //rowList:[10,25,50], |
---|
| 442 | rowList:[10], |
---|
| 443 | pager: '#fields-search-messages-grid-pager', |
---|
| 444 | sortname: 'id', |
---|
| 445 | viewrecords: true, |
---|
| 446 | sortorder: "desc", |
---|
| 447 | multiselect: true, |
---|
| 448 | autowidth: true, |
---|
| 449 | reloadAfterEdit: true, |
---|
| 450 | reloadAfterSubmit: true, |
---|
| 451 | height:200, |
---|
| 452 | loadComplete: function(data) { |
---|
| 453 | // // aplica o contador |
---|
| 454 | // jQuery('.timable').each(function (i) { |
---|
| 455 | // jQuery(this).countdown({ |
---|
[6452] | 456 | // since: new Date(parseInt(this.title)), |
---|
[6443] | 457 | // significant: 1, |
---|
[6452] | 458 | // layout: 'há {d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}', |
---|
[6443] | 459 | // description: ' atrás' |
---|
| 460 | // }); |
---|
| 461 | // }); |
---|
| 462 | }, |
---|
| 463 | onSelectRow: function (id, selected) { |
---|
[6452] | 464 | if( selected ) |
---|
[6443] | 465 | { |
---|
| 466 | selectedMessages[ id ] = true; |
---|
[6048] | 467 | } |
---|
[6443] | 468 | else |
---|
| 469 | { |
---|
| 470 | delete selectedMessages[ id ]; |
---|
| 471 | } |
---|
| 472 | }, |
---|
[6452] | 473 | onSelectAll: function (id, selected) { |
---|
[6443] | 474 | for (i in id) { |
---|
| 475 | if(selected) |
---|
| 476 | selectedMessages[id[i]] = true; |
---|
| 477 | else |
---|
[6452] | 478 | delete selectedMessages[id[i]]; |
---|
[6443] | 479 | } |
---|
| 480 | }, |
---|
| 481 | caption: 'Mensagens que atendem aos critérios' |
---|
| 482 | }); // end jqGrid |
---|
[6048] | 483 | } |
---|
| 484 | |
---|
[6392] | 485 | /* Gerencia a listagem de filtros do usuário */ |
---|
[5539] | 486 | function list_filters(html){ |
---|
[6021] | 487 | outOfficeVerify(); |
---|
[6392] | 488 | for (var index in selectedMessages) { |
---|
| 489 | delete selectedMessages[index]; |
---|
| 490 | } |
---|
[5539] | 491 | if(html){ |
---|
| 492 | if( ! $(".filters-windows").length ) |
---|
[5761] | 493 | container = $('.expressomail-module-container').append("<div class='filters-windows'></div>").find(".filters-windows").html( html ).find(".expresso-window-container"); |
---|
| 494 | list_container = $('.expressomail-module-container').find(".rule-list-container"); |
---|
[5539] | 495 | } |
---|
| 496 | list_container = $(".expresso-window-filters").dialog({ |
---|
| 497 | width:700, |
---|
| 498 | modal: true, |
---|
| 499 | resizable: false, |
---|
| 500 | closeOnEscape:true, |
---|
| 501 | close:function(event, ui) { |
---|
| 502 | event.stopPropagation(); |
---|
[5598] | 503 | if(list_container.find(".cancel").length) |
---|
[6452] | 504 | list_container.find(".cancel").trigger('click'); |
---|
[5627] | 505 | $(".dialog-head-buttonpane").hide(); |
---|
[5539] | 506 | }, |
---|
| 507 | open: function () { |
---|
| 508 | $(".ui-dialog .ui-dialog-titlebar") |
---|
| 509 | .append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>') |
---|
| 510 | .find('.ui-dialog-titlebar-minimize').click(function() { |
---|
| 511 | $(".ui-dialog-buttonpane, .ui-dialog-content").toggle(); |
---|
| 512 | $(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin'); |
---|
| 513 | }); |
---|
[5627] | 514 | $(".dialog-head-buttonpane").show(); |
---|
[5539] | 515 | }, |
---|
| 516 | autoOpen: false, |
---|
| 517 | buttons: [{ |
---|
[5801] | 518 | text : get_lang("Close"), |
---|
[5539] | 519 | click : function() { |
---|
| 520 | $( this ).dialog( "close" ); |
---|
| 521 | } |
---|
| 522 | }] |
---|
| 523 | }); |
---|
| 524 | $(".ui-dialog-titlebar").after("<div class='dialog-head-buttonpane ui-dialog-buttonpane ui-widget-content ui-helper-clearfix' style='background-color: rgb(224, 238, 238); '><div class='ui-dialog-buttonset header-buttonpane'></div></div>"); |
---|
| 525 | $(".dialog-head-buttonpane").css("padding", "5px"). |
---|
[5801] | 526 | find(".header-buttonpane").html("<a href='#' class='button add' title='"+get_lang("Add new rule")+"'>"+get_lang("New rule")+"</a>"+(!outoffice ? "<a href='#' class='button add vacation' title='"+get_lang("Add rule out of office")+"'>"+get_lang("Out of office")+"</a>" : "")).find(".button").button(); |
---|
[6452] | 527 | |
---|
[5539] | 528 | $(".ui-dialog-buttonpane.ui-widget-content").css("background-color", "#E0EEEE"); |
---|
[5598] | 529 | var list = DataLayer.render( BASE_PATH + 'modules/filters/filter-list.ejs', DataLayer.get("filter:detail", true)); |
---|
| 530 | list_container.html(list).find(".button").button(); |
---|
[6452] | 531 | |
---|
[5543] | 532 | list_container.find(".rule-list").selectable({ |
---|
| 533 | selecting: function(event, ui) { |
---|
| 534 | $(ui.selecting).find(':checkbox').attr('checked', true); |
---|
| 535 | }, |
---|
| 536 | unselecting: function(event, ui) { |
---|
| 537 | $(ui.unselecting).find(':checkbox').attr('checked', false); |
---|
| 538 | } |
---|
| 539 | }); |
---|
[6452] | 540 | |
---|
[5598] | 541 | list_container.find( ".menu-control .button" ).filter(".update").button({ |
---|
[5543] | 542 | icons: { |
---|
| 543 | primary: "ui-icon-pencil" |
---|
| 544 | }, |
---|
| 545 | text: false |
---|
| 546 | }).click(function(){ |
---|
[5627] | 547 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5543] | 548 | var filters = DataLayer.get( 'filter', true); |
---|
| 549 | for(var i =0; i < filters.length; i++){ |
---|
| 550 | if(filters[i].id == id){ |
---|
| 551 | filters = filters[i]; |
---|
| 552 | break; |
---|
[6452] | 553 | } |
---|
[5543] | 554 | } |
---|
[5801] | 555 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5543] | 556 | var details_container = $(".expresso-window-filters").html(html); |
---|
| 557 | if(filters.name != "vacation"){ |
---|
| 558 | form = container.find("form"); |
---|
| 559 | criterias = details_container.find( 'fieldset input[name="criteriaType[]"]' ); |
---|
| 560 | actions = details_container.find( 'fieldset input[name="actionType[]"]' ); |
---|
| 561 | nameObj = details_container.find( 'input[name="name"]' ); |
---|
| 562 | isExact = details_container.find( 'input[name="isExact"]' ); |
---|
| 563 | showDetails(filters); |
---|
[5598] | 564 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
| 565 | list_container.find(".button").button().filter(".forth").click(function(){ |
---|
[5539] | 566 | accord.accordion('activate',1); |
---|
[5930] | 567 | }).end().filter(".forth2").click(function(){ |
---|
| 568 | accord.accordion('activate',2); |
---|
[5539] | 569 | }).end().filter(".back").click(function(){ |
---|
| 570 | accord.accordion('activate',0); |
---|
[5930] | 571 | }).end().filter(".back2").click(function(){ |
---|
| 572 | accord.accordion('activate',1); |
---|
[5539] | 573 | }).end().filter(".cancel").click(function(){ |
---|
| 574 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 575 | }).end().filter(".submit").click(function(){ |
---|
[5543] | 576 | if(nameObj) |
---|
| 577 | nameObj.attr("disabled", "false"); |
---|
[5591] | 578 | if(valid_save()) |
---|
| 579 | $(this).submit(); |
---|
| 580 | else |
---|
| 581 | return; |
---|
[6452] | 582 | DataLayer.commit( 'filter', false,function(){ |
---|
| 583 | if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { |
---|
[6392] | 584 | for (var index in selectedMessages) { |
---|
| 585 | set_message_flag(index, action, false); |
---|
| 586 | } |
---|
| 587 | } |
---|
[5662] | 588 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 589 | }); |
---|
[6452] | 590 | }).end().filter('.button.search').click(function() { |
---|
[6392] | 591 | /* Valida se o usuário preencheu as informações */ |
---|
| 592 | if(valid_save()) |
---|
| 593 | showGridMessages($(this)); |
---|
| 594 | else |
---|
| 595 | return; |
---|
| 596 | }) |
---|
[5543] | 597 | }else{ |
---|
[5598] | 598 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 599 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 600 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5539] | 601 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 602 | }).end().filter(".submit").click(function(){ |
---|
| 603 | $(this).submit(); |
---|
[5662] | 604 | DataLayer.commit( 'filter', false,function(){ |
---|
| 605 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 606 | }); |
---|
[5539] | 607 | }); |
---|
[5543] | 608 | details_container.find('[name="vacation"]').val(filters.actions[0].parameter); |
---|
| 609 | } |
---|
[5539] | 610 | }); |
---|
[5543] | 611 | }).end() |
---|
| 612 | .filter(".enable").button({ |
---|
| 613 | icons: { |
---|
[5648] | 614 | primary: "ui-icon-circle-close" |
---|
[5543] | 615 | }, |
---|
| 616 | text: false |
---|
| 617 | }).click(function(){ |
---|
[6452] | 618 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 619 | DataLayer.put( 'filter', id, { enabled: false }); |
---|
[5627] | 620 | DataLayer.commit("filter", false,function(){ |
---|
| 621 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 622 | }); |
---|
[5543] | 623 | }).end() |
---|
| 624 | |
---|
| 625 | .filter(".disable").button({ |
---|
| 626 | icons: { |
---|
[5648] | 627 | primary: "ui-icon-circle-check" |
---|
[5543] | 628 | }, |
---|
| 629 | text: false |
---|
| 630 | }).click(function(){ |
---|
[5627] | 631 | var id = $(this).parents("li.rule").find('.id').val(); |
---|
[5601] | 632 | DataLayer.put( 'filter', id, { enabled: true }); |
---|
[5627] | 633 | DataLayer.commit("filter", false,function(){ |
---|
| 634 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 635 | }); |
---|
[5543] | 636 | }).end() |
---|
[6452] | 637 | |
---|
[5543] | 638 | .filter(".close").button({ |
---|
| 639 | icons: { |
---|
| 640 | primary: "ui-icon-close" |
---|
| 641 | }, |
---|
| 642 | text: false |
---|
[5648] | 643 | }).click(function(event){ |
---|
[5662] | 644 | var filter_name = $(event.target).parents("li.rule").find('.id').val(); |
---|
[5902] | 645 | var filter_screen_name = $(event.target).parents("li.rule").find('.title').html(); |
---|
| 646 | $.Zebra_Dialog(get_lang("Are you sure to delete the filter") + ": <strong>"+filter_screen_name+"</strong>",{ |
---|
[5662] | 647 | 'type': 'question', |
---|
[5801] | 648 | 'title': get_lang("Exclusion Confirmation"), |
---|
[5662] | 649 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
| 650 | 'onClose': function(caption) { |
---|
| 651 | if(caption == get_lang('Yes')){ |
---|
[5762] | 652 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 653 | DataLayer.remove('filter', false); |
---|
| 654 | DataLayer.get('filter'); |
---|
[5662] | 655 | DataLayer.remove( 'filter', filter_name); |
---|
| 656 | DataLayer.commit("filter", false,function(){ |
---|
| 657 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 658 | }); |
---|
| 659 | }else{ |
---|
| 660 | $(event.target).removeClass("ui-selected").parent().removeClass("ui-selected"); |
---|
| 661 | } |
---|
| 662 | } |
---|
[5543] | 663 | }); |
---|
| 664 | }).end().removeClass("ui-button-icon-only"); |
---|
[6452] | 665 | |
---|
[6021] | 666 | $(".button.allenable").click(function(){ |
---|
[5987] | 667 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[5995] | 668 | DataLayer.put( 'filter', o.innerHTML, { enabled: true }); |
---|
[5987] | 669 | }); |
---|
| 670 | DataLayer.commit("filter", false, function(){ |
---|
| 671 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 672 | }); |
---|
| 673 | }); |
---|
[6452] | 674 | |
---|
[6021] | 675 | $(".button.alldisable").click(function(){ |
---|
[5987] | 676 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[5995] | 677 | DataLayer.put( 'filter', o.innerHTML, { enabled: false }); |
---|
[5987] | 678 | }); |
---|
| 679 | DataLayer.commit("filter", false, function(){ |
---|
| 680 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 681 | }); |
---|
| 682 | }); |
---|
[6452] | 683 | |
---|
[6021] | 684 | $(".button.alldelete").click(function(){ |
---|
[5985] | 685 | $.Zebra_Dialog(get_lang("Are you sure to delete the filters?"),{ |
---|
| 686 | 'type': 'question', |
---|
| 687 | 'title': get_lang("Exclusion Confirmation"), |
---|
| 688 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
| 689 | 'onClose': function(caption) { |
---|
| 690 | if(caption == get_lang('Yes')){ |
---|
| 691 | /** TODO - Mudar quando API abstrair atualizações no cache */ |
---|
| 692 | DataLayer.remove('filter', false); |
---|
| 693 | DataLayer.get('filter'); |
---|
[6452] | 694 | container.find('.rule-list').find('.rule').find('.select').find(':checked').parents('.rule').find('.title').each(function(i,o){ |
---|
[6392] | 695 | DataLayer.remove( 'filter', urlencode(o.innerHTML) ); |
---|
[5985] | 696 | }); |
---|
| 697 | DataLayer.commit("filter", false,function(){ |
---|
| 698 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 699 | }); |
---|
| 700 | }else{ |
---|
| 701 | return true; |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | }); |
---|
| 705 | }); |
---|
[6452] | 706 | |
---|
[5930] | 707 | var aa = 0; |
---|
[6452] | 708 | |
---|
[5598] | 709 | list_container.parent().find(".button.add:first").click(function(){ |
---|
| 710 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
[5801] | 711 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5598] | 712 | list_container.html(html); |
---|
| 713 | var accord = list_container.find(".rule-details-container").accordion({autoHeight: false}); |
---|
| 714 | list_container.find(".button").button().filter(".forth").click(function(){ |
---|
[5543] | 715 | accord.accordion('activate',1); |
---|
[5930] | 716 | }).end().filter(".forth2").click(function(){ |
---|
| 717 | accord.accordion('activate',2); |
---|
[5543] | 718 | }).end().filter(".back").click(function(){ |
---|
| 719 | accord.accordion('activate',0); |
---|
[5930] | 720 | }).end().filter(".back2").click(function(){ |
---|
| 721 | accord.accordion('activate',1); |
---|
[5543] | 722 | }).end().filter(".cancel").click(function(){ |
---|
| 723 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[5862] | 724 | }).end().filter(".submit").click(function() { |
---|
[5591] | 725 | if(valid_save()) |
---|
| 726 | $(this).submit(); |
---|
| 727 | else |
---|
| 728 | return; |
---|
[5627] | 729 | DataLayer.commit( 'filter',false,function(){ |
---|
[6452] | 730 | if($('#gbox_fields-search-messages-grid').length > 0 && action != '') { |
---|
[6392] | 731 | for (var index in selectedMessages) { |
---|
| 732 | set_message_flag(index, action, false); |
---|
| 733 | } |
---|
| 734 | } |
---|
[5627] | 735 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 736 | }); |
---|
[6452] | 737 | }).end().filter('.button.search').click(function() { |
---|
[5862] | 738 | if(valid_save()) |
---|
[6048] | 739 | showGridMessages($(this)); |
---|
[5862] | 740 | else |
---|
| 741 | return; |
---|
| 742 | }); // end function click |
---|
| 743 | }); // end DataLayer.render |
---|
[5543] | 744 | }); |
---|
[5598] | 745 | list_container.parent().find(".button.add.vacation").click(function(){ |
---|
[6452] | 746 | |
---|
[5598] | 747 | list_container.parent().find(".dialog-head-buttonpane").addClass("hidden"); |
---|
[5801] | 748 | DataLayer.render( BASE_PATH + 'modules/filters/edit-filter.ejs', {folders : DataLayer.get("folder", true), delimiter: cyrus_delimiter},function(html){ |
---|
[5598] | 749 | list_container.html(html); |
---|
| 750 | list_container.find(".vacation-details-container").removeClass("hidden"); |
---|
| 751 | list_container.find(".rule-details-container").addClass("hidden"); |
---|
| 752 | list_container.find(".button").button().filter(".back").click(function(){ |
---|
[5543] | 753 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
[6452] | 754 | }).end().filter(".submit").click(function(){ |
---|
[6392] | 755 | if(list_container.find(".vacation-details-container .filter-textarea").val().length <= 0){ |
---|
| 756 | $.Zebra_Dialog(get_lang('Write a message')); |
---|
| 757 | list_container.find(".vacation-details-container .filter-textarea").focus(); |
---|
| 758 | }else{ |
---|
| 759 | $(this).submit(); |
---|
| 760 | DataLayer.commit( 'filter',false,function(){ |
---|
| 761 | DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {},list_filters); |
---|
| 762 | }); |
---|
| 763 | } |
---|
[5543] | 764 | }); |
---|
[6452] | 765 | }); |
---|
[5543] | 766 | }); |
---|
[5539] | 767 | } |
---|
[6284] | 768 | |
---|
[6392] | 769 | /* Inicializa os filtros e chama o list_filters */ |
---|
[5782] | 770 | function init_filters(){ |
---|
| 771 | var html = DataLayer.render( BASE_PATH + 'modules/filters/init.ejs', {}); |
---|
| 772 | list_filters(html); |
---|
| 773 | } |
---|