<?php

defined('BASEPATH') or exit('No direct script access allowed');

$aColumns = [
    'ref',
    'date',
    'invoice',
    'tblsuppliers.company as supplier',
    ];

$sIndexColumn = 'id';
$sTable       = 'tblnir';
$where = [];
$join = [
    'LEFT JOIN tblsuppliers ON tblsuppliers.userid = tblnir.supplier_id'
];

$result  = data_tables_init($aColumns, $sIndexColumn, $sTable, $join, $where, ['tblnir.id']);
$output  = $result['output'];
$rResult = $result['rResult'];

foreach ($rResult as $aRow) {
    $row = [];
//    for ($i = 0; $i < count($aColumns); $i++) {
//        $_data = $aRow[$aColumns[$i]];
//        if ($aColumns[$i] == 'name') {
////            $role_permissions = $this->ci->roles_model->get_role_permissions($aRow['roleid']);
//            $_data            = '<a href="' . admin_url('produse/produs/' . $aRow['id']) . '" class="mbot10 display-block">' . $_data . '</a>';
//
//        }
//        $row[] = $_data;
//    }
//    $row[] = _d($aRow['date']);
    $row[] = '<a href="' . admin_url('hpynir/nir/' . $aRow['id']) . '" class="mbot10 display-block">' . $aRow['ref'] . '</a>';
    $row[] = '<a href="' . admin_url('hpynir/nir/' . $aRow['id']) . '" class="mbot10 display-block">' . $aRow['date'] . '</a>';
//    $row[] = (int)$aRow['ref'];
//    $row[] = $aRow['invoice'];
    $row[] = '<a href="' . admin_url('hpynir/nir/' . $aRow['id']) . '" class="mbot10 display-block">' . $aRow['invoice'] . '</a>';
//    $row[] = $aRow['supplier'];
    $row[] = '<a href="' . admin_url('hpynir/nir/' . $aRow['id']) . '" class="mbot10 display-block">' . $aRow['supplier'] . '</a>';


    $options = icon_btn('hpynir/nir/' . $aRow['id'], 'th-list');
    $options .= icon_btn('hpynir/pdf/' . $aRow['id'], 'file-pdf-o');
    $options .= icon_btn('hpynir/sterge/' . $aRow['id'], 'times', 'btn-danger _delete');
    $row[]   = $options;

    $output['aaData'][] = $row;
}
