예제 #1
0
 /**
  * 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.
  */
 public function remind($module, $type, $id, $owner, &$args)
 {
     global $locale_char_set, $AppUI;
     $q = new w2p_Database_Query();
     // 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 w2p_Utilities_Date();
     if (!$today->isWorkingDay()) {
         return true;
     }
     // Check if the task is completed
     if ($this->task_percent_complete == 100) {
         return -1;
     }
     $contacts = $this->getAssigned();
     // 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->addJoin('contacts', 'c', 'c.contact_id = u.user_contact', 'inner');
     $q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
     $q->addWhere('u.user_id = ' . (int) $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 w2p_Utilities_Date($this->task_start_date);
     $expires = new w2p_Utilities_Date($this->task_end_date);
     $now = new w2p_Utilities_Date();
     $diff = $expires->dateDiff($now);
     $diff *= w2p_Utilities_Date::compare($expires, $now);
     $prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW);
     if ($diff == 0) {
         $msg = $AppUI->_('TODAY', UI_OUTPUT_RAW);
     } elseif ($diff == 1) {
         $msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW);
     } elseif ($diff < 0) {
         $msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
         $prefix = $AppUI->_('Task', UI_OUTPUT_RAW);
     } else {
         $msg = $AppUI->_(array($diff, 'DAYS'));
     }
     $project = new CProject();
     $project_name = $project->load($this->task_project)->project_name;
     // Check to see that the project is both active and not a template
     if (!$project->project_active || $project->project_status == w2PgetConfig('template_projects_status_id', 0)) {
         return -1;
     }
     $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) . ': START-TIME' . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': END-TIME' . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_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 || $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 w2p_Utilities_Mail();
     $mail->Subject($subject, $locale_char_set);
     foreach ($contacts as $contact) {
         $user_id = CUser::getUserIdByContactID($contact['contact_id']);
         $AppUI->loadPrefs($user_id);
         $df = $AppUI->getPref('DISPLAYFORMAT');
         $tz = $AppUI->getPref('TIMEZONE');
         $body = str_replace('START-TIME', $starts->convertTZ($tz)->format($df), $body);
         $body = str_replace('END-TIME', $expires->convertTZ($tz)->format($df), $body);
         $mail->Body($body, $locale_char_set);
         if ($mail->ValidEmail($contact['contact_email'])) {
             $mail->To($contact['contact_email'], true);
             $mail->Send();
         }
     }
     return true;
 }
 public function render($markToday = true, $filename = '')
 {
     if ($markToday) {
         $today = new w2p_Utilities_Date();
         $today->convertTZ($this->AppUI->getPref('TIMEZONE'));
         $today->addDays(-1);
         $vline = new GanttVLine($today->format(FMT_DATETIME_MYSQL), $this->todayText);
         $vline->title->setFont(FF_CUSTOM, FS_NORMAL, 8);
         $this->graph->Add($vline);
     }
     $filename == '' ? $this->graph->Stroke() : $this->graph->Stroke($filename);
 }
예제 #3
0
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly');
}
global $AppUI, $w2Pconfig, $cal_df, $cf;
// check permissions for this module
$perms =& $AppUI->acl();
$canView = canView($m);
$canAddProject = $perms->checkModuleItem('projects', 'add', $project_id);
if (!$canView) {
    $AppUI->redirect('m=public&a=access_denied');
}
$AppUI->loadCalendarJS();
$today = new w2p_Utilities_Date();
$today->convertTZ($AppUI->getPref('TIMEZONE'));
//Lets load the users panel viewing options
$q = new w2p_Database_Query();
$q->addTable('project_designer_options', 'pdo');
$q->addQuery('pdo.*');
$q->addWhere('pdo.pd_option_user = '******'project_id', 0);
$project_id = (int) w2PgetParam($_GET, 'project_id', $project_id);
$extra = array('where' => 'project_active = 1');
$project = new CProject();
$projects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects');
$q = new w2p_Database_Query();
$q->addTable('projects');
$q->addQuery('projects.project_id, company_name');
$q->addJoin('companies', 'co', 'co.company_id = project_company');
 /**
  * w2p_Output_MonthCalendar::_drawMain()
  *
  * { Description }
  *
  */
 private function _drawMain()
 {
     $today = new w2p_Utilities_Date();
     $today->convertTZ($this->_AppUI->getPref('TIMEZONE'));
     $today = $today->format('%Y%m%d%w');
     $date = $this->this_month;
     $this_day = (int) $date->getDay();
     $this_month = (int) $date->getMonth();
     $this_year = (int) $date->getYear();
     setlocale(LC_TIME, 'en');
     $cal = Date_Calc::getCalendarMonth($this_month, $this_year, '%Y%m%d%w', LOCALE_FIRST_DAY);
     setlocale(LC_ALL, $this->_AppUI->user_lang);
     $df = $this->_AppUI->getPref('SHDATEFORMAT');
     $html = '';
     foreach ($cal as $week) {
         $html .= '<tr>';
         if ($this->showWeek) {
             $html .= '<td class="week">';
             $html .= $this->dayFunc ? "<a href=\"javascript:{$this->weekFunc}('{$week['0']}')\">" : '';
             $html .= '<img src="' . w2PfindImage('view.week.gif') . '" alt="Week View" /></a>';
             $html .= $this->dayFunc ? '</a>' : '';
             $html .= '</td>';
         }
         foreach ($week as $day) {
             $this_day = new w2p_Utilities_Date($day);
             $m = (int) substr($day, 4, 2);
             $d = (int) substr($day, 6, 2);
             $dow = (int) substr($day, 8, 1);
             $cday = (int) substr($day, 0, 8);
             //If we are on minical mode and we find tasks or events for this day then lets color code the cell depending on that
             if (array_key_exists($cday, $this->events) && $this->styleMain == 'minical') {
                 $nr_tasks = 0;
                 $nr_events = 0;
                 //lets count tasks and events
                 foreach ($this->events[$cday] as $record) {
                     if (isset($record['task']) && $record['task']) {
                         ++$nr_tasks;
                     } else {
                         ++$nr_events;
                     }
                 }
                 if ($nr_events && $nr_tasks) {
                     //if we find both
                     $class = 'eventtask';
                 } elseif ($nr_events) {
                     //if we just find events
                     $class = 'event';
                 } elseif ($nr_tasks) {
                     //if we just find tasks
                     $class = 'task';
                 }
                 if ($day == $today) {
                     $class .= 'today';
                 }
             } elseif ($m != $this_month) {
                 $class = 'empty';
             } elseif ($day == $today) {
                 $class = 'today';
             } elseif ($dow == 0 || $dow == 6) {
                 $class = 'weekend';
             } else {
                 $class = 'day';
             }
             $day = substr($day, 0, 8);
             $html .= '<td class="' . $class . '"';
             if ($this->showHighlightedDays && isset($this->highlightedDays[$day])) {
                 $html .= ' style="border: 1px solid ' . $this->highlightedDays[$day] . '"';
             }
             $html .= ' onclick="' . $this->dayFunc . '(\'' . $day . '\',\'' . $this_day->format($df) . '\')' . '">';
             if ($this->dayFunc) {
                 $html .= "<a href=\"javascript:{$this->dayFunc}('{$day}','" . $this_day->format($df) . "')\" class=\"{$class}\">";
                 $html .= $d;
                 $html .= '</a>';
             } else {
                 $html .= $d;
             }
             if ($this->showEvents) {
                 $html .= $this->_drawEvents(substr($day, 0, 8));
             }
             $html .= '</td>';
         }
         $html .= '</tr>';
     }
     return $html;
 }
예제 #5
0
if (!$event_id && !$is_clash) {
    $seldate = new w2p_Utilities_Date($date, $AppUI->getPref('TIMEZONE'));
    // If date is today, set start time to now + inc
    if ($date == date('Ymd')) {
        $h = date('H');
        // an interval after now.
        $min = intval(date('i') / $inc) + 1;
        $min *= $inc;
        if ($min > 60) {
            $min = 0;
            $h++;
        }
    }
    if ($h && $h < w2PgetConfig('cal_day_end')) {
        $seldate->setTime($h, $min, 0);
        $seldate->convertTZ('UTC');
        $obj->event_start_date = $seldate->format(FMT_TIMESTAMP);
        $seldate->addSeconds($inc * 60);
        $seldate->convertTZ('UTC');
        $obj->event_end_date = $seldate->format(FMT_TIMESTAMP);
    } else {
        $seldate->setTime(w2PgetConfig('cal_day_start'), 0, 0);
        $seldate->convertTZ('UTC');
        $obj->event_start_date = $seldate->format(FMT_TIMESTAMP);
        $seldate->convertTZ($AppUI->getPref('TIMEZONE'));
        $seldate->setTime(w2PgetConfig('cal_day_end'), 0, 0);
        $seldate->convertTZ('UTC');
        $obj->event_end_date = $seldate->format(FMT_TIMESTAMP);
    }
}
$start_date = intval($obj->event_start_date) ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($obj->event_start_date, '%Y-%m-%d %T')) : null;
예제 #6
0
$extra = array('join' => 'project_departments', 'on' => 'projects.project_id = project_departments.project_id');
$projects = $proj->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects');
$projFilter = arrayMerge(array('all' => $AppUI->_('All Projects')), $projects);
$durnTypes = w2PgetSysVal('TaskDurationType');
$taskPriority = w2PgetSysVal('TaskPriority');
$taskPriority[999] = $AppUI->_('Select User Priority');
$table_header = '';
$table_rows = '';
$userTZ = $AppUI->getPref('TIMEZONE');
// create Date objects from the datetime fields
$start_date = intval($log_start_date) ? new w2p_Utilities_Date($log_start_date, $userTZ) : new w2p_Utilities_Date(null, $userTZ);
$start_date->convertTZ('UTC');
$end_date = intval($log_end_date) ? new w2p_Utilities_Date($log_end_date, $userTZ) : new w2p_Utilities_Date(null, $userTZ);
$end_date->convertTZ('UTC');
$now = new w2p_Utilities_Date(null, $userTZ);
$now->convertTZ('UTC');
if (!$log_start_date) {
    $start_date->subtractSpan(new Date_Span('14,0,0,0'));
}
// get Users with all Allocation info (e.g. their freeCapacity)
$tempoTask = new CTask();
$userAlloc = $tempoTask->getAllocation('user_id', null, true);
?>

<script language="javascript" type="text/javascript">
<?php 
// security improvement:
// some javascript functions may not appear on client side in case of user not having write permissions
// else users would be able to arbitrarily run 'bad' functions
if ($canEdit) {
    ?>
예제 #7
0
 /**
  * Called by the Event Queue processor to process a reminder
  * on a task.
  * @access  public
  * @param   string  $notUsed    Module name (not used)
  * @param   string  $notUsed2   Type of event (not used)
  * @param   integer $id         ID of task being reminded
  * @param   integer $owner      Originator of event
  * @param   mixed   $notUsed    event-specific arguments.
  *
  * @return  mixed   true, dequeue event, false, event stays in queue.
  * -1, event is destroyed.
  */
 public function remind($notUsed = null, $notUsed2 = null, $id, $owner, $notUsed3 = null)
 {
     // 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 w2p_Utilities_Date();
     if (!$today->isWorkingDay()) {
         return true;
     }
     // Check if the task is completed
     if ($this->task_percent_complete == 100) {
         return -1;
     }
     $contacts = $this->assignees($this->task_id);
     $contact = new CContact();
     $owner = $contact->findContactByUserId($this->task_owner);
     $contacts[$owner->contact_id] = array('user_id' => $this->task_owner, 'contact_id' => $owner->contact_id, 'contact_name' => $owner->contact_display_name, 'contact_email' => $owner->contact_email);
     // build the subject line, based on how soon the
     // task will be overdue.
     $starts = new w2p_Utilities_Date($this->task_start_date);
     $expires = new w2p_Utilities_Date($this->task_end_date);
     $now = new w2p_Utilities_Date();
     $diff = $expires->dateDiff($now);
     $diff *= $expires->compare($expires, $now);
     $prefix = $this->_AppUI->_('Task Due', UI_OUTPUT_RAW);
     if ($diff == 0) {
         $msg = $this->_AppUI->_('TODAY', UI_OUTPUT_RAW);
     } elseif ($diff == 1) {
         $msg = $this->_AppUI->_('TOMORROW', UI_OUTPUT_RAW);
     } elseif ($diff < 0) {
         $msg = $this->_AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
         $prefix = $this->_AppUI->_('Task', UI_OUTPUT_RAW);
     } else {
         $msg = $this->_AppUI->_(array($diff, 'DAYS'));
     }
     $project = new CProject();
     $project->overrideDatabase($this->_query);
     $project_name = $project->load($this->task_project)->project_name;
     // Check to see that the project is both active and not a template
     if (!$project->project_active || $project->project_status == w2PgetConfig('template_projects_status_id', 0)) {
         return -1;
     }
     $subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name;
     $emailManager = new w2p_Output_EmailManager($this->_AppUI);
     $body = $emailManager->getTaskRemind($this, $msg, $project_name, $contacts);
     $mail = new w2p_Utilities_Mail();
     $mail->Subject($subject);
     foreach ($contacts as $contact) {
         $user_id = $contact['user_id'];
         $this->_AppUI->loadPrefs($user_id);
         $df = $this->_AppUI->getPref('SHDATEFORMAT');
         $tz = $this->_AppUI->getPref('TIMEZONE');
         $body = str_replace('START-TIME', $starts->convertTZ($tz)->format($df), $body);
         $body = str_replace('END-TIME', $expires->convertTZ($tz)->format($df), $body);
         $mail->Body($body, $this->_locale_char_set);
         $mail->To($contact['contact_email'], true);
         $mail->Send();
     }
     return true;
 }
예제 #8
0
 /**
  * Tests converting between timezones
  */
 public function testConvertTZ()
 {
     $myDate1 = new w2p_Utilities_Date('', 'US/Eastern');
     $myDate2 = new w2p_Utilities_Date('', 'CST');
     $myDate2->convertTZ('EST');
     //This tweaks the test data in case the +1 is across the day change.
     $tmpHour = $myDate1->hour + 1 >= 24 ? $myDate1->hour + 1 - 24 : $myDate1->hour + 1;
     $this->assertEquals($tmpHour, $myDate2->hour);
     $this->assertEquals($myDate1->minute, $myDate2->minute);
     $myDate2->convertTZ('PST');
     $tmpHour = $myDate1->hour - 2 < 0 ? $myDate1->hour - 2 + 24 : $myDate1->hour - 2;
     $this->assertEquals($tmpHour, $myDate2->hour);
 }
예제 #9
0
$bulk_task_durntype = w2PgetParam($_POST, 'bulk_task_durntype', '');
$bulk_task_start_date = w2PgetParam($_POST, 'add_task_bulk_start_date', '');
$bulk_task_end_date = w2PgetParam($_POST, 'add_task_bulk_end_date', '');
$bulk_task_allow_other_user_tasklogs = w2PgetParam($_POST, 'bulk_task_allow_other_user_tasklogs', '');
$add_task_bulk_time_keep = w2PgetParam($_POST, 'add_task_bulk_time_keep', '0');
$bulk_move_date = w2PgetParam($_POST, 'bulk_move_date', '0');
$bulk_task_percent_complete = w2PgetParam($_POST, 'bulk_task_percent_complete', '');
$userTZ = $AppUI->getPref('TIMEZONE');
if ($bulk_task_start_date) {
    $start_date_userTZ = $start_date = new w2p_Utilities_Date($bulk_task_start_date, $userTZ);
    $start_date->convertTZ('UTC');
    $bulk_start_date = $start_date->format(FMT_DATETIME_MYSQL);
}
if ($bulk_task_end_date) {
    $end_date_userTZ = $end_date = new w2p_Utilities_Date($bulk_task_end_date, $userTZ);
    $end_date->convertTZ('UTC');
    $bulk_end_date = $end_date->format(FMT_DATETIME_MYSQL);
}
if (!canEdit('tasks')) {
    $AppUI->redirect(ACCESS_DENIED);
}
$updateFields = array('bulk_task_percent_complete' => $bulk_task_percent_complete, 'bulk_task_owner' => $bulk_task_owner, 'bulk_task_priority' => $bulk_task_priority, 'bulk_task_access' => $bulk_task_access, 'bulk_task_type' => $bulk_task_type);
if (is_array($selected) && count($selected)) {
    $upd_task = new CTask();
    foreach ($selected as $val) {
        $upd_task->load($val);
        foreach ($updateFields as $name => $value) {
            if ($value != '' && (int) $_POST[$name] == (int) $value) {
                if ($upd_task->task_id) {
                    $upd_task->{str_replace('bulk_', '', $name)} = $value;
                    $result = $upd_task->store();
}
if ($column == "task_description") {
    $task_obj->task_description = $value;
}
if ($column == "task_percent_complete") {
    $task_obj->task_percent_complete = (int) $value;
}
if ($column == "task_start_date") {
    $userTZ = $AppUI->getPref('TIMEZONE');
    $start_date_userTZ = $start_date = new w2p_Utilities_Date($value, $userTZ);
    $start_date->convertTZ('UTC');
    $ts = $start_date->format(FMT_DATETIME_MYSQL);
    $task_obj->task_start_date = $ts;
}
if ($column == "task_end_date") {
    $userTZ = $AppUI->getPref('TIMEZONE');
    $start_date_userTZ = $start_date = new w2p_Utilities_Date($value, $userTZ);
    $start_date->convertTZ('UTC');
    $ts = $start_date->format(FMT_DATETIME_MYSQL);
    $task_obj->task_end_date = $ts;
}
//  if (column=="task_start_date") $task_obj->task_name=$value;
// if (column=="task_end_date") $task_obj->task_name=$value;
/* Update a record using information about id, columnName (property
   of the object or column in the table) and value that should be
   set */
if ($id > 0 && $task_obj->store()) {
    echo $value;
} else {
    echo "cannot store/edit task name";
}