<?php
//print_r($_POST);
//$filter = ['id' => $_GET['econid']];
//print_r($user);
$result = $auth->getApiData("get/users");
if (!isset($result->errorcode)) {
    //$partners = $auth->getApiDataFilter("get/machine/full", $filter);
?>
    <div class="card">
        <div class="card-header">
            <h3 class="card-title">Felhasználók</h3>

            <div class="card-tools">
                <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                    <i class="fas fa-minus"></i>
                </button>
                <button type="button" class="btn btn-tool" data-card-widget="remove" title="Remove">
                    <i class="fas fa-times"></i>
                </button>
            </div>
        </div>
        <div class="card-body table-responsive p-0">
            <table class="table table-hover text-nowrap projects">
                <thead>
                    <tr>
                        <th style="width: 10%">
                            #
                        </th>
                        <th style="width: 20%">
                            Név
                        </th>
                        <th style="width: 10%">
                            Jogosultság
                        </th>
                        <th style="width: 10%">
                            Adózás
                        </th>
                        <th style="width: 20%">
                            Utolsó belépés
                        </th>
                        <th style="width: 20%">
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    //print_r($result);
                    foreach ($result as $user) :
                    ?>
                        <tr>
                            <td>
                                <?php echo $user->id; ?>
                            </td>
                            <td>
                                <a>
                                    <?php
                                    echo $user->lastName." ".$user->firstName
                                    ?>
                                </a>
                                <br>
                                <small>
                                    <?php //echo convertToDate($service->date)?>
                                </small>
                            </td>
                            <td>
                                <?php echo $user->accesslevel; ?>
                            </td>
                            <td>
                                <?php echo (isset($user->userTax))?getTax($user->userTax):'-'; ?>
                            </td>
                            <td>
                                <?php echo (isset($user->tokenValidUntil))?date("Y-m-d H:i:s",strtotime(convertToDate($user->tokenValidUntil)." -8 Hour")):' - '; ?>
                            </td>
                            <td class="project-actions text-right">
                                <a class="btn btn-info btn-sm" href="<?php echo SITEURL?>/users/users/editrole?econid=<?php echo $user->id?>">
                                    <i class="fas fa-pencil-alt"></i>
                                    Megtekintés
                                </a>
                            </td>
                        </tr>
                    <?php
                    endforeach;
                    ?>
                </tbody>
            </table>
        </div>
        <!-- /.card-body -->
    </div>
<?php
}
?>
<?php
addJS("edit.js");
?>