[3282] | 1 | /** |
---|
| 2 | * @author diogenes |
---|
| 3 | */ |
---|
| 4 | function ccFullSearch() { |
---|
| 5 | var win; |
---|
| 6 | var fields = null; |
---|
| 7 | } |
---|
| 8 | |
---|
| 9 | ccFullSearch.prototype.showForm = function() { |
---|
| 10 | div = document.getElementById('cc_searchDiv'); |
---|
| 11 | if(this.fields==null) |
---|
| 12 | this.fields = new Array(Element('cc_qa_given_names').value, Element('cc_corporate').value+":", Element('cc_qa_email').value, Element('cc_qa_phone').value); |
---|
| 13 | if(div) |
---|
| 14 | this.showWindow(div); |
---|
| 15 | else { |
---|
| 16 | |
---|
| 17 | var el = document.createElement("DIV"); |
---|
| 18 | el.style.visibility = "hidden"; |
---|
| 19 | el.style.position = "absolute"; |
---|
| 20 | el.style.left = "0px"; |
---|
| 21 | el.style.top = "0px"; |
---|
| 22 | el.style.width = "0px"; |
---|
| 23 | wHeight = Element('ccQAWinHeight').value; |
---|
| 24 | el.style.height = wHeight + 'px'; |
---|
| 25 | el.className = "div_cc_rectQuickAddContact"; |
---|
| 26 | el.id = 'cc_searchDiv'; |
---|
| 27 | document.body.appendChild(el); |
---|
| 28 | el.innerHTML = ""; |
---|
| 29 | |
---|
| 30 | var fieldsTop = 10; |
---|
| 31 | var fieldsSpace = 30; |
---|
| 32 | for (i=0; i<this.fields.length; i++) { |
---|
| 33 | el.innerHTML += '<span id="ccSearchSpan' + i + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 5px; width: 100px; text-align: right; border: 0px solid #999;">' + this.fields[i] + '</span>'; |
---|
| 34 | el.innerHTML += '<input id="ccSearchInp' + i + '" type="text" maxlength="30" style="position: absolute; top: ' + (fieldsTop + i * fieldsSpace) + 'px; left: 110px; width: 135px;">'; |
---|
| 35 | } |
---|
| 36 | el.innerHTML +='<div id="ccSearchFunctions" style="border: 0px solid black; width: 220px; height: 20px">' + |
---|
| 37 | '<input title="' + Element('cc_panel_search_text').value + '" type="button" onclick="ccFullSearchVar.go();" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 35px; width: 60px" value="'+Element('cc_panel_search_text').value+'"/>' + |
---|
| 38 | '<input title="' + Element('cc_msg_clean').value + '" type="button" onclick="ccFullSearchVar.clean();" value="' + Element('cc_msg_clean').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 100px; width: 60px" />' + |
---|
| 39 | '<input title="' + Element('cc_qa_close').value + '" type="button" onclick="ccFullSearchVar.close();" value="' + Element('cc_qa_close').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 165px; width: 60px" />' + |
---|
| 40 | '</div>'; |
---|
| 41 | el.innerHTML += "<br>"; |
---|
| 42 | |
---|
| 43 | this.showWindow(el); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | ccFullSearch.prototype.showWindow = function (div) |
---|
| 49 | { |
---|
| 50 | if(! this.win) { |
---|
| 51 | win = new dJSWin({ |
---|
| 52 | id: 'ccSearch_'+div.id, |
---|
| 53 | content_id: div.id, |
---|
| 54 | width: '255px', |
---|
| 55 | height: wHeight+'px', |
---|
| 56 | title_color: '#3978d6', |
---|
| 57 | bg_color: '#eee', |
---|
| 58 | title: Element('cc_cs_title').value, |
---|
| 59 | title_text_color: 'white', |
---|
| 60 | button_x_img: Element('cc_phpgw_img_dir').value+'/winclose.gif', |
---|
| 61 | border: true }); |
---|
| 62 | |
---|
| 63 | this.win = win; |
---|
| 64 | win.draw(); |
---|
| 65 | } |
---|
| 66 | if((ccTree.actualCatalog=='bo_people_catalog') || |
---|
| 67 | (ccTree.actualCatalog=='bo_shared_people_manager')) //Habilita empresa apenas para catálogos que não sejam do ldap. |
---|
| 68 | Element('ccSearchInp1').disabled = false; |
---|
| 69 | else |
---|
| 70 | Element('ccSearchInp1').disabled = true; |
---|
| 71 | this.win.open(); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | ccFullSearch.prototype.go = function () { |
---|
| 75 | |
---|
| 76 | var _this = this; |
---|
| 77 | var data = new Array(); |
---|
| 78 | var type = Element('cc_type_contact').value; |
---|
| 79 | |
---|
| 80 | data['fields'] = new Array(); |
---|
| 81 | |
---|
[4153] | 82 | data['search_for'] = Element('ccSearchInp0').value + " " |
---|
| 83 | + Element('ccSearchInp1').value + " " |
---|
| 84 | + Element('ccSearchInp2').value + " " |
---|
| 85 | + Element('ccSearchInp3').value + " "; |
---|
| 86 | var invalidChars = /[\%\?]/; |
---|
[3628] | 87 | if(invalidChars.test(data['search_for']) || invalidChars.test(data['search_for_area'])){ |
---|
| 88 | showMessage(Element('cc_msg_err_invalid_serch').value); |
---|
| 89 | return; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | var search_for = data['search_for'].split(' '); |
---|
| 93 | var greaterThanMin = false; |
---|
| 94 | var use_length = v_min; |
---|
| 95 | |
---|
| 96 | for (i = 0; i < search_for.length; i++) |
---|
| 97 | { |
---|
| 98 | if (search_for[i].length >= use_length) |
---|
| 99 | { |
---|
| 100 | greaterThanMin = true; |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | if (!greaterThanMin){ |
---|
| 105 | alert("Favor fazer a consulta com pelo menos " + v_min + " caracteres!"); |
---|
| 106 | return; |
---|
| 107 | } |
---|
[4153] | 108 | |
---|
| 109 | if (Element('ccSearchInp0').value == "") |
---|
| 110 | data['search_for'] = ""; |
---|
| 111 | |
---|
[3282] | 112 | if (type=='groups') { |
---|
| 113 | data['fields']['id'] = 'group.id_group'; |
---|
| 114 | data['fields']['search'] = 'group.title'; |
---|
| 115 | } |
---|
| 116 | else { |
---|
| 117 | data['fields']['id'] = 'contact.id_contact'; |
---|
| 118 | data['fields']['search'] = 'contact.names_ordered'; |
---|
| 119 | } |
---|
[3628] | 120 | //data['search_for'] = Element('ccSearchInp0').value; |
---|
[3282] | 121 | data['full_search'] = new Array(); |
---|
| 122 | |
---|
| 123 | data['full_search']['corporate'] = Element('ccSearchInp1').disabled?'':Element('ccSearchInp1').value; |
---|
| 124 | data['full_search']['mail'] = Element('ccSearchInp2').value ; |
---|
| 125 | data['full_search']['phone'] = Element('ccSearchInp3').value ; |
---|
| 126 | var handler = function(responseText) { |
---|
| 127 | ccSearch.mount_handler(responseText); |
---|
| 128 | _this.close(); |
---|
| 129 | } |
---|
| 130 | Connector.newRequest('fullSearch',CC_url+'search&data='+serialize(data), 'GET',handler); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | ccFullSearch.prototype.close = function() { |
---|
| 134 | this.win.close(); |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | ccFullSearch.prototype.clean = function() { |
---|
| 138 | for (i=0; i<this.fields.length; i++) { |
---|
| 139 | Element('ccSearchInp'+i).value = ''; |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | var ccFullSearchVar = new ccFullSearch(); |
---|