mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 00:58:55 +01:00
fixed disapearing holidays caused by the observance rule, see bug [ 996820 ] Calendar Control - Missing Holidays
This commit is contained in:
parent
9352bd53c4
commit
2d428a66c7
@ -387,9 +387,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$temp_locale = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
|
$temp_locale = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
|
||||||
for($i=0;$i<count($holidays);$i++)
|
foreach($holidays as $i => $holiday)
|
||||||
|
//for($i=0;$i<count($holidays);$i++)
|
||||||
{
|
{
|
||||||
$c = $i;
|
|
||||||
if($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale'])
|
if($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale'])
|
||||||
{
|
{
|
||||||
if(is_object($holidaycalc))
|
if(is_object($holidaycalc))
|
||||||
@ -399,11 +399,7 @@
|
|||||||
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
|
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
|
||||||
$holidaycalc = CreateObject('calendar.holidaycalc');
|
$holidaycalc = CreateObject('calendar.holidaycalc');
|
||||||
}
|
}
|
||||||
$holidays[$i]['date'] = $holidaycalc->calculate_date($holidays[$i], $holidays, $this->year, $c);
|
$holidays[$i]['date'] = $holidaycalc->calculate_date($holiday, $holidays, $this->year);
|
||||||
if($c != $i)
|
|
||||||
{
|
|
||||||
$i = $c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unset($holidaycalc);
|
unset($holidaycalc);
|
||||||
$this->holidays = $this->sort_holidays_by_date($holidays);
|
$this->holidays = $this->sort_holidays_by_date($holidays);
|
||||||
|
@ -15,25 +15,25 @@
|
|||||||
|
|
||||||
class holidaycalc
|
class holidaycalc
|
||||||
{
|
{
|
||||||
function add($holiday,&$holidays,$year,&$i,$day_offset=0)
|
function add($holiday,&$holidays,$year,$day_offset=0)
|
||||||
{
|
{
|
||||||
$i++;
|
|
||||||
$holidays[$i]= $holiday;
|
|
||||||
if ($day_offset)
|
if ($day_offset)
|
||||||
{
|
{
|
||||||
$holidays[$i]['name'] .= ' (Observed)';
|
$holiday['name'] .= ' (Observed)';
|
||||||
}
|
}
|
||||||
$holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$holiday['day']+$day_offset,$year);
|
$holiday['date'] = mktime(0,0,0,$holiday['month'],$holiday['day']+$day_offset,$year);
|
||||||
foreach(array('day'=>'d','month'=>'m','occurence'=>'Y') as $key => $frmt)
|
foreach(array('day'=>'d','month'=>'m','occurence'=>'Y') as $key => $frmt)
|
||||||
{
|
{
|
||||||
$holidays[$i][$key] = date($frmt,$holidays[$i]['date']);
|
$holiday[$key] = date($frmt,$holiday['date']);
|
||||||
}
|
}
|
||||||
$holidays[$i]['obervance_rule'] = 0;
|
$holiday['obervance_rule'] = 0;
|
||||||
|
|
||||||
//echo "<p>holidaycalc::add(".print_r($holiday,True).",,$year,,$day_offset)=".print_r($holidays[$i],True)."</p>";
|
$holidays[]= $holiday;
|
||||||
|
|
||||||
|
//echo "<p>holidaycalc::add(,,$year,,$day_offset)=".print_r($holiday,True)."</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculate_date($holiday, &$holidays, $year, &$i)
|
function calculate_date($holiday, &$holidays, $year)
|
||||||
{
|
{
|
||||||
//echo "<p>holidaycalc::calculate_date(".print_r($holiday,True).",,$year,)</p>";
|
//echo "<p>holidaycalc::calculate_date(".print_r($holiday,True).",,$year,)</p>";
|
||||||
|
|
||||||
@ -71,7 +71,7 @@
|
|||||||
// 0 = sundays are observed on monday (+1), 6 = saturdays are observed on fridays (-1)
|
// 0 = sundays are observed on monday (+1), 6 = saturdays are observed on fridays (-1)
|
||||||
if($dow == 0 || $dow == 6)
|
if($dow == 0 || $dow == 6)
|
||||||
{
|
{
|
||||||
$this->add($holiday,$holidays,$year,$i,$dow == 0 ? 1 : -1);
|
$this->add($holiday,$holidays,$year,$dow == 0 ? 1 : -1);
|
||||||
}
|
}
|
||||||
if ($holiday['month'] == 1 && $day == 1)
|
if ($holiday['month'] == 1 && $day == 1)
|
||||||
{
|
{
|
||||||
@ -79,10 +79,10 @@
|
|||||||
// checking if next year's newyear might be observed in this year
|
// checking if next year's newyear might be observed in this year
|
||||||
if ($dow == 6)
|
if ($dow == 6)
|
||||||
{
|
{
|
||||||
$this->add($holiday,$holidays,$year+1,$i,-1);
|
$this->add($holiday,$holidays,$year+1,-1);
|
||||||
}
|
}
|
||||||
// add the next years newyear, to show it in a week- or month-view
|
// add the next years newyear, to show it in a week- or month-view
|
||||||
$this->add($holiday,$holidays,$year+1,$i);
|
$this->add($holiday,$holidays,$year+1);
|
||||||
}
|
}
|
||||||
// checking if last year's new year's eve might be observed in this year
|
// checking if last year's new year's eve might be observed in this year
|
||||||
if ($holiday['month'] == 12 && $day == 31)
|
if ($holiday['month'] == 12 && $day == 31)
|
||||||
@ -90,10 +90,10 @@
|
|||||||
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year-1,$holiday['month'],$day);
|
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year-1,$holiday['month'],$day);
|
||||||
if ($dow == 0)
|
if ($dow == 0)
|
||||||
{
|
{
|
||||||
$this->add($holiday,$holidays,$year-1,$i,1);
|
$this->add($holiday,$holidays,$year-1,1);
|
||||||
}
|
}
|
||||||
// add the last years new year's eve, to show it in a week- or month-view
|
// add the last years new year's eve, to show it in a week- or month-view
|
||||||
$this->add($holiday,$holidays,$year-1,$i);
|
$this->add($holiday,$holidays,$year-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user