File: /home/cafsindia/hrms_cafsindia_com/application/views/payroll_wizard/manage.php
<?php
$this->load->view("partial/header");
$access_data = $this->session->userdata('access_data');
$access_add = (int)$access_data[$controller_name]['access_add'];
$access_update = (int)$access_data[$controller_name]['access_update'];
$access_delete = (int)$access_data[$controller_name]['access_delete'];
$access_search = (int)$access_data[$controller_name]['access_search'];
$access_export = (int)$access_data[$controller_name]['access_export'];
$access_import = (int)$access_data[$controller_name]['access_import'];
$page_name = ucwords(str_replace("_"," ",$controller_name));
$all_formula = [];
$all_formula = array_merge($formula_master,$all_formula);
$all_formula = array_merge($formula_earning,$all_formula);
$all_formula = array_merge($formula_deduction,$all_formula);
?>
<style>
body{
overflow-x: hidden;
}
th{
position: sticky;
top: 0;
z-index: 1;
background-color: #f2f2f2;
}
.select2-selection--multiple{
overflow-y: scroll !important;
height: 60px;
border-radius: 10px;
}
table#calculator {
border-spacing: 10px 8px;
border-collapse: inherit;
width: 100%;
text-align: center;
}
table#calculator > tbody>tr>td:hover{
background-color: #f9f9f9;
}
/* //.btn:hover, .btn:focus, .btn.focus */
table#calculator > tbody>tr>td{
padding: 1px 15px;
border: 1px solid #CCCCCC;
font-size: 25px;
background-color: #f2f2f2;
border-radius: 4px;
cursor: pointer !important;
box-shadow: 0 2px 2px 0 rgb(0 0 0 / 14%), 0 1px 5px 0 rgb(0 0 0 / 12%) !important;
}
.popover-content {
padding: 9px 14px;
height: auto !important;
word-break: break-all !important;
}
</style>
<div class='row' style="margin: 0px;max-height:500px;margin-bottom: 15px;">
<div class='col-md-12 col-xs-12'>
<div class='row' style="margin: 0px;padding:10px 0px;">
<div class='col-md-9 col-xs-9'>
<h1 class='page_txt'><?php echo $page_name;?></h1>
</div>
<div class='col-md-3 col-xs-3' style="text-align:right;">
<button class='btn btn-xs btn-edit' id="report_list_view_btn">View all report</button>
</div>
</div>
</div>
<!--- REPORT INPUT - START --->
<div class='col-md-12 col-xs-12' style='margin-bottom: 15px;'>
<div class="row form-inline">
<div class="form-group">
<?php
echo form_label($this->lang->line('report_list'), 'report_list', array('class' => 'required'));
echo form_dropdown(array( 'name' => 'report_list', 'id' => 'report_list', 'class' => 'form-control input-sm select2'), $report_list);
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label($this->lang->line('category_for'), 'category_for', array('class' => 'required'));
echo form_dropdown(array( 'name' => 'category_for[]', 'multiple id' =>'category_for', 'class' => 'form-control input-sm select2'), $category_for);
echo "<label><input name='category_for_select' id='category_for_select' type='checkbox' style='cursor:pointer;'> Select All</label>";
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label($this->lang->line('duration_type'), 'duration_type', array('class' => 'required'));
$duration_type_array = array(""=>"---- Duration Type ----",1=>"Single Month",2=>"Multi Month");
echo form_dropdown(array( 'name' => 'duration_type', 'id' => 'duration_type', 'class' => 'form-control input-sm select2'), $duration_type_array);
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label($this->lang->line('report_type'), 'report_type', array('class' => 'required'));
$report_type_array = array(""=>"---- Report Type ----",1=>"Consolidate",2=>"Detail",3=>"Only Master");
echo form_dropdown(array( 'name' => 'report_type', 'id' => 'report_type', 'class' => 'form-control input-sm select2'), $report_type_array);
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label($this->lang->line('group_by'), 'group_by');
echo form_dropdown(array( 'name' => 'group_by[]', 'multiple id' =>'group_by', 'class' => 'form-control input-sm select2'), $group_by);
?>
</div>
<div class="form-group" style="display:none;" >
<label id='sub_total_div'>
<input name='sub_total' id='sub_total' type="checkbox" checked> Sub Total
</label>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label("Display Format", 'display_format');
$display_format_array = array(""=>"---- Display Format ----",1=>"Horizonal",2=>"Vertical");
echo form_dropdown(array( 'name' => 'display_format', 'id' =>'display_format', 'class' => 'form-control input-sm select2'), $display_format_array);
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label("From Month", 'from_month', array('class' => 'required'));
echo form_input(array("name"=>"from_month", "id"=>"from_month","value"=>$date,"placeholder"=>"From date","class"=>"form-control input-sm datepicker_month"));
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label("To Month", 'to_month', array('class' => 'required'));
echo form_input(array("name"=>"to_month", "id"=>"to_month","value"=>$date,"placeholder"=>"From date","class"=>"form-control input-sm datepicker_month"));
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label("Save/Update", 'save_upd');
$save_upd_array = array(""=>"---- Save / Update ----",1=>"Save",2=>"Duplicate",3=>"Update");
echo form_dropdown(array( 'name' => 'save_upd', 'id' => 'save_upd', 'class' => 'form-control input-sm select2'), $save_upd_array);
?>
</div>
<div class="form-group" style="display:none;">
<?php
echo form_label($this->lang->line('report_title'), 'report_title', array('class' => 'required'));
echo form_input(array( 'name' => 'report_title', 'id' => 'report_title', 'class' => 'form-control input-sm', 'placeholder'=>$this->lang->line('report_title'),'value' => ''));
?>
</div>
</div>
</div>
<!--- REPORT INPUT - END --->
<!--- TAB & REPORT SELECT INFORMATION HOLDER - START --->
<div class='col-md-12 col-xs-12' style='margin-bottom: 30px;display:none;' id="report_tab_holder">
<div class="row">
<!--- REPORT TAB - START --->
<div class="col-md-4">
<ul class="nav nav-tabs" data-tabs="tabs" id="input_tab">
<li class="active" role="presentation">
<a data-toggle="tab" data_id="master_tab" href="#master_tab">Master</a>
</li>
<li role="presentation">
<a data-toggle="tab" data_id="earning_tab" href="#earning_tab">Earning</a>
</li>
<li role="presentation">
<a data-toggle="tab" data_id="deduction_tab" href="#deduction_tab">Deduction</a>
</li>
<li role="presentation">
<a data-toggle="tab" data_id="formula_tab" href="#formula_tab">Formula</a>
</li>
<li role="presentation">
<a data-toggle="modal" data-target="#filter_module" style="cursor:pointer;">Filter</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="master_tab">
<div style='padding:4px;background-color:#f2f2f2;color:#000000;'>
<input id="master_search" type="text" placeholder="Search.." style="width:100%" class='form-control input-sm'>
</div>
<div style="max-height:350px;overflow:auto;">
<table class='table table-hover table-striped'>
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<th>
<input type='checkbox' id='master_all' value='master_all' style='cursor:pointer;'>
</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="master_body">
<?php
foreach($master as $master_info){
$prime_form_id = $master_info['prime_form_id'];
$label_name = $master_info['label_name'];
$view_name = $master_info['view_name'];
$transaction_type = (int)$master_info['transaction_type'];
$trans_name = $master_info['trans_name'];
$trans_color ="";
if($transaction_type === 2){
$trans_color = "#e3f7e4";
}else
if($transaction_type === 3){
$trans_color = "#f1dadc";
}else
if($transaction_type === 4){
$trans_color = "#f5e6d2";
}
if(($label_name !== "employee_code") && ($label_name !== "emp_name")){
$master_id_info = "MASTER_$prime_form_id";
echo "<tr style='background-color:$trans_color;cursor:pointer;'>
<td>
<input type='checkbox' id='$master_id_info' value='$master_id_info' style='cursor:pointer;'>
</td>
<td>$view_name</td>
<td>$trans_name</td>
</tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="earning_tab">
<div style='padding:4px;background-color:#f2f2f2;color:#000000;'>
<input id="earning_search" type="text" placeholder="Search.." style="width:100%" class='form-control input-sm'>
</div>
<div style="max-height:350px;overflow:auto;">
<table class='table table-hover table-striped'>
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<th>
<input type='checkbox' id='earning_all' value='earning_all' style='cursor:pointer;'>
</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="earning_body">
<?php
foreach($earning as $earning_info){
$prime_form_id = $earning_info['prime_form_id'];
$label_name = $earning_info['label_name'];
$view_name = $earning_info['view_name'];
$transaction_type = (int)$earning_info['transaction_type'];
$trans_name = $earning_info['trans_name'];
$gross_check = (int)$earning_info['gross_check'];
$earning_id_info = "EARNING_$prime_form_id";
$trans_color ="";
if($gross_check === 1){
$trans_name = "Include for Gross";
$trans_color = "#e3f7e4";
}
echo "<tr style='background-color:$trans_color;cursor:pointer;'>
<td>
<input type='checkbox' id='$earning_id_info' value='$earning_id_info' style='cursor:pointer;'>
</td>
<td>$view_name</td>
<td>$trans_name</td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="deduction_tab">
<div style='padding:4px;background-color:#f2f2f2;color:#000000;'>
<input id="deduction_search" type="text" placeholder="Search.." style="width:100%" class='form-control input-sm'>
</div>
<div style="max-height:350px;overflow:auto;">
<table class='table table-hover table-striped'>
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<th>
<input type='checkbox' id='deduction_all' value='deduction_all' style='cursor:pointer;'>
</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="deduction_body">
<?php
foreach($deduction as $deduction_info){
$prime_form_id = $deduction_info['prime_form_id'];
$label_name = $deduction_info['label_name'];
$view_name = $deduction_info['view_name'];
$transaction_type = (int)$deduction_info['transaction_type'];
$trans_name = $deduction_info['trans_name'];
$deduction_check = (int)$deduction_info['deduction_check'];
$deduction_id_info = "DEDUCTION_$prime_form_id";
$trans_color ="";
if($deduction_check === 1){
$trans_name = "Include for Gross";
$trans_color = "#f1dadc";
}
echo "<tr style='background-color:$trans_color;cursor:pointer;'>
<td>
<input type='checkbox' id='$deduction_id_info' value='$deduction_id_info' style='cursor:pointer;'>
</td>
<td>$view_name</td>
<td>$trans_name</td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="formula_tab">
<div class="row" style="margin:0px;padding:10px;">
<div class="form-group">
<input type='hidden' id="formula_mode" name="formula_mode" value=""/>
<input type='hidden' id="formula_id" name="formula_id" value=""/>
<?php
echo form_label("Formula Name", 'formula_name', array('class' => 'required'));
echo form_input(array( 'name' => 'formula_name', 'id' => 'formula_name', 'class' => 'form-control input-sm', 'placeholder'=>"Formula Name",'value' => '',"maxlength"=>'100'));
?>
</div>
<div class="form-group">
<?php
echo form_label("Formula For", 'formula_for', array('class' => 'required'));
$formula_for = array(""=>"---- Formula For ----",1=>"Master",2=>"Earning",3=>"Deduction"); //
echo form_dropdown(array( 'name' => 'formula_for', 'id' =>'formula_for', 'class' => 'form-control input-sm select2'), $formula_for);
?>
</div>
<div class="form-group">
<?php
echo form_label("Master", 'formula_master', array('class' => 'required'));
echo form_dropdown(array( 'name' => 'formula_master', 'id' =>'formula_master', 'class' => 'form-control input-sm select2'), $formula_master);
?>
</div>
<div class="form-group">
<?php
echo form_label("Earning", 'formula_earning', array('class' => 'required'));
echo form_dropdown(array('name' => 'formula_earning', 'id' =>'formula_earning', 'class' => 'form-control input-sm select2'), $formula_earning);
?>
</div>
<div class="form-group">
<?php
echo form_label("Deduction", 'formula_deduction', array('class' => 'required'));
echo form_dropdown(array( 'name' => 'formula_deduction', 'id' =>'formula_deduction', 'class' => 'form-control input-sm select2'), $formula_deduction);
?>
</div>
<div class="form-group">
<textarea name='formula' id='formula' class='form-control' rows='4' placeholder='Query Column'></textarea>
</div>
<div class="form-group">
<div class="row" style="margin:0px;">
<div class="col-md-6">
<table id="calculator">
<tr>
<td id="+">+</td>
<td id="-">-</td>
<td id="*">*</td>
</tr>
<tr>
<td id="/">/</td>
<td id="(">(</td>
<td id=")">)</td>
</tr>
</table>
</div>
<div class="col-md-6" style='text-align:right;'>
<button class="btn btn-primary btn-sm" id="formula_submit">Add new field</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--- REPORT TAB - END --->
<!--- REPORT SELECT INFORMATION - START --->
<div class="col-md-8">
<div class="row" style="max-height:450px;overflow:auto;" id="select_holder">
<table class='table table-hover table-striped' id="select_table">
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<!-- <th>Sort Order</th> -->
<th>Type</th>
<th>Name</th>
<th>View name </th>
<th style='text-align:center;'>Total</th>
<th style='text-align:center;'>Formula</th>
<th style='text-align:center;'>Edit</th>
<th style='text-align:center;'>Remove</th>
</tr>
</thead>
<tbody id="selected_body" class='sortable report_sort' >
</tbody>
</table>
</div>
</div>
<!--- REPORT SELECT INFORMATION - END --->
</div>
</div>
<!--- TAB & REPORT SELECT INFORMATION HOLDER - END --->
<!--- REPORT BUTTON - START --->
<div class='col-md-12 col-xs-12' style='margin-bottom: 15px;display:none;' id="report_submit_holder">
<div class="row">
<div class="col-md-8">
<!-- <button class="btn btn-danger btn-sm" id="report_cancel">Cancel</button> -->
</div>
<!-- ROW COUNT BY [MS 16-07-2024] -->
<div class="col-md-2" style='text-align:right;'>
<h5 id="rowCount" style='font-weight: bold;'></h5>
</div>
<div class="col-md-2" style='text-align:right;'>
<button class="btn btn-primary btn-sm" id="report_submit">Download Report</button>
</div>
</div>
</div>
<!--- REPORT BUTTON - END --->
<!--- FILTER MODEL - START --->
<div class="modal fade" id="filter_module" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Filter</h4>
</div>
<div class="modal-body">
<div class="row" style="margin:15px 0px;">
<div class="col-md-4">
<ul class="nav nav-tabs" data-tabs="tabs" id="filter_tab">
<li class="active" role="presentation">
<a data-toggle="tab" data_id="filter_master_tab" href="#filter_master_tab">Master</a>
</li>
<li role="presentation">
<a data-toggle="tab" data_id="filter_earning_tab" href="#filter_earning_tab">Earning</a>
</li>
<li role="presentation">
<a data-toggle="tab" data_id="filter_deduction_tab" href="#filter_deduction_tab">Deduction</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="filter_master_tab">
<div style='padding:4px;background-color:#f2f2f2;color:#000000;'>
<input id="filter_master_search" type="text" placeholder="Search.." style="width:100%" class='form-control input-sm'>
</div>
<div style="max-height:350px;overflow:auto;">
<table class='table table-hover table-striped'>
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<th>select</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="filter_master_body">
<?php
foreach($master as $master_info){
$prime_form_id = $master_info['prime_form_id'];
$label_name = $master_info['label_name'];
$view_name = $master_info['view_name'];
$transaction_type = (int)$master_info['transaction_type'];
$trans_name = $master_info['trans_name'];
$field_type = (int)$master_info['field_type'];
$trans_color ="";
if($transaction_type === 2){
$trans_color = "#e3f7e4";
}else
if($transaction_type === 3){
$trans_color = "#f1dadc";
}else
if($transaction_type === 4){
$trans_color = "#f5e6d2";
}
if(($transaction_type === 1) || ($transaction_type === 4)){
if(($label_name !== "employee_code") && ($label_name !== "emp_name") && ($field_type !== 10)){
$master_id_info = "FILTER_MASTER_$prime_form_id";
echo "<tr style='background-color:$trans_color;cursor:pointer;'>
<td>
<input type='checkbox' id='$master_id_info' value='$master_id_info' style='cursor:pointer;'>
</td>
<td>$view_name</td>
<td>$trans_name</td>
</tr>";
}
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="filter_earning_tab">
<div style='padding:4px;background-color:#f2f2f2;color:#000000;'>
<input id="filter_earning_search" type="text" placeholder="Search.." style="width:100%" class='form-control input-sm'>
</div>
<div style="max-height:350px;overflow:auto;">
<table class='table table-hover table-striped'>
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<th>Select</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="filter_earning_body">
<?php
foreach($earning as $earning_info){
$prime_form_id = $earning_info['prime_form_id'];
$label_name = $earning_info['label_name'];
$view_name = $earning_info['view_name'];
$transaction_type = (int)$earning_info['transaction_type'];
$trans_name = $earning_info['trans_name'];
$gross_check = (int)$earning_info['gross_check'];
$field_type = (int)$earning_info['field_type'];
$earning_id_info = "FILTER_EARNING_$prime_form_id";
$trans_color ="";
if($gross_check === 1){
$trans_name = "Include for Gross";
$trans_color = "#e3f7e4";
}
if($field_type !== 10){
echo "<tr style='background-color:$trans_color;cursor:pointer;'>
<td>
<input type='checkbox' id='$earning_id_info' value='$earning_id_info' style='cursor:pointer;'>
</td>
<td>$view_name</td>
<td>$trans_name</td>
</tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="tab-pane fade" id="filter_deduction_tab">
<div style='padding:4px;background-color:#f2f2f2;color:#000000;'>
<input id="filter_deduction_search" type="text" placeholder="Search.." style="width:100%" class='form-control input-sm'>
</div>
<div style="max-height:350px;overflow:auto;">
<table class='table table-hover table-striped'>
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<th>Select</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody id="filter_deduction_body">
<?php
foreach($deduction as $deduction_info){
$prime_form_id = $deduction_info['prime_form_id'];
$label_name = $deduction_info['label_name'];
$view_name = $deduction_info['view_name'];
$transaction_type = (int)$deduction_info['transaction_type'];
$trans_name = $deduction_info['trans_name'];
$deduction_check = (int)$deduction_info['deduction_check'];
$field_type = (int)$deduction_info['field_type'];
$deduction_id_info = "FILTER_DEDUCTION_$prime_form_id";
$trans_color ="";
if($deduction_check === 1){
$trans_name = "Include for Gross";
$trans_color = "#f1dadc";
}
if($field_type !== 10){
echo "<tr style='background-color:$trans_color;cursor:pointer;'>
<td>
<input type='checkbox' id='$deduction_id_info' value='$deduction_id_info' style='cursor:pointer;'>
</td>
<td>$view_name</td>
<td>$trans_name</td>
</tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-8">
<div class="row" style="max-height:450px;overflow:auto;margin:0px;" id="filter_select_holder">
<table class='table table-hover table-striped' id="filter_sel_table">
<thead style="background-color:#f2f2f2;color:#000000;">
<tr>
<!-- <th>Sort Order</th> -->
<th>Type</th>
<th>Name</th>
<th style='text-align:center;'>conditon</th>
<th style='text-align:center;min-width:35%;max-width:35%;width:35%;'>values</th>
<th style='text-align:center;'>Remove</th>
</tr>
</thead>
<tbody id="filter_sel_body" class='sortable filter_sortable'>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Back</button>
</div>
</div>
</div>
</div>
<!--- FILTER MODEL - END --->
<!--- REPORT LIST VIEW - START --->
<div class="modal fade" id="report_list_view" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Report List</h4>
</div>
<div class="modal-body">
<!--
$("#category_for,#duration_type,#report_type,#group_by,#display_format,#from_month,#to_month,#save_upd,#report_title").val("");
$('#sub_total').prop('checked', false);
-->
<table class="table table-hover table-striped datatable_view dataTable" style="min-height:100px;">
<thead>
<tr>
<th>Sl.no.</th>
<th>Report</th>
<th>Category</th>
<th>Duration Type</th>
<th>Result Type</th>
<th>Group / Order By</th>
<th>Sub Total</th>
<th>Display Format</th>
<th>From Month</th>
<th>To Month</th>
<th>Action</th>
</tr>
</thead>
<tbody id="report_list_view_tbody">
</tbody>
</table>
</div>
</div>
</div>
</div>
<!--- REPORT LIST VIEW - END --->
</div>
<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script> -->
<script type="text/javascript">
$(document).ready(function (){
const common_fn = {
call_select(){
$('.select2').select2({
placeholder: '---- Select ----',
allowClear: true,
//tags: true,
});
$('.select2-tags').select2({
//tags: true,
allowClear: true,
tokenSeparators: [',']
});
},
call_datepicker(){
$(".datepicker").datetimepicker({
format: 'DD-MM-YYYY',
});
$(".datepicker_month").datetimepicker({
format: 'MM-YYYY',
});
$(".datepicker_year").datetimepicker({
format: 'YYYY',
});
$('.only_time').datetimepicker({
format: 'HH:mm',
});
$(".datepicker_time").datetimepicker({
format: 'DD-MM-YYYY HH:mm:ss',
//debug: true
});
},
clear_error(){
var error_msg = $(".val_error").is(":visible");
if(error_msg){ $(".val_error").remove(); }
},
clear_screen(){
$("#category_for,#duration_type,#report_type,#group_by,#display_format,#from_month,#to_month,#save_upd,#report_title").val("");
$('#sub_total').prop('checked', false);
$('#category_for_select').prop('checked', false);
$("#category_for,#duration_type,#report_type,#group_by,#display_format,#from_month,#to_month,#save_upd,#report_title,#sub_total_div").parent().hide();
$('#report_tab_holder,#report_submit_holder').hide();
$.each(Object.keys(selected_info), function(key, select_id){
delete selected_info[select_id]
$("#select_table tbody tr#tr_"+select_id).remove();
document.getElementById(select_id).checked = false;
});
document.getElementById("master_all").checked = false;
document.getElementById("earning_all").checked = false;
document.getElementById("deduction_all").checked = false;
$.each(Object.keys(filter_sel_info), function(key,filter_id) {
delete filter_sel_info[filter_id];
$("#filter_sel_table tbody tr#ftr_"+filter_id).remove();
document.getElementById(filter_id).checked = false;
});
common_fn.call_datepicker();
},
upd_screen(rslt_info){
var head_info = rslt_info.head
var column_info = rslt_info.column
var filter_info = rslt_info.filter
/* --- HEAD INFORMATION - START ---*/
$.map(head_info, function(value,key){
if(key !== "sub_total"){
$("#"+key).val(value);
}
});
$('#sub_total').prop('checked', false);
if(parseInt(head_info.sub_total) === 1){
$('#sub_total').prop('checked', true);
}
$('#category_for,#duration_type,#save_upd').parent().show();
$('#report_type option[value="1"]').attr('disabled',false);
$('#report_type option[value="3"]').attr('disabled',false);
var duration_type = $("#duration_type").val();
if(parseInt(head_info.duration_type) === 2){
$('#report_type option[value="1"]').attr('disabled',true);
$('#report_type option[value="3"]').attr('disabled',true);
}
$('#report_type').parent().show();
$('#input_tab li > a').parent().removeClass('active')
$('#master_tab,#earning_tab,#deduction_tab,#formula_tab').removeClass('active in');
$('#input_tab li > a[data_id=master_tab],#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().addClass('hide');
if((parseInt(head_info.duration_type) === 1) && (parseInt(head_info.report_type) === 1)){
$('#report_tab_holder').show();
$('#from_month,#to_month,#group_by').parent().show();
$('#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().removeClass('hide');
$('#input_tab li > a[data_id=earning_tab]').parent().removeClass('hide').addClass('active');
$('#earning_tab').addClass('active in');
}else
if((parseInt(head_info.duration_type) === 1) && (parseInt(head_info.report_type) === 2)){ // Single Month & Detail
$('#report_tab_holder').show();
$('#from_month,#group_by').parent().show();
$('#input_tab li > a[data_id=master_tab],#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().removeClass('hide');
$('#input_tab li > a[data_id=master_tab]').parent().removeClass('hide').addClass('active');
$('#master_tab').addClass('active in');
}else
if((parseInt(head_info.duration_type) === 1) && (parseInt(head_info.report_type) === 3)){ // Single Month & Only Mater
$('#report_tab_holder').show();
$('#input_tab li > a[data_id=master_tab]').parent().removeClass('hide').addClass('active');
$('#master_tab').addClass('active in');
}else
if((parseInt(head_info.duration_type) === 2) && (parseInt(head_info.report_type) === 2)){ // Multi Month & Detail
$('#report_tab_holder').show();
$('#from_month,#to_month,#group_by,#display_format').parent().show();
$('#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().removeClass('hide');
$('#input_tab li > a[data_id=earning_tab]').parent().removeClass('hide').addClass('active');
$('#earning_tab').addClass('active in');
}
if(head_info.group_by === null){
$('#display_format').parent().hide();
}else{
group_by = head_info.group_by.filter(function(v){return v!==''});
let group_len = group_by.length;
if(((parseInt(head_info.duration_type) === 1) && (parseInt(head_info.report_type) === 1) && (group_len === 1 ) || ((parseInt(head_info.duration_type) === 2) && (parseInt(head_info.report_type) === 2)))){
$('#display_format').parent().show();
}else{
$('#display_format').parent().hide();
}
if((parseInt(head_info.duration_type) === 1) && (parseInt(head_info.report_type) === 2) && (group_len > 0 )){
$('#sub_total_div').parent().show();
}else{
$('#sub_total_div').parent().hide();
}
}
common_fn.call_select();
/* --- HEAD INFORMATION - END ---*/
/* --- COLUMN INFORMATION - SATRT --- */
$.map(column_info, function(value,key){
var pro_key = value.pro_key
selected_info[pro_key] = value
common_fn.selected_tr(pro_key);
document.getElementById(pro_key).checked = true;
});
/* --- COLUMN INFORMATION - END --- */
/* --- FILTER INFORMATION - SATRT --- */
$.map(filter_info, function(value,key){
var pro_key = "FILTER_"+value.pro_key
filter_sel_info[pro_key] = value
common_fn.filter_sel_tr(pro_key);
document.getElementById(pro_key).checked = true;
});
/* --- FILTER INFORMATION - END --- */
},
upd_report_list_view(response,msg_mode){
if(msg_mode){
if(response.success){
toastr.success(response.message);
}else{
toastr.error(response.message);
}
common_fn.clear_screen();
$('#report_list').empty();
$.each(response.report_list, function(key, value) {
$("#report_list").append($("<option></option>").attr("value",key).text(value));
});
$("#report_list").val("");
common_fn.call_select();
}
$('#report_list_view_tbody').html("");
$('#report_list_view_tbody').html(response.rslt);
$('#report_list_view_tbody tr td button.delete').click(function(event){
var delete_id = event.target.id;
if(delete_id){
$.confirm({
title: 'Confirm!',
content: 'Are you sure. you want delete select records??',
escapeKey: 'Yes',
onOpenBefore: function () {
},
buttons: {
yes: {
text: 'Yes',
btnClass: 'btn-success',
action: function(){
var form_data = JSON.stringify({delete_id:delete_id});
$.ajax({
url: '<?php echo site_url("$controller_name/delete_report_list"); ?>',
data: {form_data},
type: 'POST',
success:function(data){
var response = JSON.parse(data);
common_fn.upd_report_list_view(response,true);
},
});
}
},
no: {
text: 'No',
btnClass: 'btn-red',
action: function(){
toastr.warning("Delete action terminated");
}
},
}
});
}else{
toastr.error("No record selected");
}
});
},
get_row_info(db_info){
var master = db_info.master;
var earning = db_info.earning;
var deduction = db_info.deduction;
var select_id = db_info.select_id;
const id_info = select_id.split("_");
var from = id_info[0];
var from_index = id_info[1];
if(from === "FILTER"){
from = id_info[1];
from_index = id_info[2];
}
var row_info = false
if((from === "MASTER") && (master[from_index])){
row_info = master[from_index];
}else
if((from === "EARNING") && (earning[from_index])){
row_info = earning[from_index];
}else
if((from === "DEDUCTION") && (deduction[from_index])){
row_info = deduction[from_index];
}
row_info.formula_info = "";
row_info.total = 0;
if(row_info.field_type === 2){
row_info.total = 1;
}
return row_info;
},
formula_onchange(allowed_option,ignore_option,change_id){
if(change_id){
common_fn.clear_error();
var formula_info = $("#formula").val();
formula_info = formula_info.trim().toLowerCase().replace(/ /g,"");
var formula_master = $(change_id).val();
if(formula_info !== ""){
var check_str = formula_info.substr(-1);
if(!($.inArray(check_str, allowed_option) !== -1)){
$(change_id).val("");
formula_master = "";
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please check formula or arithmetic operator</div>");
}
if((check_str === ")") && (formula_master !== "")){
var check_forumal = check_str+formula_master.substr(-1);
if($.inArray(check_forumal, ignore_option) !== -1){
$(change_id).val("");
formula_master = "";
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please check formula or arithmetic operator</div>");
}
}
var check_str2 = formula_info.substr(-2);
if($.inArray(check_str2, ignore_option) !== -1){
$(change_id).val("");
formula_master = "";
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please check formula or arithmetic operator</div>");
}
}
var formula = formula_info+formula_master;
$('#formula').val(formula);
}
},
selected_tr(select_id){
if(select_id){
var selecte_length = Object.keys(selected_info).length;
var rowCount = $('#select_table tr').length;//Changed by [MS 16-07-2024]
if(selecte_length === 0){
$('#selected_body').html("");
$('#report_submit_holder').hide();
}else{
$('#report_submit_holder').show();
}
$('#rowCount').html('Count : '+rowCount);//Changed by [MS 16-07-2024]
var process_info = selected_info[select_id];
if(process_info){
const id_info = select_id.split("_");
var from = id_info[0];
var type = "-";
if(from === "MASTER"){
type = "Master";
}else
if(from === "EARNING"){
type = "Earning";
}else
if(from === "DEDUCTION"){
type = "Deduction";
}else
if(from === "NEW"){
type = "New";
}
var sort_order = selecte_length
var prime_form_id = process_info.prime_form_id;
var label_name = process_info.label_name;
var name = process_info.view_name;
var view_name = process_info.view_name;
var transaction_type = process_info.transaction_type;
var trans_name = process_info.trans_name;
var field_type = parseInt(process_info.field_type);
var pick_list_type = process_info.pick_list_type;
var pick_list = process_info.pick_list;
var pick_table = process_info.pick_table;
var auto_prime_id = process_info.auto_prime_id;
var auto_dispaly_value = process_info.auto_dispaly_value;
var pick_display_value = process_info.pick_display_value;
var formula_info = "";
if(trans_name === "NEW"){
formula_info = process_info.formula_info
name = view_name
}
var tr_id = "tr_"+select_id;
var label_id = "label_"+select_id;
var total_td = "<td style='padding:4px;text-align:center;'>-</td>";
var formula_td = "<td style='padding:4px;text-align:center;'>-</td>";
var edit_td = "<td style='padding:4px;text-align:center;'>-</td>";
if(field_type === 2){
total_td = "<td style='padding:4px;text-align:center;'><input class='tot_input' type='checkbox' id="+select_id+" checked style='cursor:pointer;' /></td>";
}
if(trans_name === "NEW"){
total_td = "<td style='padding:4px;text-align:center;'><input class='tot_input' type='checkbox' id="+select_id+" checked style='cursor:pointer;'/></td>";
formula_td = "<td style='padding:4px;text-align:center;'> <span style='cursor:pointer;' class='btn btn-xs btn-default' data-container='body' data-toggle='popover' data-placement='bottom' data-content='"+formula_info+"'><i class='fa fa-info-circle' aria-hidden='true'></i></span></td>";
edit_td = "<td style='padding:4px;text-align:center;'><button class='btn btn-xs btn-edit edit' id="+select_id+">Edit</button></td>";
}
//<td style='padding:4px;'>"+type+"</td>
var td_info = "<td style='padding:4px;'>"+type+"</td><td style='padding:4px;' id="+label_id+" >"+name+"</td><td style='padding:4px;'><input type='text' style='width:100%' class='form-control input-sm edit_input' id="+select_id+" value='"+view_name+"' maxlength='100'/></td>"+total_td + formula_td+edit_td+"<td style='padding:4px;text-align:center;' class='remove' ><button class='btn btn-xs btn-edit remove' id="+select_id+">Delete</button></td>";
if(document.getElementById(tr_id)){
$("#"+tr_id).html(td_info);
}else{
var tr_info = "<tr style='cursor:pointer;' id="+tr_id+">"+td_info+"</tr>";
$("#select_table tbody").append(tr_info);
}
}else{
toastr.error("Unaable to get selected information");
}
}else{
toastr.error("Invalid select id");
}
$('[data-toggle="popover"]').popover();
// $('#selected_body tr td input.edit_input').bind('keypress', function (event){
// var regex = new RegExp("^[a-zA-Z0-9_ ]+$");
// var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
// if (!regex.test(key)) {
// event.preventDefault();
// toastr.error("only alphanumeric & underscore allowed");
// return false;
// }
// });
$('#selected_body tr td input.edit_input').on('keyup', function (event) {
event.target.value = event.target.value.replace(/[^a-zA-Z0-9_ ]/g,'');
var edit_id = event.target.id;
var edit_value = event.target.value;
if(edit_id){
var view_name_length = edit_value.length;
if(view_name_length > 100){
toastr.error("Max char length is 100");
}else{
var edit_info = selected_info[edit_id];
edit_info.view_name = edit_value
if(edit_info.trans_name === "NEW"){
edit_info.label_name = edit_value
}
selected_info[edit_id] = edit_info
$("#label_"+edit_id).html(edit_value);
}
}
});
$('#selected_body tr td input.tot_input').on('change', function (event) {
var tot_id = event.target.id;
var tot_info = selected_info[tot_id];
if(this.checked) {
tot_info.total = 1
}else{
tot_info.total = 0
}
selected_info[tot_id] = tot_info
});
$('#selected_body tr td button.edit').click(function(event){
var edit_id = event.target.id
if(edit_id){
var edit_info = selected_info[edit_id];
$("#formula_mode").val("UPD");
$("#formula_id").val(edit_id);
$("#formula_name").val(edit_info.view_name);
$("#formula").val(edit_info.formula_info);
$('#input_tab li > a').parent().removeClass('active')
$('#master_tab,#earning_tab,#deduction_tab,#formula_tab').removeClass('active in');
$('#input_tab li > a[data_id=formula_tab]').parent().removeClass('hide').addClass('active');
$('#formula_tab').addClass('active in')
}
});
$('#selected_body tr td button.remove').click(function(event){
var remove_id = event.target.id
if(remove_id){//by [MS 16-07-2024]
$("#select_table tbody tr#tr_"+remove_id).remove();
var rowCount = $('#select_table tr').length;
rowCount = (rowCount - '1');
$('#rowCount').html('Count : '+rowCount);
document.getElementById(remove_id).checked = false;
delete selected_info[remove_id];
}
});
},
unselected_tr(select_id){//Changed by [MS 16-07-2024]
var rowCount = $('#select_table tr').length;
rowCount = (rowCount - '1');
$('#rowCount').html('Count : '+rowCount);
},
filter_sel_tr(select_id){
if(select_id){
var filter_sel_length = Object.keys(filter_sel_info).length;
if(filter_sel_length === 0){
$('#selected_body').html("");
$('#report_submit_holder').hide();
}else{
$('#report_submit_holder').show();
}
var process_info = filter_sel_info[select_id];
if(process_info){
var sort_order = filter_sel_length
var prime_form_id = process_info.prime_form_id;
var label_name = process_info.label_name;
var name = process_info.view_name;
var view_name = process_info.view_name;
var transaction_type = process_info.transaction_type;
var trans_name = process_info.trans_name;
var field_type = parseInt(process_info.field_type);
var pick_list_type = process_info.pick_list_type;
var pick_list = process_info.pick_list;
var pick_table = process_info.pick_table;
var auto_prime_id = process_info.auto_prime_id;
var auto_dispaly_value = process_info.auto_dispaly_value;
var pick_display_value = process_info.pick_display_value;
/*
1 => Text =>(1 => Only Text , 2=> Text With Number, 3 => Only Numbers).
2 => Decimals.
3 => Integer.
4 => Date =>(1 => Date - Month - Year , 2 => Month - Year , 3 => Year).
5 => Picklist
6 => Checkbox
7 => Multipicklist
8 => Summary Box(Like Text Box)
9 => Auto Complete Box
10 => File Upload Box
11 => Mobile Number
12 => Email
13 => Date & Time
14 => Readonly(Non Editable)
15 => Time(Time & Min)
*/
const id_info = select_id.split("_");
var from = id_info[1];
var type = "-";
if(from === "MASTER"){
type = "Master";
}else
if(from === "EARNING"){
type = "Earning";
}else
if(from === "DEDUCTION"){
type = "Deduction";
}else
if(from === "NEW"){
type = "New";
}
var tr_id = "ftr_"+select_id;
var input_id = "input_"+select_id;
var from_id = "from_"+select_id;
var to_id = "to_"+select_id;
var condtion_id = "cond_"+select_id;
var picklist_sel = "picklist_"+select_id;
var picklist_btn = "picklistbtn_"+select_id;
var input = "-";
var condtion = "-";
var td_style = "";
if((field_type === 1) || (field_type === 11)|| (field_type === 12) || (field_type === 14)){
input = "<input type='text' style='width:100%' class='form-control input-sm filter_edit' value='"+process_info.where_val+"' placeholder="+name+" id="+input_id+" />";
condtion = "<select class='form-control input-sm filter_cond' id="+condtion_id+" ><option value='='>===</option><option value='!='>!==</option></select>";
}else
if((field_type === 2) || (field_type === 3)){
input = "<input type='text' style='width:100%' class='form-control input-sm filter_edit' value='"+process_info.where_val+"' placeholder="+name+" id="+input_id+" />";
condtion = "<select class='form-control input-sm filter_cond' id="+condtion_id+" ><option value='='>=</option><option value='!='>!=</option><option value='>'>></option><option value='>='>>=</option><option value='<'><</option><option value='<='><=</option></select>";
}else
if((field_type === 4) || (field_type === 13) || (field_type === 15)){
var class_name = "datepicker"
if(field_type === 13){
class_name = "datepicker_time";
}else
if(field_type === 15){
class_name = "only_time";
}
td_style = "style='display: flex;'"
input = "<input type='text' id="+from_id+" value='"+process_info.where_val_from+"' style='width:100%;margin: 0px 2px;' class='form-control input-sm "+class_name+" filter_edit_date' placeholder='Date'/> <input type='text' id="+to_id+" value='"+process_info.where_val_to+"' style='width:50%;margin: 0px 2px;' class='form-control input-sm "+class_name+" filter_edit_date hide' placeholder='Date'/>";
condtion = "<select class='form-control input-sm filter_cond_date' id="+condtion_id+"><option value='==='>=</option><option value='!=='>!=</option><option value='>'>></option><option value='>='>>=</option><option value='<'><</option><option value='<='><=</option><option value='between'>Between</option></select>";
}else
if((field_type === 5) || (field_type === 7) || (field_type === 9)){
var option = "";
var opt_exit = false;
$.each(process_info.where_sel_list, function(key, value) {
opt_exit = true;
option += "<option value="+key+">"+value+"</option>";
});
if(opt_exit){
input = "<select class='form-control input-sm select2 filter_pick_change' multiple id="+picklist_sel+" name="+picklist_sel+"[] >"+option+"</select>";
}else{
input = "<select class='form-control input-sm select2 filter_pick_change hide' multiple id="+picklist_sel+" name="+picklist_sel+"[] ></select><button class='btn btn-xs btn-edit get_picklist' id="+picklist_btn+">Get Picklist</button>";
}
}
//<td style='padding:4px;'>"+name+"</td>
var td_info = "<td style='padding:4px;'>"+name+"<input type='hidden' value='"+sort_order+"' name='sort_name'><input type='hidden' value='"+select_id+"' name='prime_form_id'></td><td style='padding:4px;'>"+type+"</td><td style='padding:4px;'>"+condtion+"</td><td "+td_style+">"+input+"</td><td style='padding:4px;text-align:center;' class='remove' ><button class='btn btn-xs btn-edit remove' id="+select_id+">Delete</button></td>";
if(document.getElementById(tr_id)){
$("#"+tr_id).html(td_info);
}else{
var tr_info = "<tr style='cursor:pointer;' id="+tr_id+">"+td_info+"</tr>";
$("#filter_sel_table tbody").append(tr_info);
}
//UPDATE INPUT VALUE ON LOAD - START
if(process_info.where_cond === ""){
process_info.where_cond = "="
}
$("#"+condtion_id).val(process_info.where_cond);
if((opt_exit) && ((field_type === 5) || (field_type === 7) || (field_type === 9))){
$("#"+picklist_sel).val(process_info.where_val);
common_fn.call_select();
}
if((field_type === 4) || (field_type === 13) || (field_type === 15)){
$("#"+from_id).css("width", "100%");
$("#"+to_id).addClass('hide')
if(process_info.where_cond === "between"){
$("#"+to_id).removeClass('hide')
$("#"+from_id).css("width", "50%");
$("#"+to_id).css("width", "50%");
}
}
//UPDATE INPUT VALUE ON LOAD - END
}else{
toastr.error("Unaable to get selected information");
}
}else{
toastr.error("Invalid select id");
}
common_fn.call_datepicker();
$('#filter_sel_body tr td select.filter_cond').on('change', function(){
var condtion_id = this.id;
var input_id = this.id.replace("cond_", "input_");
var select_id = this.id.replace("cond_", "");
var process_info = filter_sel_info[select_id];
if(process_info){
process_info.where_cond = $("#"+condtion_id).val();
process_info.where_val = $("#"+input_id).val();
filter_sel_info[select_id] = process_info
}
});
$('#filter_sel_body tr td input.filter_edit').on('keyup', function (event){
var edit_id = event.target.id;
var edit_value = event.target.value;
var select_id = edit_id.replace("input_", "");
var process_info = filter_sel_info[select_id];
if(process_info){
var condtion_id = "#cond_"+select_id;
process_info.where_cond = $(condtion_id).val();
process_info.where_val = edit_value
filter_sel_info[select_id] = process_info
}
});
$('#filter_sel_body tr td select.filter_cond_date').on('change', function(){
var from_id = this.id.replace("cond_", "from_");
var to_id = this.id.replace("cond_", "to_");
$("#"+from_id).css("width", "100%");
$("#"+to_id).addClass('hide')
if(this.value === "between"){
$("#"+to_id).removeClass('hide')
$("#"+from_id).css("width", "50%");
$("#"+to_id).css("width", "50%");
}
var select_id = this.id.replace("cond_", "");
var process_info = filter_sel_info[select_id];
if(process_info){
process_info.where_cond = $("#"+this.id).val();
if(this.value === "between"){
process_info.where_val_from = $("#"+from_id).val();
process_info.where_val_to = $("#"+to_id).val();
process_info.where_val = "";
}else{
process_info.where_val_from = "";
process_info.where_val_to = "";
process_info.where_val = $("#"+from_id).val()
}
filter_sel_info[select_id] = process_info
}
});
$('#filter_sel_body tr td input.filter_edit_date').on('dp.hide', function(){
var select_id = this.id.replace("from_","");
select_id = select_id.replace("to_","");
var from_id = "from_"+select_id;
var to_id = "to_"+select_id;
var condtion_id = "cond_"+select_id;
var process_info = filter_sel_info[select_id];
if(process_info){
process_info.where_cond = $("#"+condtion_id).val();
if($("#"+condtion_id).val() === "between"){
process_info.where_val_from = $("#"+from_id).val();
process_info.where_val_to = $("#"+to_id).val();
process_info.where_val = "";
}else{
process_info.where_val_from = "";
process_info.where_val_to = "";
process_info.where_val = $("#"+from_id).val()
}
filter_sel_info[select_id] = process_info
}
});
$('#filter_sel_body tr td button.get_picklist').click(function(event){
var btn_id = event.target.id;
var picklist_btn = this.id;
var selected_id = this.id.replace("picklistbtn_", "");
var picklist_sel = this.id.replace("picklistbtn_", "picklist_");
var picklist_id = this.id.replace("picklistbtn_FILTER_", "");
var filter_val = this.id.replace("picklistbtn_", "");
var form_data = JSON.stringify({picklist_id:picklist_id});
$('#'+btn_id).html('<i class=\"fa fa-spinner fa-spin\"></i> Processing...');
$('#'+btn_id).attr('disabled','disabled');
$.ajax({
url: '<?php echo site_url("$controller_name/get_picklist"); ?>',
data: {form_data},
type: 'POST',
success:function(data){
$('#'+btn_id).attr('disabled',false);
$('#'+btn_id).html('Get Picklist');
var rslt = JSON.parse(data);
if(!rslt.success){
toastr.error(rslt.message);
}else{
$.each(rslt.rslt, function(key, value) {
$("#"+picklist_sel).append($("<option></option>").attr("value",key).text(value));
});
var process_info = filter_sel_info[selected_id];
if(process_info){
process_info.where_sel_list = rslt.rslt;
}
filter_sel_info[select_id] = process_info;
$("#"+picklist_btn).addClass('hide')
$("#"+picklist_sel).removeClass('hide')
common_fn.call_select();
}
},
});
});
$('#filter_sel_body tr td select.filter_pick_change').on('change', function(){
var select_value = $("#"+this.id).val();
var select_id = this.id.replace("picklist_", "");
var process_info = filter_sel_info[select_id];
if(process_info){
process_info.where_cond = "";
process_info.where_val = select_value
filter_sel_info[select_id] = process_info
}
});
$('#filter_sel_body tr td button.remove').click(function(event){
var remove_id = event.target.id
if(remove_id){
$("#filter_sel_table tbody tr#ftr_"+remove_id).remove();
document.getElementById(remove_id).checked = false;
delete filter_sel_info[remove_id];
}
});
},
excel_download(report_data){
var change_to = []
change_to[0] = "text";
change_to[1] = "text";
change_to[2] = "decimal";
change_to[3] = "integer";
change_to[4] = "date";
change_to[5] = "text";
change_to[6] = "text";
change_to[7] = "text";
change_to[8] = "text";
change_to[9] = "text";
change_to[10] = "text";
change_to[11] = "text";
change_to[12] = "text";
change_to[13] = "date_time";
change_to[14] = "text";
change_to[15] = "time_min";
var duration_type = $("#duration_type").val();
var report_type = $("#report_type").val();
var display_format = $("#display_format").val();
var field_info = report_data.field_info;
var final_rslt = report_data.final_rslt;
var report_data_len = final_rslt.length;
if(report_data_len > 0 ){
var header_info = final_rslt[0];
var excel_output = [];
excel_output.push(header_info);
if((parseInt(duration_type) === 2) && (parseInt(report_type) === 2) && (parseInt(display_format) === 1)){
var header_info_1 = final_rslt[1];
excel_output.push(header_info_1);
delete final_rslt[0];
delete final_rslt[1]; // [MS 12-09-2024]
}else{
delete final_rslt[0];
//delete final_rslt[1];
}
$.each(final_rslt, function(col_key, col_val) {
if(col_val){
var innerRowData = [];
var count = 0;
$.each(col_val, function(key, val) {
var field_type = field_info[count];
var change_info = change_to[field_type];
if(($.trim(val))&&(change_info === "text")){
val = val.toString();
}else
if(($.trim(val))&&(change_info === "decimal")){
val = parseFloat(val)
}else
if(($.trim(val))&&(change_info === "integer")){
val = parseInt(val)
}else
if(($.trim(val))&&(change_info === "date")){
val = new Date(val)
}
// else
// if(($.trim(val))&&(change_info === "date_time")){
// }else
// if(($.trim(val))&&(change_info === "time_min")){
// }
count++
innerRowData.push(val);
});
excel_output.push(innerRowData);
}
});
var sheet = moment().format('YYYYMMDDHHMMSS');
var filename = "RW_"+sheet+".xlsx";
var wb = XLSX.utils.book_new();
var ws = XLSX.utils.aoa_to_sheet(excel_output);
XLSX.utils.book_append_sheet(wb,ws,sheet);
XLSX.writeFile(wb,filename);
}
},
};
common_fn.call_select();
common_fn.call_datepicker();
common_fn.clear_error();
var master = <?php echo json_encode($master); ?>;
var earning = <?php echo json_encode($earning); ?>;
var deduction = <?php echo json_encode($deduction); ?>;
var all_formula = <?php echo json_encode($all_formula); ?>;
var group_list = <?php echo json_encode($group_list); ?>;
const allowed_option = ["+","-","*","/","(",")"];
const ignore_option = [".+", ".-", ".*", "./", ".)", ".(", "+.", "-.", "*.", "/.", ").", "(.", "++", "+-", "+*", "+/", "+)", "--", "-+", "-*", "-/", "-)", "**", "*+", "*-", "*/", "*)", "//", "/+", "/-", "/*", "/)", "(+", "(-", "(/", "0(", "1(", "2(", "3(", "4(", "5(", "6(", "7(", "8(", "9(", "a(", "b(", "c(", "e(", "f(", "g(", "h(", "i(", "j(", "k(", "l(", "m(", "n(", "o(", "p(", "q(", "r(", "s(", "t(", "u(", "v(", "w(", "x(", "y(", "z(", "0(", ")1", ")2", ")3", ")4", ")5", ")6", ")7", ")8", ")9", ")a", ")b", ")c", ")d", ")e", ")f", ")g", ")h", ")i", ")j", ")k", ")l", ")m", ")n", ")o", ")p", ")q", ")r", ")s", ")t", ")u", ")v", ")w", ")x", ")y", ")z", "()",];
var selected_info = []
var filter_sel_info = []
$('body').on('click',function(e){
$('[data-toggle=popover]').each(function () {
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
$('#report_list_view_btn').click(function(event){
$('#report_list_view').modal({backdrop: 'static', keyboard: false});
$('#report_list_view_tbody').html('<tr><td colspan="11" style="color:red;text-align:center"><i class="fa fa-spinner fa-spin"></i> Processing...</td></tr>');
$.ajax({
url: '<?php echo site_url("$controller_name/get_report_list_view"); ?>',
data: {},
type: 'POST',
success:function(data){
var response = JSON.parse(data);
common_fn.upd_report_list_view(response,false);
},
});
});
//******************** INPUT ON CHANGE - START ********************
$("#category_for_select").click(function(){
if($("#category_for_select").is(':checked') ){
$("#category_for > option").prop("selected","selected");
$("#category_for").trigger("change");
}else{
$("#category_for > option").removeAttr("selected");
$("#category_for").trigger("change");
}
$('#category_for option').filter(function(){
return !this.value || $.trim(this.value).length == 0;
}).remove();
});
$('#report_title,#save_upd,#category_for,#duration_type,#report_type,#from_month,#to_month,#group_by,#sub_total_div,#display_format').parent().hide();
$('#report_tab_holder,#report_submit_holder').hide();
$("#report_list").change(function(event){
common_fn.clear_screen();
var report_list = event.target.value;
if(!report_list){
$('#report_list').parent().append("<div class='val_error' style='color:red;'>Please select report</div>");
}else{
common_fn.clear_error();
if(report_list === "NEW"){
$('#category_for,#duration_type,#save_upd').parent().show();
$('#save_upd option[value="1"]').attr('disabled',false);
$('#save_upd option[value="2"]').attr('disabled',true);
$('#save_upd option[value="3"]').attr('disabled',true);
}else{
$('#save_upd option[value="1"]').attr('disabled',true);
$('#save_upd option[value="2"]').attr('disabled',false);
$('#save_upd option[value="3"]').attr('disabled',false);
if(parseInt(report_list) > 0){
common_fn.clear_screen();
var form_data = JSON.stringify({report_list:report_list});
$('#report_list').attr('disabled', true);
$('#report_list').parent().append("<div class='val_error' style='color:red;'><i class=\"fa fa-spinner fa-spin\"></i> Please wait we processing your request...</div>");
$.ajax({
url: '<?php echo site_url("$controller_name/get_report_info"); ?>',
data: {form_data},
type: 'POST',
success:function(data){
common_fn.clear_error();
$('#report_list').removeAttr('disabled');
var response = JSON.parse(data);
if(!response.success){
toastr.error(response.message);
}else{
var rslt_info = response.rslt
common_fn.upd_screen(rslt_info);
toastr.success(response.message);
}
},
});
}
}
common_fn.call_select();
}
});
$("#save_upd").change(function(event){
var save_upd = event.target.value;
if(save_upd !== ""){
$('#report_title').parent().show();
$('#report_title').attr('disabled', true);
if((parseInt(save_upd) === 1) || (parseInt(save_upd) === 2)){
$('#report_title').removeAttr('disabled');
}else{
$('#report_title').attr('disabled', true);
}
}else{
$('#report_title').parent().hide();
}
});
$("#duration_type").change(function(){
common_fn.clear_error();
$("#report_type").val("");
$("#from_month").val("");
$("#to_month").val("");
$("#group_by").val("");
$("#display_format").val("");
$('#sub_total').prop('checked', false);
$('#report_type,#from_month,#to_month,#group_by,#sub_total_div,#display_format').parent().hide();
$('#report_tab_holder').hide();
$('#report_type option[value="1"]').attr('disabled',false);
$('#report_type option[value="3"]').attr('disabled',false);
var duration_type = $("#duration_type").val();
if(parseInt(duration_type) === 2){
$('#report_type option[value="1"]').attr('disabled',true);
$('#report_type option[value="3"]').attr('disabled',true);
}
$('#report_type').parent().show();
common_fn.call_select();
});
$("#report_type").change(function(){
$("#group_by").val("");
$("#display_format").val("");
$('#sub_total').prop('checked', false);
common_fn.call_select();
common_fn.clear_error()
var duration_type = $("#duration_type").val();
var report_type = $("#report_type").val();
$('#from_month,#to_month,#group_by,#sub_total_div,#display_format').parent().hide();
$('#report_tab_holder').hide();
$('#input_tab li > a').parent().removeClass('active')
$('#master_tab,#earning_tab,#deduction_tab,#formula_tab').removeClass('active in');
$('#input_tab li > a[data_id=master_tab],#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().addClass('hide');
if((parseInt(duration_type) === 1) && (parseInt(report_type) === 1)){ // Single Month & Consolidate
$('#report_tab_holder').show();
$('#from_month,#to_month,#group_by').parent().show();
$('#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().removeClass('hide');
$('#input_tab li > a[data_id=earning_tab]').parent().removeClass('hide').addClass('active');
$('#earning_tab').addClass('active in');
$("#select_table tbody tr").each(function(event){
var tr_id = this.id.replace("tr_", "");
var id_info = tr_id.split("_");
var from = id_info[0];
if(from === "MASTER"){
$("#select_table tbody tr#tr_"+tr_id).remove();
document.getElementById(tr_id).checked = false;
delete selected_info[tr_id];
}
});
document.getElementById("master_all").checked = false;
}else
if((parseInt(duration_type) === 1) && (parseInt(report_type) === 2)){ // Single Month & Detail
$('#report_tab_holder').show();
$('#from_month,#group_by').parent().show();
$('#input_tab li > a[data_id=master_tab],#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().removeClass('hide');
$('#input_tab li > a[data_id=master_tab]').parent().removeClass('hide').addClass('active');
$('#master_tab').addClass('active in');
}else
if((parseInt(duration_type) === 1) && (parseInt(report_type) === 3)){ // Single Month & Only Mater
$('#report_tab_holder').show();
$('#input_tab li > a[data_id=master_tab]').parent().removeClass('hide').addClass('active');
$('#master_tab').addClass('active in');
$("#select_table tbody tr").each(function(index){
var tr_id = this.id.replace("tr_", "");
var id_info = tr_id.split("_");
var from = id_info[0];
if(from !== "MASTER"){
$("#select_table tbody tr#tr_"+tr_id).remove();
document.getElementById(tr_id).checked = false;
delete selected_info[tr_id];
}
});
document.getElementById("master_all").checked = false;
document.getElementById("earning_all").checked = false;
document.getElementById("deduction_all").checked = false;
}else
if((parseInt(duration_type) === 2) && (parseInt(report_type) === 2)){ // Multi Month & Detail
$('#report_tab_holder').show();
$('#from_month,#to_month,#group_by,#display_format').parent().show();
$('#input_tab li > a[data_id=earning_tab],#input_tab li > a[data_id=deduction_tab],#input_tab li > a[data_id=formula_tab]').parent().removeClass('hide');
$('#input_tab li > a[data_id=earning_tab]').parent().removeClass('hide').addClass('active');
$('#earning_tab').addClass('active in');
$("#select_table tbody tr").each(function(index){
var tr_id = this.id.replace("tr_", "");
var id_info = tr_id.split("_");
var from = id_info[0];
if(from === "MASTER"){
$("#select_table tbody tr#tr_"+tr_id).remove();
document.getElementById(tr_id).checked = false;
delete selected_info[tr_id];
}
});
document.getElementById("master_all").checked = false;
/* UDY *******************
SHOULD'T ENABLE MASTER TAB FOR // Multi Month & Detail
- if enable in excel Components same value repet for all month
*/
}
});
$("#group_by").change(function(){
$("#display_format").val("");
$('#sub_total').prop('checked', false);
common_fn.call_select();
common_fn.clear_error()
var duration_type = $("#duration_type").val();
var report_type = $("#report_type").val();
var group_by_input = $("#group_by").val();
if(group_by_input === null){
$('#display_format').parent().hide();
}else{
group_by = group_by_input.filter(function(v){return v!==''});
let group_len = group_by.length;
if(((parseInt(duration_type) === 1) && (parseInt(report_type) === 1) && (group_len === 1 ) || ((parseInt(duration_type) === 2) && (parseInt(report_type) === 2)))){
$('#display_format').parent().show();
}else{
$('#display_format').parent().hide();
}
if((parseInt(duration_type) === 1) && (parseInt(report_type) === 2) && (group_len > 0 )){
$('#sub_total_div').parent().show();
}else{
$('#sub_total_div').parent().hide();
}
}
});
//******************** INPUT ON CHANGE - END ********************
//******************* SELECT TAB - START *****************
$('[data-toggle="popover"]').popover()
$("#master_search").on("keyup", function(){
var value = $(this).val().toLowerCase();
$("#master_body tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$("#earning_search").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#earning_body tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$("#deduction_search").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#deduction_body tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$('#master_all,#earning_all,#deduction_all').click(function(event){
var process_id = event.target.id
var process_list = false;
var process_mode = "";
if(process_id){
if(process_id=== "master_all"){
process_list = master;
process_mode = "MASTER_";
}else
if(process_id=== "earning_all"){
process_list = earning;
process_mode = "EARNING_";
}else
if(process_id=== "deduction_all"){
process_list = deduction;
process_mode = "DEDUCTION_";
}
}
var check_uncheck = false;
if($(event.target).is(":checked")) {
check_uncheck = true
}else{
}
if(process_list){
$.map(process_list, function(val,i){
var select_id = process_mode+val.prime_form_id;
if((val.label_name !== "employee_code") && (val.label_name !== "emp_name")){
document.getElementById(select_id).checked = check_uncheck;
if(check_uncheck){
var db_info = {master:master,earning:earning,deduction:deduction,select_id:select_id}
var row_info = common_fn.get_row_info(db_info);
selected_info[select_id] = row_info
common_fn.selected_tr(select_id);
}else{
delete selected_info[select_id]
$("#select_table tbody tr#tr_"+select_id).remove();
}
}
});
}
});
$('#master_body tr,#earning_body tr,#deduction_body tr').click(function(event){
if(event.target.type !== 'checkbox'){
$(':checkbox', this).trigger('click');
}
var checkbox = $(this).find("input[type='checkbox']");
var select_id = event.target.id;
if(select_id){
if($(event.target).is(":checked")){
var db_info = {master:master,earning:earning,deduction:deduction,select_id:select_id}
var row_info = common_fn.get_row_info(db_info);
selected_info[select_id] = row_info
common_fn.selected_tr(select_id);
}else{
delete selected_info[select_id]
$("#select_table tbody tr#tr_"+select_id).remove();
common_fn.unselected_tr(select_id);//Changed by [MS 16-07-2024]
}
}
});
//******************* SELECT TAB - END *****************
//******************* FORMULA - START *****************
$('#formula_master,#formula_earning,#formula_deduction').parent().hide();
$('#formula_name').bind('keypress', function (event){
var regex = new RegExp("^[a-zA-Z0-9_ ]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)) {
event.preventDefault();
toastr.error("only alphanumeric,space & underscore allowed in formula name");
return false;
}
});
$("#formula_for").change(function(){
common_fn.clear_error()
var formula_name = $("#formula_name").val();
var formula_for = $("#formula_for").val();
$('#formula_master,#formula_earning,#formula_deduction').parent().hide();
$("#formula_master,#formula_earning,#formula_deduction").val("");
common_fn.call_select();
if(formula_name === ""){
toastr.error("Please new field enter name");
$('#formula_name').parent().append("<div class='val_error' style='color:red;'>Please new field enter name</div>");
$("#formula_for").val("");
common_fn.call_select();
}else{
if(parseInt(formula_for) === 1){
$('#formula_master').parent().show();
}else
if(parseInt(formula_for) === 2){
$('#formula_earning').parent().show();
}else
if(parseInt(formula_for) === 3){
$('#formula_deduction').parent().show();
}
}
});
$("#formula_master").change(function(){
common_fn.formula_onchange(allowed_option,ignore_option,"#formula_master");
});
$("#formula_earning").change(function(){
common_fn.formula_onchange(allowed_option,ignore_option,"#formula_earning");
});
$("#formula_deduction").change(function(){
common_fn.formula_onchange(allowed_option,ignore_option,"#formula_deduction");
});
$('#calculator tbody tr td').click(function(event){
var formula_info = $("#formula").val();
formula_info = formula_info.trim().toLowerCase().replace(/ /g,"");
var operator = event.target.id
if(formula_info){
var check_str = formula_info.substr(-1);
var check_forumal = check_str+operator;
if($.inArray(check_forumal, ignore_option) !== -1){
operator = "";
}
}
var formula = formula_info+operator;
$('#formula').val(formula);
});
$('#formula_submit').click(function(event){
common_fn.clear_error();
var formula_mode = $("#formula_mode").val();
var formula_id = $("#formula_id").val();
var formula_name = $("#formula_name").val();
var formula_info = $("#formula").val();
if((formula_name !== "") && (formula_info !== "")){
formula_info = formula_info.trim().toLowerCase().replace(/ /g,"");
// var chk_sel_col = formula_info.replace(/[^a-zA-Z0-9._]/g, ",");
var chk_sel_col = formula_info.replace(/[^a-zA-Z0-9._]|\bround\b/g, ",");
var open_bracket = formula_info.split("(").length - 1;
var close_bracket = formula_info.split(")").length - 1;
var start_char = formula_info.slice(0, 1);
var end_char = formula_info.substr(-1);
var allowed_charater = /^[A-Za-z0-9_.\/+*()-]+$/;
const start_end_ignore = ["+","-","*","/","_"];
var isExist = []
$.map(ignore_option, function(val,i){
if(formula_info.includes(val)){
isExist.push(val);
}
});
var chk_sel_col_info = chk_sel_col.split(",");
var inValid_col = []
$.map(chk_sel_col_info, function(val,i){
var isNumeric = $.isNumeric(val);
if(!isNumeric){
if(!all_formula[val]){
inValid_col.push(val);
}
}
});
if($.inArray(start_char, start_end_ignore) !== -1){
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please check formula may contain incorrect operator at start</div>");
}else
if($.inArray(end_char, start_end_ignore) !== -1){
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please check formula may contain incorrect operator at end</div>");
}else
if(isExist.length > 0){
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please check formula may contain incorrect operator position</div>");
}else
if(inValid_col.length > 0){
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please remove invalid column name in formula</div>");
}else
if(allowed_charater.test(formula_info) == false) {
$('#formula').parent().append("<div class='val_error' style='color:red;'>Allow charater are +,-,*,/,(,),aplha,number</div>");
}else
if(open_bracket !== close_bracket){
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please check open and close brackets</div>");
}else{
var label_name = formula_name.trim().toLowerCase().replace(/ /g, "_");
var exist_formula = [];
$.each(Object.keys(selected_info), function(key, value) {
var sel_info = selected_info[value]
if(sel_info.trans_name === "NEW"){
exist_formula.push(sel_info);
}
});
var form_id = "NEW_"+exist_formula.length;
if(formula_mode === "UPD"){
form_id = formula_id
}
var new_field = {"prime_form_id":form_id,"label_name":label_name,"view_name":formula_name,"transaction_type":0,"trans_name":"NEW",field_type:0,gross_check:0,deduction_check:0,pick_list_type:"",pick_list:"",pick_table:"",auto_prime_id:"",auto_dispaly_value:"",pick_display_value:"",total:1,pro_key:form_id,formula_info:formula_info};
selected_info[form_id] = new_field;
common_fn.selected_tr(form_id);
$("#formula_mode,#formula_id,#formula_name,#formula_for,#formula_master,#formula_earning,#formula_deduction,#formula").val("");
common_fn.call_select();
$('#formula_master,#formula_earning,#formula_deduction').parent().hide();
}
}else{
if(formula_name === ""){
$('#formula_name').parent().append("<div class='val_error' style='color:red;'>Please enter formula name</div>");
}
if(formula_info === ""){
$('#formula').parent().append("<div class='val_error' style='color:red;'>Please enter formula</div>");
}
}
});
//******************* FORMULA - END *****************
//******************* TOTAL CLICK - START ***************** //[MS 16-07-2024]
$('#master_all,#earning_all,#deduction_all').on('change',function(event){
if($(event.target).is(":unchecked")) {
var tab_count = $('#select_table tr').length;
tab_count = tab_count - 1;
$('#rowCount').html('Count : '+tab_count);
}
})
//******************* TOTAL CLICK - END *****************
//******************* SORT ORDER - START *****************
$(".report_sort" ).sortable({
update: function( event, ui ){
var table_idsInOrder = [];
$('#selected_body tr').each(function() {
if( $(this).attr('id')){
var tr_id = $(this).attr('id').replace("tr_", "");
table_idsInOrder[tr_id] = selected_info[tr_id];
}
});
selected_info = table_idsInOrder;
},connectWith: '.report_sort'
});
//******************* SORT ORDER - END *****************
//******************* REPORT SUBMIT - START ***************
$('#report_submit').click(function(event){
var selecte_length = Object.keys(selected_info).length;
if(selecte_length === 0){
toastr.error("Please select field atleast one field");
}else{
const not_allowed = ["name","sort_order", "edit", "remove","formula"];
common_fn.clear_error();
var can_process = true;
var report_list = $("#report_list").val();
var category_for = $("#category_for").val();
var duration_type = $("#duration_type").val();
var report_type = $("#report_type").val();
var group_by_input = $("#group_by").val();
if(group_by_input){
var group_by = group_by_input.filter(function(v){return v!==''});
}
var display_format = $("#display_format").val();
var from_month = $("#from_month").val();
var to_month = $("#to_month").val();
var report_title = $("#report_title").val();
var save_upd = $("#save_upd").val();
var sub_total = false;
if($('#sub_total').is(":checked")){
sub_total = true
}
var select_info = [];
//var field_info = [];
$.each(Object.keys(selected_info), function(key, value) {
var sel_info = selected_info[value]
sel_info.pro_key = value;
//field_info.push({label_name:sel_info.label_name,field_type:sel_info.field_type,pro_key:sel_info.pro_key});
select_info.push(sel_info);
});
//console.log(field_info);
//return false;
var filter_info = []
$.each(Object.keys(filter_sel_info), function(key, value) {
var info = filter_sel_info[value]
info.pro_key = value.replace("FILTER_", "");
filter_info.push(info);
});
if(report_list === ""){
can_process = false
$('#report_list').parent().append("<div class='val_error' style='color:red;'>Please select Report name or new</div>");
}
if(category_for === null){
can_process = false
$('#category_for').parent().append("<div class='val_error' style='color:red;'>Please select atleast one category</div>");
}else{
if(category_for.length === 0){
can_process = false
$('#category_for').parent().append("<div class='val_error' style='color:red;'>Please select atleast one category</div>");
}
}
if(display_format === ""){
var group_len = 0;
if(group_by){
group_len = group_by.length;
}
if(((parseInt(duration_type) === 1) && (parseInt(report_type) === 1) && (group_len === 1 ) || ((parseInt(duration_type) === 2) && (parseInt(report_type) === 2)))){
can_process = false
$('#display_format').parent().append("<div class='val_error' style='color:red;'>Please select display formate</div>");
}
if(parseInt(duration_type) === 1){
display_format = 1
}else
if(parseInt(duration_type) === 2){
display_format = 2
}
}
if(duration_type === ""){
can_process = false
$('#duration_type').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}else{
if(report_type === ""){
can_process = false
$('#duration_type').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}else{
var duration_type = parseInt(duration_type);
var report_type = parseInt(report_type);
if((duration_type === 1) && (report_type === 1)){
if(from_month === ""){
can_process = false
$('#from_month').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}
if(to_month == ""){
can_process = false
$('#to_month').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}
}else
if((duration_type === 1) && (report_type === 2)){
to_month = "";
if(from_month === ""){
can_process = false
$('#from_month').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}
}else
if((duration_type === 2) && (report_type === 2)){
if(from_month === ""){
can_process = false
$('#from_month').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}
if(to_month === ""){
can_process = false
$('#to_month').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}
}
if((parseInt(save_upd) === 1) || (parseInt(save_upd) === 2)){
if(report_title === ""){
can_process = false
$('#report_title').parent().append("<div class='val_error' style='color:red;'>Please select duration type</div>");
}
}
}
}
if(!can_process){
$("html, body").animate({ scrollTop: 0 }, "slow");
toastr.warning('Please provide valid input');
}else{
var form_data = {
report_list : report_list,
category_for : category_for,
duration_type : duration_type,
report_type : report_type,
group_by : group_by,
sub_total : sub_total,
display_format : display_format,
from_month : from_month,
to_month : to_month,
save_upd : save_upd,
report_title : report_title,
select_info : select_info,
filter_info : filter_info,
group_list : group_list,
}
form_data = JSON.stringify(form_data);
$("#report_submit").html("<i class='fa fa-spinner fa-spin'></i> Processing...");
$('#report_submit').attr('disabled','disabled');
$.ajax({
url: '<?php echo site_url("$controller_name/process_report"); ?>',
data: {form_data},
type: 'POST',
success:function(data){
var rslt = JSON.parse(data);
if(!rslt.success){
$('#report_submit').attr('disabled',false);
$("#report_submit").html("Submit");
toastr.error(rslt.message);
}else{
toastr.success(rslt.message);
var report_data = rslt.rslt
common_fn.excel_download(report_data);
var save_upd = $("#save_upd").val();
$('#report_submit').attr('disabled',false);
$("#report_submit").html("Submit");
if((parseInt(save_upd) === 1) || (parseInt(save_upd) === 2)){
common_fn.clear_screen();
$('#report_list').attr('disabled', true);
$('#report_list').parent().append("<div class='val_error' style='color:red;'><i class=\"fa fa-spinner fa-spin\"></i> Please wait we refreshing your report list...</div>");
$.ajax({
url: '<?php echo site_url("$controller_name/get_report_list"); ?>',
data: {form_data},
type: 'POST',
success:function(data){
var response = JSON.parse(data);
common_fn.clear_error();
$('#report_list').removeAttr('disabled');
if(!response.success){
toastr.error(response.message);
}else{
$('#report_list').empty();
$("#report_list").append($("<option></option>").attr("value","NEW").text("New"));
$.each(response.rslt, function(key, value) {
if(key !== "NEW"){
$("#report_list").append($("<option></option>").attr("value",key).text(value));
}
});
$("#report_list").val("");
common_fn.call_select();
toastr.success(response.message);
}
},
});
}else{
$("#save_upd").val("");
$('#report_title').parent().hide();
common_fn.call_select();
}
}
},
});
}
}
});
//******************* REPORT SUBMIT - END **********************
//******************* FILTER SELECT TAB - START *****************
$("#filter_master_search").on("keyup", function(){
var value = $(this).val().toLowerCase();
$("#filter_master_body tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$("#filter_earning_search").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#filter_earning_body tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$("#filter_deduction_search").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#filter_deduction_body tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$('#filter_master_body tr,#filter_earning_body tr,#filter_deduction_body tr').click(function(event){
if(event.target.type !== 'checkbox'){
$(':checkbox', this).trigger('click');
}
var checkbox = $(this).find("input[type='checkbox']");
var select_id = event.target.id;
if(select_id){
if($(event.target).is(":checked")){
var db_info = {master:master,earning:earning,deduction:deduction,select_id:select_id}
var row_info = common_fn.get_row_info(db_info);
if(row_info){
row_info.where_cond = "";
row_info.where_val = "";
row_info.where_val_from = "";
row_info.where_val_to = "";
row_info.where_sel_list = [];
filter_sel_info[select_id] = row_info
common_fn.filter_sel_tr(select_id);
}
}else{
delete filter_sel_info[select_id]
$("#filter_sel_table tbody tr#ftr_"+select_id).remove();
}
}
});
//******************* FILTER SELECT TAB - END *****************
//******************* FILTER SORT ORDER - START *****************
$(".filter_sortable" ).sortable({
update: function( event, ui ){
var table_idsInOrder = [];
$('#filter_sel_body tr').each(function() {
if( $(this).attr('id')){
var tr_id = $(this).attr('id').replace("ftr_", "");
table_idsInOrder[tr_id] = filter_sel_info[tr_id];
}
});
filter_sel_info = table_idsInOrder;
},connectWith: '.report_sort'
});
//******************* FILTER SORT ORDER - END *****************
});
</script>
<style>
#filters {
display: none !important;
}
<?php
if($access_search === 1){
echo "#filters { display: inline !important; }";
}
?>
</style>
<style type="text/css">
@media screen and (min-width: 768px) {
.print_modal{
width: 760px; /* New width for default modal */
}
}
@media screen {
#printSection {
display: none;
}
}
@media print {
body * {
visibility:hidden;
}
#printSection, #printSection * {
visibility:visible;
}
#printSection {
position:absolute;
margin-left:15px;
top:10px;
}
}
.zoom:hover {
transform: scale(3.5);
z-index: 99999; / (150% zoom - Note: if the zoom is too large, it will go outside of the viewport) /
}
</style>
<?php $this->load->view("partial/footer"); ?>