$Type = "01";
$Group = "01";
$asset = "001";
/*
$year = $_GET['assetYear'];
$Type = $_GET['assetType'];
$Group = $_GET['assetGroup'];
$asset = $_GET['assetCode'];
*/
$yearS = $year - 543;
$command = "WHERE assetAddDate LIKE '%" . $year . "%' AND assetTypeCode = '" . $type . "' AND assetGroupCode = '" . $group . "'";
$arrYear = $showAsset->getShowAssetYear();
$arrType = $showType->getAssetType();
//$showGroup->setAssetTypeCode($arrType);
$arrGroup = $showGroup->getAssetGroupByType("01");
$arrAsset = $showAsset->getAssetBy($command);
?>
            
            <select id="assetYearQR" onchange="changePrintQR();">
            <option value="0000">ประจำปี</option>
            <?php 
while ($row = $dbAsset->fetch_array($arrYear)) {
    $selDate = $row['years'];
    $year = $selDate + 543;
    echo "<option value='" . $year . "'>";
    echo $year . "</option>";
}
?>
             </select>
             
              <select id="assetTypeQR" onchange="changePrintQR();">
$yearFull = $_GET["assetYear"];
$type = $_GET["assetTypeCode"];
$group = $_GET["assetGroupCode"];
//$year = $yearFull-543;
$commandSearch = "AND CONCAT(SUBSTR(C.assetYear,3,4),'/',A.assetTypeCode,'-',A.assetTypeCode,B.assetGroupCode,'-',C.assetCode) LIKE '%" . $searchCode . "%'";
$commandYear = "AND C.assetYear = '" . $yearFull . "'";
$commandType = "AND A.assetTypeCode = '" . $type . "'";
$commandGroup = "AND B.assetGroupCode = '" . $group . "'";
$commandYT = "AND C.assetYear = '" . $yearFull . "' AND A.assetTypeCode = '" . $type . "'";
$commandYTG = "AND C.assetYear = '" . $yearFull . "' AND A.assetTypeCode = '" . $type . "' AND B.assetGroupCode = '" . $group . "'";
$commandTG = "AND C.assetTypeCode = '" . $type . "' AND B.assetGroupCode = '" . $group . "'";
$commandYG = "AND C.assetYear = '" . $yearFull . "' AND B.assetGroupCode = '" . $group . "'";
//$typeCode = $_GET["id"];
//$typeCode = $_GET["id"];
$arrAll = $asset->getAsset();
$arrYear = $asset->getAssetBy($commandYear);
$arrType = $asset->getAssetBy($commandType);
$arrGroup = $asset->getAssetBy($commandGroup);
$arrYT = $asset->getAssetBy($commandYT);
$arrTG = $asset->getAssetBy($commandTG);
$arrYTG = $asset->getAssetBy($commandYTG);
$arrYG = $asset->getAssetBy($commandYG);
$arrSearch = $asset->getAssetBy($commandSearch);
if ($searchCode != null) {
    $cmd = $arrSearch;
} else {
    if ($yearFull == null && $type == null && $group == null) {
        $cmd = $arrAll;
    } else {
        if ($yearFull != "0000" && $type == "00" && $group == "00") {
            $cmd = $arrYear;
session_start();
include_once '../configuration/db.php';
include_once '../configuration/ClassUser.php';
include_once '../configuration/ClassAsset.php';
include_once '../configuration/ClassCustomer.php';
include_once '../function/funcs.php';
//setup user
$user = new User();
setupUser($user);
//setup tkt
$Asset = new Asset();
//get input id
if (isset($_GET['id'])) {
    $token = $_GET['id'];
    $Asset->getAssetBy($token);
}
echo "\n       <html>\n       <head>";
if (isset($_GET['new'])) {
    echo "<title>OpenTroubleTicketing | New Asset </title>";
} else {
    echo "<title>OpenTroubleTicketing | View Asset : " . $Asset->code[0] . " </title>";
}
echo "\n       <meta charset='utf-8'>\n       <meta name='viewport' content='width=device-width, initial-scale=1'>\n       <link rel='icon' href='icon/icon.png'/>\n       <link rel='stylesheet' href='../style/bootstrap.min.css'>\n       <link rel='stylesheet' href='windowAssetStyle.css'>\n       <link rel='stylesheet' href='../style/defaultStyle.css'>\n       <script src='../js/jquery.min.js'></script>\n       <script src='../js/bootstrap.min.js'></script>\n       <script src='windowAssetScript.js'></script>\n       <script src='../js/defaultScript.js'></script>\n       </head>\n       <body>\n       <div class='container-fluid'>";
echo "\n           <div class='row'>\n               <div class='col-sm-3 col-md-3 col-lg-3>\n                   <label for='customerID'>ID</label><br>";
if (isset($_GET['new'])) {
    echo "<input type='text' class='disabled editable' id='assetCODE'  value=''>";
} else {
    echo "<input type='text' class='disabled editable' id='assetCODE' value='" . $Asset->code[0] . "'>";
}
echo "    \n               </div>\n               <div class='col-sm-3 col-md-3 col-lg-3>\n                  <label for='assetType'>TYPE</label>\n                  <input type='text' class='disabled editable' id='assetType' value='" . $Asset->type[0] . "'>\n               </div>\n                <div class='col-sm-3 col-md-3 col-lg-3>\n                  <label for='assetModel'>MODEL</label>\n                  <input type='text' class='disabled editable' id='assetModel' value='" . $Asset->model[0] . "'>\n               </div>\n               <div class='col-sm-3 col-md-3 col-lg-3>\n                  <label for='assetBrand'>BRAND</label>\n                  <input type='text' class='disabled editable' id='assetBrand' value='" . $Asset->brand[0] . "'>\n               </div>\n           </div>\n           <div class='row'>\n               <div class='col-sm-3 col-md-3 col-lg-3>\n                  <label for='assetSite'>SITE</label>\n                  <input type='text' class='disabled editable' id='assetSite' value='" . $Asset->site[0] . "'>\n               </div>\n               <div class='col-sm-3 col-md-3 col-lg-3>\n                  <label for='assetIp'>IP</label>\n                  <input type='text' class='disabled editable' id='assetIp' value='" . $Asset->ip[0] . "'>\n               </div>\n               <div class='col-sm-3 col-md-3 col-lg-3>\n                  <label for='assetStatus'>STATUS</label><br>";
    include_once '../configuration/ClassCustomer.php';
    $token = $_POST['token'];
    $customer = new Customer();
    if ($customer->getCustomerBy($token)) {
        $customer->printTabledCustomerList('active');
    } else {
        echo 0;
    }
}
//function: search asset
if (isset($_POST['searchASSETbyTOKEN'])) {
    include_once '../configuration/db.php';
    include_once '../configuration/ClassAsset.php';
    $token = $_POST['token'];
    $asset = new Asset();
    if ($asset->getAssetBy($token)) {
        $asset->printTabledAssetList('active');
    } else {
        echo 0;
    }
}
//function: update tkt
if (isset($_POST['updateTKT'])) {
    include_once '../configuration/db.php';
    include_once '../function/funcs.php';
    include_once '../configuration/ClassTicket.php';
    $id = $_POST['id'];
    $asset = sanitizeInput($_POST['asset']);
    $category = sanitizeInput($_POST['category']);
    $status = sanitizeInput($_POST['status']);
    $assignedTo = sanitizeInput($_POST['assignedTo']);
                }
                $counter++;
            }
        } else {
            echo "No customers found";
        }
        echo "</div>";
    }
}
if (isset($_POST['searchAsset'])) {
    $str = $_POST['code'];
    if (strlen($str) < 3) {
        echo "Hints are avaiable for 3 or more chars";
    } else {
        $assets = new Asset();
        $assets->getAssetBy($str);
        echo "<div id='hints'>";
        if ($assets->number > 0 && in_array('active', $assets->status)) {
            $counter = 0;
            while ($counter < $assets->number) {
                if ($assets->status[$counter] == 'active') {
                    echo "<li><a class='assetHint' href='#" . $assets->code[$counter] . "'>" . $assets->code[$counter] . "</a></li>";
                }
                $counter++;
            }
        } else {
            echo "No asset found";
        }
        echo "</div>";
    }
}