BUG 9619 "Grillas: Problema en las dependencias al eliminar..." SOLVED

- When you delete a row of a grid in any order (not in sequential order)
  and then add a new row, dependent fields do not work.
- Problem resuelo, dependent fields work correctly when you delete any row.
* Available from version 2.0.44
This commit is contained in:
Victor Saisa Lopez
2012-08-27 18:57:17 -04:00
parent 81deb1fab4
commit 40e2dbbcb8
5 changed files with 413 additions and 302 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -7,19 +7,28 @@ if( !isset($request) ){
if( isset($request) ){
switch($request){
case 'deleteGridRowOnDynaform':
// This code is to update the SESSION variable for dependent fields in grids
$oFields = array();
if (!defined('XMLFORM_AJAX_PATH')) define('XMLFORM_AJAX_PATH',PATH_XMLFORM);
ksort($_SESSION[$_POST['formID']][$_POST['gridname']]);
$initialKey = 1;
foreach ($_SESSION[$_POST['formID']][$_POST['gridname']] as $key => $value) {
if ($key != $_POST['rowpos']) {
$oFields[$initialKey] = $value;
$initialKey++;
}
//This code is to update the SESSION variable for dependent fields in grids
if (!defined("XMLFORM_AJAX_PATH")) {
define("XMLFORM_AJAX_PATH", PATH_XMLFORM);
}
if (is_array($_SESSION[$_POST["formID"]][$_POST["gridname"]])) {
ksort($_SESSION[$_POST["formID"]][$_POST["gridname"]]);
$oFields = array();
$initialKey = 1;
foreach ($_SESSION[$_POST["formID"]][$_POST["gridname"]] as $key => $value) {
if ($key != $_POST["rowpos"]) {
$oFields[$initialKey] = $value;
$initialKey++;
}
}
unset($_SESSION[$_POST["formID"]][$_POST["gridname"]]);
$_SESSION[$_POST["formID"]][$_POST["gridname"]] = $oFields;
}
unset($_SESSION[$_POST['formID']][$_POST['gridname']]);
$_SESSION[$_POST['formID']][$_POST['gridname']] = $oFields;
/* if( isset($_SESSION['APPLICATION']) ){
G::LoadClass('case');

View File

@@ -3350,10 +3350,14 @@ class XmlForm_Field_Grid extends XmlForm_Field
for ($c=1; $c <= $therow; $c++){
if ($c == $therow){
$xValues[$therow] = $aRow;
}else{
foreach ($aRow as $key=>$value){
$xValues[$c][$key] = '';
}
} else {
if (is_array($aRow)) {
foreach ($aRow as $key => $value){
$xValues[$c][$key] = "";
}
} else {
//
}
}
}
$values = $xValues;
@@ -3394,22 +3398,29 @@ class XmlForm_Field_Grid extends XmlForm_Field
return $tpl->printObject ( $this, $therow );
}
/**
* Change the columns for rows and rows to columns
* @param <array> $values
* @return <array>
*/
function flipValues($values) {
$flipped = array ();
foreach ( $values as $rowKey => $row ) {
foreach ( $row as $colKey => $cell ) {
if (! isset ( $flipped [$colKey] ) || ! is_array ( $flipped [$colKey] ))
$flipped [$colKey] = array ();
$flipped [$colKey] [$rowKey] = $cell;
}
/**
* Change the columns for rows and rows to columns
* @param <array> $arrayData
* @return <array>
*/
public function flipValues($arrayData)
{
$flipped = array();
foreach ($arrayData as $rowIndex => $rowValue) {
if (is_array($rowValue)) {
foreach ($rowValue as $colIndex => $colValue) {
if (!isset($flipped[$colIndex]) || !is_array($flipped[$colIndex])) {
$flipped[$colIndex] = array();
}
$flipped[$colIndex][$rowIndex] = $colValue;
}
}
}
return $flipped;
}
return $flipped;
}
}
/**
@@ -3698,6 +3709,10 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
$mask = '%Y-%m-%d'; //set default
}
if ($this->defaultValue == "today") {
$defaultValue = masktophp($mask);
}
if( strpos($mask, '%') === false ) {
if( strpos($mask, '-') !== false )
$separator = '-';

View File

@@ -13,7 +13,7 @@
{if ($form->addRow) }
<table class='Record'>
<tr><td></td>
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" />&nbsp;<a id="form[{$form->name}][addLink]" class="GridLink" href="#" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow();return false;">{$form->NewLabel}</a></td>
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" />&nbsp;<a id="form[{$form->name}][addLink]" class="GridLink" href="javascript:;" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow(); return false;">{$form->NewLabel}</a></td>
</tr>
</table>
{/if}
@@ -37,7 +37,7 @@
<td style="white-space:nowrap;">{$field->field}</td>
{/foreach}
{if $form->deleteRow == '1' }
<td align="center"><A class="GridLink" href="#" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]');return false;">{$form->DeleteLabel}</A>&nbsp;</td>
<td align="center"><A class="GridLink" href="javascript:;" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]'); return false;">{$form->DeleteLabel}</A>&nbsp;</td>
{/if}
{if ($form->editRow=='1')}
<td>edit"{$form->editRow}"</td>

View File

@@ -14,7 +14,7 @@
{if ($form->addRow) }
<table class='Record'>
<tr><td></td>
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" />&nbsp;<a class="GridLink" href="#" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow();return false;">{$form->NewLabel}</a></td>
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" />&nbsp;<a class="GridLink" href="javascript:;" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow(); return false;">{$form->NewLabel}</a></td>
</tr>
</table>
{/if}
@@ -39,7 +39,7 @@
<td style="">{$field->field}</td>
{/foreach}
{if $form->deleteRow == '1' }
<td align="center"><A class="GridLink" href="#" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]');return false;">{$form->DeleteLabel}</A>&nbsp;</td>
<td align="center"><A class="GridLink" href="javascript:;" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]'); return false;">{$form->DeleteLabel}</A>&nbsp;</td>
{/if}
{if ($form->editRow=='1')}
<td>edit"{$form->editRow}"</td>