<?php
/*=======================================================================
 *
 * jb_list_fs.php
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/

include_once ("../include/global.inc.php");
include_once ("../include/auth.inc.php");

// Check HTTP-Parameters
getSecHttpVars("1",array("maskNumOfWins","setPercentValues"));


// Get default values to be displayed calling the joblists (1. frame = Autoranking, 2. frame = Open jobs, etc.)
// First try to get default values defined by the employees
$defaultListStatus = "";
$tmp = getParameterValue($emp_id, "MASK_JOBLIST_DEFAULTLIST");
if ($tmp != "") :
   $defaultListStatus = explode(",",$tmp);
endif;
// If values do not exist take default system values
if ($defaultListStatus == "") :
   $defaultListStatus = explode(",",MASK_JOBLIST_DEFAULTLIST);
endif;


if ($maskNumOfWins == "" || $maskNumOfWins == "0" || !is_numeric($maskNumOfWins)) : $maskNumOfWins = "2"; endif;       // Number of frames = number of lists

// Initialize navigation-level
mcIsSet($navigationLevel, "1");
if ($navigationLevel == "" || ($navigationLevel != "1" && $navigationLevel != "2" && $navigationLevel != "3")) :
   $navigationLevel = "1";
endif;

$frames = "";
$framesetScaleArray = array();

// Scaling factor for homogeneous scaling (no percent values set manually)
$scale = round(100 / $maskNumOfWins);

for ($j = 1; $j <= $maskNumOfWins; $j++) :
    if ($setPercentValues == "") :
       $framesetScaleArray[] = $scale . "%";
    else :
       // Get percent-value for scaling of the current frame
       getSecHttpVars("1",array("percentScaleValueWin_" . $j));
       $tmp = "percentScaleValueWin_" . $j;
       $framesetScaleArray[] = ${$tmp};
    endif;
    $frames .= "<frame src=\"jb_list.php?defaultListStatus=" . ec($defaultListStatus[$j - 1]) . "&maskNumOfWin=" . ec($j) . "&maskNumOfWins=" . ec($maskNumOfWins) . ($j == "1" ? "&showScalingMenu=0" : "") .  "\" name=\"content" . $j . "\" scrolling=\"auto\" marginwidth=\"0\" marginheight=\"0\">\n";
endfor;

// Normalize values to 100%
if ($setPercentValues != "") :
   $sumValue = array_sum($framesetScaleArray);
   for ($j = 0; $j < $maskNumOfWins; $j++) :
       $framesetScaleArray[$j] = round($framesetScaleArray[$j] * (100 / $sumValue));
   endfor;
endif;

$framesetScale = implode(",", $framesetScaleArray);
?>

<html>

<head>
<title><?php echo getLngt("AUFTRAGSLISTEN") ?></title>

</head>

<frameset rows="<?php echo $framesetScale ?>" id="jb_list_fs">

   <?php echo $frames ?>
    
</frameset>

</html>
