function cQuickAddContact () { this.arrayWin = new Array(); this.el; this._nFields = Element('ccQAnFields').value; } cQuickAddContact.prototype.showList = function(id){ _this = this; var handler = function (responseText) { var contacts = unserialize(responseText); var title = contacts['names_ordered']; el = document.createElement("DIV"); el.style.visibility = "hidden"; el.style.position = "absolute"; el.style.left = "0px"; el.style.top = "0px"; el.style.width = "0px"; wHeight = Element('ccQAWinHeight').value; el.style.height = wHeight + 'px'; el.className = "div_cc_rectQuickAddContact"; el.id = id+':cc_rectQuickAddContact'; document.body.appendChild(el); el.innerHTML = ""; var fieldsTop = 10; var fieldsSpace = 30; fields = new Array(Element('cc_qa_alias').value, Element('cc_qa_given_names').value, Element('cc_qa_family_names').value, Element('cc_qa_phone').value, Element('cc_qa_email').value); for (i=0; i' + fields[i] + ''; if (i == 0) { el.innerHTML += ''; } else if (i == 4) { el.innerHTML += ''; } else { el.innerHTML += ''; } } el.innerHTML +='
' + '' + '' + '
'; el.innerHTML += "
"; _this.showWindow(el); } div = document.getElementById(id+':cc_rectQuickAddContact'); if(div) this.showWindow(div); else { Connector.newRequest('get_catalog_add_contact', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_catalog_add_contact', 'POST', handler, 'id='+id); } } cQuickAddContact.prototype.showWindow = function (div) { if(! this.arrayWin[div.id]) { win = new dJSWin({ id: 'ccQuickAddContact_'+div.id, content_id: div.id, width: '255px', height: wHeight+'px', title_color: '#3978d6', bg_color: '#eee', title: Element('ccQATitle').value, title_text_color: 'white', button_x_img: Element('cc_phpgw_img_dir').value+'/winclose.gif', border: true }); this.arrayWin[div.id] = win; win.draw(); } else { win = this.arrayWin[div.id]; } win.open(); } cQuickAddContact.prototype.send = function (id) { var _this = this; div = document.getElementById(id+':cc_rectQuickAddContact'); win = this.arrayWin[div.id]; var handler = function (responseText) { Element('cc_debug').innerHTML = responseText; var data = unserialize(responseText); if (!data || typeof(data) != 'object') { showMessage(Element('cc_msg_err_contacting_server').value); return; } else if (data['status'] == 'alreadyExists') { showMessage(data['msg']); return; } else if (data['status'] != 'ok') { return; } win.close(); if (_this.afterSave) { switch (typeof(_this.afterSave)) { case 'function': _this.afterSave(); break; case 'string': eval(_this.afterSave); break; } } } var sdata = new Array(); for (var f = 0; f < 5; f++){ sdata[f] = document.getElementById('ccQuickAddCI' + f + id).value; } //Utiliza expressão regular para validar email var reEmail = /^[A-Za-z\d_-]+(\.[A-Za-z\d_-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/; if(!reEmail.test(sdata[4])){ alert("O endereço de email '" + sdata[4] + "' não é válido!\n" + "Por favor informe um endereço válido."); return false; } //Utiliza expressão regular para validar telefone var rePhone = /^[0-9|(-)| |-]{0,15}$/; if (!rePhone.test(sdata[3])){ alert("O número de telefone '" + sdata[3] + "' não é valido! Utilize apenas números.\n" + "Parenteses, traços ou espaços em branco podem ser usados como carácter separador."); return false; } var sdata = 'add='+escape(serialize(sdata)); Connector.newRequest('cQuickAdd.Send', CC_url+'quick_add', 'POST', handler, sdata); } cQuickAddContact.prototype.fechar = function(id) { div = document.getElementById(id+':cc_rectQuickAddContact'); win = this.arrayWin[div.id]; win.close(); } /* Build the Object */ var ccQuickAddContact ; var cQuickAddContact_pre_load = document.body.onload; if (is_ie) { document.body.onload = function (e) { cQuickAddContact_pre_load(); ccQuickAddContact = new cQuickAddContact(); }; } else { ccQuickAddContact = new cQuickAddContact(); }