= 7) {
switch ($view){
case "5term":
//select terms from last 5 years
$oldestyear = date("Y") - 5;
$getterms = "select distinct TERM_CODE_GRADUATED, TERM_GRADUATED from BANINST1.Z_SZRGRHR where DEGREE_STATUS != 'Pending' and (SUBSTR(TERM_CODE_GRADUATED, 1,4) >= ".$oldestyear.") order by TERM_CODE_GRADUATED desc";
break;
case "gradterm":
//select 2 most recent terms
$getterms = "select distinct TERM_CODE_GRADUATED, TERM_GRADUATED from BANINST1.Z_SZRGRHR where DEGREE_STATUS != 'Pending' and TERM_CODE_GRADUATED IS NOT NULL order by TERM_CODE_GRADUATED desc FETCH NEXT 2 ROWS ONLY";
break;
case "archive":
//select all terms back to 199910
$getterms = "select distinct TERM_CODE_GRADUATED, TERM_GRADUATED, TERM_GRADUATED from BANINST1.Z_SZRGRHR where DEGREE_STATUS != 'Pending' and TERM_CODE >= '199910' order by TERM_CODE DESC";
break;
default:
//select all terms back to 2000
$getterms = "select distinct TERM_CODE_GRADUATED, TERM_GRADUATED, TERM_GRADUATED from BANINST1.Z_SZRGRHR where DEGREE_STATUS != 'Pending' and TERM_CODE >= '200010' order by TERM_CODE DESC";
break;
}
//echo $getterms;
$results = oci_parse($Oracleconn, $getterms);
oci_execute($results);
while (($row = oci_fetch_array($results, OCI_ASSOC)) != false) {
$term_Select_text=str_replace(" Credit Courses", "", $row['TERM_GRADUATED']);
$term_array[] = ['term_code' => $row['TERM_CODE_GRADUATED'], 'term_desc' => $term_Select_text];
//echo "Term Code:".$row['TERM_CODE_GRADUATED']."
Term Desc:".$term_Select_text."
";
}
$term_json = json_encode($term_array);
var_dump($term_json);
$fp = fopen($terms_url, 'w');
fwrite($fp, $term_json);
fclose($fp);
}
$directory = getcwd();
$filename2 = "default-term.inc";
$default_term_url = $directory."\\".$filename2;
//check to see if updated more than 7 days
$diff=time()-filemtime( $default_term_url );
$days = round($diff/86400);
if ($days >= 7) {
$getdefaultterm = "Select TERM_CODE_GRADUATED from BANINST1.Z_SZRGRHR where DEGREE_STATUS != 'Pending' and TERM_CODE_GRADUATED IS NOT NULL order by TERM_CODE_GRADUATED desc FETCH NEXT 1 ROWS ONLY";
$defalttermresults = oci_parse($Oracleconn, $getdefaultterm);
oci_execute($defalttermresults);
while (($row = oci_fetch_array($defalttermresults, OCI_ASSOC)) != false) {
$term_default = $row['TERM_CODE_GRADUATED'];
$fp = fopen($default_term_url, 'w');
fwrite($fp, $term_default);
fclose($fp);
}
}