Add JS files

This commit is contained in:
2025-05-12 15:45:17 +00:00
parent 7ddd15c4fa
commit 967007b0c7
3239 changed files with 1157078 additions and 0 deletions

36
modules/ACLRoles/ACLRoles.js Executable file
View File

@@ -0,0 +1,36 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var aclviewer=function(){var lastDisplay='';return{view:function(role_id,role_module){YAHOO.util.Connect.asyncRequest('POST','index.php',{'success':aclviewer.display,'failure':aclviewer.failed},'module=ACLRoles&action=EditRole&record='+role_id+'&category_name='+role_module);ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_REQUEST_PROCESSED'));},save:function(form_name){var formObject=document.getElementById(form_name);YAHOO.util.Connect.setForm(formObject);YAHOO.util.Connect.asyncRequest('POST','index.php',{'success':aclviewer.postSave,'failure':aclviewer.failed});ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVING'));},postSave:function(o){eval(o.responseText);aclviewer.view(result['role_id'],result['module']);},display:function(o){aclviewer.lastDisplay='';ajaxStatus.flashStatus('Done');document.getElementById('category_data').innerHTML=o.responseText;},failed:function(){ajax.flashStatus('Could Not Connect');},toggleDisplay:function(id){if(aclviewer.lastDisplay!=''&&typeof(aclviewer.lastDisplay)!='undefined'){aclviewer.hideDisplay(aclviewer.lastDisplay);}
if(aclviewer.lastDisplay!=id){aclviewer.showDisplay(id);aclviewer.lastDisplay=id;}else{aclviewer.lastDisplay='';}},hideDisplay:function(id){document.getElementById(id).style.display='none';document.getElementById(id+'link').style.display='';},showDisplay:function(id){document.getElementById(id).style.display='';document.getElementById(id+'link').style.display='none';}};}();

View File

@@ -0,0 +1,98 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
$(function() {
if (OPT.IamPopup)
$("#header").hide();
$(".loading_panel").css("display", "none");
});
function open_contact_popup(module_name,width,height,initial_filter,close_popup,hide_clear_button,popup_request_data,popup_mode,create,metadata)
{window.document.popup_request_data=popup_request_data;window.document.close_popup=close_popup;URL='index.php?mode=MultiSelect&'
+'module='+module_name
+'&action=ContactAddressPopup';if(initial_filter!='')
{URL+='&query=true'+initial_filter;}
if(hide_clear_button)
{URL+='&hide_clear_button=true';}
windowName='popup_window';windowFeatures='width='+width
+',height='+height
+',resizable=1,scrollbars=1';if(popup_mode==''&&popup_mode=='undefined'){popup_mode='single';}
URL+='&mode='+popup_mode;if(create==''&&create=='undefined'){create='false';}
URL+='&create='+create;if(metadata!=''&&metadata!='undefined'){URL+='&metadata='+metadata;}
win=window.open(URL,windowName,windowFeatures);if(window.focus)
{win.focus();}
return win;}
function set_focus(){document.getElementById('name').focus();}
var p_check_form = check_form;
check_form_ = function(formname) {
console.log('tu?');
if (!p_check_form("EditView"))
return false;
//add mz 2015-04-17
//zapis ajaxowo i obsługa popup
var formData = new FormData($("#EditView")[0]);
console.log(formData);
$(".loading_panel").css("display", "block");
$.ajax({
type: "POST",
url: "index.php?module=Accounts&action=Save&to_pdf=1",
data: formData,
success: function(data) {
console.log(data);
if (OPT.IamPopup) {
if(data==1){
alert("Istnieje już kontrahent o podanym nipie!");
$('.loading_panel').hide();
} else {
parent_id.value = data;
window.close();
}
} else {
if(data==1){
window.location.replace("index.php?module=Accounts&action=ShowDuplicates");
} else {
window.location.replace("index.php?module=Accounts&action=DetailView&record="+data);
}
}
},
processData : false,
contentType : false,
});
return false;
}

View File

@@ -0,0 +1,318 @@
//addresses
function saveItems() {
document.getElementById('position_list').value = ItemsList(true);
}
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 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);
}
}
var tbody_;
var ItemListSave;
var ItemListClear;
var ItemListFil;
var FillText;
addEvent(
window,
'load',
function () {
var paramsTable = new paramsMT('itemsTable');
paramsTable.onCreateRow = function (row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function () {
}
row.onSelect = function () {
//for(var i=0; i<this.myTable.colCount(); i++)
//this.cells.item(i).change(!this.newPos);
//this.cells.item(0).change(true);
}
row.onDeselect = function () {
}
}
paramsTable.onCreateCell = function (cell) {
var i = cell.index;
cell.change = function (select) {
};
if (i == 0) {
cell.setData = function (data) {
if (data.position)
cell.firstChild.value = data.position;
if (data.id)
cell.getElementsByTagName('input')[1].value = data.id;
};
cell.getData = function (data) {
data.position = cell.firstChild.value;
data.id = cell.getElementsByTagName('input')[1].value;
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('readonly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type', 'hidden');
edit.setAttribute('readonly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 1) {
cell.setData = function (data) {
if (data.name) {
cell.firstChild.value = data.name;
}
};
cell.getData = function (data) {
data.name = cell.firstChild.value;
}
cell.onDeselect = function () {
ERROR = false;
var data = new Object();
this.getData(data);
if (!ERROR) {
data.name = data.name;
this.setData(data);
}
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 2) {
cell.setData = function (data) {
if (data.street)
cell.getElementsByTagName('input')[0].value = data.street;
};
cell.getData = function (data) {
data.street = cell.firstChild.value;
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 3) {
cell.setData = function (data) {
if (data.city)
cell.firstChild.value = data.city;
};
cell.getData = function (data) {
data.city = cell.firstChild.value;
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 4) {
cell.setData = function (data) {
if (data.postalcode)
cell.firstChild.value = data.postalcode;
};
cell.getData = function (data) {
data.postalcode = cell.firstChild.value;
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 5) {
cell.setData = function (data) {
if (data.country)
cell.firstChild.value = data.country;
};
cell.getData = function (data) {
data.country = cell.firstChild.value;
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 6) {
cell.setData = function (data) {
if (data.phone)
cell.firstChild.value = data.phone;
};
cell.getData = function (data) {
data.phone = cell.firstChild.value;
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 7) {
cell.setData = function (data) {
if (data.fax)
cell.firstChild.value = data.fax;
};
cell.getData = function (data) {
data.fax = cell.firstChild.value;
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 8) {
var img;
cell.style.padding = "auto auto auto auto";
//insert
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src', 'modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index + 1);
refreshPositionIndex();
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_DELETE_ROW']);
img.setAttribute('src', 'modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.parentNode.deleteRow();
refreshPositionIndex();
};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src', 'modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.parentNode.moveUp();
refreshPositionIndex();
};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src', 'modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.parentNode.moveDown();
refreshPositionIndex();
}
cell.appendChild(img);
}
}
refreshPositionIndex = function () {
for (var i = 0; i < paramsTable.rowCount(); i++) {
var data = paramsTable.row(i).getData();
data.position = i + 1;
paramsTable.row(i).setData(data);
}
}
ItemsList = function (json) {
var data = '';
for (var i = 0; i < paramsTable.rowCount(); i++) {
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable.row(i).getData());
}
return data;
}
if (paramsTable.rowCount() == 0) {
paramsTable.addRow();
refreshPositionIndex();
}
;
paramsTable.onSetCellData = function (row, cell, data) {
if (cell.innerHTML == '')
cell.innerHTML = '&nbsp;';
}
ItemListSave = function (json, el) {
var data = new Object();
var tmp;
for (var i = 0; i < paramsTable.rowCount(); i++) {
data[i.toString()] = paramsTable.row(i).getData();
}
paramsOptions = data;
var r = JSON.stringifyNoSecurity(paramsOptions);
doRequest(
'index.php',
'module=Accounts&action=price_conditionSave&to_pdf=1&paramslist=' + r + '&record=' + document.forms.EditView.record.value,
function (result) {
if (result.indexOf("Saved") >= 0)
alert("Zapisano!");
else
alert("Błąd podczas zapisywania!");
}
);
}
ItemListClear = function (noNew, save) {
if (typeof (save) == "string")
ItemListSave(null, save);
while (paramsTable.rowCount() > 0)
paramsTable.row(0).deleteRow(noNew);
refreshPositionIndex();
}
ItemListFill = function () {
var pl;
pl = document.getElementById('position_list').value;
if (pl && pl != '') {
try {
pl = eval(pl);
for (x in pl) {
var pl_row = pl[x];
if (pl_row.template == '')
continue;
paramsTable.addRow().setData(pl_row);
}
} catch (err) {
pl = null;
}
;
}
refreshPositionIndex();
}
ItemListClear();
ItemListFill();
}
);

248
modules/Accounts/Banks.js Normal file
View File

@@ -0,0 +1,248 @@
//addresses
function saveItems4() {
document.getElementById('position_list4').value = ItemsList4(true);
}
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 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);
}
}
var tbody_;
var ItemListSave4;
var ItemListClear4;
var ItemListFill4;
var FillText;
addEvent(
window,
'load',
function () {
var paramsTable4 = new paramsMT('itemsTable4');
paramsTable4.onCreateRow = function (row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function () {
}
row.onSelect = function () {
//for(var i=0; i<this.myTable.colCount(); i++)
//this.cells.item(i).change(!this.newPos);
//this.cells.item(0).change(true);
}
row.onDeselect = function () {
}
}
paramsTable4.onCreateCell = function (cell) {
var i = cell.index;
cell.change = function (select) {
};
if (i == 0) {
cell.setData = function (data) {
if (data.position)
cell.firstChild.value = data.position;
if (data.id)
cell.getElementsByTagName('input')[1].value = data.id;
};
cell.getData = function (data) {
data.position = cell.firstChild.value;
data.id = cell.getElementsByTagName('input')[1].value;
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('readonly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type', 'hidden');
edit.setAttribute('readonly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 1) {
cell.setData = function (data) {
if (data.name) {
cell.firstChild.value = data.name;
}
};
cell.getData = function (data) {
data.name = cell.firstChild.value;
}
cell.onDeselect = function () {
ERROR = false;
var data = new Object();
this.getData(data);
if (!ERROR) {
data.name = data.name;
this.setData(data);
}
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 2) {
cell.setData = function (data) {
if (data.account)
cell.getElementsByTagName('input')[0].value = data.account;
};
cell.getData = function (data) {
data.account = cell.firstChild.value;
}
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if (i == 3) {
var img;
cell.style.padding = "auto auto auto auto";
//insert
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src', 'modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index + 1);
refreshPositionIndex4();
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_DELETE_ROW']);
img.setAttribute('src', 'modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.parentNode.deleteRow();
refreshPositionIndex4();
};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src', 'modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.parentNode.moveUp();
refreshPositionIndex4();
};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt', MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src', 'modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function () {
this.parentNode.parentNode.moveDown();
refreshPositionIndex4();
}
cell.appendChild(img);
}
}
refreshPositionIndex4 = function () {
for (var i = 0; i < paramsTable4.rowCount(); i++) {
var data = paramsTable4.row(i).getData();
data.position = i + 1;
paramsTable4.row(i).setData(data);
}
}
ItemsList4 = function (json) {
var data = '';
for (var i = 0; i < paramsTable4.rowCount(); i++) {
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable4.row(i).getData());
}
return data;
}
if (paramsTable4.rowCount() == 0) {
paramsTable4.addRow();
refreshPositionIndex4();
}
;
paramsTable4.onSetCellData = function (row, cell, data) {
if (cell.innerHTML == '')
cell.innerHTML = '&nbsp;';
}
ItemListSave4 = function (json, el) {
var data = new Object();
var tmp;
for (var i = 0; i < paramsTable4.rowCount(); i++) {
data[i.toString()] = paramsTable4.row(i).getData();
}
paramsOptions = data;
var r = JSON.stringifyNoSecurity(paramsOptions);
doRequest(
'index.php',
'module=Accounts&action=price_conditionSave&to_pdf=1&paramslist=' + r + '&record=' + document.forms.EditView.record.value,
function (result) {
if (result.indexOf("Saved") >= 0)
alert("Zapisano!");
else
alert("Błąd podczas zapisywania!");
}
);
}
ItemListClear4 = function (noNew, save) {
if (typeof (save) == "string")
ItemListSave4(null, save);
while (paramsTable4.rowCount() > 0)
paramsTable4.row(0).deleteRow(noNew);
refreshPositionIndex4();
}
ItemListFill4 = function () {
var pl;
pl = document.getElementById('position_list4').value;
if (pl && pl != '') {
try {
pl = eval(pl);
for (x in pl) {
var pl_row = pl[x];
if (pl_row.template == '')
continue;
paramsTable4.addRow().setData(pl_row);
}
} catch (err) {
pl = null;
}
;
}
refreshPositionIndex4();
}
ItemListClear4();
ItemListFill4();
}
);

View File

@@ -0,0 +1,192 @@
//categories
function saveItems3(){
document.getElementById('position_list3').value = ItemsList3(true);
}
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 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);
}
}
var tbody_;
var ItemListSave3;
var ItemListClear3;
var ItemListFil3;
var FillText;
addEvent(
window,
'load',
function() {
var paramsTable3 = new paramsMT('itemsTable3');
paramsTable3.onCreateRow = function(row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function() {}
row.onSelect = function() {
}
row.onDeselect = function() {
}
}
paramsTable3.onCreateCell = function(cell) {
var i = cell.index;
if(i == 0) {
cell.setData = function(data) {
console.log(data);
if(data.ecmaccountcategory_name) {
cell.firstChild.value = data.ecmaccountcategory_name;
cell.getElementsByTagName('input')[1].value = data.ecmaccountcategory_id;
if (data.id)
cell.getElementsByTagName('input')[2].value = data.id;
}
};
cell.getData = function(data) {
data.ecmaccountcategory_name = cell.firstChild.value;
data.ecmaccountcategory_id = cell.getElementsByTagName('input')[1].value;
data.id = cell.getElementsByTagName('input')[2].value;
}
cell.onSelect = function() {
var cn = this.getElementsByTagName('input');
cn[0].name = 'name_p';
cn[0].id = 'name_p';
cn[1].name = 'id_p';
cn[1].id = 'id_p';
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.product_group = data.product_group;
this.setData(data);
}
var cn = this.getElementsByTagName('input');
cn[0].name = '';
cn[0].id = '';
cn[1].name = '';
cn[1].id = '';
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type','text');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
img.setAttribute('src','modules/EcmQuotes/images/search.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
var ecmpopup = open_popup( "EcmAccountCategories", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"id_p","name":"name_p"}}, "single", true );
setTimeout(function(){ecmpopup.focus();},200);
}
cell.appendChild(img);
}
if(i == 1) {
var img;
cell.style.padding="auto auto auto auto";
//insert
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
refreshPositionIndex();
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.deleteRow(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src','modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveUp(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src','modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveDown();refreshPositionIndex(); }
cell.appendChild(img);
}
}
ItemsList3 = function(json) {
var data = '';
for(var i=0; i<paramsTable3.rowCount(); i++) {
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable3.row(i).getData());
}
return data;
}
if(paramsTable3.rowCount() == 0) {paramsTable3.addRow();};
paramsTable3.onSetCellData = function(row,cell,data) {
if(cell.innerHTML == '') cell.innerHTML = '&nbsp;';
}
ItemListFill3 = function() {
var pl;
pl = document.getElementById('position_list3').value;
console.log(pl);
if(pl && pl != '') {
try {
pl = eval(pl);
for(x in pl) { var pl_row = pl[x]; if (pl_row.template=='') continue; paramsTable3.addRow().setData(pl_row); }
} catch(err) { pl = null; };
}
}
ItemListClear3 = function(noNew,save) {
if(typeof(save)=="string") ItemListSave(null,save);
while(paramsTable3.rowCount()>0) paramsTable3.row(0).deleteRow(noNew);
}
ItemListClear3();
ItemListFill3();
}
);

View File

@@ -0,0 +1,224 @@
//addresses
function saveItems2(){
document.getElementById('position_list2').value = ItemsList2(true);
}
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 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);
}
}
var tbody_;
var ItemListSave2;
var ItemListClear2;
var ItemListFil2;
var FillText;
addEvent(
window,
'load',
function() {
var paramsTable2 = new paramsMT('itemsTable2');
paramsTable2.onCreateRow = function(row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function() {}
row.onSelect = function() {
}
row.onDeselect = function() {
}
}
paramsTable2.onCreateCell = function(cell) {
var i = cell.index;
cell.change = function(select) {};
if(i == 0) {
cell.setData = function(data) {
console.log(data);
if(data.ecmproductcategory_name) {
cell.firstChild.value = data.ecmproductcategory_name;
cell.getElementsByTagName('input')[1].value = data.ecmproductcategory_id;
if (data.id)
cell.getElementsByTagName('input')[2].value = data.id;
}
};
cell.getData = function(data) {
data.ecmproductcategory_name = cell.firstChild.value;
data.ecmproductcategory_id = cell.getElementsByTagName('input')[1].value;
data.id = cell.getElementsByTagName('input')[2].value;
}
cell.onSelect = function() {
var cn = this.getElementsByTagName('input');
cn[0].name = 'name_p';
cn[0].id = 'name_p';
cn[1].name = 'id_p';
cn[1].id = 'id_p';
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.product_group = data.product_group;
this.setData(data);
}
var cn = this.getElementsByTagName('input');
cn[0].name = '';
cn[0].id = '';
cn[1].name = '';
cn[1].id = '';
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type','text');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
img.setAttribute('src','modules/EcmQuotes/images/search.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
var ecmpopup = open_popup( "EcmProductCategories", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"id_p","name":"name_p"}}, "single", true );
setTimeout(function(){ecmpopup.focus();},200);
}
cell.appendChild(img);
}
if(i == 1) {
cell.setData = function(data) {
if (data.discount)
cell.getElementsByTagName('input')[0].value = FormatNumber(data.discount);
};
cell.getData = function(data) {
data.discount = UnformatNumber(cell.firstChild.value);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.discount = data.discount;
this.setData(data);
}
}
cell.onDeselect = function() {
}
var edit = document.createElement('input');
edit.setAttribute('type','text');
edit.setAttribute('tabIndex',1);
edit.setAttribute('onChange','$(this).val(FormatNumber($(this).val(),2));');
edit.className = 'inputs';
edit.value = NumberToUserFormatNumber(0);
cell.appendChild(edit);
}
if(i == 2) {
var img;
cell.style.padding="auto auto auto auto";
//insert
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
refreshPositionIndex();
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.deleteRow(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src','modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveUp(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src','modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveDown();refreshPositionIndex(); }
cell.appendChild(img);
}
}
ItemsList2 = function(json) {
var data = '';
for(var i=0; i<paramsTable2.rowCount(); i++) {
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable2.row(i).getData());
}
return data;
}
if(paramsTable2.rowCount() == 0) {paramsTable2.addRow();};
paramsTable2.onSetCellData = function(row,cell,data) {
if(cell.innerHTML == '') cell.innerHTML = '&nbsp;';
}
ItemListFill2 = function() {
var pl;
pl = document.getElementById('position_list2').value;
console.log(pl);
if(pl && pl != '') {
try {
pl = eval(pl);
for(x in pl) { var pl_row = pl[x]; if (pl_row.template=='') continue; paramsTable2.addRow().setData(pl_row); }
} catch(err) { pl = null; };
}
}
ItemListClear2 = function(noNew,save) {
if(typeof(save)=="string") ItemListSave(null,save);
while(paramsTable2.rowCount()>0) paramsTable2.row(0).deleteRow(noNew);
}
ItemListClear2();
ItemListFill2();
}
);

View File

@@ -0,0 +1,322 @@
//addresses
function saveItems55() {
document.getElementById('position_list55').value = ItemsList55(true);
}
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 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);
}
}
var tbody_;
var ItemListSave2;
var ItemListClear2;
var ItemListFil2;
var FillText;
addEvent(
window,
'load',
function() {
var paramsTable2 = new paramsMT('itemsTable55');
paramsTable2.onCreateRow = function(row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function() {
}
row.onSelect = function() {
}
row.onDeselect = function() {
}
}
paramsTable2.onCreateCell = function(cell) {
var i = cell.index;
cell.change = function(select) {
};
if (i == 0) {
cell.setData = function(data) {
console.log(data);
if(data.product_group) {
cell.firstChild.value = data.product_group;
cell.getElementsByTagName('input')[1].value = data.cat_id;
if (data.id)
cell.getElementsByTagName('input')[2].value = data.id;
}
};
cell.getData = function(data) {
data.product_group = cell.firstChild.value;
data.cat_id = cell.getElementsByTagName('input')[1].value;
data.id = cell.getElementsByTagName('input')[2].value;
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if (!ERROR) {
this.setData(data);
}
var cn = this.getElementsByTagName('input');
cn[0].name = '';
cn[0].id = '';
cn[1].name = '';
cn[1].id = '';
}
cell.onSelect = function() {
var cn = this.getElementsByTagName('input');
cn[0].name = 'name_mailinggroup';
cn[0].id = 'name_mailinggroup';
cn[1].name = 'id_mailinggroup';
cn[1].id = 'id_mailinggroup';
}
// cell.select = function() { this.selectNext(); }
// cell.selectNext = function() { var row =
// this.parentNode.selectNext(); row.select();
// row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type', 'text');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type', 'hidden');
edit.setAttribute('readonly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type', 'hidden');
edit.setAttribute('readonly', 'readonly');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
cell.appendChild(edit);
var img = document.createElement('img');
img.setAttribute('alt', 'Search');
img.setAttribute('src',
'modules/EcmQuotes/images/search.gif');
img.style.cursor = 'pointer';
if(module_sugar_grp1=='Accounts'){
var formType='Accounts';
}
if(module_sugar_grp1=='Leads'){
var formType='Accounts';
}
if(module_sugar_grp1=='Contacts'){
var formType='Contacts';
}
if(module_sugar_grp1=='ContactLeads'){
var formType='Contacts';
}
img.onclick = function() {
var ecmpopup = open_popup("EcmMailingCategories", 600,
400, "&type_advanced="+formType, true, false, {
"call_back_function" : "set_return",
"form_name" : "EditView",
"field_to_name_array" : {
"id" : "id_mailinggroup",
"name" : "name_mailinggroup"
}
}, "single", true);
setTimeout(function() {
ecmpopup.focus();
}, 200);
}
cell.appendChild(img);
}
if (i == 1) {
cell.setData = function(data) {
if (data.discount!=1){
cell.getElementsByTagName('input')[0].checked = false;
}
};
cell.getData = function(data) {
data.discount = UserFormatNumberToNumber(cell.firstChild.value);
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if (!ERROR) {
data.discount = data.discount;
this.setData(data);
}
}
var edit = document.createElement('input');
edit.setAttribute('type', 'checkbox');
edit.setAttribute('tabIndex', 1);
edit.className = 'inputs';
edit.checked = true;
edit.value = 1;
cell.appendChild(edit);
}
if (i == 2) {
var img;
cell.style.padding = "auto auto auto auto";
// insert
img = document.createElement('img');
img.setAttribute('alt','ADD');
img.setAttribute('src',
'modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable
.addRow(this.parentNode.parentNode.index + 1);
refreshPositionIndex();
};
// delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt', 'DELETE');
img.setAttribute('src',
'modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.parentNode.deleteRow();
refreshPositionIndex();
};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
// move up
img = document.createElement('img');
img.setAttribute('alt','UP');
img.setAttribute('src',
'modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.parentNode.moveUp();
refreshPositionIndex();
};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
// move down
img = document.createElement('img');
img.setAttribute('alt', 'DOWN');
img.setAttribute('src',
'modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.parentNode.moveDown();
refreshPositionIndex();
}
cell.appendChild(img);
}
}
ItemsList55 = function(json) {
var data = '';
for (var i = 0; i < paramsTable2.rowCount(); i++) {
var a=0;
var data2=new Object();
$(paramsTable2.row(i)).find("td input").each(function() {
if(a==3){
if($(this).prop("checked")==true){
data2.discount=1;
} else {
data2.discount=0;
}
}
if(a==0){
data2.product_group=$(this).val();
}
if(a==1){
data2.cat_id=$(this).val();
}
if(a==2){
data2.id=$(this).val();
}
a++;
});
data = data
+ '||||'
+ JSON.stringifyNoSecurity(data2);
}
return data;
}
if (paramsTable2.rowCount() == 0) {
paramsTable2.addRow();
}
;
paramsTable2.onSetCellData = function(row, cell, data) {
if (cell.innerHTML == '')
cell.innerHTML = '&nbsp;';
}
ItemListFill2 = function() {
var pl;
pl = document.getElementById('position_list55').value;
console.log(pl);
if (pl && pl != '') {
try {
pl = eval(pl);
for (x in pl) {
var pl_row = pl[x];
if (pl_row.template == '')
continue;
paramsTable2.addRow().setData(pl_row);
}
} catch (err) {
pl = null;
}
;
}
}
ItemListClear2 = function(noNew, save) {
if (typeof (save) == "string")
ItemListSave(null, save);
while (paramsTable2.rowCount() > 0)
paramsTable2.row(0).deleteRow(noNew);
}
ItemListClear2();
ItemListFill2();
});

2308
modules/Accounts/MyTable.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
$(document).ready(function() {
var MaxInputs = 10; //maximum input boxes allowed
var InputsWrapper = $("#InputsWrapper"); //Input boxes wrapper ID
var AddButton = $("#AddMoreWWWBox"); //Add button ID
var x = InputsWrapper.length; //initlal text box count
var FieldCount=1; //to keep track of text box added
var weblists = $.parseJSON($("input[name='websites_list']").val()); // get and decode json object
$.each(weblists, function(idx, obj) { // add existing elements
FieldCount++; //text box added increment
//add input box
if(idx == 0 ){ // to first element
$( "div input[name='websites[]']" ).first().val(obj.www);
$( "div input[name='websites_id[]']" ).first().val(obj.id);
} else { // rest
$(InputsWrapper).append('<tr><td><input type="hidden" value="'+obj.id+'" name="websites_id[]"><input type="text" size="30" name="websites[]" id="field_'+ FieldCount +'" value="'+obj.www +'"/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&amp;themeName=Sugar5&amp;imageName=id-ff-remove.png"></a></td></tr>');
}
x++; //text box increment
});
$(AddButton).click(function (e) //on add input button click
{
if(x <= MaxInputs) //max input box allowed
{
FieldCount++; //text box added increment
//add input box
$(InputsWrapper).append('<tr><td><input type="hidden" value="" name="websites_id[]"><input type="text" size="30" name="websites[]" id="field_'+ FieldCount +'" value="http://"/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&amp;themeName=Sugar5&amp;imageName=id-ff-remove.png"></a></td>,/tr>');
x++; //text box increment
}
return false;
});
$("body").on("click",".removeclass", function(e){ //user click on remove text
if( x > 1 ) {
$(this).closest('tr').remove();//remove text box
x--; //decrement textbox
}
return false;
})
});

4
modules/Accounts/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

13
modules/Accounts/jquery_ui.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,57 @@
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var a = new Array();
var html = "";
var table = document.getElementById("ChartData");
for (var i = 0, row; row = table.rows[i]; i++) {
a[i] = new Array();
for (var j = 0, col; col = row.cells[j]; j++) {
a[i][j]=row.cells[j].textContent;
if(j>0 && i > 0){
a[i][j] = a[i][j].replace(".", "").replace(".", "");
a[i][j] = parseFloat(a[i][j].replace(",", "."));
}
}
}
// Calculate the width and height of the Array
var w = a.length ? a.length : 0,
h = a[0] instanceof Array ? a[0].length : 0;
// In case it is a zero matrix, no transpose routine needed.
if(h === 0 || w === 0) { t=[]; }
/**
* @var {Number} i Counter
* @var {Number} j Counter
* @var {Array} t Transposed data is stored in this array.
*/
var i, j, t = [];
// Loop through every item in the outer array (height)
for(i=0; i<h-1; i++) {
// Insert a new row (array)
t[i] = [];
// Loop through every item per item in outer array (width)
for(j=0; j<w-1; j++) {
// Save transposed data.
t[i][j] = a[j][i];
}
}
var data = google.visualization.arrayToDataTable(t);
formatter = new google.visualization.NumberFormat({
suffix: ' zł',
fractionDigits: '2',
decimalSymbol: ',',
groupingSymbol: '.',
});
for (i = 1; i < data.getNumberOfColumns(); i++) {
formatter.format(data, i);
}
var options = {
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}

View File

@@ -0,0 +1,29 @@
$(function() {
var availableTags = [
"zachodniopomorskie",
"dolnośląskie",
"kujawsko-pomorskie",
"lubelskie",
"lubuskie",
"łódzkie",
"małopolskie",
"mazowieckie",
"opolskie",
"podkarpackie",
"podlaskie",
"pomorskie",
"śląskie",
"świętokrzyskie",
"warmińsko-mazurskie",
"wielkopolskie"
];
var $searchBox = $( "input[name='register_address_state']");
$searchBox.autocomplete({
source: availableTags
});
var $searchBox2 = $( "input[name='billing_address_state']");
$searchBox2.autocomplete({
source: availableTags
});
});

View File

@@ -0,0 +1,47 @@
$(document).ready(function() {
console.log('ten plik');
$('.loading_panel').hide();
var MaxInputs = 10; //maximum input boxes allowed
var InputsWrapper = $("#InputsWrapper2"); //Input boxes wrapper ID
var AddButton = $("#AddMoreWWWBox2"); //Add button ID
var x = InputsWrapper.length; //initlal text box count
var FieldCount=1; //to keep track of text box added
var weblists = $.parseJSON($("input[name='telephones_list']").val()); // get and decode json object
$.each(weblists, function(idx, obj) { // add existing elements
FieldCount++; //text box added increment
//add input box
if(idx == 0 ){ // to first element
$( "div input[name='telephones[]']" ).first().val(obj.telephone);
$( "div input[name='telephones_id[]']" ).first().val(obj.id);
} else { // rest
$(InputsWrapper).append('<tr><td><input type="hidden" value="'+obj.id+'" name="telephones_id[]"><input type="text" size="30" name="telephones[]" id="field_'+ FieldCount +'" value="'+obj.telephone +'"/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&amp;themeName=Sugar5&amp;imageName=id-ff-remove.png"></a></td></tr>');
}
x++; //text box increment
});
$(AddButton).click(function (e) //on add input button click
{
if(x <= MaxInputs) //max input box allowed
{
FieldCount++; //text box added increment
//add input box
$(InputsWrapper).append('<tr><td><input type="hidden" value="" name="telephones_id[]"><input type="text" size="30" name="telephones[]" id="field_'+ FieldCount +'" value=""/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&amp;themeName=Sugar5&amp;imageName=id-ff-remove.png"></a></td>,/tr>');
x++; //text box increment
}
return false;
});
$("body").on("click",".removeclass", function(e){ //user click on remove text
if( x > 1 ) {
$(this).closest('tr').remove();//remove text box
x--; //decrement textbox
}
return false;
})
});

View File

@@ -0,0 +1,47 @@
$(document).ready(function() {
$('.loading_panel').hide();
var MaxInputs = 10; //maximum input boxes allowed
var InputsWrapper = $("#InputsWrapper"); //Input boxes wrapper ID
var AddButton = $("#AddMoreWWWBox"); //Add button ID
var x = InputsWrapper.length; //initlal text box count
var FieldCount=1; //to keep track of text box added
var weblists = $.parseJSON($("input[name='websites_list']").val()); // get and decode json object
$.each(weblists, function(idx, obj) { // add existing elements
FieldCount++; //text box added increment
//add input box
if(idx == 0 ){ // to first element
$( "div input[name='websites[]']" ).first().val(obj.www);
$( "div input[name='websites_id[]']" ).first().val(obj.id);
} else { // rest
$(InputsWrapper).append('<tr><td><input type="hidden" value="'+obj.id+'" name="websites_id[]"><input type="text" size="30" name="websites[]" id="field_'+ FieldCount +'" value="'+obj.www +'"/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&amp;themeName=Sugar5&amp;imageName=id-ff-remove.png"></a></td></tr>');
}
x++; //text box increment
});
$(AddButton).click(function (e) //on add input button click
{
if(x <= MaxInputs) //max input box allowed
{
FieldCount++; //text box added increment
//add input box
$(InputsWrapper).append('<tr><td><input type="hidden" value="" name="websites_id[]"><input type="text" size="30" name="websites[]" id="field_'+ FieldCount +'" value="http://"/></td><td><a href="#" class="removeclass"><img class="id-ff-remove" name="0" src="index.php?entryPoint=getImage&amp;themeName=Sugar5&amp;imageName=id-ff-remove.png"></a></td>,/tr>');
x++; //text box increment
}
return false;
});
$("body").on("click",".removeclass", function(e){ //user click on remove text
if( x > 1 ) {
$(this).closest('tr').remove();//remove text box
x--; //decrement textbox
}
return false;
})
});

View File

@@ -0,0 +1,43 @@
$(document)
.ready(
function() {
var mapProp = {
center : new google.maps.LatLng(52.05, 19.45),
zoom : 6,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document
.getElementById("googleMapContainer"), mapProp);
var markers = JSON.parse(b64_to_utf8($('#googleMapMarkers')
.val()));
$.each(markers, function(index, m) {
var marker = new google.maps.Marker({
position : new google.maps.LatLng(m.lat, m.lng),
url : '/',
animation : google.maps.Animation.DROP,
customInfo : m.info,
title : m.title,
map : map
});
google.maps.event.addListener(marker, 'click',
markerClickFunction);
});
function markerClickFunction() {
infowindow = new google.maps.InfoWindow({
content : this.customInfo
});
infowindow.open(map, this);
closeInfoWindow(infowindow);
}
function closeInfoWindow(infoWindow) {
setTimeout(function() {
infoWindow.close();
}, 8000);
}
});
function b64_to_utf8(str) {
return decodeURIComponent(escape(window.atob(str)));
}

View File

@@ -0,0 +1,448 @@
function NumberToUserFormatNumber(number,add) {
if(!number) number = 0;
number = parseFloat(number);
var tmp = number.toFixed(OPT['dec_len']);
var s1 = tmp.substring(0,tmp.length-1-OPT['dec_len']);
var s2 = tmp.substring(tmp.length-OPT['dec_len'],tmp.length);
var tmp = '';
for(var i=s1.length;i>0;i-=3) {
tmp = ((i<=3)?"":OPT['sep_1000'])+s1.substring(i-3,i)+tmp;
}
s1 = tmp;
return (s1+OPT['dec_sep']+s2).toString()+((add)?add:'');
}
function UserFormatNumberToNumber(ufn,add) {
if(add) {
var match = /add/g;
ufn = ufn.replace(match,'');
}
var match = /Err/g;
ufn = ufn.replace(match,'');
if(!ufn) return parseFloat(0);
var pos = ufn.indexOf(OPT['dec_sep']);
var s1='', s2='';
if(pos==-1) { s1 = ufn; s2 = ''; }
else { s1 = ufn.substring(0,pos); s2 = ufn.substring(pos+1,ufn.length); }
/*
if(OPT['sep_1000'] != "")
for(var i=s1.length-4;i>=0;i-=4)
if(s1.charAt(i) != OPT['sep_1000']) { return -1; }
if(s1.charAt(0) == OPT['sep_1000']) return -1;
*/
var pos = -1;
while((pos = s1.indexOf(OPT['sep_1000'])) != -1)
s1 = s1.substring(0,pos)+s1.substring(pos+1,s1.length);
//alert(s1);
return parseFloat(s1+"."+s2);
}
function keyPressedNumber(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
function isEnterOrTabPressed(e) {
var keynum = keyPressedNumber(e);
if(keynum == 9 || keynum == 13) return true; else return false;
}
function setSelectionRange(obj) {
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh-1);
range.select();
} else {
if(obj.setSelectionRange) {
obj.setSelectionRange(0,obj.value.length);
}
}
obj.focus();
}
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
}
function paramsMT(name) {
this.myTableName = name;
this.table = document.getElementById(this.myTableName);
this.thead = this.table.tHead;
this.tbody = this.table.tBodies.item(0);
this.cellSelectedClass = 'selectedCell';
this.rowSelectedClass = 'selectedRow';
this.selectedRow;
this.selectedCell;
this.rowCount = function() {
return this.tbody.rows.length;
}
this.colCount = function() {
return this.thead.rows.item(0).cells.length;
};
this.colWidth = function(i) {
return this.thead.rows.item(0).cells.item(i).width;
};
this.moveUpRow = function() {
if(this.selectedRow) this.selectedRow.moveUp();
};
this.moveDownRow = function() {
if(this.selectedRow) this.selectedRow.moveDown();
};
this.insertRow = function(row, newRow) {
if(!row)
if(this.rowCount())
if(typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length-1);
var row_tmp;
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
if(this.rowCount() > 0 && row.nextSibling)
this.tbody.insertBefore(row_tmp, row.nextSibling);
else
this.tbody.appendChild(row_tmp);
return row_tmp;
};
this.refreshRowIndex = function() {
for(var i=0; i<this.rowCount(); i++) {
this.tbody.rows.item(i).index = i;
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
}
}
this.onRefreshRowIndex;
this.addRow = function(i,data) {
var row = this.createRow();
if(this.selectedRow) this.selectedRow.deselect();
if(this.selectedCell) this.selectedCell.deselect();
row.myTable = this;
if(i || i===0)
this.tbody.insertBefore(row,this.tbody.rows.item(i));
else
this.tbody.appendChild(row);
this.refreshRowIndex();
this.setRowData(row, data);
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
return row;
}
this.createRow = function(row) {
var row = document.createElement('tr');
row.myTable = this;
row.isnew = false;
row.onclick = function() { this.select(); }
row.select = function() {
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
this.myTable.selectedRow = this;
this.className = this.myTable.rowSelectedClass;
if(row.onSelect) row.onSelect();
}
}
row.deselect = function() {
if(this.myTable.selectedRow === this) {
this.className = '';
this.myTable.selectedRow = '';
if(row.onDeselect) row.onDeselect();
}
};
row.selectNext = function() {
if(this.index < this.myTable.rowCount()-1) { this.deselect(); this.nextSibling.select(); return this.nextSibling; }
else {
if(this.noAddNew) return this;
this.deselect();
var row = this.myTable.addRow(); return row;
}
}
row.selectPrevious = function() {
this.deselect();
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
}
row.deleteRow = function(noNew) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
if(this.myTable.rowCount() == 1 && !noNew) {
var MyTaBlE = this.myTable;
setTimeout( function() { MyTaBlE.addRow();} , 1000);
}
this.myTable.tbody.removeChild(this);
this.myTable.refreshRowIndex();
}
row.moveUp = function() {
if(!this.previousSibling) return;
this.myTable.tbody.insertBefore(this,this.previousSibling);
this.myTable.refreshRowIndex();
}
row.moveDown = function() {
if(!this.nextSibling) this.myTable.addRow(row);
this.myTable.tbody.insertBefore(this.nextSibling,this);
this.myTable.refreshRowIndex();
}
row.setData = function(data) {
if(!data || typeof(data) != "object") { return; };
for(var i=0; i<this.myTable.colCount(); i++) {
this.cells.item(i).setData(data);
}
}
row.getData = function() {
var data = new Object();
for(var i=0; i<this.myTable.colCount(); i++) {
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
}
return data;
}
for(var i=0; i<this.colCount(); i++) {
var cell = this.createCell(i);
row.appendChild(cell);
}
if(this.onCreateRow) this.onCreateRow(row);
return row;
};
this.onCreateRow; //function(row) {}
this.createCell = function(i) {
var cell = document.createElement('td');
cell.index = i;
cell.myTable = this;
cell.onclick = function() { this.select(); }
cell.select = function() {
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
this.myTable.selectedCell = this;
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
if(this.onSelect) this.onSelect();
this.className = this.myTable.cellSelectedClass;
}
}
cell.deselect = function() {
if(this.myTable.selectedCell === this) {
if(cell.onDeselect) cell.onDeselect();
this.className = '';
this.selected = false;
this.myTable.selectedCell = '';
}
};
cell.selectNext = function() {
this.deselect();
if(this.nextSibling) this.nextSibling.select();
else {
if(!this.parentNode.nextSibling) { if(this.noNewAdd) return; else this.myTable.addRow(); }
this.parentNode.nextSibling.select();
this.parentNode.nextSibling.firstChild.select();
}
}
cell.afterCreate = function() {}
cell.setData = function(data) {}
cell.getData = function(data) {}
if(this.onCreateCell) this.onCreateCell(cell);
return cell;
};
this.onCreateCell; //function(cell) {}
this.setRowData = function(row,data) {
for(var i=0; i<this.colCount(); i++) {
this.setCellData(row,row.cells.item(i),data);
}
}
this.setCellData = function(row,cell,data) {
if(typeof(row) == "number")
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
if(typeof(cell) != "object")
if(typeof(cell) == "number" && typeof(row) == "object") {
if(row.cells.item(cell))
cell = row.cells.item(cell);
else return;
}
else return;
if(this.onSetCellData) this.onSetCellData(row,cell,data);
}
this.onSetCellData; //function(row,cell,data) {}
this.selectRow = function(row) {
if(this.selectedRow === row) return;
if(this.selectedRow) this.deselectRow();
this.selectedRow = row;
this.selectedRow.className = this.rowSelectedClass;
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
}
this.selectNextRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.nextSibling) this.insertRow();
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.nextSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.selectPreviousRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.previousSibling) return;
if(this.selectedRow === this.tbody.rows.item(0)) return;
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.previousSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.refreshNumeration = function() {
for(var i=0; i<this.tbody.rows.length; i++)
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
}
this.KeyPressedNumber = function(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
this.KeyPressed = function(e, cell, method) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
if((keynum == 9) || (keynum == 13)) {
cell.selectNext();
return false;
}
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|| (keynum == 8) //backspace
|| (keynum == 46) //delete
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188); //,
}
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
}

View File

@@ -0,0 +1,39 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
if(typeof(SUGAR)=='undefined'){var SUGAR={};}
SUGAR.Administration={Async:{},RepairXSS:{toRepair:new Object,currentRepairObject:"",currentRepairIds:new Array(),repairedCount:0,numberToFix:25,refreshEstimate:function(select){this.toRepair=new Object();this.repairedCount=0;var button=document.getElementById('repairXssButton');var selected=select.value;var totalDisplay=document.getElementById('repairXssDisplay');var counter=document.getElementById('repairXssCount');var repaired=document.getElementById('repairXssResults');var repairedCounter=document.getElementById('repairXssResultCount');if(selected!="0"){button.style.display='inline';repairedCounter.value=0;AjaxObject.startRequest(callbackRepairXssRefreshEstimate,"&adminAction=refreshEstimate&bean="+selected);}else{button.style.display='none';totalDisplay.style.display='none';repaired.style.display='none';counter.value=0;repaired.value=0;}},executeRepair:function(){if(this.toRepair){if(this.currentRepairIds.length<1){if(!this.loadRepairQueue()){alert(done);return;}}
var beanIds=new Array();for(var i=0;i<this.numberToFix;i++){if(this.currentRepairIds.length>0){beanIds.push(this.currentRepairIds.pop());}}
var beanId=JSON.stringifyNoSecurity(beanIds);AjaxObject.startRequest(callbackRepairXssExecute,"&adminAction=repairXssExecute&bean="+this.currentRepairObject+"&id="+beanId);}},loadRepairQueue:function(){var loaded=false;this.currentRepairObject='';this.currentRepairIds=new Array();for(var bean in this.toRepair){if(this.toRepair[bean].length>0){this.currentRepairObject=bean;this.currentRepairIds=this.toRepair[bean];loaded=true;}}
this.toRepair[this.currentRepairObject]=new Array();return loaded;}}}

View File

@@ -0,0 +1,37 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var AjaxObject={ret:'',currentRequestObject:null,timeout:30000,forceAbort:false,_reset:function(){this.timeout=30000;this.forceAbort=false;},handleFailure:function(o){alert('asynchronous call failed.');},startRequest:function(callback,args,forceAbort){if(this.currentRequestObject!=null){if(this.forceAbort==true||callback.forceAbort==true){YAHOO.util.Connect.abort(this.currentRequestObject,null,false);}}
this.currentRequestObject=YAHOO.util.Connect.asyncRequest('POST',"./index.php?module=Administration&action=Async&to_pdf=true",callback,args);this._reset();},refreshEstimate:function(o){this.ret=JSON.parse(o.responseText);document.getElementById('repairXssDisplay').style.display='inline';document.getElementById('repairXssCount').value=this.ret.count;SUGAR.Administration.RepairXSS.toRepair=this.ret.toRepair;},showRepairXssResult:function(o){var resultCounter=document.getElementById('repairXssResultCount');this.ret=JSON.parse(o.responseText);document.getElementById('repairXssResults').style.display='inline';if(this.ret.msg=='success'){SUGAR.Administration.RepairXSS.repairedCount+=this.ret.count;resultCounter.value=SUGAR.Administration.RepairXSS.repairedCount;}else{resultCounter.value=this.ret;}
SUGAR.Administration.RepairXSS.executeRepair();}};var callbackRepairXssRefreshEstimate={success:AjaxObject.refreshEstimate,failure:AjaxObject.handleFailure,timeout:AjaxObject.timeout,scope:AjaxObject};var callbackRepairXssExecute={success:AjaxObject.showRepairXssResult,failure:AjaxObject.handleFailure,timeout:AjaxObject.timeout,scope:AjaxObject};

41
modules/Campaigns/DetailView.js Executable file
View File

@@ -0,0 +1,41 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function set_return_prospect_list_and_save(popup_reply_data)
{var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;for(var the_key in name_to_value_array)
{if(the_key=='toJSON')
{}
else
{window.document.forms[form_name].elements[the_key].value=name_to_value_array[the_key];}}
window.document.forms[form_name].module.value='Campaigns';window.document.forms[form_name].return_module.value=window.document.forms[form_name].module.value;window.document.forms[form_name].return_action.value='DetailView';window.document.forms[form_name].return_id.value=window.document.forms[form_name].record.value;window.document.forms[form_name].action.value='SaveCampaignProspectListRelationship';window.document.forms[form_name].submit();}

63
modules/Campaigns/WebToLead.js Executable file
View File

@@ -0,0 +1,63 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var grid2,grid3,grid4,grid3F,grid4F;var add_all_fields=SUGAR.language.get('app_strings','LBL_ADD_ALL_LEAD_FIELDS');var remove_all_fields=SUGAR.language.get('app_strings','LBL_REMOVE_ALL_LEAD_FIELDS');function addGrids(form_name){if(!check_form('WebToLeadCreation')){return false;}
else{grid3=SUGAR_GRID_grid1;grid4=SUGAR_GRID_grid2;var webFormDiv=document.getElementById('webformfields');addCols(grid3,'colsFirst',webFormDiv);addCols(grid4,'colsSecond',webFormDiv);return true;}}
function checkFields(REQUIRED_LEAD_FIELDS,LEAD_SELECT_FIELDS){grid2=SUGAR_GRID_grid0;grid3=SUGAR_GRID_grid1;grid4=SUGAR_GRID_grid2;var reqFields='';for(var i=0;i<grid2.getRecordSet().getLength();i++){if(grid2.getRecord(i).getData()[2]!=null){reqFields=reqFields+grid2.getRecord(i).getData()[0]+', ';}}
if(reqFields){reqFields=reqFields.substring(0,reqFields.lastIndexOf(','));alert(REQUIRED_LEAD_FIELDS+' '+reqFields);return false;}
else if(grid3.getRecordSet().getLength()==1&&grid4.getRecordSet().getLength()==1){alert(LEAD_SELECT_FIELDS);return false;}
else{return true;}}
function askLeadQ(direction,REQUIRED_LEAD_FIELDS,LEAD_SELECT_FIELDS){if(direction=='back'){var grid_Div=document.getElementById('grid_Div');var lead_Div=document.getElementById('lead_queries_Div');grid_Div.style.display='block';lead_Div.style.display='none';}
if(direction=='next'){if(!checkFields(REQUIRED_LEAD_FIELDS,LEAD_SELECT_FIELDS)){return false;}
else{var lead_Div=document.getElementById('lead_queries_Div');var grid_Div=document.getElementById('grid_Div');lead_Div.style.display='block';grid_Div.style.display='none';}}}
function campaignPopulated(){var camp_populated=document.getElementById('campaign_id');if(camp_populated.value==0){return true;};return true;}
function selectFields(indexes,grid){var retStr='';for(var i=0;i<indexes.length;i++){retStr=retStr+grid.getRow(indexes[i]).childNodes[0].childNodes[0].innerHTML+','+'\n';retStr=retStr+'\n';}
return retStr.substring(0,retStr.lastIndexOf(','));}
function displayAddRemoveDragButtons(Add_All_Fields,Remove_All_Fields){var addRemove=document.getElementById("lead_add_remove_button");if(grid2.getRecordSet().getLength()==0){addRemove.setAttribute('value',Remove_All_Fields);addRemove.setAttribute('title',Remove_All_Fields);}
else if(grid3.getRecordSet().getLength()==0&&grid4.getRecordSet().getLength()==0){addRemove.setAttribute('value',Add_All_Fields);addRemove.setAttribute('title',Add_All_Fields);}}
function displayAddRemoveButtons(Add_All_Fields,Remove_All_Fields){var addRemove=document.getElementById("lead_add_remove_button");if(grid2.getRecordSet().getLength()>1){addRemove.setAttribute('value',Add_All_Fields);addRemove.setAttribute('title',Add_All_Fields);}
else{addRemove.setAttribute('value',Remove_All_Fields);addRemove.setAttribute('title',Remove_All_Fields);}}
function dragDropAllFields(Add_All_Fields,Remove_All_Fields){grid2=SUGAR_GRID_grid0;grid3=SUGAR_GRID_grid1;grid4=SUGAR_GRID_grid2;var addRemove=document.getElementById("lead_add_remove_button");var availibleSet=grid2.getRecordSet();var availibleCount=availibleSet.getLength();if(addRemove.value==Add_All_Fields&&availibleCount>1){for(var i=0;i<availibleCount;i++){if(i%2==0&&availibleSet.getRecord(i).getData()[0]!=" "){grid3.addRow(availibleSet.getRecord(i).getData(),(i/2));}
if(i%2==1&&availibleSet.getRecord(i).getData()[0]!=" "){grid4.addRow(availibleSet.getRecord(i).getData(),((i-1)/2));}}
for(i=availibleCount-1;i>=0;i--){if(grid2.getRecord(i)!=null&&grid2.getRecord(i).getData()[0]!=" "){grid2.deleteRow(i);}}}
else if(addRemove.value==Remove_All_Fields){var count=0;if(grid3.getRecordSet().getLength()>=grid4.getRecordSet().getLength()){count=grid3.getRecordSet().getLength();}
else{count=grid4.getRecordSet().getLength();}
for(var i=0;i<count;i++){if(grid3.getRecord(i)!=null&&grid3.getRecord(i).getData()[0]!=" "){grid2.addRow(grid3.getRecord(i).getData(),grid2.getRecordSet().getLength()-1);}
if(grid4.getRecord(i)!=null&&grid4.getRecord(i).getData()[0]!=" "){grid2.addRow(grid4.getRecord(i).getData(),grid2.getRecordSet().getLength()-1);}}
for(var i=count-1;i>=0;i--){if(grid4.getRecord(i)!=null&&grid4.getRecord(i).getData()[0]!=" "){grid4.deleteRow(i);}
if(grid3.getRecord(i)!=null&&grid3.getRecord(i).getData()[0]!=" "){grid3.deleteRow(i);}}}
displayAddRemoveButtons(Add_All_Fields,Remove_All_Fields);}
function addCols(grid,colsNumber,webFormDiv){for(var i=0;i<grid.getRecordSet().getLength()-1;i++){var selectedEl=grid.getRecord(i).getData()[1];var webField=document.createElement('input');webField.setAttribute('id',colsNumber+i);webField.setAttribute('name',colsNumber+'[]');webField.setAttribute('type','hidden');webField.setAttribute('value',selectedEl);webFormDiv.appendChild(webField);}}
function editUrl(){var chk_url_elm=document.getElementById("chk_edit_url");if(chk_url_elm.checked==true){var url_elm=document.getElementById("post_url");url_elm.disabled=false;}
if(chk_url_elm.checked==false){var url_elm=document.getElementById("post_url");url_elm.disabled=true;}}

56
modules/Campaigns/wizard.js Executable file
View File

@@ -0,0 +1,56 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function hide(divname){var elem1=document.getElementById(divname);elem1.style.display='none';}
function show(div){var elem1=document.getElementById(div);elem1.style.display='';}
function showdiv(div){hideall();show(div);}
function hideall(){var last_val=document.getElementById('wiz_total_steps');var last=parseInt(last_val.value);for(i=1;i<=last;i++){hide('step'+i);}}
function showfirst(wiz_mode){showdiv('step1');var current_step=document.getElementById('wiz_current_step');current_step.value="1";var save_button=document.getElementById('wiz_submit_button');var next_button=document.getElementById('wiz_next_button');var save_button_div=document.getElementById('save_button_div');var next_button_div=document.getElementById('next_button_div');var back_button_div=document.getElementById('back_button_div');save_button.disabled=true;back_button_div.style.display='none';save_button_div.style.display='none';next_button.focus();if(wiz_mode=='marketing'){back_button_div.style.display='';}
hilite(current_step.value);}
function navigate(direction){var current_step=document.getElementById('wiz_current_step');var currentValue=parseInt(current_step.value);if(validate_wiz(current_step.value,direction)){if(direction=='back'){current_step.value=currentValue-1;}
if(direction=='next'){current_step.value=currentValue+1;}
if(direction=='direct'){}
showdiv("step"+current_step.value);hilite(current_step.value);var total=document.getElementById('wiz_total_steps').value;var save_button=document.getElementById('wiz_submit_button');var back_button_div=document.getElementById('back_button_div');var save_button_div=document.getElementById('save_button_div');var next_button_div=document.getElementById('next_button_div');if(current_step.value==total){save_button.disabled=false;back_button_div.style.display='';save_button_div.style.display='';next_button_div.style.display='none';}else{if(current_step.value<2){back_button_div.style.display='none';}else{back_button_div.style.display='';}
var next_button=document.getElementById('wiz_next_button');next_button_div.style.display='';save_button_div.style.display='none';next_button.focus();}}else{}}
var already_linked='';function hilite(hilite){var last=parseInt(document.getElementById('wiz_total_steps').value);for(i=1;i<=last;i++){var nav_step=document.getElementById('nav_step'+i);nav_step.className='';}
var nav_step=document.getElementById('nav_step'+hilite);nav_step.className='';if(already_linked.indexOf(hilite)<0){nav_step.innerHTML="<a href='#' onclick=\"javascript:direct('"+hilite+"');\">"+nav_step.innerHTML+"</a>";already_linked+=',hilite';}}
function link_navs(beg,end){if(beg==''){beg=1;}
if(end==''){var last=document.getElementById('wiz_total_steps').value;end=last;}
beg=parseInt(beg);end=parseInt(end);for(i=beg;i<=end;i++){var nav_step=document.getElementById('nav_step'+i);nav_step.innerHTML="<a href='#' onclick=\"javascript:direct('"+i+"');\">"+nav_step.innerHTML+"</a>";}}
function direct(stepnumber){var current_step=document.getElementById('wiz_current_step');var currentValue=parseInt(current_step.value);if(validate_wiz(current_step.value,'direct')){current_step.value=stepnumber;navigate('direct');}else{}}
function validate_wiz(step,direction){var total=document.getElementById('wiz_total_steps').value;var wiz_message=document.getElementById('wiz_message');if(direction=='back'){if(step=='1'){var msg=SUGAR.language.get('mod_strings','LBL_WIZARD_FIRST_STEP_MESSAGE');wiz_message.innerHTML="<font color=\'red\' size=\'2\'><b>"+msg+"</b></font>";return false;}else{wiz_message.innerHTML='';}}
if(direction=='next'){if(step==total){var msg=SUGAR.language.get('mod_strings','LBL_WIZARD_LAST_STEP_MESSAGE');wiz_message.innerHTML="<font color=\'red\' size=\'2\'><b>"+msg+"</b></font>";return false;}else{wiz_message.innerHTML='';}}
if(direction=='direct'){}
if((direction!='direct')&&(window.validate_wiz_form)&&(!validate_wiz_form('step'+step))){return false;}
return true;}

56
modules/Connectors/Connector.js Executable file
View File

@@ -0,0 +1,56 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function run_test(source_id){var callback={success:function(data){var resultDiv=document.getElementById(source_id+'_result');resultDiv.innerHTML='<b>'+data.responseText+'</b>';},failure:function(data){var resultDiv=document.getElementById(source_id+'_result');resultDiv.innerHTML='<b>'+SUGAR.language.get('app_strings','ERROR_UNABLE_TO_RETRIEVE_DATA')+'</b>';},timeout:300000}
var resultDiv=document.getElementById(source_id+'_result');resultDiv.innerHTML='<img src=themes/default/images/sqsWait.gif>';document.ModifyProperties.source_id.value=source_id;document.ModifyProperties.action.value='RunTest';YAHOO.util.Connect.setForm(document.ModifyProperties);var cObj=YAHOO.util.Connect.asyncRequest('POST','index.php?module=Connectors',callback);document.ModifyProperties.action.value='SaveModifyProperties';}
var widgetTimout;function dswidget_open(elt){var wdiget_div=document.getElementById('dswidget_div');var objX=findPosX(elt);var objY=findPosY(elt);wdiget_div.style.top=(objY+15)+'px';wdiget_div.style.left=(objX)+'px';wdiget_div.style.display='block';}
function dswidget_close(){widgetTimout=setTimeout("hide_widget()",500);}
function hide_widget(){var wdiget_div=document.getElementById('dswidget_div');wdiget_div.style.display='none';}
function clearButtonTimeout(){if(widgetTimout){clearTimeout(widgetTimout);}}
function findPosX(obj)
{var curleft=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curleft+=obj.offsetLeft;obj=obj.offsetParent;}
if(obj!=null)
curleft+=obj.offsetLeft;}
else if(obj.x)
curleft+=obj.x;return curleft;}
function findPosY(obj)
{var curtop=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curtop+=obj.offsetTop;obj=obj.offsetParent;}
if(obj!=null)
curtop+=obj.offsetTop;}
else if(obj.y)
curtop+=obj.y;return curtop;}

61
modules/Contacts/Contact.js Executable file
View File

@@ -0,0 +1,61 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function set_campaignlog_and_save_background(popup_reply_data)
{var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;var passthru_data=popup_reply_data.passthru_data;var query_array=new Array();if(name_to_value_array!='undefined'){for(var the_key in name_to_value_array)
{if(the_key=='toJSON')
{}
else
{query_array.push(the_key+'='+name_to_value_array[the_key]);}}}
var selection_list;if(popup_reply_data.selection_list)
{selection_list=popup_reply_data.selection_list;}
else
{selection_list=popup_reply_data.name_to_value_array;}
if(selection_list!='undefined'){for(var the_key in selection_list)
{query_array.push('subpanel_id[]='+selection_list[the_key])}}
var module=get_module_name();var id=get_record_id();query_array.push('value=DetailView');query_array.push('module='+module);query_array.push('http_method=get');query_array.push('return_module='+module);query_array.push('return_id='+id);query_array.push('record='+id);query_array.push('isDuplicate=false');query_array.push('return_type=addcampaignlog');query_array.push('action=Save2');query_array.push('inline=1');var refresh_page=escape(passthru_data['refresh_page']);for(prop in passthru_data){if(prop=='link_field_name'){query_array.push('subpanel_field_name='+escape(passthru_data[prop]));}else{if(prop=='module_name'){query_array.push('subpanel_module_name='+escape(passthru_data[prop]));}else{query_array.push(prop+'='+escape(passthru_data[prop]));}}}
var query_string=query_array.join('&');request_map[request_id]=passthru_data['child_field'];var returnstuff=http_fetch_sync('index.php',query_string);request_id++;got_data(returnstuff,true);if(refresh_page==1){document.location.reload(true);}}
function validatePortalName(e){var portalName=document.getElementById('portal_name');var portalNameExisting=document.getElementById("portal_name_existing");var portalNameVerified=document.getElementById('portal_name_verified');if(typeof(portalName.parentNode.lastChild)!='undefined'&&portalName.parentNode.lastChild.tagName=='SPAN'){portalName.parentNode.lastChild.innerHTML='';}
if(portalName.value==portalNameExisting.value){return;}
var callbackFunction=function success(data){count=data.responseText;if(count!=0){add_error_style('EditView','portal_name',SUGAR.language.get('app_strings','ERR_EXISTING_PORTAL_USERNAME'));for(wp=1;wp<=10;wp++){window.setTimeout('fade_error_style(style, '+wp*10+')',1000+(wp*50));}
portalName.focus();}
if(portalNameVerified.parentNode.childNodes.length>1){portalNameVerified.parentNode.removeChild(portalNameVerified.parentNode.lastChild);}
verifiedTextNode=document.createElement('span');verifiedTextNode.innerHTML='';portalNameVerified.parentNode.appendChild(verifiedTextNode);portalNameVerified.value=count==0?"true":"false";verifyingPortalName=false;}
if(portalNameVerified.parentNode.childNodes.length>1){portalNameVerified.parentNode.removeChild(portalNameVerified.parentNode.lastChild);}
if(portalName.value!=''&&!verifyingPortalName){document.getElementById('portal_name_verified').value="false";verifiedTextNode=document.createElement('span');portalNameVerified.parentNode.appendChild(verifiedTextNode);verifiedTextNode.innerHTML=SUGAR.language.get('app_strings','LBL_VERIFY_PORTAL_NAME');verifyingPortalName=true;var cObj=YAHOO.util.Connect.asyncRequest('POST','index.php?module=Contacts&action=ValidPortalUsername&portal_name='+portalName.value,{success:callbackFunction,failure:callbackFunction});}}
function handleKeyDown(e){if((kc=e["keyCode"])){enterKeyPressed=(kc==13)?true:false;if(enterKeyPressed){validatePortalName(e);freezeEvent(e);setTimeout(forceSubmit,2100);}}}
function freezeEvent(e){if(e.preventDefault)e.preventDefault();e.returnValue=false;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();return false;}
function forceSubmit(){theForm=YAHOO.util.Dom.get('EditView');if(theForm){theForm.action.value='Save';if(!check_form('EditView')){return false;}
theForm.submit();}}
verifyingPortalName=false;enterKeyPressed=false;

29
modules/Contacts/js/States.js Executable file
View File

@@ -0,0 +1,29 @@
$(function() {
var availableTags = [
"zachodniopomorskie",
"dolnośląskie",
"kujawsko-pomorskie",
"lubelskie",
"lubuskie",
"łódzkie",
"małopolskie",
"mazowieckie",
"opolskie",
"podkarpackie",
"podlaskie",
"pomorskie",
"śląskie",
"świętokrzyskie",
"warmińsko-mazurskie",
"wielkopolskie"
];
var $searchBox = $( "input[name='primary_address_state']");
$searchBox.autocomplete({
source: availableTags
});
var $searchBox2 = $( "input[name='alt_address_state']");
$searchBox2.autocomplete({
source: availableTags
});
});

38
modules/Currencies/EditView.js Executable file
View File

@@ -0,0 +1,38 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function isoUpdate(formElem){if(typeof(js_iso4217[formElem.value])=='undefined'){return false;}
var thisForm=formElem.form;var thisCurr=js_iso4217[formElem.value];if(thisForm.name.value==''){thisForm.name.value=thisCurr.name;}
if(thisForm.symbol.value==''){thisForm.symbol.value='';for(var i=0;i<thisCurr.unicode.length;i++){thisForm.symbol.value=thisForm.symbol.value+String.fromCharCode(thisCurr.unicode[i]);}}
return true;}

View File

@@ -0,0 +1,198 @@
//categories
function saveItems3(){
document.getElementById('position_list3').value = ItemsList3(true);
}
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 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);
}
}
var tbody_;
var ItemListSave3;
var ItemListClear3;
var ItemListFil3;
var FillText;
addEvent(
window,
'load',
function() {
var paramsTable3 = new paramsMT('itemsTable3');
paramsTable3.onCreateRow = function(row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function() {}
row.onSelect = function() {
}
row.onDeselect = function() {
}
}
paramsTable3.onCreateCell = function(cell) {
var i = cell.index;
if(i == 0) {
cell.setData = function(data) {
console.log(data);
if(data.ecmproductcategory_name) {
cell.firstChild.value = data.ecmproductcategory_name;
cell.getElementsByTagName('input')[1].value = data.ecmproductcategory_id;
if (data.id)
cell.getElementsByTagName('input')[2].value = data.id;
}
};
cell.getData = function(data) {
data.ecmproductcategory_name = cell.firstChild.value;
data.ecmproductcategory_id = cell.getElementsByTagName('input')[1].value;
data.id = cell.getElementsByTagName('input')[2].value;
}
cell.onSelect = function() {
var cn = this.getElementsByTagName('input');
cn[0].name = 'name_p';
cn[0].id = 'name_p';
cn[1].name = 'id_p';
cn[1].id = 'id_p';
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.product_group = data.product_group;
this.setData(data);
}
var cn = this.getElementsByTagName('input');
cn[0].name = '';
cn[0].id = '';
cn[1].name = '';
cn[1].id = '';
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type','text');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
img.setAttribute('src','modules/EcmQuotes/images/search.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
var ecmpopup = open_popup( "EcmProductCategories", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"id_p","name":"name_p"}}, "single", true );
setTimeout(function(){ecmpopup.focus();},200);
}
cell.appendChild(img);
}
if(i == 1) {
var img;
cell.style.padding="auto auto auto auto";
//insert
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
refreshPositionIndex();
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.deleteRow(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src','modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveUp(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src','modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveDown();refreshPositionIndex(); }
cell.appendChild(img);
}
}
ItemsList3 = function(json) {
var data = '';
for(var i=0; i<paramsTable3.rowCount(); i++) {
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable3.row(i).getData());
}
return data;
}
if(paramsTable3.rowCount() == 0) {paramsTable3.addRow();};
paramsTable3.onSetCellData = function(row,cell,data) {
if(cell.innerHTML == '') cell.innerHTML = '&nbsp;';
}
ItemListFill3 = function() {
var pl;
pl = document.getElementById('position_list3').value;
console.log(pl);
if(pl && pl != '') {
try {
pl = eval(pl);
for(x in pl) { var pl_row = pl[x]; if (pl_row.template=='') continue; paramsTable3.addRow().setData(pl_row); }
} catch(err) { pl = null; };
}
}
ItemListClear3 = function(noNew,save) {
if(typeof(save)=="string") ItemListSave(null,save);
while(paramsTable3.rowCount()>0) paramsTable3.row(0).deleteRow(noNew);
}
ItemListClear3();
ItemListFill3();
var check_form_ = check_form;
check_form = function(formname) {
saveItems3();
return check_form_(formname);
}
}
);

View File

@@ -0,0 +1,48 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var rhandle=new RevisionListHandler();var from_popup_return=false;function document_set_return(popup_reply_data)
{from_popup_return=true;var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;related_doc_id='EMPTY';for(var the_key in name_to_value_array)
{if(the_key=='toJSON')
{}
else
{var displayValue=name_to_value_array[the_key];displayValue=displayValue.replace('&#039;',"'");displayValue=displayValue.replace('&amp;',"&");displayValue=displayValue.replace('&gt;',">");displayValue=displayValue.replace('&lt;',"<");displayValue=displayValue.replace('&quot; ',"\"");if(the_key=='related_doc_id'){related_doc_id=displayValue;}
window.document.forms[form_name].elements[the_key].value=displayValue;}}
related_doc_id=JSON.stringifyNoSecurity(related_doc_id);var conditions=new Array();conditions[conditions.length]={"name":"document_id","op":"starts_with","value":related_doc_id};var query=new Array();var query={"module":"DocumentRevisions","field_list":['id','revision','date_entered'],"conditions":conditions,"order":'date_entered desc'};result=global_rpcClient.call_method('query',query,true);rhandle.display(result);}
function RevisionListHandler(){}
RevisionListHandler.prototype.display=function(result){var names=result['list'];var rev_tag=document.getElementById('related_doc_rev_id');rev_tag.options.length=0;for(i=0;i<names.length;i++){rev_tag.options[i]=new Option(names[i].fields['revision'],names[i].fields['id'],false,false);}
rev_tag.disabled=false;}
function setvalue(source){src=new String(source.value);target=new String(source.form.document_name.value);if(target.length==0){lastindex=src.lastIndexOf("/");if(lastindex==-1){lastindex=src.lastIndexOf("\\");}
if(lastindex==-1){source.form.document_name.value=src;source.form.escaped_document_name.value=src;}else{source.form.document_name.value=src.substr(++lastindex,src.length);source.form.escaped_document_name.value=src.substr(lastindex,src.length);}}}
function toggle_template_type(istemplate){template_type=document.getElementById('template_type');if(istemplate.checked){template_type.disabled=false;}else{template_type.disabled=true;}}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,152 @@
var options = ["invoice","compain_note","return_note"];
$(document).ready(function () {
// parent Edit list
ParentEditList();
// tabelka z vatami
InitializeVatTable();
// Przypisani uzytkownicy
UserListEdit();
InitializeTableCost();
$("#currency_id").change(function() {
getNBPCurrencyExchange($("#currency_id :selected").val());
});
$("#value").change(function() {
$('#left_paid').val($("#value").val());
});
var previousVal;
var pollInterval = setInterval(function() {
var val = $('#document_date').val();
if (val !== previousVal) {
console.log('hmm');
getNBPCurrencyExchange($("#currency_id :selected").val());
}
previousVal = val;
}, 500);
if($('#dbase').val()!='saassystem'){
addToValidate('EditView', 'uploadfile','uploadfile',true,'Proszę wybrać plik!');
}
$('#category_id').on('change',function(){
if($.inArray($("#category_id").val(),options)>-1){
addToValidate('EditView', 'value','value',true,'Proszę wpisać kwotę dokumentu!');
addToValidate('EditView', 'document_date','document_date',true,'Proszę wybrać datę dokumentu!');
} else {
removeFromValidate('EditView', 'value');
removeFromValidate('EditView', 'document_date');
removeFromValidate('EditView', 'payment_date');
}
});
removeFromValidate('EditView', 'revision');
});
var check_form_ = check_form;
check_form = function (formname) {
window.onbeforeunload = null;
// unformat vat table positions before save
if($('#document_type').val()==""){
alert("Proszę wybrać typ faktury!");
return false;
}
var int;
if($.inArray($("#category_id").val(),options)>-1){
if ($("#value").val()=="") {
alert("Wartość dokumentu nie może być pusta!");
return false;
}
}
if ($("#currency_id").val()!="PLN") {
if($('#currency_value').val()==""){
alert("Proszę podać kurs waluty!");
return false;
}
}
if($.inArray($("#category_id").val(),options)>-1){
if (UnformatNumber($("#value").val())==0) {
alert("Wartość dokumentu nie może być równa zeru!");
return false;
}
if ($("#value").val()=="") {
alert("Wartość dokumentu nie może być pusta!");
}
if ($("#left_paid").val() != '0,00') {
addToValidate('EditView', 'payment_date','payment_date',true,'Proszę wpisać kwotę płatności!');
if($('#payment_date').val()==''){
alert('Wpisałeś kwotę do zapłaty, podaj termin płatności!');
return false;
} else {
// int=$("#left_paid").val(UnformatNumber($("#left_paid").val()));
// $("#value").val(UnformatNumber($("#value").val()));
}
} else {
removeFromValidate('EditView', 'payment_date');
}
var count = $('#tblAppendGrid').appendGrid('getRowCount');
var netto=0;
var vat=0;
for (var i = 0; i < count; i++) {
var data2 = $('#tblAppendGrid').appendGrid('getRowValue', i);
var netto_position = parseFloat(UnformatNumber(data2.netto));
if(!isNaN(netto_position)){
netto = netto+netto_position;
}
var vat_position=parseFloat(UnformatNumber(data2.vat));
if(!isNaN(vat_position)){
vat = vat+vat_position;
}
}
var total = netto + vat;
total = total.toFixed(2);
if(parseFloat(total)!==parseFloat(UnformatNumber($('#value').val()))){
alert("Wartość dokumentu powinna być identyczna jak łączna wartość z tabelki Stawki VAT!");
return false;
}
}
if(check_form_(formname)==false){
return false;
} else {
var count = $('#tblAppendGrid').appendGrid('getRowCount');
for (var i = 0; i < count; i++) {
var data2 = $('#tblAppendGrid').appendGrid('getRowValue', i);
$('#tblAppendGrid').appendGrid('setCtrlValue', 'vat', i, UnformatNumber(data2.vat));
$('#tblAppendGrid').appendGrid('setCtrlValue', 'netto', i, UnformatNumber(data2.netto));
// $("#value").val(UnformatNumber($("#value").val()));
}
$("#value").val(UnformatNumber($("#value").val()));
$("#currency_value").val(UnformatNumber($("#currency_value").val()));
$("#left_paid").val(UnformatNumber($("#left_paid").val()));
return true;
}
};

View File

@@ -0,0 +1,448 @@
function NumberToUserFormatNumber(number,add) {
if(!number) number = 0;
number = parseFloat(number);
var tmp = number.toFixed(OPT['dec_len']);
var s1 = tmp.substring(0,tmp.length-1-OPT['dec_len']);
var s2 = tmp.substring(tmp.length-OPT['dec_len'],tmp.length);
var tmp = '';
for(var i=s1.length;i>0;i-=3) {
tmp = ((i<=3)?"":OPT['sep_1000'])+s1.substring(i-3,i)+tmp;
}
s1 = tmp;
return (s1+OPT['dec_sep']+s2).toString()+((add)?add:'');
}
function UserFormatNumberToNumber(ufn,add) {
if(add) {
var match = /add/g;
ufn = ufn.replace(match,'');
}
var match = /Err/g;
ufn = ufn.replace(match,'');
if(!ufn) return parseFloat(0);
var pos = ufn.indexOf(OPT['dec_sep']);
var s1='', s2='';
if(pos==-1) { s1 = ufn; s2 = ''; }
else { s1 = ufn.substring(0,pos); s2 = ufn.substring(pos+1,ufn.length); }
/*
if(OPT['sep_1000'] != "")
for(var i=s1.length-4;i>=0;i-=4)
if(s1.charAt(i) != OPT['sep_1000']) { return -1; }
if(s1.charAt(0) == OPT['sep_1000']) return -1;
*/
var pos = -1;
while((pos = s1.indexOf(OPT['sep_1000'])) != -1)
s1 = s1.substring(0,pos)+s1.substring(pos+1,s1.length);
//alert(s1);
return parseFloat(s1+"."+s2);
}
function keyPressedNumber(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
function isEnterOrTabPressed(e) {
var keynum = keyPressedNumber(e);
if(keynum == 9 || keynum == 13) return true; else return false;
}
function setSelectionRange(obj) {
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh-1);
range.select();
} else {
if(obj.setSelectionRange) {
obj.setSelectionRange(0,obj.value.length);
}
}
obj.focus();
}
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
}
function paramsMT(name) {
this.myTableName = name;
this.table = document.getElementById(this.myTableName);
this.thead = this.table.tHead;
this.tbody = this.table.tBodies.item(0);
this.cellSelectedClass = 'selectedCell';
this.rowSelectedClass = 'selectedRow';
this.selectedRow;
this.selectedCell;
this.rowCount = function() {
return this.tbody.rows.length;
}
this.colCount = function() {
return this.thead.rows.item(0).cells.length;
};
this.colWidth = function(i) {
return this.thead.rows.item(0).cells.item(i).width;
};
this.moveUpRow = function() {
if(this.selectedRow) this.selectedRow.moveUp();
};
this.moveDownRow = function() {
if(this.selectedRow) this.selectedRow.moveDown();
};
this.insertRow = function(row, newRow) {
if(!row)
if(this.rowCount())
if(typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length-1);
var row_tmp;
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
if(this.rowCount() > 0 && row.nextSibling)
this.tbody.insertBefore(row_tmp, row.nextSibling);
else
this.tbody.appendChild(row_tmp);
return row_tmp;
};
this.refreshRowIndex = function() {
for(var i=0; i<this.rowCount(); i++) {
this.tbody.rows.item(i).index = i;
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
}
}
this.onRefreshRowIndex;
this.addRow = function(i,data) {
var row = this.createRow();
if(this.selectedRow) this.selectedRow.deselect();
if(this.selectedCell) this.selectedCell.deselect();
row.myTable = this;
if(i || i===0)
this.tbody.insertBefore(row,this.tbody.rows.item(i));
else
this.tbody.appendChild(row);
this.refreshRowIndex();
this.setRowData(row, data);
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
return row;
}
this.createRow = function(row) {
var row = document.createElement('tr');
row.myTable = this;
row.isnew = false;
row.onclick = function() { this.select(); }
row.select = function() {
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
this.myTable.selectedRow = this;
this.className = this.myTable.rowSelectedClass;
if(row.onSelect) row.onSelect();
}
}
row.deselect = function() {
if(this.myTable.selectedRow === this) {
this.className = '';
this.myTable.selectedRow = '';
if(row.onDeselect) row.onDeselect();
}
};
row.selectNext = function() {
if(this.index < this.myTable.rowCount()-1) { this.deselect(); this.nextSibling.select(); return this.nextSibling; }
else {
if(this.noAddNew) return this;
this.deselect();
var row = this.myTable.addRow(); return row;
}
}
row.selectPrevious = function() {
this.deselect();
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
}
row.deleteRow = function(noNew) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
if(this.myTable.rowCount() == 1 && !noNew) {
var MyTaBlE = this.myTable;
setTimeout( function() { MyTaBlE.addRow(); refreshPositionIndex();} , 1000);
}
this.myTable.tbody.removeChild(this);
this.myTable.refreshRowIndex();
}
row.moveUp = function() {
if(!this.previousSibling) return;
this.myTable.tbody.insertBefore(this,this.previousSibling);
this.myTable.refreshRowIndex();
}
row.moveDown = function() {
if(!this.nextSibling) this.myTable.addRow(row);
this.myTable.tbody.insertBefore(this.nextSibling,this);
this.myTable.refreshRowIndex();
}
row.setData = function(data) {
if(!data || typeof(data) != "object") { return; };
for(var i=0; i<this.myTable.colCount(); i++) {
this.cells.item(i).setData(data);
}
}
row.getData = function() {
var data = new Object();
for(var i=0; i<this.myTable.colCount(); i++) {
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
}
return data;
}
for(var i=0; i<this.colCount(); i++) {
var cell = this.createCell(i);
row.appendChild(cell);
}
if(this.onCreateRow) this.onCreateRow(row);
return row;
};
this.onCreateRow; //function(row) {}
this.createCell = function(i) {
var cell = document.createElement('td');
cell.index = i;
cell.myTable = this;
cell.onclick = function() { this.select(); }
cell.select = function() {
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
this.myTable.selectedCell = this;
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
if(this.onSelect) this.onSelect();
this.className = this.myTable.cellSelectedClass;
}
}
cell.deselect = function() {
if(this.myTable.selectedCell === this) {
if(cell.onDeselect) cell.onDeselect();
this.className = '';
this.selected = false;
this.myTable.selectedCell = '';
}
};
cell.selectNext = function() {
this.deselect();
if(this.nextSibling) this.nextSibling.select();
else {
if(!this.parentNode.nextSibling) { if(this.noNewAdd) return; else this.myTable.addRow(); }
this.parentNode.nextSibling.select();
this.parentNode.nextSibling.firstChild.select();
}
}
cell.afterCreate = function() {}
cell.setData = function(data) {}
cell.getData = function(data) {}
if(this.onCreateCell) this.onCreateCell(cell);
return cell;
};
this.onCreateCell; //function(cell) {}
this.setRowData = function(row,data) {
for(var i=0; i<this.colCount(); i++) {
this.setCellData(row,row.cells.item(i),data);
}
}
this.setCellData = function(row,cell,data) {
if(typeof(row) == "number")
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
if(typeof(cell) != "object")
if(typeof(cell) == "number" && typeof(row) == "object") {
if(row.cells.item(cell))
cell = row.cells.item(cell);
else return;
}
else return;
if(this.onSetCellData) this.onSetCellData(row,cell,data);
}
this.onSetCellData; //function(row,cell,data) {}
this.selectRow = function(row) {
if(this.selectedRow === row) return;
if(this.selectedRow) this.deselectRow();
this.selectedRow = row;
this.selectedRow.className = this.rowSelectedClass;
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
}
this.selectNextRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.nextSibling) this.insertRow();
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.nextSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.selectPreviousRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.previousSibling) return;
if(this.selectedRow === this.tbody.rows.item(0)) return;
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.previousSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.refreshNumeration = function() {
for(var i=0; i<this.tbody.rows.length; i++)
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
}
this.KeyPressedNumber = function(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
this.KeyPressed = function(e, cell, method) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
if((keynum == 9) || (keynum == 13)) {
cell.selectNext();
return false;
}
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|| (keynum == 8) //backspace
|| (keynum == 46) //delete
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188); //,
}
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
}

198
modules/Documents3/Categories.js Executable file
View File

@@ -0,0 +1,198 @@
//categories
function saveItems3(){
document.getElementById('position_list3').value = ItemsList3(true);
}
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 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);
}
}
var tbody_;
var ItemListSave3;
var ItemListClear3;
var ItemListFil3;
var FillText;
addEvent(
window,
'load',
function() {
var paramsTable3 = new paramsMT('itemsTable3');
paramsTable3.onCreateRow = function(row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function() {}
row.onSelect = function() {
}
row.onDeselect = function() {
}
}
paramsTable3.onCreateCell = function(cell) {
var i = cell.index;
if(i == 0) {
cell.setData = function(data) {
console.log(data);
if(data.ecmproductcategory_name) {
cell.firstChild.value = data.ecmproductcategory_name;
cell.getElementsByTagName('input')[1].value = data.ecmproductcategory_id;
if (data.id)
cell.getElementsByTagName('input')[2].value = data.id;
}
};
cell.getData = function(data) {
data.ecmproductcategory_name = cell.firstChild.value;
data.ecmproductcategory_id = cell.getElementsByTagName('input')[1].value;
data.id = cell.getElementsByTagName('input')[2].value;
}
cell.onSelect = function() {
var cn = this.getElementsByTagName('input');
cn[0].name = 'name_p';
cn[0].id = 'name_p';
cn[1].name = 'id_p';
cn[1].id = 'id_p';
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.product_group = data.product_group;
this.setData(data);
}
var cn = this.getElementsByTagName('input');
cn[0].name = '';
cn[0].id = '';
cn[1].name = '';
cn[1].id = '';
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type','text');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
img.setAttribute('src','modules/EcmQuotes/images/search.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
var ecmpopup = open_popup( "EcmProductCategories", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"id_p","name":"name_p"}}, "single", true );
setTimeout(function(){ecmpopup.focus();},200);
}
cell.appendChild(img);
}
if(i == 1) {
var img;
cell.style.padding="auto auto auto auto";
//insert
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
refreshPositionIndex();
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.deleteRow(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src','modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveUp(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src','modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveDown();refreshPositionIndex(); }
cell.appendChild(img);
}
}
ItemsList3 = function(json) {
var data = '';
for(var i=0; i<paramsTable3.rowCount(); i++) {
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable3.row(i).getData());
}
return data;
}
if(paramsTable3.rowCount() == 0) {paramsTable3.addRow();};
paramsTable3.onSetCellData = function(row,cell,data) {
if(cell.innerHTML == '') cell.innerHTML = '&nbsp;';
}
ItemListFill3 = function() {
var pl;
pl = document.getElementById('position_list3').value;
console.log(pl);
if(pl && pl != '') {
try {
pl = eval(pl);
for(x in pl) { var pl_row = pl[x]; if (pl_row.template=='') continue; paramsTable3.addRow().setData(pl_row); }
} catch(err) { pl = null; };
}
}
ItemListClear3 = function(noNew,save) {
if(typeof(save)=="string") ItemListSave(null,save);
while(paramsTable3.rowCount()>0) paramsTable3.row(0).deleteRow(noNew);
}
ItemListClear3();
ItemListFill3();
var check_form_ = check_form;
check_form = function(formname) {
saveItems3();
return check_form_(formname);
}
}
);

48
modules/Documents3/documents.js Executable file
View File

@@ -0,0 +1,48 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var rhandle=new RevisionListHandler();var from_popup_return=false;function document_set_return(popup_reply_data)
{from_popup_return=true;var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;related_doc_id='EMPTY';for(var the_key in name_to_value_array)
{if(the_key=='toJSON')
{}
else
{var displayValue=name_to_value_array[the_key];displayValue=displayValue.replace('&#039;',"'");displayValue=displayValue.replace('&amp;',"&");displayValue=displayValue.replace('&gt;',">");displayValue=displayValue.replace('&lt;',"<");displayValue=displayValue.replace('&quot; ',"\"");if(the_key=='related_doc_id'){related_doc_id=displayValue;}
window.document.forms[form_name].elements[the_key].value=displayValue;}}
related_doc_id=JSON.stringifyNoSecurity(related_doc_id);var conditions=new Array();conditions[conditions.length]={"name":"document_id","op":"starts_with","value":related_doc_id};var query=new Array();var query={"module":"DocumentRevisions","field_list":['id','revision','date_entered'],"conditions":conditions,"order":'date_entered desc'};result=global_rpcClient.call_method('query',query,true);rhandle.display(result);}
function RevisionListHandler(){}
RevisionListHandler.prototype.display=function(result){var names=result['list'];var rev_tag=document.getElementById('related_doc_rev_id');rev_tag.options.length=0;for(i=0;i<names.length;i++){rev_tag.options[i]=new Option(names[i].fields['revision'],names[i].fields['id'],false,false);}
rev_tag.disabled=false;}
function setvalue(source){src=new String(source.value);target=new String(source.form.document_name.value);if(target.length==0){lastindex=src.lastIndexOf("/");if(lastindex==-1){lastindex=src.lastIndexOf("\\");}
if(lastindex==-1){source.form.document_name.value=src;source.form.escaped_document_name.value=src;}else{source.form.document_name.value=src.substr(++lastindex,src.length);source.form.escaped_document_name.value=src.substr(lastindex,src.length);}}}
function toggle_template_type(istemplate){template_type=document.getElementById('template_type');if(istemplate.checked){template_type.disabled=false;}else{template_type.disabled=true;}}

1482
modules/Documents3/js/Bim-it.js Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
$(document).ready(function () {
var valueformat = $($('#value').children()[0]);
valueformat.html(FormatNumber(valueformat.html()));
// var left_paidformat = $($('#left_paid').children()[0]);
// left_paidformat.html(FormatNumber(left_paidformat.html()));
// html = SUGAR.language.get('Documents', 'LBL_REGISTER_DATE') + ':';
// html += '<br>' + SUGAR.language.get('Documents', 'LBL_CATEGORY') + ':';
// html += '<br>' + SUGAR.language.get('Documents', 'LBL_DOCUMENT_NUMBER') + ':';
// $('#test').closest('td').prev().html(html);
// var tmp = SUGAR.language.get('app_list_strings', 'ecminvoiceouts_category_dom');
// $('#categoryspan').html(tmp[$('#categoryspan').html()]);
});

View File

@@ -0,0 +1,345 @@
var rowNumber = 0;
var rowNumber2 = 0;
var check_form_ = check_form;
$(document).ready(function () {
// parent Edit list
InitializeAssignedWith();
// tabelka z vatami
InitializeVatTable();
// Przypisani uzytkownicy
InitializeUserList();
InitializeTableCost();
$('#value').change(function (event) {
if ($('#value').val() == 'NaN,NaN') {
$('#value').val('0,00');
}
});
$('#document_number').click(function(){
$('#document_number').val($('#document_name').val());
});
// Przy zapisie usuwa puste pola z user accepted
$("#EditView").submit(function (event) {
var pola = $("input[id^='user_name_']")
$.each(pola, function (idx,obj){
if (obj.value=='') {
$(this).closest('tr').remove();
}
});
pola = $("input[id^='user_id_']");
$.each(pola, function (idx,obj){
if (obj.value=='') {
$(this).closest('tr').remove();
}
});
// event.preventDefault();
});
$("#document_date").on('change', function(){
if($('input[name="record"]').val()==''){
if($("#register_date").val()==''){
var options = {
onComplete: function(cep) {
if(isDate(cep))
$('#register_date').css("color", "");
else
$('#register_date').css("color", "red");
return;
},
'translation': {
A: {pattern: /[0-3]/},
B: {pattern: /[0-9]/},
C: {pattern: /[0-1]/},
D: {pattern: /[0-9]/},
Y: {pattern: /[0-9]/}
},
selectOnFocus: true
};
var tmp = $('<input></input>');
tmp.val($(this).val());
$(tmp).mask('AB.CD.YYYY', options);
$('#register_date').val($(tmp).val())
}
}
});
});
check_form = function (formname) {
window.onbeforeunload = null;
var tmp = $("input[name='escaped_document_name']").val() == '';
var tmp2 = $("input[name='uploadfile']").val() == '';
if (tmp) {
if (tmp2) {
alert('Nie podano pliku');
return false;
}
}
$("#document_name").val($.trim($("#document_name").val()));
if ($("#document_name").val() == '') {
alert('Nie podano nazwy dokumentu');
$("#document_name").focus();
return false;
}
if ($('#active_date').val().length < 10) {
var txt = 'Nie podano ';
if ($('#active_date').val().length > 0) {
txt += 'pełnej daty publikacji.';
} else {
txt += 'daty publikacji';
}
alert(txt);
$("#active_date").focus();
return false;
}
if ($("#left_paid").val() != '') {
//int = $("#left_paid").val(UnformatNumber($("#left_paid").val()));
if ($('#payment_date').val() == '') {
if ($('#left_paid').val() != '0,00') {
alert('Wpisałeś kwotę do zapłaty, podaj termin płatności!');
return false;
}
}
}
// unformat vat table positions before save
var count = $('#tblAppendGrid').appendGrid('getRowCount');
for (var i = 0; i < count; i++) {
var data2 = $('#tblAppendGrid').appendGrid('getRowValue', i);
$('#tblAppendGrid').appendGrid('setCtrlValue', 'vat', i, UnformatNumber(data2.vat));
$('#tblAppendGrid').appendGrid('setCtrlValue', 'netto', i, UnformatNumber(data2.netto));
}
if ($("#value").val() != '')
$("#value").val(UnformatNumber($("#value").val()));
var int;
};
function InitializeUserList(){
var user_list = $.parseJSON($("input[name='user_list']").val());
if (user_list.length == 0){
addUserAcceptanceField();
} else{
$.each(user_list, function (idx, obj) {
addUserAcceptanceField(
obj.user_id,
obj.user_name,
obj.accepted,
obj.accepted_description,
obj.date_accepted
);
});
}
}
function addUserAcceptanceField(user_id, user_name, accepted, accepted_description, date) {
user_id = user_id || null;
user_name = user_name || null;
accepted = accepted || null;
accepted_description = accepted_description || null;
date = date || null;
rowNumber++;
//Tworzenie wiersza
var tabela = document.getElementById('user_acceptance_table');
var tbRow = document.createElement('tr');
tabela.appendChild(tbRow);
var tbCellInput = document.createElement('td');
var tbCellButtons = document.createElement('td');
tbRow.appendChild(tbCellInput);
tbRow.appendChild(tbCellButtons);
//Tworzenie input'ow
var inputUserId = document.createElement('input');
inputUserId.id = 'user_id_' + rowNumber;
inputUserId.name = 'user_id[]';
inputUserId.type = 'hidden';
tbCellInput.appendChild(inputUserId);
var inputUserAcceptedDescription = document.createElement('input');
inputUserAcceptedDescription.id = 'accepted_description_' + rowNumber;
inputUserAcceptedDescription.name = 'accepted_description[]';
inputUserAcceptedDescription.type = 'hidden';
tbCellInput.appendChild(inputUserAcceptedDescription);
var inputUserAccepted = document.createElement('input');
inputUserAccepted.id = 'accepted_' + rowNumber;
inputUserAccepted.name = 'accepted[]';
inputUserAccepted.type = 'hidden';
tbCellInput.appendChild(inputUserAccepted);
var inputUserDateAccepted = document.createElement('input');
inputUserDateAccepted.id = 'date_accepted_' + rowNumber;
inputUserDateAccepted.name = 'date_accepted[]';
inputUserDateAccepted.type = 'hidden';
tbCellInput.appendChild(inputUserDateAccepted);
var inputUserName = document.createElement('input');
inputUserName.id = 'user_name_' + rowNumber;
inputUserName.name = 'user_name[]';
inputUserName.size = 30;
inputUserName.maxlength = 50;
tbCellInput.appendChild(inputUserName);
//Tworzenie guzikow
var buttonChooseUser = document.createElement('button');
var buttonimg = document.createElement('img');
buttonimg.src = 'index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=id-ff-select.png';
buttonChooseUser.appendChild(buttonimg);
buttonChooseUser.onclick = function (event) {
var tmp = $(this).closest("tr").find('input[id^=user_id]').attr('id');
var tmp2 = $(this).closest("tr").find('input[id^=user_name_]').attr('id');
open_popup('Users', 600, 400, '', true, false,
{'call_back_function': 'set_return', 'form_name': 'EditView', 'field_to_name_array':
{'id': tmp, 'name': tmp2}}, 'single', true);
}
buttonChooseUser.type = "button";
buttonChooseUser.title = SUGAR.language.get('Documents', 'HELP_LBL_USERACCEPT_CHOOSE_BUTTON');
tbCellButtons.appendChild(buttonChooseUser);
var buttonDel = document.createElement('button');
var buttonDelimg = document.createElement('img');
buttonDelimg.src ='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=id-ff-clear.png';
buttonDel.appendChild(buttonDelimg);
buttonDel.onclick = function (e) {
if (document.getElementById('user_acceptance_table').rows.length > 1) {
$(this).closest('tr').remove();
}
};
buttonDel.type = 'button';
buttonDel.accessKey = 'C';
buttonDel.className = 'removerow';
buttonDel.title = SUGAR.language.get('Documents', 'HELP_LBL_USERACCEPT_BUTTONDEL');
tbCellButtons.appendChild(buttonDel);
//Ustawianie wartosci jesli sa
if(user_id!=null){
inputUserId.value = user_id;
inputUserName.value = user_name;
inputUserAccepted.value = accepted;
inputUserAcceptedDescription.value = accepted_description;
inputUserDateAccepted.value = date;
}
}
function InitializeAssignedWith(){
var parent_list = $.parseJSON($("input[name='parent_list']").val());
if (parent_list.length == 0){
addAssociatedWithField();
} else{
$.each(parent_list, function (idx, obj) {
addAssociatedWithField(obj.id, obj.parent_type, htmlspecialchars_decode(obj.parent_name), obj.parent_id);
});
}
}
function addAssociatedWithField(list_id, parent_type, parent_name, parent_id){
list_id = list_id || null;
parent_type = parent_type + 's' || null;
parent_name = parent_name || null;
parent_id = parent_id || null;
rowNumber2++;
var tabela = document.getElementById('associated_with');
var tbRow = document.createElement('tr');
tabela.appendChild(tbRow);
var tbCellInput = document.createElement('td');
var tbCellButtons = document.createElement('td');
tbRow.appendChild(tbCellInput);
tbRow.appendChild(tbCellButtons);
//Tworzenie input'ow
var inputParentType = document.createElement('select');
inputParentType.id = 'parent_type_' + rowNumber2;
inputParentType.name = 'parent_type[]';
var option= null;
var parent_type_list = $.parseJSON($("input[name='parent_type_list']").val());
$.each(parent_type_list, function (idx2, obj2) {
option = document.createElement("option");
option.text = obj2;
option.value = idx2;
if(parent_type==idx2){
option.selected = true;
}
inputParentType.add(option);
});
tbCellInput.appendChild(inputParentType);
var inputParentId = document.createElement('input');
inputParentId.id = 'parent_id_' + rowNumber2;
inputParentId.name = 'parent_id[]';
inputParentId.type = 'hidden';
tbCellInput.appendChild(inputParentId);
var inputParentName = document.createElement('input');
inputParentName.id = 'parent_name_' + rowNumber2;
inputParentName.name = 'parent_name[]';
inputParentName.size = 30;
inputParentName.autocomplete='off';
inputParentName.tabIndex=60;
inputParentName.maxlength = 50;
tbCellInput.appendChild(inputParentName);
var inputList = document.createElement('input');
inputList.id = 'list_id_' + rowNumber2;
inputList.name = 'list_id[]';
inputList.type = 'hidden';
tbCellInput.appendChild(inputList);
//Tworzenie guzikow
var buttonChooseUser = document.createElement('button');
var buttonimg = document.createElement('img');
buttonimg.src = 'index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=id-ff-select.png';
buttonChooseUser.appendChild(buttonimg);
buttonChooseUser.onclick = function (event) {
var window = $(this).closest("tr").find('select[id^=parent_type_]').find(":selected").val();
var tmp = $(this).closest("tr").find('input[id^=parent_id_]').attr('id');
var tmp2 = $(this).closest("tr").find('input[id^=parent_name_]').attr('id');
if(window=='Accounts'){
open_popup(window, 600, 400, '', true, false,{'call_back_function': 'set_return', 'form_name': 'EditView', 'field_to_name_array':{'id': tmp, 'name': tmp2}}, 'single', true);
}else if(window=='Contacts'){
open_popup(window, 600, 400, '', true, false,{'call_back_function': 'set_return', 'form_name': 'EditView', 'field_to_name_array':{'id': tmp, 'name': tmp2}}, 'single', true);
}else if(window=='EcmInvoiceOuts'){
open_popup(window, 600, 400, '', true, false,{'call_back_function': 'set_return', 'form_name': 'EditView', 'field_to_name_array':{'id': tmp, 'document_no': tmp2}}, 'single', true);
}else if(window=='EcmSales'){
open_popup(window, 600, 400, '', true, false,{'call_back_function': 'set_return', 'form_name': 'EditView', 'field_to_name_array':{'id': tmp, 'document_no': tmp2}}, 'single', true);
}else if(window=='EcmStockDocIns'){
open_popup(window, 600, 400, '', true, false,{'call_back_function': 'set_return', 'form_name': 'EditView', 'field_to_name_array':{'id': tmp, 'document_no': tmp2}}, 'single', true);
}else if(window=='EcmProducts'){
open_popup(window, 600, 400, '', true, false,{'call_back_function': 'set_return', 'form_name': 'EditView', 'field_to_name_array':{'id': tmp, 'name': tmp2}}, 'single', true);
}
}
buttonChooseUser.type = "button";
buttonChooseUser.accessKey='l';
buttonChooseUser.title = SUGAR.language.get('Documents', 'HELP_LBL_USERACCEPT_CHOOSE_BUTTON');
tbCellButtons.appendChild(buttonChooseUser);
var buttonDel = document.createElement('button');
var buttonDelimg = document.createElement('img');
buttonDelimg.src ='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=id-ff-clear.png';
buttonDel.appendChild(buttonDelimg);
buttonDel.onclick = function (e) {
if (document.getElementById('associated_with').rows.length > 1) {
$(this).closest('tr').remove();
}
};
buttonDel.type = 'button';
buttonDel.accessKey = 'C';
buttonDel.className = 'removerow';
buttonDel.title = SUGAR.language.get('Documents', 'HELP_LBL_USERACCEPT_BUTTONDEL');
tbCellButtons.appendChild(buttonDel);
inputList.value = list_id;
inputParentName.value = parent_name;
inputParentId.value = parent_id;
$('select[id^=parent_type_]').change(function (event){
$(this).closest('tr').find('input[id^=parent_id]').val('');
$(this).closest('tr').find('input[id^=parent_name]').val('');
$(this).closest('tr').find('input[id^=list_id]').val('');
});
}

View File

@@ -0,0 +1,81 @@
function InitializeTableCost() {
// Initialize appendGrid
$('#tableCostEdit').appendGrid({
hideRowNumColumn: false,
caption: null,
initRows: 1,
columns: [
{
name: 'name',
type: 'text',
ctrlClass: 'inputs',
display: SUGAR.language.get("app_strings", "LBL_NAME"),
displayCss: {'vertical-align': 'middle'},
ctrlCss: {'text-align': 'right'},
},{
name: 'koszt',
display: SUGAR.language.get("app_strings", "LBL_COST"),
type: 'text',
ctrlClass: 'inputs',
displayCss: {'vertical-align': 'middle'},
ctrlCss: {'text-align': 'right'},
onChange: function (evt, rowIndex) {
// formatowanie
var data = $('#tableCostEdit').appendGrid('getRowValue', rowIndex);
if (data.koszt != '') {
$('#tableCostEdit').appendGrid('setCtrlValue', 'koszt', rowIndex, FormatNumber(data.koszt));
}
},
},{
name: 'addcolumn',
display: 'addcolumn',
ctrlClass: 'inputs',
type: 'text',
displayCss: {'vertical-align': 'middle'},
ctrlCss: {'text-align': 'right'}
}
],
i18n: {
append: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_APPEND"),
remove: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVE"),
insert: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_INSERT"),
moveUp: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEUP"),
moveDown: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEDOWN"),
removeLast: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVELAST"),
rowEmpty: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWEMPTY"),
rowDrag: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWDRAG"),
},
customGridButtons: {
insert: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/add_position.gif';
return button;
},
moveUp: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/moverowup.gif';
return button;
},
moveDown: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/moverowdown.gif';
return button;
},
removeLast: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/deleterow.gif';
return button;
},
append: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/insertrow.gif';
return button;
},
remove: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/deleterow.gif';
return button;
},
},
});
}

448
modules/Documents3/paramsMT.js Executable file
View File

@@ -0,0 +1,448 @@
function NumberToUserFormatNumber(number,add) {
if(!number) number = 0;
number = parseFloat(number);
var tmp = number.toFixed(OPT['dec_len']);
var s1 = tmp.substring(0,tmp.length-1-OPT['dec_len']);
var s2 = tmp.substring(tmp.length-OPT['dec_len'],tmp.length);
var tmp = '';
for(var i=s1.length;i>0;i-=3) {
tmp = ((i<=3)?"":OPT['sep_1000'])+s1.substring(i-3,i)+tmp;
}
s1 = tmp;
return (s1+OPT['dec_sep']+s2).toString()+((add)?add:'');
}
function UserFormatNumberToNumber(ufn,add) {
if(add) {
var match = /add/g;
ufn = ufn.replace(match,'');
}
var match = /Err/g;
ufn = ufn.replace(match,'');
if(!ufn) return parseFloat(0);
var pos = ufn.indexOf(OPT['dec_sep']);
var s1='', s2='';
if(pos==-1) { s1 = ufn; s2 = ''; }
else { s1 = ufn.substring(0,pos); s2 = ufn.substring(pos+1,ufn.length); }
/*
if(OPT['sep_1000'] != "")
for(var i=s1.length-4;i>=0;i-=4)
if(s1.charAt(i) != OPT['sep_1000']) { return -1; }
if(s1.charAt(0) == OPT['sep_1000']) return -1;
*/
var pos = -1;
while((pos = s1.indexOf(OPT['sep_1000'])) != -1)
s1 = s1.substring(0,pos)+s1.substring(pos+1,s1.length);
//alert(s1);
return parseFloat(s1+"."+s2);
}
function keyPressedNumber(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
function isEnterOrTabPressed(e) {
var keynum = keyPressedNumber(e);
if(keynum == 9 || keynum == 13) return true; else return false;
}
function setSelectionRange(obj) {
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh-1);
range.select();
} else {
if(obj.setSelectionRange) {
obj.setSelectionRange(0,obj.value.length);
}
}
obj.focus();
}
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
}
function paramsMT(name) {
this.myTableName = name;
this.table = document.getElementById(this.myTableName);
this.thead = this.table.tHead;
this.tbody = this.table.tBodies.item(0);
this.cellSelectedClass = 'selectedCell';
this.rowSelectedClass = 'selectedRow';
this.selectedRow;
this.selectedCell;
this.rowCount = function() {
return this.tbody.rows.length;
}
this.colCount = function() {
return this.thead.rows.item(0).cells.length;
};
this.colWidth = function(i) {
return this.thead.rows.item(0).cells.item(i).width;
};
this.moveUpRow = function() {
if(this.selectedRow) this.selectedRow.moveUp();
};
this.moveDownRow = function() {
if(this.selectedRow) this.selectedRow.moveDown();
};
this.insertRow = function(row, newRow) {
if(!row)
if(this.rowCount())
if(typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length-1);
var row_tmp;
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
if(this.rowCount() > 0 && row.nextSibling)
this.tbody.insertBefore(row_tmp, row.nextSibling);
else
this.tbody.appendChild(row_tmp);
return row_tmp;
};
this.refreshRowIndex = function() {
for(var i=0; i<this.rowCount(); i++) {
this.tbody.rows.item(i).index = i;
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
}
}
this.onRefreshRowIndex;
this.addRow = function(i,data) {
var row = this.createRow();
if(this.selectedRow) this.selectedRow.deselect();
if(this.selectedCell) this.selectedCell.deselect();
row.myTable = this;
if(i || i===0)
this.tbody.insertBefore(row,this.tbody.rows.item(i));
else
this.tbody.appendChild(row);
this.refreshRowIndex();
this.setRowData(row, data);
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
return row;
}
this.createRow = function(row) {
var row = document.createElement('tr');
row.myTable = this;
row.isnew = false;
row.onclick = function() { this.select(); }
row.select = function() {
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
this.myTable.selectedRow = this;
this.className = this.myTable.rowSelectedClass;
if(row.onSelect) row.onSelect();
}
}
row.deselect = function() {
if(this.myTable.selectedRow === this) {
this.className = '';
this.myTable.selectedRow = '';
if(row.onDeselect) row.onDeselect();
}
};
row.selectNext = function() {
if(this.index < this.myTable.rowCount()-1) { this.deselect(); this.nextSibling.select(); return this.nextSibling; }
else {
if(this.noAddNew) return this;
this.deselect();
var row = this.myTable.addRow(); return row;
}
}
row.selectPrevious = function() {
this.deselect();
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
}
row.deleteRow = function(noNew) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
if(this.myTable.rowCount() == 1 && !noNew) {
var MyTaBlE = this.myTable;
setTimeout( function() { MyTaBlE.addRow(); refreshPositionIndex();} , 1000);
}
this.myTable.tbody.removeChild(this);
this.myTable.refreshRowIndex();
}
row.moveUp = function() {
if(!this.previousSibling) return;
this.myTable.tbody.insertBefore(this,this.previousSibling);
this.myTable.refreshRowIndex();
}
row.moveDown = function() {
if(!this.nextSibling) this.myTable.addRow(row);
this.myTable.tbody.insertBefore(this.nextSibling,this);
this.myTable.refreshRowIndex();
}
row.setData = function(data) {
if(!data || typeof(data) != "object") { return; };
for(var i=0; i<this.myTable.colCount(); i++) {
this.cells.item(i).setData(data);
}
}
row.getData = function() {
var data = new Object();
for(var i=0; i<this.myTable.colCount(); i++) {
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
}
return data;
}
for(var i=0; i<this.colCount(); i++) {
var cell = this.createCell(i);
row.appendChild(cell);
}
if(this.onCreateRow) this.onCreateRow(row);
return row;
};
this.onCreateRow; //function(row) {}
this.createCell = function(i) {
var cell = document.createElement('td');
cell.index = i;
cell.myTable = this;
cell.onclick = function() { this.select(); }
cell.select = function() {
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
this.myTable.selectedCell = this;
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
if(this.onSelect) this.onSelect();
this.className = this.myTable.cellSelectedClass;
}
}
cell.deselect = function() {
if(this.myTable.selectedCell === this) {
if(cell.onDeselect) cell.onDeselect();
this.className = '';
this.selected = false;
this.myTable.selectedCell = '';
}
};
cell.selectNext = function() {
this.deselect();
if(this.nextSibling) this.nextSibling.select();
else {
if(!this.parentNode.nextSibling) { if(this.noNewAdd) return; else this.myTable.addRow(); }
this.parentNode.nextSibling.select();
this.parentNode.nextSibling.firstChild.select();
}
}
cell.afterCreate = function() {}
cell.setData = function(data) {}
cell.getData = function(data) {}
if(this.onCreateCell) this.onCreateCell(cell);
return cell;
};
this.onCreateCell; //function(cell) {}
this.setRowData = function(row,data) {
for(var i=0; i<this.colCount(); i++) {
this.setCellData(row,row.cells.item(i),data);
}
}
this.setCellData = function(row,cell,data) {
if(typeof(row) == "number")
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
if(typeof(cell) != "object")
if(typeof(cell) == "number" && typeof(row) == "object") {
if(row.cells.item(cell))
cell = row.cells.item(cell);
else return;
}
else return;
if(this.onSetCellData) this.onSetCellData(row,cell,data);
}
this.onSetCellData; //function(row,cell,data) {}
this.selectRow = function(row) {
if(this.selectedRow === row) return;
if(this.selectedRow) this.deselectRow();
this.selectedRow = row;
this.selectedRow.className = this.rowSelectedClass;
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
}
this.selectNextRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.nextSibling) this.insertRow();
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.nextSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.selectPreviousRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.previousSibling) return;
if(this.selectedRow === this.tbody.rows.item(0)) return;
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.previousSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.refreshNumeration = function() {
for(var i=0; i<this.tbody.rows.length; i++)
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
}
this.KeyPressedNumber = function(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
this.KeyPressed = function(e, cell, method) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
if((keynum == 9) || (keynum == 13)) {
cell.selectNext();
return false;
}
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|| (keynum == 8) //backspace
|| (keynum == 46) //delete
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188); //,
}
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
}

View File

@@ -0,0 +1,25 @@
$(document).ready(function() {
setTime();
});
function setTime() {
var time = $("#mojtime").html();
var hours = 0;
var minutes = 0;
var seconds = 0;
time = parseInt(time);
minutes = Math.floor(time / 60);
hours = Math.floor(minutes / 60);
seconds = time - (minutes * 60);
minutes = minutes - (hours * 60);
if(hours<10){
hours = "0"+hours;
}
if(minutes<10){
minutes = "0"+minutes;
}
if(seconds<10){
seconds = "0"+seconds;
}
$("#mojtime").html("" + hours +"."+ minutes +":"+ seconds);
}

View File

@@ -0,0 +1,375 @@
var startCat;
var startIndex;
var cost_netto = 764;
var cost_netto_s = cost_netto/3600; // koszt netto / 1h = koszt na sekunde
$(document).ready(function () {
initializeTime();
if($('#cost_hour').val()==''){
$('#cost_hour').val("15,20");
}
//$('#cost_hour').attr('disabled','disabled');
startCat = $('#category').find(":selected").val();
startIndex = $('#indeks').val();
if ($('#indeks').val() == '') {
categoryChange();
}
$("#cost_action").change(function () {
cost_actionChange();
});
$("#cost_hour").change(function () {
cost_hourChange();
});
$('#category').change(function () {
categoryChange();
});
$('#indeks').change(function () {
indeksChange();
});
$('#cost_other').change(function () {
cost_otherChange();
});
$("#EditView").submit(function (event) {
indeksChek();
});
});
function initializeTime() {
var time = parseInt($("#time").val());
if (isNaN(time)) {
time = 0;
$("#time").val(0);
}
var hours = 0;
var minutes = 0;
var seconds = 0;
minutes = Math.floor(time / 60);
hours = Math.floor(minutes / 60);
seconds = time - (minutes * 60);
minutes = minutes - (hours * 60);
$("#seconds").val(seconds);
$("#minutes").val(minutes);
$("#hours").val(hours);
}
function secondsChange() {
var tmp = parseInt($("#seconds").val());
if (isNaN(tmp)) {
tmp = 0;
}
if (tmp < 0) {
tmp = 0;
}
if (tmp > 59) {
tmp = 59;
}
$("#seconds").val(tmp);
updateTime();
}
function minutesChange() {
var tmp = parseInt($("#minutes").val());
if (isNaN(tmp)) {
tmp = 0;
}
if (tmp < 0) {
tmp = 0;
}
if (tmp > 59) {
tmp = 59;
}
$("#minutes").val(tmp);
updateTime();
}
function hoursChange() {
var tmp = parseInt($("#hours").val());
if (isNaN(tmp)) {
tmp = 0;
}
if (tmp < 0) {
tmp = 0;
}
$("#hours").val(tmp);
updateTime();
}
function cost_actionChange() {
var tmp = parseFloat($("#cost_action").val().replace(",", "."));
if (isNaN(tmp) || tmp == 'NaN,NaN') {
tmp = 0;
}
$("#cost_action").val(FormatNumber(tmp));
var cost_hour = UnformatNumber($("#cost_hour").val());
var proporcja = tmp/cost_hour;
var cost_other = (proporcja*cost_netto/100).toFixed(2);
$("#cost_other").val(FormatNumber(cost_other));
time = Math.round(3600*proporcja);
$('#time').val(time);
initializeTime();
}
function cost_hourChange() {
var tmp = parseFloat($("#cost_hour").val().replace(",", "."));
if (isNaN(tmp) || tmp == 'NaN,NaN') {
tmp = 0;
}
$("#cost_hour").val(FormatNumber(tmp));
}
function cost_otherChange() {
var tmp = parseFloat($("#cost_other").val().replace(",", "."));
if (isNaN(tmp) || tmp == 'NaN,NaN') {
tmp = 0;
}
$("#cost_other").val(FormatNumber(tmp));
//var time = $("#time").val();
var proporcja = tmp/cost_netto;
time = Math.round(3600*proporcja*100);
$('#time').val(time);
initializeTime();
var cost_hour = UnformatNumber($("#cost_hour").val())*100;
var cost_action = (cost_hour*proporcja).toFixed(2);
$("#cost_action").val(FormatNumber(cost_action));
}
function categoryChange() {
var category = $('#category').find(":selected").val();
console.log(category);
if (startIndex == '') {
var sufix;
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "getIndeks",
category: category,
},
success: function (data) {
sufix = data;
}
});
var text = $('#category').find(":selected").text();
var prefix = '';
if (text.indexOf(' ') === -1) {
prefix = text.substring(0, 5).toUpperCase();
} else {
prefix = text.substring(0, 2).toUpperCase();
prefix = prefix
+ text.substring(text.indexOf(' ') + 1, text.indexOf(' ') + 4)
.toUpperCase();
}
var indeks = prefix + sufix;
$("#indeks").val(indeks);
}else{
if(category==startCat){
$("#indeks").val(startIndex);
}else{
var sufix;
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "getIndeks",
category: category,
},
success: function (data) {
sufix = data;
}
});
var text = $('#category').find(":selected").text();
var prefix = '';
if (text.indexOf(' ') === -1) {
prefix = text.substring(0, 5).toUpperCase();
} else {
prefix = text.substring(0, 2).toUpperCase();
prefix = prefix
+ text.substring(text.indexOf(' ') + 1, text.indexOf(' ') + 4)
.toUpperCase();
}
var indeks = prefix + sufix;
$("#indeks").val(indeks);
}
}
}
function indeksChange() {
var checkindeks = $.trim($("#indeks").val()).toUpperCase();
if (checkindeks.length > 0) {
if (checkindeks.length > 10) {
checkindeks = checkindeks.substring(0, 10);
}
$("#indeks").val(checkindeks);
var condition = false;
var category = $('#category').find(":selected").val();
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "checkIndeks",
indeks: checkindeks,
category: category,
},
success: function (data) {
condition = data;
}
});
if (condition) {
alert("Podany indeks dla danej kategorii już istnieje");
$("#indeks").val('');
}
} else {
alert("Indeks nie może być pusty");
}
}
function indeksChek(){
var checkindeks = $.trim($("#indeks").val()).toUpperCase();
if (checkindeks.length > 0) {
if (checkindeks.length > 10) {
checkindeks = checkindeks.substring(0, 10);
}
$("#indeks").val(checkindeks);
var condition = false;
var category = $('#category').find(":selected").val();
$.ajax({
type: "POST",
url: "index.php?module=EcmActions&action=indeksIncrement&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "checkIndeks",
indeks: checkindeks,
category: category,
},
success: function (data) {
condition = data;
}
});
if (condition) {
categoryChange();
}
} else {
alert("Indeks nie może być pusty");
}
}
function updateTime() {
var hours = parseInt($("#hours").val()) * 3600;
var minutes = parseInt($("#minutes").val()) * 60;
var seconds = parseInt($("#seconds").val());
var tmp = hours + minutes + seconds;
$("#time").val(tmp);
var time = tmp;
var cost_hour = UnformatNumber($("#cost_hour").val())*100;
if (isNaN(cost_hour) || cost_hour == 'NaN,NaN') {
cost_hour = 0;
}
var cost_hour_h = parseFloat(cost_hour / 3600); //*time + cost_netto_s*time
if (isNaN(cost_hour_h)) {
cost_hour_h = 0;
}
var tmp = ((cost_hour_h*time)/100).toFixed(2);
$("#cost_action").val(FormatNumber(tmp));
var tmp2 = (((cost_netto_s*time)/100)).toFixed(2);
$("#cost_other").val(FormatNumber(tmp2));
}
function setCost_Hour() {
var tmp = $("#time").val();
var cost_action = UnformatNumber($("#cost_action").val());
console.log($("#cost_action").val());
console.log(cost_action);
console.log(tmp);
if (isNaN(cost_action) || cost_action == 'NaN,NaN') {
cost_action = 0;
}
var value = parseFloat((3600 / tmp) * cost_action);
if (isNaN(value) || value == 'Infinity') {
value = 0;
$("#cost_hour").val("Nieprawidłowa wartość czasu");
} else {
$("#cost_hour").val(FormatNumber(value));
}
}
function setCost_Action() {
var time = $("#time").val();
var cost_hour = UnformatNumber($("#cost_hour").val())*100;
if (isNaN(cost_hour) || cost_hour == 'NaN,NaN') {
cost_hour = 0;
}
var cost_hour_h = parseFloat(cost_hour / 3600); //*time + cost_netto_s*time
if (isNaN(cost_hour_h)) {
cost_hour_h = 0;
}
var tmp = ((cost_hour_h*time)/100).toFixed(2);
$("#cost_action").val(FormatNumber(tmp));
}
function setCost_Other() {
var time = $("#time").val();
var cost_other = UnformatNumber($("#cost_other").val())*100;
var tmp2 = (((cost_netto_s*time)/100)).toFixed(2);
$("#cost_other").val(FormatNumber(tmp2));
}
function FormatNumber(number, precision) {
var precision = precision || 2;
// make string..
number = number + '';
number = number.replace(',', '.');
// round
number = toFixed(number, precision);
// add 1000 sep
var tmp = number.split(".");
var c = '';
for (var i = tmp[0].length; i != -1; i--) {
c += tmp[0].charAt(i);
if ((tmp[0].length - i) == 0 || i == 0)
continue;
if ((tmp[0].length - i) % 3 == 0)
c += '.';
}
// reverse c
c = c.split("").reverse().join("");
return c + ',' + tmp[1];
}
function UnformatNumber(number) {
// make string..
number = number + '';
// remove 1000 sep
number = number.replace(/\./g, '');
// change ',' to '.'
number = number.replace(',', '.');
return parseFloat(number);
}
// round with precision
function toFixed(value, precision) {
var precision = precision || 0,
neg = value < 0, power = Math.pow(10, precision),
value = Math.round(value * power),
integral = String((neg ? Math.ceil : Math.floor)(value / power)),
fraction = String((neg ? -value : value) % power),
padding = new Array(Math.max(precision - fraction.length, 0) + 1).join('0');
//fix problem with Math.floor and Math.ceil with result zero (lose sign)
if (neg && integral=="0")
integral='-'+integral;
return precision ? integral + '.' + padding + fraction : integral;
}

View File

View File

@@ -0,0 +1,454 @@
$(document).ready(function () {
CKEDITOR.replace('template');
getListCodeTemplate();
$("#pdf_template_selected").val($('#templates').val());
$('#templates').change(function () {
$("#pdf_template_selected").val($('#templates').val());
getCodeTemplate();
});
$("#save").on('click',saveCodeTemplate);
$("#add").on('click',addCodeTemplate);
$("#edit").on('click',editLabel);
$("#remove").on("click",removeCodeTemplate);
$("#edit_save").on("click", editLabelCodeTemplate);
$("#add_save").on('click',addSaveCodeTemplate);
$("#preview_pdf").on('click',getPDFpreview);
$(".margin").on("change", marginChange);
});
function getPDFpreview(){
var id_template = $("#templates").val();
var html_template = CKEDITOR.instances['template'].getData();
margin_top = $("#margin_top").val();
margin_bottom = $("#margin_bottom").val();
margin_left = $("#margin_left").val();
margin_right = $("#margin_right").val();
zapisane_pozycje = [];
$.each($("#parseFieldsTable").find("input"),function (key,value){
zapisane_pozycje.push($(value).val());
});
aditional_fields = [];
$.each($('#pdf_template_aditional_fields').appendGrid('getAllValue'), function (key, row){
if(row.value0!=''){
row.value0 = trim(row.value0);
if(row.value0!=''){
var re = new RegExp(' ', 'g');
row.value0 = row.value0.replace(re, '_');
sprawdz_czy_juz_zapisana = false;
$.each(aditional_fields, function (k,v){
if(row.value0==v.value0){
sprawdz_czy_juz_zapisana = true;
}
});
if(!sprawdz_czy_juz_zapisana){
aditional_fields.push(row);
}
}
}
});
$('#pdf_template_aditional_fields').appendGrid('load',aditional_fields);
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "html",
async: false,
data: {
job: "saveCodeTemplate",
id_template: id_template,
html_template: html_template,
margin_top: margin_top,
margin_bottom: margin_bottom,
margin_left: margin_left,
margin_right: margin_right,
aditional_fields: aditional_fields,
},
success: function (data) {
refreshPraseList();
getCodeTemplate();
},
error: function (){
alert("Coś poszło nie tak... Nie udało się wygenerować podglądu");
return;
},
});
var id_template = $('#pdf_template_selected').val();
console.log(id_template);
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=createPDF&to_pdf=1",
dataType: "html",
data: {
generateFromTeplateExample: id_template,
record: 1,
},
success: function (data) {
window.open("pdfexample.pdf");
}
});
}
function refreshPraseList(){
var id_template= $("#templates").val();
console.log(id_template);
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "json",
data: {
job: "getParseFields",
id_template : id_template,
},
success: function(data) {
$("#parseFieldsTable").find('tr').remove();
$.each(data, function(key, value) {
$("#parseFieldsTable").append('<tr><td style="border-bottom:1pt solid black;"><b>' + value + '</b></td><td style="border-bottom:1pt solid black;" ><input type="text" onClick="this.select();" value="$' + key + '$"/></td></tr>');
});
}
});
}
function InitializeAdidionalFields(initData) {
// Initialize appendGrid
$('#pdf_template_aditional_fields').appendGrid({
hideRowNumColumn: false,
initRows: 1,
initData:initData,
columns: [
{
name: 'value0',
display: SUGAR.language.get("EcmAgreements", "LBL_NAME"),
type: 'text',
displayCss: {
'vertical-align': 'middle'
},
ctrlCss: {
'text-align': 'left'
},
ctrlClass: 'inputs',
onChange: function (evt, rowIndex) {
var linia = $('#pdf_template_aditional_fields').appendGrid('getRowValue', rowIndex);
var nazwa = '$' +linia.value0+ '$';
$.each($("#parseFieldsTable").find("input"),function (key,value){
if( nazwa ==$(value).val()){
alert("Podana nazwa jest już używana, proszę wybrać inną.");
}
});
}
},{
name: 'value3',
display: SUGAR.language.get("EcmAgreements", "LBL_DEFAULT_VALUE"),
type: 'text',
displayCss: {
'vertical-align': 'middle'
},
ctrlCss: {
'text-align': 'left'
},
ctrlClass: 'inputs',
},{
name: 'value2',
display: 'relatedTemplate',
type: 'hidden',
value: $("#templates").val(),
}, {
name: 'id',
display: 'id',
type: 'hidden',
}, {
name: 'name',
display: 'name',
type: 'hidden',
value : 'AgreementTemplatesAditionalFields',
}, {
name: 'module_name',
display: 'module_name',
type: 'hidden',
value : 'EcmAgreements',
},
],
i18n: {
append: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_APPEND"),
remove: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVE"),
insert: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_INSERT"),
moveUp: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEUP"),
moveDown: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_MOVEDOWN"),
removeLast: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_REMOVELAST"),
rowEmpty: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWEMPTY"),
rowDrag: SUGAR.language.get("app_strings", "LBL_APPENDGRID_I18_ROWDRAG"),
},
customGridButtons: {
insert: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/add_position.gif';
return button;
},
remove: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/deleterow.gif';
return button;
},
moveUp: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/moverowup.gif';
return button;
},
moveDown: function () {
var button = document.createElement('img');
button.src = 'modules/EcmQuotes/images/moverowdown.gif';
return button;
},
},
afterRowRemoved: function (caller, rowIndex) {
var quantity = $('#pdf_template_aditional_fields').appendGrid(
'getRowCount');
if (quantity == 0) {
$('#pdf_template_aditional_fields').appendGrid('appendRow', 1);
}
},
hideButtons: {
removeLast: true,
append: true,
moveUp: true,
moveDown: true
}
});
}
function hide(){
$("#edit_div").hide();
$("#add_div").hide();
}
function marginChange(){
var value = $(this).val();
if(value==''){
$(this).val(0);
return;
}
if(value<0){
$(this).val(0);
return;
}
if(value>100){
$(this).val(100);
return;
}
}
function getListCodeTemplate() {
var selected = $("#pdf_template_selected").val();
$('#templates').find('option').remove();
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "json",
data: {
job: "getListCodeTemplate",
},
success: function(data) {
console.log(selected);
$.each(data, function(key, value) {
$("#templates").append('<option value="' + key + '">' + value + '</option>');
});
if(selected!=''){
$("#templates").val(selected);
}else{
$("#templates").val($("#templates option:first").val());
$('#pdf_template_selected').val($("#templates").val());
}
getCodeTemplate();
}
});
}
function getCodeTemplate() {
var id = $('#templates').val();
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "getCodeTemplate",
id: id,
},
success: function (data) {
CKEDITOR.instances['template'].setData(data.pdf_template);
$("#margin_top").val(data.margin_top);
$("#margin_bottom").val(data.margin_bottom);
$("#margin_left").val(data.margin_left);
$("#margin_right").val(data.margin_right);
refreshPraseList();
InitializeAdidionalFields(data.aditional_fields);
}
});
}
function saveCodeTemplate() {
var id_template = $("#templates").val();
var html_template = CKEDITOR.instances['template'].getData();
margin_top = $("#margin_top").val();
margin_bottom = $("#margin_bottom").val();
margin_left = $("#margin_left").val();
margin_right = $("#margin_right").val();
zapisane_pozycje = [];
$.each($("#parseFieldsTable").find("input"),function (key,value){
zapisane_pozycje.push($(value).val());
});
aditional_fields = [];
$.each($('#pdf_template_aditional_fields').appendGrid('getAllValue'), function (key, row){
if(row.value0!=''){
row.value0 = trim(row.value0);
if(row.value0!=''){
var re = new RegExp(' ', 'g');
row.value0 = row.value0.replace(re, '_');
sprawdz_czy_juz_zapisana = false;
$.each(aditional_fields, function (k,v){
if(row.value0==v.value0){
sprawdz_czy_juz_zapisana = true;
}
});
if(!sprawdz_czy_juz_zapisana){
aditional_fields.push(row);
}
}
}
});
$('#pdf_template_aditional_fields').appendGrid('load',aditional_fields);
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "html",
async: false,
data: {
job: "saveCodeTemplate",
id_template: id_template,
html_template: html_template,
margin_top: margin_top,
margin_bottom: margin_bottom,
margin_left: margin_left,
margin_right: margin_right,
aditional_fields: aditional_fields,
},
success: function (data) {
refreshPraseList();
getCodeTemplate();
alert("Zapisano pomyślnie");
},
error: function (){
alert("Coś poszło nie tak... Zmiany nie zostały zapisane");
},
});
}
function addCodeTemplate(){
$("#add_div").show();
}
function addSaveCodeTemplate(){
var label = trim($("#add_label").val());
if(label == ''){
alert("Nie podano nazwy szablonu");
return false;
}
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "html",
async: false,
data: {
job: "addSaveCodeTemplate",
label: label,
},
success: function (data) {
if(data=='0'){
alert('Coś poszło nie tak. Nie zapisano żadnych zmian.');
return;
}
if(data=='1'){
alert('Podana nazwa już istnieje,wybierz inną');
return;
}
$("#pdf_template_selected").val(data);
alert('Pomyślnie dodano szablon.');
getListCodeTemplate();
},
error: function (){
alert("Coś poszło nie tak..<br>Zmiany nie zostały zapisane");
},
});
$("#add_label").val('');
$("#add_div").hide();
}
function editLabel(){
$("#edit_label").val($("#templates option:selected").html());
$("#edit_div").show();
}
function editLabelCodeTemplate(){
var id_template = $("#templates").val();
var label = trim($("#edit_label").val());
if(label == ''){
alert("Nie podano nazwy szablonu");
return false;
}
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "html",
async: false,
data: {
job: "editLabelCodeTemplate",
label: label,
id_template: id_template,
},
success: function (data) {
alert(data);
if(data=="Pomyślnie zmieniono nazwę szablonu."){
getListCodeTemplate();
}
},
error: function (){
alert("Coś poszło nie tak..<br>Zmiany nie zostały zapisane");
},
});
$("#edit_div").val('');
$("#edit_div").hide();
}
function removeCodeTemplate(){
var zgoda = confirm("Czy na pewno usunąć szablon?\nNie będzie można tego cofnąć bez kontaktu z administratorem.");
if(!zgoda){
return;
}
var id_template = $("#templates").val();
$("#pdf_template_selected").val('');
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "html",
async: false,
data: {
job: "removeCodeTemplate",
id_template: id_template,
},
success: function (data) {
getListCodeTemplate();
alert(data);
},
error: function (){
alert("Coś poszło nie tak..<br>Zmiany nie zostały zapisane");
},
});
}

View File

@@ -0,0 +1,100 @@
//START:
$(document).ready(
function() {
var prev_val;
// confirm exit
window.onbeforeunload = confirmExit;
// prevent submit by enter press
lockEnter();
// parent info
$('#parent_id').on('inputchange',
function() {
$(".loading_panel").css("display", "block");
setTimeout(function() {
getParentInfo($("#parent_id").val(), 'Accounts');
}, 1000);
});
// categories
getCategoriesList();
// its vat free change
$("#no_tax").change(function() {
// calculate totals
var count = $('#' + itemsTable + '_T tr').length - 1; // -1 -
// thead row
for (var index = 0; index != count; index++)
calculateRow(index);
});
$("#currency_id").change(function() {
getNBPCurrencyExchange($("#currency_id :selected").val());
});
// formatowanie liczb
$("#amount").change(function(e){
$(this).val(FormatNumber($(this).val()));
});
$("#interest_rate").change(function(e){
$(this).val(FormatNumber($(this).val()));
});
$("#rate_of_commission").change(function(e){
$(this).val(FormatNumber($(this).val()));
});
$("#number_of_installments").change(function(e){
$(this).val(FormatNumber($(this).val()));
});
$('#principal_value').focus(function() {
prev_val = $(this).val();
});
$("#principal_value").change(function(e){
$(this).val(FormatNumber($(this).val()));
if($("#a2_5").text().search('xxx')>0){
$("#a2_5").text($("#a2_5").text().replace('xxx',$(this).val()+' zł'));
} else {
console.log(prev_val);
$("#a2_5").text($("#a2_5").text().replace(prev_val+' zł',$(this).val()+' zł'));
}
});
DrawHeaders();
///generateNumber();
EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmInvoiceOuts');
//$("#document_no").attr("readonly", false);
$(".loading_panel").css("display", "none");
// handle setItems
DrawFormaWplatyTable();
setITEMS = function() {
var formname = 'EditView';
if (check_form_(formname) == true) {
SetTab('ITEMS');
}
};
});
// handle save
var check_form_ = check_form;
check_form = function(formname) {
window.onbeforeunload = null;
$(".loading_panel").css("display", "block");
// calculate totals
return true;
};
function confirmExit() {
return "";
}
function lockEnter() {
// prevent default
$(window).keydown(function(event) {
if (event.keyCode == 13 && $(":focus").prop('tagName')!='TEXTAREA') {
event.preventDefault();
return false;
}
});
}

View File

@@ -0,0 +1,8 @@
//START:
$(document).ready(
function() {
DrawHeaders();
getItems(false);
});

View File

@@ -0,0 +1,105 @@
$(document).ready(function () {
getListCodeTemplate();
CKEDITOR.replace('pdf_text');
$('#pdf_template_selected').val($('#pdf_template').val());
$('#pdf_template').on('change',function () {
if( $('#pdf_template_selected').val()!=''){
var zgoda = confirm("Czy na pewno chcesz zmienić szablon pdf? Zmiany w aktualnym szablonie będą utracone.");
if(!zgoda){
return;
}
}
$('#pdf_template_selected').val($('#pdf_template').val());
getFilledCodeTemplate();
getAditionalFieldsTemplate();
});
$("#refresh").on('click',pdfRefresh);
$("#preview_pdf").on('click',getPDFpreview);
});
function getPDFpreview(){
window.open("Agreement.pdf");
}
function getAditionalFieldsTemplate() {
var id = $('#pdf_template').val();
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "json",
async: false,
data: {
job: "getCodeTemplate",
id: id,
},
success: function (data) {
$("#aditionalFields").find('tr').remove();
$.each(data.aditional_fields, function (key,value){
$("#aditionalFields").append("<tr><td width='12.5%' >"+ value.value0+ ":</td><td><input type='text' id='" + value.value0 + "' name='" + value.value0 + "' value='" + value.value3 + "'></td></tr>");
});
}
});
}
function pdfRefresh(){
var zgoda = confirm("Czy na pewno chcesz odświeżyć treść pdf? Nie będzie można tego cofnąć.");
if(!zgoda){
return;
}
getFilledCodeTemplate();
}
function getFilledCodeTemplate() {
var id_template = $('#pdf_template').val();
var inputs = $('input, textarea, select').not(':input[type=button], :input[type=submit], :input[type=reset]');
var fill_data = {};
$.each(inputs, function (indeks,value){
var jqval = $(value);
if(jqval.val()!=''){
fill_data[jqval.attr('name')] = jqval.val();
}
});
var tmp = null;
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "html",
data: {
job: "getFilledCodeTemplate",
id: id_template,
data: fill_data,
},
success: function (data) {
CKEDITOR.instances['pdf_text'].setData(data);
}
});
}
function getListCodeTemplate() {
var selected = $("#pdf_template_selected").val();
$('#pdf_template').find('option').remove();
$.ajax({
type: "POST",
url: "index.php?module=EcmAgreements&action=dbpost&to_pdf=1",
dataType: "json",
data: {
job: "getListCodeTemplate",
},
success: function(data) {
$("#pdf_template").append('<option value=""></option>');
$.each(data, function(key, value) {
console.debug("key " + key);
console.debug("selected " + selected);
if (key == selected) {
$("#pdf_template").append('<option value="' + key + '">' + value + '</option>');
} else {
$("#pdf_template").append('<option value="' + key + '">' + value + '</option>');
}
$("#pdf_template").val(selected);
});
}
});
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
columns = new Array();
//define columns
//begin: number
columns[0] = {
'name' : 'number',
'label' : 'Lp.',
'width' : 4,
'content' : new Array(),
};
columns[0]['content'][0] = {'name' : '', 'type': 'text', 'readonly' : true};
//end: number
//begin: code
columns[1] = {
'name' : 'payment_',
'label' : 'Termin płatności odsetek i raty kapitałowej',
'width' : 20,
'content' : new Array(),
};
columns[1]['content'][0] = {'name' : 'date', 'type': 'text', 'readonly' : true};
//end: code
//begin: name
columns[2] = {
'name' : 'total',
'label' : 'Suma raty i odsetek',
'width' : 6,
'align' : 'right',
'content' : new Array(),
};
columns[2]['content'][0] = {'name' : '', 'type': 'text', 'readonly' : true, 'isNumber' : true};
//end: name
//begin: quantity
columns[3] = {
'name' : 'interest_',
'label' : 'Odsetki',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[3]['content'][0] = {'name' : 'rate', 'type': 'text', 'readonly' : true, 'isNumber' : true};
//end: quantity
//begin: unit
columns[4] = {
'name' : 'rate_of_',
'label' : 'Prowizja',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[4]['content'][0] = {'name' : 'commission', 'type': 'text', 'readonly' : true, 'isNumber' : true};
//end: unit
//begin: price_start
columns[5] = {
'name' : 'principal_',
'label' : 'Rata kapitałowa',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[5]['content'][0] = {'name' : 'value', 'type': 'text', 'readonly' : true, 'isNumber' : true};
//end: price_start
//begin: discount
columns[6] = {
'name' : 'saldo',
'label' : 'Saldo',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[6]['content'][0] = {'name' : '', 'type': 'text', 'readonly' : true, 'isNumber' : true};
//end: discount
//begin: price_netto

View File

@@ -0,0 +1,71 @@
columns = new Array();
//define columns
//begin: number
columns[0] = {
'name' : 'number',
'label' : 'Lp.',
'width' : 4,
'content' : new Array(),
};
columns[0]['content'][0] = {'name' : '', 'type': 'text', 'readonly' : true};
//end: number
//begin: code
columns[1] = {
'name' : 'payment_',
'label' : 'Termin płatności odsetek i raty kapitałowej',
'width' : 20,
'content' : new Array(),
};
columns[1]['content'][0] = {'name' : 'date', 'type': 'text', 'readonly' : true};
//end: code
//begin: name
columns[2] = {
'name' : 'total',
'label' : 'Suma raty i odsetek',
'width' : 6,
'align' : 'right',
'content' : new Array(),
};
columns[2]['content'][0] = {'name' : '', 'type': 'text','isNumber' : true};
//end: name
//begin: quantity
columns[3] = {
'name' : 'interest_',
'label' : 'Odsetki',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[3]['content'][0] = {'name' : 'rate', 'type': 'text', 'isNumber' : true, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());'};
//end: quantity
//begin: unit
columns[4] = {
'name' : 'rate_of_',
'label' : 'Prowizja',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[4]['content'][0] = {'name' : 'commission', 'type': 'text','isNumber' : true, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());'};
//end: unit
//begin: price_start
columns[5] = {
'name' : 'principal_',
'label' : 'Rata kapitałowa',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[5]['content'][0] = {'name' : 'value', 'type': 'text', 'isNumber' : true, 'onChange' : 'ObliczPozycje($(this).parent(\'td\').parent(\'tr\').index());'};
//end: price_start
//begin: discount
columns[6] = {
'name' : 'saldo',
'label' : 'Saldo',
'width' : 5,
'content' : new Array(),
'align' : 'right',
};
columns[6]['content'][0] = {'name' : '', 'type': 'text', 'isNumber' : true, 'onChange' : 'calculateRow($(this).parent(\'td\').parent(\'tr\').index());'};
//end: discount
//begin: price_netto

View File

@@ -0,0 +1,62 @@
$(document).ready(function () {
var int_header_height = 10; //put pixel value height of header here
if ($(document).scrollTop() <= int_header_height) {
$('#desc').css('position','absolute').css('top','0px');
} else {
$('#desc').css('position','fixed').css('top','10px');
}
});
function setBoxStyle(hour,y_value,cc,id)
{
var x=findPosX(document.getElementById("table_day"));
var y=findPosY(document.getElementById("hour"+hour)); //by id
//y=y+y_value+184;
y=y+y_value-1;
x=x+cc+32;
document.getElementById("activity"+id).style.position="absolute";
document.getElementById("activity"+id).style.left=x+"px";
document.getElementById("activity"+id).style.top=y+"px";
}
function resizeHours(hour,hour_height)
{
document.getElementById("hour"+hour).style.height=hour_height+"px";
}
function getHourPosition(hour,t)
{
var v;
var r=t.rows;
for(i=0;i<hour;i++)
{
v=v+r[i].height;
}
return v;
}
function showdescriptionCalendar(title,desc,object,pos)
{
var div=document.createElement("div");
desc=desc.replace("&lt;","<");
desc=desc.replace("&gt;",">");
desc=desc.replace("&quot;",'"');
desc=desc.replace("&acute;","'");
div.style.display="none";
div.style.background="#ffffff";
div.style.position="fixed";
div.style.bottom = '0%';
div.style.padding = '10px';
div.id="desc";
div.innerHTML='<table bgcolor="#cccccc" class="olBgClass" border="0" cellpadding="1" cellspacing="1"><tbody><tr><td><table class="olCgClass" border="0" cellpadding="2" cellspacing="0" width="100%"><tbody><tr><td class="olCgClass" width="100%">'+title+'</td><td align="right"><a href="javascript:hidedescriptionCalendar();" title="Click to Close" onClick="javascript:hidedescription();" class="olCloseFontClass"><img src="themes/Sugar/images/close_inline.gif" border="0"></a></td></tr></tbody></table><table class="olFgClass" border="0" cellpadding="2" cellspacing="0" width="100%"><tbody><tr><td class="olFgClass" valign="top" background="#ffffff">'+desc+'<br></td></tr></tbody></table></td></tr></tbody></table>';
document.body.appendChild(div);
$('#desc').show();
}
function hidedescriptionCalendar()
{
if(document.getElementById("desc"))
{
document.getElementById("desc").style.display="none";
document.body.removeChild(document.getElementById("desc"));
}
}

181
modules/EcmCalendars/helper.js Executable file
View File

@@ -0,0 +1,181 @@
function showdescription(id,title,desc,minus,object)
{
if(!minus)minus=0;
var sum=17-minus;
document.getElementById("desc").style.display="inline";
document.getElementById("desc-title").innerHTML=title;
document.getElementById("desc-desc").innerHTML=desc;
posy=findPosY(object)+sum;
posx=findPosX(object);
moveDiv(document.getElementById("desc"),posy,posx);
}
function hidedescription()
{
document.getElementById("desc").style.display="none";
}
function mintajaxget(url,tag){
$('#'+tag).html('<img src="themes/default/images/loading.gif" border="0">');
$.ajax({
type : "POST",
url : url,
dataType : "html",
async : false,
success : function(data) {
$('#'+tag).html(data);
},
});
}
function mintajaxpost(url,tag,form)
{
var req=mint.Request();
req.OnSuccess=function(){$(tag).innerHTML=this.responseText;}
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
req.SendForm(form);
}
function moveDiv(obj, mvTop, mvLeft) {
obj.style.position = "absolute";
obj.style.top = mvTop;
obj.style.left = mvLeft;
}
function getPos(inputElement) {
var coords = new Object();
coords.x = 0;
coords.y = 0;
try {
targetElement = inputElement;
if(targetElement.x && targetElement.y) {
coords.x = targetElement.x;
coords.y = targetElement.y;
} else {
if(targetElement.offsetParent) {
coords.x += targetElement.offsetLeft;
coords.y += targetElement.offsetTop;
while(targetElement = targetElement.offsetParent) {
coords.x += targetElement.offsetLeft;
coords.y += targetElement.offsetTop;
}
} else {
//alert("Could not find any reference for coordinate positioning.");
}
}
return coords;
} catch(error) {
//alert(error.msg);
return coords;
}
}
function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
return curleft;
//return getPos(obj).x;
}
function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
while(1)
{
curtop += obj.offsetTop;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.y)
curtop += obj.y;
return curtop;
//return getPos(obj).y;
}
function showdiv(id,div,minusy,minusx)
{
document.getElementById(div).style.display="inline";
posy=findPosY(document.getElementById(id))-minusy;
posx=findPosX(document.getElementById(id))-minusx;
moveDiv(document.getElementById(div),posy,posx);
}
function hidediv(div)
{
document.getElementById(div).style.display="none";
}
function showprice(id,price,purchase_price,margin,order_by,sorder)
{
document.getElementById('price').value=price;
document.getElementById('purchase_price').value=purchase_price;
document.getElementById('margin').value=margin;
document.getElementById('product_id').value=id;
document.getElementById('order_by').value=order_by;
document.getElementById('sorder').value=sorder;
document.getElementById('price-block').style.display="block";
}
function getPrice(id,type)
{
var purchase_price=document.getElementById('purchase_price_'+id).value;
var margin_rate=document.getElementById('margin_rate_'+id).value;
var list_price;
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
if(!isNaN(list_price))document.getElementById('list_price_'+id).value=roundNumber(list_price,2);
}
function getPricePricebook()
{
var purchase_price=document.getElementById('purchase_price').value;
var margin_rate=document.getElementById('margin').value;
var list_price;
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
if(!isNaN(list_price))document.getElementById('price').value=roundNumber(list_price,2);
}
function CurrencyFormatted(amount)
{
var i = parseFloat(amount);
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
if(s.indexOf('.') < 0) { s += '.00'; }
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
s = minus + s;
return s;
}
function roundN(rnum,rlength)
{
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
return newnumber;
}
function roundNumber(num, dec)
{
if(!isNaN(num))return CurrencyFormatted(roundN(parseFloat(num),dec));
else return "";
}
function ShowHideBlock(id)
{
if(document.getElementById(id).style.display=="block")
{
document.getElementById(id).style.display="none"
}
else
{
document.getElementById(id).style.display="block"
}
}

31
modules/EcmCalls/DoCall.js Executable file
View File

@@ -0,0 +1,31 @@
var EcmCalls_DOCALL = true;
function CALL(number) {
if(!EcmCalls_DOCALL) { EcmCalls_DOCALL = true; return true; }
YAHOO.util.Connect.asyncRequest(
'GET',
'index.php?module=EcmCalls&action=DoCall&to_pdf=1&number='+number,
{
success: function(result) {
if(result.responseText == '') return;
var iframe = document.getElementById('doCallIFrame');
if(!iframe) {
iframe = document.createElement('iframe');
iframe.id = 'doCallIFrame';
iframe.style.display = 'none';
document.body.appendChild(iframe);
}
if(iframe && result.responseText != '') {
//alert('>'+result.responseText+'<');
//document.location = result.responseText;
iframe.src = result.responseText;
}
},
failure: function () {
alert('error');
}
}
);
// if(iframe) iframe.src = 'index.php?module=EcmCalls&action=DoCall&to_pdf=1&number='+number;
}

257
modules/EcmCalls/Hint.js Executable file
View File

@@ -0,0 +1,257 @@
//Ajax Request - Begin
function doRequest(where,post,succes,fail) {
this.succes = function(result) { succes(result.responseText); }
this.fail = function(result) { fail(result.responseText); }
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.succes,failure:this.fail},post);
}
//Ajax Request - End
var lastLockedGuid = '';
function findPos(obj) {
var nleft = 0;
var ntop = 0;
if (obj.offsetParent) {
nleft = obj.offsetLeft
ntop = obj.offsetTop
while (obj = obj.offsetParent) {
nleft += obj.offsetLeft
ntop += obj.offsetTop
}
}
return [nleft,ntop];
}
function showCallHint(ev,guid,id,img,title,call,record,module,id2,chi) {
//lock_unlock_Position();
//if(lastLockedGuid == guid) return;
var div = document.getElementById('hint_div_'+guid);
if(div.lockPosition == true && div.ec_call_record == record) return;
else lock_unlock_Position();
div.ec_call_record = record;
div = ShowAdditionalDetails(title, div, call, module);
div.ec_number = call;
div.ec_record = record;
div.ec_module = module;
div.ec_id = id2;
div.ec_name = title;
div.ec_chi = chi;
if(!div.ec_number) {
document.getElementById("EcmCallsStatusPhoneIcon").style.display = "none";
} else {
document.getElementById("EcmCallsStatusPhoneIcon").style.display = "";
}
if(!div.ec_module || !div.ec_id) {
document.getElementById("EcmCalls_search_img").style.display = "none";
document.getElementById("EcmCalls_view_detail_img").style.display = "none";
} else {
document.getElementById("EcmCalls_view_detail_img").style.display = "";
document.getElementById("EcmCalls_search_img").style.display = "";
}
if(chi && chi != '') {
var chi_span = document.getElementById('EcmCallsCallHintIcon_'+chi);
if(chi_span) {
document.getElementById("EcmCallsStatusPhoneIcon").innerHTML = chi_span.innerHTML;
}
}
if(!div) return;
//if(div.parentNode !== document.body) { div.parentNode_ = div.parentNode; document.body.appendChild(div); }
div.style.display = '';
/* if(typeof(img) != "undefined") {
var position = findPos(img);
div.style.left = position[0]-div.offsetWidth;
div.style .top = position[1];
} else {
*/
ev = ev || window.event;
var x = 0; var y = 0;
if(ev.pageX || ev.pageY) {
x = ev.pageX;
y = ev.pageY;
} else {
x = ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y = ev.clientY + document.body.scrollTop - document.body.clientTop
}
var ws = getWindowVisibleSize();
var sc = getScrollXY();
var container = document.getElementById("EcmCallsAdditionalDetailsContainer");
var ofw = x-sc[0]+div.offsetWidth+5;
if(typeof(img) != "undefined" || ofw > ws[0] ) {
x = x-10-div.offsetWidth;
document.getElementById("EcmCallsAdditionalInfoTopButtons").style.cssFloat = "right";
document.getElementById("EcmCallsAdditionalInfoTopButtons").style.styleFloat = "right";
} else {
x = x+10;
document.getElementById("EcmCallsAdditionalInfoTopButtons").style.cssFloat = "left";
document.getElementById("EcmCallsAdditionalInfoTopButtons").style.styleFloat = "left";
}
var table1 = document.getElementById("EcmCallsAdditionalDetailsHeader");
var table1td = document.getElementById("EcmCallsAdditionalDetailsHeaderTD");
var table1div = document.getElementById("EcmCallsAdditionalDetailsHeaderDIV");
var table2 = document.getElementById("EcmCallsAdditionalDetailsFooter");
var table2td = document.getElementById("EcmCallsAdditionalDetailsFooterTD");
var table2div = document.getElementById("EcmCallsAdditionalDetails_description");
if((y-sc[1]+div.offsetHeight+5) > ws[1]) {
if(table1) container.appendChild(table1);
table1.className = "olFgClass";
// table1td.className = "olFgClass";
// table1div.className = "olFontClass";
table2.className = "olCgClass";
// table2td.className = "olCgClass";
// table2div.className = "olCapFontClass";
y = y + 5 - div.offsetHeight;
} else {
if(table2) container.appendChild(table2);
table2.className = "olFgClass";
// table2td.className = "olFgClass";
// table2div.className = "olFontClass";
table1.className = "olCgClass";
// table1td.className = "olCgClass";
// table1div.className = "olCapFontClass";
y = y - 5;
}
div.style.left = x;
div.style.top = y;
// var tds = div.getElementsByTagName('td');
// for(var i=0; i<tds.length; i++) tds[i].style.backgroundColor = div.style.backgroundColor;
}
function lock_unlock_Position(guid,img) {
if(lastLockedGuid != '') { var tmp = lastLockedGuid; lastLockedGuid = ''; lock_unlock_Position(tmp); }
if(typeof(guid) == "undefined") return;
var div = document.getElementById('EcmCallsAdditionalDetails');
if(div) {
var div_guid = document.getElementById('hint_div_'+guid);
if(div_guid && img) div_guid.imgNote = img;
if(typeof(div_guid.lockPosition) == "undefined") div_guid.lockPosition = false;
div_guid.lockPosition = !div_guid.lockPosition;
if(div_guid.lockPosition) {
if(typeof(div_guid.old_note) == "undefined") {
var ttt = div_guid.getElementsByTagName('textarea');
if(ttt[0])
div_guid.old_note = ttt[0].value;
lastLockedGuid = guid;
}
}
else {
hideCallHint(null,guid); lastLockedGuid = ''; div_guid.ec_call_record = '';
}
}
}
function show_hide_Position(guid,img) {
var div = document.getElementById('EcmCallsAdditionalDetails');
var div_guid = document.getElementById('hint_div_'+guid);
if(div) {
if(div.style.display == "" && div_guid.lockPosition == true) {
div.style.display = "none";
} else if(div.style.display == "none") {
div.style.display = "";
}
if(div_guid) {
if(typeof(div_guid.lockPosition) == "undefined" || div_guid.lockPosition == false) {
lock_unlock_Position(guid, img);
}
}
}
}
function hideCallHint(ev,guid,id,img) {
var div = document.getElementById('EcmCallsAdditionalDetails');
var div_guid = document.getElementById('hint_div_'+guid);
if(div && div_guid && div_guid.lockPosition != true) {
div = ShowAdditionalDetails("");
//if(div.parentNode === document.body) div.parentNode_.appendChild(div);// = div.parentNode; document.body.appendChild(div); }
div.style.display = 'none';
}
}
function saveNote(guid,id) {
var div = document.getElementById('hint_div_'+guid);
var note = div.getElementsByTagName('textarea')[0].value;
var guid = guid;
if(note != div.old_note)
doRequest(
'index.php',
'&to_pdf=1&module=EcmCalls&action=AjaxSave&record='+id+'&note='+note,
function(result) {
lock_unlock_Position();
var div = document.getElementById('hint_div_'+guid);
var cell = div.parentNode_;//.parentNode;
div.old_note = note;
if(note == '') img = "modules/EcmCalls/images/hint_grey.gif"; else img = "modules/EcmCalls/images/hint_black.gif";
if(div.imgNote) div.imgNote.src = img;
//alert(cell);
//cell.getElementsByTagName('img')[0].src = img; var img = '';
},
function(result) {}
);
else lock_unlock_Position();
}
function cancelNote(guid) {
var div = document.getElementById('hint_div_'+guid);
if(div) {
div.getElementsByTagName('textarea')[0].value = div.old_note;
lock_unlock_Position();
}
}
function getWindowVisibleSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
return [ myWidth, myHeight ];
}
function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
return [ scrOfX, scrOfY ];
}

184
modules/EcmCalls/ListView.js Executable file
View File

@@ -0,0 +1,184 @@
// JavaScript Document
var EcmCalls_image_assign = document.getElementById('EcmCalls_image_assign');
var EcmCalls_image_search = document.getElementById('EcmCalls_image_search');
function EcmCalls_viewAnMenu(img, number, record, module, id, name) {
var anMenu = document.getElementById('anMenu');
if(typeof(anMenu) == "object") {
var imgPos = YAHOO.util.Dom.getXY(img);
if(imgPos) {
anMenuClear();
if(module && module != '') {
document.forms.anMenuEdit.an_menu_parent.value = module;
document.forms.anMenuEdit.an_menu_old_parent.value = module;
} else {
document.forms.anMenuEdit.an_menu_old_parent.value = '';
}
if(id && id != '') {
document.forms.anMenuEdit.an_menu_parent_id.value = id;
document.forms.anMenuEdit.an_menu_old_parent_id.value = id;
} else {
document.forms.anMenuEdit.an_menu_parent_id.value = '';
document.forms.anMenuEdit.an_menu_old_parent_id.value = '';
}
if(name && name != '')
document.forms.anMenuEdit.an_menu_parent_name.value = name;
else
document.forms.anMenuEdit.an_menu_parent_name.value = '';
if(record && record != '')
document.forms.anMenuEdit.an_menu_ecmcall_record.value = record;
else
document.forms.anMenuEdit.an_menu_ecmcall_record.value = '';
if(number && number != '')
document.forms.anMenuEdit.an_menu_old_parent_phone.value = number;
else
document.forms.anMenuEdit.an_menu_old_parent_phone.value = '';
document.forms.anMenuEdit.an_menu_new_phone.value = number;
//document.forms.anMenuEdit.an_menu_update_all_old_records.checked = true;
anMenu.style.display = '';
var left = imgPos[0]+8-anMenu.offsetWidth/2;
if((document.body.offsetWidth - imgPos[0] - anMenu.offsetWidth/2 - 25) < 0)
left = document.body.offsetWidth - 25 - anMenu.offsetWidth;
anMenu.style.left = left;
anMenu.style.top = imgPos[1]-12-anMenu.offsetHeight;
}
}
}
function EcmCalls_showAssignImage(span, number, record, module, id, name) {
if(typeof(span) == "object") {
span.parentNode.appendChild(EcmCalls_image_assign);
EcmCalls_image_assign.style.display = '';
EcmCalls_image_assign.onclick = function() { EcmCalls_viewAnMenu(this, number, record, module, id, name); };
if(typeof(module) != "undefined" && typeof(id) != "undefined") {
span.parentNode.appendChild(EcmCalls_image_search);
EcmCalls_image_search.style.display = '';
EcmCalls_image_search.onclick = function() {
var url = 'index.php?searchFormTab=advanced_search&module=EcmCalls&action=index&query=true&parent_from_advanced='+module+'&parent_from_id_advanced[]='+id+'&orderBy=CALLDATE&sortOrder=DESC';
if(document.getElementById('call_date_from_ecmcalls_tmp')) url += '&call_date_from_advanced='+document.getElementById('call_date_from_ecmcalls_tmp').value;
if(document.getElementById('call_date_to_ecmcalls_tmp')) url += '&call_date_to_advanced='+document.getElementById('call_date_to_ecmcalls_tmp').value;
if(document.getElementById('calldate_ecmcalls_tmp')) url += '&calldate_advanced='+document.getElementById('calldate_ecmcalls_tmp').value;
window.location = url;
};
} else {
EcmCalls_image_search.style.display = 'none';
}
}
}
function EcmCalls_hideAssignImage(span, number) {
if(typeof(span) == "object") {
//EcmCalls_image_assign.style.display = 'none';
//document.body.appendChild(EcmCalls_image_assign);
}
}
function EcmCallsSearchRecord() {
var div = document.getElementById("EcmCallsAdditionalDetails");
if(div) {
var url = 'index.php?searchFormTab=advanced_search&module=EcmCalls&action=index&query=true&parent_from_advanced='+div.ec_module+'&parent_from_id_advanced[]='+div.ec_id+'&orderBy=CALLDATE&sortOrder=DESC';
if(document.getElementById('call_date_from_ecmcalls_tmp')) url += '&call_date_from_advanced='+document.getElementById('call_date_from_ecmcalls_tmp').value;
if(document.getElementById('call_date_to_ecmcalls_tmp')) url += '&call_date_to_advanced='+document.getElementById('call_date_to_ecmcalls_tmp').value;
if(document.getElementById('calldate_ecmcalls_tmp')) url += '&calldate_advanced='+document.getElementById('calldate_ecmcalls_tmp').value;
window.location = url;
}
}
function EcmCallsAssignRecord(img) {
var div = document.getElementById("EcmCallsAdditionalDetails");
if(div) {
EcmCalls_viewAnMenu(img, div.ec_number, div.ec_record, div.ec_module, div.ec_id, div.ec_name);
}
}
function EcmCallsViewDetailRecord(img) {
var div = document.getElementById("EcmCallsAdditionalDetails");
if(div) {
window.location = "index.php?module="+(div.ec_module == "Users" ? "Employees" : div.ec_module)+"&action=DetailView&record="+div.ec_id+"&return_module=EcmCalls&return_action=ListView";
}
}
function ShowAdditionalDetails(title,obj,call,module)
{
var div = document.getElementById("EcmCallsAdditionalDetails");
if(!div) {
div = document.createElement("div");
div.style.background="#ffffff";
div.style.position="absolute";
div.style.left = '10px';
div.style.top = '10px';
div.id="EcmCallsAdditionalDetails";
var divi ='<div id="" class="olBgClass" style="background-image: none;"><table class="olBgClass" width="300" border="0" cellpadding="0" style="border:none;" cellspacing="0"><tbody><tr><td><div id="EcmCallsAdditionalDetailsContainer"><table id="EcmCallsAdditionalDetailsHeader" class="olCgClass" width="100%" border="0" cellpadding="2" cellspacing="0"><tbody><tr><td id="EcmCallsAdditionalDetailsHeaderTD" class="olCgClass" width="100%" style="margin-left:2px; padding-left:2px;"><div id="EcmCallsAdditionalDetailsHeaderDIV" class="olCapFontClass">';
divi += '<div style="float: left;" id="EcmCallsAdditionalInfoTopButtons">';
divi += '<img id="EcmCalls_search_img" onClick="EcmCallsSearchRecord();" src="modules/EcmCalls/images/search.gif" border="0" style="cursor:pointer;">';
divi += '<img id="EcmCalls_assign_img" onClick="EcmCallsAssignRecord(this);" style="margin-left: 2px; cursor:pointer;" src="modules/EcmCalls/images/assign.gif" border="0">';
divi += '<img id="EcmCalls_view_detail_img" onClick="EcmCallsViewDetailRecord(this);" style="margin-left: 2px; cursor:pointer;" src="modules/EcmCalls/images/view_detail.gif" border="0">';
divi += '<span id="EcmCallsStatusPhoneIcon" style="margin-left: 2px;"><img src="include/ECM/EcmFormatPhoneNumber/images/additional_details_phone.gif" border="0" style="cursor:pointer;"></span>';
divi += '<img style="margin-left:2px;margin-right: 2px; cursor:pointer;" onClick="lock_unlock_Position();" src="modules/EcmCalls/images/close.gif" border="0" style="cursor:pointer;">';
divi += '</div>';
divi += '<div style="float:left;margin-left:2px;padding-left:2px;" id="EcmCallsAdditionalDetails_title" ></div>';
divi += '</div></td></tr></tbody></table><table id="EcmCallsAdditionalDetailsFooter" class="olFgClass" width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td id="EcmCallsAdditionalDetailsFooterTD" class="olFgClass" valign="top"><div id="EcmCallsAdditionalDetails_description" class="olFontClass"></div></td></tr></tbody></table></div></td></tr></tbody></table></div>';
div.innerHTML = divi;
document.body.appendChild(div);
}
if(div) {
if(call) {
document.getElementById("EcmCalls_search_img").style.display = "";
document.getElementById("EcmCalls_assign_img").style.display = "";
} else {
document.getElementById("EcmCalls_search_img").style.display = "none";
document.getElementById("EcmCalls_assign_img").style.display = "none";
}
var title_tmp = "";
if(typeof(title) == "undefined")
title_tmp = call;
else
title_tmp = title;
if(typeof(module) == "undefined" && typeof(call) != "undefined") module = "Others";
if(typeof(module) != "undefined")
title_tmp = SUGAR.language.get('EcmCalls','LBL_NUMBER_OWNER_TYPE_'+module.toUpperCase()) + ": " + title_tmp;
document.getElementById("EcmCallsAdditionalDetails_title").innerHTML = title_tmp;
var ddd = document.getElementById("EcmCallsAdditionalDetails_description");
if(ddd.firstChild) {
ddd.firstChild.style.display = 'none';
if(ddd.firstChild.parentNode_)
ddd.firstChild.parentNode_.appendChild(ddd.firstChild);
else
document.body.appendChild(ddd.firstChild);
}
if(obj) {
obj.style.position = 'relative';
obj.style.left = 0;
obj.style.top = 0;
obj.parentNode_ = obj.parentNode;
ddd.appendChild(obj);
obj.style.display = '';
obj.parentNode_.appendChild(div);
}
return div;
}
}

367
modules/EcmCalls/MyTable.js Executable file
View File

@@ -0,0 +1,367 @@
function keyPressedNumber(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
function isEnterOrTabPressed(e) {
var keynum = keyPressedNumber(e);
if(keynum == 9 || keynum == 13) return true; else return false;
}
function setSelectionRange(obj) {
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh-1);
range.select();
} else {
if(obj.setSelectionRange) {
obj.setSelectionRange(0,obj.value.length);
}
}
obj.focus();
}
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
}
function MyTable(name) {
this.myTableName = name;
this.table = document.getElementById(this.myTableName);
this.thead = this.table.tHead;
this.tbody = this.table.tBodies.item(0);
this.cellSelectedClass = 'selectedCell';
this.rowSelectedClass = 'selectedRow';
this.selectedRow;
this.selectedCell;
this.rowCount = function() {
return this.tbody.rows.length;
}
this.colCount = function() {
return this.thead.rows.item(0).cells.length;
};
this.colWidth = function(i) {
return this.thead.rows.item(0).cells.item(i).width;
};
this.moveUpRow = function() {
if(this.selectedRow) this.selectedRow.moveUp();
};
this.moveDownRow = function() {
if(this.selectedRow) this.selectedRow.moveDown();
};
this.insertRow = function(row, newRow) {
if(!row)
if(this.rowCount())
if(typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length-1);
var row_tmp;
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
if(this.rowCount() > 0 && row.nextSibling)
this.tbody.insertBefore(row_tmp, row.nextSibling);
else
this.tbody.appendChild(row_tmp);
return row_tmp;
};
this.refreshRowIndex = function() {
for(var i=0; i<this.rowCount(); i++) {
this.tbody.rows.item(i).index = i;
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
}
}
this.onRefreshRowIndex;
this.addRow = function(i,data) {
var row = this.createRow();
if(this.selectedRow) this.selectedRow.deselect();
if(this.selectedCell) this.selectedCell.deselect();
row.myTable = this;
if(i || i===0)
this.tbody.insertBefore(row,this.tbody.rows.item(i));
else
this.tbody.appendChild(row);
this.refreshRowIndex();
this.setRowData(row, data);
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
return row;
}
this.createRow = function(row) {
var row = document.createElement('tr');
row.myTable = this;
row.isnew = false;
row.onclick = function() { this.select(); }
row.select = function() {
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
this.myTable.selectedRow = this;
this.className = this.myTable.rowSelectedClass;
if(row.onSelect) row.onSelect();
}
}
row.deselect = function() {
if(this.myTable.selectedRow === this) {
this.className = '';
this.myTable.selectedRow = '';
if(row.onDeselect) row.onDeselect();
}
};
row.selectNext = function() {
this.deselect();
if(this.index == this.myTable.rowCount()) { this.nextSibling.select(); return this.nextSibling; }
else {
var row = this.myTable.addRow(); return row;
}
}
row.selectPrevious = function() {
this.deselect();
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
}
row.deleteRow = function(noNew) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
if(this.myTable.rowCount() == 1 && !noNew) {
var MyTaBlE = this.myTable;
setTimeout( function() { MyTaBlE.addRow(); } , 1000);
}
this.myTable.tbody.removeChild(this);
this.myTable.refreshRowIndex();
}
row.moveUp = function() {
if(!this.previousSibling) return;
this.myTable.tbody.insertBefore(this,this.previousSibling);
this.myTable.refreshRowIndex();
}
row.moveDown = function() {
if(!this.nextSibling) this.myTable.addRow(row);
this.myTable.tbody.insertBefore(this.nextSibling,this);
this.myTable.refreshRowIndex();
}
row.setData = function(data) {
if(!data || typeof(data) != "object") { return; };
for(var i=0; i<this.myTable.colCount(); i++) {
this.cells.item(i).setData(data);
}
}
row.getData = function() {
var data = new Object();
for(var i=0; i<this.myTable.colCount(); i++) {
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
}
return data;
}
for(var i=0; i<this.colCount(); i++) {
var cell = this.createCell(i);
row.appendChild(cell);
}
if(this.onCreateRow) this.onCreateRow(row);
return row;
};
this.onCreateRow; //function(row) {}
this.createCell = function(i) {
var cell = document.createElement('td');
cell.index = i;
cell.myTable = this;
cell.onclick = function() { this.select(); }
cell.select = function() {
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
this.myTable.selectedCell = this;
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
if(this.onSelect) this.onSelect();
this.className = this.myTable.cellSelectedClass;
}
}
cell.deselect = function() {
if(this.myTable.selectedCell === this) {
if(cell.onDeselect) cell.onDeselect();
this.className = '';
this.selected = false;
this.myTable.selectedCell = '';
}
};
cell.selectNext = function() {
this.deselect();
if(this.nextSibling) this.nextSibling.select();
else {
if(!this.parentNode.nextSibling) this.myTable.addRow();
this.parentNode.nextSibling.select();
this.parentNode.nextSibling.firstChild.select();
}
}
cell.afterCreate = function() {}
cell.setData = function(data) {}
cell.getData = function(data) {}
if(this.onCreateCell) this.onCreateCell(cell);
return cell;
};
this.onCreateCell; //function(cell) {}
this.setRowData = function(row,data) {
for(var i=0; i<this.colCount(); i++) {
this.setCellData(row,row.cells.item(i),data);
}
}
this.setCellData = function(row,cell,data) {
if(typeof(row) == "number")
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
if(typeof(cell) != "object")
if(typeof(cell) == "number" && typeof(row) == "object") {
if(row.cells.item(cell))
cell = row.cells.item(cell);
else return;
}
else return;
if(this.onSetCellData) this.onSetCellData(row,cell,data);
}
this.onSetCellData; //function(row,cell,data) {}
this.selectRow = function(row) {
if(this.selectedRow === row) return;
if(this.selectedRow) this.deselectRow();
this.selectedRow = row;
this.selectedRow.className = this.rowSelectedClass;
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
}
this.selectNextRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.nextSibling) this.insertRow();
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.nextSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.selectPreviousRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.previousSibling) return;
if(this.selectedRow === this.tbody.rows.item(0)) return;
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.previousSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.refreshNumeration = function() {
for(var i=0; i<this.tbody.rows.length; i++)
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
}
this.KeyPressedNumber = function(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
this.KeyPressed = function(e, cell, method) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
if((keynum == 9) || (keynum == 13)) {
cell.selectNext();
return false;
}
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|| (keynum == 8) //backspace
|| (keynum == 46) //delete
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188); //,
}
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
}

186
modules/EcmCalls/Settings.js Executable file
View File

@@ -0,0 +1,186 @@
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);
}
}
var tbody_;
var ItemListSave;
var ItemListClear;
var ItemListFil;
addEvent(
window,
'load',
function() {
var phonesTable = new MyTable('phonesTable');
phonesTable.onRefreshRowIndex = function(row) {
var data = new Object();
data['index'] = (row.index+1).toString();
row.cells.item(0).setData(data);
}
phonesTable.onCreateRow = function(row) {
row.newPos = false;
row.ondblclick = function() {}
row.onSelect = function() {
for(var i=0; i<this.myTable.colCount(); i++)
this.cells.item(i).change(!this.newPos);
}
row.onDeselect = function() {
for(var i=0; i<this.myTable.colCount(); i++)
this.cells.item(i).change(false);
}
}
phonesTable.onCreateCell = function(cell) {
var i = cell.index;
cell.change = function(select) {};
if(i == 0) {
cell.setData = function(data) {
if(data.index) cell.firstChild.value = data.index;
};
cell.getData = function(data) {
data.index = cell.firstChild.value;
}
cell.select = function() { this.selectNext(); }
var edit = document.createElement('input');
edit.setAttribute('type','text');
edit.setAttribute('readOnly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
}
if(i == 1) {
cell.change = function(select) {}
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
data.phone = cn[0].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if(data.phone) cn[0].value = data.phone;
}
var edit = '<input type="text" onFocus="this.parentNode.select();" tabindex="1" class="inputs" style="height:16px;" autocomplete="off" onKeyDown="return this.parentNode.myTable.KeyPressed(event,this.parentNode);">';
cell.innerHTML = edit;
}
if(i == 2) {
cell.change = function(select) {}
cell.selectNext = function() { this.nextSibling.selectNext(); }
cell.getData = function(data) {
var cn = this.getElementsByTagName('input');
data.note = cn[0].value;
}
cell.setData = function(data) {
var cn = this.getElementsByTagName('input');
if(data.note) cn[0].value = data.note;
}
var edit = '<input type="text" onFocus="this.parentNode.select();" tabindex="1" class="inputs" style="height:16px;" autocomplete="off" onKeyDown="return this.parentNode.myTable.KeyPressed(event,this.parentNode);">';
cell.innerHTML = edit;
}
if(i == 3) {
var img;
//insert
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src','modules/EcmCalls/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
img.setAttribute('src','modules/EcmCalls/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.deleteRow(); };
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move up
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src','modules/EcmCalls/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveUp(); };
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src','modules/EcmCalls/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveDown(); }
cell.appendChild(img);
}
}
phonesTable.onSetCellData = function(row,cell,data) {
if(cell.innerHTML == '') cell.innerHTML = '&nbsp;';
}
ItemListSave = function(json) {
var data = new Object();
var tmp;
for(var i=0; i<phonesTable.rowCount(); i++) {
var tmp_data = phonesTable.row(i).getData();
if(tmp_data['phone'] != '' && tmp_data['note'] != '') data[i.toString()] = tmp_data;
}
var r = json ? JSON.stringifyNoSecurity(data) : data;
document.getElementById('phone_list').value = r;
}
ItemListClear = function(noNew) {
while(phonesTable.rowCount()>0) phonesTable.row(0).deleteRow(noNew);
}
ItemListFill = function() {
var pl = document.getElementById('phone_list').value;
if(pl && pl != '') {
try {
pl = eval(pl);
for(x in pl) if(typeof(pl[x]) == "object") { var pl_row = pl[x]; phonesTable.addRow().setData(pl_row); }
} catch(err) { pl = null; };
}
if(phonesTable.rowCount() == 0) phonesTable.addRow();
}
ItemListFill();
}
);

104
modules/EcmCalls/SubPanel.js Executable file
View File

@@ -0,0 +1,104 @@
//my standard functions - begin
function doRequest(where,post,success,fail) {
this.Display = function(result) { success(result.responseText); }
this.Fail = function(result){ if(typeof(fail) != "undefined") { if(typeof(fail) == "string") alert(fail); else fail(result.responseText); } }
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
}
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);
}
}
//my standard functions - end
var EcmCallsPage = 0;
var EcmCallsRowLook = new Object()
var EcmCallsColors = new Object();
function loadEcmCalls(page) {
var b = findSubpanel('subpanel_ecmcalls');
if(b) {
doRequest(
'index.php',
'module=EcmCalls&action=SubPanel&to_pdf=1&page='+page+'&searchModule='+document.forms.DetailView.module.value+'&searchRecord='+document.forms.DetailView.record.value,
function(result) {
b.slotCount = 0;
var arr = eval(result);
if(arr[0]) {
arr = arr[0];
EcmCallsColors = arr['colors'];
for(x in arr['positions']) addEcmCall(b,arr['positions'][x]);
}
b.slotCount = 0;
}
);
}
}
function addEcmCall(body_,ecmcall) {
var tr = document.createElement('tr');
tr.height = "20";
tr.scope = "row";
tr.onmouseover = function() { setPointer(this, '', 'over', EcmCallsColors['even_bg'], EcmCallsColors['hilite_bg'] , ''); }
tr.onmouseout = function() { setPointer(this, '', 'out', EcmCallsColors['even_bg'], EcmCallsColors['hilite_bg'] , ''); }
for(x in EcmCallsRowLook) {
var td = document.createElement('td');
td.className = ((body_.slotCount%2) ? 'oddListRowS1' : 'evenListRowS1');
td.bgcolor = EcmCallsColors['odd_bg'];
td.valign = "top";
td.noWrap = "noWrap";
var span = document.createElement('span');
span.sugar = "slot"+(body_.slotCount++)+"b";
span.innerHTML = ecmcall[x];
td.appendChild(span);
tr.appendChild(td);
}
body_.appendChild(tr);
var tr = document.createElement('tr');
var td = document.createElement('td');
td.colSpan = 20;
td.className = 'listViewHRS1';
tr.appendChild(td);
body_.appendChild(tr);
}
function findSubpanel(name) {
var div = document.getElementById(name);
if(div) {
var table = div.getElementsByTagName('table');
if(table && table[0]) {
var body_ = table[0].getElementsByTagName('tbody');
if(body_) {
return body_[0];
}
}
}
return null;
}
addEvent(
window,
'load',
function(result) {
/*
var tmp = document.getElementById('EcmCallsSubPanelDefs');
var spd = eval(tmp.value);
if(spd && spd[0]) spd = spd[0];
EcmCallsRowLook = spd;
*/
showSubPanel('ecmcalls','/index.php?module=EcmCalls&spModule='+document.forms.DetailView.module.value+'&record='+document.forms.DetailView.record.value+'&'+document.forms.DetailView.module.value+'_CELL_offset=0&to_pdf=true&action=SubPanelViewerMy&subpanel=ecmcalls&EcmCalls_CELL_offset=0&EcmCalls_CELL_ORDER_BY=&sort_order=desc&to_pdf=true',true);
//loadEcmCalls();
}
);

View File

@@ -0,0 +1 @@
// JavaScript Document

164
modules/EcmCalls/formloader.js Executable file
View File

@@ -0,0 +1,164 @@
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 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 FormLoader() {
this.module;
this.createModule;
this.fieldName;
this.buttonName = 'FormLoaderButton';
this.load = function(module,createModule,fieldName) {
this.module = module;
this.createModule = createModule;
this.fieldName = fieldName;
}
this.createButton = function() {
var b = document.createElement('input');
b.type = 'button';
b.className = 'button';
b.name = this.buttonName;
b.value = 'Create';
b.FL = this;
b.onclick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
return b;
}
this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
this.editDblClick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
this.responseData = function(data) {
if(this.onResponseData) this.onResponseData(data);
}
this.onResponseData;
this.addPostData = function() {
if(this.onAddPostData)
return this.onAddPostData();
else
return '';
}
this.onAddPostData;
this.onButtonClick;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

200
modules/EcmDesigns/Categories.js Executable file
View File

@@ -0,0 +1,200 @@
//categories
function saveItems3(){
document.getElementById('position_list3').value = ItemsList3(true);
}
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 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);
}
}
var tbody_;
var ItemListSave3;
var ItemListClear3;
var ItemListFil3;
var FillText;
addEvent(
window,
'load',
function() {
var paramsTable3 = new paramsMT('itemsTable3');
paramsTable3.onCreateRow = function(row) {
row.newPos = false;
row.noAddNew = true;
row.ondblclick = function() {}
row.onSelect = function() {
}
row.onDeselect = function() {
}
}
paramsTable3.onCreateCell = function(cell) {
var i = cell.index;
if(i == 0) {
cell.setData = function(data) {
console.log(data);
if(data.ecmproductcategory_name) {
cell.firstChild.value = data.ecmproductcategory_name;
cell.getElementsByTagName('input')[1].value = data.ecmproductcategory_id;
if (data.id)
cell.getElementsByTagName('input')[2].value = data.id;
}
};
cell.getData = function(data) {
data.ecmproductcategory_name = cell.firstChild.value;
data.ecmproductcategory_id = cell.getElementsByTagName('input')[1].value;
data.id = cell.getElementsByTagName('input')[2].value;
}
cell.onSelect = function() {
var cn = this.getElementsByTagName('input');
cn[0].name = 'name_p';
cn[0].id = 'name_p';
cn[1].name = 'id_p';
cn[1].id = 'id_p';
}
cell.onDeselect = function() {
ERROR = false;
var data = new Object();
this.getData(data);
if(!ERROR) {
data.product_group = data.product_group;
this.setData(data);
}
var cn = this.getElementsByTagName('input');
cn[0].name = '';
cn[0].id = '';
cn[1].name = '';
cn[1].id = '';
}
//cell.select = function() { this.selectNext(); }
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
var edit = document.createElement('input');
edit.setAttribute('type','text');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var edit = document.createElement('input');
edit.setAttribute('type','hidden');
edit.setAttribute('readonly','readonly');
edit.setAttribute('tabIndex',1);
edit.className = 'inputs';
cell.appendChild(edit);
var img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
img.setAttribute('src','modules/EcmQuotes/images/search.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
var ecmpopup = open_popup( "EcmProductCategories", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"id_p","name":"name_p"}}, "single", true );
setTimeout(function(){ecmpopup.focus();},200);
}
cell.appendChild(img);
}
if(i == 1) {
var img;
cell.style.padding="auto auto auto auto";
//insert
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/insertrow.gif');
img.style.cursor = 'pointer';
img.onclick = function() {
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
refreshPositionIndex();
};
//delete
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
img.setAttribute('src','modules/EcmQuotes/images/deleterow.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.deleteRow(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
cell.appendChild(document.createElement('br'));
//move up
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
img.setAttribute('src','modules/EcmQuotes/images/moverowup.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveUp(); refreshPositionIndex();};
cell.appendChild(img);
cell.appendChild(document.createTextNode(" "));
//move down
img = document.createElement('img');
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
img.setAttribute('src','modules/EcmQuotes/images/moverowdown.gif');
img.style.cursor = 'pointer';
img.onclick = function() { this.parentNode.parentNode.moveDown();refreshPositionIndex(); }
cell.appendChild(img);
}
}
ItemsList3 = function(json) {
var data = '';
for(var i=0; i<paramsTable3.rowCount(); i++) {
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable3.row(i).getData());
}
return data;
}
if(paramsTable3.rowCount() == 0) {paramsTable3.addRow();};
paramsTable3.onSetCellData = function(row,cell,data) {
if(cell.innerHTML == '') cell.innerHTML = '&nbsp;';
}
ItemListFill3 = function() {
var pl;
pl = document.getElementById('position_list3').value;
console.log(pl);
if(pl && pl != '') {
try {
pl = eval(pl);
for(x in pl) { var pl_row = pl[x]; if (pl_row.template=='') continue; paramsTable3.addRow().setData(pl_row); }
} catch(err) { pl = null; };
}
}
ItemListClear3 = function(noNew,save) {
if(typeof(save)=="string") ItemListSave(null,save);
while(paramsTable3.rowCount()>0) paramsTable3.row(0).deleteRow(noNew);
}
ItemListClear3();
ItemListFill3();
var check_form_ = check_form;
check_form = function(formname) {
saveItems3();
alert(document.getElementById('position_list3').value);
return check_form_(formname);
}
}
);

2308
modules/EcmDesigns/MyTable.js Executable file

File diff suppressed because it is too large Load Diff

448
modules/EcmDesigns/paramsMT.js Executable file
View File

@@ -0,0 +1,448 @@
function NumberToUserFormatNumber(number,add) {
if(!number) number = 0;
number = parseFloat(number);
var tmp = number.toFixed(OPT['dec_len']);
var s1 = tmp.substring(0,tmp.length-1-OPT['dec_len']);
var s2 = tmp.substring(tmp.length-OPT['dec_len'],tmp.length);
var tmp = '';
for(var i=s1.length;i>0;i-=3) {
tmp = ((i<=3)?"":OPT['sep_1000'])+s1.substring(i-3,i)+tmp;
}
s1 = tmp;
return (s1+OPT['dec_sep']+s2).toString()+((add)?add:'');
}
function UserFormatNumberToNumber(ufn,add) {
if(add) {
var match = /add/g;
ufn = ufn.replace(match,'');
}
var match = /Err/g;
ufn = ufn.replace(match,'');
if(!ufn) return parseFloat(0);
var pos = ufn.indexOf(OPT['dec_sep']);
var s1='', s2='';
if(pos==-1) { s1 = ufn; s2 = ''; }
else { s1 = ufn.substring(0,pos); s2 = ufn.substring(pos+1,ufn.length); }
/*
if(OPT['sep_1000'] != "")
for(var i=s1.length-4;i>=0;i-=4)
if(s1.charAt(i) != OPT['sep_1000']) { return -1; }
if(s1.charAt(0) == OPT['sep_1000']) return -1;
*/
var pos = -1;
while((pos = s1.indexOf(OPT['sep_1000'])) != -1)
s1 = s1.substring(0,pos)+s1.substring(pos+1,s1.length);
//alert(s1);
return parseFloat(s1+"."+s2);
}
function keyPressedNumber(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
function isEnterOrTabPressed(e) {
var keynum = keyPressedNumber(e);
if(keynum == 9 || keynum == 13) return true; else return false;
}
function setSelectionRange(obj) {
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
if(obj.createTextRange) {
var range = obj.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", obj.value.lengh-1);
range.select();
} else {
if(obj.setSelectionRange) {
obj.setSelectionRange(0,obj.value.length);
}
}
obj.focus();
}
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
}
function paramsMT(name) {
this.myTableName = name;
this.table = document.getElementById(this.myTableName);
this.thead = this.table.tHead;
this.tbody = this.table.tBodies.item(0);
this.cellSelectedClass = 'selectedCell';
this.rowSelectedClass = 'selectedRow';
this.selectedRow;
this.selectedCell;
this.rowCount = function() {
return this.tbody.rows.length;
}
this.colCount = function() {
return this.thead.rows.item(0).cells.length;
};
this.colWidth = function(i) {
return this.thead.rows.item(0).cells.item(i).width;
};
this.moveUpRow = function() {
if(this.selectedRow) this.selectedRow.moveUp();
};
this.moveDownRow = function() {
if(this.selectedRow) this.selectedRow.moveDown();
};
this.insertRow = function(row, newRow) {
if(!row)
if(this.rowCount())
if(typeof(row) == "number")
row = this.tbody.rows.item(row);
else
row = this.tbody.rows.item(this.tbody.rows.length-1);
var row_tmp;
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
if(this.rowCount() > 0 && row.nextSibling)
this.tbody.insertBefore(row_tmp, row.nextSibling);
else
this.tbody.appendChild(row_tmp);
return row_tmp;
};
this.refreshRowIndex = function() {
for(var i=0; i<this.rowCount(); i++) {
this.tbody.rows.item(i).index = i;
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
}
}
this.onRefreshRowIndex;
this.addRow = function(i,data) {
var row = this.createRow();
if(this.selectedRow) this.selectedRow.deselect();
if(this.selectedCell) this.selectedCell.deselect();
row.myTable = this;
if(i || i===0)
this.tbody.insertBefore(row,this.tbody.rows.item(i));
else
this.tbody.appendChild(row);
this.refreshRowIndex();
this.setRowData(row, data);
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
return row;
}
this.createRow = function(row) {
var row = document.createElement('tr');
row.myTable = this;
row.isnew = false;
row.onclick = function() { this.select(); }
row.select = function() {
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
this.myTable.selectedRow = this;
this.className = this.myTable.rowSelectedClass;
if(row.onSelect) row.onSelect();
}
}
row.deselect = function() {
if(this.myTable.selectedRow === this) {
this.className = '';
this.myTable.selectedRow = '';
if(row.onDeselect) row.onDeselect();
}
};
row.selectNext = function() {
if(this.index < this.myTable.rowCount()-1) { this.deselect(); this.nextSibling.select(); return this.nextSibling; }
else {
if(this.noAddNew) return this;
this.deselect();
var row = this.myTable.addRow(); return row;
}
}
row.selectPrevious = function() {
this.deselect();
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
}
row.deleteRow = function(noNew) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
if(this.myTable.rowCount() == 1 && !noNew) {
var MyTaBlE = this.myTable;
setTimeout( function() { MyTaBlE.addRow(); refreshPositionIndex();} , 1000);
}
this.myTable.tbody.removeChild(this);
this.myTable.refreshRowIndex();
}
row.moveUp = function() {
if(!this.previousSibling) return;
this.myTable.tbody.insertBefore(this,this.previousSibling);
this.myTable.refreshRowIndex();
}
row.moveDown = function() {
if(!this.nextSibling) this.myTable.addRow(row);
this.myTable.tbody.insertBefore(this.nextSibling,this);
this.myTable.refreshRowIndex();
}
row.setData = function(data) {
if(!data || typeof(data) != "object") { return; };
for(var i=0; i<this.myTable.colCount(); i++) {
this.cells.item(i).setData(data);
}
}
row.getData = function() {
var data = new Object();
for(var i=0; i<this.myTable.colCount(); i++) {
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
}
return data;
}
for(var i=0; i<this.colCount(); i++) {
var cell = this.createCell(i);
row.appendChild(cell);
}
if(this.onCreateRow) this.onCreateRow(row);
return row;
};
this.onCreateRow; //function(row) {}
this.createCell = function(i) {
var cell = document.createElement('td');
cell.index = i;
cell.myTable = this;
cell.onclick = function() { this.select(); }
cell.select = function() {
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
this.myTable.selectedCell = this;
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
if(this.onSelect) this.onSelect();
this.className = this.myTable.cellSelectedClass;
}
}
cell.deselect = function() {
if(this.myTable.selectedCell === this) {
if(cell.onDeselect) cell.onDeselect();
this.className = '';
this.selected = false;
this.myTable.selectedCell = '';
}
};
cell.selectNext = function() {
this.deselect();
if(this.nextSibling) this.nextSibling.select();
else {
if(!this.parentNode.nextSibling) { if(this.noNewAdd) return; else this.myTable.addRow(); }
this.parentNode.nextSibling.select();
this.parentNode.nextSibling.firstChild.select();
}
}
cell.afterCreate = function() {}
cell.setData = function(data) {}
cell.getData = function(data) {}
if(this.onCreateCell) this.onCreateCell(cell);
return cell;
};
this.onCreateCell; //function(cell) {}
this.setRowData = function(row,data) {
for(var i=0; i<this.colCount(); i++) {
this.setCellData(row,row.cells.item(i),data);
}
}
this.setCellData = function(row,cell,data) {
if(typeof(row) == "number")
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
if(typeof(cell) != "object")
if(typeof(cell) == "number" && typeof(row) == "object") {
if(row.cells.item(cell))
cell = row.cells.item(cell);
else return;
}
else return;
if(this.onSetCellData) this.onSetCellData(row,cell,data);
}
this.onSetCellData; //function(row,cell,data) {}
this.selectRow = function(row) {
if(this.selectedRow === row) return;
if(this.selectedRow) this.deselectRow();
this.selectedRow = row;
this.selectedRow.className = this.rowSelectedClass;
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
}
this.selectNextRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.nextSibling) this.insertRow();
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.nextSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.selectPreviousRow = function() {
if(!this.selectedRow) return;
if(!this.selectedRow.previousSibling) return;
if(this.selectedRow === this.tbody.rows.item(0)) return;
var cell_id = this.selectedCell.lp;
this.selectRow(this.selectedRow.previousSibling);
this.selectCell(this.selectedRow.cells.item(cell_id));
}
this.refreshNumeration = function() {
for(var i=0; i<this.tbody.rows.length; i++)
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
}
this.KeyPressedNumber = function(e) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
return keynum;
}
this.KeyPressed = function(e, cell, method) {
var keynum;
if(window.event) //IE
keynum = e.keyCode;
else
keynum = e.which;
if((keynum == 9) || (keynum == 13)) {
cell.selectNext();
return false;
}
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
return true;
}
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|| (keynum == 8) //backspace
|| (keynum == 46) //delete
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|| (keynum == 37) //left arrow
|| (keynum == 39) //right arrow
|| (keynum == 188); //,
}
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
}

1018
modules/EcmDevices/Email.js Executable file

File diff suppressed because it is too large Load Diff

480
modules/EcmDevices/advajax.js Executable file
View File

@@ -0,0 +1,480 @@
/*
* AdvancedAJAX 1.1.2
* (c) 2005-2006 Lukasz Lach
* mail: anakin@php5.pl
* www: http://advajax.anakin.us/
* http://anakin.us/
* http://creativecommons.org/licenses/LGPL/2.1/
*
*/
function advAJAX() {
var obj = new Object();
obj.url = window.location.href;
obj.method = "GET";
obj.parameters = new Object();
obj.jsonParameters = new Object();
obj.headers = new Object();
obj.async = true;
obj.mimeType = "text/xml";
obj.username = null;
obj.password = null;
obj.form = null;
obj.disableForm = true;
obj.unique = true;
obj.uniqueParameter = "_uniqid";
obj.requestDone = false;
obj.queryString = "";
obj.responseText = null;
obj.responseXML = null;
obj.status = null;
obj.statusText = null;
obj.aborted = false;
obj.timeout = 0;
obj.retryCount = 0;
obj.retryDelay = 1000;
obj.tag = null;
obj.group = null;
obj.progressTimerInterval = 50;
obj.xmlHttpRequest = null;
obj.onInitialization = null;
obj.onFinalization = null;
obj.onReadyStateChange = null;
obj.onLoading = null;
obj.onLoaded = null;
obj.onInteractive = null;
obj.onComplete = null;
obj.onProgress = null;
obj.onSuccess = null;
obj.onFatalError = null;
obj.onError = null;
obj.onTimeout = null;
obj.onRetryDelay = null;
obj.onRetry = null;
obj.onGroupEnter = null;
obj.onGroupLeave = null;
obj.createXmlHttpRequest = function() {
if (typeof XMLHttpRequest != "undefined")
return new XMLHttpRequest();
var xhrVersion = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
"MSXML2.XMLHttp","Microsoft.XMLHttp" ];
for (var i = 0; i < xhrVersion.length; i++) {
try {
var xhrObj = new ActiveXObject(xhrVersion[i]);
return xhrObj;
} catch (e) { }
}
obj.raiseEvent("FatalError");
return null;
};
obj._oldResponseLength = null;
obj._progressTimer = null;
obj._progressStarted = navigator.userAgent.indexOf('Opera') == -1;
obj._onProgress = function() {
if (typeof obj.onProgress == "function" &&
typeof obj.xmlHttpRequest.getResponseHeader == "function") {
var contentLength = obj.xmlHttpRequest.getResponseHeader("Content-length");
if (contentLength != null && contentLength != '') {
var responseLength = obj.xmlHttpRequest.responseText.length;
if (responseLength != obj._oldResponseLength) {
obj.raiseEvent("Progress", obj, responseLength, contentLength);
obj._oldResponseLength = obj.xmlHttpRequest.responseText.length;
}
}
}
if (obj._progressStarted) return;
obj._progressStarted = true;
var _obj = this;
this.__onProgress = function() {
obj._onProgress();
obj._progressTimer = window.setTimeout(_obj.__onProgress, obj.progressTimerInterval);
}
_obj.__onProgress();
}
obj._onInitializationHandled = false;
obj._initObject = function() {
if (obj.xmlHttpRequest != null) {
delete obj.xmlHttpRequest["onreadystatechange"];
obj.xmlHttpRequest = null;
}
if ((obj.xmlHttpRequest = obj.createXmlHttpRequest()) == null)
return null;
if (typeof obj.xmlHttpRequest.overrideMimeType != "undefined")
obj.xmlHttpRequest.overrideMimeType(obj.mimeType);
obj.xmlHttpRequest.onreadystatechange = function() {
if (obj == null || obj.xmlHttpRequest == null)
return;
obj.raiseEvent("ReadyStateChange", obj, obj.xmlHttpRequest.readyState);
obj._onProgress();
switch (obj.xmlHttpRequest.readyState) {
case 1: obj._onLoading(); break;
case 2: obj._onLoaded(); break;
case 3: obj._onInteractive(); break;
case 4: obj._onComplete(); break;
}
};
obj._onLoadingHandled =
obj._onLoadedHandled =
obj._onInteractiveHandled =
obj._onCompleteHandled = false;
};
obj._onLoading = function() {
if (obj._onLoadingHandled)
return;
if (!obj._retry && obj.group != null) {
if (typeof advAJAX._groupData[obj.group] == "undefined")
advAJAX._groupData[obj.group] = 0;
advAJAX._groupData[obj.group]++;
if (typeof obj.onGroupEnter == "function" && advAJAX._groupData[obj.group] == 1)
obj.onGroupEnter(obj);
}
obj.raiseEvent("Loading", obj);
obj._onLoadingHandled = true;
};
obj._onLoaded = function() {
if (obj._onLoadedHandled)
return;
obj.raiseEvent("Loaded", obj);
obj._onLoadedHandled = true;
};
obj._onInteractive = function() {
if (obj._onInteractiveHandled)
return;
obj.raiseEvent("Interactive", obj);
obj._onInteractiveHandled = true;
if (!obj._progressStarted)
obj._onProgress();
};
obj._onComplete = function() {
if (obj._onCompleteHandled || obj.aborted)
return;
if (obj._progressStarted) {
window.clearInterval(obj._progressTimer);
obj._progressStarted = false;
}
obj.requestDone = true;
with (obj.xmlHttpRequest) {
obj.responseText = responseText;
obj.responseXML = responseXML;
if (typeof status != "undefined")
obj.status = status;
if (typeof statusText != "undefined")
obj.statusText = statusText;
}
obj.raiseEvent("Complete", obj);
obj._onCompleteHandled = true;
if (obj.status == 200)
obj.raiseEvent("Success", obj); else
obj.raiseEvent("Error", obj);
delete obj.xmlHttpRequest['onreadystatechange'];
obj.xmlHttpRequest = null;
if (obj.disableForm)
obj.switchForm(true);
obj._groupLeave();
obj.raiseEvent("Finalization", obj);
};
obj._groupLeave = function() {
if (obj.group != null) {
advAJAX._groupData[obj.group]--;
if (advAJAX._groupData[obj.group] == 0)
obj.raiseEvent("GroupLeave", obj);
}
};
obj._retry = false;
obj._retryNo = 0;
obj._onTimeout = function() {
if (obj == null || obj.xmlHttpRequest == null || obj._onCompleteHandled)
return;
obj.aborted = true;
obj.xmlHttpRequest.abort();
obj.raiseEvent("Timeout", obj);
obj._retry = true;
if (obj._retryNo != obj.retryCount) {
obj._initObject();
if (obj.retryDelay > 0) {
obj.raiseEvent("RetryDelay", obj);
startTime = new Date().getTime();
while (new Date().getTime() - startTime < obj.retryDelay);
}
obj._retryNo++;
obj.raiseEvent("Retry", obj, obj._retryNo);
obj.run();
} else {
delete obj.xmlHttpRequest["onreadystatechange"];
obj.xmlHttpRequest = null;
if (obj.disableForm)
obj.switchForm(true);
obj._groupLeave();
obj.raiseEvent("Finalization", obj);
}
};
obj.run = function() {
obj._initObject();
if (obj.xmlHttpRequest == null)
return false;
obj.aborted = false;
if (!obj._onInitializationHandled) {
obj.raiseEvent("Initialization", obj);
obj._onInitializationHandled = true;
}
if (obj.method == "GET" && obj.unique)
obj.parameters[encodeURIComponent(obj.uniqueParameter)] =
new Date().getTime().toString().substr(5) + Math.floor(Math.random() * 100).toString();
if (!obj._retry) {
for (var a in obj.parameters) {
if (obj.queryString.length > 0)
obj.queryString += "&";
if (typeof obj.parameters[a] != "object")
obj.queryString += encodeURIComponent(a) + "=" + encodeURIComponent(obj.parameters[a]); else {
for (var i = 0; i < obj.parameters[a].length; i++)
obj.queryString += encodeURIComponent(a) + "=" + encodeURIComponent(obj.parameters[a][i]) + "&";
obj.queryString = obj.queryString.slice(0, -1);
}
}
for (var a in obj.jsonParameters) {
var useJson = typeof [].toJSONString == 'function';
if (obj.queryString.length > 0)
obj.queryString += "&";
obj.queryString += encodeURIComponent(a) + "=";
if (useJson)
obj.queryString += encodeURIComponent(obj.jsonParameters[a].toJSONString()); else
obj.queryString += encodeURIComponent(obj.jsonParameters[a]);
}
if (obj.method == "GET" && obj.queryString.length > 0)
obj.url += (obj.url.indexOf("?") != -1 ? "&" : "?") + obj.queryString;
}
if (obj.disableForm)
obj.switchForm(false);
try {
obj.xmlHttpRequest.open(obj.method, obj.url, obj.async, obj.username || '', obj.password || '');
} catch (e) {
obj.raiseEvent("FatalError", obj, e);
return;
}
if (obj.timeout > 0)
setTimeout(obj._onTimeout, obj.timeout);
if (typeof obj.xmlHttpRequest.setRequestHeader != "undefined")
for (var a in obj.headers)
obj.xmlHttpRequest.setRequestHeader(encodeURIComponent(a), encodeURIComponent(obj.headers[a]));
if (obj.method == "POST" && typeof obj.xmlHttpRequest.setRequestHeader != "undefined") {
obj.xmlHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
obj.xmlHttpRequest.send(obj.queryString);
} else if (obj.method == "GET")
obj.xmlHttpRequest.send('');
};
obj.handleArguments = function(args) {
if (typeof args.form == "object" && args.form != null) {
obj.form = args.form;
obj.appendForm();
}
for (a in args) {
if (typeof obj[a] == "undefined")
obj.parameters[a] = args[a]; else {
if (a != "parameters" && a != "headers")
obj[a] = args[a]; else
for (b in args[a])
obj[a][b] = args[a][b];
}
}
obj.method = obj.method.toUpperCase();
};
obj.switchForm = function(enable) {
if (typeof obj.form != "object" || obj.form == null)
return;
with (obj.form)
for (var nr = 0; nr < elements.length; nr++)
if (!enable) {
if (elements[nr]["disabled"])
elements[nr]["_disabled"] = true; else
elements[nr]["disabled"] = "disabled";
} else
if (typeof elements[nr]["_disabled"] == "undefined")
elements[nr].removeAttribute("disabled");
};
obj.appendForm = function() {
with (obj.form) {
obj.method = getAttribute("method").toUpperCase();
obj.url = getAttribute("action");
for (var nr = 0; nr < elements.length; nr++) {
var e = elements[nr];
if (e.disabled)
continue;
switch (e.type) {
case "text":
case "password":
case "hidden":
case "textarea":
obj.addParameter(e.name, e.value);
break;
case "select-one":
if (e.selectedIndex >= 0)
obj.addParameter(e.name, e.options[e.selectedIndex].value);
break;
case "select-multiple":
for (var nr2 = 0; nr2 < e.options.length; nr2++)
if (e.options[nr2].selected)
obj.addParameter(e.name, e.options[nr2].value);
break;
case "checkbox":
case "radio":
if (e.checked)
obj.addParameter(e.name, e.value);
break;
}
}
}
};
obj.addParameter = function(name, value) {
if (typeof obj.parameters[name] == "undefined")
obj.parameters[name] = value; else
if (typeof obj.parameters[name] != "object")
obj.parameters[name] = [ obj.parameters[name], value ]; else
obj.parameters[name][obj.parameters[name].length] = value;
};
obj.delParameter = function(name) {
delete obj.parameters[name];
};
obj.raiseEvent = function(name) {
var args = [];
for (var i = 1; i < arguments.length; i++)
args.push(arguments[i]);
if (typeof obj["on" + name] == "function")
obj["on" + name].apply(null, args);
if (name == "FatalError")
obj.raiseEvent("Finalization", obj);
}
if (typeof advAJAX._defaultParameters != "undefined")
obj.handleArguments(advAJAX._defaultParameters);
return obj;
}
advAJAX.get = function(args) {
return advAJAX.handleRequest("GET", args);
};
advAJAX.post = function(args) {
return advAJAX.handleRequest("POST", args);
};
advAJAX.head = function(args) {
return advAJAX.handleRequest("HEAD", args);
};
advAJAX.submit = function(form, args) {
if (typeof args == "undefined" || args == null)
return -1;
if (typeof form != "object" || form == null)
return -2;
var request = new advAJAX();
args["form"] = form;
request.handleArguments(args);
return request.run();
};
advAJAX.assign = function(form, args) {
if (typeof args == "undefined" || args == null)
return -1;
if (typeof form != "object" || form == null)
return -2;
if (typeof form["onsubmit"] == "function")
form["_onsubmit"] = form["onsubmit"];
form["advajax_args"] = args;
form["onsubmit"] = function() {
if (typeof this["_onsubmit"] != "undefined" && this["_onsubmit"]() === false)
return false;
if (advAJAX.submit(this, this["advajax_args"]) == false)
return true;
return false;
}
return true;
};
advAJAX.download = function(targetObj, url) {
if (typeof targetObj == "string")
targetObj = document.getElementById(targetObj);
if (!targetObj)
return -1;
advAJAX.get({
url: url,
onSuccess : function(obj) {
targetObj.innerHTML = obj.responseText;
}
});
};
advAJAX.scan = function() {
var obj = document.getElementsByTagName("a");
for (var i = 0; i < obj.length;) {
if (obj[i].getAttribute("rel") == "advancedajax" && obj[i].getAttribute("href") !== null) {
var url = obj[i].getAttribute("href");
var div = document.createElement("div");
div.innerHTML = obj[i].innerHTML;
div.className = obj[i].className;
var parent = obj[i].parentNode;
parent.insertBefore(div, obj[i]);
parent.removeChild(obj[i]);
advAJAX.download(div, url);
} else i++;
}
};
advAJAX.handleRequest = function(requestType, args) {
if (typeof args == "undefined" || args == null)
return -1;
var request = new advAJAX();
window.advajax_obj = request;
request.method = requestType;
request.handleArguments(args);
return request.run();
};
advAJAX._defaultParameters = new Object();
advAJAX.setDefaultParameters = function(args) {
advAJAX._defaultParameters = new Object();
for (a in args)
advAJAX._defaultParameters[a] = args[a];
};
advAJAX._groupData = new Object();

5308
modules/EcmDevices/moo1.2.js Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
// JavaScript Document
function moveDiv(obj, mvTop, mvLeft) {
obj.style.position = "absolute";
obj.style.top = mvTop;
obj.style.left = mvLeft;
}
function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
while(1)
{
curtop += obj.offsetTop;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.y)
curtop += obj.y;
return curtop;
}
function showdescription(id,title,desc,minus)
{
if(!minus)minus=0;
var sum=17-minus;
document.getElementById("opis").style.display="inline";
document.getElementById("opis-title").innerHTML=title;
document.getElementById("opis-desc").innerHTML=desc;
posy=findPosY(document.getElementById("link-"+id))+sum;
posx=findPosX(document.getElementById("link-"+id))-80;
moveDiv(document.getElementById("opis"),posy,posx);
}
function hidedescription()
{
document.getElementById("opis").style.display="none";
}

164
modules/EcmDocs/formloader.js Executable file
View File

@@ -0,0 +1,164 @@
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 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 FormLoader() {
this.module;
this.createModule;
this.fieldName;
this.buttonName = 'FormLoaderButton';
this.load = function(module,createModule,fieldName) {
this.module = module;
this.createModule = createModule;
this.fieldName = fieldName;
}
this.createButton = function() {
var b = document.createElement('input');
b.type = 'button';
b.className = 'button';
b.name = this.buttonName;
b.value = 'Create';
b.FL = this;
b.onclick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
return b;
}
this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
this.editDblClick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
this.responseData = function(data) {
if(this.onResponseData) this.onResponseData(data);
}
this.onResponseData;
this.addPostData = function() {
if(this.onAddPostData)
return this.onAddPostData();
else
return '';
}
this.onAddPostData;
this.onButtonClick;
}

164
modules/EcmDocs/helper.js Executable file
View File

@@ -0,0 +1,164 @@
function showdescription(id,title,desc,minus,object)
{
if(!minus)minus=0;
var sum=17-minus;
document.getElementById("desc").style.display="inline";
document.getElementById("desc-title").innerHTML=title;
document.getElementById("desc-desc").innerHTML=desc;
posy=findPosY(object)+sum;
posx=findPosX(object);
moveDiv(document.getElementById("desc"),posy,posx);
}
function hidedescription()
{
document.getElementById("desc").style.display="none";
}
function mintajaxget(url,tag)
{
var req=mint.Request();
req.Set('timeout',10000000);
req.Set('retryNum',0);
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
req.OnSuccess = function(){if($(tag).type=='text'){if(this.responseText!="")$(tag).value=this.responseText;}else{if(this.responseText!="")$(tag).innerHTML=this.responseText;}}
req.Send(url,tag);
}
function mintajaxpost(url,tag,form)
{
var req=mint.Request();
req.OnSuccess=function(){$(tag).innerHTML=this.responseText;}
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
req.SendForm(form);
}
function moveDiv(obj, mvTop, mvLeft) {
obj.style.position = "absolute";
obj.style.top = mvTop;
obj.style.left = mvLeft;
}
function getPos(inputElement) {
var coords = new Object();
coords.x = 0;
coords.y = 0;
try {
targetElement = inputElement;
if(targetElement.x && targetElement.y) {
coords.x = targetElement.x;
coords.y = targetElement.y;
} else {
if(targetElement.offsetParent) {
coords.x += targetElement.offsetLeft;
coords.y += targetElement.offsetTop;
while(targetElement = targetElement.offsetParent) {
coords.x += targetElement.offsetLeft;
coords.y += targetElement.offsetTop;
}
} else {
//alert("Could not find any reference for coordinate positioning.");
}
}
return coords;
} catch(error) {
//alert(error.msg);
return coords;
}
}
function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
return curleft;
//return getPos(obj).x;
}
function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
while(1)
{
curtop += obj.offsetTop;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.y)
curtop += obj.y;
return curtop;
//return getPos(obj).y;
}
function showdiv(id,div,minusy,minusx)
{
document.getElementById(div).style.display="inline";
posy=findPosY(document.getElementById(id))-minusy;
posx=findPosX(document.getElementById(id))-minusx;
moveDiv(document.getElementById(div),posy,posx);
}
function hidediv(div)
{
document.getElementById(div).style.display="none";
}
function showprice(id,price,order_by,sorder)
{
document.getElementById('price').value=price;
document.getElementById('product_id').value=id;
document.getElementById('order_by').value=order_by;
document.getElementById('sorder').value=sorder;
document.getElementById('price-block').style.display="block";
}
function getPrice(id,type)
{
var purchase_price=document.getElementById('purchase_price_'+id).value;
var margin_rate=document.getElementById('margin_rate_'+id).value;
var list_price;
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
if(!isNaN(list_price))document.getElementById('list_price_'+id).value=roundNumber(list_price,2);
}
function CurrencyFormatted(amount)
{
var i = parseFloat(amount);
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
if(s.indexOf('.') < 0) { s += '.00'; }
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
s = minus + s;
return s;
}
function roundN(rnum,rlength)
{
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
return newnumber;
}
function roundNumber(num, dec)
{
if(!isNaN(num))return CurrencyFormatted(roundN(parseFloat(num),dec));
else return "";
}
function ShowHideBlock(id)
{
if(document.getElementById(id).style.display=="block")
{
document.getElementById(id).style.display="none"
}
else
{
document.getElementById(id).style.display="block"
}
}

2
modules/EcmDocs/mintajax.js Executable file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,76 @@
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());
}
);

View File

@@ -0,0 +1,82 @@
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 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 FormLoader() {
this.module;
this.createModule;
this.fieldName;
this.buttonName = 'FormLoaderButton';
this.load = function(module,createModule,fieldName) {
this.module = module;
this.createModule = createModule;
this.fieldName = fieldName;
}
this.createButton = function() {
var b = document.createElement('input');
b.type = 'button';
b.className = 'button';
b.name = this.buttonName;
b.value = 'Create';
b.FL = this;
b.onclick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create","resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
return b;
}
this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
this.editDblClick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create","resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
this.responseData = function(data) {
if(this.onResponseData) this.onResponseData(data);
}
this.onResponseData;
this.addPostData = function() {
if(this.onAddPostData)
return this.onAddPostData();
else
return '';
}
this.onAddPostData;
this.onButtonClick;
}

480
modules/EcmDocuments/advajax.js Executable file
View File

@@ -0,0 +1,480 @@
/*
* AdvancedAJAX 1.1.2
* (c) 2005-2006 Lukasz Lach
* mail: anakin@php5.pl
* www: http://advajax.anakin.us/
* http://anakin.us/
* http://creativecommons.org/licenses/LGPL/2.1/
*
*/
function advAJAX() {
var obj = new Object();
obj.url = window.location.href;
obj.method = "GET";
obj.parameters = new Object();
obj.jsonParameters = new Object();
obj.headers = new Object();
obj.async = true;
obj.mimeType = "text/xml";
obj.username = null;
obj.password = null;
obj.form = null;
obj.disableForm = true;
obj.unique = true;
obj.uniqueParameter = "_uniqid";
obj.requestDone = false;
obj.queryString = "";
obj.responseText = null;
obj.responseXML = null;
obj.status = null;
obj.statusText = null;
obj.aborted = false;
obj.timeout = 0;
obj.retryCount = 0;
obj.retryDelay = 1000;
obj.tag = null;
obj.group = null;
obj.progressTimerInterval = 50;
obj.xmlHttpRequest = null;
obj.onInitialization = null;
obj.onFinalization = null;
obj.onReadyStateChange = null;
obj.onLoading = null;
obj.onLoaded = null;
obj.onInteractive = null;
obj.onComplete = null;
obj.onProgress = null;
obj.onSuccess = null;
obj.onFatalError = null;
obj.onError = null;
obj.onTimeout = null;
obj.onRetryDelay = null;
obj.onRetry = null;
obj.onGroupEnter = null;
obj.onGroupLeave = null;
obj.createXmlHttpRequest = function() {
if (typeof XMLHttpRequest != "undefined")
return new XMLHttpRequest();
var xhrVersion = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
"MSXML2.XMLHttp","Microsoft.XMLHttp" ];
for (var i = 0; i < xhrVersion.length; i++) {
try {
var xhrObj = new ActiveXObject(xhrVersion[i]);
return xhrObj;
} catch (e) { }
}
obj.raiseEvent("FatalError");
return null;
};
obj._oldResponseLength = null;
obj._progressTimer = null;
obj._progressStarted = navigator.userAgent.indexOf('Opera') == -1;
obj._onProgress = function() {
if (typeof obj.onProgress == "function" &&
typeof obj.xmlHttpRequest.getResponseHeader == "function") {
var contentLength = obj.xmlHttpRequest.getResponseHeader("Content-length");
if (contentLength != null && contentLength != '') {
var responseLength = obj.xmlHttpRequest.responseText.length;
if (responseLength != obj._oldResponseLength) {
obj.raiseEvent("Progress", obj, responseLength, contentLength);
obj._oldResponseLength = obj.xmlHttpRequest.responseText.length;
}
}
}
if (obj._progressStarted) return;
obj._progressStarted = true;
var _obj = this;
this.__onProgress = function() {
obj._onProgress();
obj._progressTimer = window.setTimeout(_obj.__onProgress, obj.progressTimerInterval);
}
_obj.__onProgress();
}
obj._onInitializationHandled = false;
obj._initObject = function() {
if (obj.xmlHttpRequest != null) {
delete obj.xmlHttpRequest["onreadystatechange"];
obj.xmlHttpRequest = null;
}
if ((obj.xmlHttpRequest = obj.createXmlHttpRequest()) == null)
return null;
if (typeof obj.xmlHttpRequest.overrideMimeType != "undefined")
obj.xmlHttpRequest.overrideMimeType(obj.mimeType);
obj.xmlHttpRequest.onreadystatechange = function() {
if (obj == null || obj.xmlHttpRequest == null)
return;
obj.raiseEvent("ReadyStateChange", obj, obj.xmlHttpRequest.readyState);
obj._onProgress();
switch (obj.xmlHttpRequest.readyState) {
case 1: obj._onLoading(); break;
case 2: obj._onLoaded(); break;
case 3: obj._onInteractive(); break;
case 4: obj._onComplete(); break;
}
};
obj._onLoadingHandled =
obj._onLoadedHandled =
obj._onInteractiveHandled =
obj._onCompleteHandled = false;
};
obj._onLoading = function() {
if (obj._onLoadingHandled)
return;
if (!obj._retry && obj.group != null) {
if (typeof advAJAX._groupData[obj.group] == "undefined")
advAJAX._groupData[obj.group] = 0;
advAJAX._groupData[obj.group]++;
if (typeof obj.onGroupEnter == "function" && advAJAX._groupData[obj.group] == 1)
obj.onGroupEnter(obj);
}
obj.raiseEvent("Loading", obj);
obj._onLoadingHandled = true;
};
obj._onLoaded = function() {
if (obj._onLoadedHandled)
return;
obj.raiseEvent("Loaded", obj);
obj._onLoadedHandled = true;
};
obj._onInteractive = function() {
if (obj._onInteractiveHandled)
return;
obj.raiseEvent("Interactive", obj);
obj._onInteractiveHandled = true;
if (!obj._progressStarted)
obj._onProgress();
};
obj._onComplete = function() {
if (obj._onCompleteHandled || obj.aborted)
return;
if (obj._progressStarted) {
window.clearInterval(obj._progressTimer);
obj._progressStarted = false;
}
obj.requestDone = true;
with (obj.xmlHttpRequest) {
obj.responseText = responseText;
obj.responseXML = responseXML;
if (typeof status != "undefined")
obj.status = status;
if (typeof statusText != "undefined")
obj.statusText = statusText;
}
obj.raiseEvent("Complete", obj);
obj._onCompleteHandled = true;
if (obj.status == 200)
obj.raiseEvent("Success", obj); else
obj.raiseEvent("Error", obj);
delete obj.xmlHttpRequest['onreadystatechange'];
obj.xmlHttpRequest = null;
if (obj.disableForm)
obj.switchForm(true);
obj._groupLeave();
obj.raiseEvent("Finalization", obj);
};
obj._groupLeave = function() {
if (obj.group != null) {
advAJAX._groupData[obj.group]--;
if (advAJAX._groupData[obj.group] == 0)
obj.raiseEvent("GroupLeave", obj);
}
};
obj._retry = false;
obj._retryNo = 0;
obj._onTimeout = function() {
if (obj == null || obj.xmlHttpRequest == null || obj._onCompleteHandled)
return;
obj.aborted = true;
obj.xmlHttpRequest.abort();
obj.raiseEvent("Timeout", obj);
obj._retry = true;
if (obj._retryNo != obj.retryCount) {
obj._initObject();
if (obj.retryDelay > 0) {
obj.raiseEvent("RetryDelay", obj);
startTime = new Date().getTime();
while (new Date().getTime() - startTime < obj.retryDelay);
}
obj._retryNo++;
obj.raiseEvent("Retry", obj, obj._retryNo);
obj.run();
} else {
delete obj.xmlHttpRequest["onreadystatechange"];
obj.xmlHttpRequest = null;
if (obj.disableForm)
obj.switchForm(true);
obj._groupLeave();
obj.raiseEvent("Finalization", obj);
}
};
obj.run = function() {
obj._initObject();
if (obj.xmlHttpRequest == null)
return false;
obj.aborted = false;
if (!obj._onInitializationHandled) {
obj.raiseEvent("Initialization", obj);
obj._onInitializationHandled = true;
}
if (obj.method == "GET" && obj.unique)
obj.parameters[encodeURIComponent(obj.uniqueParameter)] =
new Date().getTime().toString().substr(5) + Math.floor(Math.random() * 100).toString();
if (!obj._retry) {
for (var a in obj.parameters) {
if (obj.queryString.length > 0)
obj.queryString += "&";
if (typeof obj.parameters[a] != "object")
obj.queryString += encodeURIComponent(a) + "=" + encodeURIComponent(obj.parameters[a]); else {
for (var i = 0; i < obj.parameters[a].length; i++)
obj.queryString += encodeURIComponent(a) + "=" + encodeURIComponent(obj.parameters[a][i]) + "&";
obj.queryString = obj.queryString.slice(0, -1);
}
}
for (var a in obj.jsonParameters) {
var useJson = typeof [].toJSONString == 'function';
if (obj.queryString.length > 0)
obj.queryString += "&";
obj.queryString += encodeURIComponent(a) + "=";
if (useJson)
obj.queryString += encodeURIComponent(obj.jsonParameters[a].toJSONString()); else
obj.queryString += encodeURIComponent(obj.jsonParameters[a]);
}
if (obj.method == "GET" && obj.queryString.length > 0)
obj.url += (obj.url.indexOf("?") != -1 ? "&" : "?") + obj.queryString;
}
if (obj.disableForm)
obj.switchForm(false);
try {
obj.xmlHttpRequest.open(obj.method, obj.url, obj.async, obj.username || '', obj.password || '');
} catch (e) {
obj.raiseEvent("FatalError", obj, e);
return;
}
if (obj.timeout > 0)
setTimeout(obj._onTimeout, obj.timeout);
if (typeof obj.xmlHttpRequest.setRequestHeader != "undefined")
for (var a in obj.headers)
obj.xmlHttpRequest.setRequestHeader(encodeURIComponent(a), encodeURIComponent(obj.headers[a]));
if (obj.method == "POST" && typeof obj.xmlHttpRequest.setRequestHeader != "undefined") {
obj.xmlHttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
obj.xmlHttpRequest.send(obj.queryString);
} else if (obj.method == "GET")
obj.xmlHttpRequest.send('');
};
obj.handleArguments = function(args) {
if (typeof args.form == "object" && args.form != null) {
obj.form = args.form;
obj.appendForm();
}
for (a in args) {
if (typeof obj[a] == "undefined")
obj.parameters[a] = args[a]; else {
if (a != "parameters" && a != "headers")
obj[a] = args[a]; else
for (b in args[a])
obj[a][b] = args[a][b];
}
}
obj.method = obj.method.toUpperCase();
};
obj.switchForm = function(enable) {
if (typeof obj.form != "object" || obj.form == null)
return;
with (obj.form)
for (var nr = 0; nr < elements.length; nr++)
if (!enable) {
if (elements[nr]["disabled"])
elements[nr]["_disabled"] = true; else
elements[nr]["disabled"] = "disabled";
} else
if (typeof elements[nr]["_disabled"] == "undefined")
elements[nr].removeAttribute("disabled");
};
obj.appendForm = function() {
with (obj.form) {
obj.method = getAttribute("method").toUpperCase();
obj.url = getAttribute("action");
for (var nr = 0; nr < elements.length; nr++) {
var e = elements[nr];
if (e.disabled)
continue;
switch (e.type) {
case "text":
case "password":
case "hidden":
case "textarea":
obj.addParameter(e.name, e.value);
break;
case "select-one":
if (e.selectedIndex >= 0)
obj.addParameter(e.name, e.options[e.selectedIndex].value);
break;
case "select-multiple":
for (var nr2 = 0; nr2 < e.options.length; nr2++)
if (e.options[nr2].selected)
obj.addParameter(e.name, e.options[nr2].value);
break;
case "checkbox":
case "radio":
if (e.checked)
obj.addParameter(e.name, e.value);
break;
}
}
}
};
obj.addParameter = function(name, value) {
if (typeof obj.parameters[name] == "undefined")
obj.parameters[name] = value; else
if (typeof obj.parameters[name] != "object")
obj.parameters[name] = [ obj.parameters[name], value ]; else
obj.parameters[name][obj.parameters[name].length] = value;
};
obj.delParameter = function(name) {
delete obj.parameters[name];
};
obj.raiseEvent = function(name) {
var args = [];
for (var i = 1; i < arguments.length; i++)
args.push(arguments[i]);
if (typeof obj["on" + name] == "function")
obj["on" + name].apply(null, args);
if (name == "FatalError")
obj.raiseEvent("Finalization", obj);
}
if (typeof advAJAX._defaultParameters != "undefined")
obj.handleArguments(advAJAX._defaultParameters);
return obj;
}
advAJAX.get = function(args) {
return advAJAX.handleRequest("GET", args);
};
advAJAX.post = function(args) {
return advAJAX.handleRequest("POST", args);
};
advAJAX.head = function(args) {
return advAJAX.handleRequest("HEAD", args);
};
advAJAX.submit = function(form, args) {
if (typeof args == "undefined" || args == null)
return -1;
if (typeof form != "object" || form == null)
return -2;
var request = new advAJAX();
args["form"] = form;
request.handleArguments(args);
return request.run();
};
advAJAX.assign = function(form, args) {
if (typeof args == "undefined" || args == null)
return -1;
if (typeof form != "object" || form == null)
return -2;
if (typeof form["onsubmit"] == "function")
form["_onsubmit"] = form["onsubmit"];
form["advajax_args"] = args;
form["onsubmit"] = function() {
if (typeof this["_onsubmit"] != "undefined" && this["_onsubmit"]() === false)
return false;
if (advAJAX.submit(this, this["advajax_args"]) == false)
return true;
return false;
}
return true;
};
advAJAX.download = function(targetObj, url) {
if (typeof targetObj == "string")
targetObj = document.getElementById(targetObj);
if (!targetObj)
return -1;
advAJAX.get({
url: url,
onSuccess : function(obj) {
targetObj.innerHTML = obj.responseText;
}
});
};
advAJAX.scan = function() {
var obj = document.getElementsByTagName("a");
for (var i = 0; i < obj.length;) {
if (obj[i].getAttribute("rel") == "advancedajax" && obj[i].getAttribute("href") !== null) {
var url = obj[i].getAttribute("href");
var div = document.createElement("div");
div.innerHTML = obj[i].innerHTML;
div.className = obj[i].className;
var parent = obj[i].parentNode;
parent.insertBefore(div, obj[i]);
parent.removeChild(obj[i]);
advAJAX.download(div, url);
} else i++;
}
};
advAJAX.handleRequest = function(requestType, args) {
if (typeof args == "undefined" || args == null)
return -1;
var request = new advAJAX();
window.advajax_obj = request;
request.method = requestType;
request.handleArguments(args);
return request.run();
};
advAJAX._defaultParameters = new Object();
advAJAX.setDefaultParameters = function(args) {
advAJAX._defaultParameters = new Object();
for (a in args)
advAJAX._defaultParameters[a] = args[a];
};
advAJAX._groupData = new Object();

View File

@@ -0,0 +1,655 @@
/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate$
* $Rev$
*
* Version: 1.1.2
*
* Requires: jQuery 1.1.3+
*/
(function($){
// store a copy of the core height and width methods
var height = $.fn.height,
width = $.fn.width;
$.fn.extend({
/**
* If used on document, returns the document's height (innerHeight).
* If used on window, returns the viewport's (window) height.
* See core docs on height() to see what happens when used on an element.
*
* @example $("#testdiv").height()
* @result 200
*
* @example $(document).height()
* @result 800
*
* @example $(window).height()
* @result 400
*
* @name height
* @type Number
* @cat Plugins/Dimensions
*/
height: function() {
if ( !this[0] ) error();
if ( this[0] == window )
if ( $.browser.opera || ($.browser.safari && parseInt($.browser.version) > 520) )
return self.innerHeight - (($(document).height() > self.innerHeight) ? getScrollbarWidth() : 0);
else if ( $.browser.safari )
return self.innerHeight;
else
return $.boxModel && document.documentElement.clientHeight || document.body.clientHeight;
if ( this[0] == document )
return Math.max( ($.boxModel && document.documentElement.scrollHeight || document.body.scrollHeight), document.body.offsetHeight );
return height.apply(this, arguments);
},
/**
* If used on document, returns the document's width (innerWidth).
* If used on window, returns the viewport's (window) width.
* See core docs on width() to see what happens when used on an element.
*
* @example $("#testdiv").width()
* @result 200
*
* @example $(document).width()
* @result 800
*
* @example $(window).width()
* @result 400
*
* @name width
* @type Number
* @cat Plugins/Dimensions
*/
width: function() {
if (!this[0]) error();
if ( this[0] == window )
if ( $.browser.opera || ($.browser.safari && parseInt($.browser.version) > 520) )
return self.innerWidth - (($(document).width() > self.innerWidth) ? getScrollbarWidth() : 0);
else if ( $.browser.safari )
return self.innerWidth;
else
return $.boxModel && document.documentElement.clientWidth || document.body.clientWidth;
if ( this[0] == document )
if ($.browser.mozilla) {
// mozilla reports scrollWidth and offsetWidth as the same
var scrollLeft = self.pageXOffset;
self.scrollTo(99999999, self.pageYOffset);
var scrollWidth = self.pageXOffset;
self.scrollTo(scrollLeft, self.pageYOffset);
return document.body.offsetWidth + scrollWidth;
}
else
return Math.max( (($.boxModel && !$.browser.safari) && document.documentElement.scrollWidth || document.body.scrollWidth), document.body.offsetWidth );
return width.apply(this, arguments);
},
/**
* Gets the inner height (excludes the border and includes the padding) for the first matched element.
* If used on document, returns the document's height (innerHeight).
* If used on window, returns the viewport's (window) height.
*
* @example $("#testdiv").innerHeight()
* @result 210
*
* @name innerHeight
* @type Number
* @cat Plugins/Dimensions
*/
innerHeight: function() {
if (!this[0]) error();
return this[0] == window || this[0] == document ?
this.height() :
this.is(':visible') ?
this[0].offsetHeight - num(this, 'borderTopWidth') - num(this, 'borderBottomWidth') :
this.height() + num(this, 'paddingTop') + num(this, 'paddingBottom');
},
/**
* Gets the inner width (excludes the border and includes the padding) for the first matched element.
* If used on document, returns the document's width (innerWidth).
* If used on window, returns the viewport's (window) width.
*
* @example $("#testdiv").innerWidth()
* @result 210
*
* @name innerWidth
* @type Number
* @cat Plugins/Dimensions
*/
innerWidth: function() {
if (!this[0]) error();
return this[0] == window || this[0] == document ?
this.width() :
this.is(':visible') ?
this[0].offsetWidth - num(this, 'borderLeftWidth') - num(this, 'borderRightWidth') :
this.width() + num(this, 'paddingLeft') + num(this, 'paddingRight');
},
/**
* Gets the outer height (includes the border and padding) for the first matched element.
* If used on document, returns the document's height (innerHeight).
* If used on window, returns the viewport's (window) height.
*
* The margin can be included in the calculation by passing an options map with margin
* set to true.
*
* @example $("#testdiv").outerHeight()
* @result 220
*
* @example $("#testdiv").outerHeight({ margin: true })
* @result 240
*
* @name outerHeight
* @type Number
* @param Map options Optional settings to configure the way the outer height is calculated.
* @cat Plugins/Dimensions
*/
outerHeight: function(options) {
if (!this[0]) error();
options = $.extend({ margin: false }, options || {});
return this[0] == window || this[0] == document ?
this.height() :
this.is(':visible') ?
this[0].offsetHeight + (options.margin ? (num(this, 'marginTop') + num(this, 'marginBottom')) : 0) :
this.height()
+ num(this,'borderTopWidth') + num(this, 'borderBottomWidth')
+ num(this, 'paddingTop') + num(this, 'paddingBottom')
+ (options.margin ? (num(this, 'marginTop') + num(this, 'marginBottom')) : 0);
},
/**
* Gets the outer width (including the border and padding) for the first matched element.
* If used on document, returns the document's width (innerWidth).
* If used on window, returns the viewport's (window) width.
*
* The margin can be included in the calculation by passing an options map with margin
* set to true.
*
* @example $("#testdiv").outerWidth()
* @result 1000
*
* @example $("#testdiv").outerWidth({ margin: true })
* @result 1020
*
* @name outerHeight
* @type Number
* @param Map options Optional settings to configure the way the outer width is calculated.
* @cat Plugins/Dimensions
*/
outerWidth: function(options) {
if (!this[0]) error();
options = $.extend({ margin: false }, options || {});
return this[0] == window || this[0] == document ?
this.width() :
this.is(':visible') ?
this[0].offsetWidth + (options.margin ? (num(this, 'marginLeft') + num(this, 'marginRight')) : 0) :
this.width()
+ num(this, 'borderLeftWidth') + num(this, 'borderRightWidth')
+ num(this, 'paddingLeft') + num(this, 'paddingRight')
+ (options.margin ? (num(this, 'marginLeft') + num(this, 'marginRight')) : 0);
},
/**
* Gets how many pixels the user has scrolled to the right (scrollLeft).
* Works on containers with overflow: auto and window/document.
*
* @example $(window).scrollLeft()
* @result 100
*
* @example $(document).scrollLeft()
* @result 100
*
* @example $("#testdiv").scrollLeft()
* @result 100
*
* @name scrollLeft
* @type Number
* @cat Plugins/Dimensions
*/
/**
* Sets the scrollLeft property for each element and continues the chain.
* Works on containers with overflow: auto and window/document.
*
* @example $(window).scrollLeft(100).scrollLeft()
* @result 100
*
* @example $(document).scrollLeft(100).scrollLeft()
* @result 100
*
* @example $("#testdiv").scrollLeft(100).scrollLeft()
* @result 100
*
* @name scrollLeft
* @param Number value A positive number representing the desired scrollLeft.
* @type jQuery
* @cat Plugins/Dimensions
*/
scrollLeft: function(val) {
if (!this[0]) error();
if ( val != undefined )
// set the scroll left
return this.each(function() {
if (this == window || this == document)
window.scrollTo( val, $(window).scrollTop() );
else
this.scrollLeft = val;
});
// return the scroll left offest in pixels
if ( this[0] == window || this[0] == document )
return self.pageXOffset ||
$.boxModel && document.documentElement.scrollLeft ||
document.body.scrollLeft;
return this[0].scrollLeft;
},
/**
* Gets how many pixels the user has scrolled to the bottom (scrollTop).
* Works on containers with overflow: auto and window/document.
*
* @example $(window).scrollTop()
* @result 100
*
* @example $(document).scrollTop()
* @result 100
*
* @example $("#testdiv").scrollTop()
* @result 100
*
* @name scrollTop
* @type Number
* @cat Plugins/Dimensions
*/
/**
* Sets the scrollTop property for each element and continues the chain.
* Works on containers with overflow: auto and window/document.
*
* @example $(window).scrollTop(100).scrollTop()
* @result 100
*
* @example $(document).scrollTop(100).scrollTop()
* @result 100
*
* @example $("#testdiv").scrollTop(100).scrollTop()
* @result 100
*
* @name scrollTop
* @param Number value A positive number representing the desired scrollTop.
* @type jQuery
* @cat Plugins/Dimensions
*/
scrollTop: function(val) {
if (!this[0]) error();
if ( val != undefined )
// set the scroll top
return this.each(function() {
if (this == window || this == document)
window.scrollTo( $(window).scrollLeft(), val );
else
this.scrollTop = val;
});
// return the scroll top offset in pixels
if ( this[0] == window || this[0] == document )
return self.pageYOffset ||
$.boxModel && document.documentElement.scrollTop ||
document.body.scrollTop;
return this[0].scrollTop;
},
/**
* Gets the top and left positioned offset in pixels.
* The positioned offset is the offset between a positioned
* parent and the element itself.
*
* For accurate calculations make sure to use pixel values for margins, borders and padding.
*
* @example $("#testdiv").position()
* @result { top: 100, left: 100 }
*
* @example var position = {};
* $("#testdiv").position(position)
* @result position = { top: 100, left: 100 }
*
* @name position
* @param Object returnObject Optional An object to store the return value in, so as not to break the chain. If passed in the
* chain will not be broken and the result will be assigned to this object.
* @type Object
* @cat Plugins/Dimensions
*/
position: function(returnObject) {
return this.offset({ margin: false, scroll: false, relativeTo: this.offsetParent() }, returnObject);
},
/**
* Gets the location of the element in pixels from the top left corner of the viewport.
* The offset method takes an optional map of key value pairs to configure the way
* the offset is calculated. Here are the different options.
*
* (Boolean) margin - Should the margin of the element be included in the calculations? True by default.
* (Boolean) border - Should the border of the element be included in the calculations? False by default.
* (Boolean) padding - Should the padding of the element be included in the calculations? False by default.
* (Boolean) scroll - Should the scroll offsets of the parent elements be included in the calculations? True by default.
* When true it adds the total scroll offsets of all parents to the total offset and also adds two
* properties to the returned object, scrollTop and scrollLeft.
* (Boolean) lite - When true it will use the offsetLite method instead of the full-blown, slower offset method. False by default.
* Only use this when margins, borders and padding calculations don't matter.
* (HTML Element) relativeTo - This should be a parent of the element and should have position (like absolute or relative).
* It will retreive the offset relative to this parent element. By default it is the body element.
*
* Also an object can be passed as the second paramater to
* catch the value of the return and continue the chain.
*
* For accurate calculations make sure to use pixel values for margins, borders and padding.
*
* Known issues:
* - Issue: A div positioned relative or static without any content before it and its parent will report an offsetTop of 0 in Safari
* Workaround: Place content before the relative div ... and set height and width to 0 and overflow to hidden
*
* @example $("#testdiv").offset()
* @result { top: 100, left: 100, scrollTop: 10, scrollLeft: 10 }
*
* @example $("#testdiv").offset({ scroll: false })
* @result { top: 90, left: 90 }
*
* @example var offset = {}
* $("#testdiv").offset({ scroll: false }, offset)
* @result offset = { top: 90, left: 90 }
*
* @name offset
* @param Map options Optional settings to configure the way the offset is calculated.
* @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
* chain will not be broken and the result will be assigned to this object.
* @type Object
* @cat Plugins/Dimensions
*/
offset: function(options, returnObject) {
if (!this[0]) error();
var x = 0, y = 0, sl = 0, st = 0,
elem = this[0], parent = this[0], op, parPos, elemPos = $.css(elem, 'position'),
mo = $.browser.mozilla, ie = $.browser.msie, oa = $.browser.opera,
sf = $.browser.safari, sf3 = $.browser.safari && parseInt($.browser.version) > 520,
absparent = false, relparent = false,
options = $.extend({ margin: true, border: false, padding: false, scroll: true, lite: false, relativeTo: document.body }, options || {});
// Use offsetLite if lite option is true
if (options.lite) return this.offsetLite(options, returnObject);
// Get the HTMLElement if relativeTo is a jquery collection
if (options.relativeTo.jquery) options.relativeTo = options.relativeTo[0];
if (elem.tagName == 'BODY') {
// Safari 2 is the only one to get offsetLeft and offsetTop properties of the body "correct"
// Except they all mess up when the body is positioned absolute or relative
x = elem.offsetLeft;
y = elem.offsetTop;
// Mozilla ignores margin and subtracts border from body element
if (mo) {
x += num(elem, 'marginLeft') + (num(elem, 'borderLeftWidth')*2);
y += num(elem, 'marginTop') + (num(elem, 'borderTopWidth') *2);
} else
// Opera ignores margin
if (oa) {
x += num(elem, 'marginLeft');
y += num(elem, 'marginTop');
} else
// IE does not add the border in Standards Mode
if ((ie && jQuery.boxModel)) {
x += num(elem, 'borderLeftWidth');
y += num(elem, 'borderTopWidth');
} else
// Safari 3 doesn't not include border or margin
if (sf3) {
x += num(elem, 'marginLeft') + num(elem, 'borderLeftWidth');
y += num(elem, 'marginTop') + num(elem, 'borderTopWidth');
}
} else {
do {
parPos = $.css(parent, 'position');
x += parent.offsetLeft;
y += parent.offsetTop;
// Mozilla and IE do not add the border
// Mozilla adds the border for table cells
if ((mo && !parent.tagName.match(/^t[d|h]$/i)) || ie || sf3) {
// add borders to offset
x += num(parent, 'borderLeftWidth');
y += num(parent, 'borderTopWidth');
// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
if (mo && parPos == 'absolute') absparent = true;
// IE does not include the border on the body if an element is position static and without an absolute or relative parent
if (ie && parPos == 'relative') relparent = true;
}
op = parent.offsetParent || document.body;
if (options.scroll || mo) {
do {
if (options.scroll) {
// get scroll offsets
sl += parent.scrollLeft;
st += parent.scrollTop;
}
// Opera sometimes incorrectly reports scroll offset for elements with display set to table-row or inline
if (oa && ($.css(parent, 'display') || '').match(/table-row|inline/)) {
sl = sl - ((parent.scrollLeft == parent.offsetLeft) ? parent.scrollLeft : 0);
st = st - ((parent.scrollTop == parent.offsetTop) ? parent.scrollTop : 0);
}
// Mozilla does not add the border for a parent that has overflow set to anything but visible
if (mo && parent != elem && $.css(parent, 'overflow') != 'visible') {
x += num(parent, 'borderLeftWidth');
y += num(parent, 'borderTopWidth');
}
parent = parent.parentNode;
} while (parent != op);
}
parent = op;
// exit the loop if we are at the relativeTo option but not if it is the body or html tag
if (parent == options.relativeTo && !(parent.tagName == 'BODY' || parent.tagName == 'HTML')) {
// Mozilla does not add the border for a parent that has overflow set to anything but visible
if (mo && parent != elem && $.css(parent, 'overflow') != 'visible') {
x += num(parent, 'borderLeftWidth');
y += num(parent, 'borderTopWidth');
}
// Safari 2 and opera includes border on positioned parents
if ( ((sf && !sf3) || oa) && parPos != 'static' ) {
x -= num(op, 'borderLeftWidth');
y -= num(op, 'borderTopWidth');
}
break;
}
if (parent.tagName == 'BODY' || parent.tagName == 'HTML') {
// Safari 2 and IE Standards Mode doesn't add the body margin for elments positioned with static or relative
if (((sf && !sf3) || (ie && $.boxModel)) && elemPos != 'absolute' && elemPos != 'fixed') {
x += num(parent, 'marginLeft');
y += num(parent, 'marginTop');
}
// Safari 3 does not include the border on body
// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent
// IE does not include the border on the body if an element is positioned static and without an absolute or relative parent
if ( sf3 || (mo && !absparent && elemPos != 'fixed') ||
(ie && elemPos == 'static' && !relparent) ) {
x += num(parent, 'borderLeftWidth');
y += num(parent, 'borderTopWidth');
}
break; // Exit the loop
}
} while (parent);
}
var returnValue = handleOffsetReturn(elem, options, x, y, sl, st);
if (returnObject) { $.extend(returnObject, returnValue); return this; }
else { return returnValue; }
},
/**
* Gets the location of the element in pixels from the top left corner of the viewport.
* This method is much faster than offset but not as accurate when borders and margins are
* on the element and/or its parents. This method can be invoked
* by setting the lite option to true in the offset method.
* The offsetLite method takes an optional map of key value pairs to configure the way
* the offset is calculated. Here are the different options.
*
* (Boolean) margin - Should the margin of the element be included in the calculations? True by default.
* (Boolean) border - Should the border of the element be included in the calculations? False by default.
* (Boolean) padding - Should the padding of the element be included in the calcuations? False by default.
* (Boolean) scroll - Sould the scroll offsets of the parent elements be included int he calculations? True by default.
* When true it adds the total scroll offsets of all parents to the total offset and also adds two
* properties to the returned object, scrollTop and scrollLeft.
* (HTML Element) relativeTo - This should be a parent of the element and should have position (like absolute or relative).
* It will retreive the offset relative to this parent element. By default it is the body element.
*
* @name offsetLite
* @param Map options Optional settings to configure the way the offset is calculated.
* @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the
* chain will not be broken and the result will be assigned to this object.
* @type Object
* @cat Plugins/Dimensions
*/
offsetLite: function(options, returnObject) {
if (!this[0]) error();
var x = 0, y = 0, sl = 0, st = 0, parent = this[0], offsetParent,
options = $.extend({ margin: true, border: false, padding: false, scroll: true, relativeTo: document.body }, options || {});
// Get the HTMLElement if relativeTo is a jquery collection
if (options.relativeTo.jquery) options.relativeTo = options.relativeTo[0];
do {
x += parent.offsetLeft;
y += parent.offsetTop;
offsetParent = parent.offsetParent || document.body;
if (options.scroll) {
// get scroll offsets
do {
sl += parent.scrollLeft;
st += parent.scrollTop;
parent = parent.parentNode;
} while(parent != offsetParent);
}
parent = offsetParent;
} while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML' && parent != options.relativeTo);
var returnValue = handleOffsetReturn(this[0], options, x, y, sl, st);
if (returnObject) { $.extend(returnObject, returnValue); return this; }
else { return returnValue; }
},
/**
* Returns a jQuery collection with the positioned parent of
* the first matched element. This is the first parent of
* the element that has position (as in relative or absolute).
*
* @name offsetParent
* @type jQuery
* @cat Plugins/Dimensions
*/
offsetParent: function() {
if (!this[0]) error();
var offsetParent = this[0].offsetParent;
while ( offsetParent && (offsetParent.tagName != 'BODY' && $.css(offsetParent, 'position') == 'static') )
offsetParent = offsetParent.offsetParent;
return $(offsetParent);
}
});
/**
* Throws an error message when no elements are in the jQuery collection
* @private
*/
var error = function() {
throw "Dimensions: jQuery collection is empty";
};
/**
* Handles converting a CSS Style into an Integer.
* @private
*/
var num = function(el, prop) {
return parseInt($.css(el.jquery?el[0]:el,prop))||0;
};
/**
* Handles the return value of the offset and offsetLite methods.
* @private
*/
var handleOffsetReturn = function(elem, options, x, y, sl, st) {
if ( !options.margin ) {
x -= num(elem, 'marginLeft');
y -= num(elem, 'marginTop');
}
// Safari and Opera do not add the border for the element
if ( options.border && (($.browser.safari && parseInt($.browser.version) < 520) || $.browser.opera) ) {
x += num(elem, 'borderLeftWidth');
y += num(elem, 'borderTopWidth');
} else if ( !options.border && !(($.browser.safari && parseInt($.browser.version) < 520) || $.browser.opera) ) {
x -= num(elem, 'borderLeftWidth');
y -= num(elem, 'borderTopWidth');
}
if ( options.padding ) {
x += num(elem, 'paddingLeft');
y += num(elem, 'paddingTop');
}
// do not include scroll offset on the element ... opera sometimes reports scroll offset as actual offset
if ( options.scroll && (!$.browser.opera || elem.offsetLeft != elem.scrollLeft && elem.offsetTop != elem.scrollLeft) ) {
sl -= elem.scrollLeft;
st -= elem.scrollTop;
}
return options.scroll ? { top: y - st, left: x - sl, scrollTop: st, scrollLeft: sl }
: { top: y, left: x };
};
/**
* Gets the width of the OS scrollbar
* @private
*/
var scrollbarWidth = 0;
var getScrollbarWidth = function() {
if (!scrollbarWidth) {
var testEl = $('<div>')
.css({
width: 100,
height: 100,
overflow: 'auto',
position: 'absolute',
top: -1000,
left: -1000
})
.appendTo('body');
scrollbarWidth = 100 - testEl
.append('<div>')
.find('div')
.css({
width: '100%',
height: 200
})
.width();
testEl.remove();
}
return scrollbarWidth;
};
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,352 @@
/*
DragResize v1.0
(c) 2005-2006 Angus Turnbull, TwinHelix Designs http://www.twinhelix.com
Licensed under the CC-GNU LGPL, version 2.1 or later:
http://creativecommons.org/licenses/LGPL/2.1/
This is distributed WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
// Common API code.
if (typeof addEvent != 'function')
{
var addEvent = function(o, t, f, l)
{
var d = 'addEventListener', n = 'on' + t, rO = o, rT = t, rF = f, rL = l;
if (o[d] && !l) return o[d](t, f, false);
if (!o._evts) o._evts = {};
if (!o._evts[t])
{
o._evts[t] = o[n] ? { b: o[n] } : {};
o[n] = new Function('e',
'var r = true, o = this, a = o._evts["' + t + '"], i; for (i in a) {' +
'o._f = a[i]; r = o._f(e||window.event) != false && r; o._f = null;' +
'} return r');
if (t != 'unload') addEvent(window, 'unload', function() {
removeEvent(rO, rT, rF, rL);
});
}
if (!f._i) f._i = addEvent._i++;
o._evts[t][f._i] = f;
};
addEvent._i = 1;
var removeEvent = function(o, t, f, l)
{
var d = 'removeEventListener';
if (o[d] && !l) return o[d](t, f, false);
if (o._evts && o._evts[t] && f._i) delete o._evts[t][f._i];
};
}
function cancelEvent(e, c)
{
e.returnValue = false;
if (e.preventDefault) e.preventDefault();
if (c)
{
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
};
// *** DRAG/RESIZE CODE ***
function DragResize(myName, config)
{
var props = {
myName: myName, // Name of the object.
enabled: true, // Global toggle of drag/resize.
handles: ['tl', 'tm', 'tr',
'ml', 'mr', 'bl', 'bm', 'br'], // Array of drag handles: top/mid/bot/right.
isElement: null, // Function ref to test for an element.
isHandle: null, // Function ref to test for move handle.
element: null, // The currently selected element.
handle: null, // Active handle reference of the element.
minWidth: 10, minHeight: 10, // Minimum pixel size of elements.
minLeft: 0, maxLeft: 9999, // Bounding box area, in pixels.
minTop: 0, maxTop: 9999,
zIndex: 1, // The highest Z-Index yet allocated.
mouseX: 0, mouseY: 0, // Current mouse position, recorded live.
lastMouseX: 0, lastMouseY: 0, // Last processed mouse positions.
mOffX: 0, mOffY: 0, // A known offset between position & mouse.
elmX: 0, elmY: 0, // Element position.
elmW: 0, elmH: 0, // Element size.
allowBlur: true, // Whether to allow automatic blur onclick.
ondragfocus: null, // Event handler functions.
ondragstart: null,
ondragmove: null,
ondragend: null,
ondragblur: null
};
for (var p in props)
this[p] = (typeof config[p] == 'undefined') ? props[p] : config[p];
};
DragResize.prototype.apply = function(node)
{
// Adds object event handlers to the specified DOM node.
var obj = this;
addEvent(node, 'mousedown', function(e) { obj.mouseDown(e) } );
addEvent(node, 'mousemove', function(e) { obj.mouseMove(e) } );
addEvent(node, 'mouseup', function(e) { obj.mouseUp(e) } );
};
DragResize.prototype.select = function(newElement) { with (this)
{
// Selects an element for dragging.
if (!document.getElementById || !enabled) return;
// Activate and record our new dragging element.
if (newElement && (newElement != element) && enabled)
{
element = newElement;
// Elevate it and give it resize handles.
element.style.zIndex = ++zIndex;
if (this.resizeHandleSet) this.resizeHandleSet(element, true);
// Record element attributes for mouseMove().
elmX = parseInt(element.style.left);
elmY = parseInt(element.style.top);
elmW = element.offsetWidth;
elmH = element.offsetHeight;
if (ondragfocus) this.ondragfocus();
}
}};
DragResize.prototype.deselect = function(delHandles) { with (this)
{
// Immediately stops dragging an element. If 'delHandles' is true, this
// remove the handles from the element and clears the element flag,
// completely resetting the .
if (!document.getElementById || !enabled) return;
if (delHandles)
{
if (ondragblur) this.ondragblur();
if (this.resizeHandleSet) this.resizeHandleSet(element, false);
element = null;
}
handle = null;
mOffX = 0;
mOffY = 0;
}};
DragResize.prototype.mouseDown = function(e) { with (this)
{
// Suitable elements are selected for drag/resize on mousedown.
// We also initialise the resize boxes, and drag parameters like mouse position etc.
if (!document.getElementById || !enabled) return true;
var elm = e.target || e.srcElement,
newElement = null,
newHandle = null,
hRE = new RegExp(myName + '-([trmbl]{2})', '');
while (elm)
{
// Loop up the DOM looking for matching elements. Remember one if found.
if (elm.className)
{
if (!newHandle && (hRE.test(elm.className) || isHandle(elm))) newHandle = elm;
if (isElement(elm)) { newElement = elm; break }
}
elm = elm.parentNode;
}
// If this isn't on the last dragged element, call deselect(),
// which will hide its handles and clear element.
if (element && (element != newElement) && allowBlur) deselect(true);
// If we have a new matching element, call select().
if (newElement && (!element || (newElement == element)))
{
// Stop mouse selections if we're dragging a handle.
if (newHandle) cancelEvent(e);
select(newElement, newHandle);
handle = newHandle;
if (handle && ondragstart) this.ondragstart(hRE.test(handle.className));
}
}};
DragResize.prototype.mouseMove = function(e) { with (this)
{
// This continually offsets the dragged element by the difference between the
// last recorded mouse position (mouseX/Y) and the current mouse position.
if (!document.getElementById || !enabled) return true;
// We always record the current mouse position.
mouseX = e.pageX || e.clientX + document.documentElement.scrollLeft;
mouseY = e.pageY || e.clientY + document.documentElement.scrollTop;
// Record the relative mouse movement, in case we're dragging.
// Add any previously stored & ignored offset to the calculations.
var diffX = mouseX - lastMouseX + mOffX;
var diffY = mouseY - lastMouseY + mOffY;
mOffX = mOffY = 0;
// Update last processed mouse positions.
lastMouseX = mouseX;
lastMouseY = mouseY;
// That's all we do if we're not dragging anything.
if (!handle) return true;
// If included in the script, run the resize handle drag routine.
// Let it create an object representing the drag offsets.
var isResize = false;
if (this.resizeHandleDrag && this.resizeHandleDrag(diffX, diffY))
{
isResize = true;
}
else
{
// If the resize drag handler isn't set or returns fase (to indicate the drag was
// not on a resize handle), we must be dragging the whole element, so move that.
// Bounds check left-right...
var dX = diffX, dY = diffY;
if (elmX + dX < minLeft) mOffX = (dX - (diffX = minLeft - elmX));
else if (elmX + elmW + dX > maxLeft) mOffX = (dX - (diffX = maxLeft - elmX - elmW));
// ...and up-down.
if (elmY + dY < minTop) mOffY = (dY - (diffY = minTop - elmY));
else if (elmY + elmH + dY > maxTop) mOffY = (dY - (diffY = maxTop - elmY - elmH));
elmX += diffX;
elmY += diffY;
}
// Assign new info back to the element, with minimum dimensions.
with (element.style)
{
left = elmX + 'px';
width = elmW + 'px';
top = elmY + 'px';
height = elmH + 'px';
}
// Evil, dirty, hackish Opera select-as-you-drag fix.
if (window.opera && document.documentElement)
{
var oDF = document.getElementById('op-drag-fix');
if (!oDF)
{
var oDF = document.createElement('input');
oDF.id = 'op-drag-fix';
oDF.style.display = 'none';
document.body.appendChild(oDF);
}
oDF.focus();
}
if (ondragmove) this.ondragmove(isResize);
// Stop a normal drag event.
cancelEvent(e);
}};
DragResize.prototype.mouseUp = function(e) { with (this)
{
// On mouseup, stop dragging, but don't reset handler visibility.
if (!document.getElementById || !enabled) return;
var hRE = new RegExp(myName + '-([trmbl]{2})', '');
if (handle && ondragend) this.ondragend(hRE.test(handle.className));
deselect(false);
}};
/* Resize Code -- can be deleted if you're not using it. */
DragResize.prototype.resizeHandleSet = function(elm, show) { with (this)
{
// Either creates, shows or hides the resize handles within an element.
// If we're showing them, and no handles have been created, create 4 new ones.
if (!elm._handle_tr)
{
for (var h = 0; h < handles.length; h++)
{
// Create 4 news divs, assign each a generic + specific class.
var hDiv = document.createElement('div');
hDiv.className = myName + ' ' + myName + '-' + handles[h];
elm['_handle_' + handles[h]] = elm.appendChild(hDiv);
}
}
// We now have handles. Find them all and show/hide.
for (var h = 0; h < handles.length; h++)
{
elm['_handle_' + handles[h]].style.visibility = show ? 'inherit' : 'hidden';
}
}};
DragResize.prototype.resizeHandleDrag = function(diffX, diffY) { with (this)
{
// Passed the mouse movement amounts. This function checks to see whether the
// drag is from a resize handle created above; if so, it changes the stored
// elm* dimensions and mOffX/Y.
var hClass = handle && handle.className &&
handle.className.match(new RegExp(myName + '-([tmblr]{2})')) ? RegExp.$1 : '';
// If the hClass is one of the resize handles, resize one or two dimensions.
// Bounds checking is the hard bit -- basically for each edge, check that the
// element doesn't go under minimum size, and doesn't go beyond its boundary.
var dY = diffY, dX = diffX, processed = false;
if (hClass.indexOf('t') >= 0)
{
rs = 1;
if (elmH - dY < minHeight) mOffY = (dY - (diffY = elmH - minHeight));
else if (elmY + dY < minTop) mOffY = (dY - (diffY = minTop - elmY));
elmY += diffY;
elmH -= diffY;
processed = true;
}
if (hClass.indexOf('b') >= 0)
{
rs = 1;
if (elmH + dY < minHeight) mOffY = (dY - (diffY = minHeight - elmH));
else if (elmY + elmH + dY > maxTop) mOffY = (dY - (diffY = maxTop - elmY - elmH));
elmH += diffY;
processed = true;
}
if (hClass.indexOf('l') >= 0)
{
rs = 1;
if (elmW - dX < minWidth) mOffX = (dX - (diffX = elmW - minWidth));
else if (elmX + dX < minLeft) mOffX = (dX - (diffX = minLeft - elmX));
elmX += diffX;
elmW -= diffX;
processed = true;
}
if (hClass.indexOf('r') >= 0)
{
rs = 1;
if (elmW + dX < minWidth) mOffX = (dX - (diffX = minWidth - elmW));
else if (elmX + elmW + dX > maxLeft) mOffX = (dX - (diffX = maxLeft - elmX - elmW));
elmW += diffX;
processed = true;
}
return processed;
}};

View File

@@ -0,0 +1,70 @@
/*
j123 -- JavaScript common library
mail: sebastian.hanula@gmail.com
www: http://www.hanula.com/lab/j123
j123 drag library
*/
j123.drag = {
object : null,
init : function(el,root) {
j123.events.add(el,'mousedown',j123.drag.start);
el.root = root;
if(isNaN(parseInt(el.root.style.left))) el.root.style.left="0px";
if(isNaN(parseInt(el.root.style.top))) el.root.style.top="0px";
if(!el.root.onDragStart) el.root.onDragStart = function(x,y,cx,cy) {};
if(!el.root.onDragEnd)el.root.onDragEnd = function(x,y) {};
if(!el.root.onDrag)el.root.onDrag = function(x,y,cx,cy,e) {return {x:x,y:y}};
},
start : function(e) {
var b = j123.drag.object = this;
e=j123.events.fix(e);
var x=parseInt(b.root.style.top);
var y=parseInt(b.root.style.left);
b.root.onDragStart(x,y,e.clientX,e.clientY);
b.lastMouseX=e.clientX;
b.lastMouseY=e.clientY;
j123.events.add(document,'mousemove',j123.drag.drag);
j123.events.add(document,'mouseup',j123.drag.end);
},
drag : function(a) {
a = j123.events.fix(a);
if(typeof a=="undefined")a=window.event;
if(typeof a.layerX=="undefined")a.layerX=a.offsetX;
if(typeof a.layerY=="undefined")a.layerY=a.offsetY;
var b=j123.drag.object;
var c=a.clientY;
var d=a.clientX;
var e=parseInt(b.root.style.top);
var f=parseInt(b.root.style.left);
var h,g;
h=f+d-b.lastMouseX;
g=e+c-b.lastMouseY;
var point = b.root.onDrag(h,g,a.clientX,a.clientY,a);
if(point.x) b.root.style.left=point.x+"px";
if(point.y) b.root.style.top=point.y+"px";
b.lastMouseX=d;
b.lastMouseY=c;
},
end : function(e) {
j123.events.remove(document,'mousemove',j123.drag.drag);
j123.events.remove(document,'mouseup',j123.drag.end);
j123.drag.object.root.onDragEnd(parseInt(j123.drag.object.root.style.left),parseInt(j123.drag.object.root.style.top));
}
};

View File

@@ -0,0 +1,79 @@
/*
j123 -- JavaScript common library
mail: sebastian.hanula@gmail.com
www: http://www.hanula.com/lab/j123
j123 sortable HTML list library (using drag & drop)
*/
j123.drag.SortableList = {
list_handle:null,
items:null,
temp_item:null,
onChangeOrder:null,
init: function(args) {
var list = $(args['list']);
this.onChangeOrder = args['onChangeOrder'];
this.list_handle = list;
this.items = list.getElementsByTagName('li');
for(var i=0;i<this.items.length;i++) {
this.items[i].setAttribute('orig_order',i);
this.items[i].setAttribute('list_order',i);
this.items[i].onDragStart = this.onItemDragStart;
this.items[i].onDrag = this.onItemDrag;
this.items[i].onDragEnd = this.onItemDragEnd;
j123.drag.init(this.items[i],this.items[i]);
}
},
sortItems : function(item_top) {
var item = j123.drag.object;
var items = j123.drag.SortableList.items;
var y = parseInt(item.style.top);
var height = parseInt(item.offsetHeight);
var item_index = parseInt(item.getAttribute('list_order'));
y += item_index*height;
var index = Math.floor(y / height); if(index < 0) index=-1;
else if(index > items.length-1) index = items.length-1;
if(!isNaN(index)) {
if(index > item_index) {
j123.drag.SortableList.list_handle.insertBefore(items[index] ? items[index]:null,item);
item_top -= height;
} else if(index < item_index -1 && (item.prev_index!=index)) {
j123.drag.SortableList.list_handle.insertBefore(items[index+1],item ? item.nextSibling:null);
item.prev_index = item_index;
item_top += height;
}
}
for(var i=0;i<items.length;i++) {
items[i].setAttribute('list_order',i);
}
return item_top;
},
onItemDragStart : function(x,y) {
j123.drag.object.style.top=0;
j123.drag.object.style.position='relative';
},
onItemDrag : function(x,y,cx,cy,event) {
y = j123.drag.SortableList.sortItems(y);
return {y:y};
},
onItemDragEnd: function(x,y,cx,cy) {
j123.drag.object.style.position='static';
if(j123.drag.SortableList.onChangeOrder) {
j123.drag.SortableList.onChangeOrder(j123.drag.SortableList.items);
}
}
};

View File

@@ -0,0 +1,63 @@
/*
j123 -- JavaScript common library
mail: sebastian.hanula@gmail.com
www: http://www.hanula.com/lab/j123
j123 events library
*/
j123.events = {
Key : {
MB_LEFT: 1,
MB_RIGHT: 2,
KEY_ESC: 27,
KEY_RETURN: 13
},
__events : false,
fix : function(e) {
if (!e) e = window.event;
if (e.target) {
if (e.target.nodeType == 3) e.target = e.target.parentNode
} else if (e.srcElement) {
e.target = e.srcElement
}
if(j123.browser.isIE) e.button = e.button-1;
return e
},
add: function(el,type,fn ) {
if(!this.__events) this.__events = [];
this.__events.push([el,type,fn]);
if(el.addEventListener) {
el.addEventListener(type, fn,false);
} else if(el.attachEvent) {
if (!el._listeners) el._listeners = new Array();
if (!el._listeners[type]) el._listeners[type] = new Array();
var applyFunc = function() {
fn.apply(el, new Array());
}
el._listeners[type][fn] = applyFunc;
el.attachEvent('on' + type, applyFunc);
}
},
remove:function(el,type, fn) {
if(el.removeEventListener) {
el.removeEventListener(type,fn,false);
} else if(el.detachEvent) {
if (el._listeners && el._listeners[type] && el._listeners[type][fn]) {
el.detachEvent('on' + type, el._listeners[type][fn]);
}
}
},
unload : function(e) {
if(j123.events.__events)
for(var i=0;i<j123.events.__events;i++)
j123.events.remove(j123.events.__events[i][0],j123.events.__events[i][1],j123.events.__events[i][2]);
}
};
j123.events.add(window,'unload',j123.events.unload);

129
modules/EcmDocuments/j123.js Executable file
View File

@@ -0,0 +1,129 @@
/*
j123 -- JavaScript common library
mail: sebastian.hanula@gmail.com
www: http://www.hanula.com/lab/j123
j123 core library
*/
j123 = {
ver : { major:0,minor:1},
onInitFunctions:[],
registerOnInit : function(fn) {
this.onInitFunctions.push(fn);
},
init: function() {
for(var i=0;i<this.onInitFunctions.length;i++) {
this.onInitFunctions[i]();
}
}
};
j123.browser = {
isIE : null,
isOpera:null,
init : function() {
var ua = navigator.userAgent.toLowerCase();
j123.browser.isIE = (ua.indexOf('msie') != -1);
j123.browser.isOpera = (ua.indexOf('opera') != -1);
}
};
j123.registerOnInit(j123.browser.init);
j123.common = {
each : function(arr,fn) {
for(var i=0;i<arr.length;i++) fn(arr[i]);
},
init: function() {
}
};
j123.registerOnInit(j123.common.init);
/////////// HTML
function $(x){ return document.getElementById(x);}
function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
};
j123.HTML = {
showElement : function(el) {
if(j123.browser.isIE) {
}
el.style.visibility.display = 'visible';
},
hideElement: function(el) {
el.style.visiblity = 'hidden';
},
removeElement: function(el) {
if(el.parentNode) el.parentNode.removeChild(el);
},
// a przed b
moveBefore: function(a,b) {
b.parentNode.insertBefore(a,b);
j123.HTML.removeElement(a);
},
// a za b
moveAfter : function(a,b) {
a.parentNode.insertBefore(a, a ? b.nextSibling :null);
ji123.HTML.removeElement(a);
},
findPosY : function(el) {
var curtop = 0;
if (el.offsetParent) {
while (el.offsetParent) {
curtop += el.offsetTop
el = el.offsetParent;
}
}
else if (el.y)
curtop += el.y;
return curtop;
},
findPosX : function(el) {
var curleft = 0;
if (el.offsetParent) {
while (el.offsetParent) {
curleft += el.offsetLeft
el = el.offsetParent;
}
}
else if (el.x)
curleft += el.x;
return curleft;
},
setTextContent :function(el,content) {
if(j123.browser.isIE || j123.browser.isOpera) el.innerText = content;
else el.textContent = content;
},
getTextContent :function(el) {
if(j123.browser.isIE || j123.browser.isOpera) return el.innerText;
else return el.textContent;
}
// TODO CSS
};

32
modules/EcmDocuments/jqDnR.js Executable file
View File

@@ -0,0 +1,32 @@
/*
* jqDnR - Minimalistic Drag'n'Resize for jQuery.
*
* Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* $Version: 2007.08.19 +r2
*/
(function($){
$.fn.jqDrag=function(h){return i(this,h,'d');};
$.fn.jqResize=function(h){return i(this,h,'r');};
$.jqDnR={dnr:{},e:0,
drag:function(v){
if(M.k == 'd')E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});
else E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
return false;},
stop:function(){E.css('opacity',M.o);$().unbind('mousemove',J.drag).unbind('mouseup',J.stop);}
};
var J=$.jqDnR,M=J.dnr,E=J.e,
i=function(e,h,k){return e.each(function(){h=(h)?$(h,e):e;
h.bind('mousedown',{e:e,k:k},function(v){var d=v.data,p={};E=d.e;
// attempt utilization of dimensions plugin to fix IE issues
if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
M={X:p.left||f('left')||0,Y:p.top||f('top')||0,W:f('width')||E[0].scrollWidth||0,H:f('height')||E[0].scrollHeight||0,pX:v.pageX,pY:v.pageY,k:d.k,o:E.css('opacity')};
E.css({opacity:0.8});$().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
return false;
});
});},
f=function(k){return parseInt(E.css(k))||false;};
})(jQuery);

32
modules/EcmDocuments/jquery.js vendored Executable file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1013
modules/EcmEmails/Email.js Executable file

File diff suppressed because it is too large Load Diff

48
modules/EcmFkBooks/fkbooks.js Executable file
View File

@@ -0,0 +1,48 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var rhandle=new RevisionListHandler();var from_popup_return=false;function ecmfkbook_set_return(popup_reply_data)
{from_popup_return=true;var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;related_doc_id='EMPTY';for(var the_key in name_to_value_array)
{if(the_key=='toJSON')
{}
else
{var displayValue=name_to_value_array[the_key];displayValue=displayValue.replace('&#039;',"'");displayValue=displayValue.replace('&amp;',"&");displayValue=displayValue.replace('&gt;',">");displayValue=displayValue.replace('&lt;',"<");displayValue=displayValue.replace('&quot; ',"\"");if(the_key=='related_doc_id'){related_doc_id=displayValue;}
window.ecmfkbook.forms[form_name].elements[the_key].value=displayValue;}}
related_doc_id=JSON.stringifyNoSecurity(related_doc_id);var conditions=new Array();conditions[conditions.length]={"name":"ecmfkbook_id","op":"starts_with","value":related_doc_id};var query=new Array();var query={"module":"EcmFkBookRevisions","field_list":['id','revision','date_entered'],"conditions":conditions,"order":'date_entered desc'};result=global_rpcClient.call_method('query',query,true);rhandle.display(result);}
function RevisionListHandler(){}
RevisionListHandler.prototype.display=function(result){var names=result['list'];var rev_tag=ecmfkbook.getElementById('related_doc_rev_id');rev_tag.options.length=0;for(i=0;i<names.length;i++){rev_tag.options[i]=new Option(names[i].fields['revision'],names[i].fields['id'],false,false);}
rev_tag.disabled=false;}
function setvalue(source){src=new String(source.value);target=new String(source.form.ecmfkbook_name.value);if(target.length==0){lastindex=src.lastIndexOf("/");if(lastindex==-1){lastindex=src.lastIndexOf("\\");}
if(lastindex==-1){source.form.ecmfkbook_name.value=src;source.form.escaped_document_name.value=src;}else{source.form.document_name.value=src.substr(++lastindex,src.length);source.form.escaped_document_name.value=src.substr(lastindex,src.length);}}}
function toggle_template_type(istemplate){template_type=ecmfkbook.getElementById('template_type');if(istemplate.checked){template_type.disabled=false;}else{template_type.disabled=true;}}

View File

@@ -0,0 +1,840 @@
window.onbeforeunload = function() {
//removeDocumentReservations(document.getElementById("temp_id").value);
//saveDocumentReservations(document.getElementById("temp_id").value);
//alert("Wprowadzone zmiany nie zostały zapisane");
};
function BlockProducts() {
return true;
var tab = document.getElementById("tbody");
var tr = tab.getElementsByTagName("tr");
var qty;
var total;
for (var i = 0; i < tr.length; i++) {
var inp = tr[i].getElementsByTagName("input");
var img = tr[i].getElementsByTagName("img");
var tx = tr[i].getElementsByTagName("textarea");
//console.log(inp);
if (inp[2].value != '') {
inp[1].setAttribute('readonly', 'readonly');
inp[1].setAttribute('onkeydown', '');
img[2].setAttribute('style', 'display:none');
//img[1].setAttribute('style', 'display:none');
}
//if(inp[8].value==1)deleteEmptyComponents(inp[11].value);
}
return true;
}
function saveDocumentReservations(temp_id, operation) {
return true;
url = 'index.php?module=EcmStockOperations&action=saveDocumentReservations&temp_doc_id=' + temp_id + '&to_pdf=1';
var req = mint.Request();
req.OnSuccess = function() {
switch (operation)
{
case 'cancel':
case 'list':
default:
//window.location = "index.php?module=EcmFkPackages&action=index";
break;
}
return;
};
req.Send(url);
}
function removeDocumentReservations(temp_id, operation) {
return true;
url = 'index.php?module=EcmStockOperations&action=deleteDocumentReservations&temp_doc_id=' + temp_id + '&to_pdf=1';
var req = mint.Request();
req.OnSuccess = function() {
switch (operation)
{
case 'cancel':
case 'list':
default:
window.location = "index.php?module=EcmFkPackages&action=index";
break;
}
return;
};
req.Send(url);
}
function getProductQuantity(rowIndex, operation) {
return true;
//console.log('getProductQuantity');
var stock_id = document.getElementById("stock_id").value;
var product_id = N.row(rowIndex).getData().id;
url = 'index.php?module=EcmStockStates&action=getProductQuantity&stock_id=' + stock_id + '&product_id=' + product_id + '&to_pdf=1';
//console.log(url);
var req = mint.Request();
req.OnSuccess = function() {
//console.log("getProductQuantity:OnSuccess");
//return;
var data = N.row(rowIndex).getData();
//console.log(data);
data.stock = this.responseText;
N.row(rowIndex).setData(data);
if (!data.reserved)
data.reserved = 0;
if (operation == "saveReservation") {
N.row(rowIndex).className = '';
saveReservation(rowIndex, false);
//console.log(data);
if (parseFloat(data.stock) >= data.rq) {
N.row(rowIndex).addClass('greenRow');
} else {
N.row(rowIndex).addClass('redRow');
}
return;
//console.log(data);
//N.row(rowIndex).className='';
//if qty = 0 do clear reserved field
if (data.rq == 0) {
N.row(rowIndex).setData();
removeReservation(rowIndex);
}
if (data.quantity >= data.rq)
{
/*
saveReservation(rowIndex, false);
return;
*/
if (data.stock >= data.rq) {
saveReservation(rowIndex, false);
return;
}
if ((data.stock < data.rq) && (parseFloat(data.stock) + parseFloat(data.rq) > 0)) {
console.log(data.stock);
console.log(data.rq);
console.log(parseFloat(data.stock) + parseFloat(data.rq));
saveReservation(rowIndex, true, parseFloat(data.stock) + parseFloat(data.rq)); // orange row true;
return;
}
if (data.quantity == 0) {
data.reserved = 0;
N.row(rowIndex).setData();
removeReservation(rowIndex);
setTimeout(function() {
getProductQuantity(rowIndex);
}, 1000);
return;
}
/*
//stock > qty - all OK, can reserve
if (data.stock>=data.quantity-data.reserved) {
saveReservation(rowIndex, false);
return;
}
if ((data.stock<(data.quantity-data.reserved)) && (parseFloat(data.stock)+parseFloat(data.reserved)>0)) {
saveReservation(rowIndex, true, parseFloat(data.stock)+parseFloat(data.reserved)); //orange row true;
return;
}
//stock <= qty + res, sand reserve, do nothing
if (data.stock<(data.quantity-data.reserved)) {
N.row(rowIndex).className = 'redRow';
return;
}
*/
}
//if (data.stock < data.rq || data.quantity > data.rq) {
N.row(rowIndex).addClass('redRow');//className = 'redRow';
// return;
//}
}
};
req.Send(url);
}
function saveReservation(rowIndex, orangeRow, qty) {
return true;
//console.log('saveReservation');
var data = N.row(rowIndex).getData();
//console.log(data);
var product_id = data.id;
var temp_item_id = data.temp_item_id;
var quantity;
if (qty)
quantity = qty;
else
quantity = data.rq;
var date = document.getElementById("temp_date").value;
var stock_id = document.getElementById("stock_id").value;
var temp_doc_id = document.getElementById("temp_id").value;
var url = 'index.php?module=EcmStockOperations&action=saveReservation&stock_id=' + stock_id + '&product_id=' + product_id + '&temp_doc_id=' + temp_doc_id + '&temp_item_id=' + temp_item_id + '&date=' + date + '&quantity=' + quantity + '&to_pdf=1';
//console.log(url);
var req = mint.Request();
req.OnSuccess = function() {
//console.log("saveReservation:OnSuccess");
var data = N.row(rowIndex).getData();
data.reserved = quantity;
N.row(rowIndex).setData(data);
//N.row(rowIndex).cell(3).getElementById("reservation_info").innerHtml="("+data.reserved+")";
//N.row(rowIndex).cells.item(4).getElementsByTagName('input')[0].value = NumberToUserFormatNumber(data.reserved);
//cell(3).getElementById("reservation_info").innerHtml
if (orangeRow == true)
N.row(rowIndex).addClass('orangeRow'); //.className = 'orangeRow';
else
N.row(rowIndex).addClass('greenRow'); //.className = 'greenRow';
getProductQuantity(rowIndex);
}
req.Send(url);
}
function removeReservation(index) {
//Console.log('removeReservation');
var data = N.row(index).getData();
var temp_item_id = data.temp_item_id;
url = 'index.php?module=EcmStockOperations&action=deleteReservation&temp_item_id=' + temp_item_id + '&to_pdf=1';
//console.log('removeReservation: ' + url);
var req = mint.Request();
req.OnSuccess = function() {
//console.log('removeReservation OnSuccess');
}
req.Send(url);
}
function SetTabIndexs() {
var main = document.getElementById("main");
var td = main.getElementsByTagName("td");
var selectedTable = null;
//var selectingColor = "red";
//var selectingCellTable = "green";
var TableIndex = 0;
for (var i = 0; i < td.length; i++) {
if (td[i].className == "tabEditViewDF") {
var TI = 0;
if (td[i].parentNode.cells.item(1) == td[i])
TI = 101 + TableIndex;
else
TI = 102 + TableIndex;
var nodes = td[i].getElementsByTagName("input");
for (var j = 0; j < nodes.length; j++)
nodes[j].tabIndex = TI;
var nodes = td[i].getElementsByTagName("select");
for (var j = 0; j < nodes.length; j++)
nodes[j].tabIndex = TI;
var nodes = td[i].getElementsByTagName("textarea");
for (var j = 0; j < nodes.length; j++)
nodes[j].tabIndex = TI;
if (td[i].parentNode.parentNode.parentNode !== selectedTable) {
//if(selectingColor == "red") selectingColor = "blue"; else selectingColor = "red";
selectedTable = td[i].parentNode.parentNode.parentNode;
TableIndex++;
}
}
}
}
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, met, call_back_function, form_name) {
if (!call_back_function)
call_back_function = "set_return";
if (!form_name)
form_name = "EditView";
return open_popup(module, 900, 700, met, 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 findPos(obj) {
var nleft = 0;
var ntop = 0;
if (obj.offsetParent) {
nleft = obj.offsetLeft
ntop = obj.offsetTop
while (obj = obj.offsetParent) {
nleft += obj.offsetLeft
ntop += obj.offsetTop
}
}
return [nleft, ntop];
}
function cursorEOT(isField) {
isRange = isField.createTextRange();
isRange.move("textedit");
isRange.select();
testOverflow = isField.scrollTop;
if (testOverflow != 0) {
return true
}
else {
return false
}
}
function adjustRows(isField) {
while (cursorEOT(isField)) {
isField.rows++
}
}
function insertText(isField, isText) {
isField.value = testText;
isField.focus();
}
function changer() {
this.list = new Object();
this.add = function(object, type, do_function, start_value) {
if (typeof(object) == "string")
object = document.getElementById(object);
if (!object)
return;
this.list[object.id] = new Object();
this.list[object.id].object = object;
this.list[object.id].type = type;
this.list[object.id].do_function = do_function;
this.list[object.id].start_value = start_value;
this.list[object.id].value = "";
}
this.getValue = function(element) {
var value = null;
if (element.object) {
if (element.type == "innerHTML")
value = element.object.innerHTML;
if (element.type == "value")
value = element.object.value;
if (element.type == "checked")
value = element.object.checked;
}
return value;
}
this.interval = 1000;
this.timer = null;
this.startTimer = function() {
var cc = this;
this.timer = setInterval(
function() {
var list = cc.list;
for (x in list) {
if (list[x].start_value) {
list[x].value = cc.getValue(list[x]);
list[x].start_value = false;
}
else {
var value = cc.getValue(list[x]);
if (list[x].value !== value)
if (list[x].do_function)
list[x].do_function(list[x].object);
list[x].value = value;
}
}
},
this.interval
);
}
this.stopTimer = function() {
clearInterval(this.timer);
this.timer = null;
}
}
var ERROR = false;
var ItemListSave = function(json) {
return "";
}
var FkPackageListSave = function(json) {
return "";
}
var IncomeListSave = function(json) {
return "";
}
function ShowLoadingView() {
var slv = document.getElementById("ShowLoadingView");
if (!slv) {
slv = document.createElement("div");
slv.id = "ShowLoadingView";
slv.className = "transparent_class_loading";
slv.style.width = "100%";
slv.style.height = "500%";
var sli = document.createElement("img");
sli.className = "transparent_class_loading_image";
sli.src = "themes/default/images/loading.gif";
slv.appendChild(sli);
document.body.appendChild(slv);
}
slv.style.display = "";
}
function HideLoadingView() {
var slv = document.getElementById("ShowLoadingView");
if (slv)
slv.style.display = "none";
}
function saveItems() {
document.getElementById("position_list").value = ItemsList(true);
}
function saveFkPackages() {
document.getElementById("fkpackages_list").value = FkPackagesList(true);
}
function checkStockQuantity() {
var tab = document.getElementById("tbody");
var tr = tab.getElementsByTagName("tr");
var qtyinstock;
var qty;
var total;
for (var i = 0; i < tr.length; i++) {
qtyinstock = tr[i].getElementsByTagName("input")[18].value;
qty = tr[i].getElementsByTagName("input")[17].value;
total = parseFloat(qtyinstock) - parseFloat(qty);
if (tr[i].getElementsByTagName("input")[17].checked == true && tr[i].getElementsByTagName("input")[2].value && parseInt(qtyinstock) - parseInt(qty) < 0) {
alert("Brakuje produktów na magazynie aby zrobic rezerwacje");
tr[i].getElementsByTagName("input")[17].value = parseInt(qtyinstock);
if (tr[i].getElementsByTagName("input")[9].value < tr[i].getElementsByTagName("input")[18].value) {
tr[i].getElementsByTagName("input")[18].value = parseInt(tr[i].getElementsByTagName("input")[9].value);
}
return false;
}
}
return true;
}
function removeHistoryRecord(id) {
var historyElement = document.forms.EditView.history;
var historyValue = JSON.parse(historyElement.value);
historyValue[id] = null;
//console.log(historyElement.value);
//console.log('Length: ' + historyValue.length);
historyElement.value = JSON.stringifyNoSecurity(historyValue);
return true;
}
function removeHistory(a) {
var paretLi = a.parentNode.parentNode;
var idParts = paretLi.id.split('_');
if (idParts[1] >= 0) {
removeHistoryRecord(idParts[1]);
//paretLi.removeChild(idParts[1]);
paretLi.style.display = 'none';
}
//console.log(paretLi.parentNode.children );
// Hide no-results item if needed.
if (paretLi.parentNode.children.length == 0) {
//
}
return true;
}
function addHistoryRecord(date, owner, record) {
var historyRecord = [
date,
owner,
record
];
var historyElement = document.forms.EditView.history;
var historyValue = JSON.parse(historyElement.value);
historyValue.unshift(historyRecord);
historyElement.value = JSON.stringifyNoSecurity(historyValue);
// Bof: Build list item.
{
var recordLi = document.createElement('li');
var dateP = document.createElement('p');
dateP.appendChild(document.createTextNode(date));
dateP.appendChild(document.createTextNode(', '));
dateP.appendChild(document.createTextNode(owner));
dateP.appendChild(document.createTextNode(':'));
//var ownerP = document.createElement('p');
//ownerP.appendChild(document.createTextNode(owner));
var recordP = document.createElement('p');
recordP.appendChild(document.createTextNode(record));
recordLi.appendChild(dateP);
//recordLi.appendChild(ownerP)
recordLi.appendChild(recordP);
}
// Eof: Build list item.
// Prepend new history record.
var wrapperList = document.getElementById('history_wrapper').children[0];
// Hide no-results item if needed.
if (wrapperList.children.length == 1 && wrapperList.children[0].getAttribute('class') == 'no-results') {
wrapperList.children[0].style.display = 'none';
}
wrapperList.insertBefore(recordLi, wrapperList.firstChild);
return true;
}
function addHistory() {
// Grab important form fields.
var owner = document.forms.EditView.history_owner;
var date = document.forms.EditView.history_date;
var record = document.forms.EditView.history_record;
// Check values.
if (owner.value.length == 0 || date.value.length == 0 || record.value.length == 0) {
alert('Wypełnij wszystkie pola.');
return false;
}
// Create row, update hidden history value.
addHistoryRecord(date.value, owner.value, record.value);
var date = new Date();
// Reset form.
owner.value = '';
date.value = date.toString('d.m.Y');
record.value = '';
return true;
}
function SaveForm() {
ShowLoadingView();
setTimeout(function() {
if (OPT["checkbox_demo"] == 1 && document.forms.EditView.record.value == "") {
alert(MOD.LBL_DEMO_VERSION_INFORMATION);
return;
}
ERROR = false;
//document.getElementById("position_list").value = ItemListSave(true);
if (ERROR) {
alert(MOD["LBL_SAVE_FORM_ERROR"]);
HideLoadingView();
return false;
}
document.forms.EditView.action.value = "Save";
if (check_form("EditView")) {
//var result = confirm(MOD.LBL_CONFIRM_QUESTION);
//if(result) document.forms.EditView.status.value = (OPT["auto_commiting"]?"s30":"s20");
doRequest(
"index.php",
getFormPost("Save"),
function(result) {
/*
console.log(result);
HideLoadingView();
return;
*/
document.forms.EditView.record.value = result.substring(result.length - 36);
if (OPT["setEmailTab"])
setEMAIL(true);
else
window.location = "index.php?module=" + document.forms.EditView.module.value + "&action=DetailView&record=" + document.forms.EditView.record.value;
},
MOD["LBL_NOT_SAVED"]
);
} else {
alert(MOD["LBL_NOT_SAVED"]);
HideLoadingView();
return false;
}
},
200);
}
function ItemListClear() {
while (N.rowCount() > 0)
N.row(0).deleteRow();
}
function getFormPost(action) {
if (!action)
action = "previewPDF";
var pd =
"to_pdf=1" +
"&module=EcmFkPackages&action=" +
action +
"&record=" +
document.forms.EditView.record.value;
pd += "&cache=fromJava" + ItemListSave(true) + FkPackageListSave(true) + IncomeListSave(true);
pd += '&history=' + document.forms.EditView.history.value;
var pd2 = new Object();
pd2["module"] = "EcmFkPackages";
pd2["action"] = action;
pd2["record"] = document.forms.EditView.record.value;
pd2["to_pdf"] = "1";
pd2["cache"] = "fromJava";
//pd2['history'] = document.forms.EditView.history.value;
document.forms.EditView.position_list.value = "";
document.forms["EditView"].action.value = action;
var tmp;
for (var i = 0; i < document.forms["EditView"].elements.length; i++) {
tmp = document.forms["EditView"].elements[i];
if (tmp.name != "") {
if (tmp.type == "checkbox")
pd2[document.forms["EditView"].elements[i].name] = (document.forms["EditView"].elements[i].checked ? "1" : "0");
else
pd2[document.forms["EditView"].elements[i].name] = document.forms["EditView"].elements[i].value;
}
}
pd += "&otherFormData=" + JSON.stringifyNoSecurity(pd2);
return pd;
}
function sendFormPostToPdf(type, panel) {
var tab = '_';
if (type != null) {
tab += type.toUpperCase();
}
ERROR = false;
document.getElementById("position_list").value = ItemListSave(true);
document.getElementById("fkpackages_list").value = FkPackageListSave(true);
document.getElementById("income_list").value = IncomeListSave(true);
if (ERROR) {
alert("There are some errors on list");
return false;
}
doRequest(
"index.php",
getFormPost("previewPDF"),
function(result) {
//console.log(result);
//return;
if (SHOW_PDF_IN_DIV == 1) {
HideLoadingView();
EcmPreviewPDF(
"index.php?module=EcmFkPackages&action=previewPDF&to_pdf=1&from=EcmFkPackages&type=" + type,
{
zoom: 75
}
);
}
else {
SetTab((panel ? "panel_" : "") + "PREVIEW" + tab);
document.getElementById("previewPDF" + tab).innerHTML = '<iframe style="border: none; width: 100%; height: 1200px;" frameborder="no" src="index.php?module=EcmFkPackages&action=previewPDF&to_pdf=1&from=EcmFkPackages&type=' + type + '#zoom=75">Yours browser not accept iframes!</iframe>';
}
}
);
}
preview_pdf = function() {
var type = document.getElementById('preview_type').value;
switch (type)
{
default:
type = 'income';
case 'fault':
case 'income':
case 'qty':
case 'val':
case 'warranty':
break;
}
doRequest(
"index.php",
getFormPost("previewPDF"),
function(result) {
//console.log(result);
//return;
if (SHOW_PDF_IN_DIV == 1) {
HideLoadingView();
EcmPreviewPDF(
"index.php?module=EcmFkPackages&action=previewPDF&to_pdf=1&from=EcmFkPackages&type=" + type,
{
zoom: 75
}
);
}
else {
document.getElementById("previewPDF").innerHTML = '<iframe style="border: none; width: 100%; height: 1200px;" frameborder="no" src="index.php?module=EcmFkPackages&action=previewPDF&to_pdf=1&from=EcmFkPackages&type=' + type + '#zoom=75">Yours browser not accept iframes!</iframe>';
}
}
);
//document.getElementById('previewPDF').innerHTML = '<iframe style="border:none;width:100%;height:1200px;" frameborder="no" src="index.php?module=EcmFkPackages&action=previewPDF&type=' + type + '&to_pdf=1&method=I&record=' + document.forms.DetailView.record.value + '#zoom=75">Yours browser not accept iframes!</iframe>';
}
function canConfirm() {
if (document.forms.EditView.status.value == "accepted" && !OPT.user.confirm_quotes) {
alert("This option is disabled for You.");
document.forms.EditView.status.value = ((OPT.old_status) ? OPT.old_status : "");
}
OPT.old_status = document.forms.EditView.status.value;
}
function CheckDiscount(noAlert) {
var discount = 0;
return 0;
}
var AjaxSearch1Items;
var AjaxSearch2Items;
var AjaxSearch3Items;
var parentFL;
var productFL;
var contactFL;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2419
modules/EcmFkPackages/MyTable.js Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var rhandle=new RevisionListHandler();var from_popup_return=false;function ecmfkpackage_set_return(popup_reply_data)
{from_popup_return=true;var form_name=popup_reply_data.form_name;var name_to_value_array=popup_reply_data.name_to_value_array;related_doc_id='EMPTY';for(var the_key in name_to_value_array)
{if(the_key=='toJSON')
{}
else
{var displayValue=name_to_value_array[the_key];displayValue=displayValue.replace('&#039;',"'");displayValue=displayValue.replace('&amp;',"&");displayValue=displayValue.replace('&gt;',">");displayValue=displayValue.replace('&lt;',"<");displayValue=displayValue.replace('&quot; ',"\"");if(the_key=='related_doc_id'){related_doc_id=displayValue;}
window.ecmfkpackage.forms[form_name].elements[the_key].value=displayValue;}}
related_doc_id=JSON.stringifyNoSecurity(related_doc_id);var conditions=new Array();conditions[conditions.length]={"name":"ecmfkpackage_id","op":"starts_with","value":related_doc_id};var query=new Array();var query={"module":"EcmFkPackageRevisions","field_list":['id','revision','date_entered'],"conditions":conditions,"order":'date_entered desc'};result=global_rpcClient.call_method('query',query,true);rhandle.display(result);}
function RevisionListHandler(){}
RevisionListHandler.prototype.display=function(result){var names=result['list'];var rev_tag=ecmfkpackage.getElementById('related_doc_rev_id');rev_tag.options.length=0;for(i=0;i<names.length;i++){rev_tag.options[i]=new Option(names[i].fields['revision'],names[i].fields['id'],false,false);}
rev_tag.disabled=false;}
function setvalue(source){src=new String(source.value);target=new String(source.form.ecmfkpackage_name.value);if(target.length==0){lastindex=src.lastIndexOf("/");if(lastindex==-1){lastindex=src.lastIndexOf("\\");}
if(lastindex==-1){source.form.ecmfkpackage_name.value=src;source.form.escaped_document_name.value=src;}else{source.form.document_name.value=src.substr(++lastindex,src.length);source.form.escaped_document_name.value=src.substr(lastindex,src.length);}}}
function toggle_template_type(istemplate){template_type=ecmfkpackage.getElementById('template_type');if(istemplate.checked){template_type.disabled=false;}else{template_type.disabled=true;}}

View File

@@ -0,0 +1,164 @@
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 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, 900, 700, "", 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 FormLoader() {
this.module;
this.createModule;
this.fieldName;
this.buttonName = 'FormLoaderButton';
this.load = function(module,createModule,fieldName) {
this.module = module;
this.createModule = createModule;
this.fieldName = fieldName;
}
this.createButton = function() {
var b = document.createElement('input');
b.type = 'button';
b.className = 'button';
b.name = this.buttonName;
b.value = 'Create';
b.FL = this;
b.onclick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
return b;
}
// this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
this.editDblClick = function() {
if(this.FL.createModule == '') return;
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
}
this.responseData = function(data) {
if(this.onResponseData) this.onResponseData(data);
}
this.onResponseData;
this.addPostData = function() {
if(this.onAddPostData)
return this.onAddPostData();
else
return '';
}
this.onAddPostData;
this.onButtonClick;
}

Some files were not shown because too many files have changed in this diff Show More