Location: PHPKode > projects > O - OpenSource GroupWare > osgw/admin/edit_holiday.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");

if(isset($_POST['update_holiday']))
{


	if(isset($_POST['special']))
	{
		$special = '1';
	} else {
		$special = '0';
	}
	
	if(isset($_POST['statutory']))
	{
		$stat = '1';
	} else {
		$stat = '0';
	}
	$country = $_POST['country'];
	if($_POST['holiday_occ'] == 'static')
	{
		$day = $_POST['day'];
		$month = $_POST['month'];
		$occurrence = 0;
	} else {
		
		$day = 0;
		$month = 0;
		$occurrence = $_POST['occ_month'] .":". $_POST['occ_day'] .":". $_POST['occ_weekday'];
	
	}
	$sql = "UPDATE o_holidays SET day='$day', month='$month', country='$country',
			statutory='$stat', occurrence='$occurrence', special='$special'
			WHERE id='{$_GET['id']}'";
	$db->query($sql);
	echo $db->error;
}


include($here. "/class.admin.php");
$admin = new admin;
echo $layout->page_header;
$db->query("SELECT * FROM o_holidays WHERE id='{$_GET['id']}'");
$db->fetch_results();
$holiday_data = $db->record;
echo $layout->service_header($text['service_name'].' - '. $text['edit_holidays'] .' - '. $db->record['holiday'], $admin->nav_buttons());
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>?id=<?php echo $_GET['id']?>" method="post">
<table>
<tr>
	<td><?php echo $text['country']?>:</td>
	<td>
	<?php

		$db->query("SELECT * FROM o_countries WHERE c_id='{$holiday_data['country']}'");
		$db->fetch_results();
		
		echo $db->record['country'];
	?>
	
	<input type="hidden" name="country" value="<?php echo $db->record['c_id']?>"></td>
</tr>
<tr>
	<td><?php echo $text['holiday']?>:</td>
	<td><input type="text" name="holiday" value="<?php echo $holiday_data['holiday']?>"></td>
</tr>
<tr>
	<td rowspan="2" style="vertical-align:top"><?php echo $text['date']?>:</td>
	<td>
		<?php
			echo "Static: <input type=\"radio\" name=\"holiday_occ\" value=\"static\"";
			if($holiday_data['day'] != 0)
			{
				echo " checked=\"checked\"";
					
			}
			echo ">";
			echo $html->select_box('day','count', array('min'=>1, 'max'=>31), $holiday_data['day']);
			echo $html->select_box('month','value_count', explode(':', $text['long_months']), $holiday_data['month']);
		
		?>
	</td>
	
</tr>
<tr>
	<td>
		<?php
			echo "Variable: <input type=\"radio\" name=\"holiday_occ\" value=\"variable\"";
			if($holiday_data['day'] == 0)
			{
				echo " checked=\"checked\"";
				
			}
			echo ">";
		
			$occ_data = explode(':', $holiday_data['occurrence']);
			echo $html->select_box('occ_day','value_count', array(1=>'1st','2nd','3rd','4th','5th','Last'), $occ_data[1]);
			echo $html->select_box('occ_weekday','value_count', explode(':', $text['long_weekdays']), $occ_data[2]);
			echo $html->select_box('occ_month','value_count', explode(':', $text['long_months']), $occ_data[0])
		?>
	</td>
</tr>
<tr>
	<td>
		<?php echo $text['statutory']?>
	</td>
	<td>
		<input type="checkbox" name="statutory" value="1" <?php if($holiday_data['statutory'] == 1){echo " checked=\"checked\"";}?>">
	</td>

</tr>
<tr>
	<td>
		<?php echo $text['special']?>
	</td>
	<td>
		<input type="checkbox" name="special" value="1" <?php if($holiday_data['special'] == 1){echo " checked=\"checked\"";}?>">
		<?php echo $text['special_select']?>
	</td>
</tr>
<tr>
	<td><input type="submit" name="update_holiday" value="<?php echo $text['save']?>" class="button1"></td>
</tr>
</table>
</form>
<?php
	echo $layout->create_footer();
?>
Return current item: O - OpenSource GroupWare