0009868: Fix timezone in freedays
authorAlexander Stintzing <a.stintzing@metaways.de>
Fri, 25 Apr 2014 13:35:52 +0000 (15:35 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 25 Apr 2014 14:24:36 +0000 (16:24 +0200)
when fetching feast days on defining sickness/vacation
days for an employee, the timezone is not correct.

https://forge.tine20.org/mantisbt/view.php?id=9868

Change-Id: Ia5ef2ad59262fef5510f2a5bdd328ff023a103f5
Reviewed-on: http://gerrit.tine20.com/customers/559
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/HumanResources/JsonTests.php
tests/tine20/HumanResources/TestCase.php
tine20/HumanResources/Frontend/Json.php
tine20/Tinebase/Controller/Record/Abstract.php

index 055cc8f..f040ed9 100644 (file)
@@ -776,11 +776,14 @@ class HumanResources_JsonTests extends HumanResources_TestCase
             $contract1->end_date = $employmentEnd;
             $contract1->workingtime_json = '{"days": [8,8,8,8,8,0,0]}';
             $contract1->vacation_days = 25;
-        
+            $contract1->feast_calendar_id = $this->_getFeastCalendar()->getId();
+            
             $recordData = $employee->toArray();
             $recordData['contracts'] = array($contract1->toArray());
             $recordData = $this->_json->saveEmployee($recordData);
 
+            $this->_createFeastDay(Tinebase_DateTime::now()->setDate(2014,1,6));
+            
             $accountController = HumanResources_Controller_Account::getInstance();
             
             // should not be created, exist already
@@ -795,7 +798,11 @@ class HumanResources_JsonTests extends HumanResources_TestCase
             $this->assertEquals(0, count($res['sicknessDays']));
             $this->assertEquals(8, count($res['excludeDates']));
             $this->assertEquals(NULL, $res['ownFreeDays']);
-            $this->assertEquals(0, count($res['feastDays']));
+            
+            $this->assertEquals(1, count($res['feastDays']));
+            $this->assertEquals(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE), $res['feastDays'][0]->getTimezone()->getName());
+            $this->assertEquals('2014-01-06 00:00:00', $res['feastDays'][0]->toString());
+            
             $this->assertEquals(1, count($res['contracts']));
             $this->assertEquals($recordData['id'], $res['employee']['id']);
             $this->assertEquals('2014-01-02 00:00:00', $res['firstDay']->toString());
index 74f8f58..3be6aae 100644 (file)
@@ -270,7 +270,7 @@ class HumanResources_TestCase extends PHPUnit_Framework_TestCase
         }
         
         $event = new Calendar_Model_Event(array(
-            'summary'     => 'Wakeup',
+            'summary'     => 'Feast Day',
             'dtstart'     => $dtstart->format('Y-m-d H:i:s'),
             'dtend'       => $dtend->format('Y-m-d H:i:s'),
             'description' => Tinebase_Record_Abstract::generateUID(10),
index 68d98f2..7dcc063 100644 (file)
@@ -471,7 +471,7 @@ class HumanResources_Frontend_Json extends Tinebase_Frontend_Json_Abstract
         
         // set time to 0
         foreach($feastDays as &$feastDay) {
-            $feastDay->setTime(0,0,0);
+            $feastDay->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE))->setTime(0,0,0);
         }
         
         // search free times for the account and the interval
index d302ebe..e5de8a8 100644 (file)
@@ -1817,7 +1817,7 @@ abstract class Tinebase_Controller_Record_Abstract
             
             if ($deleteContracts->count()) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
-                    Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__. ' Deleting dependent records with id = "' . $deleteContracts->getId() . '" on property ' . $_property . ' for ' . $this->_applicationName . ' ' . $this->_modelName);
+                    Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__. ' Deleting dependent records with id = "' . print_r($deleteContracts->getId(), 1) . '" on property ' . $_property . ' for ' . $this->_applicationName . ' ' . $this->_modelName);
                 }
                 $controller->delete($deleteContracts->id);
             }