<?php
if (isset ( $_POST ['submit'] ) && $_POST ['check'] == 'slip') {
	$check = $_POST ['slip'];
	
	$payslipdate = $_POST['month_year']; // get
	                                                                           // the
	                                                                           // name
	                                                                           // of
	                                                                           // month
	                                                                           // in
	                                                                           // alphbet;
	$empname = $check ['empname'];
	$department = $check ['department'];
	$empcode = $check ['empcode'];
	$employment_income = $check ['employment_income'];
	$employment_expences = $check ['employment_expences'];
	$net_employment_income = $check ['net_employment_income'];
	/* $trade_income = $check ['trade_income']; */
	$paidday = $check ['paidday'];
	$presentday = $check ['presentday'];
	$weekoff = $_POST ['weekoff'];
	$total_leaves = $check ['total_leaves'];
	$extrawork = $check ['extrawork'];
	/* $dividends = $check ['dividends']; */
	$earned_income_relief = $check ['earned_income_relief'];
	/* $interest = $check ['interest']; */
	$spouse_relief = $check ['spouse_relief'];
	/* $property_rent = $check ['property_rent']; */
	$qualifying_relief = $check ['qualifying_relief'];
	/* $royality_income = $check ['royality_income']; */
	$mother_relief = $check ['mother_relief'];
	/* $gain_income_nature = $check ['gain_income_nature']; */
	$parent_relief = $check ['parent_relief'];
	/* $total_income = $check ['total_income']; */
	$grandparent_relief = $check ['grandparent_relief'];
	/* $approved_donations = $check ['approved_donations']; */
	$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'];
	$assessable_income = $check ['assessableincome'];
	$chargeableincome = $check ['chargeableincome'];
	$chargeableincometax = $check ['chargeableincometax'];
	$parenthood_tax = $check ['parenthood_tax'];
	$nettax_payable = $check ['nettax_payable'];
	/*
	 * $prepared_by = $check ['prepared_by']; $authorised_sign = $check
	 * ['authorised_sign']; $employee_sign = $check ['employee_sign'];
	 */
	
	$payslipdatecheck = $db->exists ( "payslip", array ("empname" => $empname, "payslipdate" => $payslipdate ) );
	
	if (! $payslipdatecheck) {
		$insert = $db->insert ( "payslip", array ("empname" => $empname, "department" => $department, "empcode" => $empcode, "employment_income" => $employment_income, "employment_expences" => $employment_expences, "net_employment_income" => $net_employment_income, /* "trade_income" => $trade_income, */ "paidday" => $paidday, "presentday" => $presentday, "weekoff" => $weekoff, "total_leaves" => $total_leaves, "extrawork" => $extrawork, /*"dividends" => $dividends,*/ "earned_income_relief" => $earned_income_relief, /*"interest" => $interest,*/ "spouse_relief" => $spouse_relief, /* "property_rent" => $property_rent, */ "qualifying_relief" => $qualifying_relief, /*"royality_income" => $royality_income,*/ "mother_relief" => $mother_relief, /*"gain_income_nature" => $gain_income_nature,*/ "parent_relief" => $parent_relief, /*"total_income" => $total_income,*/ "grandparent_relief" => $grandparent_relief, /*"approved_donations" => $approved_donations,*/ "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, "assessableincome" => $assessable_income, "chargeableincome" => $chargeableincome, "chargeableincometax" => $chargeableincometax, "parenthood_tax" => $parenthood_tax, "nettax_payable" => $nettax_payable, 
			/* "prepared_by" => $prepared_by, "authorised_sign" => $authorised_sign, 
			"employee_sign"=>$employee_sign, */"payslipdate" => $payslipdate ) );
		
	} else {
		$update = $db->update ( "payslip", array ("empname" => $empname, "department" => $department, 
				"empcode" => $empcode, "employment_income" => $employment_income, 
				"employment_expences" => $employment_expences, "net_employment_income" => $net_employment_income, 
                "paidday" => $paidday, "presentday" => $presentday, "weekoff" => $weekoff, "total_leaves" => $total_leaves, "extrawork" => $extrawork, /*"dividends" => $dividends,*/ "earned_income_relief" => $earned_income_relief, /*"interest" => $interest,*/ "spouse_relief" => $spouse_relief, /*"property_rent" => $property_rent,*/ "qualifying_relief" => $qualifying_relief, /*"royality_income" => $royality_income,*/ "mother_relief" => $mother_relief, /*"gain_income_nature" => $gain_income_nature,*/ "parent_relief" => $parent_relief, /*"total_income" => $total_income,*/ "grandparent_relief" => $grandparent_relief, /*"approved_donations" => $approved_donations,*/ "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, "assessableincome" => $assessable_income, "chargeableincome" => $chargeableincome, "chargeableincometax" => $chargeableincometax, "parenthood_tax" => $parenthood_tax, "nettax_payable" => $nettax_payable,
				"payslipdate" => $payslipdate ), array ("empname" => $empname ) );
		
	}
	
	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($insert){?>
					<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>
				<h5>Oops! There Are Some Problem In Inserted...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
	}
}
?>