Ejemplo n.º 1
0
function check_points($points, $maxpoints)
{
    if (!is_array($points)) {
        $points = array();
    }
    if (!is_array($maxpoints)) {
        $maxpoints = array();
    }
    $keys = array_keys($points);
    foreach ($keys as $key) {
        if (!is_array($points[$key])) {
            $points[$key] = array();
        }
        $keys2 = array_keys($points[$key]);
        foreach ($keys2 as $key2) {
            if (check_point($points[$key][$key2], $maxpoints[$key2]) !== POINT_OK) {
                return FALSE;
            }
        }
    }
    return TRUE;
}
 function display_memberdata_admin($template, $id, $name, $firstname, $fullname, $matriculation_number, $count, $points, $maxpoints, $write_mode = FALSE, $bonus_1 = FALSE, $bonus_2 = FALSE)
 {
     $sum = 0.0;
     if ($write_mode) {
         $block = "BLOCK_POINTS_ADMIN";
     } else {
         $block = "BLOCK_POINTS";
     }
     if (!is_array($points)) {
         $points = array();
     }
     $template->setCurrentBlock("BLOCK_MEMBER");
     $template->setVariable("MEMBER_NAME", $name . "<br /><small>(" . ($matriculation_number != 0 ? $matriculation_number : "n.a.") . ")</small>");
     $template->setVariable("MEMBER_TITLE", $firstname . " " . $fullname);
     for ($i = 1; $i <= $count; $i++) {
         if (!isset($points[$i])) {
             $p = "";
         } else {
             $p = $points[$i];
         }
         if (isset($points[$i])) {
             $sum += (double) str_replace(",", ".", $points[$i]);
         }
         $template->setCurrentBlock($block);
         $template->setVariable("MEMBER_POINTS", trim($p));
         if ($write_mode) {
             $template->setVariable("MEMBER_ID", $id);
             $template->setVariable("MEMBER_SHEETCOUNT", $i);
             $style = "text-align: right;";
             $check = check_point($points[$i], $maxpoints[$i]);
             if ($check !== POINT_OK) {
                 $hint = "";
                 $style .= " background-color: #D11E01; color: #ffffff;";
                 switch ($check) {
                     case POINTERROR_NOINT:
                         $hint = gettext("Not a number");
                         break;
                     case POINTERROR_LOWERZERO:
                         $hint = gettext("Lower than zero");
                         break;
                     case POINTERROR_GREATERMAX:
                         $hint = gettext("Greater than max");
                         break;
                     default:
                         $hint = gettext("Invalid input");
                         break;
                 }
                 $template->setVariable("POINT_TITLE", $hint);
             }
             $template->setVariable("POINT_STYLE", "style='" . $style . "'");
         }
         $template->parse($block);
     }
     // SUM
     $template->setCurrentBlock("BLOCK_POINTS");
     $template->setVariable("MEMBER_POINTS", $sum);
     $template->parse("BLOCK_POINTS");
     // BONUS
     $template->setCurrentBlock("BLOCK_POINTS");
     $bonustext = units_pointlist::calculate_bonus($sum, $bonus_1, $bonus_2);
     $template->setVariable("MEMBER_POINTS", $bonustext);
     $template->parse("BLOCK_POINTS");
     $template->parse("BLOCK_MEMBER");
 }