Location: PHPKode > projects > O - OpenSource GroupWare > osgw/admin/holidays.php
<?php
/**************************************************************************
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   @Authors:	Ryan Thompson(hide@address.com)
***************************************************************************/
include("./data.php");
$service['add_header'] = TRUE;
include("../config.inc.php");

include($here. "/class.admin.php");
$admin = new admin;
if(isset($_GET['add_holiday']))
{
	$O->redirect("/admin/add_holiday.php?country={$_GET['select_country']}");
}

echo $layout->page_header;
echo $layout->service_header($text['service_name'].' - '. $text['holiday_manager'], $admin->nav_buttons());
?>
<br />
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="get">
<table>
<tr>
	<td class="input_header">
		Select Country:
	</td>
	<td>
		<select name="select_country">
		<?php
		$sql = "SELECT o_countries.country, o_countries.c_id FROM o_countries 
			RIGHT JOIN o_holidays ON o_holidays.country=o_countries.c_id GROUP BY o_countries.c_id, o_countries.country";
		$db->query($sql);
		while($db->fetch_results())
		{
			echo "<option value=\"{$db->record['c_id']}\"";
			if($db->record['c_id'] == $_GET['select_country'])
			{
				echo " selected=\"selected\"";	
			}
			echo ">{$db->record['country']}</option>\n";
		}
		?>
		</select>
	</td>
	<td>
		<input type="submit" name="get_holidays" value="Get Holidays" class="button1">
	</td>
</tr>
</table>

<br />
<?php 

	$months = explode(':', $text['long_months']);
	if(isset($_GET['get_holidays']))
	{
		
		echo $html->create_list(
			array("STYLE"		=> 'list_header',
				"HOLIDAY"	=> $text['holiday'],
				"DATE"		=> $text['date'],
				"EDIT"		=> $text['edit']),
		$O->dir ."/admin/html/holiday_hdr.html");
		$sql = "SELECT * FROM o_holidays WHERE country='{$_GET['select_country']}'";
		$db->query($sql);
		while($db->fetch_results())
		{
			if($db->record['holiday'] == 'Easter')
			{
				if($holiday_date = $date->get_easter(date('Y')) < time())
				{
					$holiday_date = $date->get_easter(date('Y') +1);
				}

			} else {
				$holiday_date = $date->next_time($db->record['month'], $db->record['day'], $db->record['occurrence'], date('Y'));
			}
			
			$class = $html->list_class($class);
			echo $html->create_list(
				array("STYLE"		=> $class,
					"HOLIDAY"	=> $db->record['holiday'],
					"DATE"		=> date($date->long_date, $holiday_date),
					"EDIT"		=> $O->create_link("/admin/edit_holiday.php?id={$db->record['id']}", "({$text['edit']})", $class)),
				$O->dir ."/admin/html/holiday_list.html");
				
		}
		echo $html->create_list(array("ADD_HOLIDAY"=>$text['add_holiday']),$O->dir ."/admin/html/holiday_ftr.html");
		
		
	}
?>
 </form>
<br />
<?php
	echo $layout->create_footer();
?>
Return current item: O - OpenSource GroupWare