/**
 * Sub-function to collect events within a period
 * @param Date the starting date of the period
 * @param Date the ending date of the period
 * @param array by-ref an array of links to append new items to
 * @param int the length to truncate entries by
 * @author Andrew Eddie <*****@*****.**>
 */
function getEventLinks($startPeriod, $endPeriod, &$links, $notUsed = null, $minical = false)
{
    global $event_filter;
    $events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter);
    $cwd = explode(',', w2PgetConfig('cal_working_days'));
    // assemble the links for the events
    foreach ($events as $row) {
        $start = new w2p_Utilities_Date($row['event_start_date']);
        $end = new w2p_Utilities_Date($row['event_end_date']);
        $date = $start;
        for ($i = 0, $i_cmp = $start->dateDiff($end); $i <= $i_cmp; $i++) {
            // the link
            // optionally do not show events on non-working days
            if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) {
                if ($minical) {
                    $link = array();
                } else {
                    $url = '?m=calendar&a=view&event_id=' . $row['event_id'];
                    $link['href'] = '';
                    $link['alt'] = '';
                    $link['text'] = w2PtoolTip($row['event_name'], getEventTooltip($row['event_id']), true) . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar') . '</a>&nbsp;' . '<a href="' . $url . '"><span class="event">' . $row['event_name'] . '</span></a>' . w2PendTip();
                }
                $links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
            }
            $date = $date->getNextDay();
        }
    }
}
 private function formatDate($mysqlDate)
 {
     $myDate = new w2p_Utilities_Date($mysqlDate);
     $myDatetime = $myDate->format('%Y%m%d %T');
     $myDatetime = str_replace(':', '', $myDatetime);
     $myDatetime = str_replace(' ', 'T', $myDatetime) . 'Z';
     return $myDatetime;
 }
 protected function hook_preStore()
 {
     if ($this->budget_start_date) {
         $date = new w2p_Utilities_Date($this->budget_start_date);
         $this->budget_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->budget_end_date) {
         $date = new w2p_Utilities_Date($this->budget_end_date);
         $this->budget_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     parent::hook_preStore();
 }
function calcDuration($start_date, $start_hour, $start_minute, $end_date, $end_hour, $end_minute, $duration_type)
{
    $year = substr($start_date, 0, 4);
    $month = substr($start_date, 4, 2);
    $day = substr($start_date, 6, 2);
    $startDate = new w2p_Utilities_Date($year . '-' . $month . '-' . $day);
    $startDate->setTime($start_hour, $start_minute);
    $year = substr($end_date, 0, 4);
    $month = substr($end_date, 4, 2);
    $day = substr($end_date, 6, 2);
    $endDate = new w2p_Utilities_Date($year . '-' . $month . '-' . $day);
    $endDate->setTime($end_hour, $end_minute);
    $duration = $startDate->calcDuration($endDate);
    if (intval($duration_type) == 24) {
        $workHours = intval(w2PgetConfig('daily_working_hours'));
        $duration = $duration / $workHours;
    }
    $response = new xajaxResponse();
    $response->assign('task_duration', 'value', $duration);
    return $response;
}
Beispiel #5
0
$titleBlock->show();
?>

<script language="javascript" type="text/javascript">
function clickDay( uts, fdate ) {
	window.location = './index.php?m=calendar&a=day_view&date='+uts+'&tab=0';
}
function clickWeek( uts, fdate ) {
	window.location = './index.php?m=calendar&a=week_view&date='+uts;
}
</script>

<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td>
<?php 
// establish the focus 'date'
$date = new w2p_Utilities_Date($date);
// prepare time period for 'events'
// "go back" to the first day shown on the calendar
// and "go forward" to the last day shown on the calendar
$first_time = new w2p_Utilities_Date($date);
$first_time->setDay(1);
$first_time->setTime(0, 0, 0);
// if Sunday is the 1st, we don't need to go back
// as that's the first day shown on the calendar
if ($first_time->getDayOfWeek() != 0) {
    $last_day_of_previous_month = $first_time->getPrevDay();
    $day_of_previous_month = $last_day_of_previous_month->getDayOfWeek();
    $seconds_to_sub_in_previous_month = 86400 * $day_of_previous_month;
    // need to cast it to int because Pear::Date_Span::set down the line
    // fails to set the seconds correctly
    $last_day_of_previous_month->subtractSeconds((int) $seconds_to_sub_in_previous_month);
Beispiel #6
0
}
$forum = new CForum();
$forum->load($forum_id);
$project = new CProject();
$project->load($forum->forum_project);
$messages = $forum->getMessages(null, $forum_id, $message_id, $sort);
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
$df .= ' ' . $AppUI->getPref('TIMEFORMAT');
$pdfdata = array();
$pdfhead = array('Date', 'User', 'Message');
foreach ($messages as $row) {
    // Find the parent message - the topic.
    if ($row['message_id'] == $message_id) {
        $topic = $row['message_title'];
    }
    $date = new w2p_Utilities_Date($AppUI->formatTZAwareTime($row['message_date'], '%Y-%m-%d %T'));
    $pdfdata[] = array($date->format($df), $row['contact_display_name'], '<b>' . $row['message_title'] . '</b>' . "\n" . $row['message_body']);
}
$font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts';
$temp_dir = W2P_BASE_DIR . '/files/temp';
$output = new w2p_Output_PDFRenderer();
$pdf = $output->getPDF();
$pdf->selectFont($font_dir . '/Helvetica.afm');
$pdf->ezText('Project: ' . $project->project_name);
$pdf->ezText('Forum: ' . $forum->forum_name);
$pdf->ezText('Topic: ' . $topic);
$pdf->ezText('');
$options = array('showLines' => 1, 'showHeadings' => 1, 'fontSize' => 8, 'rowGap' => 2, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => '400', 'cols' => array(0 => array('justification' => 'left', 'width' => 75), 1 => array('justification' => 'left', 'width' => 100), 2 => array('justification' => 'left', 'width' => 350)));
$pdf->ezTable($pdfdata, $pdfhead, null, $options);
$pdf->ezStream(array('Content-Disposition' => 'forum-thread-' . $forum_id . '.pdf'));
Beispiel #7
0
 public function __construct($datetime = null, $tz = '')
 {
     parent::__construct($datetime, $tz);
     trigger_error("CDate has been deprecated in v2.0 and will be removed by v4.0. Please use w2p_Utilities_Date instead.", E_USER_NOTICE);
 }
Beispiel #8
0
        $df = $AppUI->getPref('SHDATEFORMAT');
        $df .= ' ' . $AppUI->getPref('TIMEFORMAT');
        $contact_updatekey = $carr[$z][$x]['contact_updatekey'];
        $contact_lastupdate = $carr[$z][$x]['contact_lastupdate'];
        $contact_updateasked = $carr[$z][$x]['contact_updateasked'];
        $last_ask = new w2p_Utilities_Date($contact_updateasked);
        $lastAskFormatted = $last_ask->format($df);
        if (count($projectList) > 0) {
            echo '<a href="" onclick="	window.open(\'./index.php?m=public&a=selector&dialog=1&callback=goProject&table=projects&user_id=' . $carr[$z][$x]['contact_id'] . '\', \'selector\', \'left=50,top=50,height=250,width=400,resizable\');return false;">' . w2PshowImage('projects.png', '', '', $m, 'click to view projects associated with this contact') . '</a>';
        }
        if ($contact_updateasked && (!$contact_lastupdate || $contact_lastupdate == 0) && $contact_updatekey) {
            echo w2PtoolTip('info', 'Waiting for Contact Update Information. (Asked on: ' . $lastAskFormatted . ')') . '<img src="' . w2PfindImage('log-info.gif') . '" style="float: right;">' . w2PendTip();
        } elseif ($contact_updateasked && (!$contact_lastupdate || $contact_lastupdate == 0) && !$contact_updatekey) {
            echo w2PtoolTip('info', 'Waiting for too long! (Asked on ' . $lastAskFormatted . ')') . '<img src="' . w2PfindImage('log-error.gif') . '" style="float: right;">' . w2PendTip();
        } elseif ($contact_updateasked && !$contact_updatekey) {
            $last_ask = new w2p_Utilities_Date($contact_lastupdate);
            echo w2PtoolTip('info', 'Update sucessfully done on: ' . $last_ask->format($df) . '') . '<img src="' . w2PfindImage('log-notice.gif') . '" style="float: right;">' . w2PendTip();
        }
        ?>
                                                    </span>
												</th>
											</table>
										</td>
									</tr>
									<tr>
										<?php 
        reset($showfields);
        $s = '';
        while (list($key, $val) = each($showfields)) {
            if (mb_strlen($carr[$z][$x][$key]) > 0) {
                if ($val == 'contact_email') {
         $upd_task->task_allow_other_user_tasklogs = $bulk_task_allow_other_user_tasklogs;
         $result = $upd_task->store($AppUI);
         if (is_array($result)) {
             break;
         }
     }
 }
 //Action: Other Actions
 if (isset($_POST['bulk_task_other']) && $bulk_task_other != '') {
     if ($upd_task->task_id) {
         //Option 1 - Mark as finished
         if ($bulk_task_other == '1') {
             $upd_task->task_percent_complete = 100;
             if (!$upd_task->task_end_date || $upd_task->task_end_date == '0000-00-00 00:00:00') {
                 $end_date = null;
                 $end_date = new w2p_Utilities_Date();
                 $upd_task->task_end_date = $end_date->format(FMT_DATETIME_MYSQL);
             }
             $result = $upd_task->store($AppUI);
             if (is_array($result)) {
                 break;
             }
             //Option 2 - Mark as milestone
         } elseif ($bulk_task_other == '2') {
             $upd_task->task_milestone = 1;
             $result = $upd_task->store($AppUI);
             if (is_array($result)) {
                 break;
             }
             //Option 3 - Mark as non milestone
         } elseif ($bulk_task_other == '3') {
Beispiel #10
0
 public function addHelpDeskTaskLog()
 {
     global $helpdesk_available;
     if ($helpdesk_available && $this->file_helpdesk_item != 0) {
         // create task log with information about the file that was uploaded
         $task_log = new CHDTaskLog();
         $task_log->overrideDatabase($this->_query);
         $task_log->task_log_help_desk_id = $this->_hditem->item_id;
         if ($this->_message != 'deleted') {
             $task_log->task_log_name = 'File ' . $this->file_name . ' uploaded';
         } else {
             $task_log->task_log_name = 'File ' . $this->file_name . ' deleted';
         }
         $task_log->task_log_description = $this->file_description;
         $task_log->task_log_creator = $this->_AppUI->user_id;
         $date = new w2p_Utilities_Date();
         $task_log->task_log_date = $date->format(FMT_DATETIME_MYSQL);
         if ($msg = $task_log->store()) {
             $this->_AppUI->setMsg($msg, UI_MSG_ERROR);
         }
     }
     return null;
 }
Beispiel #11
0
<?php 
$tabview = array('either', 'tabbed', 'flat');
echo arraySelect($tabview, 'pref_name[TABVIEW]', 'class=text size=1', $prefs['TABVIEW'], true);
?>
	</td>
</tr>

<tr>
	<td align="right"><?php 
echo $AppUI->_('Short Date Format');
?>
:</td>
	<td>
<?php 
// exmample date
$ex = new w2p_Utilities_Date();
$dates = array();
$f = '%d/%m/%Y';
$dates[$f] = $ex->format($f);
$f = '%d/%b/%Y';
$dates[$f] = $ex->format($f);
$f = '%m/%d/%Y';
$dates[$f] = $ex->format($f);
$f = '%b/%d/%Y';
$dates[$f] = $ex->format($f);
$f = '%d.%m.%Y';
$dates[$f] = $ex->format($f);
$f = '%m.%d.%Y';
$dates[$f] = $ex->format($f);
$f = '%Y/%b/%d';
$dates[$f] = $ex->format($f);
function clash_suggest(w2p_Core_CAppUI $AppUI, $cal_sdf)
{
    global $m, $a;
    $obj = new CEvent();
    $obj->bind($_SESSION['add_event_post']);
    $start_date = new w2p_Utilities_Date($obj->event_start_date);
    $end_date = new w2p_Utilities_Date($obj->event_end_date);
    $df = $AppUI->getPref('SHDATEFORMAT');
    $start_secs = $start_date->getTime();
    $end_secs = $end_date->getTime();
    $duration = (int) (($end_secs - $start_secs) / 60);
    $titleBlock = new w2p_Theme_TitleBlock('Suggest Alternative Event Time', 'myevo-appointments.png', $m, $m . '.' . $a);
    $titleBlock->show();
    $calurl = W2P_BASE_URL . '/index.php?m=calendar&a=clash&event_id=' . $obj->event_id;
    $times = array();
    $t = new w2p_Utilities_Date();
    $t->setTime(0, 0, 0);
    if (!defined('LOCALE_TIME_FORMAT')) {
        define('LOCALE_TIME_FORMAT', '%I:%M %p');
    }
    for ($m = 0; $m < 60; $m++) {
        $times[$t->format('%H%M%S')] = $t->format(LOCALE_TIME_FORMAT);
        $t->addSeconds(1800);
    }
    /* TODO: This needs to be refactored to use the core setDate_new function. */
    ?>
    <script language="javascript" type="text/javascript">
    function setDate( frm_name, f_date ) {
        fld_date = eval( 'document.' + frm_name + '.' + f_date );
        fld_real_date = eval( 'document.' + frm_name + '.' + 'event_' + f_date );
        if (fld_date.value.length>0) {
          if ((parseDate(fld_date.value))==null) {
                alert('The Date/Time you typed does not match your prefered format, please retype.');
                fld_real_date.value = '';
                fld_date.style.backgroundColor = 'red';
            } else {
                fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
                fld_date.value = formatDate(parseDate(fld_date.value), '<?php 
    echo $cal_sdf;
    ?>
');
                fld_date.style.backgroundColor = '';
            }
        } else {
            fld_real_date.value = '';
        }
    }

    function set_clash_action(action) {
        document.editFrm.clash_action.value = action;
        document.editFrm.submit();
    }

    </script>
    <form name="editFrm" method="post" action="<?php 
    echo $calurl . '&clash_action=process';
    ?>
" accept-charset="utf-8">
    <table width='100%' class='std addedit'>
    <tr>
      <td width='50%' align='right'><?php 
    echo $AppUI->_('Earliest Date');
    ?>
:</td>
      <td width='50%' align='left' nowrap="nowrap">
        <input type="hidden" name="event_start_date" id="event_start_date" value="<?php 
    echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : '';
    ?>
" />
        <input type="text" name="start_date" id="start_date" onchange="setDate('editFrm', 'start_date');" value="<?php 
    echo $start_date ? $start_date->format($df) : '';
    ?>
" class="text" />
        <a href="javascript: void(0);" onclick="return showCalendar('start_date', '<?php 
    echo $df;
    ?>
', 'editFrm', null, true)">
        <img src="<?php 
    echo w2PfindImage('calendar.gif');
    ?>
" width="24" height="12" alt="<?php 
    echo $AppUI->_('Calendar');
    ?>
" border="0" />
          </a>
      </td>
    </tr>
    <tr>
      <td width='50%' align='right'><?php 
    echo $AppUI->_('Latest Date');
    ?>
:</td>
      <td width='50%' align='left' nowrap="nowrap">
        <input type="hidden" name="event_end_date" id="event_end_date" value="<?php 
    echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : '';
    ?>
" />
        <input type="text" name="end_date" id="end_date" onchange="setDate('editFrm', 'end_date');" value="<?php 
    echo $end_date ? $end_date->format($df) : '';
    ?>
" class="text" />
        <a href="javascript: void(0);" onclick="return showCalendar('end_date', '<?php 
    echo $df;
    ?>
', 'editFrm', null, true)">
        <img src="<?php 
    echo w2PfindImage('calendar.gif');
    ?>
" width="24" height="12" alt="<?php 
    echo $AppUI->_('Calendar');
    ?>
" border="0" />
          </a>
      </td>
    </tr>
    <tr>
      <td width='50%' align='right'><?php 
    echo $AppUI->_('Earliest Start Time');
    ?>
:</td>
      <td width='50%' align='left'>
        <?php 
    echo arraySelect($times, 'start_time', 'size="1" class="text"', $start_date->format('%H%M%S'));
    ?>
      </td>
    </tr>
    <tr>
      <td width='50%' align='right'><?php 
    echo $AppUI->_('Latest Finish Time');
    ?>
:</td>
      <td width='50%' align='left'>
        <?php 
    echo arraySelect($times, 'end_time', 'size="1" class="text"', $end_date->format('%H%M%S'));
    ?>
      </td>
    </tr>
    <tr>
      <td width='50%' align='right'><?php 
    echo $AppUI->_('Duration');
    ?>
:</td>
      <td width='50%' align='left'>
        <input type="text" class="text" size="5" name="duration" value="<?php 
    echo $duration;
    ?>
" />
        <?php 
    echo $AppUI->_('minutes');
    ?>
      </td>
    </tr>
    <tr>
      <td><input type="button" value="<?php 
    echo $AppUI->_('cancel');
    ?>
" class="button" onclick="set_clash_action('cancel');" /></td>
      <td align="right"><input type="button" value="<?php 
    echo $AppUI->_('submit');
    ?>
" class="button" onclick="set_clash_action('process')" /></td>
    </tr>
    </table>
    <input type='hidden' name='clash_action' value='cancel' />
    </form>
    <?php 
}
function showWeeks()
{
    global $allocated_hours_sum, $end_date, $start_date, $AppUI, $user_list, $user_names, $user_usage, $hideNonWd, $table_header, $table_rows, $df, $working_days_count, $total_hours_capacity, $total_hours_capacity_all;
    $working_days_count = 0;
    $allocated_hours_sum = 0;
    $ed = new w2p_Utilities_Date(Date_Calc::endOfWeek($end_date->day, $end_date->month, $end_date->year));
    $sd = new w2p_Utilities_Date(Date_Calc::beginOfWeek($start_date->day, $start_date->month, $start_date->year));
    $week_difference = ceil($ed->workingDaysInSpan($sd) / count(explode(',', w2PgetConfig('cal_working_days'))));
    $actual_date = $sd;
    $table_header = '<tr><th>' . $AppUI->_('User') . '</th>';
    for ($i = 0; $i < $week_difference; $i++) {
        $actual_date->addSeconds(168 * 3600);
        // + one week
        $working_days_count = $working_days_count + count(explode(',', w2PgetConfig('cal_working_days')));
    }
    $table_header .= '<th nowrap="nowrap" colspan="2">' . $AppUI->_('Allocated') . '</th></tr>';
    $table_rows = '';
    foreach ($user_list as $user_id => $user_data) {
        $user_names[$user_id] = $user_data['contact_first_name'] . ' ' . $user_data['contact_last_name'];
        if (isset($user_usage[$user_id])) {
            $table_rows .= '<tr><td nowrap="nowrap">(' . $user_data['user_username'] . ') ' . $user_data['contact_first_name'] . ' ' . $user_data['contact_last_name'] . '</td>';
            $actual_date = $sd;
            $array_sum = array_sum($user_usage[$user_id]);
            $average_user_usage = number_format($array_sum / ($week_difference * count(explode(',', w2PgetConfig('cal_working_days'))) * w2PgetConfig('daily_working_hours')) * 100, 2);
            $allocated_hours_sum += $array_sum;
            $bar_color = 'blue';
            if ($average_user_usage > 100) {
                $bar_color = 'red';
                $average_user_usage = 100;
            }
            $table_rows .= '<td ><div align="left">' . round($array_sum, 2) . ' ' . $AppUI->_('hours') . '</td> <td align="right"> ' . $average_user_usage;
            $table_rows .= '%</div>';
            $table_rows .= '<div align="left" style="height:2px;width:' . $average_user_usage . '%; background-color:' . $bar_color . '">&nbsp;</div></td>';
            $table_rows .= '</tr>';
        }
    }
    $total_hours_capacity = $working_days_count / 2 * w2PgetConfig('daily_working_hours') * count($user_usage);
    $total_hours_capacity_all = $working_days_count / 2 * w2PgetConfig('daily_working_hours') * count($user_list);
}
Beispiel #14
0
     $res = $task->getAssignedUsers($task_id);
     foreach ($res as $rw) {
         switch ($rw['perc_assignment']) {
             case 100:
                 $caption .= $rw['contact_display_name'] . ';';
                 break;
             default:
                 $caption .= $rw['contact_display_name'] . ' [' . $rw['perc_assignment'] . '%];';
                 break;
         }
     }
     $q->clear();
     $caption = mb_substr($caption, 0, mb_strlen($caption) - 1);
 }
 if ($flags == 'm') {
     $start = new w2p_Utilities_Date($start);
     $start->addDays(0);
     $s = $start->format($df);
     if ($caller == 'todo') {
         $gantt->addMilestone(array($name, $pname, '', $s, $s), $a['task_start_date']);
     } else {
         $gantt->addMilestone(array($name, '', $s, $s), $a['task_start_date']);
     }
 } else {
     $type = $a['task_duration_type'];
     $dur = $a['task_duration'];
     if ($type == 24) {
         $dur *= $w2Pconfig['daily_working_hours'];
     }
     if ($showWork == '1') {
         $work_hours = 0;
$no_modify = false;
$start_date = new w2p_Utilities_Date('2001-01-01 00:00:00');
$end_date = new w2p_Utilities_Date('2100-12-31 23:59:59');
// assemble the links for the events
$events = CEvent::getEventsForPeriod($start_date, $end_date, 'all', 0, $project_id);
$start_hour = w2PgetConfig('cal_day_start');
$end_hour = w2PgetConfig('cal_day_end');
$tf = $AppUI->getPref('TIMEFORMAT');
$df = $AppUI->getPref('SHDATEFORMAT');
$types = w2PgetSysVal('EventType');
$html = '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">';
$html .= '<tr><th>' . $AppUI->_('Date') . '</th><th>' . $AppUI->_('Type') . '</th><th>' . $AppUI->_('Event') . '</th></tr>';
foreach ($events as $row) {
    $html .= '<tr>';
    $start = new w2p_Utilities_Date($row['event_start_date']);
    $end = new w2p_Utilities_Date($row['event_end_date']);
    $html .= '<td width="25%" nowrap="nowrap">' . $start->format($df . ' ' . $tf) . '&nbsp;-&nbsp;';
    $html .= $end->format($df . ' ' . $tf) . '</td>';
    $href = '?m=calendar&a=view&event_id=' . $row['event_id'];
    $alt = $row['event_description'];
    $html .= '<td width="10%" nowrap="nowrap">';
    $html .= w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar');
    $html .= '&nbsp;<b>' . $AppUI->_($types[$row['event_type']]) . '</b><td>';
    $html .= w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true);
    $html .= '<a href="' . $href . '" class="event">';
    $html .= $row['event_title'];
    $html .= '</a>';
    $html .= w2PendTip();
    $html .= '</td></tr>';
}
$html .= '</table>';
/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$del = (int) w2PgetParam($_POST, 'del', 0);
$obj = new CEvent();
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
if ($obj->event_start_date) {
    $start_date = new w2p_Utilities_Date($obj->event_start_date . $_POST['start_time']);
    $obj->event_start_date = $start_date->format(FMT_DATETIME_MYSQL);
}
if ($obj->event_end_date) {
    $end_date = new w2p_Utilities_Date($obj->event_end_date . $_POST['end_time']);
    $obj->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
}
$action = $del ? 'deleted' : 'stored';
$clashRedirect = false;
if ($del) {
    $result = $obj->delete();
} else {
    if ($_POST['event_assigned'] > '' && ($clash = $obj->checkClash($_POST['event_assigned']))) {
        $last_a = $a;
        $GLOBALS['a'] = "clash";
        $clashRedirect = true;
    } else {
        $result = $obj->store();
        if (isset($_POST['event_assigned'])) {
            $obj->updateAssigned(explode(',', $_POST['event_assigned']));
Beispiel #17
0
$today = $ctoday->format(FMT_TIMESTAMP_DATE);
$date = w2PgetParam($_GET, 'date', $today);
// establish the focus 'date'
$this_day = new w2p_Utilities_Date($date);
$dd = $this_day->getDay();
$mm = $this_day->getMonth();
$yy = $this_day->getYear();
// get current week
$this_week = Date_calc::beginOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY);
// prepare time period for 'events'
$first_time = clone $this_day;
$first_time->setTime(0, 0, 0);
$last_time = clone $this_day;
$last_time->setTime(23, 59, 59);
$prev_day = new w2p_Utilities_Date(Date_calc::prevDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
$next_day = new w2p_Utilities_Date(Date_calc::nextDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
// get the list of visible companies
$company = new CCompany();
global $companies;
$companies = $company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
$companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
// setup the title block
$titleBlock = new CTitleBlock('Day View', 'myevo-appointments.png', $m, $m . '.' . $a);
$titleBlock->addCrumb('?m=calendar&a=year_view&date=' . $this_day->format(FMT_TIMESTAMP_DATE), 'year view');
$titleBlock->addCrumb('?m=calendar&date=' . $this_day->format(FMT_TIMESTAMP_DATE), 'month view');
$titleBlock->addCrumb('?m=calendar&a=week_view&date=' . $this_week, 'week view');
$titleBlock->addCrumb('?m=calendar&a=day_view&date=' . $this_day->format(FMT_TIMESTAMP_DATE), 'day view');
$titleBlock->addCell($AppUI->_('Company') . ':');
$titleBlock->addCell(arraySelect($companies, 'company_id', 'onChange="document.pickCompany.submit()" class="text"', $company_id), '', '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="pickCompany" accept-charset="utf-8">', '</form>');
$titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new event') . '">', '', '<form action="?m=calendar&a=addedit&date=' . $this_day->format(FMT_TIMESTAMP_DATE) . '" method="post" accept-charset="utf-8">', '</form>');
$titleBlock->show();
Beispiel #18
0
        echo $AppUI->_('My Info');
        ?>
</span></a>
                                                </td>
                                                <?php 
        if (canAccess('tasks')) {
            ?>
                                                    <td nowrap="nowrap" align="right">
                                                    <a class="button" href="./index.php?m=tasks&amp;a=todo"><span><b><?php 
            echo $AppUI->_('Todo');
            ?>
</b></span></a>
                                                    </td><?php 
        }
        if (canAccess('calendar')) {
            $now = new w2p_Utilities_Date();
            ?>
                                                    <td nowrap="nowrap" align="right">
                                                        <a class="button" href="./index.php?m=calendar&amp;a=day_view&amp;date=<?php 
            echo $now->format(FMT_TIMESTAMP_DATE);
            ?>
"><span><?php 
            echo $AppUI->_('Today');
            ?>
</span></a>
                                                    </td><?php 
        }
        ?>
                                                <td nowrap="nowrap" align="right">
                                                    <a class="button" href="./index.php?logout=-1"><span><?php 
        echo $AppUI->_('Logout');
Beispiel #19
0
along with web2Project; if not, write to the Free Software
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');
Beispiel #20
0
 /**
  * Stores the current task log in the database updating the task_log_updated
  * field appropriately. Then updates total hours worked cache on task.
  *
  * @return void
  *
  * @access public
  */
 public function store()
 {
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $q = $this->_getQuery();
     $this->task_log_updated = $q->dbfnNowWithTZ();
     if ($this->task_log_date) {
         $date = new w2p_Utilities_Date($this->task_log_date);
         $this->task_log_date = $date->format(FMT_DATETIME_MYSQL);
     }
     $dot = strpos($this->task_log_hours, ':');
     if ($dot > 0) {
         $log_duration_minutes = sprintf('%.3f', substr($this->task_log_hours, $dot + 1) / 60.0);
         $this->task_log_hours = floor($this->task_log_hours) + $log_duration_minutes;
     }
     $this->task_log_hours = $this->task_log_hours;
     $this->task_log_costcode = cleanText($this->task_log_costcode);
     if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'edit', $this->{$this->_tbl_key})) {
         if ($msg = parent::store()) {
             $this->_error['store-check'] = $msg;
         } else {
             $stored = true;
             $this->updateTaskSummary($this->_AppUI, $this->task_log_task);
         }
     }
     if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'add')) {
         $this->task_log_created = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             $this->_error['store-check'] = $msg;
         } else {
             $stored = true;
             $this->updateTaskSummary(null, $this->task_log_task);
         }
     }
     return $stored;
 }
Beispiel #21
0
<?php

/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not call this file directly.');
}
$df = $AppUI->getPref('SHDATEFORMAT');
$date = w2PgetParam($_GET, 'date', '');
$field = w2PgetParam($_GET, 'field', '');
$this_day = new w2p_Utilities_Date($date);
$formatted_date = $this_day->format($df);
?>
<script language="javascript" type="text/javascript">
<!--
	window.parent.document.<?php 
echo $field;
?>
.value = '<?php 
echo $formatted_date;
?>
';
//-->
</script>
Beispiel #22
0
 /**
  * Post Request Handler
  *
  * This method is called when a request is a POST
  *
  * @return array
  */
 public function executePost()
 {
     /**
      * @todo Remove this once we figure out how to reference vars in file
      * that is autoloaded
      */
     global $tracking_dynamics;
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     $project_id = $this->getParam('project_id', self::TYPE_INT);
     $hassign = $this->getParam('hassign');
     $hdependencies = $this->getParam('hdependencies');
     $notify = $this->getParam('task_notify');
     $comment = $this->getParam('email_comment');
     $task_id = $this->getParam('task_id');
     $adjustStartDate = $this->getParam('set_task_start_date');
     $task = new CTask();
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = '******';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $post_data = array('task_id' => $this->getParam('task_id'), 'task_name' => $this->getParam('task_name'), 'task_status' => $this->getParam('task_status'), 'task_percent_complete' => $this->getParam('task_percent_complete'), 'task_milestone' => $this->getParam('task_milestone'), 'task_owner' => $this->getParam('task_owner'), 'task_access' => $this->getParam('task_access'), 'task_related_url' => $this->getParam('task_related_url'), 'task_parent' => $this->getParam('task_parent'), 'task_type' => $this->getParam('task_type'), 'task_target_budget' => $this->getParam('task_target_budget'), 'task_description' => $this->getParam('task_description'), 'task_start_date' => $this->getParam('task_start_date'), 'task_end_date' => $this->getParam('task_end_date'), 'task_duration' => $this->getParam('task_duration'), 'task_duration_type' => $this->getParam('task_duration_type'), 'task_dynamic' => $this->getParam('task_dynamic'), 'task_allow_other_user_tasklogs' => $this->getParam('task_allow_other_user_tasklogs'), 'task_project' => $this->getParam('task_project'), 'task_priority' => $this->getParam('task_priority'));
     // Include any files for handling module-specific requirements
     foreach (findTabModules('tasks', 'addedit') as $mod) {
         $fname = W2P_BASE_DIR . '/modules/' . $mod . '/tasks_dosql.addedit.php';
         if (file_exists($fname)) {
             require_once $fname;
         }
     }
     // Find the task if we are set
     $task_end_date = null;
     if ($task_id) {
         $task->load($task_id);
         $task_end_date = new w2p_Utilities_Date($task->task_end_date);
     }
     $task = new CTask();
     if (!$task->bind($post_data)) {
         throw new Frapi_Error('SAVE_ERROR', $task->getError());
     }
     if ($task->task_dynamic != 1) {
         $task_dynamic_delay = $this->getParam('task_dynamic_nodelay') ? $this->getParam('task_dynamic_nodelay') : '0';
         if (in_array($task->task_dynamic, $tracking_dynamics)) {
             $task->task_dynamic = $task_dynamic_delay ? 21 : 31;
         } else {
             $task->task_dynamic = $task_dynamic_delay ? 11 : 0;
         }
     }
     // Let's check if task_dynamic is unchecked
     if (!$this->getParam('task_dynamic')) {
         $task->task_dynamic = false;
     }
     // Make sure task milestone is set or reset as appropriate
     if ($this->getParam('task_milestone')) {
         $task->task_milestone = false;
     }
     //format hperc_assign user_id=percentage_assignment;user_id=percentage_assignment;user_id=percentage_assignment;
     $tmp_ar = explode(';', $this->getParam('hperc_assign'));
     $i_cmp = sizeof($tmp_ar);
     $hperc_assign_ar = array();
     for ($i = 0; $i < $i_cmp; $i++) {
         $tmp = explode('=', $tmp_ar[$i]);
         if (count($tmp) > 1) {
             $hperc_assign_ar[$tmp[0]] = $tmp[1];
         } elseif ($tmp[0] != '') {
             $hperc_assign_ar[$tmp[0]] = 100;
         }
     }
     // let's check if there are some assigned departments to task
     $task->task_departments = implode(',', $this->getParam('dept_ids', self::TYPE_ARRAY));
     // convert dates to SQL format first
     if ($task->task_start_date) {
         $date = new w2p_Utilities_Date($task->task_start_date);
         $task->task_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     $end_date = null;
     if ($task->task_end_date) {
         if (strpos($task->task_end_date, '2400') !== false) {
             $task->task_end_date = str_replace('2400', '2359', $task->task_end_date);
         }
         $end_date = new w2p_Utilities_Date($task->task_end_date);
         $task->task_end_date = $end_date->format(FMT_DATETIME_MYSQL);
     }
     $error_array = $task->store($AppUI);
     // Return all the validation messages
     if ($error_array !== true) {
         $error_message = '';
         foreach ($error_array as $error) {
             $error_message .= $error . '. ';
         }
         throw new Frapi_Error('SAVE_ERROR', $error_message);
     }
     $task_parent = $this->getParam('task_parent') ? $this->getParam('task_parent', SELF::TYPE_INT) : 0;
     $old_task_parent = $this->getParam('old_task_parent') ? $this->getParam('old_task_parent', SELF::TYPE_INT) : 0;
     if ($task_parent != $old_task_parent) {
         $oldTask = new CTask();
         $oldTask->load($old_task_parent);
         $oldTask->updateDynamics(false);
     }
     // How to handle custom fields? Do we support it in api?
     // Now add any task reminders
     // If there wasn't a task, but there is one now, and
     // that task date is set, we need to set a reminder.
     if (empty($task_end_date) || !empty($end_date) && $task_end_date->dateDiff($end_date)) {
         $task->addReminder();
     }
     if (isset($hassign)) {
         $task->updateAssigned($hassign, $hperc_assign_ar);
     }
     if (isset($hdependencies)) {
         // && !empty($hdependencies)) {
         // there are dependencies set!
         // backup initial start and end dates
         $tsd = new w2p_Utilities_Date($task->task_start_date);
         $ted = new w2p_Utilities_Date($task->task_end_date);
         // updating the table recording the
         // dependency relations with this task
         $task->updateDependencies($hdependencies, $task_parent);
         // we will reset the task's start date based upon dependencies
         // and shift the end date appropriately
         if ($adjustStartDate && !is_null($hdependencies)) {
             // load already stored task data for this task
             $tempTask = new CTask();
             $tempTask->load($task->task_id);
             // shift new start date to the last dependency end date
             $nsd = new w2p_Utilities_Date($tempTask->get_deps_max_end_date($tempTask));
             // prefer Wed 8:00 over Tue 16:00 as start date
             $nsd = $nsd->next_working_day();
             // prepare the creation of the end date
             $ned = new w2p_Utilities_Date();
             $ned->copy($nsd);
             if (empty($task->task_start_date)) {
                 // appropriately calculated end date via start+duration
                 $ned->addDuration($task->task_duration, $task->task_duration_type);
             } else {
                 // calc task time span start - end
                 $d = $tsd->calcDuration($ted);
                 // Re-add (keep) task time span for end date.
                 // This is independent from $obj->task_duration.
                 // The value returned by Date::Duration() is always in hours ('1')
                 $ned->addDuration($d, '1');
             }
             // prefer tue 16:00 over wed 8:00 as an end date
             $ned = $ned->prev_working_day();
             $task->task_start_date = $nsd->format(FMT_DATETIME_MYSQL);
             $task->task_end_date = $ned->format(FMT_DATETIME_MYSQL);
             $q = new w2p_Database_Query();
             $q->addTable('tasks', 't');
             $q->addUpdate('task_start_date', $task->task_start_date);
             $q->addUpdate('task_end_date', $task->task_end_date);
             $q->addWhere('task_id = ' . (int) $task->task_id);
             $q->addWhere('task_dynamic <> 1');
             $q->exec();
             $q->clear();
         }
         $task->pushDependencies($task->task_id, $task->task_end_date);
     }
     //$task = (array)$task;
     $task->load($task_id);
     unset($task->_query, $task->_error, $task->_tbl_prefix, $task->_tbl, $task->_tbl_key, $task->_tbl_module);
     $this->data['task'] = $task;
     $this->data['success'] = true;
     return $this->toArray();
 }
Beispiel #23
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;
 }
Beispiel #24
0
<script language="javascript" type="text/javascript">
function clickDay( uts, fdate ) {
	window.location = './index.php?m=events&a=day_view&date='+uts;
}
function clickWeek( uts, fdate ) {
	window.location = './index.php?m=events&a=week_view&date='+uts;
}
</script>

<?php 
// establish the focus 'date'
if (!$date) {
    $date = new w2p_Utilities_Date();
} else {
    $date = new w2p_Utilities_Date($date);
}
$date->setDay(1);
$date->setMonth(1);
$prev_year = $date->format(FMT_TIMESTAMP_DATE);
$prev_year = (int) ($prev_year - 10000);
$next_year = $date->format(FMT_TIMESTAMP_DATE);
$next_year = (int) ($next_year + 10000);
?>
<table class="std view">
	<tr>
		<td align="center">
			<table width="100%" cellspacing="0" cellpadding="4">
				<tr>
					<td colspan="20" valign="top">
				    	<table border="0" cellspacing="1" cellpadding="2" width="100%" class="motitle">
Beispiel #25
0
 if ($t['task_start_date'] == '0000-00-00 00:00:00') {
     if ($t['task_end_date'] == '0000-00-00 00:00:00') {
         $todaydate = new w2p_Utilities_Date();
         $t['task_start_date'] = $todaydate->format(FMT_TIMESTAMP_DATE);
     } else {
         $t['task_start_date'] = $t['task_end_date'];
     }
 }
 //Check if end date exists, if not try giving it the start date.
 //If the start date does not exist then set it for today.
 //This avoids jpgraphs internal errors that render the gantt completely useless
 if ($t['task_end_date'] == '0000-00-00 00:00:00') {
     if ($t['task_duration']) {
         $t['task_end_date'] = db_unix2dateTime(db_dateTime2unix($t['task_start_date']) + SECONDS_PER_DAY * convert2days($t['task_duration'], $t['task_duration_type']));
     } else {
         $todaydate = new w2p_Utilities_Date();
         $t['task_end_date'] = $todaydate->format(FMT_TIMESTAMP_DATE);
     }
 }
 $tStart = intval($t['task_start_date']) ? $t['task_start_date'] : $start;
 $tEnd = intval($t['task_end_date']) ? $t['task_end_date'] : $end;
 $tStartObj = new w2p_Utilities_Date($t['task_start_date']);
 $tEndObj = new w2p_Utilities_Date($t['task_end_date']);
 if ($t['task_milestone'] != 1) {
     $columnValues = array('task_name' => $name, 'start_date' => $tStart, 'end_date' => $tEnd, 'actual_end' => '');
     $height = $t['task_dynamic'] == 1 ? 0.1 : 0.6;
     $gantt->addBar($columnValues, $t['task_percent_complete'] . '% ' . $AppUI->_('Complete'), $height, $p['project_color_identifier'], $p['project_active'], $t['task_percent_complete'], $t['task_id']);
 } else {
     $gantt->addMilestone(array('-- ' . $name), $t['task_start_date']);
 }
 $task->task_id = $t['task_id'];
Beispiel #26
0
 print '		<p>DB provider and version nr: ' . $db->dataProvider . ' ' . $db_info['version'] . ' (' . $db_info['description'] . ')</p>';
 print '		<p>DB Table Prefix: "' . w2PgetConfig('dbprefix') . '"</p>';
 print '		<p>Web Server: ' . safe_get_env('SERVER_SOFTWARE') . '</p>';
 print '		<p>Server Protocol | Gateway Interface: ' . safe_get_env('SERVER_PROTOCOL') . ' | ' . safe_get_env('GATEWAY_INTERFACE') . '</p>';
 print '		<p>Client Browser: ' . safe_get_env('HTTP_USER_AGENT') . '</p>';
 print '		<p>URL Query: ' . safe_get_env('QUERY_STRING') . '</p>';
 if (file_exists($module_file)) {
     $script_handle = fopen($module_file, "r");
     if ($script_handle) {
         $script_first_line = fgets($script_handle, 4096);
         fclose($script_handle);
     }
     $script_first_line = substr(trim($script_first_line), 10, -4);
     print '		<p>File Version ' . $script_first_line . '</p>';
 }
 $right_now_is = new w2p_Utilities_Date();
 print '		<p>Server Time | Timezone: ' . $right_now_is->format(FMT_DATERFC822) . ' | ' . date('T') . '</p>';
 print '		<p>PHP Max. Execution Time: ' . ini_get('max_execution_time') . ' seconds</p>';
 print '		<p>Memory Limit: ' . (ini_get('memory_limit') ? str_replace('M', ' Mb', ini_get('memory_limit')) : 'Not Defined') . '</p>';
 print '	</td>';
 print '	</tr>';
 print '	<tr valign="top">';
 print '		<th width="100%">Performance</th>';
 print '	</tr>';
 print '	<tr valign="top">';
 print '	<td width="100%">';
 if (is_callable('memory_get_usage')) {
     print '	<p>Memory Used: ' . sprintf('%01.2f Mb', memory_get_usage() / pow(1024, 2)) . '</p>';
     print '	<p>Memory Unused: ' . sprintf('%01d Kb', (memory_get_usage() - $w2p_performance_memory_marker) / 1024) . '</p>';
 }
 if (is_callable('memory_get_peak_usage')) {
            }
            $result[$key] = $row;
        }
        // execute and return
        return $result;
    }
}
// assemble the links for the events
$events = CEvent::getEventsForPeriod($first_time, $last_time, $event_filter, $user_id);
$events2 = array();
$tasks = CTask_ex::getAllTasksForPeriod($first_time, $last_time, $company_id);
$start_hour = w2PgetConfig('cal_day_start');
$end_hour = w2PgetConfig('cal_day_end');
foreach ($events as $row) {
    $start = new w2p_Utilities_Date($row['event_start_date']);
    $end = new w2p_Utilities_Date($row['event_end_date']);
    $events2[$start->format('%H%M%S')][] = $row;
    if ($start_hour > $start->format('%H')) {
        $start_hour = $start->format('%H');
    }
    if ($end_hour < $end->format('%H')) {
        $end_hour = $end->format('%H');
    }
}
$tf = $AppUI->getPref('TIMEFORMAT');
$dayStamp = $this_day->format(FMT_TIMESTAMP_DATE);
$start = $start_hour;
$end = $end_hour;
$inc = w2PgetConfig('cal_day_increment');
if ($start === null) {
    $start = 8;
Beispiel #28
0
 $pdfdata[] = array($AppUI->_('Total Hours'), round($total, 2));
 if ($log_pdf) {
     // make the PDF file
     $font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts';
     $temp_dir = W2P_BASE_DIR . '/files/temp';
     require $AppUI->getLibraryClass('ezpdf/class.ezpdf');
     $pdf = new Cezpdf();
     $pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
     $pdf->selectFont($font_dir . '/Helvetica.afm');
     $pdf->ezText(w2PgetConfig('company_name'), 12);
     if ($log_all) {
         $date = new w2p_Utilities_Date();
         $pdf->ezText("\nAll hours as of " . $date->format($df), 8);
     } else {
         $sdate = new w2p_Utilities_Date($log_start_date);
         $edate = new w2p_Utilities_Date($log_end_date);
         $pdf->ezText("\nHours from " . $sdate->format($df) . ' to ' . $edate->format($df), 8);
     }
     $pdf->selectFont($font_dir . '/Helvetica-Bold.afm');
     $pdf->ezText("\n" . $AppUI->_('Overall Report'), 12);
     foreach ($allpdfdata as $company => $data) {
         $title = $company;
         $options = array('showLines' => 1, 'showHeadings' => 0, 'fontSize' => 8, 'rowGap' => 2, 'colGap' => 5, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '500', 'cols' => array(0 => array('justification' => 'left', 'width' => 250), 1 => array('justification' => 'right', 'width' => 120)));
         $pdf->ezTable($data, null, $title, $options);
     }
     $w2pReport = new CReport();
     if ($fp = fopen($temp_dir . '/' . $w2pReport->getFilename() . '.pdf', 'wb')) {
         fwrite($fp, $pdf->ezOutput());
         fclose($fp);
         echo '<a href="' . W2P_BASE_URL . '/files/temp/' . $w2pReport->getFilename() . '.pdf" target="pdf">';
         echo $AppUI->_('View PDF File');
                    $t = $gantt_arr[$p['project_id']][$i][0];
                    $level = $gantt_arr[$p['project_id']][$i][1];
                    if ($t['task_end_date'] == null) {
                        $t['task_end_date'] = $t['task_start_date'];
                    }
                    $tStart = $t['task_start_date'] > '0000-00-00 00:00:00' ? $t['task_start_date'] : date('Y-m-d H:i:s');
                    $tEnd = $t['task_end_date'] > '0000-00-00 00:00:00' ? $t['task_end_date'] : date('Y-m-d H:i:s');
                    $tStartObj = new w2p_Utilities_Date($tStart);
                    $tEndObj = new w2p_Utilities_Date($tEnd);
                    if ($t['task_milestone'] != 1) {
                        $advance = str_repeat('  ', $level + 2);
                        $name = mb_strlen($advance . $t['task_name']) > 35 ? mb_substr($advance . $t['task_name'], 0, 33) . '...' : $advance . $t['task_name'];
                        $height = $t['task_dynamic'] == 1 ? 0.1 : 0.6;
                        $columnValues = array('project_name' => $name, 'start_date' => $tStartObj->getDate(), 'end_date' => $tEndObj->getDate(), 'actual_end' => '');
                        $gantt->addBar($columnValues, '', $height, $p['project_color_identifier'], $p['project_active'], $progress, $p['project_id']);
                    } else {
                        $name = $advance . '* ' . $t['task_name'];
                        $milestone = substr($t['task_start_date'], 0, 10);
                        $milestoneDate = new w2p_Utilities_Date($milestone);
                        $gantt->addMilestone(array($name, '', $milestoneDate->format($df)), $t['task_start_date']);
                    }
                    // End of insert workers for each task into Gantt Chart
                }
                // End of insert tasks into Gantt Chart
            }
            // End of if showAllGant checkbox is checked
        }
    }
    // End of check for valid projects array.
}
$gantt->render();
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->w2PTrimAll();
     // ensure changes of state in checkboxes is captured
     $this->project_active = (int) $this->project_active;
     $this->project_private = (int) $this->project_private;
     $this->project_target_budget = filterCurrency($this->project_target_budget);
     $this->project_actual_budget = filterCurrency($this->project_actual_budget);
     // Make sure project_short_name is the right size (issue for languages with encoded characters)
     $this->project_short_name = mb_substr($this->project_short_name, 0, 10);
     if (empty($this->project_end_date)) {
         $this->project_end_date = null;
     }
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $this->project_id = (int) $this->project_id;
     // convert dates to SQL format first
     if ($this->project_start_date) {
         $date = new w2p_Utilities_Date($this->project_start_date);
         $this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_end_date) {
         $date = new w2p_Utilities_Date($this->project_end_date);
         $date->setTime(23, 59, 59);
         $this->project_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_actual_end_date) {
         $date = new w2p_Utilities_Date($this->project_actual_end_date);
         $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     // check project parents and reset them to self if they do not exist
     if (!$this->project_parent) {
         $this->project_parent = $this->project_id;
         $this->project_original_parent = $this->project_id;
     } else {
         $parent_project = new CProject();
         $parent_project->load($this->project_parent);
         $this->project_original_parent = $parent_project->project_original_parent;
     }
     if (!$this->project_original_parent) {
         $this->project_original_parent = $this->project_id;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     $q = $this->_query;
     $this->project_updated = $q->dbfnNowWithTZ();
     if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->project_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) {
         $this->project_created = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             return $msg;
         }
         if (0 == $this->project_parent || 0 == $this->project_original_parent) {
             $this->project_parent = $this->project_id;
             $this->project_original_parent = $this->project_id;
             if ($msg = parent::store()) {
                 return $msg;
             }
         }
         $stored = true;
     }
     //split out related departments and store them seperatly.
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         foreach ($this->project_departments as $department) {
             if ($department) {
                 $q->addTable('project_departments');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('department_id', $department);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         foreach ($this->project_contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     if ($stored) {
         $custom_fields = new w2p_Core_CustomFields('projects', 'addedit', $this->project_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->project_id);
         // Store Custom Fields
         CTask::storeTokenTask($AppUI, $this->project_id);
     }
     return $stored;
 }