sql_query("UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0");
$users=sql_select("SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, SUM(`end`-`start`) as `shift_length` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` WHERE `User`.`Gekommen` = 1 GROUP BY `User`.`UID` ORDER BY `shift_length` DESC".$limit);
foreach($usersas$usr)
sql_query("UPDATE `User` SET `Aktiv` = 1 WHERE `UID`=".sql_escape($usr['UID']));
$users=sql_select("SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, SUM(`end`-`start`) as `shift_length` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` WHERE `User`.`Gekommen` = 1 GROUP BY `User`.`UID` ORDER BY `shift_length` DESC".$limit);
$table="";
if($search=="")
$tokens=array();
else
$tokens=explode("",$search);
foreach($usersas$usr){
if(count($tokens)>0){
$match=false;
$index=join("",$usr);
foreach($tokensas$t)
if(strstr($index,trim($t))){
$match=true;
break;
}
if(!$match)
continue;
}
$table.='<tr>';
$table.='<td>'.$usr['Nick'].'</td>';
$table.='<td>'.$usr['shift_count'].'</td>';
if($usr['shift_count']==0)
$table.='<td>-</td>';
else
$table.='<td>'.round($usr['shift_length']/60).' min ('.round($usr['shift_length']/3600).' h)</td>';