Grid 1.1 Solve Bugs: 5330, 6509, 6150, 6153, 6328
This commit is contained in:
@@ -1,16 +1,34 @@
|
||||
var G_Grid = function(oForm, sGridName) {
|
||||
// G_Field integration - Start
|
||||
var G_Grid = function(oForm, sGridName){
|
||||
var oGrid = this;
|
||||
this.parent = G_Field;
|
||||
this.parent(oForm, '', sGridName);
|
||||
// G_Field integration - End
|
||||
this.sGridName = sGridName;
|
||||
this.sAJAXPage = oForm.ajaxServer || '';
|
||||
this.oGrid = document.getElementById(this.sGridName);
|
||||
this.onaddrow = function(iRow){};
|
||||
this.ondeleterow = function(){};
|
||||
|
||||
this.aFields = [];
|
||||
this.aElements = [];
|
||||
this.aFunctions = [];
|
||||
this.aFormulas = [];
|
||||
|
||||
this.allDependentFields = ''; //Stores all dependent fields
|
||||
|
||||
this.alertMe = function (txt){
|
||||
new leimnud.module.app.alert().make( {
|
||||
label : txt
|
||||
});
|
||||
};
|
||||
|
||||
this.getObjectName = function(Name){
|
||||
var arr = Name.split('][');
|
||||
var aux = arr.pop();
|
||||
aux = aux.replace(']','');
|
||||
return aux;
|
||||
};
|
||||
|
||||
//Begin SetFields ---------------------------------------------------------------------
|
||||
this.setFields = function(aFields, iRow) {
|
||||
this.aFields = aFields;
|
||||
var i, j, k, aAux, oAux, sDependentFields;
|
||||
@@ -18,8 +36,9 @@ var G_Grid = function(oForm, sGridName) {
|
||||
j = iRow || 1;
|
||||
switch (this.aFields[i].sType) {
|
||||
case 'text':
|
||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
|
||||
this.aElements.push(new G_Text(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
|
||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')){
|
||||
this.aElements.push(
|
||||
new G_Text(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
|
||||
+ this.aFields[i].sFieldName));
|
||||
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
|
||||
if(this.aFields[i].oProperties.strTo) {
|
||||
@@ -64,17 +83,23 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}
|
||||
}
|
||||
// Set dependent fields
|
||||
sw1 = false;
|
||||
if (this.allDependentFields == '') sw1 = true; //Check if dependent fields are setted.
|
||||
for (i = 0; i < this.aFields.length; i++) {
|
||||
j = iRow || 1;
|
||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
|
||||
if (aFields[i].oProperties.dependentFields != '') {
|
||||
this.setDependents(j, this.getElementByName(j, this.aFields[i].sFieldName), aFields[i].oProperties.dependentFields);
|
||||
this.setDependents(j, this.getElementByName(j, this.aFields[i].sFieldName), aFields[i].oProperties.dependentFields, sw1);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.setDependents = function(iRow, me, theDependentFields) {
|
||||
//End Set Fields --------------------------------------------------------
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.setDependents = function(iRow, me, theDependentFields, sw) {
|
||||
var i;
|
||||
var dependentFields = theDependentFields || '';
|
||||
dependentFields = dependentFields.split(',');
|
||||
@@ -83,9 +108,16 @@ var G_Grid = function(oForm, sGridName) {
|
||||
if (oField) {
|
||||
me.dependentFields[i] = oField;
|
||||
me.dependentFields[i].addDependencie(me);
|
||||
if (sw){ //Gets all dependent field only first time
|
||||
if (this.allDependentFields != '') this.allDependentFields += ',';
|
||||
this.allDependentFields += dependentFields[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.unsetFields = function() {
|
||||
var i, j = 0, k, l = 0;
|
||||
k = this.aElements.length / this.aFields.length;
|
||||
@@ -95,11 +127,9 @@ var G_Grid = function(oForm, sGridName) {
|
||||
l++;
|
||||
this.aElements.splice(j - l, 1);
|
||||
}
|
||||
//////for (i = 0; i < this.aElements.length ;i++) {
|
||||
//////alert(this.aElements[i].name +" --- "+this.aElements[i].value());
|
||||
//////}
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
this.getElementByName = function(iRow, sName) {
|
||||
var i;
|
||||
for (i = 0; i < this.aElements.length; i++) {
|
||||
@@ -109,6 +139,9 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.getElementValueByName = function(iRow, sName) {
|
||||
var oAux = document.getElementById('form[' + this.sGridName + '][' + iRow + '][' + sName + ']');
|
||||
if (oAux) {
|
||||
@@ -117,6 +150,9 @@ var G_Grid = function(oForm, sGridName) {
|
||||
return 'Object not found!';
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.getFunctionResult = function(sName) {
|
||||
var oAux = document.getElementById('form[SYS_GRID_AGGREGATE_' + this.sGridName + '_' + sName + ']');
|
||||
if (oAux) {
|
||||
@@ -126,227 +162,233 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.addGridRow = function() {
|
||||
var i, aObjects, aDatePicker;
|
||||
var defaultValue = '';
|
||||
var gridType = '';
|
||||
var oRow = document.getElementById('firstRow_' + this.sGridName);
|
||||
var aCells = oRow.getElementsByTagName('td');
|
||||
var oNewRow = this.oGrid.insertRow(this.oGrid.rows.length - 1);
|
||||
var currentRow = this.oGrid.rows.length - 2;
|
||||
|
||||
oNewRow.onmouseover=function(){
|
||||
highlightRow(this, '#D9E8FF');
|
||||
}
|
||||
};
|
||||
oNewRow.onmouseout=function(){
|
||||
highlightRow(this, '#fff');
|
||||
}
|
||||
};
|
||||
|
||||
// Clone Cells Loop
|
||||
for (i = 0; i < aCells.length; i++) {
|
||||
oNewRow.appendChild(aCells[i].cloneNode(true));
|
||||
if (i == 0) {
|
||||
oNewRow.getElementsByTagName('td')[i].innerHTML = this.oGrid.rows.length - 2;
|
||||
} else {
|
||||
if (i == (aCells.length - 1)) {
|
||||
oNewRow.getElementsByTagName('td')[i].innerHTML = oNewRow.getElementsByTagName('td')[i].innerHTML.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
} else {
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||
if (aObjects) {
|
||||
if (aObjects[0]) {
|
||||
if (aObjects[0].onclick) {
|
||||
sAux = new String(aObjects[0].onclick);
|
||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enodename = aCells[i].innerHTML.substring(aCells[i].innerHTML.indexOf('<')+1, aCells[i].innerHTML.indexOf(' '));
|
||||
enodename = enodename.toLowerCase();
|
||||
|
||||
switch (enodename) {
|
||||
oNewRow.appendChild(aCells[i].cloneNode(true)); //Clone First Cell exactly.
|
||||
switch (i){
|
||||
case 0:
|
||||
oNewRow.getElementsByTagName('td')[i].innerHTML = currentRow;
|
||||
break;
|
||||
case aCells.length - 1:
|
||||
oNewRow.getElementsByTagName('td')[i].innerHTML = oNewRow.getElementsByTagName('td')[i].innerHTML.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
||||
break;
|
||||
default:
|
||||
eNodeName = aCells[i].innerHTML.substring(aCells[i].innerHTML.indexOf('<')+1, aCells[i].innerHTML.indexOf(' '));
|
||||
eNodeName = eNodeName.toLowerCase();
|
||||
switch(eNodeName){
|
||||
case 'input':
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('input');
|
||||
|
||||
if (aObjects) {
|
||||
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
|
||||
aObjects[0].setAttribute('id', newID);
|
||||
//aObjects[0].setAttribute('value', '');
|
||||
if (aObjects){
|
||||
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
||||
aObjects[0].id = newID;
|
||||
aObjects[0].name = newID;
|
||||
if (/*@cc_on!@*/0) { // Internet Explorer test (needs to be modified for IE8)
|
||||
aObjects[0].mergeAttributes(document.createElement("<INPUT id='" + newID + "' name='" + newID + "'/>"), false);
|
||||
var aux = oNewRow.getElementsByTagName('td')[i].innerHTML;
|
||||
}
|
||||
|
||||
tags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||
var attributDefaultValue;
|
||||
if( tags.length >= 0 ){ //then it is not a datepicker
|
||||
scriptTags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');
|
||||
attributes = elementAttributesNS(aObjects[0], 'pm');
|
||||
if(attributes.defaultvalue != undefined && attributes.defaultvalue != '')
|
||||
attributDefaultValue=attributes.defaultvalue;
|
||||
else
|
||||
attributDefaultValue='';
|
||||
if (attributes.defaultvalue != '' && typeof attributes.defaultvalue != 'undefined'){
|
||||
defaultValue = attributes.defaultvalue;
|
||||
}else{
|
||||
defaultValue = '';
|
||||
}
|
||||
|
||||
if (aObjects[0].type != 'checkbox') {
|
||||
if(attributDefaultValue!='' && attributDefaultValue!=undefined)
|
||||
aObjects[0].value = attributDefaultValue;
|
||||
else
|
||||
aObjects[0].value = '';
|
||||
} else {
|
||||
aObjects[0].checked = false;
|
||||
}
|
||||
if (aObjects[0].detachEvent) {
|
||||
try {
|
||||
aObjects[0].detachEvent('onkeypress', this.getElementByName(1, aObjects[0].id.split('][')[2].replace(']', '')).validateKey);
|
||||
}
|
||||
catch (e) {
|
||||
//Nothing
|
||||
}
|
||||
}
|
||||
|
||||
//verifying if it is a datepicker
|
||||
switch(aObjects[0].type){
|
||||
case 'text': //TEXTBOX, CURRENCY, PERCENTAGE, DATEPICKER
|
||||
tags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||
|
||||
if( tags.length == 2 ){ //then it is a datepicker
|
||||
scriptTags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');
|
||||
datePickerTriggerId = tags[1].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
attributes = elementAttributesNS(aObjects[0], 'pm');
|
||||
|
||||
oNewRow.getElementsByTagName('td')[i].removeChild(scriptTags[0]);
|
||||
if (tags.length == 2){ //DATEPICKER
|
||||
//Copy Images
|
||||
img1 = tags[0].innerHTML;
|
||||
img2 = tags[1].innerHTML;
|
||||
//Create new trigger name
|
||||
var datePickerTriggerId = tags[1].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
||||
//Remove 'a' tag for date picker trigger
|
||||
oNewRow.getElementsByTagName('td')[i].removeChild(tags[1]);
|
||||
|
||||
if (tags[0].onclick) {
|
||||
evOnclick = new String(tags[0].onclick);
|
||||
eval('tags[0].onclick = ' + evOnclick.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
||||
//Capture Script and remove
|
||||
scriptTags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('script');
|
||||
oNewRow.getElementsByTagName('td')[i].removeChild(scriptTags[0]);
|
||||
//Create 'a' to remove Date
|
||||
if (tags[0].onclick){
|
||||
var onclickevn = new String(tags[0].onclick);
|
||||
eval('tags[0].onclick = ' + onclickevn.replace(/\[1\]/g, '\[' + currentRow + '\]') + ';');
|
||||
}
|
||||
|
||||
var datePickerTrigger = document.createElement('a');
|
||||
datePickerTrigger.id = datePickerTriggerId;
|
||||
datePickerTrigger.name = datePickerTriggerId;
|
||||
|
||||
var datePickerTriggerImg = document.createElement('img');
|
||||
datePickerTriggerImg.src = '/images/pmdateicon.png';
|
||||
datePickerTriggerImg.border = 0;
|
||||
datePickerTriggerImg.width = 12;
|
||||
datePickerTriggerImg.height = 12;
|
||||
datePickerTriggerImg.style.position = 'relative';
|
||||
datePickerTriggerImg.style.left = '-17px';
|
||||
datePickerTriggerImg.style.top = '0px';
|
||||
|
||||
datePickerTrigger.appendChild(datePickerTriggerImg);
|
||||
oNewRow.getElementsByTagName('td')[i].appendChild(datePickerTrigger);
|
||||
//Create new 'a' to trigger DatePicker
|
||||
var a2 = document.createElement('a');
|
||||
a2.id = datePickerTriggerId;
|
||||
a2.innerHTML = img2;
|
||||
oNewRow.getElementsByTagName('td')[i].appendChild(a2);
|
||||
//Load DatePicker Trigger
|
||||
datePicker4("", newID, attributes.mask, attributes.start, attributes.end, attributes.time);
|
||||
}else {
|
||||
if (/*@cc_on!@*/0) {
|
||||
oNewRow.getElementsByTagName('td')[i].innerHTML = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('span');
|
||||
if (aObjects) {
|
||||
if (aObjects[0]) {
|
||||
// aObjects[0].name =
|
||||
// aObjects[0].name.replace(/\[1\]/g, '\[' +
|
||||
// (this.oGrid.rows.length - 2) + '\]');
|
||||
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
}
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||
if (aObjects) {
|
||||
if (aObjects[0]) {
|
||||
if (aObjects[0].onclick) {
|
||||
sAux = new String(aObjects[0].onclick);
|
||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('div');
|
||||
|
||||
if (aObjects.length > 0) {
|
||||
|
||||
if (aObjects[0]) {
|
||||
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
aObjects[0].name = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
if (aObjects[0].onclick) {
|
||||
sAux = new String(aObjects[0].onclick);
|
||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
||||
}
|
||||
}
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||
if (aObjects) {
|
||||
if (aObjects[0]) {
|
||||
if (aObjects[0].onclick) {
|
||||
sAux = new String(aObjects[0].onclick);
|
||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
aObjects[0].value = defaultValue;
|
||||
break;
|
||||
case 'select':
|
||||
case 'checkbox': //CHECKBOX
|
||||
aObjects[0].checked = false;
|
||||
aObjects[0].value = defaultValue;
|
||||
break;
|
||||
case 'hidden': //HIDDEN
|
||||
aObjects[0].value = defaultValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
aObjects = null;
|
||||
break;
|
||||
case 'textarea': //TEXTAREA
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');
|
||||
if (aObjects){
|
||||
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
||||
aObjects[0].id = newID;
|
||||
aObjects[0].name = newID;
|
||||
attributes = elementAttributesNS(aObjects[0], 'pm');
|
||||
if (attributes.defaultvalue != '' && typeof attributes.defaultvalue != 'undefined'){
|
||||
defaultValue = attributes.defaultvalue;
|
||||
}else{
|
||||
defaultValue = '';
|
||||
}
|
||||
aObjects[0].innerHTML = defaultValue;
|
||||
}
|
||||
aObjects = null;
|
||||
break;
|
||||
case 'select': //DROPDOWN
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('select');
|
||||
if (aObjects) {
|
||||
if (aObjects){
|
||||
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
||||
aObjects[0].id = newID;
|
||||
aObjects[0].name = newID;
|
||||
attributes = elementAttributesNS(aObjects[0], 'pm');
|
||||
if (attributes.defaultvalue != '' && typeof attributes.defaultvalue != 'undefined'){
|
||||
defaultValue = attributes.defaultvalue;
|
||||
//Set '' for Default Value when dropdown has dependent fields.
|
||||
if (attributes.dependent == '1') defaultValue = '';
|
||||
}else{
|
||||
defaultValue = '';
|
||||
}
|
||||
if (attributes.gridtype != '' && typeof attributes.gridtype != 'undefined'){
|
||||
gridType = attributes.gridtype;
|
||||
}else{
|
||||
gridType = '';
|
||||
}
|
||||
aDependents = this.allDependentFields.split(',');
|
||||
sObject = this.getObjectName(newID);
|
||||
//Check if dropdow is dependent
|
||||
sw = false;
|
||||
for (x=0; x < aDependents.length; x++){
|
||||
if (aDependents[x] == sObject) sw = true;
|
||||
}
|
||||
//Delete Options if dropdow is dependent
|
||||
//only remains empty value
|
||||
if (sw){
|
||||
var oAux = document.createElement(aObjects[0].tagName);
|
||||
oAux.name = aObjects[0].name.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
oAux.setAttribute("required", aObjects[0].getAttribute("required"));
|
||||
oAux.id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
for ( var j = 0; j < aObjects[0].options.length; j++) {
|
||||
if (aObjects[0].options[j].value == ''){
|
||||
var oOption = document.createElement('OPTION');
|
||||
oOption.value = aObjects[0].options[j].value;
|
||||
oOption.text = aObjects[0].options[j].text;
|
||||
oAux.options.add(oOption);
|
||||
}
|
||||
aObjects[0].parentNode.replaceChild(oAux, aObjects[0]);
|
||||
/**
|
||||
* note added by gustavo cruz gustavo-at-colosa-dot-com
|
||||
* the piece of code below has been comented in revision 2123
|
||||
* i have tested it and seems to work well, please check this.
|
||||
* aObjects[0].name.replace(/\[1\]/g, '\[' +
|
||||
* (this.oGrid.rows.length - 2) + '\]');
|
||||
* aObjects[0].id = aObjects[0].id.replace(/\[1\]/g,
|
||||
* '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
* aObjects[0].selectedIndex = 0;
|
||||
*/
|
||||
}
|
||||
break;
|
||||
case 'textarea':
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');
|
||||
if (aObjects) {
|
||||
aObjects[0].name = aObjects[0].name.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
aObjects[0].value = '';
|
||||
aObjects[0].innerHTML = ''; //Delete options
|
||||
for (var r =0; r < oAux.options.length; r++){
|
||||
var xOption = document.createElement('OPTION');
|
||||
xOption.value = oAux.options[r].value;
|
||||
xOption.text = oAux.options[r].text;
|
||||
aObjects[0].options.add(xOption);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||
if (aObjects) {
|
||||
aObjects[0].name = aObjects[0].name.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
aObjects[0].value = '';
|
||||
}else{
|
||||
//Set Default Value if it's not a Dependent Field
|
||||
if (defaultValue != ''){
|
||||
var oAux = document.createElement(aObjects[0].tagName);
|
||||
for ( var j = 0; j < aObjects[0].options.length; j++) {
|
||||
var oOption = document.createElement('OPTION');
|
||||
oOption.value = aObjects[0].options[j].value;
|
||||
oOption.text = aObjects[0].options[j].text;
|
||||
if (aObjects[0].options[j].value === defaultValue){
|
||||
oOption.setAttribute('selected','selected');
|
||||
}
|
||||
oAux.options.add(oOption);
|
||||
}
|
||||
aObjects[0].innerHTML = ''; //Delete options
|
||||
for (var r =0; r < oAux.options.length; r++){
|
||||
var xOption = document.createElement('OPTION');
|
||||
xOption.value = oAux.options[r].value;
|
||||
xOption.text = oAux.options[r].text;
|
||||
if (_BROWSER.name == 'msie'){
|
||||
if (oAux.options[r].getAttribute('selected') != ''){
|
||||
xOption.setAttribute('selected','selected');
|
||||
}
|
||||
}else{
|
||||
if (oAux.options[r].getAttribute('selected') == 'selected'){
|
||||
xOption.setAttribute('selected','selected');
|
||||
}
|
||||
}
|
||||
aObjects[0].options.add(xOption);
|
||||
}
|
||||
}
|
||||
//TODO: Implement Default Value and Dependent Fields Trigger for grid dropdowns
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
oNewRow.getElementsByTagName('td')[i].innerHTML = ' ';
|
||||
break;
|
||||
}
|
||||
aObjects = null;
|
||||
break;
|
||||
case 'a': //LINKS
|
||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||
if (aObjects){
|
||||
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
||||
aObjects[0].id = newID;
|
||||
aObjects[0].name = newID;
|
||||
}
|
||||
aObjects = null;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.aFields.length > 0) {
|
||||
this.setFields(this.aFields, this.oGrid.rows.length - 2);
|
||||
this.setFields(this.aFields, currentRow);
|
||||
}
|
||||
if (this.aFunctions.length > 0) {
|
||||
this.assignFunctions(this.aFunctions, 'change', this.oGrid.rows.length - 2);
|
||||
this.assignFunctions(this.aFunctions, 'change', currentRow);
|
||||
}
|
||||
if (this.aFormulas.length > 0) {
|
||||
this.assignFormulas(this.aFormulas, 'change', this.oGrid.rows.length - 2);
|
||||
this.assignFormulas(this.aFormulas, 'change', currentRow);
|
||||
}
|
||||
//Recalculate functions if are declared
|
||||
if (this.aFunctions.length > 0) {
|
||||
for (i = 0; i < this.aFunctions.length; i++) {
|
||||
oAux = document.getElementById('form[' + this.sGridName + '][' + currentRow + '][' + this.aFunctions[i].sFieldName + ']');
|
||||
if (oAux) {
|
||||
switch (this.aFunctions[i].sFunction) {
|
||||
case 'sum':
|
||||
this.sum(false, oAux);
|
||||
break;
|
||||
case 'avg':
|
||||
this.avg(false, oAux);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Fires OnAddRow Event
|
||||
//FIXME: This feature does not work in IE
|
||||
if (this.onaddrow) {
|
||||
this.onaddrow(this.oGrid.rows.length - 2);
|
||||
this.onaddrow(currentRow);
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
this.deleteGridRow = function(sRow) {
|
||||
var i, iRow, iRowAux, oAux, ooAux;
|
||||
if (this.oGrid.rows.length == 3) {
|
||||
@@ -368,7 +410,7 @@ var G_Grid = function(oForm, sGridName) {
|
||||
* Dynaform - by Nyeke <erik@colosa.com
|
||||
*/
|
||||
|
||||
deleteRowOnDybaform(this, iRow);
|
||||
deleteRowOnDynaform(this, iRow);
|
||||
|
||||
iRowAux = iRow + 1;
|
||||
while (iRowAux <= (this.oGrid.rows.length - 2)) {
|
||||
@@ -487,37 +529,12 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}
|
||||
|
||||
if (this.aFunctions.length > 0) {
|
||||
|
||||
for (i = 0; i < this.aFunctions.length; i++) {
|
||||
oAux = document.getElementById('form[' + this.sGridName + '][1][' + this.aFunctions[i].sFieldName + ']');
|
||||
if (oAux) {
|
||||
switch (this.aFunctions[i].sFunction) {
|
||||
case 'sum':
|
||||
this.sum(false, oAux);
|
||||
/*
|
||||
aaAux=oAux.name.split('][');
|
||||
sNamef=aaAux[2].replace(']', '');
|
||||
var sumaSol = 0;
|
||||
this.aElements.length;
|
||||
var j=1;k=0;
|
||||
for ( var i = 0; i < this.aElements.length; i++) {
|
||||
nnName= this.aElements[i].name.split('][');
|
||||
if (nnName[2] == sNamef && j <= (this.oGrid.rows.length-2)){
|
||||
ooAux=this.getElementByName(j, nnName[2]);
|
||||
|
||||
if(ooAux!=null){
|
||||
|
||||
sumaSol += parseFloat(G.cleanMask(ooAux.value() || 0, ooAux.mask).result.replace(/,/g, ''))
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
sumaSol = sumaSol.toFixed(2);
|
||||
oAux = document.getElementById('form[SYS_GRID_AGGREGATE_' + oGrid.sGridName + '_' + sNamef + ']');
|
||||
oAux.value = sumaSol;
|
||||
oAux = document.getElementById('form[SYS_GRID_AGGREGATE_' + oGrid.sGridName + '__' + sNamef + ']');
|
||||
oAux.innerHTML = sumaSol;//return;
|
||||
*/
|
||||
break;
|
||||
case 'avg':
|
||||
this.avg(false, oAux);
|
||||
@@ -526,6 +543,8 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}
|
||||
}
|
||||
}
|
||||
//Fires OnAddRow Event
|
||||
//FIXME: This feature does not work in IE
|
||||
if (this.ondeleterow) {
|
||||
this.ondeleterow();
|
||||
}
|
||||
@@ -533,6 +552,9 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}.extend(this)
|
||||
});
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.assignFunctions = function(aFields, sEvent, iRow) {
|
||||
iRow = iRow || 1;
|
||||
var i, j, oAux;
|
||||
@@ -566,10 +588,16 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.setFunctions = function(aFunctions) {
|
||||
this.aFunctions = aFunctions;
|
||||
this.assignFunctions(this.aFunctions, 'change');
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.sum = function(oEvent, oDOM) {
|
||||
oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement);
|
||||
var i, aAux, oAux, fTotal, sMask, nnName;
|
||||
@@ -584,7 +612,7 @@ var G_Grid = function(oForm, sGridName) {
|
||||
if (aAux[2] == nnName[2] && j <= (this.oGrid.rows.length-2)){
|
||||
oAux=this.getElementByName(j, nnName[2]);
|
||||
if(oAux!=null){
|
||||
fTotal += parseFloat(G.cleanMask(oAux.value() || 0, oAux.mask).result.replace(/,/g, ''))
|
||||
fTotal += parseFloat(G.cleanMask(oAux.value() || 0, oAux.mask).result.replace(/,/g, ''));
|
||||
}
|
||||
j++;
|
||||
}
|
||||
@@ -602,6 +630,8 @@ var G_Grid = function(oForm, sGridName) {
|
||||
// oAux.innerHTML = G.toMask(fTotal, sMask).result;
|
||||
oAux.innerHTML = fTotal;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
this.avg = function(oEvent, oDOM) {
|
||||
oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement);
|
||||
var i, aAux, oAux, fTotal, sMask;
|
||||
@@ -630,6 +660,9 @@ var G_Grid = function(oForm, sGridName) {
|
||||
oAux.innerHTML = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
this.assignFormulas = function(aFields, sEvent, iRow) {
|
||||
iRow = iRow || 1;
|
||||
var i, j, oAux;
|
||||
@@ -646,10 +679,14 @@ var G_Grid = function(oForm, sGridName) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
this.setFormulas = function(aFormulas) {
|
||||
this.aFormulas = aFormulas;
|
||||
this.assignFormulas(this.aFormulas, 'change');
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
this.evaluateFormula = function(oEvent, oDOM, oField) {
|
||||
oDOM = (oDOM ? oDOM : oEvent.target || window.event.srcElement);
|
||||
var aAux, sAux, i, oAux;
|
||||
@@ -919,7 +956,9 @@ var G_Grid = function(oForm, sGridName) {
|
||||
* [integer: row index]
|
||||
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@mail.com>
|
||||
*/
|
||||
function deleteRowOnDybaform(grid, sRow) {
|
||||
|
||||
|
||||
function deleteRowOnDynaform(grid, sRow) {
|
||||
var oRPC = new leimnud.module.rpc.xmlhttp( {
|
||||
url : '../gulliver/genericAjax',
|
||||
args : 'request=deleteGridRowOnDynaform&gridname=' + grid.sGridName + '&rowpos=' + sRow
|
||||
|
||||
@@ -38,6 +38,7 @@ class XmlForm_Field {
|
||||
var $group = 0;
|
||||
var $mode = '';
|
||||
var $defaultValue = NULL;
|
||||
var $gridFieldType = '';
|
||||
/*to change the presentation*/
|
||||
var $enableHtml = false;
|
||||
var $style = '';
|
||||
@@ -667,6 +668,52 @@ class XmlForm_Field {
|
||||
}
|
||||
return $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares NS Default Text
|
||||
* @author Enrique Ponce de Leon <enrique@colosa.com>
|
||||
* @param boolean optional (true = always show, false = show only if not empty)
|
||||
* @return string
|
||||
*/
|
||||
function NSDefaultValue($show = false){
|
||||
$idv = 'pm:defaultvalue="'.$this->defaultValue.'"';
|
||||
if ($show){
|
||||
return $idv;
|
||||
}else{
|
||||
return ($this->defaultValue != '')? $idv : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares NS Grid Type
|
||||
* @author Enrique Ponce de Leon <enrique@colosa.com>
|
||||
* @param boolean optional (true = always show, false = show only if not empty)
|
||||
* @return string
|
||||
*/
|
||||
function NSGridType($show = false){
|
||||
$igt = 'pm:gridtype="'.$this->gridFieldType.'"';
|
||||
if ($show){
|
||||
return $igt;
|
||||
}else{
|
||||
return ($this->gridFieldType != '')? $igt : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares NS Grid Type
|
||||
* @author Enrique Ponce de Leon <enrique@colosa.com>
|
||||
* @param boolean optional (true = always show, false = show only if not empty)
|
||||
* @return string
|
||||
*/
|
||||
function NSDependentFields($show = false){
|
||||
$idf = 'pm:dependent="'.(($this->dependentFields != '')? '1':'0').'"';
|
||||
if ($show){
|
||||
return $idf;
|
||||
}else{
|
||||
return ($this->dependentFields != '')? $idf : '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Class XmlForm_Field_Title
|
||||
@@ -788,14 +835,18 @@ class XmlForm_Field_SimpleText extends XmlForm_Field
|
||||
// also the fields rendered in a grid needs now have an attribute required set to 0 or 1
|
||||
// that it means not required or required respectively.
|
||||
$this->mode = $this->modeForGrid;
|
||||
if (isNewDynaform($owner)=='1'){
|
||||
$values = array();
|
||||
$values[] = $this->defaultValue;
|
||||
}
|
||||
foreach ( $values as $v ) {
|
||||
if ($this->mode === 'edit' && $owner->modeGrid != 'view') {
|
||||
if ($this->readOnly)
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '" readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '" readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().' '.$this->NSGridType().'/>';
|
||||
else
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '"style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '"style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().' '.$this->NSGridType().'/>';
|
||||
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '"style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '\' required="' . $isRequired . '"style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().' '.$this->NSGridType().'/>' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
$result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
@@ -901,6 +952,7 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
|
||||
} else {
|
||||
$isRequired = '0';
|
||||
}
|
||||
|
||||
// Note added by Gustavo Cruz
|
||||
// also the fields rendered in a grid needs now have an attribute required set to 0 or 1
|
||||
// that it means not required or required respectively.
|
||||
@@ -917,11 +969,11 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText
|
||||
$v =($v!='')?$v:$this->defaultValue;
|
||||
if ($this->mode === 'edit' && $owner->modeGrid != 'view') {
|
||||
if ($this->readOnly)
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" pm:defaultvalue="'.$this->defaultValue.'"/>';
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().'/>';
|
||||
else
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" pm:defaultvalue="'.$this->defaultValue.'"/>';
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().'/>';
|
||||
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '"/>' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
$result [] = '<input class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value="' . $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ) . '" required="' . $isRequired . '" style="display:none;' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().'/>' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
} else {
|
||||
$result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
}
|
||||
@@ -993,7 +1045,7 @@ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek
|
||||
function render($value = NULL, $owner = NULL)
|
||||
{
|
||||
|
||||
//echo $this->sqlConnection;
|
||||
|
||||
if (! $this->sqlConnection)
|
||||
$this->sqlConnection = 'workflow';
|
||||
|
||||
@@ -1289,6 +1341,8 @@ class XmlForm_Field_Textarea extends XmlForm_Field {
|
||||
var $wrap = 'OFF';
|
||||
var $hint = '';
|
||||
var $className;
|
||||
|
||||
|
||||
/**
|
||||
* Function render
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
@@ -1337,6 +1391,7 @@ class XmlForm_Field_Textarea extends XmlForm_Field {
|
||||
* @return string
|
||||
*/
|
||||
function renderGrid($values = NULL, $owner) {
|
||||
$this->gridFieldType = 'textarea';
|
||||
// Note added by Gustavo Cruz
|
||||
// set the variable isRequired if the needs to be validated
|
||||
if ($this->required){
|
||||
@@ -1344,6 +1399,12 @@ class XmlForm_Field_Textarea extends XmlForm_Field {
|
||||
} else {
|
||||
$isRequired = '0';
|
||||
}
|
||||
|
||||
if (isNewDynaform($owner)==1){
|
||||
echo 'Nuevo';
|
||||
$values = array();
|
||||
$values[] = $this->defaultValue;
|
||||
}
|
||||
// Note added by Gustavo Cruz
|
||||
// also the fields rendered in a grid needs now have an attribute required set to 0 or 1
|
||||
// that it means not required or required respectively.
|
||||
@@ -1353,11 +1414,11 @@ class XmlForm_Field_Textarea extends XmlForm_Field {
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
if ($this->mode === 'edit' && $owner->modeGrid != 'view') {
|
||||
|
||||
if (is_null($v)) $v = $this->defaultValue;
|
||||
if ($this->readOnly)
|
||||
$result [] = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '" readOnly="readOnly">'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
$result [] = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '" readOnly="readOnly" '.$this->NSDefaultValue().' '.$this->NSGridType().'>'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
else
|
||||
$result [] = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '">'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
$result [] = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '" '.$this->NSDefaultValue().' '.$this->NSGridType().'>'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
|
||||
|
||||
if (stristr ( $_SERVER ['HTTP_USER_AGENT'], 'iPhone' )) {
|
||||
@@ -1365,7 +1426,7 @@ class XmlForm_Field_Textarea extends XmlForm_Field {
|
||||
|
||||
$result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' );
|
||||
} else { //start add Alvaro
|
||||
$varaux = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '">'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
$varaux = '<textarea class="module_app_input___gray" id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" wrap="hard" rows="' . $this->rows . '"cols="'.$this->cols.'" required="' . $isRequired . '" '.$this->NSDefaultValue().' '.$this->NSGridType().'>'.$this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'</textarea>';
|
||||
$result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).'<div style="display:none;">'.$varaux.'</div>';
|
||||
//end add Alvaro
|
||||
}
|
||||
@@ -1398,6 +1459,7 @@ class XmlForm_Field_Currency extends XmlForm_Field_SimpleText {
|
||||
var $formula = '';
|
||||
var $function = '';
|
||||
var $hint;
|
||||
var $gridFieldType = 'currency';
|
||||
|
||||
/**
|
||||
* render the field in a dynaform
|
||||
@@ -1406,13 +1468,17 @@ class XmlForm_Field_Currency extends XmlForm_Field_SimpleText {
|
||||
* @return <String>
|
||||
*/
|
||||
function render( $value = NULL, $owner = NULL) {
|
||||
//$this->gridFieldType = 'currency';
|
||||
if (isNewDynaform($owner)==1){
|
||||
$value = $this->defaultValue;
|
||||
}
|
||||
$onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values );
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly)
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().' '.$this->NSGridType().'/>';
|
||||
else {
|
||||
|
||||
$html = '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
$html = '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '" '.$this->NSDefaultValue().' '.$this->NSGridType().'/>';
|
||||
|
||||
if($this->hint){
|
||||
$html .= '<a href="#" onmouseout="hideTooltip()" onmouseover="showTooltip(event, \''.$this->hint.'\');return false;">
|
||||
@@ -1464,11 +1530,10 @@ class XmlForm_Field_Percentage extends XmlForm_Field_SimpleText {
|
||||
var $formula = '';
|
||||
var $function = '';
|
||||
var $hint;
|
||||
|
||||
var $gridFieldType = 'percentage';
|
||||
|
||||
function render( $value = NULL, $owner = NULL) {
|
||||
$onkeypress = G::replaceDataField ( $this->onkeypress, $owner->values );
|
||||
|
||||
if ($this->mode === 'edit') {
|
||||
if ($this->readOnly)
|
||||
return '<input class="module_app_input___gray" id="form[' . $this->name . ']" name="form[' . $this->name . ']" type ="text" size="' . $this->size . '" maxlength="' . $this->maxLength . '" value=\'' . $this->htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>';
|
||||
@@ -1780,11 +1845,18 @@ class XmlForm_Field_YesNo extends XmlForm_Field
|
||||
* @return <array>
|
||||
*/
|
||||
function renderGrid($values = array(), $owner) {
|
||||
$this->gridFieldType = 'yesno';
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
|
||||
if (isNewDynaform($owner)==1){
|
||||
$values = array();
|
||||
$values[] = $this->defaultValue;
|
||||
}
|
||||
|
||||
$this->mode = $this->modeForGrid;
|
||||
foreach ( $values as $v ) {
|
||||
$html = (($this->mode == 'view' || $owner->modeGrid == 'view')? ($v === '0' ? 'NO' : 'YES') : '') . '<select id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"' . (($this->mode == 'view' || $owner->modeGrid == 'view')? ' style="display:none;"' : '') . '>';
|
||||
$html = (($this->mode == 'view' || $owner->modeGrid == 'view')? ($v === '0' ? 'NO' : 'YES') : '') . '<select id="form[' . $owner->name . '][' . $r . '][' . $this->name . ']" name="form[' . $owner->name . '][' . $r . '][' . $this->name . ']"' . (($this->mode == 'view' || $owner->modeGrid == 'view')? ' style="display:none;"' : '') . ' '.$this->NSDefaultValue().' '.$this->NSGridType().'>';
|
||||
$html .= '<option value="' . '0' . '"' . ($v === '0' ? ' selected' : '') . '>' . 'NO' . '</input>';
|
||||
$html .= '<option value="' . '1' . '"' . ($v === '1' ? ' selected' : '') . '>' . 'YES' . '</input>';
|
||||
$html .= '</select>';
|
||||
@@ -1923,7 +1995,6 @@ class XmlForm_Field_Dropdownpt extends XmlForm_Field {
|
||||
function render($value = NULL, $owner = NULL) {
|
||||
$this->value = $value;
|
||||
|
||||
//G::pr($this->value); die;
|
||||
$id = $this->value->id;
|
||||
$value = isset($this->value->value)? $this->value->value: '';
|
||||
$items = $this->value->items;
|
||||
@@ -2076,6 +2147,7 @@ class XmlForm_Field_Checkbox extends XmlForm_Field
|
||||
*/
|
||||
function renderGrid($values = array(), $owner)
|
||||
{
|
||||
$this->gridFieldType = 'checkbox';
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
foreach ( $values as $v ) {
|
||||
@@ -2087,7 +2159,7 @@ class XmlForm_Field_Checkbox extends XmlForm_Field
|
||||
$disabled = '';
|
||||
}
|
||||
//$disabled = (($this->value == 'view') ? 'disabled="disabled"' : '');
|
||||
$html = $res = "<input id='form[" . $owner->name . "][" . $r . "][" . $this->name . "]' value='{$this->value}' name='form[" . $owner->name . "][" . $r . "][" . $this->name . "]' type='checkbox' $checked $disabled readonly = '{$this->readOnly}'/>";
|
||||
$html = $res = "<input id='form[" . $owner->name . "][" . $r . "][" . $this->name . "]' value='{$this->value}' name='form[" . $owner->name . "][" . $r . "][" . $this->name . "]' type='checkbox' $checked $disabled readonly = '{$this->readOnly}' ".$this->NSDefaultValue()." ".$this->NSGridType()."/>";
|
||||
$result [] = $html;
|
||||
$r ++;
|
||||
}
|
||||
@@ -2297,6 +2369,7 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
|
||||
return isset($value) && ( array_key_exists( $value , $this->options ) );*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function render
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
@@ -2327,6 +2400,15 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
|
||||
$isRequired = '0';
|
||||
}
|
||||
//end
|
||||
|
||||
if (isNewDynaform($owner)==1){
|
||||
if ($this->dependentFields != ''){
|
||||
$value = "";
|
||||
}else{
|
||||
$value = $this->defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
// added by Gustavo Cruz
|
||||
if($this->readonly == true || $this->modeGridDrop === 'view'){
|
||||
$readOnlyField = "disabled";
|
||||
@@ -2334,7 +2416,7 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
|
||||
// added end
|
||||
if (! $onlyValue) {
|
||||
if ($this->mode === 'edit') {
|
||||
$html = '<select '.$readOnlyField.' pm:required="'.$isRequired.'" class="module_app_input___gray" id="form' . $rowId . '[' . $this->name . ']" name="form' . $rowId . '[' . $this->name . ']" ' . (($this->style) ? 'style="' . $this->style . '"' : '') . '>';
|
||||
$html = '<select '.$readOnlyField.' pm:required="'.$isRequired.'" class="module_app_input___gray" id="form' . $rowId . '[' . $this->name . ']" name="form' . $rowId . '[' . $this->name . ']" ' . (($this->style) ? 'style="' . $this->style . '"' : '') . ' '.$this->NSDefaultValue().' '.$this->NSGridType().' '.$this->NSDependentFields(true).'>';
|
||||
} elseif ($this->mode === 'view') {
|
||||
$html = $this->htmlentities ( isset ( $this->options [$value] ) ? $this->options [$value] : '', ENT_COMPAT, 'utf-8' );
|
||||
$html .= '<select '.$readOnlyField.' pm:required="'.$isRequired.'" class="module_app_input___gray" id="form' . $rowId . '[' . $this->name . ']" name="form' . $rowId . '[' . $this->name . ']" style="display:none" ' . (($this->style) ? 'style="' . $this->style . '"' : '') . '>';
|
||||
@@ -2397,6 +2479,8 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
|
||||
*/
|
||||
function renderGrid($values = array(), $owner = NULL, $onlyValue = false, $therow = -1)
|
||||
{
|
||||
|
||||
$this->gridFieldType = 'dropdown';
|
||||
$result = array ();
|
||||
$r = 1;
|
||||
if(! isset($owner->modeGrid)) $owner->modeGrid = '';
|
||||
@@ -2818,6 +2902,7 @@ class XmlForm_Field_Grid extends XmlForm_Field
|
||||
}
|
||||
}
|
||||
$this->values = $values;
|
||||
|
||||
$this->NewLabel = G::LoadTranslation('ID_NEW');
|
||||
$this->DeleteLabel = G::LoadTranslation('ID_DELETE');
|
||||
|
||||
@@ -3741,8 +3826,6 @@ class XmlForm_Field_Xmlform extends XmlForm_Field {
|
||||
$this->xmlform->parseFile ( $this->xmlfile . '.xml', $language, false );
|
||||
$this->fields = $this->xmlform->fields;
|
||||
$this->scriptURL = $this->xmlform->scriptURL;
|
||||
//echo "content:" . $this->scriptURL;
|
||||
//die;
|
||||
$this->id = $this->xmlform->id;
|
||||
unset ( $this->xmlform );
|
||||
}
|
||||
@@ -3766,8 +3849,6 @@ class XmlForm_Field_Xmlform extends XmlForm_Field {
|
||||
$tpl->template = $tpl->printTemplate ( $this );
|
||||
//In the header
|
||||
|
||||
// echo "content:" . $this->scriptURL;
|
||||
// die;
|
||||
$oHeadPublisher = & headPublisher::getSingleton ();
|
||||
$oHeadPublisher->addScriptFile ( $this->scriptURL );
|
||||
$oHeadPublisher->addScriptCode ( $tpl->printJavaScript ( $this ) );
|
||||
@@ -3915,7 +3996,7 @@ class XmlForm
|
||||
}
|
||||
|
||||
}
|
||||
//var_dump($this->requiredFields);
|
||||
|
||||
$oJSON = new Services_JSON ( );
|
||||
$this->objectRequiredFields = str_replace('"', "%27", str_replace("'", "%39", $oJSON->encode ( $this->requiredFields )) );
|
||||
|
||||
@@ -3932,6 +4013,7 @@ class XmlForm
|
||||
/* fwrite ($f, '$this = unserialize( \'' .
|
||||
addcslashes( serialize ( $this ), '\\\'' ) . '\' );' . "\n" );*/
|
||||
foreach ( $this as $key => $value ) {
|
||||
//cho $key .'<br/>';
|
||||
switch ($key) {
|
||||
case 'home' :
|
||||
case 'fileName' :
|
||||
@@ -4167,7 +4249,6 @@ class xmlformTemplate extends Smarty
|
||||
*/
|
||||
function getFields(&$form, $therow = -1)
|
||||
{
|
||||
|
||||
$result = array ();
|
||||
foreach ( $form->fields as $k => $v ) {
|
||||
if ($form->mode != '') { #@ last modification: erik
|
||||
@@ -4188,6 +4269,7 @@ class xmlformTemplate extends Smarty
|
||||
}
|
||||
} else {
|
||||
if (isset ( $form->owner )) {
|
||||
|
||||
if (count ( $value ) < count ( $form->owner->values [$form->name] )) {
|
||||
$i = count ( $value );
|
||||
$j = count ( $form->owner->values [$form->name] );
|
||||
@@ -4195,7 +4277,13 @@ class xmlformTemplate extends Smarty
|
||||
$value [] = '';
|
||||
}
|
||||
}
|
||||
$aObj = $form->owner;
|
||||
}else{
|
||||
$aObj = $form;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($v->type == 'grid') {
|
||||
$result ['form'] [$k] = $form->fields [$k]->renderGrid ( $value, $form, $therow );
|
||||
} else {
|
||||
@@ -4358,3 +4446,14 @@ class XmlForm_Field_Image extends XmlForm_Field
|
||||
$value = date($tmp);
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns if the current dynaform is new or reopened
|
||||
* @author Enrique Ponce de Leon <enrique@colosa.com>
|
||||
* @package gulliver.system
|
||||
*/
|
||||
function isNewDynaform($owner){
|
||||
$sw = ($_SESSION['NEW_CASE']=='New')? '1' : '0';
|
||||
return $sw;
|
||||
}
|
||||
|
||||
@@ -216,6 +216,9 @@ function startCase() {
|
||||
if (isset ( $_SESSION ['TASK'] )) unset ( $_SESSION ['TASK'] );
|
||||
if (isset ( $_SESSION ['INDEX'] )) unset ( $_SESSION ['INDEX'] );
|
||||
if (isset ( $_SESSION ['STEP_POSITION'] )) unset ( $_SESSION ['STEP_POSITION'] );
|
||||
if (isset ( $_SESSION ['START_NEW_CASE'] )) unset ( $_SESSION ['START_NEW_CASE'] );
|
||||
|
||||
//echo 'Start new case<br />';
|
||||
|
||||
/* Process */
|
||||
try {
|
||||
@@ -224,6 +227,7 @@ function startCase() {
|
||||
lookinginforContentProcess($_POST['processId']);
|
||||
|
||||
$aData = $oCase->startCase ( $_REQUEST ['taskId'], $_SESSION ['USER_LOGGED'] );
|
||||
|
||||
$_SESSION ['APPLICATION'] = $aData ['APPLICATION'];
|
||||
$_SESSION ['INDEX'] = $aData ['INDEX'];
|
||||
$_SESSION ['PROCESS'] = $aData ['PROCESS'];
|
||||
@@ -240,6 +244,8 @@ function startCase() {
|
||||
$_SESSION ['BREAKSTEP'] ['NEXT_STEP'] = $aNextStep;
|
||||
$aData ['openCase'] = $aNextStep;
|
||||
|
||||
$aData ['NewDynaform'] = true; //Sets New Dynaform value
|
||||
|
||||
$aData ['status'] = 'success';
|
||||
print (G::json_encode ( $aData )) ;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ if( $RBAC->userCanAccess('PM_CASES') != 1 ) {
|
||||
require_once 'classes/model/AppDelay.php';
|
||||
G::LoadClass('case');
|
||||
|
||||
//Clean NEW_CASE session variable if case isn't new.
|
||||
if ($_GET['new']!='yes') $_SESSION['NEW_CASE'] = '';
|
||||
|
||||
$oCase = new Cases();
|
||||
|
||||
//cleaning the case session data
|
||||
|
||||
@@ -46,6 +46,15 @@
|
||||
if( isset($_GET['APP_UID']) && isset($_GET['DEL_INDEX'])) {
|
||||
$case = $oCase->loadCase($_GET['APP_UID'], $_GET['DEL_INDEX']);
|
||||
$appNum = $case['APP_TITLE'];
|
||||
|
||||
//Sets NEW_CASE session variable when we're starting a new case
|
||||
if (isset($_GET['new'])){
|
||||
if ($_GET['new']=='yes'){
|
||||
$_SESSION['NEW_CASE'] = 'New';
|
||||
}else{
|
||||
$_SESSION['NEW_CASE'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_GET['to_revise'])){
|
||||
|
||||
@@ -376,7 +376,11 @@ function openCaseA(n){
|
||||
var res = Ext.util.JSON.decode(response.responseText);
|
||||
|
||||
if (res.openCase) {
|
||||
if (res.NewDynaform){
|
||||
window.location = res.openCase.PAGE + '&new=yes';
|
||||
}else{
|
||||
window.location = res.openCase.PAGE;
|
||||
}
|
||||
} else {
|
||||
Ext.Msg.show({
|
||||
title : TRANSLATIONS.ID_ERROR_CREATING_NEW_CASE, // 'Error creating a new Case',
|
||||
|
||||
@@ -65,10 +65,6 @@
|
||||
|
||||
<JS type="javascript">
|
||||
<![CDATA[
|
||||
var changeToUpper = function() {
|
||||
this.value = this.value.toUpperCase();
|
||||
};
|
||||
|
||||
var onChangeType = function(iRow, bEmpty) {
|
||||
var iRow = iRow | this.name.split('][')[1];
|
||||
var oAux;
|
||||
@@ -76,98 +72,28 @@ var onChangeType = function(iRow, bEmpty) {
|
||||
case 'VARCHAR':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.readOnly = '';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
if (bEmpty) {
|
||||
oAux.checked = false;
|
||||
oAux.disabled = false;
|
||||
}
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
if (!getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY').checked) {
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';
|
||||
}*/
|
||||
break;
|
||||
case 'TEXT':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.value = '';
|
||||
oAux.readOnly = 'readOnly';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
if (bEmpty) {
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
}
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
case 'DATE':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.value = '';
|
||||
oAux.readOnly = 'readOnly';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
case 'INT':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.readOnly = '';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
if (bEmpty) {
|
||||
oAux.checked = false;
|
||||
oAux.disabled = false;
|
||||
}
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
if (bEmpty) {
|
||||
oAux.checked = false;
|
||||
oAux.disabled = false;
|
||||
}
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
if (bEmpty) {
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';
|
||||
}*/
|
||||
break;
|
||||
case 'FLOAT':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.readOnly = '';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
var onClickForeignKey = function(iRow) {
|
||||
var iRow = iRow | this.name.split('][')[1];
|
||||
var oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
if (getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY').checked) {
|
||||
oAux.disabled = false;
|
||||
oAux.value = '';
|
||||
}
|
||||
else {
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
var verifyData = function(oForm) {
|
||||
if (oForm.onsubmit()) {
|
||||
var bContinue = true;
|
||||
@@ -258,14 +184,6 @@ var verifyData = function(oForm) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*if (bContinue) {
|
||||
if (getGridField('FIELDS', i, 'FLD_FOREIGN_KEY').checked) {
|
||||
if (getGridField('FIELDS', i, 'FLD_FOREIGN_KEY_TABLE').value == '') {
|
||||
bContinue = false;
|
||||
iMessage = 3;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// Check duplicate fields
|
||||
if(bContinue) {
|
||||
if(!(getGridField('FIELDS', i, 'FLD_NAME').value in fieldsTmp)) {
|
||||
@@ -348,7 +266,6 @@ var verifyData = function(oForm) {
|
||||
|
||||
var changeValues = function(iRow, sType) {
|
||||
iRow = parseInt(iRow);
|
||||
|
||||
switch (sType) {
|
||||
case 'UP':
|
||||
if (iRow == 1) {
|
||||
@@ -403,40 +320,30 @@ var changeValues = function(iRow, sType) {
|
||||
onChangeType(iOtherRow, false);
|
||||
};
|
||||
|
||||
var dynaformOnload = function() {
|
||||
function LoadPMTable() {
|
||||
//Adding events for the grid fields
|
||||
var iRows = Number_Rows_Grid('FIELDS', 'FLD_UID');
|
||||
var oAux;
|
||||
for (var i = 1; i <= iRows; i++) {
|
||||
oAux = getGridField('FIELDS', i, 'FLD_NAME');
|
||||
leimnud.event.add(oAux, 'change', {method:changeToUpper,instance:oAux,event:true});
|
||||
oAux = getGridField('FIELDS', i, 'FLD_TYPE');
|
||||
leimnud.event.add(oAux, 'change', {method:onChangeType,instance:oAux,event:true});
|
||||
//oAux = getGridField('FIELDS', i, 'FLD_FOREIGN_KEY');
|
||||
//leimnud.event.add(oAux, 'click', {method:onClickForeignKey,instance:oAux,event:true});
|
||||
onChangeType(i, false);
|
||||
//onClickForeignKey(i, false);
|
||||
}
|
||||
getObject('FIELDS').onaddrow = function(iRow) {
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_NAME');
|
||||
leimnud.event.add(oAux, 'change', {method:changeToUpper,instance:oAux,event:true});
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_TYPE');
|
||||
leimnud.event.add(oAux, 'change', {method:onChangeType,instance:oAux,event:true});
|
||||
//oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
//leimnud.event.add(oAux, 'click', {method:onClickForeignKey,instance:oAux,event:true});
|
||||
onChangeType(iRow, true);
|
||||
//onClickForeignKey(iRow, true);
|
||||
|
||||
document.getElementById('FIELDS').rows[iRow].getElementsByTagName('td')[10].innerHTML = document.getElementById('FIELDS').rows[1].getElementsByTagName('td')[10].innerHTML.replace('[1]', '[' + iRow + ']');
|
||||
document.getElementById('FIELDS').rows[iRow].getElementsByTagName('td')[11].innerHTML = document.getElementById('FIELDS').rows[1].getElementsByTagName('td')[11].innerHTML.replace('[1]', '[' + iRow + ']');
|
||||
|
||||
};
|
||||
//
|
||||
};
|
||||
|
||||
function cancel(){
|
||||
window.location = 'additionalTablesList';
|
||||
}
|
||||
|
||||
dynaformOnload = LoadPMTable;
|
||||
|
||||
]]>
|
||||
|
||||
</JS>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<FLD_UID type="text" size="1" style="display:none;"/>
|
||||
|
||||
<FLD_NAME type="text" size="15" maxlength="64" validate="Field">
|
||||
<FLD_NAME type="text" size="15" maxlength="64" validate="Field" strto="UPPER">
|
||||
<en>Field Name</en>
|
||||
</FLD_NAME>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<FLD_UID type="text" size="1" style="display:none;"/>
|
||||
|
||||
<FLD_NAME type="text" size="15" maxlength="64" validate="Field">
|
||||
<FLD_NAME type="text" size="15" maxlength="64" validate="Field" strto="UPPER">
|
||||
<en>Field Name</en>
|
||||
</FLD_NAME>
|
||||
|
||||
|
||||
@@ -69,10 +69,6 @@
|
||||
|
||||
<JS type="javascript">
|
||||
<![CDATA[
|
||||
var changeToUpper = function() {
|
||||
this.value = this.value.toUpperCase();
|
||||
};
|
||||
|
||||
var onChangeType = function(iRow) {
|
||||
var iRow = iRow | this.name.split('][')[1];
|
||||
var oAux;
|
||||
@@ -80,72 +76,24 @@ var onChangeType = function(iRow) {
|
||||
case 'VARCHAR':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.readOnly = '';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = false;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
case 'TEXT':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.value = '';
|
||||
oAux.readOnly = 'readOnly';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
case 'DATE':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.value = '';
|
||||
oAux.readOnly = 'readOnly';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
case 'INT':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.readOnly = '';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = false;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = false;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
case 'FLOAT':
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_SIZE');
|
||||
oAux.readOnly = '';
|
||||
/*oAux = getGridField('FIELDS', iRow, 'FLD_AUTO_INCREMENT');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
oAux.checked = false;
|
||||
oAux.disabled = true;
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY_TABLE');
|
||||
oAux.disabled = true;
|
||||
oAux.value = '';*/
|
||||
break;
|
||||
}
|
||||
};
|
||||
@@ -162,7 +110,7 @@ var onClickForeignKey = function(iRow) {
|
||||
oAux.value = '';
|
||||
}
|
||||
};
|
||||
var aReservedWords = new Array('ADD','ALL','ALTER','ANALYZE','AND','AS','ASC','ASENSITIVE','BEFORE',
|
||||
var aReservedWords = new Array('ADD','ALL','ALTER','ANALYZE','AND','AS','ASC','ASENSITIVE','BEFORE',
|
||||
'BETWEEN','BIGINT','BINARY','BLOB','BOTH','BY','CALL','CASCADE','CASE',
|
||||
'CHANGE','CHAR','CHARACTER','CHECK','COLLATE','COLUMN','CONDITION',
|
||||
'CONSTRAINT','CONTINUE','CONVERT','CREATE','CROSS','CURRENT_DATE',
|
||||
@@ -203,7 +151,6 @@ var verifyData = function(oForm) {
|
||||
var iRows = Number_Rows_Grid('FIELDS', 'FLD_UID');
|
||||
var fieldsTmp = [];
|
||||
var words = '';
|
||||
|
||||
for (var i = 1; i <= iRows; i++) {
|
||||
for(var j = 0; j < aReservedWords.length; j++ ) {
|
||||
if(getGridField('FIELDS', i, 'FLD_NAME').value == aReservedWords[j]) {
|
||||
@@ -253,14 +200,6 @@ var verifyData = function(oForm) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*if (bContinue) {
|
||||
if (getGridField('FIELDS', i, 'FLD_FOREIGN_KEY').checked) {
|
||||
if (getGridField('FIELDS', i, 'FLD_FOREIGN_KEY_TABLE').value == '') {
|
||||
bContinue = false;
|
||||
iMessage = 3;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// Check duplicate fields
|
||||
if(bContinue) {
|
||||
if(!(getGridField('FIELDS', i, 'FLD_NAME').value.toUpperCase() in fieldsTmp)) {
|
||||
@@ -344,8 +283,7 @@ var verifyData = function(oForm) {
|
||||
}
|
||||
};
|
||||
|
||||
leimnud.event.add(window, 'load', function() {
|
||||
//Adding ajax validations
|
||||
function LoadPMTable(){
|
||||
leimnud.event.add(getField('ADD_TAB_NAME'), 'change', function() {
|
||||
getField('ADD_TAB_NAME').value = getField('ADD_TAB_NAME').value.toUpperCase();
|
||||
var sTableNameOld = getField('ADD_TAB_NAME_OLD').value;
|
||||
@@ -373,7 +311,7 @@ leimnud.event.add(window, 'load', function() {
|
||||
oSaveButton.disabled = false;
|
||||
}
|
||||
}
|
||||
// if (getField('ADD_TAB_CLASS_NAME').value == '') {
|
||||
|
||||
var aAux = getField('ADD_TAB_NAME').value.split('_');
|
||||
var sAux = '';
|
||||
var i;
|
||||
@@ -387,7 +325,7 @@ leimnud.event.add(window, 'load', function() {
|
||||
sAux = '_' + sAux;;
|
||||
}
|
||||
getField('ADD_TAB_CLASS_NAME').value = sAux;
|
||||
// }
|
||||
|
||||
|
||||
// Validate ilegal character
|
||||
var sTbl_name = getField('ADD_TAB_NAME').value.toUpperCase();
|
||||
@@ -412,6 +350,7 @@ leimnud.event.add(window, 'load', function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
leimnud.event.add(getField('ADD_TAB_CLASS_NAME'), 'change', function() {
|
||||
var sClassNameOld = getField('ADD_TAB_CLASS_NAME_OLD').value;
|
||||
var oSaveButton = getField('btnSave');
|
||||
@@ -434,49 +373,31 @@ leimnud.event.add(window, 'load', function() {
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if (sClassNameOld != '') {
|
||||
oSaveButton.disabled = false;
|
||||
//}
|
||||
}
|
||||
});
|
||||
|
||||
//Adding events for the grid fields
|
||||
var iRows = Number_Rows_Grid('FIELDS', 'FLD_UID');
|
||||
var oAux;
|
||||
for (var i = 1; i <= iRows; i++) {
|
||||
oAux = getGridField('FIELDS', i, 'FLD_NAME');
|
||||
leimnud.event.add(oAux, 'change', {method:changeToUpper,instance:oAux,event:true});
|
||||
oAux = getGridField('FIELDS', i, 'FLD_TYPE');
|
||||
leimnud.event.add(oAux, 'change', {method:onChangeType,instance:oAux,event:true});
|
||||
//oAux = getGridField('FIELDS', i, 'FLD_FOREIGN_KEY');
|
||||
//leimnud.event.add(oAux, 'click', {method:onClickForeignKey,instance:oAux,event:true});
|
||||
onChangeType(i);
|
||||
//onClickForeignKey(i);
|
||||
}
|
||||
if (getObject('FIELDS')){
|
||||
getObject('FIELDS').onaddrow = function(iRow) {
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_NAME');
|
||||
leimnud.event.add(oAux, 'change', {method:changeToUpper,instance:oAux,event:true});
|
||||
oAux = getGridField('FIELDS', iRow, 'FLD_TYPE');
|
||||
leimnud.event.add(oAux, 'change', {method:onChangeType,instance:oAux,event:true});
|
||||
//oAux = getGridField('FIELDS', iRow, 'FLD_FOREIGN_KEY');
|
||||
//leimnud.event.add(oAux, 'click', {method:onClickForeignKey,instance:oAux,event:true});
|
||||
onChangeType(iRow);
|
||||
//onClickForeignKey(iRow);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
leimnud.event.add(getField('ADD_TAB_CLASS_NAME'), 'click', function() {
|
||||
//alert('sss');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
function cancel(){
|
||||
window.location = 'additionalTablesList';
|
||||
}
|
||||
|
||||
dynaformOnload = LoadPMTable;
|
||||
|
||||
]]>
|
||||
</JS>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user