{% extends 'payroll/report/base.html' %}
{% load i18n %}
{% block opts_modify %}
    var cols = [[
        {field:'emp_code', width:120, title: "{% trans 'report_column_empCode' %}", sort:true}
        ,{field:'first_name', title: "{% trans 'report_column_firstName' %}"}
        ,{field:'last_name', title: "{% trans 'report_column_lastName' %}"}
        ,{field:'department', title: "{% trans 'report_column_departmentName' %}"}
{#        ,{field:'position_name', title: "{% trans 'report_column_positionName' %}"}#}
        ,{field:'salary_amount', title: "{% trans 'salaryStructure_field_amount' %}"}
        ,{field:'effective_date', title: "{% trans 'salaryStructure_field_effectiveDate' %}"}
        ,{field:'ot1', title: "{% trans 'report_column_overtimeFormula1' %}"}
        ,{field:'ot2', title: "{% trans 'report_column_overtimeFormula2' %}"}
        ,{field:'ot3', title: "{% trans 'report_column_overtimeFormula3' %}"}
        ,{field:'normal_ot', title: "{% trans 'report_column_normalOvertime' %}"}
        ,{field:'weekend_ot', title: "{% trans 'report_column_weekendOvertime' %}"}
        ,{field:'holiday_ot', title: "{% trans 'report_column_holidayOvertime' %}"}
        ,{field:'late_time', title: "{% trans 'report_column_lateFormula' %}"}
        ,{field:'absent_time', title: "{% trans 'report_column_absentFormula' %}"}
        ,{field:'early_leave', title: "{% trans 'report_column_earlyleaveFormula' %}"}
        ,{field:'increase', title: "{% trans 'report_column_increaseFormula' %}"}
        ,{field:'deduction', title: "{% trans 'report_column_deductionFormula' %}"}
    ]];
    var leaveCols = [];
    $.ajax({
        url: "/payroll/api/leaveformulas/"
        ,type: "GET"
        ,dataType: "json"
        ,async: false
        ,success:function(response){
            var data = response.data;
            leave_set = new Set()
            data.forEach(function(col, index){
                if(!leave_set.has(col['category_name'])) {
                    leave_set.add(col['category_name'])
                    leaveCols.push({field: col['category_name'], title: col['category_name']})
                };
            });
        }
        ,error:function(){

        }
    });
    var _cols = cols[0].concat(leaveCols);
    cols[0] = _cols;
    $.extend(opts, {
    cols: cols
    ,url:"payroll/api/report/salarystructure_report/"
    })

    $('#salarystructure_report-search-form div div:first').css('display', 'block');

{% endblock %}