本文整理汇总了PHP中DateTimeValue::advance方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValue::advance方法的具体用法?PHP DateTimeValue::advance怎么用?PHP DateTimeValue::advance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeValue
的用法示例。
在下文中一共展示了DateTimeValue::advance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEventLimits
function getEventLimits($event, $date, &$event_start, &$event_duration, &$end_modified) {
$end_modified = false;
if ($event instanceof ProjectEvent) {
$event_start = new DateTimeValue($event->getStart()->getTimestamp() + 3600 * logged_user()->getTimezone());
$event_duration = new DateTimeValue($event->getDuration()->getTimestamp() + 3600 * logged_user()->getTimezone());
} else if ($event instanceof ProjectTask) {/* @var $event ProjectTask */
$work_day_start = new DateTimeValue($date->getTimestamp());
$wsd = user_config_option('work_day_start_time');
$work_day_start->setHour(substr($wsd, 0, strpos($wsd, ':')));
$work_day_start->setMinute(substr($wsd, strpos($wsd, ':')+1));
if ($event->getStartDate() instanceof DateTimeValue && $event->getStartDate()->getTimestamp() + 3600 * logged_user()->getTimezone() >= $work_day_start->getTimestamp()) {
$event_start = new DateTimeValue($event->getStartDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
} else if (!$event->getStartDate() instanceof DateTimeValue && $event->getTimeEstimate() > 0 && $event->getDueDate() instanceof DateTimeValue) {
$event_start = new DateTimeValue($event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
$event_start->advance($event->getTimeEstimate() * -60);
} else {
$event_start = $work_day_start;
}
$work_day_end = new DateTimeValue($date->getTimestamp());
$wed = user_config_option('work_day_end_time');
$work_day_end->setHour(substr($wed, 0, strpos($wed, ':')));
$work_day_end->setMinute(substr($wed, strpos($wed, ':')+1));
if ($event->getDueDate() instanceof DateTimeValue && $event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone() <= $work_day_end->getTimestamp()) {
$event_duration = new DateTimeValue($event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
} else if (!$event->getDueDate() instanceof DateTimeValue && $event->getTimeEstimate() > 0 && $event->getStartDate() instanceof DateTimeValue) {
$event_duration = new DateTimeValue($event_start->getTimestamp());
$event_duration->advance($event->getTimeEstimate() * 60);
} else {
$event_duration = $work_day_end;
}
}
$tomorrow = new DateTimeValue($date->getTimestamp());
$tomorrow->add('d', 1);
if ($event_duration->getTimestamp() > $tomorrow->getTimestamp()) {
$event_duration = new DateTimeValue($tomorrow->getTimestamp());
$end_modified = true;
}
if ($event_start->getTimestamp() < $date->getTimestamp()) {
if (!$event->isRepetitive()) {
$event_start = new DateTimeValue($date->getTimestamp());
} else {
$event_start->setDay($date->getDay());
$event_start->setMonth($date->getMonth());
$event_start->setYear($date->getYear());
}
}
}
示例2: smarty_function_reminder
/**
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_reminder($params, &$smarty)
{
$object = array_var($params, 'object');
$reminder_date = null;
if (instance_of($object, 'ProjectObject')) {
if ($object->isCompleted()) {
return '';
}
// if
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME, $link);
$query = "select reminder_date from healingcrystals_project_object_misc where object_id='" . $object->getId() . "'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
if (!empty($info['reminder_date'])) {
$reminder_date = DateTimeValue::makeFromString($info['reminder_date']);
}
}
mysql_close($link);
} else {
return new InvalidParamError('object', $object, '$object is not expected to be an instance of ProjectObject', true);
}
// if
$offset = get_user_gmt_offset();
if (instance_of($reminder_date, 'DateTimeValue')) {
require_once SMARTY_PATH . '/plugins/modifier.datetime.php';
$date = smarty_modifier_datetime($reminder_date, 0);
// just printing date, offset is 0!
if ($reminder_date->isToday($offset)) {
return '<span class="today"><span class="number">Reminder set for: ' . lang('Today') . ' ' . date('h:i A', $reminder_date->getTimestamp()) . '</span></span>';
} elseif ($reminder_date->isYesterday($offset)) {
return '<span class="late" title="' . clean($date) . '">Reminder set for: ' . lang('<span class="number">Yesterday ' . date('h:i A', $reminder_date->getTimestamp()) . '</span>') . '</span>';
} elseif ($reminder_date->isTomorrow($offset)) {
return '<span class="upcoming" title="' . clean($date) . '">Reminder set for: <span class="number">' . lang('Tomorrow') . ' ' . date('h:i A', $reminder_date->getTimestamp()) . '</span></span>';
} else {
$now = new DateTimeValue();
$now->advance($offset);
$now = $now->beginningOfDay();
$reminder_date->beginningOfDay();
if ($reminder_date->getTimestamp() > $now->getTimestamp()) {
return '<span class="upcoming" title="' . clean($date) . '">Reminder set for: ' . date('F d, Y h:i A', $reminder_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days)', array('days' => floor(($reminder_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
} else {
return '<span class="late" title="' . clean($date) . '">Reminder set for: ' . date('F d, Y h:i A', $reminder_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days Late)', array('days' => floor(($now->getTimestamp() - $reminder_date->getTimestamp()) / 86400))) . '</span>';
}
// if
}
// if
} else {
return '';
}
// if
}
示例3: smarty_function_due
/**
* Print due on string (due in, due today or late) for a given object
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_due($params, &$smarty)
{
$object = array_var($params, 'object');
$due_date = null;
if (instance_of($object, 'ProjectObject')) {
if ($object->can_be_completed) {
if ($object->isCompleted()) {
return lang('Completed');
}
// if
$due_date = $object->getDueOn();
} else {
return '--';
}
// if
} elseif (instance_of($object, 'Invoice')) {
if ($object->getStatus() == INVOICE_STATUS_ISSUED) {
$due_date = $object->getDueOn();
} else {
return '--';
}
// if
} else {
return new InvalidParamError('object', $object, '$object is not expected to be an instance of ProjectObject or Invoice class', true);
}
// if
$offset = get_user_gmt_offset();
if (instance_of($due_date, 'DateValue')) {
require_once SMARTY_PATH . '/plugins/modifier.date.php';
$date = smarty_modifier_date($due_date, 0);
// just printing date, offset is 0!
$reminder_string_begining = '';
$reminder_string_end = '';
$sql = "select auto_email_status, email_reminder_period, email_reminder_unit, email_reminder_time from healingcrystals_project_object_misc where object_id=? and auto_email_status='1'";
$arguments = array($object->getId());
$sql = db_prepare_string($sql, $arguments);
$row = db_execute_all($sql);
if (!empty($row)) {
$entry = $row[0];
$auto_email_status = array_var($entry, 'auto_email_status');
$email_reminder_period = array_var($entry, 'email_reminder_period', '0');
$email_reminder_unit = array_var($entry, 'email_reminder_unit', 'D');
$email_reminder_time = array_var($entry, 'email_reminder_time', '06:00');
$meridian = '';
list($h, $m) = explode(':', $email_reminder_time);
$h = (int) $h;
if ($h > 12) {
$h -= 12;
$meridian = 'PM';
} elseif ($h == 12) {
$meridian = 'PM';
} elseif ($h == 0) {
$meridian = 'AM';
} else {
$meridian = 'AM';
}
$email_reminder_time = str_pad($h, 2, '0', STR_PAD_LEFT) . ':' . $m . ' ' . $meridian;
$reminder_string_begining = 'Reminder set for ' . $email_reminder_period . ' ' . ($email_reminder_unit == 'D' ? 'Day(s)' : ($email_reminder_unit == 'W' ? 'Week(s)' : ($email_reminder_unit == 'M' ? 'Month(s)' : ''))) . " from Due Date: ";
$reminder_string_end = " at " . $email_reminder_time;
}
if ($due_date->isToday($offset)) {
if (!empty($reminder_string_begining)) {
return '<span class="today">' . $reminder_string_begining . '<span class="number">' . lang('Today') . '</span>' . $reminder_string_end . '</span>';
} else {
return '<span class="today"><span class="number">' . lang('Due Today') . '</span></span>';
}
} elseif ($due_date->isYesterday($offset)) {
if (!empty($reminder_string_begining)) {
return '<span class="late" title="' . clean($date) . '">' . $reminder_string_begining . lang('<span class="number">1 Day Late</span>') . $reminder_string_end . '</span>';
} else {
return '<span class="late" title="' . clean($date) . '">' . lang('<span class="number">1 Day Late</span>') . '</span>';
}
} elseif ($due_date->isTomorrow($offset)) {
if (!empty($reminder_string_begining)) {
return '<span class="upcoming" title="' . clean($date) . '">' . $reminder_string_begining . '<span class="number">' . lang('Tomorrow') . '</span>' . $reminder_string_end . '</span>';
} else {
return '<span class="upcoming" title="' . clean($date) . '"><span class="number">' . lang('Due Tomorrow') . '</span></span>';
}
} else {
$now = new DateTimeValue();
$now->advance($offset);
$now = $now->beginningOfDay();
$due_date->beginningOfDay();
if ($due_date->getTimestamp() > $now->getTimestamp()) {
//return '<span class="upcoming" title="' . clean($date) . '">' . lang('Due in <span class="number">:days</span> Days', array('days' => floor(($due_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
//return '<span class="upcoming" title="' . clean($date) . '">' . lang('<span class="number">:days</span> Days', array('days' => floor(($due_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
if (!empty($reminder_string_begining)) {
return '<span class="upcoming" title="' . clean($date) . '">' . $reminder_string_begining . date('F d, Y', $due_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days)', array('days' => floor(($due_date->getTimestamp() - $now->getTimestamp()) / 86400))) . $reminder_string_end . '</span>';
} else {
return '<span class="upcoming" title="' . clean($date) . '">Due ' . date('F d, Y', $due_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days)', array('days' => floor(($due_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
}
} else {
//return '<span class="late" title="' . clean($date) . '">' . lang('<span class="number">:days</span> Days Late', array('days' => floor(($now->getTimestamp() - $due_date->getTimestamp()) / 86400))) . '</span>';
//.........这里部分代码省略.........
示例4: smarty_function_recurring_info
function smarty_function_recurring_info($params, &$smarty)
{
$object = array_var($params, 'object');
if (!instance_of($object, 'ProjectObject')) {
return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject', true);
}
$info = '';
$sql = "select recurring_period, recurring_period_type, recurring_period_condition, recurring_end_date from healingcrystals_project_object_misc where object_id=?";
$arguments = array($object->getId());
$sql = db_prepare_string($sql, $arguments);
$row = db_execute_all($sql);
if (!empty($row)) {
$entry = $row[0];
$recurring_period = array_var($entry, 'recurring_period');
$recurring_period_type = array_var($entry, 'recurring_period_type');
$recurring_period_condition = array_var($entry, 'recurring_period_condition');
$recurring_end_date = array_var($entry, 'recurring_end_date');
if (!empty($recurring_period) && !empty($recurring_period_type) && $recurring_period_condition) {
$info = 'Recurring every ' . $recurring_period . ' ';
switch ($recurring_period_type) {
case 'D':
$info .= ' day(s) ';
break;
case 'W':
$info .= ' week(s) ';
break;
case 'M':
$info .= ' month(s) ';
break;
}
switch ($recurring_period_condition) {
case 'after_due_date':
$info .= 'after Task is Due';
break;
case 'after_task_complete':
$info .= 'after Task has been Completed';
break;
}
$info = '<span class="recurring">' . $info . '</span>';
}
}
return $info;
if (instance_of($due_date, 'DateValue')) {
require_once SMARTY_PATH . '/plugins/modifier.date.php';
$date = smarty_modifier_date($due_date, 0);
// just printing date, offset is 0!
$reminder_string_begining = '';
$reminder_string_end = '';
$sql = "select auto_email_status, email_reminder_period, email_reminder_unit, email_reminder_time from healingcrystals_project_object_misc where object_id=?";
$arguments = array($object->getId());
$sql = db_prepare_string($sql, $arguments);
$row = db_execute_all($sql);
if (!empty($row)) {
$entry = $row[0];
$auto_email_status = array_var($entry, 'auto_email_status');
$email_reminder_period = array_var($entry, 'email_reminder_period', '0');
$email_reminder_unit = array_var($entry, 'email_reminder_unit', 'D');
$email_reminder_time = array_var($entry, 'email_reminder_time', '06:00');
$meridian = '';
list($h, $m) = explode(':', $email_reminder_time);
$h = (int) $h;
if ($h > 12) {
$h -= 12;
$meridian = 'PM';
} elseif ($h == 0) {
$meridian = 'PM';
} else {
$meridian = 'AM';
}
$email_reminder_time = str_pad($h, 2, '0', STR_PAD_LEFT) . ':' . $m . ' ' . $meridian;
$reminder_string_begining = 'Reminder set for ' . $email_reminder_period . ' ' . ($email_reminder_unit == 'D' ? 'Day(s)' : ($email_reminder_unit == 'W' ? 'Week(s)' : ($email_reminder_unit == 'M' ? 'Month(s)' : ''))) . " from Due Date: ";
$reminder_string_end = " at " . $email_reminder_time;
}
if ($due_date->isToday($offset)) {
if (!empty($reminder_string_begining)) {
return '<span class="today">' . $reminder_string_begining . '<span class="number">' . lang('Today') . '</span>' . $reminder_string_end . '</span>';
} else {
return '<span class="today"><span class="number">' . lang('Due Today') . '</span></span>';
}
} elseif ($due_date->isYesterday($offset)) {
if (!empty($reminder_string_begining)) {
return '<span class="late" title="' . clean($date) . '">' . $reminder_string_begining . lang('<span class="number">1 Day Late</span>') . $reminder_string_end . '</span>';
} else {
return '<span class="late" title="' . clean($date) . '">' . lang('<span class="number">1 Day Late</span>') . '</span>';
}
} elseif ($due_date->isTomorrow($offset)) {
if (!empty($reminder_string_begining)) {
return '<span class="upcoming" title="' . clean($date) . '">' . $reminder_string_begining . '<span class="number">' . lang('Tomorrow') . '</span>' . $reminder_string_end . '</span>';
} else {
return '<span class="upcoming" title="' . clean($date) . '"><span class="number">' . lang('Due Tomorrow') . '</span></span>';
}
} else {
$now = new DateTimeValue();
$now->advance($offset);
$now = $now->beginningOfDay();
$due_date->beginningOfDay();
if ($due_date->getTimestamp() > $now->getTimestamp()) {
//return '<span class="upcoming" title="' . clean($date) . '">' . lang('Due in <span class="number">:days</span> Days', array('days' => floor(($due_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
//return '<span class="upcoming" title="' . clean($date) . '">' . lang('<span class="number">:days</span> Days', array('days' => floor(($due_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
if (!empty($reminder_string_begining)) {
//.........这里部分代码省略.........
示例5: findUpcoming
/**
* Return upcoming objects in a given projects
*
* @param User $user
* @param Project $project
* @param array $types
* @param integer $page
* @param integer $per_page
* @return array
*/
function findUpcoming($user, $project = null, $types = null, $page = null, $per_page = null)
{
if (instance_of($project, 'Project')) {
$type_filter = ProjectUsers::getVisibleTypesFilterByProject($user, $project, $types);
} else {
$type_filter = ProjectUsers::getVisibleTypesFilter($user, array(PROJECT_STATUS_ACTIVE), $types);
}
if ($type_filter) {
$today = new DateTimeValue();
$today->advance(get_user_gmt_offset());
$newer_than = $today->endOfDay();
$conditions = array($type_filter . ' AND due_on > ? AND state >= ? AND visibility >= ? AND completed_on IS NULL', $newer_than, STATE_VISIBLE, $user->getVisibility());
if ($page !== null && $per_page !== null) {
return ProjectObjects::paginate(array('conditions' => $conditions, 'order' => 'due_on, priority DESC'), $page, $per_page);
} else {
return ProjectObjects::find(array('conditions' => $conditions, 'order' => 'due_on, priority DESC'));
}
// if
}
// if
return null;
}
示例6: DateTimeValue
function change_start_due_date()
{
$task = ProjectTasks::findById(get_id());
if (!$task->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$tochange = array_var($_GET, 'tochange', '');
if (($tochange == 'both' || $tochange == 'due') && $task->getDueDate() instanceof DateTimeValue) {
$year = array_var($_GET, 'year', $task->getDueDate()->getYear());
$month = array_var($_GET, 'month', $task->getDueDate()->getMonth());
$day = array_var($_GET, 'day', $task->getDueDate()->getDay());
$hour = array_var($_GET, 'hour', $task->getDueDate()->getHour());
$minute = array_var($_GET, 'min', $task->getDueDate()->getMinute());
$new_date = new DateTimeValue(mktime($hour, $minute, 0, $month, $day, $year));
if (isset($_GET['hour']) && isset($_GET['min'])) {
$new_date->advance(logged_user()->getTimezone() * -3600);
}
$task->setDueDate($new_date);
}
if (($tochange == 'both' || $tochange == 'start') && $task->getStartDate() instanceof DateTimeValue) {
$year = array_var($_GET, 'year', $task->getStartDate()->getYear());
$month = array_var($_GET, 'month', $task->getStartDate()->getMonth());
$day = array_var($_GET, 'day', $task->getStartDate()->getDay());
$hour = array_var($_GET, 'hour', $task->getStartDate()->getHour());
$minute = array_var($_GET, 'min', $task->getStartDate()->getMinute());
$new_date = new DateTimeValue(mktime($hour, $minute, 0, $month, $day, $year));
if (isset($_GET['hour']) && isset($_GET['min'])) {
$new_date->advance(logged_user()->getTimezone() * -3600);
}
$task->setStartDate($new_date);
}
try {
DB::beginWork();
$task->save();
DB::commit();
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error change date'));
}
// try
ajx_current("empty");
}
示例7: DateTimeValue
<th width="15%"></th>
<?php
if (user_config_option("start_monday")) {
?>
<th width='15%'></th>
<?php
}
?>
<th id="ie_scrollbar_adjust" style="display:none;width:15px;padding:0px;margin:0px;"></th>
</tr>
<?php
$date_start = new DateTimeValue($fd_ts);
$date_start->advance(-24 * 3600 * $firstday);
$ld_dow = date('w', $ld_ts);
$date_end = new DateTimeValue($ld_ts);
$date_end->advance(24 * 3600 * (6 - $ld_dow));
$milestones = ProjectMilestones::getRangeMilestones($date_start, $date_end);
if ($task_filter != "hide") {
$tasks = ProjectTasks::getRangeTasksByUser($date_start, $date_end, $user_filter != -1 ? $user : null, $task_filter);
}
if (user_config_option('show_birthdays_in_calendar')) {
$birthdays = Contacts::instance()->getRangeContactsByBirthday($date_start, $date_end, active_context_members(false));
} else {
$birthdays = array();
}
$result = array();
if ($milestones) {
$result = array_merge($result, $milestones);
}
if (isset($tasks)) {
foreach ($tasks as $task) {
示例8: smarty_function_reminder
/**
*
* @param array $params
* @param Smarty $smarty
* @return string
* HISTORY
* 22 May 2012 (SA) Ticket #841: check recurring task reminder script
*/
function smarty_function_reminder($params, &$smarty)
{
$object = array_var($params, 'object');
$reminder_date = null;
if (instance_of($object, 'ProjectObject')) {
if ($object->isCompleted()) {
return '';
}
// if
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME, $link);
//BOF:mod 20120904
/*
//EOF:mod 20120904
$query = "select * from healingcrystals_project_object_misc where object_id='" . $object->getId() . "'";
//BOF:mod 20120904
*/
$query = "select a.reminder_date, a.recurring_period, a.recurring_period_type, b.completed_on from healingcrystals_project_object_misc a inner join healingcrystals_project_objects b on a.object_id=b.id where a.object_id='" . $object->getId() . "'";
//EOF:mod 20120904
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
if (!empty($info['reminder_date']) && $info['reminder_date'] != '0000-00-00 00:00:00') {
$reminder_date = DateTimeValue::makeFromString($info['reminder_date']);
}
//BOF:mod 20120904
if (!empty($info['completed_on'])) {
//EOF:mod 20120904
if ($info['recurring_period_type'] != '' && $info['recurring_period'] != '') {
$recurring_period = $info['recurring_period'];
$recurring_period_type = $info['recurring_period_type'];
switch ($recurring_period_type) {
case 'D':
$recurring_period_type = 'day' . ($recurring_period == 1 ? '' : 's');
break;
case 'W':
$recurring_period_type = 'week' . ($recurring_period == 1 ? '' : 's');
break;
case 'M':
$recurring_period_type = 'month' . ($recurring_period == 1 ? '' : 's');
break;
case 'Y':
$recurring_period_type = 'year' . ($recurring_period == 1 ? '' : 's');
break;
}
$datetime = new DateTime();
$datetime->modify('+' . $recurring_period . ' ' . $recurring_period_type);
//BOF:mod 20120703
if (!empty($reminder_date)) {
$temp_date = $reminder_date;
}
//EOF:mod 20120703
$reminder_date = DateTimeValue::makeFromString($datetime->format('Y-m-d H:00'));
//BOF:mod 20120703
if (!empty($temp_date) && $temp_date->getTimestamp() >= time()) {
$reminder_date = $temp_date;
}
//EOF:mod 20120703
}
//BOF:mod 20120904
}
//EOF:mod 20120904
}
mysql_close($link);
} else {
return new InvalidParamError('object', $object, '$object is not expected to be an instance of ProjectObject', true);
}
// if
$offset = get_user_gmt_offset();
if (instance_of($reminder_date, 'DateTimeValue')) {
require_once SMARTY_PATH . '/plugins/modifier.datetime.php';
$date = smarty_modifier_datetime($reminder_date, 0);
// just printing date, offset is 0!
if ($reminder_date->isToday($offset)) {
return '<span class="today"><span class="number">Reminder set for: ' . lang('Today') . ' ' . date('h:i A', $reminder_date->getTimestamp()) . '</span></span>';
} elseif ($reminder_date->isYesterday($offset)) {
return '<span class="late" title="' . clean($date) . '">Reminder set for: ' . lang('<span class="number">Yesterday ' . date('h:i A', $reminder_date->getTimestamp()) . '</span>') . '</span>';
} elseif ($reminder_date->isTomorrow($offset)) {
return '<span class="upcoming" title="' . clean($date) . '">Reminder set for: <span class="number">' . lang('Tomorrow') . ' ' . date('h:i A', $reminder_date->getTimestamp()) . '</span></span>';
} else {
$now = new DateTimeValue();
$now->advance($offset);
$now = $now->beginningOfDay();
$reminder_date->beginningOfDay();
if ($reminder_date->getTimestamp() > $now->getTimestamp()) {
return '<span class="upcoming" title="' . clean($date) . '">Reminder set for: ' . date('F d, Y h:i A', $reminder_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days)', array('days' => floor(($reminder_date->getTimestamp() - $now->getTimestamp()) / 86400))) . '</span>';
} else {
return '<span class="late" title="' . clean($date) . '">Reminder set for: ' . date('F d, Y h:i A', $reminder_date->getTimestamp()) . lang(' (<span class="number">:days</span> Days Late)', array('days' => floor(($now->getTimestamp() - $reminder_date->getTimestamp()) / 86400))) . '</span>';
}
// if
}
// if
//.........这里部分代码省略.........
示例9: snoozereminder
function snoozereminder()
{
$snooze = $this->request->post('snooze');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
if ($snooze) {
/*mysql_query("update healingcrystals_project_object_misc set snooze_duration='" . (int)$snooze['duration'] . "', snooze_unit='" . $snooze['unit'] . "' where object_id='" . $this->active_task->getId() . "'");
$query = "select reminder_date from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'";
$result = mysql_query($query);
if (mysql_num_rows($result)){
$info = mysql_fetch_assoc($result);
if (!empty($info['reminder_date']) && $info['reminder_date']!='0000-00-00 00:00:00'){
$base_date = strtotime($info['reminder_date']);
$modified_date = '';
if ($snooze['duration']>0){
switch($snooze['unit']){
case 'H':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' hours', $base_date);
break;
case 'D':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' days', $base_date);
break;
case 'W':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' weeks', $base_date);
break;
case 'M':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' months', $base_date);
break;
}
if (!empty($modified_date)){
mysql_query("update healingcrystals_project_object_misc set reminder_date='" . date('Y-m-d H:i:s', $modified_date) . "' where object_id='" . $this->active_task->getId() . "'");
}
}
}
}*/
//$query = mysql_query("select now() as cur_time");
//$info = mysql_fetch_assoc($query);
//$base_date = strtotime($info['cur_time']);
$base_date = new DateTimeValue();
$base_date->advance(get_system_gmt_offset($this->logged_user), true);
//$base_date->advance(get_user_gmt_offset($this->logged_user), true);
$modified_date = '';
if ($snooze['duration'] > 0) {
switch ($snooze['unit']) {
case 'I':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' minutes', $base_date->getTimestamp());
break;
case 'H':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' hours', $base_date->getTimestamp());
break;
case 'D':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' days', $base_date->getTimestamp());
break;
case 'W':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' weeks', $base_date->getTimestamp());
break;
case 'M':
$modified_date = strtotime('+ ' . $snooze['duration'] . ' months', $base_date->getTimestamp());
break;
}
if (!empty($modified_date)) {
$sql = "select object_id from " . TABLE_PREFIX . "project_object_misc where object_id='" . $this->active_task->getId() . "'";
$result = mysql_query($sql);
if (mysql_num_rows($result)) {
mysql_query("update healingcrystals_project_object_misc set last_modified=now(), snooze_datetime='" . date('Y-m-d H:i:s', $modified_date) . "' where object_id='" . $this->active_task->getId() . "'");
} else {
mysql_query("insert into " . TABLE_PREFIX . "project_object_misc (object_id, date_added, snooze_datetime) values ('" . $this->active_task->getId() . "', now(), '" . date('Y-m-d H:i:s', $modified_date) . "')");
}
}
}
$this->redirectToUrl($this->active_task->getViewUrl() . '#task' . $this->active_task->getId());
} else {
/*$snooze = array('duration' => '', 'unit' => '');
$result = mysql_query("select snooze_duration, snooze_unit from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'");
if (mysql_num_rows($result)){
$info = mysql_fetch_assoc($result);
if (!empty($info['snooze_duration'])) $snooze['duration'] = $info['snooze_duration'];
if (!empty($info['snooze_unit'])) $snooze['unit'] = $info['snooze_unit'];
}*/
$snooze_date = 'Not Set';
$result = mysql_query("select snooze_datetime from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'");
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
if (!empty($info['snooze_datetime'])) {
$snooze_date = date('m-d-Y H:i', strtotime($info['snooze_datetime']));
}
}
}
mysql_close($link);
$this->smarty->assign(array('form_action_url' => assemble_url('project_task_snoozereminder', array('project_id' => $this->active_project->getId(), 'task_id' => $this->active_task->getId())), 'snooze_date' => $snooze_date));
}
示例10: replicateRepetitiveTaskForCalendarRawTask
function replicateRepetitiveTaskForCalendarRawTask($task, $from_date, $to_date)
{
$new_task_array = array();
if ($task['repeat_forever'] > 0 || $task['repeat_num'] > 0 || $task['repeat_end'] != EMPTY_DATETIME) {
$res = forwardRepDateRawTask($task, $from_date);
$ref_date = $res['date'];
$top_repeat_num = $task['repeat_num'] - $res['count'];
$last_repeat = $task['repeat_end'] != EMPTY_DATETIME ? new DateTimeValue(strtotime($task['repeat_end'])) : null;
if ($task['repeat_num'] > 0 && $top_repeat_num <= 0 || $last_repeat instanceof DateTimeValue && $last_repeat->getTimestamp() < $ref_date->getTimestamp()) {
return array();
}
$num_repetitions = 0;
while ($ref_date->getTimestamp() < $to_date->getTimestamp()) {
if ($task['repeat_by'] == 'start_date' && $task['start_date'] == EMPTY_DATETIME) {
return $new_task_array;
}
if ($task['repeat_by'] == 'due_date' && $task['due_date'] == EMPTY_DATETIME) {
return $new_task_array;
}
if ($task['repeat_by'] == 'start_date') {
$diff = $ref_date->getTimestamp() - strtotime($task['start_date']);
$task['start_date'] = $ref_date->toMySQL();
if ($task['due_date'] != EMPTY_DATETIME) {
$dd = new DateTimeValue(strtotime($task['due_date']));
$dd->advance($diff);
$task['due_date'] = $dd->toMySQL();
}
} else {
if ($task['repeat_by'] == 'due_date') {
$diff = $ref_date->getTimestamp() - strtotime($task['due_date']);
$task['due_date'] = $ref_date->toMySQL();
if ($task['start_date'] != EMPTY_DATETIME) {
$sd = new DateTimeValue(strtotime($task['start_date']));
$sd->advance($diff);
$task['start_date'] = $sd->toMySQL();
}
}
}
$new_task = array();
foreach ($task as $k => $v) {
$new_task[$k] = $v;
}
$new_due_date = null;
$new_st_date = null;
if ($task['start_date'] != EMPTY_DATETIME) {
$new_st_date = new DateTimeValue(strtotime($task['start_date']));
}
if ($task['due_date'] != EMPTY_DATETIME) {
$new_due_date = new DateTimeValue(strtotime($task['due_date']));
}
if ($task['repeat_d'] > 0) {
if ($new_st_date instanceof DateTimeValue) {
$new_st_date = $new_st_date->add('d', $task['repeat_d']);
}
if ($new_due_date instanceof DateTimeValue) {
$new_due_date = $new_due_date->add('d', $task['repeat_d']);
}
$ref_date->add('d', $task['repeat_d']);
} else {
if ($task['repeat_m'] > 0) {
if ($new_st_date instanceof DateTimeValue) {
$new_st_date = $new_st_date->add('M', $task['repeat_m']);
}
if ($new_due_date instanceof DateTimeValue) {
$new_due_date = $new_due_date->add('M', $task['repeat_m']);
}
$ref_date->add('M', $task['repeat_m']);
} else {
if ($task['repeat_y'] > 0) {
if ($new_st_date instanceof DateTimeValue) {
$new_st_date = $new_st_date->add('y', $task['repeat_y']);
}
if ($new_due_date instanceof DateTimeValue) {
$new_due_date = $new_due_date->add('y', $task['repeat_y']);
}
$ref_date->add('y', $task['repeat_y']);
}
}
}
if ($new_st_date instanceof DateTimeValue) {
$new_task['start_date'] = $new_st_date->toMySQL();
}
if ($new_due_date instanceof DateTimeValue) {
$new_task['due_date'] = $new_due_date->toMySQL();
}
$num_repetitions++;
if ($top_repeat_num > 0 && $top_repeat_num == $num_repetitions) {
break;
}
if ($last_repeat instanceof DateTimeValue && $last_repeat->getTimestamp() < $ref_date->getTimestamp()) {
break;
}
$new_task_array[] = $new_task;
$task = array();
foreach ($new_task as $k => $v) {
$task[$k] = $v;
}
}
} else {
return array($task);
//.........这里部分代码省略.........