<?php
//print_r($_POST);
//$filter = ['id' => $_GET['econid']];
//print_r($user);
if (isset($_POST) && $_POST != []) {
    $data = $_POST;
    $filter = ['productCategoryName' => $data['productCategoryName']];
    //$test = $auth->getApiDataFilter("get/product",['companyName'=>2]);
    //print_r($test);
    $response = $auth->getApiDataFilter('get/productcategory/exists', $filter);
    if (isset($response->status)) {
        $response = $auth->getApiData("get/productcategory/lastid");
        $response = $response[0];
        $data['id'] = $response->id + 1;
        $data['postedBy'] = $user->id;
        print_r(json_encode($data));
        $response = $auth->sendApiData("set/productcategory/new", $data);
        print_r($response);
    }
}
//$partners = $auth->getApiDataFilter("get/machine/full", $filter);
?>
<div class="row card">
    <div class="col-12 text-center">
        <button type="button" class="btn btn-block bg-gradient-success btn-lg savedata">Mentés</button>
    </div>
</div>
<form id="sendForm" class="row" method="POST">
    <div class="col-lg-6 col-sm-12">
        <div class="card">
            <div class="card-header">
                <h4>Új Termékkategória</h4>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-lg-4 div-sm-6">
                        <h5>Termékkategória neve</h5>
                    </div>
                    <div class="col-lg-8 div-sm-6">
                        <input value="" class="form-control" name="productCategoryName" />
                    </div>
                </div>
                
            </div>
        </div>
    </div> 
</form>
<?php
addJS("edit.js");
?>