table having 2 rows based on id.how to cumulative to make single row inatatable library
table having 2 rows based on id.how to cumulative to make single row inatatable library
$(document).ready(function () {
var empTable = $('#reportTable').dataTable({
"aaSorting": [[0, "asc"]],
"iDisplayLength": <?= $Settings->rows_per_page ?>,
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "<?= lang('all') ?>"]],
'bProcessing': true,
'bServerSide': true,
"scrollX": true,
'sAjaxSource': '<?php echo base_url(); ?>payment/getAmountData',
'fnServerData': function (sSource, aoData, fnCallback) {
$.ajax({
'dataType': 'json',
'type': 'POST',
'url': sSource,
'data': aoData,
'success': fnCallback
});
},
'fnRowCallback': function (nRow, aData, iDisplayIndex) {
var oSettings = empTable.fnSettings();
nRow.id = aData[0];
var nCells = nRow.getElementsByTagName('td');
var basic_pay = reduce(aData[4]);
var total = ceiling(parseFloat(aData[4]) + parseFloat(aData[5]));
var total_salary = ceiling(parseFloat(total) + parseFloat(aData[6]) + parseFloat(aData[7]) + parseFloat(aData[8]) + parseFloat(aData[9]) + parseFloat(aData[10]));
var begin_total = 0;
var gpf = 0;
var final_total = 0;
nCells[6].innerHTML = currencyFormat(basic_pay);
nCells[6].innerHTML = currencyFormat(total);
nCells[12].innerHTML = currencyFormat(total_salary);
return nRow;
},
"aoColumns": [
{
"bSortable": false
},
{
"bSortable": false
},
{
"bSortable": false
},
{
"bSortable": false
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
},
{
"bSortable": false,
"mRender": currencyFormat
}
// , {
// "bSortable": false
// }
]
});
});
try {
$this->load->library('datatables');
$query = $this->datatables->select('
employee_info.employee_id as employee_id,
employee_info.employee_name,
e.designation_name,
scale_pay.name,
employee_info.basic_pay,
employee_info.grade_pay,
0 as total,
c.da,
c.hra,
c.ta,
c.da_on_ta,
c.fma,
0 as total_salary,
0 as begin_total,
0 as gpf,
0 as final_total
')->from('employee_info')
->join('scale_pay ', 'scale_pay.id = employee_info.scale_of_pay', 'left')
->join('designation e', 'e.designation_id = employee_info.designation_id')
->join('month_pay c', 'c.employee_id = employee_info.employee_id')
->join('monthly_deduction f', 'f.employee_id = employee_info.employee_id AND f.monthyear')
// ->group_by('employee_info.employee_id')
// ->group_by('employee_info.basic_pay')
->where($where);
echo $this->datatables->generate();
} catch (Exception $e) {
throw new Exception("Error Processing Request", 1);
}