<div class="container">
	<div class="row">
		<div class="col">
			<h4><b>STATUTORY DETAILS</b></h4>
		</div>
	</div>
	<div class="row">
		<div class="col">
			<div class="row">
				<div class="col">
					<b>EMPLOYEE EPF NUMBER </b>
				</div>
				<div class="col">
					<?php echo (!empty($statutory_details) && $statutory_details->ee_epf_no)?': '.strtoupper($statutory_details->ee_epf_no):': N/A'; ?>
				</div>
			</div>
		</div>
		<div class="col">
			<div class="row">
				<div class="col">
					<b>EMPLOYEE SOCSO NO</b>
				</div>
				<div class="col">
					<?php echo (!empty($statutory_details) &&$statutory_details->ee_socso)?': '.strtoupper($statutory_details->ee_socso):': N/A'; ?>
				</div>
			</div>
		</div>
	</div><br>
	<div class="row">
		<div class="col">
			<div class="row">
				<div class="col">
					<b>EMPLOYER RATE</b>
				</div>
				<div class="col">
					<?php /* akmal. tak faham kenapa data dlm master tidak selari dgn cara data present. */
						if (!empty($statutory_details) && $statutory_details->er_rate == 0) {
							echo ': STATUTORY RATE ('.$statutory_details->er_percent.'%)';
						}elseif (!empty($statutory_details) && $statutory_details->er_rate == 1) {
							echo ': COMPANY RATE ('.$statutory_details->er_percent.'%)';
						}elseif (!empty($statutory_details) && $statutory_details->er_rate == 2) {
							echo ': PERSONAL RATE ('.$statutory_details->er_percent.'%)';
						}else echo 'N/A'; 
						/*if (!empty($statutory_details) && $statutory_details->er_percent > 0) {
							echo 'STATUTORY RATE ('.$statutory_details->er_percent.' %)';
						}else echo 'N/A'; */
					?>
				</div>
			</div>
		</div>
		<div class="col">
			<div class="row">
				<div class="col">
					<b style="color: red;">*</b><b>EMPLOYEE RATE</b>
					<button type="button" class="btn btn-default btn-sm d-print-none <?php echo $btn_hidden; ?>" onclick="EditEmployeeRate();" data-trigger="hover" data-tooltip="tooltip" title="Edit Employee Rate"><i class="fa fa-edit" style="color: #F0AD4E;"></i></button>
				</div>
				<div class="col">
					<?php /* akmal. tak faham kenapa data dlm master tidak selari dgn cara data present.*/
						if (!empty($statutory_details) && $statutory_details->ee_rate == 0) {
							echo ': STATUTORY RATE ('.$statutory_details->ee_percent.'%)';
						}elseif (!empty($statutory_details) && $statutory_details->ee_rate == 1) {
							echo ': COMPANY RATE ('.$statutory_details->ee_percent.'%)';
						}elseif (!empty($statutory_details) && $statutory_details->ee_rate == 2) {
							echo ': PERSONAL RATE ('.$statutory_details->ee_percent.'%)';
						}else echo 'N/A'; 
						/*if (!empty($statutory_details) && $statutory_details->ee_percent > 0) {
							echo 'STATUTORY RATE ('.$statutory_details->ee_percent.' %)';
						}else echo 'N/A'; */
					?>
				</div>
			</div>
		</div>
	</div><br>

	<div class="row">
		<div class="col-lg-6">
			<div class="row">
				<div class="col">
					<b>INCOME TAX NO</b>
				</div>
				<div class="col">
					<?php echo(!empty($statutory_details) && $statutory_details->ee_income_tax)?': '.strtoupper($statutory_details->ee_income_tax):': N/A'; ?>
				</div>
			</div>
		</div>
	</div>
	<br>

	<div class="row">
		<div class="col">
			<div class="row">
				<div class="col">
					<b>PCB DEDUCTION (%)</b>
					<button type="button" class="btn btn-default btn-sm d-print-none <?php echo $btn_hidden; ?>" onclick="EditPCBDeduction();" data-trigger="hover" data-tooltip="tooltip" title="Edit PCB Deduction"><i class="fa fa-edit" style="color: #F0AD4E;"></i></button>
				</div>
				<div class="col">
					<?php echo(!empty($statutory_details) && $statutory_details->ee_pcb_deduction_percent)?': '.$statutory_details->ee_pcb_deduction_percent:': N/A'; ?>
				</div>
			</div>
		</div>
		<div class="col">
			<div class="row">
				<div class="col">
					<b>ZAKAT DEDUCTION (%)</b>
				</div>
				<div class="col">
					<?php echo(!empty($statutory_details) && $statutory_details->ee_zakat_deduction_percent)?': '.$statutory_details->ee_zakat_deduction_percent:': N/A'; ?>
				</div>
			</div>
		</div>
	</div><br>

	<div class="row">
		<div class="col">
			<div class="row">
				<div class="col">
					<b>STATUS</b>
				</div>
				<div class="col">
					<p><?php echo (!empty($statutory_details->status))?': '.'ACTIVE':': INACTIVE'; ?></p>
				</div>
			</div>
		</div>
		<div class="col">
			<div class="row">
				<div class="col">
					<b style="color: red;">*</b><b>YEAR</b>
					<button type="button" class="btn btn-default btn-sm d-print-none <?php echo $btn_hidden; ?>" onclick="EditPCBDeductionYear();" data-trigger="hover" data-tooltip="tooltip" title="Edit PCB Deduction Year"><i class="fa fa-edit" style="color: #F0AD4E;"></i></button>
				</div>
				<div class="col">
					<p><?php echo (!empty($statutory_details->year))?': '.$statutory_details->year:': N/A'; ?></p>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- modal -->
<div class="modal fade d-print-none" role="dialog" aria-hidden="true" id="employeeRateModal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="racks-modal-title">Edit Employee Rate</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
			<form id="employeeRateForm" class="form">
				<div class="modal-body">
					<div class="form-row">
						<div class="col-12 col-sm-6">
							<label for="employee_rate">Employee Rate</label>
							<!--input type="text"class="form-control" name="employee_rate" id="employee_rate"-->
							<select class="select form-control" name="employee_rate" id="employee_rate">
								<option value="9">9%</option>
								<option value="11">11%</option>							
						</select>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<div class="btn-group float-right">
						<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
						<button type="button" id="saveEmployeeRateButton" onclick="saveEmployeeRate();" class="btn btn-primary">Save</button>
					</div>
				</div>
			</form>
        </div>
    </div>
</div>

<div class="modal fade d-print-none" role="dialog" aria-hidden="true" id="PCBDeductionModal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="racks-modal-title">Edit PCB Deduction Rate</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
			<form id="PCBDeductionForm" class="form">
				<div class="modal-body">
					<div class="form-row">
						<div class="col-12 col-sm-6">
							<label for="PCBDeduction_rate">PCB Deduction Rate</label>
							<input type="text"class="form-control" name="PCBDeduction_rate" id="PCBDeduction_rate">
							<small><i>Zakat Deduction Rate will be auto calculate (Zakat = 100% - PCB)</i></small>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<div class="btn-group float-right">
						<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
						<button type="button" id="savePCBDeductionButton" onclick="savePCBDeduction();" class="btn btn-primary">Save</button>
					</div>
				</div>
			</form>
        </div>
    </div>
</div>

<div class="modal fade d-print-none" role="dialog" aria-hidden="true" id="PCBDeductionYearModal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="racks-modal-title">Edit PCB Deduction Year</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
			<form id="PCBDeductionYearForm" class="form">
				<div class="modal-body">
					<div class="form-row">
						<div class="col-12 col-sm-6">
							<label for="PCBDeduction_year">PCB Deduction Year</label>
							<input type="text"class="form-control" name="PCBDeduction_year" id="PCBDeduction_year">
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<div class="btn-group float-right">
						<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
						<button type="button" id="savePCBDeductionYearButton" onclick="savePCBDeductionYear();" class="btn btn-primary">Save</button>
					</div>
				</div>
			</form>
        </div>
    </div>
</div>

<script type="text/javascript">
	function EditEmployeeRate(){

		clearForm("#employeeRateForm");

		$('#employeeRateModal').find('#racks-modal-title').text('Edit Employee Rate');
        $('#saveEmployeeRateButton').attr('onclick', 'saveEmployeeRate()');
		$('#employeeRateModal').modal('show');
	}

	function EditPCBDeduction(){

		clearForm("#PCBDeductionForm");

		$('#PCBDeductionModal').find('#racks-modal-title').text('Edit PCB Deduction Rate');
        $('#savePCBDeductionButton').attr('onclick', 'savePCBDeduction()');
		$('#PCBDeductionModal').modal('show');
	}

	function EditPCBDeductionYear(){

		clearForm("#PCBDeductionYearForm");

		$('#PCBDeductionYearModal').find('#racks-modal-title').text('Edit PCB Deduction Year');
        $('#savePCBDeductionYearButton').attr('onclick', 'savePCBDeductionYear()');
		$('#PCBDeductionYearModal').modal('show');
	}

	function saveEmployeeRate(){
		var postData = {
			'profiling_id' 	: $("#profiling_id_new").val(),
			'ee_rate' 		: 0,
			'ee_percent' 	: $("#employee_rate").val(),
		}
		$.ajax({
			type: 'POST',
			url: '<?php echo base_url('hr/Myprofile/save_employee_rate/'); ?>',
			data: postData,
			dataType: 'JSON',
			success: function(data) {
				if(data.status == 'success')
				{
					localStorage.setItem("status",data.status);
					localStorage.setItem("msg",data.msg);

					location.replace(data.redirect);
				}
			}
		});
	}

	function savePCBDeduction(){
		var postData = {
			'profiling_id' 					: $("#profiling_id_new").val(),
			'ee_pcb_deduction_percent' 		: $("#PCBDeduction_rate").val(),
			'ee_zakat_deduction_percent' 	: 100 - $("#PCBDeduction_rate").val(),
		}
		$.ajax({
			type: 'POST',
			url: '<?php echo base_url('hr/Myprofile/save_pcb_deduction/'); ?>',
			data: postData,
			dataType: 'JSON',
			success: function(data) {
				if(data.status == 'success')
				{
					localStorage.setItem("status",data.status);
					localStorage.setItem("msg",data.msg);

					location.replace(data.redirect);
				}
			}
		});
	}

	function savePCBDeductionYear(){
		var postData = {
			'profiling_id' 	: $("#profiling_id_new").val(),
			'year' 			: $("#PCBDeduction_year").val(),
		}
		$.ajax({
			type: 'POST',
			url: '<?php echo base_url('hr/Myprofile/save_pcb_deduction_year'); ?>',
			data: postData,
			dataType: 'JSON',
			success: function(data) {
				if(data.status == 'success')
				{
					localStorage.setItem("status",data.status);
					localStorage.setItem("msg",data.msg);

					location.replace(data.redirect);
				}
			}
		});
	}
</script>