本文整理汇总了PHP中CDate::isWorkingDay方法的典型用法代码示例。如果您正苦于以下问题:PHP CDate::isWorkingDay方法的具体用法?PHP CDate::isWorkingDay怎么用?PHP CDate::isWorkingDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDate
的用法示例。
在下文中一共展示了CDate::isWorkingDay方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remind
/**
* Called by the Event Queue processor to process a reminder
* on a task.
* @access public
* @param string $module Module name (not used)
* @param string $type Type of event (not used)
* @param integer $id ID of task being reminded
* @param integer $owner Originator of event
* @param mixed $args event-specific arguments.
* @return mixed true, dequeue event, false, event stays in queue.
-1, event is destroyed.
*/
function remind($module, $type, $id, $owner, &$args)
{
global $locale_char_set, $AppUI;
$q = new DBQuery();
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
// If we don't have preferences set for these, use ISO defaults.
if (!$df) {
$df = '%Y-%m-%d';
}
if (!$tf) {
$tf = '%H:%m';
}
$df .= ' ' . $tf;
// At this stage we won't have an object yet
if (!$this->load($id)) {
return -1;
// No point it trying again later.
}
$this->htmlDecode();
// Only remind on working days.
$today = new CDate();
if (!$today->isWorkingDay()) {
return true;
}
// Check if the task is completed
if ($this->task_percent_complete == 100) {
return -1;
}
// Grab the assignee list
$q->addTable('user_tasks', 'ut');
$q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
$q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
$q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
$q->addWhere('ut.task_id = ' . $id);
$contacts = $q->loadHashList('contact_id');
$q->clear();
// Now we also check the owner of the task, as we will need
// to notify them as well.
$owner_is_not_assignee = false;
$q->addTable('users', 'u');
$q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
$q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
$q->addWhere('u.user_id = ' . $this->task_owner);
if ($q->exec(ADODB_FETCH_NUM)) {
list($owner_contact, $owner_first_name, $owner_last_name, $owner_email) = $q->fetchRow();
if (!isset($contacts[$owner_contact])) {
$owner_is_not_assignee = true;
$contacts[$owner_contact] = array('contact_id' => $owner_contact, 'contact_first_name' => $owner_first_name, 'contact_last_name' => $owner_last_name, 'contact_email' => $owner_email);
}
}
$q->clear();
// build the subject line, based on how soon the
// task will be overdue.
$starts = new CDate($this->task_start_date);
$expires = new CDate($this->task_end_date);
$now = new CDate();
$diff = $expires->dateDiff($now);
$prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW);
if ($diff == 0) {
$msg = $AppUI->_('TODAY', UI_OUTPUT_RAW);
} else {
if ($diff == 1) {
$msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW);
} else {
if ($diff < 0) {
$msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
$prefix = $AppUI->_('Task', UI_OUTPUT_RAW);
} else {
$msg = $AppUI->_(array($diff, 'DAYS'));
}
}
}
$q->addTable('projects');
$q->addQuery('project_name');
$q->addWhere('project_id = ' . $this->task_project);
$project_name = htmlspecialchars_decode($q->loadResult());
$q->clear();
$subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name;
$body = $AppUI->_('Task Due', UI_OUTPUT_RAW) . ': ' . $msg . "\n" . $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $project_name . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': ' . $starts->format($df) . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': ' . $expires->format($df) . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . DP_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . '&reminded=1' . "\n\n" . $AppUI->_('Resources', UI_OUTPUT_RAW) . ":\n";
foreach ($contacts as $contact) {
if ($owner_is_not_assignee || $contact['contact_id'] != $owner_contact) {
$body .= $contact['contact_first_name'] . ' ' . $contact['contact_last_name'] . ' <' . $contact['contact_email'] . ">\n";
}
}
$body .= "\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ":\n" . $this->task_description . "\n";
$mail = new Mail();
foreach ($contacts as $contact) {
//.........这里部分代码省略.........
示例2: CDate
<?php
$total_sum = 0;
foreach ($projects as $id => $project_name) {
?>
<tr>
<td style="background:#8AC6FF; text-align:right;"><?php
echo $project_name;
?>
</td>
<td style="background:#8AC6FF;"> </td>
<?php
$date = new CDate($start_report);
$sum_project = 0;
for ($i = 0; $i < $start_report->getDaysInMonth(); $i++) {
if ($date->isWorkingDay()) {
?>
<td style="background:#8AC6FF;text-align:center;" align="right">
<?php
} else {
?>
<td style="background:#EF95CB;text-align:center;" align="right">
<?php
}
?>
<?php
if (isset($projects_hours[$id][$date->format('%Y-%m-%d')])) {
printf("%.1f", $projects_hours[$id][$date->format('%Y-%m-%d')]);
$sum_project += $projects_hours[$id][$date->format('%Y-%m-%d')];
}
示例3: calc_duration
function calc_duration($start_date = null, $end_date = null)
{
//
global $AppUI;
$cal_day_start = intval(dPgetConfig('cal_day_start'));
$cal_day_end = intval(dPgetConfig('cal_day_end'));
$count = new CDate($start_date);
$end = new CDate($end_date);
$total_dias = 0;
while ($count <= $end) {
if ($count->isWorkingDay()) {
$total_dias++;
}
$count->addDays(1);
}
return $total_dias;
}
示例4: clash_process
function clash_process()
{
global $AppUI, $do_include;
$obj =& new CEvent();
$obj->bind($_SESSION['add_event_post']);
$attendees = $_SESSION['add_event_attendees'];
$users = array();
if (isset($attendees) && $attendees) {
$users = explode(',', $attendees);
}
array_push($users, $obj->event_owner);
// First remove any duplicates
$users = array_unique($users);
// Now remove any null entries, so implode doesn't create a dud SQL
// Foreach is safer as it works on a copy of the array.
foreach ($users as $key => $user) {
if (!$user) {
unset($users[$key]);
}
}
$start_date =& new CDate($_POST['event_start_date'] . "000000");
$end_date =& new CDate($_POST['event_end_date'] . "235959");
// First find any events in the range requested.
$event_list = $obj->getEventsInWindow($start_date->format(FMT_DATETIME_MYSQL), $end_date->format(FMT_DATETIME_MYSQL), (int) ($_POST['start_time'] / 100), (int) ($_POST['end_time'] / 100), $users);
$event_start_date =& new CDate($_POST['event_start_date'] . $_POST['start_time']);
$event_end_date =& new CDate($_POST['event_end_date'] . $_POST['end_time']);
if (!$event_list || !count($event_list)) {
// First available date/time is OK, seed addEdit with the details.
$obj->event_start_date = $event_start_date->format(FMT_DATETIME_MYSQL);
$obj->event_end_date = $event_end_date->format(FMT_DATETIME_MYSQL);
$_SESSION['add_event_post'] = get_object_vars($obj);
$AppUI->setMsg('No clashes in suggested timespan', UI_MSG_OK);
$_SESSION['event_is_clash'] = true;
$_GET['event_id'] = $obj->event_id;
$do_include = DP_BASE_DIR . "/modules/calendar/addedit.php";
return;
}
// Now we grab the events, in date order, and compare against the
// required start and end times.
// Working in 30 minute increments from the start time, and remembering
// the end time stipulation, find the first hole in the times.
// Determine the duration in hours/minutes.
$start_hour = (int) ($_POST['start_time'] / 10000);
$start_minutes = (int) ($_POST['start_time'] % 10000 / 100);
$start_time = $start_hour * 60 + $start_minutes;
$end_hour = (int) ($_POST['end_time'] / 10000);
$end_minutes = (int) ($_POST['end_time'] % 10000 / 100);
$end_time = $end_hour * 60 + $end_minutes - $_POST['duration'];
// First, build a set of "slots" that give us the duration
// and start/end times we need
$first_day = $start_date->format('%E');
$end_day = $end_date->format('%E');
$days_between = $end_day + 1 - $first_day;
$oneday =& new Date_Span(array(1, 0, 0, 0));
$slots = array();
$slot_count = 0;
$first_date = new CDate($start_date);
for ($i = 0; $i < $days_between; $i++) {
if ($first_date->isWorkingDay()) {
$slots[$i] = array();
for ($j = $start_time; $j <= $end_time; $j += 30) {
$slot_count++;
$slots[$i][] = array('date' => $first_date->format('%Y-%m-%d'), 'start_time' => $j, 'end_time' => $j + $_POST['duration'], 'committed' => false);
}
}
$first_date->addSpan($oneday);
}
// Now process the events list
foreach ($event_list as $event) {
$sdate = new CDate($event['event_start_date']);
$edate = new CDate($event['event_end_date']);
$sday = $sdate->format('%E');
$day_offset = $sday - $first_day;
// Now find the slots on that day that match
list($syear, $smonth, $sday, $shour, $sminute, $ssecond) = sscanf($event['event_start_date'], "%4d-%2d-%2d %2d:%2d:%2d");
list($eyear, $emonth, $eday, $ehour, $eminute, $esecond) = sscanf($event['event_start_date'], "%4d-%2d-%2d %2d:%2d:%2d");
$start_mins = $shour * 60 + $sminute;
$end_mins = $ehour * 60 + $eminute;
if (isset($slots[$day_offset])) {
foreach ($slots[$day_offset] as $key => $slot) {
if ($start_mins <= $slot['end_time'] && $end_mins >= $slot['start_time']) {
$slots[$day_offset][$key]['committed'] = true;
}
}
}
}
// Third pass through, find the first uncommitted slot;
foreach ($slots as $day_offset => $day_slot) {
foreach ($day_slot as $slot) {
if (!$slot['committed']) {
$hour = (int) ($slot['start_time'] / 60);
$min = $slot['start_time'] % 60;
$ehour = (int) ($slot['end_time'] / 60);
$emin = $slot['end_time'] % 60;
$obj->event_start_date = $slot['date'] . " " . sprintf("%02d:%02d:00", $hour, $min);
$obj->event_end_date = $slot['date'] . " " . sprintf("%02d:%02d:00", $ehour, $emin);
$_SESSION['add_event_post'] = get_object_vars($obj);
$AppUI->setMsg('First available time slot', UI_MSG_OK);
$_SESSION['event_is_clash'] = true;
$_GET['event_id'] = $obj->event_id;
//.........这里部分代码省略.........
示例5: clash_process
function clash_process()
{
global $AppUI, $do_include;
$obj =& new CEvent();
$obj->bind($_SESSION['add_event_post']);
$attendees = $_SESSION['add_event_attendees'];
$users = array();
if (isset($attendees) && $attendees) {
$users = explode(',', $attendees);
}
array_push($users, $obj->event_owner);
// First remove any duplicates
$users = array_unique($users);
// Now remove any null entries, so implode doesn't create a dud SQL
// Foreach is safer as it works on a copy of the array.
foreach ($users as $key => $user) {
if (!$user) {
unset($users[$key]);
}
}
// First find any events in the range requested.
$start_date = new CDate($_POST['event_start_date'] . $_POST['start_time']);
$end_date = new CDate($_POST['event_start_date'] . $_POST['start_time']);
$end_date->addSeconds($_POST['duration'] * 60);
$final_date = new CDate($_POST['event_end_date'] . $_POST['end_time']);
$original_event_start = $obj->event_start_date;
$original_event_end = $obj->event_end_date;
$user_list = implode(',', $users);
// Now we grab the events, in date order, and compare against the
// required start and end times.
// Working in 30 minute increments from the start time, and remembering
// the end time stipulation, find the first hole in the times.
// Determine the duration in hours/minutes.
$start_hour = (int) ($_POST['start_time'] / 10000);
$start_minutes = (int) ($_POST['start_time'] % 10000 / 100);
$start_min_offset = $start_hour * 60 + $start_minutes;
$end_hour = (int) ($_POST['end_time'] / 10000);
$end_minutes = (int) ($_POST['end_time'] % 10000 / 100);
$end_min_offset = $end_hour * 60 + $end_minutes - $_POST['duration'];
// First, build a set of "slots" that give us the duration
// and start/end times we need
$first_day = $start_date->format('%E');
$end_day = $final_date->format('%E');
$oneday =& new Date_Span(array(1, 0, 0, 0));
$slots = array();
$curr_date = new CDate($start_date);
$curr_date->setTime(0, 0, 0);
$inc = intval(dPgetConfig('cal_day_increment')) ? intval(dPgetConfig('cal_day_increment')) : 30;
for ($i = 0; $i <= $end_day - $first_day; $i++) {
if ($curr_date->isWorkingDay()) {
for ($j = $start_min_offset; $j <= $end_min_offset; $j += $inc) {
$is_committed = false;
$slot_start_date = new CDate($curr_date);
$slot_start_date->addSeconds($j * 60);
$slot_end_date = new CDate($slot_start_date);
$slot_end_date->addSeconds($_POST['duration'] * 60);
$obj->event_start_date = $slot_start_date->format('%Y-%m-%d %T');
$obj->event_end_date = $slot_end_date->format('%Y-%m-%d %T');
if (!($clash = $obj->checkClash($user_list))) {
$_SESSION['add_event_post'] = get_object_vars($obj);
$AppUI->setMsg('First available time slot', UI_MSG_OK);
$_SESSION['event_is_clash'] = true;
$_GET['event_id'] = $obj->event_id;
$do_include = DP_BASE_DIR . '/modules/calendar/addedit.php';
return;
}
}
}
$curr_date->addSpan($oneday);
$curr_date->setTime(0, 0, 0);
}
// If we get here we have found no available slots
$obj->event_start_date = $original_event_start;
$obj->event_end_date = $original_event_end;
clear_clash();
$AppUI->setMsg('No times match your parameters', UI_MSG_ALERT);
$AppUI->redirect();
}