function cIEContacts () { this.win; this.el; this.wWidth = 395; this.wHeight = 255; } cIEContacts.prototype.changeOptions = function(type){ if(type == 'i') { Element('export_span').style.display = 'none'; Element('import_span').style.display = ''; } else{ Element('import_span').style.display = 'none'; Element('export_span').style.display = ''; } } cIEContacts.prototype.showFailures = function(data){ if (data == 'undefined') return; if (data){ var lang_clean = Element('cc_msg_clean').value; var info_box = document.getElementById('s_info2'); info_box.innerHTML = data; info_box.style.visibility = ''; var cleanButton = document.createElement('input'); cleanButton.type='button'; cleanButton.value=lang_clean; cleanButton.onclick= function() { ccIEContacts.cleanInfo() }; info_box.appendChild(cleanButton); } } cIEContacts.prototype.cleanInfo = function(){ var info_box = document.getElementById('s_info2'); info_box.innerHTML = ''; } cIEContacts.prototype.showList = function(){ if (!this.el){ this.el = document.createElement("DIV"); this.el.style.visibility = "hidden"; this.el.style.position = "absolute"; this.el.style.left = "0px"; this.el.style.top = "0px"; this.el.style.width = this.wWidth + 'px'; this.el.style.height = this.wHeight + 'px'; if(is_ie) { this.el.style.width = "430"; this.el.style.overflowY = "auto"; this.el.style.overflowX = "hidden"; } else { this.el.style.overflow = "-moz-scrollbars-vertical"; } this.el.id = 'cc_rectIEContacts'; document.body.appendChild(this.el); var lang_import_contacts = Element('cc_msg_import_contacts').value; var lang_close_win = Element('cc_msg_close_win').value var lang_export_contacts = Element('cc_msg_export_contacts').value; var lang_expresso_info_csv = Element('cc_msg_expresso_info_csv').value; var lang_expresso_default = Element('cc_msg_expresso_default').value; var lang_choose_contacts_file = Element('cc_msg_choose_contacts_file').value; var lang_msg_choose_type = Element('cc_msg_choose_file_type').value; var lang_msg_expresso_info_csv = Element('cc_msg_expresso_info_csv').value; var lang_msg_export_csv = Element('cc_msg_export_csv').value; var lang_msg_automatic = Element('cc_msg_automatic').value; var lang_close = Element('cc_msg_close').value; var lang_moz_tb = Element('cc_msg_moz_thunderbird').value; var lang_outl_pt = Element('cc_msg_outlook_express_pt').value; var lang_outl_en = Element('cc_msg_outlook_express_en').value; var lang_outl2k_pt = Element('cc_msg_outlook_2k_pt').value; var lang_outl2k_en = Element('cc_msg_outlook_2k_en').value; var lang_expresso_default_csv = Element('cc_msg_expresso_default_csv').value; this.el.innerHTML = '
'+ ''+ '
'+lang_import_contacts+ '        '+lang_export_contacts+'
'+ ''+ ''+ ''+ ''+ ''+ ''+ '
'+ ''+lang_expresso_info_csv+'
'+ '
'+ lang_msg_choose_type + ': 
'+ '
'+lang_choose_contacts_file+'

'+ ''+ '
    '+ '
'+ ''+ ''+ ''+ ''+ ''+ '
'; } this.showWindow(); } cIEContacts.prototype.showWindow = function () { if(!this.win) { this.win = new dJSWin({ id: 'ccIEContacts', content_id: this.el.id, width: (this.wWidth +(is_ie ? 41 : 0)) +'px', height: this.wHeight +'px', title_color: '#3978d6', bg_color: '#eee', title: Element('cc_msg_ie_personal').value, title_text_color: 'white', button_x_img: '../phpgwapi/images/winclose.gif', border: true }); this.win.draw(); } this.win.open(); } cIEContacts.prototype.importWriteStatus = function(args){ // array args // args[0] - status (success, error ou importing) // args[1] - numero de contatos novos; // args[2] - numero de contatos falhos; // args[3] - numero de contatos sobrescritos; var form = document.formCSV; var status = ''; var lang_import_fail = Element('cc_msg_import_fail').value; var lang_importing = Element('cc_msg_importing_contacts').value; var lang_import_finish = Element('cc_msg_import_finished').value; var lang_new = Element('cc_msg_new').value; var lang_failure = Element('cc_msg_failure').value; var lang_exists = Element('cc_msg_exists').value; var lang_show_more_info = Element('cc_msg_show_more_info').value; var l_1 = '['+args[1]+lang_new+']'; var l_2 = '['+args[2]+lang_failure+']'; var l_3 = '['+args[3]+lang_exists+']'; var l_4 = '
'+lang_show_more_info+''; var l_error = '  '+lang_import_fail+ ' '; var l_importing = '  '+lang_importing + ' '; if(args[0] == 'success') { for(i = 1; i < 5; i++) { status += " "+eval('l_'+i); } Element('s_info').innerHTML = '  '+lang_import_finish+'
 '+status; } else Element('s_info').innerHTML = eval('l_'+args[0]); Element("s_info").style.visibility = ''; var recreate_fileupload = function () { var import_file = document.createElement("INPUT"); import_file.type = "FILE"; import_file.name = "import_file"; import_file.id = "import_file"; form.appendChild(import_file); Element('import_button').disabled = false; form.style.visibility = ''; } if(args[0] != 'importing') { recreate_fileupload(); setTimeout("Element('s_info').style.visibility = 'hidden'", 12000); } } cIEContacts.prototype.importCSV = function () { var lang_msg_invalid_csv = Element('cc_msg_invalid_csv').value; var form = document.formCSV; if ((form.import_file.value.length < 10) || (form.import_file.value.substring(form.import_file.value.length - 4, form.import_file.value.length).toLowerCase() != ".csv")){ alert(lang_msg_invalid_csv); return; } var _this = this; Element('import_button').disabled = true; var handler_import = function (responseText){ var args = new Array(); var data = unserialize(responseText); if(data.error) args[0] = 'error'; else { args[0] = 'success'; args[1] = data._new ? data._new : 0; args[2] = data._failure ? data._failure : 0; args[3] = data._existing ? data._existing : 0; args[4] = data._failure_status } _this.importWriteStatus(args); } if(! (divUpload = Element('divUpload'))) { divUpload = document.createElement('DIV'); divUpload.id = 'divUpload'; document.body.appendChild(divUpload); } divUpload.innerHTML= ''; var _onload = function(){ var typeImport = Element('typeImport').value; Connector.newRequest('import_contacts','../index.php?menuaction=contactcenter.ui_data.data_manager&method=import_contacts&typeImport='+typeImport,'GET',handler_import); } if (Element('importCSVFile').attachEvent) Element('importCSVFile').attachEvent("onload", _onload); else Element('importCSVFile').onload = _onload; form.action ="inc/cc_updown.php"; form.target ="importCSVFile"; form.submit(); form.removeChild(form.import_file); form.style.visibility = 'hidden'; this.importWriteStatus(new Array('importing')); } cIEContacts.prototype.close = function() { this.win.close(); } cIEContacts.prototype.exportCSV = function() { var lang_export_error = Element('cc_msg_export_error'); var handler_export = function(data) { if(!data){ alert(lang_export_error ); return; } var div_download = document.getElementById("id_div_download"); if (!div_download){ div_download = document.createElement("DIV"); div_download.id="id_div_download"; document.body.appendChild(div_download); } div_download.innerHTML=""; Element('export_button').disabled = false; } var typeExport = Element("typeExport"); Element('export_button').disabled = true; Connector.newRequest('export_contacts', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=export_contacts', 'POST', handler_export, 'typeExport='+typeExport.value); } /* Build the Object */ var ccIEContacts = new cIEContacts();