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