{% 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:'calc_time', title: "{% trans 'monthlySalary_field_calc_time' %}"}
            ,{field:'total_deduction', title: "{% trans 'monthlySalary_field_total_deduction' %}"}

            ,{field:'late_time', title: "{% trans 'monthlySalary_field_late_time' %}"}
            ,{field:'early_leave', title: "{% trans 'monthlySalary_field_early_leave' %}"}
            ,{field:'absent_time', title: "{% trans 'monthlySalary_field_absent_time' %}"}
            ,{field:'deduction', title: "{% trans 'monthlySalary_field_deduction' %}"}
            ,{field:'extra_deduction', title: "{% trans 'monthlySalary_field_extra_deduction' %}"}
            ,{field:'advance_deduction', title: "{% trans 'monthlySalary_field_advance_deduction' %}"}
            ,{field:'loan_deduction', title: "{% trans 'monthlySalary_field_loan_deduction' %}"}
        ]];
    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/deduction_report/"
    });
{% endblock %}
