{% extends 'att/report/base.html' %} {% load i18n %} {% block opts_modify %} var baseCols = [ {field:'emp_code', title: "{% trans 'transaction_field_employeeCode' %}", sort: true}, {field:'first_name', title: "{% trans 'canteen_report_field_first_name' %}", sort: true}, {field:'last_name', title: "{% trans 'canteen_report_field_last_name' %}", sort: true}, {field:'dept_id', title: "{% trans 'canteen_report_field_department_id' %}", sort: true}, {field:'dept_name', title: "{% trans 'canteen_report_field_department_name' %}", sort: true}, {field:'position', title: "{% trans 'canteen_report_field_position' %}", sort: true}, {field:'punch_time', title: "{% trans 'transaction_field_punchtimeDate' %}", sort: true} ]; var _cols = $.extend(true, [], baseCols); var periodCount = 1; $.ajax({ type: "GET", url: "/att/api/totalpunchReport/work_code/", cache:false, async:false, dataType: "json", success: function(response, xhr){ workcode = response.data; } }); for(var i=0; i < workcode.length; i++){ _cols.push({field:workcode[i], title:workcode[i]}); } _cols.push({field:'total_punch', title: "{% trans 'transaction_field_totalPunch' %}"}); $.extend(opts, { cols: [_cols] ,method: "get" ,url: "/att/api/totalpunchReport/" }); {% endblock %} {% block columns_modify %} $.ajax({ type: "GET", url: '/att/api/totalpunchReport/work_code/', data: c, cache:false, async:false, dataType: "json", success: function(response, xhr){ periodCount = response.data; } }); _cols = $.extend(true, [], baseCols); for(var i=0; i < periodCount; i ++){ _cols.push({field:workcode[i], title:workcode[i]}); } $.extend(opts, { cols: [_cols] ,method: "get" ,url: "/att/api/totalpunchReport/" ,where: c ,page: {curr: 1} }); tb = table.reload(tb.config.id, opts) $.extend(action_opts, { curTable: tb }); $("#{{model_name}}_fluid" + " div.grid-toolbar").actions(action_opts); {% endblock %}