Merged in victorsl/processmaker/PM-4413-3017 (pull request #3364)

PM-4413
This commit is contained in:
Julio Cesar Laura Avendaño
2015-12-10 16:18:13 -04:00
4 changed files with 41 additions and 15 deletions

View File

@@ -5470,6 +5470,16 @@ class Cases
$arrayData2 = $arrayData;
}
if (isset($aTask['USR_UID']) && !empty($aTask['USR_UID'])) {
$user = new \ProcessMaker\BusinessModel\User();
$arrayUserData = $user->getUser($aTask['USR_UID'], true);
$arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2, (trim($arrayUserData['USR_TIME_ZONE']) != '')? trim($arrayUserData['USR_TIME_ZONE']) : \ProcessMaker\Util\System::getTimeZone());
} else {
$arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2);
}
$sBody2 = G::replaceDataGridField($sBody, $arrayData2, false);
switch ($aTask["TAS_ASSIGN_TYPE"]) {

View File

@@ -393,15 +393,7 @@ class User
$arrayResult[$this->getFieldNameByFormatFieldName('USR_PHOTO_PATH')] = $pathPhotoUser;
if (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) {
$userTimeZone = $record['USR_TIME_ZONE'];
if (trim($userTimeZone) == '') {
$arraySystemConfiguration = \System::getSystemConfiguration('', '', SYS_SYS);
$userTimeZone = $arraySystemConfiguration['time_zone'];
}
$arrayResult[$this->getFieldNameByFormatFieldName('USR_TIME_ZONE')] = $userTimeZone;
$arrayResult[$this->getFieldNameByFormatFieldName('USR_TIME_ZONE')] = (trim($record['USR_TIME_ZONE']) != '')? trim($record['USR_TIME_ZONE']) : \ProcessMaker\Util\System::getTimeZone();
}
//Return
@@ -774,7 +766,7 @@ class User
$rsCriteria = \UsersPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$result = $rsCriteria->next();
$row = $rsCriteria->getRow();

View File

@@ -341,13 +341,14 @@ class DateTime
/**
* Convert UTC to Time Zone
*
* @param mixed $data Data
* @param array $arrayKey Keys that convert to Time Zone
* @param string $format Format to return data
* @param mixed $data Data
* @param string $toTimeZone Time Zone to convert
* @param array $arrayKey Keys that convert to Time Zone
* @param string $format Format to return data
*
* @return mixed Return data
*/
public static function convertUtcToTimeZone($data, array $arrayKey = [], $format = 'Y-m-d H:i:s')
public static function convertUtcToTimeZone($data, $toTimeZone = null, array $arrayKey = [], $format = 'Y-m-d H:i:s')
{
try {
if (!(isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])) {
@@ -356,7 +357,7 @@ class DateTime
}
$fromTimeZone = 'UTC';
$toTimeZone = \ProcessMaker\BusinessModel\User::getUserLoggedTimeZone();
$toTimeZone = (!is_null($toTimeZone))? $toTimeZone : \ProcessMaker\BusinessModel\User::getUserLoggedTimeZone();
//Return
return (new \ProcessMaker\Util\DateTime())->convertDataToTimeZone($data, $fromTimeZone, $toTimeZone, $arrayKey, $format);

View File

@@ -0,0 +1,23 @@
<?php
namespace ProcessMaker\Util;
class System
{
/**
* Get Time Zone
*
* @return string Return Time Zone
*/
public static function getTimeZone()
{
try {
$arraySystemConfiguration = \System::getSystemConfiguration('', '', SYS_SYS);
//Return
return $arraySystemConfiguration['time_zone'];
} catch (\Exception $e) {
throw $e;
}
}
}