diff --git a/gulliver/js/grid/core/grid.js b/gulliver/js/grid/core/grid.js
index 92883b980..01ae8ccd6 100644
--- a/gulliver/js/grid/core/grid.js
+++ b/gulliver/js/grid/core/grid.js
@@ -1,80 +1,105 @@
-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;
for (i = 0; i < this.aFields.length; i++) {
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 + ']['
- + this.aFields[i].sFieldName));
- this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
- if(this.aFields[i].oProperties.strTo) {
- this.aElements[this.aElements.length - 1].strTo = this.aFields[i].oProperties.strTo;
+ 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 + ']['
+ + this.aFields[i].sFieldName));
+ this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
+ if(this.aFields[i].oProperties.strTo) {
+ this.aElements[this.aElements.length - 1].strTo = this.aFields[i].oProperties.strTo;
+ }
+ if (aFields[i].oProperties) {
+ this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.mask;
+ }
+ j++;
}
- if (aFields[i].oProperties) {
- this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.mask;
+ break;
+ case 'currency':
+ while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
+ this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
+ + this.aFields[i].sFieldName));
+ if (aFields[i].oProperties) {
+ this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.mask;
+ }
+ j++;
}
- j++;
- }
- break;
- case 'currency':
- while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
- this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
- + this.aFields[i].sFieldName));
- if (aFields[i].oProperties) {
- this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.mask;
+ break;
+ case 'percentage':
+ while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
+ this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j
+ + '][' + this.aFields[i].sFieldName));
+ if (aFields[i].oProperties) {
+ this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.mask;
+ }
+ j++;
}
- j++;
- }
- break;
- case 'percentage':
- while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
- this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j
- + '][' + this.aFields[i].sFieldName));
- if (aFields[i].oProperties) {
- this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.mask;
+ break;
+ case 'dropdown':
+ while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
+ this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
+ + this.aFields[i].sFieldName));
+ if (aFields[i].oProperties) {
+ this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.sMask;
+ }
+ j++;
}
- j++;
- }
- break;
- case 'dropdown':
- while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
- this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
- + this.aFields[i].sFieldName));
- if (aFields[i].oProperties) {
- this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.sMask;
- }
- j++;
- }
- break;
+ break;
}
}
// 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,23 +108,28 @@ 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;
for (i = 0; i < this.aFields.length; i++) {
-
+
j += k;
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) {
@@ -125,228 +161,234 @@ var G_Grid = function(oForm, sGridName) {
return 'Object not found!';
}
};
-
+
+ ////////////////////////////////////////////////////////////////////////
+
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', '');
+ aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('input');
+ 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(""), false);
- var aux = oNewRow.getElementsByTagName('td')[i].innerHTML;
+ attributes = elementAttributesNS(aObjects[0], 'pm');
+ if (attributes.defaultvalue != '' && typeof attributes.defaultvalue != 'undefined'){
+ defaultValue = attributes.defaultvalue;
+ }else{
+ defaultValue = '';
}
-
- 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 (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
- 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]);
- 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) + '\]') + ';');
- }
-
- 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);
- 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) + '\]') + ';');
+ switch(aObjects[0].type){
+ case 'text': //TEXTBOX, CURRENCY, PERCENTAGE, DATEPICKER
+ tags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
+ 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]);
+ //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 + '\]') + ';');
+ }
+ //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);
}
- }
+ aObjects[0].value = defaultValue;
+ break;
+ case 'checkbox': //CHECKBOX
+ aObjects[0].checked = false;
+ aObjects[0].value = defaultValue;
+ break;
+ case 'hidden': //HIDDEN
+ aObjects[0].value = defaultValue;
+ break;
}
}
-
- 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) + '\]') + ';');
- }
- }
- }
- }
- break;
- case 'select':
- aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('select');
- if (aObjects) {
- 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++) {
- 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 = null;
+ break;
+ case 'textarea': //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 = '';
+ 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 'a':
+ case 'select': //DROPDOWN
+ aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('select');
+ 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);
+ 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].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);
+ }
+ }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
+ }
+ }
+ aObjects = null;
+ break;
+ case 'a': //LINKS
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 = '';
+ if (aObjects){
+ newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
+ aObjects[0].id = newID;
+ aObjects[0].name = newID;
}
+ aObjects = null;
break;
-
- default:
- oNewRow.getElementsByTagName('td')[i].innerHTML = ' ';
- break;
+ }
+ break;
+ }
+ }
+
+ if (this.aFields.length > 0) {
+ this.setFields(this.aFields, currentRow);
+ }
+ if (this.aFunctions.length > 0) {
+ this.assignFunctions(this.aFunctions, 'change', currentRow);
+ }
+ if (this.aFormulas.length > 0) {
+ 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;
}
- aObjects = null;
}
}
}
- if (this.aFields.length > 0) {
- this.setFields(this.aFields, this.oGrid.rows.length - 2);
- }
- if (this.aFunctions.length > 0) {
- this.assignFunctions(this.aFunctions, 'change', this.oGrid.rows.length - 2);
- }
- if (this.aFormulas.length > 0) {
- this.assignFormulas(this.aFormulas, 'change', this.oGrid.rows.length - 2);
- }
+ //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) {
@@ -358,92 +400,92 @@ var G_Grid = function(oForm, sGridName) {
new leimnud.module.app.confirm().make( {
label : G_STRINGS.ID_MSG_DELETE_GRID_ITEM,
action : function() {
- //this.aElements = [];
+ //this.aElements = [];
sRow = sRow.replace('[', '');
sRow = sRow.replace(']', '');
iRow = Number(sRow);
-
+
/*
* delete the respective session row grid variables from
* Dynaform - by Nyeke 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) + '\]') + ';');
+ case ' 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 = oCell1.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) + '\]') + ';');
+ }
+ }
+ }
}
- }
-
- break;
- case '= 0; j--) { aObjects1[0].options[j] =
- * null; }
- */
- aObjects1[0].options.length = 0;
- for ( var j = 0; j < aObjects2[0].options.length; j++) {
- var optn = $dce("OPTION");
- optn.text = aObjects2[0].options[j].text;
- optn.value = aObjects2[0].options[j].value;
- aObjects1[0].options[j] = optn;
- }
- aObjects1[0].value = vValue;
- }
- break;
- case '= 0; j--) { aObjects1[0].options[j] =
+ * null; }
+ */
+ aObjects1[0].options.length = 0;
+ for ( var j = 0; j < aObjects2[0].options.length; j++) {
+ var optn = $dce("OPTION");
+ optn.text = aObjects2[0].options[j].text;
+ optn.value = aObjects2[0].options[j].value;
+ aObjects1[0].options[j] = optn;
+ }
+ aObjects1[0].value = vValue;
+ }
+ break;
+ case ' 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);
- break;
+ 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.ondeleterow) {
this.ondeleterow();
}
-
+
}.extend(this)
});
};
+
+ ///////////////////////////////////////////////////////////////////////////////////
+
this.assignFunctions = function(aFields, sEvent, iRow) {
iRow = iRow || 1;
var i, j, oAux;
@@ -540,36 +562,42 @@ var G_Grid = function(oForm, sGridName) {
j = iRow;
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + aFields[i].sFieldName + ']')) {
switch (aFields[i].sFunction) {
- case 'sum':
- leimnud.event.add(oAux, sEvent, {
- method : this.sum,
- instance : this,
- event : true
- });
- break;
- case 'avg':
- leimnud.event.add(oAux, sEvent, {
- method : this.avg,
- instance : this,
- event : true
- });
- break;
- default:
- leimnud.event.add(oAux, sEvent, {
- method : aFields[i].sFunction,
- instance : this,
- event : true
- });
+ case 'sum':
+ leimnud.event.add(oAux, sEvent, {
+ method : this.sum,
+ instance : this,
+ event : true
+ });
+ break;
+ case 'avg':
+ leimnud.event.add(oAux, sEvent, {
+ method : this.avg,
+ instance : this,
+ event : true
+ });
+ break;
+ default:
+ leimnud.event.add(oAux, sEvent, {
+ method : aFields[i].sFunction,
+ instance : this,
+ event : true
+ });
break;
}
j++;
}
}
};
+
+ ////////////////////////////////////////////////////////////////////////////////
+
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;
@@ -577,14 +605,14 @@ var G_Grid = function(oForm, sGridName) {
i = 1;
fTotal = 0;
aAux[2] = aAux[2].replace(']', '');
-
+
var j=1;
for ( var k = 0; k < this.aElements.length; k++) {
nnName= this.aElements[k].name.split('][');
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;
@@ -677,9 +714,9 @@ var G_Grid = function(oForm, sGridName) {
if (oContinue) {
//we're selecting the mask to put in the field with the formula
for (i = 0; i < this.aFields.length; i++) {
- if(oField.sFieldName==this.aFields[i].sFieldName) {
- maskformula =this.aFields[i].oProperties.mask;
- }
+ if(oField.sFieldName==this.aFields[i].sFieldName) {
+ maskformula =this.aFields[i].oProperties.mask;
+ }
}
if(maskformula!=''){
maskDecimal=maskformula.split(";");
@@ -690,7 +727,7 @@ var G_Grid = function(oForm, sGridName) {
}
maskToPut=maskDecimal[1].length;
}else{
- maskToPut=0;
+ maskToPut=0;
}
eval("document.getElementById('" + aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + "]').value = (" + sAux + ').toFixed('+maskToPut+');');
//eval("document.getElementById('" + aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + "]').value = (" + sAux + ').toFixed(2);');
@@ -700,12 +737,12 @@ var G_Grid = function(oForm, sGridName) {
if (oAux) {
if (oAux.name == aAux[0] + '][' + aAux[1] + '][' + oField.sFieldName + ']') {
switch (this.aFunctions[i].sFunction) {
- case 'sum':
- this.sum(false, oAux);
- break;
- case 'avg':
- this.avg(false, oAux);
- break;
+ case 'sum':
+ this.sum(false, oAux);
+ break;
+ case 'avg':
+ this.avg(false, oAux);
+ break;
}
if (oAux.fireEvent) {
oAux.fireEvent('onchange');
@@ -726,147 +763,147 @@ var G_Grid = function(oForm, sGridName) {
};
/*add*/
- this.deleteGridRownomsg = function(sRow) {
+ this.deleteGridRownomsg = function(sRow) {
var i, iRow, iRowAux, oAux, ooAux;
-
-
- //action : function() {
- //this.aElements = [];
- sRow = sRow.replace('[', '');
- sRow = sRow.replace(']', '');
- iRow = Number(sRow);
-
- /*
- * delete the respective session row grid variables from
- * Dynaform - by Nyeke 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 = oCell1.getElementsByTagName('div');
-
- if (aObjects.length > 0) {
-
+ aObjects = oCell1.getElementsByTagName('a');
+ if (aObjects) {
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 = oCell1.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) + '\]') + ';');
- }
- }
- }
}
- //oCell1.innerHTML= aux.innerHTM;
- break;
- case '= 0; j--) { aObjects1[0].options[j] =
- * null; }
- */
- aObjects1[0].options.length = 0;
- for ( var j = 0; j < aObjects2[0].options.length; j++) {
- var optn = $dce("OPTION");
- optn.text = aObjects2[0].options[j].text;
- optn.value = aObjects2[0].options[j].value;
- aObjects1[0].options[j] = optn;
- }
- aObjects1[0].value = vValue;
- }
- break;
- case '= 0; j--) { aObjects1[0].options[j] =
+ * null; }
+ */
+ aObjects1[0].options.length = 0;
+ for ( var j = 0; j < aObjects2[0].options.length; j++) {
+ var optn = $dce("OPTION");
+ optn.text = aObjects2[0].options[j].text;
+ optn.value = aObjects2[0].options[j].value;
+ aObjects1[0].options[j] = optn;
}
+ aObjects1[0].value = vValue;
+ }
+ break;
+ case ' 0) {
this.unsetFields();
}*/
- //this slice of code was added to fill the grid after to delete some row
- this.aElements = [];
- for (var k=1;k<= this.oGrid.rows.length-2;k++){
- for (var i = 0; i < this.aFields.length; i++) {
- var j = k;
- switch (this.aFields[i].sType) {
- case 'text':
- 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) {
- this.aElements[this.aElements.length - 1].strTo = this.aFields[i].oProperties.strTo;
- }
- break;
- case 'currency':
- this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
- break;
- case 'percentage':
- this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j+ '][' + this.aFields[i].sFieldName));
- break;
- case 'dropdown':
- this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
- break;
+ //this slice of code was added to fill the grid after to delete some row
+ this.aElements = [];
+ for (var k=1;k<= this.oGrid.rows.length-2;k++){
+ for (var i = 0; i < this.aFields.length; i++) {
+ var j = k;
+ switch (this.aFields[i].sType) {
+ case 'text':
+ 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) {
+ this.aElements[this.aElements.length - 1].strTo = this.aFields[i].oProperties.strTo;
}
- j++;
- }
+ break;
+ case 'currency':
+ this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
+ break;
+ case 'percentage':
+ this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j+ '][' + this.aFields[i].sFieldName));
+ break;
+ case 'dropdown':
+ this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
+ break;
}
-
- 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':
+ j++;
+ }
+ }
+
+ 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('][');
@@ -891,21 +928,21 @@ var G_Grid = function(oForm, sGridName) {
oAux.value = sumaSol;
oAux = document.getElementById('form[SYS_GRID_AGGREGATE_' + oGrid.sGridName + '__' + sNamef + ']');
oAux.innerHTML = sumaSol;//return;
- */
+ */
break;
- case 'avg':
- this.avg(false, oAux);
+ case 'avg':
+ this.avg(false, oAux);
break;
- }
- }
}
}
- if (this.ondeleterow) {
- this.ondeleterow();
- }
-
- //}.extend(this)
-
+ }
+ }
+ if (this.ondeleterow) {
+ this.ondeleterow();
+ }
+
+ //}.extend(this)
+
};
/*add end*/
};
@@ -919,7 +956,9 @@ var G_Grid = function(oForm, sGridName) {
* [integer: row index]
* @author Erik Amaru Ortiz
*/
-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
@@ -929,7 +968,7 @@ function deleteRowOnDybaform(grid, sRow) {
oPanel.loader.hide();
scs = rpc.xmlhttp.responseText.extractScript();
scs.evalScript();
-
+
/**
* We verify if the debug panel is open, if it is-> update its content
*/
@@ -950,4 +989,4 @@ function deleteRowOnDybaform(grid, sRow) {
}
}.extend(this);
oRPC.make();
-}
+}
\ No newline at end of file
diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php
index 1e729f310..d44a1bdf4 100644
--- a/gulliver/system/class.xmlform.php
+++ b/gulliver/system/class.xmlform.php
@@ -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
+ * @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
+ * @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
+ * @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 [] = '';
+ $result [] = 'NSDefaultValue().' '.$this->NSGridType().'/>';
else
- $result [] = '';
+ $result [] = 'NSDefaultValue().' '.$this->NSGridType().'/>';
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
- $result [] = '' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
+ $result [] = '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 [] = '';
+ $result [] = 'NSDefaultValue().'/>';
else
- $result [] = '';
+ $result [] = 'NSDefaultValue().'/>';
} elseif ($this->mode === 'view' || $owner->modeGrid === 'view') {
- $result [] = '' . htmlentities ( $v, ENT_COMPAT, 'utf-8' );
+ $result [] = '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.
@@ -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 [] = '';
+ $result [] = '';
else
- $result [] = '';
+ $result [] = '';
} 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 = '';
+ $varaux = '';
$result [] = $this->htmlentities ( $v, ENT_COMPAT, 'utf-8' ).''.$varaux.'
';
//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
*/
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 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' readOnly="readOnly" style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>';
+ return '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 = 'htmlentities ( $value, ENT_QUOTES, 'utf-8' ) . '\' style="' . htmlentities ( $this->style, ENT_COMPAT, 'utf-8' ) . '" onkeypress="' . htmlentities ( $onkeypress, ENT_COMPAT, 'utf-8' ) . '"/>';
+ $html = '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 .= '
@@ -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 '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
*/
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') : '') . '