Hallo...
Ich traue mich gar nicht zu fragen aber ich habe ein Problem mit Checkbox..
Durch eine Abfrage wird eine Rangliste erstellt..Danach kann man bestimmte Personen anklicken in einer Checkbox...
Jetzt will ich einen Button erstellen um alle anzucklicken..oder die häckchen wieder raus zu nehmen...Ich habe 12 unterschiedlich ansätze von google oder auch von diesem Forum ausprobiert..leider hat es nicht geklappt..
Ich hoffe es kann mir jemand von euch helfen...
Im voraus vielen Dank
Hier der Code:
<?
if(!empty($_SESSION['id'])) {
if($_SESSION['id'] == 1) $_SESSION['acc'] = 1;
switch($_GET['action']):
default:
if($_SESSION['acc']) {
if(isset($_GET['timefield']) && isset($_GET['from']) && isset($_GET['until'])) {
$fp = fopen($basePath.'/punkte.settings', 'w');
fwrite($fp, $_GET['timefield'].'|'.$_GET['from'].'|'.$_GET['until']); fclose($fp);
}
}
$sett = explode('|', @file_get_contents($basePath.'/punkte.settings'));
$_GET['timefield'] = $sett[0];
$_GET['from'] = $sett[1];
$_GET['until'] = $sett[2];
?>
<a href="index.php">zurück</a><br />
<h1>Rangliste <?=$_GET['from']?> - <?=$_GET['until']?></h1>
<?
if($_SESSION['acc']) {
?>
<form action="<?=$baseURL?>" method="get">
<input type="hidden" name="content" value="punkte" />
<fieldset>
<legend><b>Admin:</b> angezeigt Datensätze festlegen</legend>
<label for="timefield">Zeitraum:</label>
<select id="timefield" name="timefield" class="inputField" style="width:120px">
<?=selectMe($_GET['timefield'], '
<option value="eingangsdatum">Eingangsdatum</option>
<option value="auftragsdatum">Auftragsdatum</option>
')?>
</select>
vom <input type="text" id="from" name="from" class="inputField" style="width:100px" value="<?=$_GET['from']?>" />
bis <input type="text" id="until" name="until" class="inputField" style="width:100px" value="<?=$_GET['until']?>" />
<input type="submit" class="submit" value="Anzeige festlegen" style="margin-left:25px" />
</fieldset>
</form>
<?
}
?>
<script language="javascript" type="text/javascript" src="<?=$baseURL?>/_js/calendar.js"></script>
<script language="javascript" type="text/javascript">
calendar.init('from');
calendar.init('until');
</script>
<tr>
<td style="width:200px">
</td>
</tr>
<table class="hperc" cellspacing="1">
<tr class="kat">
<?=($_SESSION['acc'] ? '<td class="tiny"> </td>' : '')?>
<td class="tiny">Platz</td>
<td>Vertreter</td>
</tr>
<?
$x = 0; $list = array();
$qry = qry("SELECT * FROM `_user` WHERE `level` = '1' AND `vertreter` = '0' ".($_SESSION['acc'] ? '' : "AND `nopoints` = '0'")." GROUP BY `knr` ORDER BY `knr`"); // Alle Vertreter auflisten
while($fetch = _fetch($qry)) {
$x++;
$p = 0; $ps = 0; $dd = 0;
// gueltige Antraege
$pqry = qry("SELECT COUNT(s1.`id`) AS `sum`, s1.product_id, s1.product_sub_id, s1.product_subs_id, s2.`points` AS p1, s3.`points` AS p2
FROM `user` AS s1
LEFT JOIN `products` AS s2 ON s1.`product_id` = s2.`id`
LEFT JOIN `products_sub` AS s3 ON s1.`product_sub_id` = s3.`id`
WHERE s1.`level` = '0' AND (s1.`knr` LIKE '".$fetch['knr']."%')
AND (DATE_FORMAT(FROM_UNIXTIME(s1.`".$_GET['timefield']."`), '%d.%m.%Y') = '".date("d.m.Y", strtotime($_GET['from']))."'
OR s1.`".$_GET['timefield']."` >= '".strtotime($_GET['from'])."')
AND (DATE_FORMAT(FROM_UNIXTIME(s1.`".$_GET['timefield']."`), '%d.%m.%Y') = '".date("d.m.Y", strtotime($_GET['until']))."'
OR s1.`".$_GET['timefield']."` <= '".strtotime($_GET['until'])."')
AND (s1.`qc` = '1' OR s1.`qc` = '0' OR s1.`qc` = '2') AND `storno` = '0' AND `storno_after` = '0'
GROUP BY `product_id`, `product_sub_id`, `product_subs_id`");
while($psql = _fetch($pqry)) {
$dd += floatval($psql['sum']);
$p += ($psql['sum'] * floatval($psql['p1']));
$p += ($psql['sum'] * floatval($psql['p2']));
foreach(explode(',', $psql['product_subs_id']) AS $e) {
$d = _fetch(qry("SELECT `points` FROM `products_subs` WHERE `id` = '".intval($e)."'"));
$p += ($psql['sum'] * floatval($d['points']));
}
}
// ungueltige / stornierte Antraege
$pqry = qry("SELECT COUNT(s1.`id`) AS `sum`, s1.product_id, s1.product_sub_id, s1.product_subs_id, s2.`points` AS p1, s3.`points` AS p2
FROM `user` AS s1
LEFT JOIN `products` AS s2 ON s1.`product_id` = s2.`id`
LEFT JOIN `products_sub` AS s3 ON s1.`product_sub_id` = s3.`id`
WHERE s1.`level` = '0' AND (s1.`knr` LIKE '".$fetch['knr']."%')
AND (DATE_FORMAT(FROM_UNIXTIME(s1.`".$_GET['timefield']."`), '%d.%m.%Y') = '".date("d.m.Y", strtotime($_GET['from']))."'
OR s1.`".$_GET['timefield']."` >= '".strtotime($_GET['from'])."')
AND (DATE_FORMAT(FROM_UNIXTIME(s1.`".$_GET['timefield']."`), '%d.%m.%Y') = '".date("d.m.Y", strtotime($_GET['until']))."'
OR s1.`".$_GET['timefield']."` <= '".strtotime($_GET['until'])."')
AND (`storno` > '0' OR `storno_after` > '0' OR `qc` = '3')
GROUP BY `product_id`, `product_sub_id`, `product_subs_id`");
while($psql = _fetch($pqry)) {
$dd += floatval($psql['sum']);
$ps += ($psql['sum'] * floatval($psql['p1']));
$ps += ($psql['sum'] * floatval($psql['p2']));
foreach(explode(',', $psql['product_subs_id']) AS $e) {
$d = _fetch(qry("SELECT `points` FROM `products_subs` WHERE `id` = '".intval($e)."'"));
$ps += ($psql['sum'] * floatval($d['points']));
}
}
if($p > 0 $ps > 0) {
$p_perc = @round(($p / ($p + $ps) * 100), 1);
$ps_perc = @round(($ps / ($p + $ps) * 100), 1);
$name = (empty($fetch['firma']) ? '' : ucfirst(re($fetch['firma'])).' - ').ucfirst(re($fetch['name'])).', '.ucfirst(re($fetch['vorname']));
if($_SESSION['level'] == 2) {
$name = '<a href="'.$baseURL.'/index.php?content=customers&timefield='.$_GET['timefield'].'&from='.$_GET['from'].'&until='.$_GET['until'].'&search='.$fetch['knr'].'&search_all=1&stamm=1&&limit=1000000&back_url='.urlencode($baseURL.'/index.php?content=punkte&timefield='.$_GET['timefield'].'&from='.$_GET['from'].'&until='.$_GET['until'].'').'">'.re($fetch['knr']).' ('.$name.')</a>';
}
$list[] = array(
'points' => ($p),
'c' => '
<tr class="[class]'.($_SESSION['id'] == $fetch['id'] ? ' marky' : '').'">
'.($_SESSION['acc'] ? '
<td><input type="checkbox" class="checkbox nopoints" name="nopoints['.$fetch['id'].']" value="1" title="Vertreter in der Rangliste anzeigen"'.(empty($fetch['nopoints']) ? ' checked="checked"' : '').' onclick="ajax(\''.$baseURL.'/index.php?content=ajax&action=setpoints&id='.$fetch['id'].'&set=\' + this.checked)" /></td>
' : '').'
<td style="text-align:right"><b>[platz].</b></td>
<td class="nowrap" style="height:38px;padding-bottom:0;padding-top:10px">
<div style="position:relative">
'.$name.'
<span style="position:absolute;right:5px;top:-10px"><b class="green">'.str_replace('.', ',', $p).' Punkt'.($p == 1 ? '' : 'e').'</b> '.(empty($ps) ? '' : '<br /><b class="red">'.(str_replace('.', ',', $ps)).' Punkt'.($ps == 1 ? '' : 'e').'</b> ').'('.$p_perc.'%)</span>
</div>
<div class="percent" style="position:relative;margin-top:7px"><div style="width:'.$p_perc.'%"></div></div>
</td>
</tr>
');
}
}
if(empty($x)) {
echo '
<tr class="first">
<td colspan="5" class="center">- Es wurden keine verwertbaren Datensätze gefunden -</td>
</tr>
';
} else {
$p = 0;
usort($list, create_function('$a,$b', '$a = $a[\'points\']; $b = $b[\'points\']; if($a == $b) { return 0; } return ($a > $b) ? -1 : +1;'));
foreach($list AS $l) {
$p++; $class = ($color % 2) ? 'first' : 'second'; $color++;
echo str_replace('[platz]', $p, str_replace('[class]', $class, $l['c']));
}
}
?>
</table>
<?
break;
endswitch;
}
?>