<?php

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

mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];
$spectype = $_SESSION["spltype_" . $dbname];
//browse($spectype);
if ($spectype == "1") {
    $speccond = "and `compchng`='1'";
} else {
    $speccond = "and `compchng`=''";
}
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 fetchpart_$ctr' name='cono_$ctr' style='width:100%'>";
    Echo "<option value=''></option>";
    $gcomp = mysqli_query($conn, "SELECT `code`,`name` FROM `company` where code !='' $speccond")or die(mysqli_error($conn));
    while ($comp = mysqli_fetch_array($gcomp)) {
        Echo "<option value='$comp[code]'>$comp[name]</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` where finyear != ''  group by finyear")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";
}
?>
 