예제 #1
0
/**
 * Function creates HTML to display Calendar MonthView
 * @param  array     $cal            - collections of objects and strings.
 * return  string    $monthview_layout - html tags in string format
 */
function getMonthViewLayout(&$cal)
{
    global $current_user, $app_strings, $cal_log, $theme;
    $category = getParentTab();
    $cal_log->debug("Entering getMonthViewLayout() method...");
    $date_format = $current_user->date_format;
    $count = 0;
    //To get no. of rows(weeks) in month
    if ($cal['calendar']->month_array[$cal['calendar']->slices[35]]->start_time->month != $cal['calendar']->date_time->month) {
        $rows = 5;
    } else {
        $rows = 6;
    }
    $format = $cal['calendar']->hour_format;
    $hour_startat = formatUserTimeString(array('hour' => date('H:i'), 'minute' => 0), '24');
    $hour_endat = formatUserTimeString(array('hour' => date('H:i', time() + 60 * 60), 'minute' => 0), '24');
    $time_arr = getaddEventPopupTime($hour_startat, $hour_endat, $format);
    $monthview_layout = '';
    $monthview_layout .= '<table class="calDayHour" style="background-color: rgb(218, 218, 218);" border="0" cellpadding="5" cellspacing="1" width="98%"><tr>';
    //To display days in week
    for ($i = 0; $i < 7; $i++) {
        $first_row = $cal['calendar']->month_array[$cal['calendar']->slices[$i]];
        $weekday = $first_row->start_time->getdayofWeek();
        $monthview_layout .= '<td class="lvtCol" valign="top" width="14%">' . $weekday . '</td>';
    }
    $monthview_layout .= '</tr></table>';
    $monthview_layout .= '<!-- month headers --> <table border=0 cellspacing=1 cellpadding=5 width=98% class="calDayHour" >';
    $cnt = 0;
    for ($i = 0; $i < $rows; $i++) {
        $monthview_layout .= '<tr>';
        for ($j = 0; $j < 7; $j++) {
            $temp_ts = $cal['calendar']->month_array[$cal['calendar']->slices[$count]]->start_time->ts;
            $temp_date = $date_format == 'dd-mm-yyyy' ? date('d-m-Y', $temp_ts) : ($date_format == 'mm-dd-yyyy' ? date('m-d-Y', $temp_ts) : ($date_format == 'yyyy-mm-dd' ? date('Y-m-d', $temp_ts) : ''));
            if ($cal['calendar']->day_start_hour != 23) {
                $endtemp_date = $temp_date;
            } else {
                $endtemp_ts = $cal['calendar']->month_array[$cal['calendar']->slices[$count + 1]]->start_time->ts;
                $endtemp_date = $date_format == 'dd-mm-yyyy' ? date('d-m-Y', $endtemp_ts) : ($date_format == 'mm-dd-yyyy' ? date('m-d-Y', $endtemp_ts) : ($date_format == 'yyyy-mm-dd' ? date('Y-m-d', $endtemp_ts) : ''));
            }
            $cal['slice'] = $cal['calendar']->month_array[$cal['calendar']->slices[$count]];
            $monthclass = dateCheck($cal['slice']->start_time->get_formatted_date());
            if ($monthclass != '') {
                $monthclass = 'calSel';
            } else {
                $monthclass = 'dvtCellLabel';
            }
            //to display dates in month
            if ($cal['slice']->start_time->getMonth() == $cal['calendar']->date_time->getMonth()) {
                $monthview_layout .= '<td style="text-align:left;" class="' . $monthclass . '" width="14%" onMouseOver="cal_show(\'create_' . $temp_date . '' . $time_arr['starthour'] . '\')" onMouseOut="fnHide_Event(\'create_' . $temp_date . '' . $time_arr['starthour'] . '\')">';
                $monthview_layout .= '<a href="index.php?module=Calendar&action=index&view=' . $cal['slice']->getView() . '' . $cal['slice']->start_time->get_date_str() . '&parenttab=' . $category . '">';
                $monthview_layout .= $cal['slice']->start_time->get_Date();
                $monthview_layout .= '</a>';
                $monthview_layout .= '<div id="create_' . $temp_date . '' . $time_arr['starthour'] . '" style="visibility:hidden;">';
                if (isPermitted("Calendar", "EditView") == "yes") {
                    $monthview_layout .= '<a onClick="fnvshobj(this,\'addEvent\'); gshow(\'addEvent\',\'Call\',\'' . $temp_date . '\',\'' . $endtemp_date . '\',\'' . $time_arr['starthour'] . '\',\'' . $time_arr['startmin'] . '\',\'' . $time_arr['startfmt'] . '\',\'' . $time_arr['endhour'] . '\',\'' . $time_arr['endmin'] . '\',\'' . $time_arr['endfmt'] . '\',\'hourview\',\'event\')" href="javascript:void(0)"><img src="' . vtiger_imageurl('cal_add.gif', $theme) . '" border="0"></a>';
                }
                $monthview_layout .= '  </div></td>';
            } else {
                $monthview_layout .= '<td class="dvtCellLabel" width="14%">&nbsp;</td>';
            }
            $count++;
        }
        $monthview_layout .= '</tr>';
        $monthview_layout .= '<tr>';
        for ($j = 0; $j < 7; $j++) {
            $monthview_layout .= '<td bgcolor="white" height="90" valign="top" width="200" align=right>';
            $monthview_layout .= getmonthEventLayer($cal, $cal['calendar']->slices[$cnt]);
            $monthview_layout .= '</td>';
            $cnt++;
        }
        $monthview_layout .= '</tr>';
    }
    $monthview_layout .= '</table>';
    return $monthview_layout;
    $cal_log->debug("Exiting getMonthViewLayout() method...");
}
예제 #2
0
function timeString($datetime, $fmt)
{
    if (is_object($datetime)) {
        $dateStr = $datetime->year . "-" . twoDigit($datetime->month) . "-" . twoDigit($datetime->day);
    } else {
        $dateStr = $datetime['year'] . "-" . twoDigit($datetime['month']) . "-" . twoDigit($datetime['day']);
    }
    $timeStr = formatUserTimeString($datetime, $fmt);
    $date = new DateTimeField($dateStr . " " . $timeStr);
    list($h, $m) = explode(':', $date->getDisplayTime());
    $timeStr = formatUserTimeString(array('hour' => $h, 'minute' => $m), $fmt);
    return $timeStr;
}
예제 #3
0
function timeString($datetime, $fmt)
{
    $timeStr = formatUserTimeString($datetime, $fmt);
    $date = new DateTimeField($timeStr);
    list($h, $m) = explode(':', $date->getDisplayTime());
    $timeStr = formatUserTimeString(array('hour' => $h, 'minute' => $m), $fmt);
    return $timeStr;
}