Files
crm.e5.pl/modules/EcmDocumentTemplates/EcmDocumentTemplates.js

77 lines
3.0 KiB
JavaScript
Raw Normal View History

2024-04-27 09:23:34 +02:00
function doRequest(where,post,doFunction,error) {
this.Display = function(result) { doFunction(result.responseText); }
this.Fail = function(result){ if(error) alert(error);}
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
}
function changeValidateRequired(formname,name,required) {
for(var i=0; i<validate[formname].length; i++)
if(validate[formname][i][0] == name) { validate[formname][i][2] = required; break; }
}
function set_focus() { document.getElementById('name').focus(); }
function my_popup(module, field_array, call_back_function, form_name) {
if(!call_back_function) call_back_function = "set_return";
if(!form_name) form_name = "EditView";
return open_popup(module, 600, 400, "", true, false, {"call_back_function":call_back_function,"form_name":form_name,"field_to_name_array":field_array});
}
function addEvent(object,eventName,do_function) {
if(typeof(object) == "string") object = document.getElementById(object);
if(!object) { alert('No object in function addEvent!'); return; }
if(object.addEventListener) {
object.addEventListener(eventName, do_function, false);
} else {
object.attachEvent('on'+eventName, do_function);
}
}
function updatePreviewNumber() {
doRequest(
'index.php',
'module=EcmDocumentTemplates&action=formatDocumentNumber&to_pdf=1&ex=1&f='+document.getElementById('document_number_format_id').value+'&d='+document.getElementById('documents_per_day_id').value,
function (response) { var dnfp = document.getElementById('doc_num_for_prev'); if(dnfp) dnfp.innerHTML = '('+response+')'; }
)
}
function deleteLogo() {
var div = document.getElementById('logoDiv');
if(div) div.parentNode.removeChild(div);
}
var accountFL;
addEvent(
window,
'load',
function () {
//adding a div to document_number_format_id
var dnfi = document.getElementById('document_number_format_id');
if(dnfi) {
var span = document.createElement('span');
span.id = 'doc_num_for_prev';
span.appendChild(document.createTextNode('()'));
dnfi.parentNode.appendChild(span);
}
addEvent(dnfi, 'change', function () {updatePreviewNumber();});
addEvent('documents_per_day_id', 'change', function () {updatePreviewNumber();});
updatePreviewNumber();
//create Account
accountFL = new FormLoader();
accountFL.load('EcmDocumentTemplates','Accounts','accountFL');
accountFL.onResponseData = function(data) {
document.forms.EditView.account_id.value = data['id'];
document.forms.EditView.account_name.value = data['name'];
};
accountFL.setEditDblClick(document.forms.EditView.account_name);
accountFL.onEditDblClick = function() { return "&fl_record="+document.forms.EditView.account_id.value; }
accountFL.onButtonClick = function() { return "&fl_name="+document.forms.EditView.account_name.value; }
//document.forms.EditView.account_id.parentNode.appendChild(accountFL.createButton());
}
);