Added a new field to the holiday table for observance rules.

This commit is contained in:
skeeter 2001-05-14 23:43:05 +00:00
parent 158c78afb6
commit c8f940a8ee
8 changed files with 79 additions and 46 deletions

View File

@ -98,7 +98,7 @@ class calendar_holiday
{ {
// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n"; // echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
$holiday = explode("\t",$lines[$i]); $holiday = explode("\t",$lines[$i]);
if(count($holiday) == 6) if(count($holiday) == 7)
{ {
$loc = $holiday[0]; $loc = $holiday[0];
$name = addslashes($holiday[1]); $name = addslashes($holiday[1]);
@ -106,8 +106,9 @@ class calendar_holiday
$month = intval($holiday[3]); $month = intval($holiday[3]);
$occurence = intval($holiday[4]); $occurence = intval($holiday[4]);
$dow = intval($holiday[5]); $dow = intval($holiday[5]);
$observ_rule = intval($holidays[6]);
// echo "Inserting LOCALE='".$loc."' NAME='".$name."' extra=(".$day.'/'.$month.'/'.$occurence.'/'.$dow.'/'.")<br>\n"; // echo "Inserting LOCALE='".$loc."' NAME='".$name."' extra=(".$day.'/'.$month.'/'.$occurence.'/'.$dow.'/'.")<br>\n";
$sql = "INSERT INTO phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow) VALUES('$loc','$name',$day,$month,$occurence,$dow)"; $sql = "INSERT INTO phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow,observance_rule) VALUES('$loc','$name',$day,$month,$occurence,$dow,$observ_rule)";
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
} }
} }
@ -134,31 +135,36 @@ class calendar_holiday
else else
{ {
$day = $holiday['day']; $day = $holiday['day'];
$dow = $phpgw->calendar->day_of_week($this->year,$holiday['month'],$day); if($holiday['observance_rule'] == True)
// This now calulates Observed holidays and creates a new entry for them.
if($dow == 0)
{ {
$i++; $dow = $phpgw->calendar->day_of_week($this->year,$holiday['month'],$day);
$this->holidays[$i]['locale'] = $holiday['locale'].' (Observed)'; // This now calulates Observed holidays and creates a new entry for them.
$this->holidays[$i]['name'] = $holiday['name']; if($dow == 0)
$this->holidays[$i]['day'] = $holiday['day'] + 1; {
$this->holidays[$i]['month'] = $holiday['month']; $i++;
$this->holidays[$i]['occurence'] = $holiday['occurence']; $this->holidays[$i]['locale'] = $holiday['locale'].' (Observed)';
$this->holidays[$i]['dow'] = $holiday['dow']; $this->holidays[$i]['name'] = $holiday['name'];
$this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$this->year) - $this->tz_offset; $this->holidays[$i]['day'] = $holiday['day'] + 1;
// echo 'Calculating for year('.$this->year.') month('.$this->holidays[$i]['month'].') dow('.$this->holidays[$i]['dow'].') occurence('.$this->holidays[$i]['occurence'].') datetime('.$this->holidays[$i]['date'].') DATE('.date('Y.m.d H:i:s',$this->holidays[$i]['date']).')<br>'."\n"; $this->holidays[$i]['month'] = $holiday['month'];
} $this->holidays[$i]['occurence'] = $holiday['occurence'];
elseif($dow == 6) $this->holidays[$i]['dow'] = $holiday['dow'];
{ $this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$this->year) - $this->tz_offset;
$i++; $this->holidays[$i]['obervance_rule'] = 0;
$this->holidays[$i]['locale'] = $holiday['locale'].' (Observed)'; // echo 'Calculating for year('.$this->year.') month('.$this->holidays[$i]['month'].') dow('.$this->holidays[$i]['dow'].') occurence('.$this->holidays[$i]['occurence'].') datetime('.$this->holidays[$i]['date'].') DATE('.date('Y.m.d H:i:s',$this->holidays[$i]['date']).')<br>'."\n";
$this->holidays[$i]['name'] = $holiday['name']; }
$this->holidays[$i]['day'] = $holiday['day'] - 1; elseif($dow == 6)
$this->holidays[$i]['month'] = $holiday['month']; {
$this->holidays[$i]['occurence'] = $holiday['occurence']; $i++;
$this->holidays[$i]['dow'] = $holiday['dow']; $this->holidays[$i]['locale'] = $holiday['locale'].' (Observed)';
$this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$this->year) - $this->tz_offset; $this->holidays[$i]['name'] = $holiday['name'];
// echo 'Calculating for year('.$this->year.') month('.$this->holidays[$i]['month'].') dow('.$this->holidays[$i]['dow'].') occurence('.$this->holidays[$i]['occurence'].') datetime('.$this->holidays[$i]['date'].') DATE('.date('Y.m.d H:i:s',$this->holidays[$i]['date']).')<br>'."\n"; $this->holidays[$i]['day'] = $holiday['day'] - 1;
$this->holidays[$i]['month'] = $holiday['month'];
$this->holidays[$i]['occurence'] = $holiday['occurence'];
$this->holidays[$i]['dow'] = $holiday['dow'];
$this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$this->year) - $this->tz_offset;
$this->holidays[$i]['obervance_rule'] = 0;
// echo 'Calculating for year('.$this->year.') month('.$this->holidays[$i]['month'].') dow('.$this->holidays[$i]['dow'].') occurence('.$this->holidays[$i]['occurence'].') datetime('.$this->holidays[$i]['date'].') DATE('.date('Y.m.d H:i:s',$this->holidays[$i]['date']).')<br>'."\n";
}
} }
} }
$datetime = mktime(0,0,0,$holiday['month'],$day,$this->year) - $this->tz_offset; $datetime = mktime(0,0,0,$holiday['month'],$day,$this->year) - $this->tz_offset;
@ -186,6 +192,7 @@ class calendar_holiday
$this->holidays[$i]['month'] = intval($this->db->f('month_num')); $this->holidays[$i]['month'] = intval($this->db->f('month_num'));
$this->holidays[$i]['occurence'] = intval($this->db->f('occurence')); $this->holidays[$i]['occurence'] = intval($this->db->f('occurence'));
$this->holidays[$i]['dow'] = intval($this->db->f('dow')); $this->holidays[$i]['dow'] = intval($this->db->f('dow'));
$this->holidays[$i]['observance_rule'] = intval($this->db->f('observance_rule'));
if(count($this->users) == 2 && $this->users[0] != $this->users[1]) if(count($this->users) == 2 && $this->users[0] != $this->users[1])
{ {
if($this->holidays[$i]['locale'] == $this->users[1]) if($this->holidays[$i]['locale'] == $this->users[1])

View File

@ -1,5 +1,5 @@
CA Quebec Civic Holiday 3 1 0 0 CA Quebec Civic Holiday 3 1 0 0 1
CA Canadian Civic Holiday 0 8 1 1 CA Canadian Civic Holiday 0 8 1 1 0
CA Rememberence Day 11 11 0 0 CA Rememberence Day 11 11 0 0 1
CA Christmas Day 25 12 0 0 CA Christmas Day 25 12 0 0 1
CA Boxing Day 26 12 0 0 CA Boxing Day 26 12 0 0 1

View File

@ -1,13 +1,13 @@
US New Years 1 1 0 0 US New Years 1 1 0 0 1
US Martin Luther King's Birthday 0 1 3 1 US Martin Luther King's Birthday 0 1 3 1 0
US Inaugeration Day 20 1 0 0 US Inaugeration Day 20 1 0 0 0
US Presidents Day 0 2 3 1 US Presidents Day 0 2 3 1 0
US Armed Forces Day 0 5 3 6 US Armed Forces Day 0 5 3 6 0
US Memorial Day 0 5 99 1 US Memorial Day 0 5 99 1 0
US Flag Day 14 6 0 0 US Flag Day 14 6 0 0 0
US Independence Day 4 7 0 0 US Independence Day 4 7 0 0 1
US Labor Day 0 9 1 1 US Labor Day 0 9 1 1 0
US Columbus Day 0 10 2 1 US Columbus Day 0 10 2 1 0
US Veterans Day 11 11 0 0 US Veterans Day 11 11 0 0 1
US Thanksgiving Day 0 11 4 4 US Thanksgiving Day 0 11 4 4 0
US Christmas Day 25 12 0 0 US Christmas Day 25 12 0 0 1

View File

@ -242,6 +242,7 @@
month_num int DEFAULT '0' NOT NULL, month_num int DEFAULT '0' NOT NULL,
occurence int DEFAULT '0' NOT NULL, occurence int DEFAULT '0' NOT NULL,
dow int DEFAULT '0' NOT NULL, dow int DEFAULT '0' NOT NULL,
observance_rule int DEFAULT '0' NOT NULL,
PRIMARY KEY (hol_id) PRIMARY KEY (hol_id)
)"; )";
$phpgw_setup->db->query($sql); $phpgw_setup->db->query($sql);

View File

@ -1660,6 +1660,18 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.009'; $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.009';
} }
$test[] = '0.9.11.009';
function upgrade0_9_11_009()
{
global $phpgw_info,$phpgw_setup;
$phpgw_setup->db->query("alter table phpgw_cal_holidays add column observance_rule int DEFAULT '0' NOT NULL",__LINE__,__TABLE__);
$phpgw_setup->db->query("delete from phpgw_cal_holidays",__LINE__,__FILE__);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.010';
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -215,7 +215,9 @@
mday int DEFAULT 0, mday int DEFAULT 0,
month_num int DEFAULT 0, month_num int DEFAULT 0,
occurence int DEFAULT 0, occurence int DEFAULT 0,
dow int DEFAULT 0 dow int DEFAULT 0,
observance_rule int DEFAULT 0
)"; )";
$phpgw_setup->db->query($sql); $phpgw_setup->db->query($sql);

View File

@ -2180,6 +2180,17 @@
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.009'; $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.009';
} }
$test[] = '0.9.11.009';
function upgrade0_9_11_009()
{
global $phpgw_info,$phpgw_setup;
$phpgw_setup->db->query("alter table phpgw_holidays add column observance_rule int default 0",__LINE__,__TABLE__);
$phpgw_setup->db->query("delete from phpgw_cal_holidays",__LINE__,__FILE__);
$phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.11.010';
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -11,5 +11,5 @@
/* $Id$ */ /* $Id$ */
$phpgw_info['server']['versions']['phpgwapi'] = '0.9.11.009'; $phpgw_info['server']['versions']['phpgwapi'] = '0.9.11.010';
$phpgw_info['server']['versions']['current_header'] = '1.12'; $phpgw_info['server']['versions']['current_header'] = '1.12';