Ejemplo n.º 1
0
function isHoliday($date = 0)
{
    // Query database for settings
    $holiday_manual = db_loadResult('SELECT holiday_manual FROM holiday_settings');
    $holiday_auto = db_loadResult('SELECT holiday_auto FROM holiday_settings');
    $holiday_driver = db_loadResult('SELECT holiday_driver FROM holiday_settings');
    if (!$date) {
        $date = new CDate();
    }
    if ($holiday_manual) {
        // Check whether the date is blacklisted
        $sql = "SELECT * FROM holiday ";
        $sql .= "WHERE ( date(holiday_start_date) <= '";
        $sql .= $date->format('%Y-%m-%d');
        $sql .= "' AND date(holiday_end_date) >= '";
        $sql .= $date->format('%Y-%m-%d');
        $sql .= "' AND holiday_white=0 ) ";
        $sql .= "OR ( ";
        $sql .= " DATE_FORMAT(holiday_start_date, '%m-%d') <= '";
        $sql .= $date->format('%m-%d');
        $sql .= "' AND DATE_FORMAT(holiday_end_date, '%m-%d') >= '";
        $sql .= $date->format('%m-%d');
        $sql .= "' AND holiday_annual=1";
        $sql .= " AND holiday_white=0 ) ";
        if (db_loadResult($sql)) {
            return 0;
        }
        // Check if we have a whitelist item for this date
        $sql = "SELECT * FROM holiday ";
        $sql .= "WHERE ( date(holiday_start_date) <= '";
        $sql .= $date->format('%Y-%m-%d');
        $sql .= "' AND date(holiday_end_date) >= '";
        $sql .= $date->format('%Y-%m-%d');
        $sql .= "' AND holiday_white=1 ) ";
        $sql .= "OR ( ";
        $sql .= " DATE_FORMAT(holiday_start_date, '%m-%d') <= '";
        $sql .= $date->format('%m-%d');
        $sql .= "' AND DATE_FORMAT(holiday_end_date, '%m-%d') >= '";
        $sql .= $date->format('%m-%d');
        $sql .= "' AND holiday_annual=1";
        $sql .= " AND holiday_white=1 ) ";
        if (db_loadResult($sql)) {
            return 1;
        }
    }
    if ($holiday_auto) {
        // Still here? Ok, lets poll the automatic system
        $drivers_alloc = Date_Holidays::getInstalledDrivers();
        $driver_object = Date_Holidays::factory($drivers_alloc[$holiday_driver]['title'], $date->getYear(), 'en_EN');
        if (!Date_Holidays::isError($driver_object)) {
            if ($driver_object->getHolidayForDate($date)) {
                return 1;
            }
        }
    }
    // No hits, must be a working day
    return 0;
}
Ejemplo n.º 2
0
function weekDates($fromPeriod, $toPeriod)
{
    global $df;
    $row = '';
    //start of week
    $sd = new CDate($fromPeriod);
    $days_from_start = $sd->getDayOfWeek();
    for ($i = 0; $i < $days_from_start; $i++) {
        $stmp = $sd->getPrevDay();
        $sd = new CDate($stmp->format('%Y-%m-%d 00:00:00'));
    }
    //end of week
    $ed = new CDate($toPeriod);
    $days_spent = $ed->getDayOfWeek();
    for ($i = 6 - $days_spent; $i > 0; $i--) {
        $etmp = $ed->getNextDay();
        $ed = new CDate($etmp->format('%Y-%m-%d 23:59:59'));
    }
    $row = "";
    while ($sd->before($ed)) {
        $row .= "\t\t\t" . '<th title="' . $sd->getYear() . '" nowrap="nowrap">' . $sd->format($df) . "</th>\n";
        $sd->addSeconds(7 * 24 * 3600);
        //add one week
    }
    return $row;
}
Ejemplo n.º 3
0
<?php

/* HELPDESK $Id: vw_weekly_by_project.php,v 1.1 2007/08/22 07:47:47 arcoz67 Exp $ */
global $tab, $TIMECARD_CONFIG;
$show_other_worksheets = $TIMECARD_CONFIG['minimum_see_level'] >= $AppUI->user_type;
if (isset($_GET['year'])) {
    $AppUI->setState('TimecardMonthlyYear', $_GET['year']);
} else {
    $current_date = new CDate();
    $AppUI->setState('TimecardMonthlyYear', $current_date->getYear());
}
$year = $AppUI->getState('TimecardMonthlyYear');
if (isset($_GET['month'])) {
    $AppUI->setState('TimecardMonthlyMonth', $_GET['month']);
} else {
    $current_date = new CDate();
    $AppUI->setState('TimecardMonthlyMonth', $current_date->getMonth());
}
$month = $AppUI->getState('TimecardMonthlyMonth');
if ($show_other_worksheets) {
    if (isset($_GET['user_id'])) {
        $AppUI->setState('TimecardMonthlyUserId', $_GET['user_id']);
    } else {
        $AppUI->setState('TimecardMonthlyUserId', $AppUI->user_id);
    }
    $user_id = $AppUI->getState('TimecardMonthlyUserId') ? $AppUI->getState('TimecardMonthlyUserId') : 0;
} else {
    $user_id = $AppUI->user_id;
}
$start_report = new CDate();
$start_report->setMonth($month);
Ejemplo n.º 4
0
}
$AppUI->savePlace();
global $locale_char_set;
// retrieve any state parameters
if (isset($_REQUEST['company_id'])) {
    $AppUI->setState('CalIdxCompany', intval(w2PgetParam($_REQUEST, 'company_id', 0)));
}
$company_id = $AppUI->getState('CalIdxCompany') !== null ? $AppUI->getState('CalIdxCompany') : $AppUI->user_company;
$event_filter = $AppUI->checkPrefState('CalIdxFilter', w2PgetParam($_REQUEST, 'event_filter', ''), 'EVENTFILTER', 'my');
// get the passed timestamp (today if none)
$date = w2PgetParam($_GET, 'date', null);
// establish the focus 'date'
$this_week = new CDate($date);
$dd = $this_week->getDay();
$mm = $this_week->getMonth();
$yy = $this_week->getYear();
// prepare time period for 'events'
$first_time = new CDate(Date_calc::beginOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$first_time->setTime(0, 0, 0);
$last_time = new CDate(Date_calc::endOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$last_time->setTime(23, 59, 59);
$prev_week = new CDate(Date_calc::beginOfPrevWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$next_week = new CDate(Date_calc::beginOfNextWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY));
$links = array();
// assemble the links for the tasks
require_once W2P_BASE_DIR . '/modules/calendar/links_tasks.php';
getTaskLinks($first_time, $last_time, $links, 50, $company_id);
// assemble the links for the events
require_once W2P_BASE_DIR . '/modules/calendar/links_events.php';
getEventLinks($first_time, $last_time, $links, 50);
// get the list of visible companies
Ejemplo n.º 5
0
}
$company_id = $AppUI->getState('CalIdxCompany', $AppUI->user_company);
$event_filter = $AppUI->checkPrefState('CalIdxFilter', @$_REQUEST['event_filter'], 'EVENTFILTER', 'my');
$AppUI->setState('CalDayViewTab', dPgetParam($_GET, 'tab', $tab));
$tab = $AppUI->getState('CalDayViewTab', '0');
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
// get the passed timestamp (today if none)
$ctoday = new CDate();
$today = $ctoday->format(FMT_TIMESTAMP_DATE);
$date = dPgetParam($_GET, 'date', $today);
// establish the focus 'date'
$this_day = new CDate($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 = php4_clone($this_day);
$first_time->setTime(0, 0, 0);
$first_time->subtractSeconds(1);
$last_time = php4_clone($this_day);
$last_time->setTime(23, 59, 59);
$prev_day = new CDate(Date_calc::prevDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
$next_day = new CDate(Date_calc::nextDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
// setup the title block
$titleBlock = new CTitleBlock('Day View');
$titleBlock->addButton('month view', 'index.php?m=calendar&date=' . $this_day->format(FMT_TIMESTAMP_DATE));
$titleBlock->addButton('week view', 'index.php?m=calendar&a=week_view&date=' . $this_week);
$titleBlock->addButton('new event', 'index.php?m=calendar&a=addedit&date=' . $this_day->format(FMT_TIMESTAMP_DATE));