本文整理汇总了PHP中Tinebase_Core::getUserTimezone方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Core::getUserTimezone方法的具体用法?PHP Tinebase_Core::getUserTimezone怎么用?PHP Tinebase_Core::getUserTimezone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Core
的用法示例。
在下文中一共展示了Tinebase_Core::getUserTimezone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFilterImap
/**
*
* @return type
*/
public function getFilterImap()
{
$format = "d-M-Y";
// prepare value
$value = (array) $this->_getDateValues($this->_operator, $this->_value);
$timezone = Tinebase_Helper::array_value('timezone', $this->_options);
$timezone = $timezone ? $timezone : Tinebase_Core::getUserTimezone();
foreach ($value as &$date) {
$date = new Tinebase_DateTime($date);
// should be in user timezone
$date->setTimezone(new DateTimeZone($timezone));
}
switch ($this->_operator) {
case 'within':
case 'inweek':
$value[1]->add(new DateInterval('P1D'));
// before is not inclusive, so we have to add a day
$return = "SINCE {$value[0]->format($format)} BEFORE {$value[1]->format($format)}";
break;
case 'before':
$return = "BEFORE {$value[0]->format($format)}";
break;
case 'after':
$return = "SINCE {$value[0]->format($format)}";
break;
case 'equals':
$return = "ON {$value[0]->format($format)}";
}
return $return;
}
示例2: testSearchEvents
/**
* test search events
*/
public function testSearchEvents()
{
$from = '2009-04-03 00:00:00';
$until = '2009-04-10 23:59:59';
$events = new Tinebase_Record_RecordSet('Calendar_Model_Event', array(array('dtstart' => '2009-04-02 22:00:00', 'dtend' => '2009-04-02 23:59:59', 'summary' => 'non recur event ending before search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-02 23:30:00', 'dtend' => '2009-04-03 00:30:00', 'summary' => 'non recur event ending within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-06 12:00:00', 'dtend' => '2009-04-07 12:00:00', 'summary' => 'non recur event completly within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-10 23:30:00', 'dtend' => '2009-04-11 00:30:00', 'summary' => 'non recur event starting within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-04-11 00:00:00', 'dtend' => '2009-04-11 02:00:00', 'summary' => 'non recur event starting after search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), Tinebase_Model_Grants::GRANT_READ => true), array('dtstart' => '2009-03-27 22:00:00', 'dtend' => '2009-03-27 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-02 23:59:59', 'summary' => 'recur event ending before search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-02 23:59:59', Tinebase_Model_Grants::GRANT_READ => true, 'originator_tz' => Tinebase_Core::getUserTimezone()), array('dtstart' => '2009-03-27 22:00:00', 'dtend' => '2009-03-27 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-05 23:59:59', 'summary' => 'recur event ending within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-05 23:59:59', Tinebase_Model_Grants::GRANT_READ => true, 'originator_tz' => Tinebase_Core::getUserTimezone()), array('dtstart' => '2009-04-03 22:00:00', 'dtend' => '2009-04-03 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-06 23:59:59', 'summary' => 'recur event completly within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-06 23:59:59', Tinebase_Model_Grants::GRANT_READ => true, 'originator_tz' => Tinebase_Core::getUserTimezone()), array('dtstart' => '2009-04-03 22:00:00', 'dtend' => '2009-04-03 23:59:59', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-12 23:59:59', 'summary' => 'recur event starting within search period => should be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-12 23:59:59', Tinebase_Model_Grants::GRANT_READ => true, 'originator_tz' => Tinebase_Core::getUserTimezone()), array('dtstart' => '2009-04-11 00:00:00', 'dtend' => '2009-04-11 02:00:00', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=2009-04-15 02:00:00', 'summary' => 'recur event starting after search period => should _not_ be found', 'attendee' => $this->_getAttendee(), 'container_id' => $this->_getTestCalendar()->getId(), 'organizer' => Tinebase_Core::getUser()->getId(), 'uid' => Calendar_Model_Event::generateUID(), 'rrule_until' => '2009-04-15 02:00:00', Tinebase_Model_Grants::GRANT_READ => true, 'originator_tz' => Tinebase_Core::getUserTimezone())));
foreach ($events as $event) {
$persistentEvent = $this->_backend->create($event);
$event->attendee->cal_event_id = $persistentEvent->getId();
foreach ($event->attendee as $attender) {
$this->_backend->createAttendee($attender);
}
}
$filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getTestCalendar()->getId()), array('field' => 'period', 'operator' => 'within', 'value' => array('from' => $from, 'until' => $until))));
$eventsFound = $this->_backend->search($filter, new Tinebase_Model_Pagination());
$eventsFoundIds = $eventsFound->getArrayOfIds();
foreach ($events as $event) {
$eventId = $event->getId();
if (strpos($event->summary, '_not_') === false) {
$this->assertTrue(in_array($eventId, $eventsFoundIds), 'The following event is missing in the search result :' . print_r($event->toArray(), true));
} else {
$this->assertFalse(in_array($eventId, $eventsFoundIds), 'The following event is in the search result, but should not be :' . print_r($event->toArray(), true));
}
}
$expectedAttendee = $this->_getAttendee();
foreach ($eventsFound as $fetchedEvent) {
$this->_assertAttendee($expectedAttendee, $fetchedEvent->attendee);
}
}
示例3: create
/**
* add one record
*
* @param Tinebase_Record_Interface $_record
* @return Tinebase_Record_Interface
* @throws Tinebase_Exception_AccessDenied
* @throws Tinebase_Exception_Record_Validation
*/
public function create(Tinebase_Record_Interface $_task)
{
$this->_handleCompleted($_task);
$_task->originator_tz = $_task->originator_tz ? $_task->originator_tz : Tinebase_Core::getUserTimezone();
$task = parent::create($_task);
$this->_addAutomaticAlarms($task);
return $task;
}
示例4: getInterval
/**
* returns the interval of this billable
*
* @return array
*/
public function getInterval()
{
$startDate = clone new Tinebase_DateTime($this->start_date);
$startDate->setTimezone(Tinebase_Core::getUserTimezone());
$startDate->setDate($startDate->format('Y'), $startDate->format('n'), 1);
$startDate->setTime(0, 0, 0);
$endDate = clone $startDate;
$endDate->addMonth(1)->subSecond(1);
return array($startDate, $endDate);
}
示例5: testTimezoneConversion
/**
* testTimezoneConversion
*/
public function testTimezoneConversion()
{
$exampleFilterData = self::getPersistentFilterData();
$savedFilterData = $this->testSaveFilter($exampleFilterData);
$testUserTimezone = Tinebase_Core::getUserTimezone();
Tinebase_Core::set(Tinebase_Core::USERTIMEZONE, $testUserTimezone !== 'US/Pacific' ? 'US/Pacific' : 'UTC');
$originalDueDateFilter = $this->_getFilter('due', $exampleFilterData);
$convertedDueDataFilter = $this->_getFilter('due', $this->_uit->getPersistentFilter($savedFilterData['id']));
Tinebase_Core::set(Tinebase_Core::USERTIMEZONE, $testUserTimezone);
$this->assertNotEquals($originalDueDateFilter['value'], $convertedDueDataFilter['value']);
}
示例6: testUpdateEvent
/**
* testUpdateEvent
*/
public function testUpdateEvent()
{
$persistentEvent = $this->testCreateEvent();
$currentTz = Tinebase_Core::getUserTimezone();
Tinebase_Core::set(Tinebase_Core::USERTIMEZONE, 'farfaraway');
$persistentEvent->summary = 'Lunchtime';
$updatedEvent = $this->_controller->update($persistentEvent);
$this->assertEquals($persistentEvent->summary, $updatedEvent->summary);
$this->assertEquals($currentTz, $updatedEvent->originator_tz, 'originator_tz must not be touchet if dtsart is not updatet!');
$updatedEvent->dtstart->addHour(1);
$updatedEvent->dtend->addHour(1);
$secondUpdatedEvent = $this->_controller->update($updatedEvent);
$this->assertEquals(Tinebase_Core::getUserTimezone(), $secondUpdatedEvent->originator_tz, 'originator_tz must be adopted if dtsart is updatet!');
Tinebase_Core::set(Tinebase_Core::USERTIMEZONE, $currentTz);
}
示例7: _getDateValues
/**
* calculates the date filter values
*
* @param string $_operator
* @param string $_value
* @param string $_dateFormat
* @return array|string date value
*/
protected function _getDateValues($_operator, $_value)
{
if ($_operator === 'within') {
// get beginning / end date and add 00:00:00 / 23:59:59
date_default_timezone_set((isset($this->_options['timezone']) || array_key_exists('timezone', $this->_options)) && !empty($this->_options['timezone']) ? $this->_options['timezone'] : Tinebase_Core::getUserTimezone());
$value = parent::_getDateValues($_operator, $_value);
$value[0] .= ' 00:00:00';
$value[1] .= ' 23:59:59';
date_default_timezone_set('UTC');
// convert to utc
$value[0] = $this->_convertStringToUTC($value[0]);
$value[1] = $this->_convertStringToUTC($value[1]);
} else {
$value = $_value instanceof DateTime ? $_value->toString(Tinebase_Record_Abstract::ISO8601LONG) : $_value;
}
return $value;
}
示例8: generate
/**
* create lead pdf
*
* @param Crm_Model_Lead $_lead lead data
*
* @return string the pdf
*/
public function generate(Crm_Model_Lead $_lead, $_pageNumber = 0)
{
$locale = Tinebase_Core::get('locale');
$translate = Tinebase_Translation::getTranslation('Crm');
// set user timezone
$_lead->setTimezone(Tinebase_Core::getUserTimezone());
/*********************** build data array ***************************/
$record = $this->getRecord($_lead, $locale, $translate);
/******************* build title / subtitle / description ***********/
$title = $_lead->lead_name;
$subtitle = "";
$description = $_lead->description;
$titleIcon = "/images/oxygen/32x32/actions/datashowchart.png";
/*********************** add linked objects *************************/
$linkedObjects = $this->getLinkedObjects($_lead, $locale, $translate);
$tags = $_lead->tags instanceof Tinebase_Record_RecordSet ? $_lead->tags->toArray() : array();
/***************************** generate pdf now! ********************/
parent::generatePdf($record, $title, $subtitle, $tags, $description, $titleIcon, NULL, $linkedObjects, FALSE);
}
示例9: getFSV
/**
* get sieve vacation object
*
* @return Felamimail_Sieve_Vacation
*/
public function getFSV()
{
$fsv = new Felamimail_Sieve_Vacation();
$fsv->setEnabled($this->enabled)->setDays($this->days && (int) $this->days > 0 ? (int) $this->days : 7)->setSubject($this->subject)->setFrom($this->from)->setMime($this->mime)->setReason($this->reason)->setDateEnabled($this->date_enabled);
$this->setTimezone(Tinebase_Core::getUserTimezone());
if ($this->start_date instanceof Tinebase_DateTime) {
$fsv->setStartdate($this->start_date->format('Y-m-d'));
}
if ($this->end_date instanceof Tinebase_DateTime) {
$fsv->setEnddate($this->end_date->format('Y-m-d'));
}
$this->setTimezone('UTC');
if (is_array($this->addresses)) {
foreach ($this->addresses as $address) {
$fsv->addAddress($address);
}
}
return $fsv;
}
示例10: sendMessage
/**
* send one message through smtp
*
* @param Expressomail_Model_Message $_message
* @return Expressomail_Model_Message
*/
public function sendMessage(Expressomail_Model_Message $_message)
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Sending message with subject ' . $_message->subject . ' to ' . print_r($_message->to, TRUE));
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_message->toArray(), TRUE));
}
// increase execution time (sending message with attachments can take a long time)
$oldMaxExcecutionTime = Tinebase_Core::setExecutionLifeTime(300);
// 5 minutes
$account = Expressomail_Controller_Account::getInstance()->get($_message->account_id);
$this->_resolveOriginalMessage($_message);
$mail = $this->createMailForSending($_message, $account);
date_default_timezone_set(Tinebase_Core::getUserTimezone());
//fetch date header to use GMT
$this->_sendMailViaTransport($mail, $account, $_message, true);
// get an array with all recipients
$recipients = $this->_getRecipients($_message);
$nonPrivateRecipients = array_merge($recipients['to'], $recipients['cc']);
$allRecipients = array_merge($recipients['bcc'], $nonPrivateRecipients);
$config = Tinebase_Core::getConfig();
$maxRecipients = Expressomail_Config::getInstance()->get(Expressomail_Config::MAX_CONTACT_ADD_TO_UNKNOWN);
if (isset($config->email->maxContactAddToUnknown)) {
$maxRecipients = $config->email->maxContactAddToUnknown;
}
if (count($allRecipients) <= $maxRecipients && $_message->add_contacts) {
Tinebase_Core::getLogger()->debug(__METHOD__ . ' Starting search and import of ' . count($allRecipients) . ' contacts');
$_message->added_contacts = $this->_saveUnknownContacts($account->user_id, $allRecipients);
Tinebase_Core::getLogger()->debug(__METHOD__ . ' Search and import completed, ' . $_message->added_contacts . ' where added');
}
if ($_message->note) {
// save note to contacts
$this->_addEmailNote($nonPrivateRecipients, $_message->subject, $_message->getPlainTextBody());
}
// reset max execution time to old value
Tinebase_Core::setExecutionLifeTime($oldMaxExcecutionTime);
$this->removeTempFiles($_message);
return $_message;
}
示例11: iMIPPrepare
/**
* prepares an iMIP (RFC 6047) Message
*
* @param array $iMIP
* @return array prepared iMIP part
*/
public function iMIPPrepare($iMIP)
{
$iMIPMessage = $iMIP instanceof Calendar_Model_iMIP ? $iMIP : new Calendar_Model_iMIP($iMIP);
$iMIPFrontend = new Calendar_Frontend_iMIP();
$iMIPMessage->preconditionsChecked = FALSE;
$iMIPFrontend->prepareComponent($iMIPMessage);
$iMIPMessage->setTimezone(Tinebase_Core::getUserTimezone());
return $iMIPMessage->toArray();
}
示例12: testAlternatingContracts
/**
<<<<<<< HEAD
* @see: https://forge.tine20.org/mantisbt/view.php?id=10122
*/
public function testAlternatingContracts()
{
$date = Tinebase_DateTime::now()->setDate(2014, 1, 1)->setTimezone(Tinebase_Core::getUserTimezone())->setTime(0, 0, 0);
$employee = $this->_getEmployee('unittest');
$employee->employment_begin = clone $date;
$contract1 = $this->_getContract();
$contract1->start_date = clone $date;
// 1.1.2014
$date->addMonth(7)->subDay(1);
$contract1->end_date = clone $date;
// 31.7.2014
$contract1->workingtime_json = '{"days": [8,8,8,8,8,0,0]}';
$contract1->vacation_days = 27;
$date->addDay(1);
// 1.8.2014
$contract2 = $this->_getContract();
$contract2->start_date = clone $date;
$contract2->workingtime_json = '{"days": [8,8,8,8,8,0,0]}';
$contract2->vacation_days = 30;
$recordData = $employee->toArray();
$recordData['contracts'] = array($contract1->toArray(), $contract2->toArray());
$recordData = $this->_json->saveEmployee($recordData);
$recordData['vacation'] = array(array());
$res = $this->_json->searchAccounts(array(array('field' => 'year', 'operator' => 'equals', 'value' => '2014')), array());
$account = $res['results'][0];
$date->subDay(1);
// 31.7.2014
$extraFreeTime = HumanResources_Controller_ExtraFreeTime::getInstance()->create(new HumanResources_Model_ExtraFreeTime(array('account_id' => $account['id'], 'days' => 4, 'expires' => clone $date, 'type' => 'payed')));
$res = $this->_json->getFeastAndFreeDays($recordData['id'], 2014);
// at this point, vacation days are not created, so the extra freetime is expired
$this->assertEquals(28, $res['results']['remainingVacation']);
// create vacation days
$day = Tinebase_DateTime::now()->setDate(2014, 1, 2)->setTimezone(Tinebase_Core::getUserTimezone())->setTime(0, 0, 0);
$newFreeTime = array('account_id' => $account['id'], 'employee_id' => $recordData['id'], 'type' => 'vacation', 'status' => 'ACCEPTED', 'firstday_date' => $day->toString());
$newFreeTime['freedays'] = array(array('duration' => '1', 'date' => $day->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()));
$newFreeTime['days_count'] = 2;
$newFreeTime['lastday_date'] = $day->toString();
$this->_json->saveFreeTime($newFreeTime);
// create vacation days
$day = Tinebase_DateTime::now()->setDate(2014, 6, 10)->setTimezone(Tinebase_Core::getUserTimezone())->setTime(0, 0, 0);
$newFreeTime = array('account_id' => $account['id'], 'employee_id' => $recordData['id'], 'type' => 'vacation', 'status' => 'ACCEPTED', 'firstday_date' => $day->toString());
$newFreeTime['freedays'] = array(array('duration' => '1', 'date' => $day->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()));
$newFreeTime['days_count'] = 4;
$newFreeTime['lastday_date'] = $day->toString();
$this->_json->saveFreeTime($newFreeTime);
// create vacation days
$day = Tinebase_DateTime::now()->setDate(2014, 7, 28)->setTimezone(Tinebase_Core::getUserTimezone())->setTime(0, 0, 0);
$newFreeTime = array('account_id' => $account['id'], 'employee_id' => $recordData['id'], 'type' => 'vacation', 'status' => 'ACCEPTED', 'firstday_date' => $day->toString());
$newFreeTime['freedays'] = array(array('duration' => '1', 'date' => $day->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()));
$newFreeTime['days_count'] = 5;
$newFreeTime['lastday_date'] = $day->toString();
$this->_json->saveFreeTime($newFreeTime);
// create sickness days
$day = Tinebase_DateTime::now()->setDate(2014, 1, 21)->setTimezone(Tinebase_Core::getUserTimezone())->setTime(0, 0, 0);
$newFreeTime = array('account_id' => $account['id'], 'employee_id' => $recordData['id'], 'type' => 'sickness', 'status' => "EXCUSED", 'firstday_date' => $day->toString());
$newFreeTime['freedays'] = array(array('duration' => '1', 'date' => $day->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()), array('duration' => '1', 'date' => $day->addDay(1)->toString()));
$day->addDay(2);
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$day->addDay(2);
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['freedays'][] = array('duration' => '1', 'date' => $day->addDay(1)->toString());
$newFreeTime['days_count'] = 14;
$newFreeTime['lastday_date'] = $day->toString();
$this->_json->saveFreeTime($newFreeTime);
// create sickness days
$day = Tinebase_DateTime::now()->setDate(2014, 1, 6)->setTimezone(Tinebase_Core::getUserTimezone())->setTime(0, 0, 0);
$newFreeTime = array('account_id' => $account['id'], 'employee_id' => $recordData['id'], 'type' => 'sickness', 'status' => "UNEXCUSED", 'firstday_date' => $day->toString());
$newFreeTime['freedays'] = array(array('duration' => '1', 'date' => $day->toString()));
$this->_json->saveFreeTime($newFreeTime);
$res = $this->_json->getFeastAndFreeDays($recordData['id'], 2014);
// at this point the extra freetime has been taken and is not expired
// 28 + 4 - 11 = 21
$this->assertEquals(21, $res['results']['remainingVacation']);
$account = $this->_json->getAccount($account['id']);
$this->assertEquals(32, $account['possible_vacation_days']);
$this->assertEquals(0, $account['expired_vacation_days']);
$this->assertEquals(21, $account['remaining_vacation_days']);
$this->assertEquals(11, $account['taken_vacation_days']);
$this->assertEquals(14, $account['excused_sickness']);
$this->assertEquals(1, $account['unexcused_sickness']);
}
示例13: testInterval12LastAutobill
public function testInterval12LastAutobill()
{
$startDate = clone $this->_referenceDate;
$startDate->subYear(1);
$this->_createProducts(array(array('name' => 'bill yearly', 'description' => 'bill every year', 'price' => '1002', 'accountable' => 'Sales_Model_Product')));
$this->_createCustomers(1);
$this->_createCostCenters();
$addressId = $this->_addressRecords->filter('customer_id', $this->_customerRecords->filter('name', 'Customer1')->getFirstRecord()->getId())->filter('type', 'billing')->getFirstRecord()->getId();
// this contract begins 6 months before the first invoice will be created
$this->_createContracts(array(array('number' => 100, 'title' => 'MyContract', 'description' => 'unittest', 'container_id' => $this->_sharedContractsContainerId, 'billing_point' => 'begin', 'billing_address_id' => $addressId, 'interval' => 12, 'start_date' => $startDate, 'last_autobill' => $startDate, 'end_date' => NULL, 'products' => array(array('product_id' => $this->_productRecords->getByIndex(0)->getId(), 'quantity' => 1, 'interval' => 12, 'last_autobill' => $startDate)))));
$startDate = clone $this->_referenceDate;
$startDate->subMonth(1);
$startDate = clone $this->_referenceDate;
$startDate->addDay(5);
$result = $this->_invoiceController->createAutoInvoices($startDate);
$this->assertEquals(1, $result['created_count']);
$invoices = $this->_invoiceController->getAll();
$firstInvoice = $invoices->getFirstRecord();
$this->assertEquals(1, $invoices->count());
$filter = new Sales_Model_InvoicePositionFilter(array());
$filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'invoice_id', 'operator' => 'in', 'value' => $invoices->getArrayOfIds())));
$invoicePositions = Sales_Controller_InvoicePosition::getInstance()->search($filter);
$this->assertEquals(12, $invoicePositions->count());
$contract = $this->_contractRecords->getFirstRecord();
$contract->setTimezone(Tinebase_Core::getUserTimezone());
$autobillDate = clone $this->_referenceDate;
for ($i = 0; $i < 8; $i++) {
$startDate->addDay(1);
$result = $this->_invoiceController->createAutoInvoices($startDate);
$this->assertEquals(0, $result['created_count']);
}
$productAggregate = Sales_Controller_ProductAggregate::getInstance()->getAll()->getFirstRecord();
$productAggregate->setTimezone(Tinebase_Core::getUserTimezone());
$this->assertEquals($autobillDate, $productAggregate->last_autobill);
}
示例14: toTineModel
//.........这里部分代码省略.........
if ($data->{$syncrotonProperty} instanceof Syncroton_Model_EmailBody) {
$event->{$tine20Property} = $data->{$syncrotonProperty}->data;
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Removing description.');
}
$event->{$tine20Property} = null;
}
break;
case 'rrule':
// handle recurrence
if ($data->{$syncrotonProperty} instanceof Syncroton_Model_EventRecurrence && isset($data->{$syncrotonProperty}->type)) {
$rrule = new Calendar_Model_Rrule();
switch ($data->{$syncrotonProperty}->type) {
case Syncroton_Model_EventRecurrence::TYPE_DAILY:
$rrule->freq = Calendar_Model_Rrule::FREQ_DAILY;
break;
case Syncroton_Model_EventRecurrence::TYPE_WEEKLY:
$rrule->freq = Calendar_Model_Rrule::FREQ_WEEKLY;
$rrule->byday = $this->_convertBitMaskToDay($data->{$syncrotonProperty}->dayOfWeek);
break;
case Syncroton_Model_EventRecurrence::TYPE_MONTHLY:
$rrule->freq = Calendar_Model_Rrule::FREQ_MONTHLY;
$rrule->bymonthday = $data->{$syncrotonProperty}->dayOfMonth;
break;
case Syncroton_Model_EventRecurrence::TYPE_MONTHLY_DAYN:
$rrule->freq = Calendar_Model_Rrule::FREQ_MONTHLY;
$week = $data->{$syncrotonProperty}->weekOfMonth;
$day = $data->{$syncrotonProperty}->dayOfWeek;
$byDay = $week == 5 ? -1 : $week;
$byDay .= $this->_convertBitMaskToDay($day);
$rrule->byday = $byDay;
break;
case Syncroton_Model_EventRecurrence::TYPE_YEARLY:
$rrule->freq = Calendar_Model_Rrule::FREQ_YEARLY;
$rrule->bymonth = $data->{$syncrotonProperty}->monthOfYear;
$rrule->bymonthday = $data->{$syncrotonProperty}->dayOfMonth;
break;
case Syncroton_Model_EventRecurrence::TYPE_YEARLY_DAYN:
$rrule->freq = Calendar_Model_Rrule::FREQ_YEARLY;
$rrule->bymonth = $data->{$syncrotonProperty}->monthOfYear;
$week = $data->{$syncrotonProperty}->weekOfMonth;
$day = $data->{$syncrotonProperty}->dayOfWeek;
$byDay = $week == 5 ? -1 : $week;
$byDay .= $this->_convertBitMaskToDay($day);
$rrule->byday = $byDay;
break;
}
$rrule->interval = isset($data->{$syncrotonProperty}->interval) ? $data->{$syncrotonProperty}->interval : 1;
if (isset($data->{$syncrotonProperty}->occurrences)) {
$rrule->count = $data->{$syncrotonProperty}->occurrences;
$rrule->until = null;
} else {
if (isset($data->{$syncrotonProperty}->until)) {
$rrule->count = null;
$rrule->until = new Tinebase_DateTime($data->{$syncrotonProperty}->until);
} else {
$rrule->count = null;
$rrule->until = null;
}
}
$event->rrule = $rrule;
}
break;
default:
if ($data->{$syncrotonProperty} instanceof DateTime) {
$event->{$tine20Property} = new Tinebase_DateTime($data->{$syncrotonProperty});
} else {
$event->{$tine20Property} = $data->{$syncrotonProperty};
}
break;
}
}
// whole day events ends at 23:59:59 in Tine 2.0 but 00:00 the next day in AS
if (isset($event->is_all_day_event) && $event->is_all_day_event == 1) {
$event->dtend->subSecond(1);
}
// decode timezone data
if (isset($data->timezone)) {
$timeZoneConverter = ActiveSync_TimezoneConverter::getInstance(Tinebase_Core::getLogger(), Tinebase_Core::get(Tinebase_Core::CACHE));
try {
$timezone = $timeZoneConverter->getTimezone($data->timezone, Tinebase_Core::getUserTimezone());
$event->originator_tz = $timezone;
} catch (ActiveSync_TimezoneNotFoundException $e) {
Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . " timezone data not found " . $data->timezone);
$event->originator_tz = Tinebase_Core::getUserTimezone();
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " timezone data " . $event->originator_tz);
}
}
$this->_handleAlarms($data, $event);
$this->_handleBusyStatus($data, $event);
// event should be valid now
$event->isValid();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " eventData " . print_r($event->toArray(), true));
}
return $event;
}
示例15: testSetRelationUpdateRelatedRecord
/**
* Test if updating a related record works
*
*/
public function testSetRelationUpdateRelatedRecord()
{
$relations = $this->_object->getRelations($this->_crmId['model'], $this->_crmId['backend'], $this->_crmId['id']);
$relatedContacts = $relations->filter('related_model', 'Addressbook_Model_Contact');
$relatedContacts->sort('related_model', 'ASC');
$relatedContacts[0]->related_record->note = "Testing to update from relation set";
// NOTE: At the moment we need to set timezone to users timzone, as related records come as arrays and don't get
// their dates converted in the JSON frontends
foreach ($relations as $relation) {
$relation->setTimezone(Tinebase_Core::getUserTimezone());
$relation->related_record = $relation->related_record->toArray();
}
$this->_object->setRelations($this->_crmId['model'], $this->_crmId['backend'], $this->_crmId['id'], $relations->toArray(), FALSE, TRUE);
$updatedRelations = $this->_object->getRelations($this->_crmId['model'], $this->_crmId['backend'], $this->_crmId['id']);
$updatedConacts = $updatedRelations->filter('related_model', 'Addressbook_Model_Contact');
$updatedConacts->sort('related_model', 'ASC');
$this->assertEquals("Testing to update from relation set", $updatedConacts[0]->related_record->note);
}