<?php
if (isset ( $_POST ['submit'] ) && isset ( $_POST ['check'] ) == 'table') {
	$check = $_POST ['table'];
	
	$employment_income = $check ['employment_income'];
	$employment_expences = $check ['employment_expences'];
	$net_employment_income = $check ['net_employment_income'];
	$trade_income = $check ['trade_income'];
	$dividends = $check ['dividends'];
	$interest = $check ['interest'];
	$property_rent = $check ['property_rent'];
	$royality_income = $check ['royality_income'];
	$gain_income_nature = $check ['gain_income_nature'];
	$total_income = $check ['total_income'];
	$approved_donations = $check ['approved_donations'];
	$assessable_income = $check ['assessable_income'];
	$earned_income_relief = $check ['earned_income_relief'];
	$spouse_relief = $check ['spouse_relief'];
	$qualifying_relief = $check ['qualifying_relief'];
	$mother_relief = $check ['mother_relief'];
	$parent_relief = $check ['parent_relief'];
	$grandparent_relief = $check ['grandparent_relief'];
	$brosis_relief = $check ['brosis_relief'];
	$cpf_relief = $check ['cpf_relief'];
	$life_insurance_relief = $check ['life_insurance_relief'];
	$coursefee_relief = $check ['coursefee_relief'];
	$leavy_relief = $check ['leavy_relief'];
	$cpf = $check ['cpf'];
	$srs = $check ['srs'];
	$nsman = $check ['nsman'];
	$chargeable_income = $check ['chargeable_income'];
	$chargeable_tax = $check ['chargeable_tax'];
	$parenthood_tax = $check ['parenthood_tax'];
	$nettax_payable = $check ['nettax_payable'];
	
	$count = $db->get_count ( "singaporetable" );
	if ($count != 1) {
		
		$insert = $db->insert ( "singaporetable", array (
				"employment_income" => $employment_income, 
				"employment_expences" => $employment_expences, 
				"net_employment_income" => $net_employment_income, 
				"trade_income" => $trade_income, 
				"dividends" => $dividends, 
				"interest" => $interest, 
				"property_rent" => $property_rent, 
				"royality_income" => $royality_income, 
				"gain_income_nature" => $gain_income_nature, 
				"total_income" => $total_income, 
				"approved_donations" => $approved_donations, 
				"assessable_income" => $assessable_income, 
				"earned_income_relief" => $earned_income_relief, 
				"spouse_relief" => $spouse_relief, 
				"qualifying_relief" => $qualifying_relief, 
				"mother_relief" => $mother_relief, 
				"parent_relief" => $parent_relief, 
				"grandparent_relief" => $grandparent_relief, 
				"brosis_relief" => $brosis_relief, 
				"cpf_relief" => $cpf_relief, 
				"life_insurance_relief" => $life_insurance_relief, 
				"coursefee_relief" => $coursefee_relief, 
				"leavy_relief" => $leavy_relief, 
				"cpf" => $cpf, 
				"srs" => $srs, 
				"nsman" => $nsman, 
				"chargeable_income" => $chargeable_income, 
				"chargeable_tax" => $chargeable_tax, 
				"parenthood_tax" => $parenthood_tax, 
				"nettax_payable" => $nettax_payable 
				) );
	} else {
		$update = $db->update ( "singaporetable", array (
				"employment_income" => $employment_income, 
				"employment_expences" => $employment_expences, 
				"net_employment_income" => $net_employment_income, 
				"trade_income" => $trade_income, 
				"dividends" => $dividends, 
				"interest" => $interest, 
				"property_rent" => $property_rent, 
				"royality_income" => $royality_income, 
				"gain_income_nature" => $gain_income_nature, 
				"total_income" => $total_income, 
				"approved_donations" => $approved_donations, 
				"assessable_income" => $assessable_income, 
				"earned_income_relief" => $earned_income_relief, 
				"spouse_relief" => $spouse_relief, 
				"qualifying_relief" => $qualifying_relief, 
				"mother_relief" => $mother_relief, 
				"parent_relief" => $parent_relief, 
				"grandparent_relief" => $grandparent_relief, 
				"brosis_relief" => $brosis_relief, 
				"cpf_relief" => $cpf_relief, 
				"life_insurance_relief" => $life_insurance_relief, 
				"coursefee_relief" => $coursefee_relief, 
				"leavy_relief" => $leavy_relief, 
				"cpf" => $cpf, 
				"srs" => $srs, 
				"nsman" => $nsman, 
				"chargeable_income" => $chargeable_income, 
				"chargeable_tax" => $chargeable_tax, 
				"parenthood_tax" => $parenthood_tax, 
				"nettax_payable" => $nettax_payable 
				), array ("id" => 1 ) );
	
	}
	if ($insert || $update) {
		?>
<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>
					<?php if($count!=1){?>
					<p>Your Record Is Inserted...</p>
					<?php }else{?>
					<p>Your Record Is Updated...</p>
					<?php }?>
				</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>
					<?php if($count!=1){?>
				<h5>Oops! There Are Some Problem In Inserted...</h5>
				<?php }else{?>
				<h5>Oops! There Are Some Problem In Updated...</h5>
				<?php }?>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
	
}
}
?>