本文整理汇总了PHP中CDate::setDate方法的典型用法代码示例。如果您正苦于以下问题:PHP CDate::setDate方法的具体用法?PHP CDate::setDate怎么用?PHP CDate::setDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDate
的用法示例。
在下文中一共展示了CDate::setDate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strpos
\', \'editFrm\', \'<?php
echo strpos($cf, '%p') !== false ? '12' : '24';
?>
\', true)" >';
htmltxt +=' <img src="<?php
echo w2PfindImage('calendar.gif', $m);
?>
" width="24" height="12" border="0" />';
htmltxt +='</a>';
oCell.innerHTML =htmltxt;
newtr.appendChild(oCell);
oCell = document.createElement('td');
htmltxt = '';
// htmltxt +='<input type='hidden' id='add_task_duration_'+line_nr+'' name='add_task_duration_'+line_nr+'' value='' />';
htmltxt +='<input type="hidden" id="add_task_end_date_'+line_nr+'" name="add_task_end_date_'+line_nr+'" value="<?php
$today->setDate($today->getTime() + 60 * 60, DATE_FORMAT_UNIXTIME);
echo $today->format(FMT_TIMESTAMP);
?>
" />';
htmltxt +='<input type="text" onchange="setDate(\'editFrm\', \'end_date_'+line_nr+'\');" class="text" style="width:130px;" id="end_date_'+line_nr+'" name="end_date_'+line_nr+'" value="<?php
echo $today->format($cf);
?>
" />';
htmltxt +='<a href="javascript: void(0);" onclick="return showCalendar(\'end_date_'+line_nr+'\', \'<?php
echo $cf;
?>
\', \'editFrm\', \'<?php
echo strpos($cf, '%p') !== false ? '12' : '24';
?>
\', true)" >';
htmltxt +=' <img src="<?php
示例2: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
function importTasks($from_project_id, $scale_project = false)
{
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $from_project_id);
$sql = $q->prepare();
$q->clear();
$tasks = array_flip(db_loadColumn($sql));
//Pristine Start and End Dates of Source and Destination Projects
$origStartDate = new CDate($origProject->project_start_date);
$origEndDate = new CDate($origProject->project_end_date);
$destStartDate = new CDate($this->project_start_date);
$destEndDate = new CDate($this->project_end_date);
$dateOffset = $destStartDate->dateDiff($origStartDate);
//Check that we have enough information to scale properly
//(i.e. no information is missing or "zero")
if (empty($origProject->project_start_date) || empty($origProject->project_end_date) || empty($this->project_start_date) || empty($this->project_end_date) || $origProject->project_start_date == '0000-00-00 00:00:00' || $origProject->project_end_date == '0000-00-00 00:00:00' || $this->project_start_date == '0000-00-00 00:00:00' || $this->project_end_date == '0000-00-00 00:00:00') {
$scale_project = false;
}
if ($scale_project) {
//get ratio for scaling, protect from division by 0
$ratio = (abs($destEndDate->dateDiff($destStartDate)) + 1) / (abs($origEndDate->dateDiff($origStartDate)) + 1);
}
// Old dependencies array from imported tasks
$deps = array();
// New dependencies array for new copies of imported tasks
$newDeps = array();
// Old2New task ID array
$taskXref = array();
// New task ID to old parent array
$nid2op = array();
// Copy each task into this project and get their deps
foreach ($tasks as $orig => $void) {
$objTask = new CTask();
$objTask->load($orig);
// Grab the old parent id
$oldParent = (int) $objTask->task_parent;
$deps[$orig] = $objTask->getDependencies();
$destTask = $objTask->copy($this->project_id, 0);
$nid2op[$destTask->task_id] = $oldParent;
$tasks[$orig] = $destTask;
$taskXref[$orig] = (int) $destTask->task_id;
}
// Build new dependencies array
foreach ($deps as $odkey => $od) {
$ndt = '';
$ndkey = $taskXref[$odkey];
$odep = explode(',', $od);
foreach ($odep as $odt) {
$ndt = $ndt . $taskXref[$odt] . ',';
}
$ndt = rtrim($ndt, ',');
$newDeps[$ndkey] = $ndt;
}
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $this->project_id);
$tasks = $q->loadColumn();
// Update dates based on new project's start date.
$origDate = new CDate($origProject->project_start_date);
$origStartHour = new CDate($this->project_start_date);
$destDate = new CDate($this->project_start_date);
foreach ($tasks as $task_id) {
$newTask = new CTask();
$newTask->load($task_id);
if (in_array($task_id, $taskXref)) {
$task_date_vars = array('task_start_date', 'task_end_date');
//Adjust task dates based on calculated offsets
foreach ($task_date_vars as $my_date) {
if (!empty($newTask->{$my_date}) && $newTask->{$my_date} != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->{$my_date});
$origStartHour->setDate($newTask->{$my_date});
$origStartHour->setTime(intval(dPgetConfig('cal_day_start')));
$destDate->setDate($newTask->{$my_date});
$destDate->addDays($dateOffset);
if ($scale_project) {
$offsetAdd = round($origDate->dateDiff($origStartDate) * $ratio) - $origDate->dateDiff($origStartDate);
$destDate->addDays($offsetAdd);
$hours_in = $origStartHour->calcDuration($origDate);
$offsetAddHours = round($hours_in * $ratio) - $hours_in;
if ($offsetAddHours % dPgetConfig('daily_working_hours')) {
$destDate->addDuration($offsetAddHours);
}
}
$destDate = $destDate->next_working_day();
$newTask->{$my_date} = $destDate->format(FMT_DATETIME_MYSQL);
}
}
//Adjust durration to scale
if ($scale_project) {
$newTask->task_duration = round($newTask->task_duration * $ratio, 2);
//.........这里部分代码省略.........
示例3: formatTime
function formatTime($uts)
{
global $AppUI;
$date = new CDate();
$date->setDate($uts, DATE_FORMAT_UNIXTIME);
return $date->format($AppUI->getPref('SHDATEFORMAT'));
}
示例4: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
function importTasks($from_project_id)
{
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $from_project_id);
$sql = $q->prepare();
$q->clear();
$tasks = array_flip(db_loadColumn($sql));
$origDate = new CDate($origProject->project_start_date);
$destDate = new CDate($this->project_start_date);
$timeOffset = $destDate->getTime() - $origDate->getTime();
// Dependencies array
$deps = array();
// Copy each task into this project and get their deps
foreach ($tasks as $orig => $void) {
$objTask = new CTask();
$objTask->load($orig);
$destTask = $objTask->copy($this->project_id);
$tasks[$orig] = $destTask;
$deps[$orig] = $objTask->getDependencies();
}
// Fix record integrity
foreach ($tasks as $old_id => $newTask) {
// Fix parent Task
// This task had a parent task, adjust it to new parent task_id
if ($newTask->task_id != $newTask->task_parent) {
$newTask->task_parent = $tasks[$newTask->task_parent]->task_id;
}
// Fix task start date from project start date offset
$origDate->setDate($newTask->task_start_date);
$destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME);
$destDate = $destDate->next_working_day();
$newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// Fix task end date from start date + work duration
//$newTask->calc_task_end_date();
if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->task_end_date);
$destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME);
$destDate = $destDate->next_working_day();
$newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
}
// Dependencies
if (!empty($deps[$old_id])) {
$oldDeps = explode(',', $deps[$old_id]);
// New dependencies array
$newDeps = array();
foreach ($oldDeps as $dep) {
$newDeps[] = $tasks[$dep]->task_id;
}
// Update the new task dependencies
$csList = implode(',', $newDeps);
$newTask->updateDependencies($csList);
}
// end of update dependencies
$newTask->store();
}
// end Fix record integrity
}
示例5: CDate
$start_day->setDate($date, DATE_FORMAT_ISO);
$today_weekday = $start_day->getDayOfWeek();
//roll back to the first day of that week, regardless of what day was specified
$rollover_day = '0';
$new_start_offset = $rollover_day - $today_weekday;
$start_day->addDays($new_start_offset);
//last day of that week, add 6 days
$end_day = new CDate();
$end_day->copy($start_day);
$end_day->addDays(6);
//set that to just midnight so as to grab the whole day
$date = $start_day->format("%Y-%m-%d") . " 00:00:00";
$start_day->setDate($date, DATE_FORMAT_ISO);
//set that to just before midnight so as to grab the whole day
$date = $end_day->format("%Y-%m-%d") . " 23:59:59";
$end_day->setDate($date, DATE_FORMAT_ISO);
$start_month = $start_day->format("%b");
$end_month = $end_day->format("%b");
$start_date = $start_day->format("%e");
$end_date = $end_day->format("%e");
$start_data_pretty[$i] = "{$start_month} {$start_date}-" . ($start_month == $end_month ? $end_date : "{$end_month} {$end_date}");
$start_data_linkable[$i] = urlencode($start_day->getDate());
// $starts[$i] = $start_day->format($df);
$sql = "\n\t\t\tSELECT\n\t\t\t\ttask_log_creator,\n\t\t\t\tsum(task_log_hours) as hours\n\t\t\tFROM\n\t\t\t\ttask_log\n\t\t\tWHERE\n\t\t\t\ttask_log_date >= '" . $start_day->format(FMT_DATETIME_MYSQL) . "' \n\t\t\t\tAND task_log_date <= '" . $end_day->format(FMT_DATETIME_MYSQL) . "'\n\t\t\t\tAND task_log_creator in (" . implode(", ", $ids) . ")\n\t\t\tGROUP BY\n\t\t\t\ttask_log_creator\n\t\t\t";
//print "<pre>$sql</pre>";
$result = db_loadList($sql);
foreach ($result as $row) {
$people[$row['task_log_creator']][$i] = $row['hours'];
}
$date = $start_day->format("%Y-%m-%d") . " 12:00:00";
$start_day->setDate($date, DATE_FORMAT_ISO);
示例6: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
function importTasks($from_project_id)
{
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $from_project_id);
$sql = $q->prepare();
$q->clear();
$tasks = array_flip(db_loadColumn($sql));
$origDate = new CDate($origProject->project_start_date);
$destDate = new CDate($this->project_start_date);
$timeOffset = $destDate->getTime() - $origDate->getTime();
$objTask = new CTask();
// Dependencies array
$deps = array();
// Copy each task into this project and get their deps, y tambien copia los usuarios asignados
foreach ($tasks as $orig => $void) {
$objTask->load($orig);
$destTask = $objTask->copy($this->project_id);
$tasks[$orig] = $destTask;
if ($this->project_company == $origProject->project_company) {
// guarda en user_tasks todos los usuarios asignados a la tarea original, solo si this y
// origProy pertenecen a la misma compañía.
$sql = "select * from user_tasks where task_id = {$orig}";
$rows = db_LoadList($sql);
foreach ($rows as $row) {
$sql2 = "INSERT INTO user_tasks (user_id, user_type, task_id, perc_assignment, user_task_priority) \n\t\t\t\t\t\t\t\tVALUES (" . $row['user_id'] . "," . $row['user_type'] . "," . $destTask->task_id . "," . $row['perc_assignment'] . "," . $row['user_task_priority'] . ")";
db_exec($sql2);
}
}
$deps[$orig] = $objTask->getDependencies();
}
// Fix record integrity
foreach ($tasks as $old_id => $newTask) {
// Fix parent Task
// This task had a parent task, adjust it to new parent task_id
if ($newTask->task_id != $newTask->task_parent) {
$newTask->task_parent = $tasks[$newTask->task_parent]->task_id;
}
// Fix task start date from project start date offset
$origDate->setDate($newTask->task_start_date);
$destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME);
$destDate = $newTask->next_working_day($destDate);
$newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// Fix task end date from start date + work duration
$newTask->calc_task_end_date();
// Dependencies
if (!empty($deps[$old_id])) {
$oldDeps = explode(',', $deps[$old_id]);
// New dependencies array
$newDeps = array();
foreach ($oldDeps as $dep) {
$newDeps[] = $tasks[$dep]->task_id;
}
// Update the new task dependencies
$csList = implode(',', $newDeps);
$newTask->updateDependencies($csList);
}
// end of update dependencies
//Asignados
$newTask->store();
}
// end Fix record integrity
}
示例7: check
public function check()
{
// ensure changes to check boxes and select lists are honoured
$this->event_private = intval($this->event_private);
$this->event_type = intval($this->event_type);
$this->event_cwd = intval($this->event_cwd);
//If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date
//so that the event starts recurring from the start day onwards n times after the start date for the period given
//Meaning: The event end date day is useless as far as recurring events are concerned.
if ($this->event_recurs) {
$start_date = new CDate($this->event_start_date);
$end_date = new CDate($this->event_end_date);
$hour = $end_date->getHour();
$minute = $end_date->getMinute();
$end_date->setDate($start_date->getDate());
$end_date->setHour($hour);
$end_date->setMinute($minute);
$this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
}
return null;
}
示例8: CDate
function update_dep_dates($task_id)
{
global $tracking_dynamics;
$destDate = new CDate();
$newTask = new CTask();
$newTask->load($task_id);
// Do not update tasks that are not tracking dependencies
if (!in_array($newTask->task_dynamic, $tracking_dynamics)) {
return;
}
// start date, based on maximal dep end date
$destDate->setDate($this->get_deps_max_end_date($newTask));
$destDate = $this->next_working_day($destDate);
$new_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// end date, based on start date and work duration
$newTask->task_start_date = $new_start_date;
$newTask->calc_task_end_date();
$new_end_date = $newTask->task_end_date;
$sql = "UPDATE tasks\n\t\tSET\n\t\t\t\ttask_start_date = '{$new_start_date}',\n\t\t\t\ttask_end_date = '{$new_end_date}'\n\t\t\tWHERE \ttask_dynamic != '1' AND task_id = {$task_id}\n\t\t";
db_exec($sql);
if ($newTask->task_parent != $newTask->task_id) {
$newTask->updateDynamics();
}
return;
}
示例9: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
function importTasks($from_project_id)
{
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $from_project_id);
$sql = $q->prepare();
$q->clear();
$tasks = array_flip(db_loadColumn($sql));
$origDate = new CDate($origProject->project_start_date);
$destDate = new CDate($this->project_start_date);
$dateOffset = $destDate->dateDiff($origDate);
// Old dependencies array from imported tasks
$deps = array();
// New dependencies array for new copies of imported tasks
$newDeps = array();
// Old2New task ID array
$taskXref = array();
// New task ID to old parent array
$nid2op = array();
// Copy each task into this project and get their deps
foreach ($tasks as $orig => $void) {
$objTask = new CTask();
$objTask->load($orig);
// Grab the old parent id
$oldParent = (int) $objTask->task_parent;
$deps[$orig] = $objTask->getDependencies();
$destTask = $objTask->copy($this->project_id, 0);
$nid2op[$destTask->task_id] = $oldParent;
$tasks[$orig] = $destTask;
$taskXref[$orig] = (int) $destTask->task_id;
}
// Build new dependencies array
foreach ($deps as $odkey => $od) {
$ndt = '';
$ndkey = $taskXref[$odkey];
$odep = explode(',', $od);
foreach ($odep as $odt) {
$ndt = $ndt . $taskXref[$odt] . ',';
}
$ndt = rtrim($ndt, ',');
$newDeps[$ndkey] = $ndt;
}
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $this->project_id);
$tasks = $q->loadColumn();
// Update dates based on new project's start date.
foreach ($tasks as $task_id) {
$newTask = new CTask();
$newTask->load($task_id);
if (in_array($task_id, $taskXref)) {
// Fix task start date from project start date offset
$origDate->setDate($newTask->task_start_date);
$destDate->setDate($newTask->task_start_date);
$destDate->addDays($dateOffset);
$destDate = $destDate->next_working_day();
$newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// Fix task end date from start date + work duration
//$newTask->calc_task_end_date();
if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->task_end_date);
$destDate->setDate($newTask->task_end_date);
$destDate->addDays($dateOffset);
$destDate = $destDate->next_working_day();
$newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
}
$newTask->task_parent = $taskXref[$nid2op[$newTask->task_id]];
$newTask->store();
$newTask->updateDependencies($newDeps[$task_id]);
}
// end check if imported task
$newTask->store();
}
// end Fix record integrity
}
示例10: importTasks
/** Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
**/
function importTasks($from_project_id)
{
// Load the original
$origProject = new CProject();
$origProject->load($from_project_id);
$q = new DBQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $from_project_id);
$q->addWhere('task_id = task_parent');
$sql = $q->prepare();
$q->clear();
$tasks = array_flip(db_loadColumn($sql));
$origDate = new CDate($origProject->project_start_date);
$destDate = new CDate($this->project_start_date);
$timeOffset = $destDate->getTime() - $origDate->getTime();
// Dependencies array
$deps = array();
// Copy each task into this project and get their deps
foreach ($tasks as $orig => $void) {
$objTask = new CTask();
$objTask->load($orig);
$destTask = $objTask->deepCopy($this->project_id);
$tasks[$orig] = $destTask;
$deps[$orig] = $objTask->getDependencies();
}
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . $this->project_id);
$tasks = $q->loadColumn();
// Update dates based on new project's start date.
$newTask = new CTask();
foreach ($tasks as $task_id) {
$newTask->load($task_id);
// Fix task start date from project start date offset
$origDate->setDate($newTask->task_start_date);
$destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME);
$destDate = $destDate->next_working_day();
$newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// Fix task end date from start date + work duration
//$newTask->calc_task_end_date();
if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->task_end_date);
$destDate->setDate($origDate->getTime() + $timeOffset, DATE_FORMAT_UNIXTIME);
$destDate = $destDate->next_working_day();
$newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
}
$newTask->store();
}
// end Fix record integrity
}