<?php
$result = $auth->getApiData("get/product");
//print_r($result);
if (!isset($result->errorcode)) {
?>
    <div class="card">
        <div class="card-header">
            <h3 class="card-title">Termékek</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: 1%">
                            #
                        </th>-->
                        <th style="width: 20%">
                            Termék neve
                        </th>
                        <!--
                        <th>
                            Leírás
                        </th>
                        <th class="text-center">
                            Ár
                        </th>
                        <th>
                            Mennyiség
                        </th>
                        <th>
                            Típus
                        </th>
                        
                        <th>
                            Jutalék KATA
                        </th>
                        <th style="width: 20%">
                        </th>
                        <th>
                            Jutalék Normál
                        </th>-->
                        <th style="width: 20%" class="text-center">
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    //print_r($result);
                    foreach ($result as $product) :
                    ?>
                        <tr>
                            <!--<td>
                                <?php echo $product->id; ?>
                            </td>-->
                            <td>
                                <a>
                                    <?php echo $product->productName; ?>
                                </a>
                                <br>
                                <small>
                                    <?php echo (isset($product->createdDate))?convertToDate($product->createdDate):''?>
                                </small>
                            </td>
                            <!--
                            <td>
                                <?php
                                    echo (isset($product->productDescription))?$product->productDescription:'';
                                ?>
                            </td>
                            <td>
                                <?php
                                    echo (isset($product->productPrice))?$product->productPrice." Ft":' - ';
                                ?>
                            </td>
                            <td>
                                <?php
                                    echo (isset($product->productQuantity)&&isset($product->productUnit))?$product->productQuantity." ".getUnitsById($product->productUnit):" - ";
                                ?>
                            </td>
                            <td>
                                <?php
                                    echo $product->productCategory;
                                ?>
                            </td>
                            <td>
                                <?php
                                echo (isset($product->productComissionKata)&&isset($product->productJutalekKATA))?$product->productComissionKata." ".$product->productJutalekKATA:" - ";
                                ?>
                            </td>
                            <td>
                                <?php
                                echo (isset($product->productComission)&&isset($product->productNormal))?$product->productComission." ".$product->productNormal:" - ";
                                ?>
                            </td>
                    -->
                            <td class="project-actions text-right">
                                <a class="btn btn-primary btn-sm" href="<?php echo SITEURL?>/products/product/viewproduct?id=<?php echo $product->id?>">
                                    <i class="fas fa-folder">
                                    </i>
                                    Nézet
                                </a>
                                <?php if($user->accesslevel==0):?>
                                <a class="btn btn-info btn-sm" href="<?php echo SITEURL?>/products/product/editproduct?id=<?php echo $product->id?>">
                                    <i class="fas fa-pencil-alt">
                                    </i>
                                    Szerkesztés
                                </a>
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php
                    endforeach;
                    ?>
                </tbody>
            </table>
        </div>
        <!-- /.card-body -->
    </div>
<?php
}
?>