File: /home/cafsindia/hrms_cafsinfotech_in/application/views/form_sixteen_mapping/manage.php
<?php
$this->load->view("partial/header");
$access_data = $this->session->userdata('access_data');
$page_name = ucwords(str_replace("_"," ",$controller_name));
$uniqueId = "prime_".$controller_name."_id";
?>
<!-- ADD STYLE ON BODY th _ARN 06-11-2025 -->
<style>
#form_16_map table.dataTable tbody th {
background-color: #ffffff !important;
}
</style>
<div class='row title_content'>
<div class='col-md-4 col-xs-4'>
<h1 class='page_txt'><?php echo $page_name;?></h1>
</div>
</div>
<div class="row" style='margin-bottom:0px;'>
<div class="col-md-12">
<form id='form_16_map'>
<div style="margin:20px !important;">
<?php
$temp_array = array();
$form16q_mapping_arr = array();
foreach ($form16_temp_result as $form16_temp_rslt){
$prime_form_sixteen_id = $form16_temp_rslt->prime_form_sixteen_id;
$form16_value = $form16_temp_rslt->form16_value;
$temp_array[$prime_form_sixteen_id] = $form16_value;
$form16q_mapping_arr[] = $form16_temp_rslt->form16q_mapping;
}
//section 10 option list waiting clarifications
$tr_line = "";
foreach($form_sixteen_head_result as $form_sixteen_head){
$form_sixteen_id = $form_sixteen_head->prime_form_sixteen_id;
$tax_act = $form_sixteen_head->tax_act;
$tax_section_head = $form_sixteen_head->tax_section_head;
$option_val = $temp_array[$form_sixteen_id];
$form16q_mapping_val = $form16q_mapping_arr[$i];
$option_10 = "<option value=''>---- Select Sections ----</option>";
$option_16 = "<option value=''>---- Select Sections ----</option>";
$option_80 = "<option value=''>---- Select Sections ----</option>";
$oth_option = "<option value=''>---- Select Sections ----</option>";
$option_6a = "<option value=''>---- Select Sections ----</option>";
foreach($tax_sec_10_result as $sec10_rslt){
$tax_act_details = $sec10_rslt->tax_act_details;
$tax_subsection_column = $sec10_rslt->tax_subsection_column;
if($option_val === $tax_subsection_column){
$option_10_sel = "selected";
}else{
$option_10_sel = "";
}
$option_10 .= "<option value='$tax_subsection_column' $option_10_sel>$tax_act_details</option>";
}
$option_10 .= "<option value='actual_rent'>actual_rent</option>";
$option_10 .= "<option value='actual_rent_pct'>actual_rent_pct</option>";
$option_10 .= "<option value='house_rent_paid'>house_rent_paid</option>";
$option_10 .= "<option value='rent'>rent</option>";
$option_10 .= "<option value='pan_card_no'>pan_card_no</option>";
$option_10 .= "<option value='lendor_pan_card_no'>lendor_pan_card_no</option>";
$option_10 .= "<option value='metro_rslt'>metro_rslt</option>";
$option_10 .= "<option value='metro_pct'>metro_pct</option>";
foreach($tax_sec_16_result as $sec16_rslt){
$tax_act_details = $sec16_rslt->tax_act_details;
$tax_subsection_column = $sec16_rslt->tax_subsection_column;
if($option_val === $tax_subsection_column){
$option_16_sel = "selected";
}else{
$option_16_sel = "";
}
$option_16 .= "<option value='$tax_subsection_column' $option_16_sel>$tax_act_details</option>";
}
foreach($tax_sec_80_result as $sec80_rslt){
$tax_act_details = $sec80_rslt->tax_act_details;
$tax_subsection_column = $sec80_rslt->tax_subsection_column;
if($option_val === $tax_subsection_column){
$option_80_sel = "selected";
}else{
$option_80_sel = "";
}
$option_80 .= "<option value='$tax_subsection_column' $option_80_sel>$tax_act_details</option>";
}
foreach($tax_sec_6a_result as $sec6a_rslt){
$tax_act_details = $sec6a_rslt->tax_act_details;
$tax_subsection_column = $sec6a_rslt->tax_subsection_column;
if($option_val === $tax_subsection_column){
$option_6a_sel = "selected";
}else{
$option_6a_sel = "";
}
$option_6a .= "<option value='$tax_subsection_column' $option_6a_sel>$tax_act_details</option>";
}
foreach($oth_sec_result as $oth_rslt){
$income_description = $oth_rslt->income_description;
$other_income_column = $oth_rslt->other_income_column;
if($option_val === $other_income_column){
$oth_option_sel = "selected";
}else{
$oth_option_sel = "";
}
$oth_option.= "<option value='$other_income_column' $oth_option_sel>$income_description</option>";
}
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='0' type='hidden'/></th><th>";
if($tax_section_head === "taxsec_1"){
$area_id ='field_column_'.$form_sixteen_id;
$input_line = "<select id='form_16_$form_sixteen_id' class='form-control input-sm select2' onchange=mapping_change_fun(id,'$area_id') multiple>$option_10</select></th><th><textarea class='form-control' name='form_16_$form_sixteen_id' id='field_column_$form_sixteen_id' ></textarea>";
}elseif($tax_section_head === "taxsec_2"){
$area_id ='field_column_'.$form_sixteen_id;
$input_line = "<select id='form_16_$form_sixteen_id' class='form-control input-sm select2' onchange=mapping_change_fun(id,'$area_id') multiple>$option_16</select></th><th><textarea class='form-control' name='form_16_$form_sixteen_id' id='field_column_$form_sixteen_id' ></textarea>";
}elseif($tax_section_head === "taxsec_3"){
$area_id ='field_column_'.$form_sixteen_id;
$input_line = "<select id='form_16_$form_sixteen_id' class='form-control input-sm select2' onchange=mapping_change_fun(id,'$area_id') multiple>$option_80</select></th><th><textarea class='form-control' name='form_16_$form_sixteen_id' id='field_column_$form_sixteen_id' ></textarea>";
}elseif($tax_section_head === "taxsec_4"){
$area_id ='field_column_'.$form_sixteen_id;
$input_line = "<select id='form_16_$form_sixteen_id' class='form-control input-sm select2' onchange=mapping_change_fun(id,'$area_id') multiple>$option_6a</select></th><th><textarea class='form-control' name='form_16_$form_sixteen_id' id='field_column_$form_sixteen_id' ></textarea>";
}elseif($tax_section_head === "otherin_1"){
$area_id ='field_column_'.$form_sixteen_id;
$input_line = "<select id='form_16_$form_sixteen_id' class='form-control input-sm select2' onchange=mapping_change_fun(id,'$area_id') multiple>$oth_option</select></th><th><textarea class='form-control' name='form_16_$form_sixteen_id' id='field_column_$form_sixteen_id' ></textarea>";
}
if($form_sixteen_id == 3){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='gross_17a' type='hidden'/></th><th>";
}
if($form_sixteen_id == 4){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='gross_17b' type='hidden'/></th><th>";
}
if($form_sixteen_id == 5){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='gross_17c' type='hidden'/></th><th>";
}
if($form_sixteen_id == 6){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='earning_total' type='hidden'/></th><th>";
}
if($form_sixteen_id == 21){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='tot_taxsec_1' type='hidden'/></th><th>";
}
if($form_sixteen_id == 22){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='gross_tot_taxsec_1' type='hidden'/></th><th>";
}
if($form_sixteen_id == 27){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='tot_taxsec_2' type='hidden'/></th><th>";
}
if($form_sixteen_id == 28){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='gross_tot_taxsec_2' type='hidden'/></th><th>";
}
if($form_sixteen_id == 32){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='tot_other' type='hidden'/></th><th>";
}
if($form_sixteen_id == 38){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='tot_taxsec_3' type='hidden'/></th><th>";
}
if($form_sixteen_id == 52){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='tot_taxsec_4' type='hidden'/></th><th>";
}
if($form_sixteen_id == 53){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='final_gross' type='hidden'/></th><th>";
}
if($form_sixteen_id == 54){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='total_tax' type='hidden'/></th><th>";
}
if($form_sixteen_id == 55){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='rebate_amt' type='hidden'/></th><th>";
}
if($form_sixteen_id == 56){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='surcharge_amt' type='hidden'/></th><th>";
}
if($form_sixteen_id == 57){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='edu_cess' type='hidden'/></th><th>";
}
if($form_sixteen_id == 58){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='tax_amt' type='hidden'/></th><th>";
}
if($form_sixteen_id == 59){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='relief_amt' type='hidden'/></th><th>";
}
if($form_sixteen_id == 60){
$input_line = "<input id='form_16_$form_sixteen_id' name='form_16_$form_sixteen_id' value ='final_tax_amt' type='hidden'/></th><th>";
}
$tr_line .= "<tr><td>".$tax_act."</td><td style='width: 30%'>$input_line</td></tr>";
}
$table_info = "<table class='table table-bordered' id='form16'>
<thead>
<tr>
<th>Tax Act</th>
<th>Mapping</th>
<th>column Map</th>
</tr>
</thead>
<tbody>
$tr_line
</tbody>
</table>";
echo $table_info;
?>
</div>
</form>
</div>
</div>
<script type="text/javascript">
$(document).ready(function (){
fetch_data()
select_call();
$("#form16").DataTable({
processing : true,
"order" : [],
serverSide : false,
destroy : true,
paging : true,
lengthMenu : [[-1],['All']],
language : {
lengthMenu : "<span style='margin-top:8px;margin-left:10px;'>Display</span> _MENU_ <span style='margin-top:8px;'>Records</span>",
searchPlaceholder: "Search records",
search : "",
processing : '<div style="text-align: center; padding: 50px;color:#4b6fa2;z-index:999999999;"><i class="fa fa-spinner fa-spin fa-2x fa-fw"></i><br/>Loading...</div>',
}
});
$('input[type=search]').addClass('form-control input-sm');
$("select[name='table_length']" ).addClass('form-control input-sm');
$("#form16_length").append(`<button class='dt-button buttons-collection btn btn-xs btn-edit' id="submit">Submit</button>`);
$("#form_16_map").validate({
submitHandler: function(form){
$("#submit").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
$('#submit').attr('disabled','disabled');
var form_16_data = JSON.stringify($("#form_16_map").serializeArray());
var key = '<?php echo $key; ?>';
var data = {form_16_data:form_16_data};
var encData = encrypt(key,data);
$.ajax({
type : "POST",
url : '<?php echo site_url($controller_name . "/save_mapping_data"); ?>',
data:encData,
contentType: 'text/plain',
success : function (data) {
var rslt = JSON.parse(data);
if(rslt.success){
toastr.success(rslt.msg);
}
$('#submit').attr('disabled',false);
$("#submit").html("Submit");
}
});
}
});
});
//DROPDOWN ONCHANGE
function mapping_change_fun(sel_id, text_area_id) {
var select_value = $.trim($("#" + sel_id).val());
var text_area = $("#" + text_area_id);
text_area.val('');
let res = select_value.replace(/,/g, "+");
text_area.val(res);
var selected_val = select_value.split(',');
$("select").not("#" + sel_id).each(function(){
var dropdown_val = $(this).val();
if(Array.isArray(dropdown_val)){
for(var i = 0; i < dropdown_val.length; i++){
if(selected_val.includes(dropdown_val[i])){
$("#" + sel_id).find("option[value='" + dropdown_val[i] + "']").prop("selected", false);
$("#" + sel_id).trigger('change');
toastr.warning("This option is already selected in another dropdown. Please choose another option.");
return false;
}
}
}
});
}
//ONLOAD DATA FETCH
function fetch_data(){
$.ajax({
type : "POST",
url : '<?php echo site_url($controller_name."/fetch_data"); ?>',
success : function(data){
var rslt = JSON.parse(data);
if(rslt.success){
rslt.form16.forEach((item, index) => {
if(item.form16_value !== ''){
var values = item.form16_value.split('+');
$("#"+item.form16_key).val(values).trigger('change');
}
});
}
}
});
}
//SELECT2
function select_call(){
$(function(){
$('.select2').select2({
placeholder: '---- Select ----',
});
$('.select2-tags').select2({
tags: true,
tokenSeparators: [',']
});
});
}
</script>
<style>
#form16_length > label{
margin-right: 15px;
}
.select2-container {
width: 98% !important;
}
</style>
<?php $this->load->view("partial/footer"); ?>