<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$admin = $_SESSION["admin_" . $dbname];

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $hide = $_REQUEST["hide"];
    $hide_var = "";

    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }

    echo "<tr>";
    echo "<td><i class='fa fa-close remove' $hide_var ></i></td>";

    echo "<td>";
    echo "<select class='form-control form cono select2 fetchpart_$ctr' name='cono_$ctr' style='width:100%'>";
    echo "<option value=''></option>";
    $getcompy = mysqli_query($conn, "SELECT `code`,`compname` FROM `company` order by code ") or die(mysqli_error($conn));
    while ($gcompy = mysqli_fetch_array($getcompy)) {
        echo "<option value='$gcompy[code]'>$gcompy[compname]</option>";
    }
    echo "</select>";
    echo "</td>";

    echo "<td>";
    echo "<select class='form-control form finyear fetchpart_$ctr' name='finyear_$ctr' style='width:100%'>";
    echo "<option value=''></option>";
    $gyear = mysqli_query($conn, "SELECT `finyear` FROM `compyear`") or die(mysqli_error($conn));
    while ($year = mysqli_fetch_array($gyear)) {
        echo "<option value='$year[finyear]'>$year[finyear]</option>";
    }
    echo "</select>";
    echo "</td>";

    echo "<td><input type='text' class='form-control form yearname' name='yearname_$ctr' value='' readonly></td>";
    echo "<td><input type='text' class='form-control form startdate' name='startdate_$ctr' value='' readonly></td>";
    echo "<td><input type='text' class='form-control form lastdate' name='lastdate_$ctr' value='' readonly></td>";
    echo "</tr >";
    $ctr++;
} else {
    echo "ERROR";
}
?>