<?php
if (isset ( $_POST ['submit'] ) && $_POST ['check'] == 'office' && $_POST ['checkday'] == 'day') {
	$office = $_POST ['office'];
	
	$day = $_POST ['day'];
	$day_value = serialize ( $day );
	$whr_am = $office ['whr_am'];
	$whr_pm = $office ['whr_pm'];
	$first_am = $office ['first_am'];
	$first_pm = $office ['first_pm'];
	$second_am = $office ['second_am'];
	$second_pm = $office ['second_pm'];
	$c_leave = $office ['c_leave'];
	$s_leave = $office ['s_leave'];
	$e_leave = $office ['e_leave'];
	$m_leave = $office ['m_leave'];
	$o_leave = $office ['o_leave'];
	
	$all = $db->get_count ( 'office' );
	
	if ($all == '0') {
		$query = $db->insert ( 'office', array ('w_day' => $day_value, 'whr_am' => $whr_am, 'whr_pm' => $whr_pm, 'first_am' => $first_am, 'first_pm' => $first_pm, 'second_am' => $second_am, 'second_pm' => $second_pm, 'c_leave' => $c_leave, 's_leave' => $s_leave, 'e_leave' => $e_leave, 'm_leave' => $m_leave, 'o_leave' => $o_leave ) );
		
		if ($query) {
			?>
<div id="hide">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">

				<div class="gritter-without-image">
					<span class="gritter-title">Cheers..
						<div class="gritter-close" id="gritterremove"
							style="display: inline;"></div>
					</span>
					<p>Your Record Is Updated...</p>
				</div>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
		
		} else {
			?>
<div class="hide1">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">
				<div class="gritter-close" id="gritterremove"
					style="display: inline;"></div>
				<h5>Oops! There Are Some Problem In Updated...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
		
		}
	} else {
		$query = $db->update ( 'office', array ('w_day' => $day_value, 'whr_am' => $whr_am, 'whr_pm' => $whr_pm, 'first_am' => $first_am, 'first_pm' => $first_pm, 'second_am' => $second_am, 'second_pm' => $second_pm, 'c_leave' => $c_leave, 's_leave' => $s_leave, 'e_leave' => $e_leave, 'm_leave' => $m_leave, 'o_leave' => $o_leave ), array ('id' => '1' ) );
		
		if ($query) {
			?>
<div id="hide">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">

				<div class="gritter-without-image">
					<span class="gritter-title">Cheers..
						<div class="gritter-close" id="gritterremove"
							style="display: inline;"></div>
					</span>
					<p>Your Record Is Updated...</p>
				</div>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
			
			$query = $db->get_row ( 'office', array ('id' => '1' ) );
		} else {
			?>
<div class="hide1">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">
				<div class="gritter-close" id="gritterremove"
					style="display: inline;"></div>
				<h5>Oops! There Are Some Problem In Updated...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
		
		}
	}
} else {
	$query = $db->get_row ( 'office', array ('id' => '1' ) );

}
?>