Ejemplo n.º 1
0
    public static function Rangliste($spieler, &$row, &$lists, $option, $jid, $vname, $gname, $sname, $cid, $exist, $count, $gid_exist)
    {
        CLMViewRanglisten::setRanglisteToolbar($vname);
        JRequest::setVar('hidemainmenu', 1);
        JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'extrainfo');
        ?>

<script language="javascript" type="text/javascript">
	 
	function edit()
	{
	var task 	= document.getElementsByName ( "task") [0];
	var pre_task 	= document.getElementsByName ( "pre_task") [0];
	task.value 	= "add";
	pre_task.value 	= "add";
	document.adminForm.submit();
	}

		 Joomla.submitbutton = function (pressbutton) { 		
		var form = document.adminForm;
		var pre_task = document.getElementsByName ( "pre_task") [0];

		if (pressbutton == 'sortieren') { 
			//alert( 'sort:'+pressbutton+'test2' );
			Sortieren(); return true; }
		if (pressbutton == 'pruefen') { 
	//alert( 'test1'+pressbutton+'test2' );
			Pruefbutton(); 	return true; }
		if (pressbutton == 'neu_laden') { 
			location.reload(); return true; }
		if (pressbutton == 'save') { 
			if (Pruefen()==false) return; }
		if (pressbutton == 'apply') { 
			if (Pruefen()==false) return; }
		if (pre_task.value == 'add') {
		if (pressbutton == 'cancel') {
				submitform( pressbutton ); return; }
			if (pressbutton == 'save') { 
				if (Pruefen()==false) return; }
			if (pressbutton == 'apply') { 
				if (Pruefen()==false) return; }
		// do field validation
		if (form.filter_vid.value == "0") {
			alert( "<?php 
        echo JText::_('RANGLISTE_VEREIN_ANGEBEN', true);
        ?>
" );
		} else if (form.filter_sid.value == "0") {
			alert( "<?php 
        echo JText::_('RANGLISTE_SAISON_ANGEBEN', true);
        ?>
" );
		} else if (form.filter_gid.value == "0") {
			alert( "<?php 
        echo JText::_('RANGLISTE_GRUPPE_ANGEBEN', true);
        ?>
" );
		} else {
			submitform( pressbutton );
		}
		} else {
			if (pressbutton == 'save') { 
				if (Pruefen()==false) return; }
			if (pressbutton == 'apply') { 
				if (Pruefen()==false) return; }
			submitform( pressbutton );
		}
	}

function Zcheck(Wert)
 {
  var chkZ = 1;
  for (i = 0; i < Wert.length; ++i)
    if (Wert.charAt(i) < "0" ||
        Wert.charAt(i) > "9")
      chkZ = -1;
  if (chkZ == -1) {
   return false;
   }
  else {return true};
 }
function Mcheck(Ob)
 {
  if (!Zcheck(Ob.value)) {
    alert("Mannschaft keine Zahl!");
    Ob.focus();
    return false;
   }
 }
function Rcheck(Ob)
 {
  if (Zcheck(Ob.value)) return true;
  var i=Ob.value.indexOf("/")
  if (i>0)
   {
    var M=Ob.value.slice(0,i);
    var R=Ob.value.slice(i+1);
    if ((R=='')||(!Zcheck(M))||(!Zcheck(R)))
     {
      Ob.focus();
      alert("<?php 
        echo JText::_('RANGLISTE_MCHECK', true);
        ?>
");
      return false;
     }
    else
     {
      Ob.value=M*1000+R*1;
      return true;
     }
   }
  Ob.focus();
  alert("Rang ist keine Zahl");
  return false;
 }
function Spielergroesser(S1,S2)
 {
  if (S1[0]>S2[0]) return true; //0=Mannschaft
  if (S1[0]<S2[0]) return false;
  if (S1[1]>S2[1]) return true; //1=Rang
  if (S1[1]<S2[1]) return false;
  if (S1[4]<S2[4]) return true; //4=DWZ
  if (S1[4]>S2[4]) return false;
  if (S1[5]<S2[5]) return true; //5=DWZ-Index
  if (S1[5]>S2[5]) return false;
  if (S1[2]>S2[2]) return true; //2=Name
  if (S1[2]<S2[2]) return false;
  if (S1[3]>S2[3]) return true; //3=Mgl
  return false;
 }
function Spielerschreiben(i)
{
    if (Spieler[i][0]==999)  document.getElementsByName('MA'+i)[0].value=0;
    else document.getElementsByName('MA'+i)[0].value=Spieler[i][0];
    if (Spieler[i][1]==9999) document.getElementsByName('RA'+i)[0].value=0;
    else document.getElementsByName('RA'+i)[0].value=Spieler[i][1];
    document.getElementById('SP'+i).innerHTML=Spieler[i][2];
    document.getElementsByName('MGL'+i)[0].value=Spieler[i][3];
    document.getElementById('MGL'+i).innerHTML=Spieler[i][3];
    document.getElementById('DWZ'+i).innerHTML=Spieler[i][4];
    document.getElementById('DWI'+i).innerHTML=Spieler[i][5];
    <?php 
        if (isset($UsePKZ) and $UsePKZ == 1) {
            ?>
document.getElementById('PKZ'+i).innerHTML=Spieler[i][6];
    document.getElementsByName('PKZ'+i)[0].innerHTML=Spieler[i][6];
    <?php 
        }
        ?>
}
function QSort(l,r,Tiefe)
 {
  var i=l;
  var j=r;
  var MittelSpieler=Spieler[Math.floor((l+r)/2)];
  do
   {
    while (Spielergroesser(MittelSpieler,Spieler[i])) i++;
    while (Spielergroesser(Spieler[j],MittelSpieler)) j--;
    if (!(i>j))
     {
      var VS2=Spieler[i];
      Spieler[i]=Spieler[j];
      Spieler[j]=VS2;
      i++;
      j--;
     }
   }
  while (!(i>j));
  if (l<j) QSort(l,j,Tiefe+1);
  if (i<r) QSort(i,r,Tiefe+1); 
 }
function Sortieren()
 {
  Spieler=new Array;
  i=0;
  while (document.getElementsByName('MA'+i)[0]) {
    Spieler[i]=new Array(5)
    Spieler[i][0]=document.getElementsByName('MA'+i)[0].value-0;
    if (Spieler[i][0]==0) Spieler[i][0]=999;
    Spieler[i][1]=document.getElementsByName('RA'+i)[0].value-0;
    if (Spieler[i][1]==0) Spieler[i][1]=9999;
    Spieler[i][2]=document.getElementById('SP'+i).innerHTML;
    Spieler[i][3]=document.getElementById('MGL'+i).innerHTML-0;
    Spieler[i][4]=document.getElementById('DWZ'+i).innerHTML-0;
    Spieler[i][5]=document.getElementById('DWI'+i).innerHTML-0;
    <?php 
        if (isset($UsePKZ) and $UsePKZ == 1) {
            ?>
Spieler[i][6]=document.getElementById('PKZ'+i).innerHTML-0;<?php 
        }
        ?>
    i++;    
   }
  QSort(0,i-1,0)
  i=0;
  while (document.getElementsByName('MA'+i)[0])
   {
    Spielerschreiben(i);
    i++;    
   }
 }
function Pruefen()
 {
  Sortieren();
  var Ma=0;
  var Ra=0;
  var Sp=0;
  var Ersatz=1;
  i=0;
  var TempMa01=document.getElementsByName('MA'+i)[0].value;
  if (TempMa01==0) {
	alert('Keine Daten!');
	return false;
  }
  while(document.getElementsByName('MA'+i)[0]) {
    var TempMa=document.getElementsByName('MA'+i)[0].value;
    var TempRa=document.getElementsByName('RA'+i)[0].value;
	if (TempMa==0) {
		break;
	}
	//Hilfsprüfung: nur auf doppelte Einträge
    if ((TempMa==Ma) && (TempRa==Ra)) {
        alert('Doppelte Rangnummer! \n Mannschaft: '+Ma+'  Rang: '+Ra);
		return false;
	} else {
        Ma=TempMa;
        Ra=TempRa;
		i++;
		continue;
	}
	return true;
	//Ende Hilfsprüfung

    if (TempMa==Ma) {
      if (TempRa==(Sp+1)) {
        i++;
        Sp++;
        continue; }
      else if (TempRa==(1000*Ma+Ersatz)) {
        i++;
        Ersatz++;
        continue; }
      else {
        if (window.confirm('Die Rangnummer von Spieler '+document.getElementsByName('SP'+i)[0].innerHTML+' ist '+TempRa+'!\nErwartet wird '+(Sp+1)+'!\nFortsetzen?')) {
          Sp=TempRa;
          i++;
          continue; }
        document.getElementsByName('RA'+i)[0].focus();
        return false; } }
    else if (TempMa==(Ma+1)) {
      Ma++;
      Ersatz=1;
      if (TempRa!=(Sp+1)) {
        if (window.confirm('Der erste Spieler ('+document.getElementsByName('SP'+i)[0].innerHTML+') der '+Ma+'.Mannschaft hat Rangnummer '+TempRa+'!\nErwartet wird '+(Sp+1)+'\nFortsetzen?')) {
          Sp=TempRa;
          i++;
          continue; }
        document.getElementsByName('RA'+i)[0].focus();
        return false; }
      else {
        Sp++;
        i++;
        continue; } }
    else if (TempMa==90) {
      Ma=90;
      Sp=90000;
      continue; }
    else if (TempMa==99) {
      Ma=99;
      Sp=99000;
      continue; }
    else {
      if (Ma!=0) var Text='Die Mannschaftsnummern müssen aufsteigend sein!\nLetzte Mannschaftsnummer war '+Ma;
      else var Text='Die erste Mannschaft muß die Nummer 1 haben!';
      if (window.confirm(Text+'\nFortsetzen?')) {
        Sp=TempRa;
        i++;
        continue; }
      document.getElementsByName('MA'+i)[0].focus();
      return false; }
    if (window.confirm('Unbekannter Aufstellungsfehler!\nMannschaft: '+TempMa+'\nRangnummer: '+TempRa+'\nSpielername: "'+document.getElementsByName('SP'+i)[0].innerHTML+'"\nFortsetzen?')) {
      Sp=TempRa;
      i++;
      continue; }
    document.getElementsByName('MA'+i)[0].focus();
    return false; }
  return true;
 } // end: function Pruefen()
function Pruefbutton()
 {
  if (Pruefen()==true) alert('Alles in Ordnung');
 }

 
</script>

<?php 
        if ($exist and JRequest::getVar('task') == "add") {
            ?>

	<div class="col width-100">
	<fieldset class="adminform">
	<legend><?php 
            echo JText::_('RANGLISTE_TIP');
            ?>
</legend>

	<h1><?php 
            echo JText::_('RANGLISTE_TIP_LINE1');
            ?>
</h1>
	<h2><?php 
            echo JText::_('RANGLISTE_TIP_LINE2');
            ?>
</h2>
	<br>

	</fieldset>
	</div>

<?php 
        }
        ?>
<form action="index.php" method="post" name="adminForm" id="adminForm">

<div>
		<div class="width-50 fltlft">
		<fieldset class="adminform">
		<legend><?php 
        echo JText::_('RANGLISTE_DETAILS');
        ?>
</legend>

		<table class="admintable">
		<tr>
			<td class="key" nowrap="nowrap"><label for="filter_vid"><?php 
        echo JText::_('RANGLISTE_VEREIN') . ' : ';
        ?>
</label>
			</td>
			<td>
			<?php 
        if (JRequest::getVar('task') == 'edit') {
            echo $vname;
        } else {
            echo $lists['vid'];
        }
        ?>
			</td>
		</tr>

		<tr>
			<td class="key" nowrap="nowrap"><label for="filter_sid"><?php 
        echo JText::_('RANGLISTE_SAISON') . ' : ';
        ?>
</label>
			</td>
			<td>
			<?php 
        if (JRequest::getVar('task') == 'edit') {
            echo $sname;
        } else {
            echo $lists['sid'];
        }
        ?>
			</td>
		</tr>

		<tr>
			<td class="key" nowrap="nowrap"><label for="filter_gid"><?php 
        echo JText::_('RANGLISTE_GRUPPE') . ' : ';
        ?>
</label>
			</td>
			<td>
			<?php 
        if (JRequest::getVar('task') == 'edit') {
            echo $gname;
        } else {
            echo $lists['gruppe'];
        }
        ?>
			</td>
		</tr>

		<tr>
			<td class="key" nowrap="nowrap"><label for="published"><?php 
        echo JText::_('JPUBLISHED') . ' : ';
        ?>
</label>
			</td>
			<td><fieldset class="radio">
			<?php 
        echo $lists['published'];
        ?>
			</fieldset></td>
		</tr>

		</table>
		</fieldset>
		</div>

 <div class="width-50 fltrt">
  <fieldset class="adminform">
   <legend><?php 
        echo JText::_('REMARKS');
        ?>
</legend>
	<table class="adminlist">
	<legend><?php 
        echo JText::_('REMARKS_PUBLIC');
        ?>
</legend>
	<tr>
	<td width="100%" valign="top">
	<textarea class="inputbox" name="bemerkungen" id="bemerkungen" cols="40" rows="1" style="width:90%"><?php 
        echo str_replace('&', '&amp;', $row->bemerkungen);
        ?>
</textarea>
	</td>
	</tr>
	</table>
	<table class="adminlist">
	<legend><?php 
        echo JText::_('REMARKS_INTERNAL');
        ?>
</legend>
	<tr>
	<td width="100%" valign="top">
	<textarea class="inputbox" name="bem_int" id="bem_int" cols="40" rows="1" style="width:90%"><?php 
        echo str_replace('&', '&amp;', $row->bem_int);
        ?>
</textarea>
	</td>
	</tr>
	</table>
  </fieldset>
  </div>
</div>

<?php 
        if (!$exist and JRequest::getVar('task') == "add" or JRequest::getVar('task') == "edit") {
            $mainframe = JFactory::getApplication();
            $filter_vid = $mainframe->getUserStateFromRequest("{$option}.filter_vid", 'filter_vid', 0, 'int');
            $filter_sid = $mainframe->getUserStateFromRequest("{$option}.filter_sid", 'filter_sid', 0, 'int');
            $filter_gid = $mainframe->getUserStateFromRequest("{$option}.filter_gid", 'filter_gid', 0, 'int');
            if (JRequest::getVar('task') == "add" and (!$spieler or !$gid_exist or !$filter_gid)) {
                ?>
	<br><br><br><br><br><br><br><br><br><br>
	<fieldset class="adminform">
	<legend><?php 
                echo JText::_('RANGLISTE_TIP');
                ?>
</legend>
	<?php 
                if (!$gid_exist and $filter_sid and $filter_vid) {
                    ?>
	<h2><?php 
                    echo JText::_('RANGLISTE_TIP_LINE11');
                    ?>
</h2>
	<br>
	<?php 
                } else {
                    ?>
	<?php 
                    if (!$spieler and $filter_vid and $filter_sid and $filter_gid) {
                        ?>
	<h2><?php 
                        echo JText::_('RANGLISTE_TIP_LINE21');
                        ?>
</h2>
	<?php 
                    } else {
                        ?>
	<h2><?php 
                        echo JText::_('RANGLISTE_TIP_LINE31');
                        ?>
</h2>
	<br>
	<?php 
                    }
                    ?>
	</fieldset>
	
 <?php 
                }
            } else {
                ?>
<br><br><br><br><br><br><br><br><br><br>
<div>
<div class="width-50 fltlft">
  <fieldset class="adminform">
   <legend><?php 
                echo JText::_('RANGLISTE_PLATZ') . ' 1 - ' . (1 + intval(count($spieler) / 2));
                ?>
</legend>
	
	<table class="admintable">

	<tr>
		<td width="8%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_M_NR');
                ?>
</td>
		<td width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_RANG');
                ?>
</td>
		<td class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_NAME');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_MGL_NR');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_PKZ');
                ?>
</td>
		<td colspan="2" width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_DWZ');
                ?>
</td>
	</tr>

<?php 
                if (JRequest::getVar('task') == 'edit') {
                    $rang = array();
                    $cnt = 0;
                    for ($x = count($spieler) - $count; $x < count($spieler); $x++) {
                        $rang_x = array($cnt => $x);
                        $rang = $rang + $rang_x;
                        $cnt++;
                    }
                    for ($x = 0; $x < count($spieler) - $count; $x++) {
                        $rang_x = array($cnt => $x);
                        $rang = $rang + $rang_x;
                        $cnt++;
                    }
                    for ($x = 0; $x < 1 + intval(count($spieler) / 2); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" value="<?php 
                        echo $spieler[$rang[$x]]->man_nr;
                        ?>
" onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" value="<?php 
                        echo $spieler[$rang[$x]]->Rang;
                        ?>
" onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" name="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                } else {
                    for ($x = 0; $x < 1 + intval(count($spieler) / 2); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" <?php 
                        if (isset($spieler[$x]->man_nr)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->man_nr;
                            ?>
"<?php 
                        }
                        ?>
 onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" <?php 
                        if (isset($spieler[$x]->Rang)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->Rang;
                            ?>
" <?php 
                        }
                        ?>
 onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" name="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                }
                ?>
	</table>
  </fieldset>
  </div>


<div class="width-50 fltlft">
  <fieldset class="adminform">
   <legend><?php 
                echo JText::_('RANGLISTE_PLATZ') . ' ' . intval(count($spieler) / 2 + 2) . " - " . count($spieler);
                ?>
</legend>

	<table class="admintable">

	<tr>
		<td width="8%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_M_NR');
                ?>
</td>
		<td width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_RANG');
                ?>
</td>
		<td class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_NAME');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_MGL_NR');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_PKZ');
                ?>
</td>
		<td colspan="2" width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_DWZ');
                ?>
</td>
	</tr>
	
<?php 
                if (JRequest::getVar('task') == 'edit') {
                    for ($x = 1 + intval(count($spieler) / 2); $x < count($spieler); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" value="<?php 
                        echo $spieler[$rang[$x]]->man_nr;
                        ?>
" onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" value="<?php 
                        echo $spieler[$rang[$x]]->Rang;
                        ?>
" onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                } else {
                    for ($x = 1 + intval(count($spieler) / 2); $x < count($spieler); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" <?php 
                        if (isset($spieler[$x]->man_nr)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->man_nr;
                            ?>
"<?php 
                        }
                        ?>
 onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" <?php 
                        if (isset($spieler[$x]->Rang)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->Rang;
                            ?>
" <?php 
                        }
                        ?>
 onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                }
                ?>
	</table>

  </fieldset>
  </div>
  </div>

<?php 
            }
        }
        ?>
		<div class="clr"></div>
		<input type="hidden" name="section" value="ranglisten" />
		<input type="hidden" name="option" value="com_clm" />
		<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" />

		<input type="hidden" name="count" value="<?php 
        echo count($spieler);
        ?>
" />
		<input type="hidden" name="zps" value="<?php 
        echo $spieler[0]->ZPS;
        ?>
" />
		<input type="hidden" name="sid" value="<?php 
        echo $spieler[0]->sid;
        ?>
" />
		<input type="hidden" name="gid" value="<?php 
        echo $row->gid;
        ?>
" />
		<input type="hidden" name="exist" value="<?php 
        echo $exist;
        ?>
" />

		<input type="hidden" name="pre_task" value="<?php 
        echo JRequest::getVar('task');
        ?>
" />
		<input type="hidden" name="task" value="edit" />

		<?php 
        echo JHtml::_('form.token');
        ?>
		</form>
		<?php 
    }
Ejemplo n.º 2
0
 function edit()
 {
     $mainframe = JFactory::getApplication();
     $option = JRequest::getCmd('option');
     $filter_vid = $mainframe->getUserStateFromRequest("{$option}.filter_vid", 'filter_vid', 0, 'var');
     $filter_sid = $mainframe->getUserStateFromRequest("{$option}.filter_sid", 'filter_sid', 0, 'int');
     $filter_gid = $mainframe->getUserStateFromRequest("{$option}.filter_gid", 'filter_gid', 0, 'int');
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $task = JRequest::getVar('task');
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     $section = JRequest::getVar('section');
     JArrayHelper::toInteger($cid, array(0));
     $row = JTable::getInstance('ranglisten', 'TableCLM');
     $vname = "";
     $gname = "";
     $sname = "";
     if ($task == 'edit') {
         // illegaler Einbruchversuch über URL !
         // evtl. mitschneiden !?!
         $saison = JTable::getInstance('saisons', 'TableCLM');
         $saison->load($row->sid);
         if ($saison->archiv == "1") {
             // AND clm_core::$access->getType() !== 'admin') {
             JError::raiseWarning(500, JText::_('RANGLISTE_ARCHIV'));
             $mainframe->redirect('index.php?option=' . $option . '&section=vereine', $msg);
         }
         if ($cid[0] == "" and $task == 'edit') {
             JError::raiseWarning(500, JText::_('RANGLISTE_FALSCH'));
             $mainframe->redirect('index.php?option=' . $option . '&section=vereine', $msg);
         }
         // load the row from the db table
         $row->load($cid[0]);
         $sql = " SELECT Vereinname as vname FROM #__clm_dwz_vereine " . " WHERE ZPS ='" . $row->zps . "'" . " AND sid =" . $row->sid;
         $db->setQuery($sql);
         $vid = $db->loadObjectList();
         $vname = $vid[0]->vname;
         $sql = " SELECT Gruppe as gname FROM #__clm_rangliste_name " . " WHERE id =" . $row->gid . " AND sid =" . $row->sid;
         $db->setQuery($sql);
         $gruppe = $db->loadObjectList();
         $gname = $gruppe[0]->gname;
         $sql = " SELECT name as sname FROM #__clm_saison " . " WHERE id =" . $row->sid;
         $db->setQuery($sql);
         $saison = $db->loadObjectList();
         $sname = $saison[0]->sname;
     }
     // Prüfen ob die gewählte Liste bereits existiert
     if ($filter_gid and $filter_vid and $filter_sid) {
         $sql = " SELECT id FROM #__clm_rangliste_id " . " WHERE gid =" . intval($filter_gid) . " AND sid = " . intval($filter_sid) . " AND zps = '{$filter_vid}'";
         $db->setQuery($sql);
         $gid_check = $db->loadObjectList();
         if (count($gid_check) == 0) {
             $exist = 0;
         } else {
             $exist = $gid_check[0]->id;
         }
     } else {
         $exist = 0;
     }
     // Prüfen ob Gruppe existiert
     if ($filter_gid and $filter_sid) {
         $sql = " SELECT id FROM #__clm_rangliste_name " . " WHERE sid = " . intval($filter_sid);
         $db->setQuery($sql);
         $gid_id = $db->loadObjectList();
         $gid_exist = $gid_id[0]->id;
     } else {
         $gid_exist = 0;
     }
     // Rangliste in Abhängigkeit der Auswahl von vid,lid,sid ausgeben
     if ($task == 'edit') {
         $sql = " ALTER TABLE #__clm_rangliste_spieler order by sid desc,gruppe asc,zps asc,man_nr asc,Rang asc ";
         $db->setQuery($sql);
         $db->query();
         $sql = " SELECT Meldeschluss, geschlecht, alter_grenze, `alter` " . " FROM #__clm_rangliste_name" . " WHERE id =" . $row->gid . " AND sid = " . $row->sid;
         $sql_zps = $row->zps;
         $sql_gid = $row->gid;
         $sql_sid = $row->sid;
     } else {
         $sql = " SELECT Meldeschluss, geschlecht, alter_grenze, `alter` " . " FROM #__clm_rangliste_name" . " WHERE id =" . intval($filter_gid) . " AND sid = " . intval($filter_sid);
         $sql_zps = $filter_vid;
         $sql_gid = intval($filter_gid);
         $sql_sid = intval($filter_sid);
     }
     $db->setQuery($sql);
     $gid = $db->loadObjectList();
     $ges = "";
     $geb = "";
     if ($gid) {
         $melde = explode("-", $gid[0]->Meldeschluss);
         $jahr = $melde[0];
         if ($gid[0]->alter_grenze == "1") {
             $geb = " AND a.Geburtsjahr < " . ($jahr - $gid[0]->alter);
         }
         if ($gid[0]->alter_grenze == "2") {
             $geb = " AND a.Geburtsjahr > " . ($jahr - ($gid[0]->alter + 1));
         }
         if ($gid[0]->geschlecht == 1) {
             $ges = " AND a.Geschlecht = 'W' ";
         }
         if ($gid[0]->geschlecht == 2) {
             $ges = " AND a.Geschlecht = 'M' ";
         }
     }
     if ($task == 'edit') {
         $sql = " SELECT r.Rang, r.man_nr, a.sid,a.ZPS,a.Mgl_Nr,a.PKZ, a.DWZ," . " a.DWZ_Index,a.Geburtsjahr,a.Spielername" . " FROM #__clm_dwz_spieler as a" . " LEFT JOIN #__clm_rangliste_id as i ON i.sid = a.sid AND i.zps = a.ZPS " . " LEFT JOIN #__clm_rangliste_spieler as r ON r.sid = a.sid AND r.ZPS = a.ZPS AND r.Mgl_Nr = a.Mgl_Nr AND r.Gruppe = i.gid " . " WHERE a.ZPS = '{$sql_zps}'" . " AND i.id = " . $cid[0] . $geb . $ges . " ORDER BY r.man_nr,r.Rang ASC, a.DWZ DESC, a.DWZ_Index ASC, a.Spielername ASC ";
     } else {
         $sql = " SELECT a.sid,a.ZPS,a.Mgl_Nr,a.PKZ,a.DWZ,a.DWZ_Index,a.Geburtsjahr,a.Spielername" . " FROM #__clm_dwz_spieler as a" . " WHERE a.ZPS = '{$sql_zps}'" . " AND sid =" . $sql_sid . $geb . $ges . " ORDER BY a.DWZ DESC, a.DWZ_Index ASC, a.Spielername ASC ";
     }
     $db->setQuery($sql);
     $spieler = $db->loadObjectList();
     // Anzahl Einträge zählen
     $sql = " SELECT COUNT(ZPS) as ZPS FROM #__clm_rangliste_spieler " . " WHERE Gruppe =" . $sql_gid . " AND sid = " . $sql_sid . " AND zps = '{$sql_zps}'";
     $db->setQuery($sql);
     $count_id = $db->loadObjectList();
     $count = $count_id[0]->ZPS;
     if (isset($row->liga)) {
         $sql = " SELECT sl FROM #__clm_liga " . " WHERE id =" . $row->liga;
         $db->setQuery($sql);
         $lid = $db->loadObjectList();
     } else {
         $lid = 0;
     }
     $clmAccess = clm_core::$access;
     if ($clmAccess->access('BE_club_edit_ranking') === false and $task == 'edit') {
         JError::raiseWarning(500, JText::_('RANGLISTE_STAFFEL'));
         $link = 'index.php?option=' . $option . '&section=' . $section;
         $mainframe->redirect($link);
     }
     if ($task == 'edit') {
         // do stuff for existing records
         $row->checkout($user->get('id'));
     } else {
         // do stuff for new records
         $row->published = 0;
     }
     $lists['published'] = JHtml::_('select.booleanlist', 'published', 'class="inputbox"', $row->published);
     // Saisonliste //
     $sql = "SELECT id, name FROM #__clm_saison WHERE archiv =0";
     $db->setQuery($sql);
     $saisonlist[] = JHtml::_('select.option', '0', JText::_('RANGLISTE_SAISON_WAE'), 'id', 'name');
     $saisonlist = array_merge($saisonlist, $db->loadObjectList());
     $lists['sid'] = JHtml::_('select.genericlist', $saisonlist, 'filter_sid', 'class="inputbox" size="1" onchange="javascript:edit();"', 'id', 'name', intval($filter_sid));
     if ($filter_sid == 0) {
         $filter_sid = clm_core::$access->getSeason();
     }
     // Gruppenliste //
     $sql = "SELECT id as gid, Gruppe FROM #__clm_rangliste_name" . " WHERE sid =" . intval($filter_sid) . " AND published = 1";
     $db->setQuery($sql);
     if (!$db->query()) {
         $this->setRedirect('index.php?option=' . $option . '&section=' . $section);
         return JError::raiseWarning(500, $db->getErrorMsg());
     }
     $gruppenlist[] = JHtml::_('select.option', '0', JText::_('RANGLISTE_GRUPPE_AUS'), 'gid', 'Gruppe');
     $gruppenlist = array_merge($gruppenlist, $db->loadObjectList());
     $lists['gruppe'] = JHtml::_('select.genericlist', $gruppenlist, 'filter_gid', 'class="inputbox" size="1" onchange="javascript:edit();"', 'gid', 'Gruppe', intval($filter_gid));
     // Vereinliste
     // Vereinefilter laden
     $vereinlist = CLMFilterVerein::vereine_filter(0);
     $lists['vid'] = JHtml::_('select.genericlist', $vereinlist, 'filter_vid', 'class="inputbox" size="1" onchange="javascript:edit();"', 'zps', 'name', $filter_vid);
     require_once JPATH_COMPONENT . DS . 'views' . DS . 'ranglisten.php';
     $jid = 0;
     CLMViewRanglisten::Rangliste($spieler, $row, $lists, $option, $jid, $vname, $gname, $sname, $cid, $exist, $count, $gid_exist);
 }
Ejemplo n.º 3
0
    function Rangliste($spieler, &$row, &$lists, $option, $jid, $vname, $gname, $sname, $cid, $exist, $count, $gid_exist)
    {
        CLMViewRanglisten::setRanglisteToolbar($vname);
        JRequest::setVar('hidemainmenu', 1);
        JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'extrainfo');
        ?>

<script language="javascript" type="text/javascript">
	<!--
	function edit()
	{
	var task 	= document.getElementsByName ( "task") [0];
	var pre_task 	= document.getElementsByName ( "pre_task") [0];
	task.value 	= "add";
	pre_task.value 	= "add";
	document.adminForm.submit();
	}

	function submitbutton(pressbutton) {
		var form = document.adminForm;
		var pre_task = document.getElementsByName ( "pre_task") [0];

		if (pressbutton == 'sortieren') { Sortieren() }
		else if (pressbutton == 'pruefen') { Pruefbutton() }
		else if (pressbutton == 'neu_laden') { location.reload() }
	else {
		if (pre_task.value == 'add') {
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		// do field validation
		if (form.filter_vid.value == "0") {
			alert( "<?php 
        echo JText::_('RANGLISTE_VEREIN_ANGEBEN', true);
        ?>
" );
		} else if (form.filter_sid.value == "0") {
			alert( "<?php 
        echo JText::_('RANGLISTE_SAISON_ANGEBEN', true);
        ?>
" );
		} else if (form.filter_gid.value == "0") {
			alert( "<?php 
        echo JText::_('RANGLISTE_GRUPPE_ANGEBEN', true);
        ?>
" );
		} else {
			submitform( pressbutton );
		}
		}
		else {
			submitform( pressbutton );
		}
	}
	}

function Zcheck(Wert)
 {
  var chkZ = 1;
  for (i = 0; i < Wert.length; ++i)
    if (Wert.charAt(i) < "0" ||
        Wert.charAt(i) > "9")
      chkZ = -1;
  if (chkZ == -1) {
   return false
   }
  else {return true};
 }
function Mcheck(Ob)
 {
  if (!Zcheck(Ob.value)) {
    alert("Mannschaft keine Zahl!");
    Ob.focus();
    return false;
   }
 }
function Rcheck(Ob)
 {
  if (Zcheck(Ob.value)) return true;
  var i=Ob.value.indexOf("/")
  if (i>0)
   {
    var M=Ob.value.slice(0,i);
    var R=Ob.value.slice(i+1);
    if ((R=='')||(!Zcheck(M))||(!Zcheck(R)))
     {
      Ob.focus();
      alert("<?php 
        echo JText::_('RANGLISTE_MCHECK', true);
        ?>
");
      return false;
     }
    else
     {
      Ob.value=M*1000+R*1;
      return true;
     }
   }
  Ob.focus();
  alert("Rang ist keine Zahl");
  return false;
 }
function Spielergroesser(S1,S2)
 {
  if (S1[0]>S2[0]) return true; //0=Mannschaft
  if (S1[0]<S2[0]) return false;
  if (S1[1]>S2[1]) return true; //1=Rang
  if (S1[1]<S2[1]) return false;
  if (S1[4]<S2[4]) return true; //4=DWZ
  if (S1[4]>S2[4]) return false;
  if (S1[5]<S2[5]) return true; //5=DWZ-Index
  if (S1[5]>S2[5]) return false;
  if (S1[2]>S2[2]) return true; //2=Name
  if (S1[2]<S2[2]) return false;
  if (S1[3]>S2[3]) return true; //3=Mgl
  return false;
 }
function Spielerschreiben(i)
{
    if (Spieler[i][0]==999)  document.getElementsByName('MA'+i)[0].value=0;
    else document.getElementsByName('MA'+i)[0].value=Spieler[i][0];
    if (Spieler[i][1]==9999) document.getElementsByName('RA'+i)[0].value=0;
    else document.getElementsByName('RA'+i)[0].value=Spieler[i][1];
    document.getElementById('SP'+i).innerHTML=Spieler[i][2];
    document.getElementsByName('MGL'+i)[0].value=Spieler[i][3];
    document.getElementById('MGL'+i).innerHTML=Spieler[i][3];
    document.getElementById('DWZ'+i).innerHTML=Spieler[i][4];
    document.getElementById('DWI'+i).innerHTML=Spieler[i][5];
    <?php 
        if (UsePKZ) {
            ?>
document.getElementById('PKZ'+i).innerHTML=Spieler[i][6];
    document.getElementsByName('PKZ'+i)[0].innerHTML=Spieler[i][6];
    <?php 
        }
        ?>
}
function QSort(l,r,Tiefe)
 {
  var i=l;
  var j=r;
  var MittelSpieler=Spieler[Math.floor((l+r)/2)];
  do
   {
    while (Spielergroesser(MittelSpieler,Spieler[i])) i++;
    while (Spielergroesser(Spieler[j],MittelSpieler)) j--;
    if (!(i>j))
     {
      var VS2=Spieler[i];
      Spieler[i]=Spieler[j];
      Spieler[j]=VS2;
      i++;
      j--;
     }
   }
  while (!(i>j));
  if (l<j) QSort(l,j,Tiefe+1);
  if (i<r) QSort(i,r,Tiefe+1); 
 }
function Sortieren()
 {
  Spieler=new Array;
  i=0;
  while (document.getElementsByName('MA'+i)[0]) {
    Spieler[i]=new Array(5)
    Spieler[i][0]=document.getElementsByName('MA'+i)[0].value-0;
    if (Spieler[i][0]==0) Spieler[i][0]=999;
    Spieler[i][1]=document.getElementsByName('RA'+i)[0].value-0;
    if (Spieler[i][1]==0) Spieler[i][1]=9999;
    Spieler[i][2]=document.getElementById('SP'+i).innerHTML;
    Spieler[i][3]=document.getElementById('MGL'+i).innerHTML-0;
    Spieler[i][4]=document.getElementById('DWZ'+i).innerHTML-0;
    Spieler[i][5]=document.getElementById('DWI'+i).innerHTML-0;
    <?php 
        if (UsePKZ) {
            ?>
Spieler[i][6]=document.getElementById('PKZ'+i).innerHTML-0;<?php 
        }
        ?>
    i++;    
   }
  QSort(0,i-1,0)
  i=0;
  while (document.getElementsByName('MA'+i)[0])
   {
    Spielerschreiben(i);
    i++;    
   }
 }
function Pruefen()
 {
  Sortieren();
  var Ma=0;
  var Sp=0;
  var Ersatz=1;
  i=0;
  while(document.getElementsByName('MA'+i)[0]) {
    var TempMa=document.getElementsByName('MA'+i)[0].value;
    var TempRa=document.getElementsByName('RA'+i)[0].value;
    if (TempMa==Ma) {
      if (TempRa==(Sp+1)) {
        i++;
        Sp++;
        continue; }
      else if (TempRa==(1000*Ma+Ersatz)) {
        i++;
        Ersatz++;
        continue; }
      else {
        if (window.confirm('Die Rangnummer von Spieler '+document.getElementsByName('SP'+i)[0].innerHTML+' ist '+TempRa+'!\nErwartet wird '+(Sp+1)+'!\nFortsetzen?')) {
          Sp=TempRa;
          i++;
          continue; }
        document.getElementsByName('RA'+i)[0].focus();
        return false; } }
    else if (TempMa==(Ma+1)) {
      Ma++;
      Ersatz=1;
      if (TempRa!=(Sp+1)) {
        if (window.confirm('Der erste Spieler ('+document.getElementsByName('SP'+i)[0].innerHTML+') der '+Ma+'.Mannschaft hat Rangnummer '+TempRa+'!\nErwartet wird '+(Sp+1)+'\nFortsetzen?')) {
          Sp=TempRa;
          i++;
          continue; }
        document.getElementsByName('RA'+i)[0].focus();
        return false; }
      else {
        Sp++;
        i++;
        continue; } }
    else if (TempMa==90) {
      Ma=90;
      Sp=90000;
      continue; }
    else if (TempMa==99) {
      Ma=99;
      Sp=99000;
      continue; }
    else {
      if (Ma!=0) var Text='Die Mannschaftsnummern müssen aufsteigend sein!\nLetzte Mannschaftsnummer war '+Ma;
      else var Text='Die erste Mannschaft muß die Nummer 1 haben!';
      if (window.confirm(Text+'\nFortsetzen?')) {
        Sp=TempRa;
        i++;
        continue; }
      document.getElementsByName('MA'+i)[0].focus();
      return false; }
    if (window.confirm('Unbekannter Aufstellungsfehler!\nMannschaft: '+TempMa+'\nRangnummer: '+TempRa+'\nSpielername: "'+document.getElementsByName('SP'+i)[0].innerHTML+'"\nFortsetzen?')) {
      Sp=TempRa;
      i++;
      continue; }
    document.getElementsByName('MA'+i)[0].focus();
    return false; }
  return true;
 } // end: function Pruefen()
function Pruefbutton()
 {
  if (Pruefen()==true) alert('Alles in Ordnung');
 }
function Neuer(Zeile,Objekt)
 {
  
  alert('Diese Funktion ist deaktiviert.\n\nGrund:\nEs ist noch unklar, an welche zusätzliche Stellen der Eintrag gehört.');
//  return false;
  ObZeile=document.getElementById('Neuer');
  NeueZeile=document.createElement('tr');
    NeueZelle=document.createElement('td');
      NeuesInput=document.createElement('input');
      NeuesInput.setAttribute('type','text');
      NeuesInput.setAttribute('name','MA'+Zeile);
      NeuesInput.setAttribute('size','3');
      NeuesInput.setAttribute('maxLength','3');
      NeuesInput.setAttribute('value','0');
      NeuesInput.setAttribute('onChange','Mcheck(this)');
    NeueZelle.appendChild(NeuesInput);
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
      NeuesInput.setAttribute('name','RA'+Zeile);
      NeuesInput.setAttribute('size','5');
      NeuesInput.setAttribute('maxLength','5');
      NeuesInput.setAttribute('onChange','Rcheck(this)');
    NeueZelle.appendChild(NeuesInput);
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
    NeueZelle=document.createElement('td');
    NeueZelle.innerHTML=prompt('Wie hei�t der Spieler?','');
    NeueZelle.setAttribute('id','SP'+Zeile);
    NeueZelle.setAttribute('style','text-align:left; font-weight:bold');
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
    <?php 
        if (UsePKZ) {
            ?>
var PKZ=prompt('Welche PKZ hat der Spieler?','0');
    while (!Zcheck(PKZ)) PKZ=prompt('Die PKZ ist eine Zahl!\n\nWelche PKZ hat der Spieler?',PKZ);
    NeueZelle.innerHTML=PKZ;
    NeueZelle.setAttribute('id','PKZ'+Zeile);
    NeueZelle.setAttribute('style','text-align:right;');
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
      NeuesInput=document.createElement('input');
      NeuesInput.setAttribute('type','hidden');
      NeuesInput.setAttribute('name','PKZ'+Zeile);
      NeuesInput.setAttribute('value',NeueZelle.innerHTML);
    document.getElementById('inputfelder').appendChild(NeuesInput.cloneNode(true));
  <?php 
        }
        ?>
var PKZ=prompt('Welche Mitgliedsnummer hat der Spieler?','0');
    while (!Zcheck(PKZ)) PKZ=prompt('Die Mitgliedsnummer ist eine Zahl!\n\nWelche Mitgliedsnummer hat der Spieler?',PKZ);
    NeueZelle.innerHTML=PKZ;
    NeueZelle.setAttribute('id','MGL'+Zeile);
    NeueZelle.setAttribute('style','text-align:right;');
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
      NeuesInput=document.createElement('input');
      NeuesInput.setAttribute('type','hidden');
      NeuesInput.setAttribute('name','MGL'+Zeile);
      NeuesInput.setAttribute('value',NeueZelle.innerHTML);
    document.getElementById('inputfelder').appendChild(NeuesInput.cloneNode(true));
    NeueZelle.innerHTML='0';
    NeueZelle.setAttribute('id','DWZ'+Zeile);
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
    NeueZelle=document.createElement('td');
    NeueZelle.innerHTML='-';
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
    NeueZelle=document.createElement('td');
    NeueZelle.innerHTML='0';
    NeueZelle.setAttribute('id','DWI'+Zeile);
    NeueZelle.setAttribute('style','text-align:right;');
  NeueZeile.appendChild(NeueZelle.cloneNode(true));
  document.getElementById('Neuer').parentNode.insertBefore(NeueZeile.cloneNode(true),document.getElementById('Neuer'));
  Objekt.setAttribute('onclick',(Zeile+1)+',this');
  NeuesInput=document.createElement('input');
  NeuesInput.setAttribute('type','hidden');
  NeuesInput.setAttribute('name','Name[]');
  NeuesInput.setAttribute('value',document.getElementById('SP'+Zeile).innerHTML);
  document.getElementById('inputfelder').appendChild(NeuesInput.cloneNode(true));
  NeuesInput.setAttribute('name','PKZ[]');
  NeuesInput.setAttribute('value',document.getElementById('PKZ'+Zeile).innerHTML);
  document.getElementById('inputfelder').appendChild(NeuesInput.cloneNode(true));
  NeuesInput.setAttribute('name','MGL[]');
  NeuesInput.setAttribute('value',document.getElementById('MGL'+Zeile).innerHTML);
  document.getElementById('inputfelder').appendChild(NeuesInput.cloneNode(true));
 }

-->
</script>

<?php 
        if ($exist and JRequest::getVar('task') == "add") {
            ?>

	<div class="col width-100">
	<fieldset class="adminform">
	<legend><?php 
            echo JText::_('RANGLISTE_TIP');
            ?>
</legend>

	<h1><?php 
            echo JText::_('RANGLISTE_TIP_LINE1');
            ?>
</h1>
	<h2><?php 
            echo JText::_('RANGLISTE_TIP_LINE2');
            ?>
</h2>
	<br>

	</fieldset>
	</div>

<?php 
        }
        ?>
<form action="index.php" method="post" name="adminForm">

<div>
		<div class="col width-50">
		<fieldset class="adminform">
		<legend><?php 
        echo JText::_('RANGLISTE_DETAILS');
        ?>
</legend>

		<table class="admintable">
		<tr>
			<td class="key" nowrap="nowrap"><label for="filter_vid"><?php 
        echo JText::_('RANGLISTE_VEREIN') . ' : ';
        ?>
</label>
			</td>
			<td>
			<?php 
        if (JRequest::getVar('task') == 'edit') {
            echo $vname;
        } else {
            echo $lists['vid'];
        }
        ?>
			</td>
		</tr>

		<tr>
			<td class="key" nowrap="nowrap"><label for="filter_sid"><?php 
        echo JText::_('RANGLISTE_SAISON') . ' : ';
        ?>
</label>
			</td>
			<td>
			<?php 
        if (JRequest::getVar('task') == 'edit') {
            echo $sname;
        } else {
            echo $lists['sid'];
        }
        ?>
			</td>
		</tr>

		<tr>
			<td class="key" nowrap="nowrap"><label for="filter_gid"><?php 
        echo JText::_('RANGLISTE_GRUPPE') . ' : ';
        ?>
</label>
			</td>
			<td>
			<?php 
        if (JRequest::getVar('task') == 'edit') {
            echo $gname;
        } else {
            echo $lists['gruppe'];
        }
        ?>
			</td>
		</tr>

		<tr>
			<td class="key" nowrap="nowrap"><label for="published"><?php 
        echo JText::_('PUBLISHED') . ' : ';
        ?>
</label>
			</td>
			<td>
			<?php 
        echo $lists['published'];
        ?>
			</td>
		</tr>

		</table>
		</fieldset>
		</div>

 <div class="col width-50">
  <fieldset class="adminform">
   <legend><?php 
        echo JText::_('RANGLISTE_BEMERKUNGEN');
        ?>
</legend>
	<legend><?php 
        echo JText::_('RANGLISTE_OEFFENTLICH');
        ?>
</legend>
	<br>
	<textarea class="inputbox" name="bemerkungen" id="bemerkungen" cols="40" rows="1" style="width:90%"><?php 
        echo str_replace('&', '&amp;', $row->bemerkungen);
        ?>
</textarea>
	<br>
	<legend><?php 
        echo JText::_('RANGLISTE_INTERN');
        ?>
</legend>
	<br>
	<textarea class="inputbox" name="bem_int" id="bem_int" cols="40" rows="1" style="width:90%"><?php 
        echo str_replace('&', '&amp;', $row->bem_int);
        ?>
</textarea>
  </fieldset>
  </div>
</div>

<?php 
        if (!$exist and JRequest::getVar('task') == "add" or JRequest::getVar('task') == "edit") {
            global $mainframe;
            $filter_vid = $mainframe->getUserStateFromRequest("{$option}.filter_vid", 'filter_vid', 0, 'int');
            $filter_sid = $mainframe->getUserStateFromRequest("{$option}.filter_sid", 'filter_sid', 0, 'int');
            $filter_gid = $mainframe->getUserStateFromRequest("{$option}.filter_gid", 'filter_gid', 0, 'int');
            if (JRequest::getVar('task') == "add" and (!$spieler or !$gid_exist or !$filter_gid)) {
                ?>
	<br><br><br><br><br><br><br><br><br><br>
	<fieldset class="adminform">
	<legend><?php 
                echo JText::_('RANGLISTE_TIP');
                ?>
</legend>
	<?php 
                if (!$gid_exist and $filter_sid and $filter_vid) {
                    ?>
	<h2><?php 
                    echo JText::_('RANGLISTE_TIP_LINE11');
                    ?>
</h2>
	<br>
	<?php 
                } else {
                    ?>
	<?php 
                    if (!$spieler and $filter_vid and $filter_sid and $filter_gid) {
                        ?>
	<h2><?php 
                        echo JText::_('RANGLISTE_TIP_LINE21');
                        ?>
</h2>
	<?php 
                    } else {
                        ?>
	<h2><?php 
                        echo JText::_('RANGLISTE_TIP_LINE31');
                        ?>
</h2>
	<br>
	<?php 
                    }
                    ?>
	</fieldset>
	
 <?php 
                }
            } else {
                ?>
<br><br><br><br><br><br><br><br><br><br>
<div>
<div class="col width-50">
  <fieldset class="adminform">
   <legend><?php 
                echo JText::_('RANGLISTE_PLATZ') . ' 1 - ' . (1 + intval(count($spieler) / 2));
                ?>
</legend>
	
	<table class="admintable">

	<tr>
		<td width="8%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_M_NR');
                ?>
</td>
		<td width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_RANG');
                ?>
</td>
		<td class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_NAME');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_MGL_NR');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_PKZ');
                ?>
</td>
		<td colspan="2" width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_DWZ');
                ?>
</td>
	</tr>

<?php 
                if (JRequest::getVar('task') == 'edit') {
                    $rang = array();
                    $cnt = 0;
                    for ($x = count($spieler) - $count; $x < count($spieler); $x++) {
                        $rang_x = array($cnt => $x);
                        $rang = $rang + $rang_x;
                        $cnt++;
                    }
                    for ($x = 0; $x < count($spieler) - $count; $x++) {
                        $rang_x = array($cnt => $x);
                        $rang = $rang + $rang_x;
                        $cnt++;
                    }
                    for ($x = 0; $x < 1 + intval(count($spieler) / 2); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" value="<?php 
                        echo $spieler[$rang[$x]]->man_nr;
                        ?>
" onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" value="<?php 
                        echo $spieler[$rang[$x]]->Rang;
                        ?>
" onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                } else {
                    for ($x = 0; $x < 1 + intval(count($spieler) / 2); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" <?php 
                        if (isset($spieler[$x]->man_nr)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->man_nr;
                            ?>
"<?php 
                        }
                        ?>
 onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" <?php 
                        if (isset($spieler[$x]->Rang)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->Rang;
                            ?>
" <?php 
                        }
                        ?>
 onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                }
                ?>
	</table>
  </fieldset>
  </div>


<div class="col width-50">
  <fieldset class="adminform">
   <legend><?php 
                echo JText::_('RANGLISTE_PLATZ') . ' ' . intval(count($spieler) / 2 + 2) . " - " . count($spieler);
                ?>
</legend>

	<table class="admintable">

	<tr>
		<td width="8%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_M_NR');
                ?>
</td>
		<td width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_RANG');
                ?>
</td>
		<td class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_NAME');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_MGL_NR');
                ?>
</td>
		<td width="7%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_PKZ');
                ?>
</td>
		<td colspan="2" width="10%" class="key" nowrap="nowrap"><?php 
                echo JText::_('RANGLISTE_DWZ');
                ?>
</td>
	</tr>
	
<?php 
                if (JRequest::getVar('task') == 'edit') {
                    for ($x = 1 + intval(count($spieler) / 2); $x < count($spieler); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" value="<?php 
                        echo $spieler[$rang[$x]]->man_nr;
                        ?>
" onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" value="<?php 
                        echo $spieler[$rang[$x]]->Rang;
                        ?>
" onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$rang[$x]]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                } else {
                    for ($x = 1 + intval(count($spieler) / 2); $x < count($spieler); $x++) {
                        ?>

	<input type="hidden" name="PKZ<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
" />
	<input type="hidden" name="MGL<?php 
                        echo $x;
                        ?>
" value="<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
" />

	<tr>
	<td class="key" nowrap="nowrap">
		<input type="text" name="MA<?php 
                        echo $x;
                        ?>
" size="3" maxLength="3" <?php 
                        if (isset($spieler[$x]->man_nr)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->man_nr;
                            ?>
"<?php 
                        }
                        ?>
 onChange="Mcheck(this)">
	</td>
	<td class="key" nowrap="nowrap">
	<input type="text" name="RA<?php 
                        echo $x;
                        ?>
" size="5" maxLength="5" <?php 
                        if (isset($spieler[$x]->Rang)) {
                            ?>
 value="<?php 
                            echo $spieler[$x]->Rang;
                            ?>
" <?php 
                        }
                        ?>
 onChange="Rcheck(this)">
	</td>
	<td id="SP<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Spielername;
                        ?>
</td>
	<td id="MGL<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->Mgl_Nr;
                        ?>
</td>
	<td id="PKZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->PKZ;
                        ?>
</td>
	<td id="DWZ<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ;
                        ?>
</td>
	<td id="DWI<?php 
                        echo $x;
                        ?>
" class="key" nowrap="nowrap">
		<?php 
                        echo $spieler[$x]->DWZ_Index;
                        ?>
</td>
	</tr>

<?php 
                    }
                }
                ?>
	</table>

  </fieldset>
  </div>
  </div>

<?php 
            }
        }
        ?>
		<div class="clr"></div>
		<input type="hidden" name="section" value="ranglisten" />
		<input type="hidden" name="option" value="com_clm" />
		<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" />

		<input type="hidden" name="count" value="<?php 
        echo count($spieler);
        ?>
" />
		<input type="hidden" name="zps" value="<?php 
        echo $spieler[0]->ZPS;
        ?>
" />
		<input type="hidden" name="sid" value="<?php 
        echo $spieler[0]->sid;
        ?>
" />
		<input type="hidden" name="gid" value="<?php 
        echo $row->gid;
        ?>
" />
		<input type="hidden" name="exist" value="<?php 
        echo $exist;
        ?>
" />

		<input type="hidden" name="pre_task" value="<?php 
        echo JRequest::getVar('task');
        ?>
" />
		<input type="hidden" name="task" value="edit" />

		<?php 
        echo JHTML::_('form.token');
        ?>
		</form>
		<?php 
    }