PM-1115 "16306: Date Field not showing next date after 1969" SOLVED
Issue:
16306: Date Field not showing next date after 1969
Cause:
Esto se debe a la funcion "mktime" de PHP para Windows el cual tiene una limitante
en el rango de fechas (rango valido entre 1901 y 2038). Para mas detalles
visite el sgte link ----> http://php.net/manual/en/function.mktime.php
Solution:
Se ha mejorado el metodo "calculateBeforeFormat" de la clase "XmlForm_Field_Date" el
cual verifica el total de añde la fecha que se obtiene con "mktime"; esto solo
para servidores Windows
This commit is contained in:
@@ -738,53 +738,53 @@ class XmlForm_Field
|
|||||||
$aValues = explode( '|', $oOwner->fields[$this->pmconnection]->keys );
|
$aValues = explode( '|', $oOwner->fields[$this->pmconnection]->keys );
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if($aData == "" || count($aData['FIELDS']) < 1){
|
if($aData == "" || count($aData['FIELDS']) < 1){
|
||||||
$message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUND' );
|
$message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUND' );
|
||||||
G::SendMessageText( $message, "WARNING" );
|
G::SendMessageText( $message, "WARNING" );
|
||||||
$sValue = "";
|
$sValue = "";
|
||||||
} else {
|
} else {
|
||||||
foreach ($aData['FIELDS'] as $aField) {
|
foreach ($aData['FIELDS'] as $aField) {
|
||||||
if ($aField['FLD_KEY'] == '1') {
|
if ($aField['FLD_KEY'] == '1') {
|
||||||
// note added by gustavo cruz gustavo[at]colosa[dot]com
|
// note added by gustavo cruz gustavo[at]colosa[dot]com
|
||||||
// this additional [if] checks if a case variable has been set
|
// this additional [if] checks if a case variable has been set
|
||||||
// in the keys attribute, so it can be parsed and replaced for
|
// in the keys attribute, so it can be parsed and replaced for
|
||||||
// their respective value.
|
// their respective value.
|
||||||
if (preg_match( "/@#/", $aValues[$i] )) {
|
if (preg_match( "/@#/", $aValues[$i] )) {
|
||||||
// check if a case are running in order to prevent that preview is
|
// check if a case are running in order to prevent that preview is
|
||||||
// erroneous rendered.
|
// erroneous rendered.
|
||||||
if (isset( $_SESSION['APPLICATION'] )) {
|
if (isset( $_SESSION['APPLICATION'] )) {
|
||||||
G::LoadClass( 'case' );
|
G::LoadClass( 'case' );
|
||||||
$oApp = new Cases();
|
$oApp = new Cases();
|
||||||
if ($oApp->loadCase( $_SESSION['APPLICATION'] ) != null) {
|
if ($oApp->loadCase( $_SESSION['APPLICATION'] ) != null) {
|
||||||
$aFields = $oApp->loadCase( $_SESSION['APPLICATION'] );
|
$aFields = $oApp->loadCase( $_SESSION['APPLICATION'] );
|
||||||
$formVariable = substr( $aValues[$i], 2 );
|
$formVariable = substr( $aValues[$i], 2 );
|
||||||
if (isset( $aFields['APP_DATA'][$formVariable] )) {
|
if (isset( $aFields['APP_DATA'][$formVariable] )) {
|
||||||
$formVariableValue = $aFields['APP_DATA'][$formVariable];
|
$formVariableValue = $aFields['APP_DATA'][$formVariable];
|
||||||
$aKeys[$aField['FLD_NAME']] = (isset( $formVariableValue ) ? G::replaceDataField( $formVariableValue, $oOwner->values ) : '');
|
$aKeys[$aField['FLD_NAME']] = (isset( $formVariableValue ) ? G::replaceDataField( $formVariableValue, $oOwner->values ) : '');
|
||||||
} else {
|
} else {
|
||||||
$aKeys[$aField['FLD_NAME']] = '';
|
$aKeys[$aField['FLD_NAME']] = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$aKeys[$aField['FLD_NAME']] = '';
|
$aKeys[$aField['FLD_NAME']] = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$aKeys[$aField['FLD_NAME']] = '';
|
$aKeys[$aField['FLD_NAME']] = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$aKeys[$aField['FLD_NAME']] = (isset( $aValues[$i] ) ? G::replaceDataField( $aValues[$i], $oOwner->values ) : '');
|
$aKeys[$aField['FLD_NAME']] = (isset( $aValues[$i] ) ? G::replaceDataField( $aValues[$i], $oOwner->values ) : '');
|
||||||
}
|
}
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$aData = $oAdditionalTables->getDataTable( $oOwner->fields[$this->pmconnection]->pmtable, $aKeys );
|
$aData = $oAdditionalTables->getDataTable( $oOwner->fields[$this->pmconnection]->pmtable, $aKeys );
|
||||||
} catch (Exception $oError) {
|
} catch (Exception $oError) {
|
||||||
$aData = array ();
|
$aData = array ();
|
||||||
}
|
}
|
||||||
if (isset( $aData[$this->pmfield] )) {
|
if (isset( $aData[$this->pmfield] )) {
|
||||||
$sValue = $aData[$this->pmfield];
|
$sValue = $aData[$this->pmfield];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4493,17 +4493,50 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
|
|||||||
{
|
{
|
||||||
$part1 = $sign * substr( $date, 0, strlen( $date ) - 1 );
|
$part1 = $sign * substr( $date, 0, strlen( $date ) - 1 );
|
||||||
$part2 = substr( $date, strlen( $date ) - 1 );
|
$part2 = substr( $date, strlen( $date ) - 1 );
|
||||||
|
|
||||||
|
$year = (int)(date("Y"));
|
||||||
|
$month = (int)(date("m"));
|
||||||
|
$day = (int)(date("d"));
|
||||||
|
|
||||||
|
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != "WIN";
|
||||||
|
$checkYear = false;
|
||||||
|
|
||||||
switch ($part2) {
|
switch ($part2) {
|
||||||
case 'd':
|
case "y":
|
||||||
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) + $part1, date( 'Y' ) ) );
|
$year = $year + $part1;
|
||||||
|
|
||||||
|
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
|
||||||
|
|
||||||
|
$checkYear = true;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case "m":
|
||||||
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ) + $part1, date( 'd' ), date( 'Y' ) ) );
|
$month = $month + $part1;
|
||||||
|
|
||||||
|
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
|
||||||
|
|
||||||
|
if ($month > 12) {
|
||||||
|
$year = $year + (int)($month / 12);
|
||||||
|
|
||||||
|
$checkYear = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'y':
|
case "d":
|
||||||
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) + $part1 ) );
|
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day + $part1, $year));
|
||||||
|
|
||||||
|
$dayAux = ($month * 31) - (31 - $day) + $part1;
|
||||||
|
|
||||||
|
if ($dayAux > 365) {
|
||||||
|
$year = $year + (int)($dayAux / 365);
|
||||||
|
|
||||||
|
$checkYear = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$osIsLinux && $checkYear && !preg_match("/^$year\-\d{2}\-\d{2}$/", $res)) {
|
||||||
|
$res = preg_replace("/^\d{4}(\-\d{2}\-\d{2})$/", "$year$1", $res);
|
||||||
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user