<?php
$requesturl = explode("/", $_SERVER['REQUEST_URI']);
if (strpos($requesturl[2], "?"))
    $requesturl[2] = substr($requesturl[2], 0, strpos($requesturl[2], "?"));
$status = substr($requesturl[2], 12, 13);
$filter = ["status" => $status];
$filter["sale"] = $user->id;
if (isset($_GET['filter'])) {
    $filter['filter'] = $_GET['filter'];
}
//echo json_encode($filter);
$result = $auth->getApiDataFilter("v3/get/orders/status", $filter);
?>
<div class="row">
    <div class="col-12">
        <div class="card">
            <input type="text" class="form-control filterSearch" placeholder="Gyors szűrés ...">
        </div>
    </div>
</div>
<div class="row">
    <?php
    if (!isset($result->errorcode)) :
        foreach ($result as $o) : ?>
            <div class="orderitem col-12" data-filter-productName="<?php echo $o->productName ?>" data-filter-companyName="<?php echo $o->orderhead->companyName ?>">
                <div class="col-12" data-id="<?php echo $o->id ?>" data-orderhead="<?php echo $o->orderhead->id ?>">
                    <div class="card">
                        <div class="card-header" style="padding:0.25rem 20px 0.25rem 20px">
                            <div class="row">
                                <div class="col-lg-2 col-sm-4">
                                    <h7><?php echo "#PASS-{$o->orderhead->id}" ?></h7>
                                </div>
                                <div class="col-lg-6 col-sm-8">
                                    <h7><?php echo $o->orderhead->companyName ?></h7>
                                    <p style="margin:0px">Szállítás dátuma:<?php echo $o->delivery ?></p>
                                </div>
                                <div class="col-lg-4 col-sm-12 text-right">
                                    <a class="btn btn-primary btn-sm" href="<?php echo SITEURL ?>/orders/order/orderview?id=<?php echo $o->orderhead->id ?>">
                                        <i class="fas fa-folder">
                                        </i>
                                        Nézet
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="card-body" style="padding:5px 20px 5px 20px">
                            <div class="row">
                                <div class="col-lg-2 col-sm-12">
                                    <strong><?php echo $o->productName ?></strong>
                                </div>
                                <div class="col-lg-2 col-sm-12">
                                    <?php echo $o->total . " Ft" ?>
                                </div>
                                <div class="col-lg-3">Sz.sz.:<?php echo (isset($o->invoiceNum)) ? $o->invoiceNum : '' ?></div>
                                <div class="col-lg-2">Sz.k.:<?php echo (isset($o->invoiceDate)) ? $o->invoiceDate : '' ?></div>
                                <div class="col-lg-2">Száll.d.:<?php echo (isset($o->delivery)) ? $o->delivery : '' ?></div>
                                <div class="col-lg-3">TP:<?php echo (isset($o->ekaer)) ? $o->ekaer : '' ?></div>
                                <div class="col-lg-3">Meg.sz.:<?php echo (isset($o->ordernum)) ? $o->ordernum : '' ?></div>
                                <div class="col-lg-3">
                                    Státusz: <?php echo selectStatus($o->status) ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    <?php endforeach;
    endif; ?>
</div>
<?php
addJS("status.js");
?>