Example #1
0
    public static function newTeam($cid)
    {
        global $lng, $coach, $raceididx, $leagues, $rules, $divisions;
        self::handlePost($cid);
        // Show new team form.
        $easyconvert = new array_to_js();
        $races = self::getRaceArray();
        @$easyconvert->add_array($races, 'races');
        echo $easyconvert->output_all();
        // txt constants to show later
        $txtNoInduce = $lng->getTrn('noInduce', 'TeamCreator');
        $txtNoTeamName = $lng->getTrn('noTeamName', 'TeamCreator');
        $txtTooFewPlayers = $lng->getTrn('tooFewPlayers', 'TeamCreator');
        $txtRaceSelectTitle = $lng->getTrn('race', 'TeamCreator');
        $txtRaceSelectOption = $lng->getTrn('raceDefaultOption', 'TeamCreator');
        $txtTeamName = $lng->getTrn('teamName', 'TeamCreator');
        $txtNoRaceSelected = $lng->getTrn('noRaceSelected', 'TeamCreator');
        $txtCreateBtn = $lng->getTrn('createBtn', 'TeamCreator');
        // The page builds itself dynamically based on the selected race
        echo <<<EOQ
   <script type="text/javascript">

   function setIndex(elem, value) {
      document.getElementById(elem).selectedIndex = value;
   }

   function getValue(elemId) {
      try {
         var elem = document.getElementById(elemId);
         return elem.options[elem.selectedIndex].value;
      } catch (err) {
         return "";
      }
   }

   function getText(elemId) {
      try {
         if(document.all){
            return document.getElementById(elemId).innerText;
         } else {
            return document.getElementById(elemId).textContent;
         }
      } catch (err) {
         return "";
      }
   }

   function addCellToRow(rowObj, cellValue, colspan) {
      var cell = rowObj.insertCell(rowObj.cells.length);
      if (colspan > 1) {
         cell.colSpan=colspan;
         cell.align="right";
         cell.innerHTML = cellValue + "&nbsp;&nbsp;";;
        } else {
         cell.innerHTML = cellValue;
        }
      return cell;
   }

   function makeInput(type, id, value) {
      return "<input type=\\"" + type + "\\" id=\\"" + id + "\\" name=\\"" + id + "\\" value=\\"" + value+ "\\" />";
   }

   function setText(element, text) {
      if(document.all){
           document.getElementById(element).innerText = text;
      } else{
          document.getElementById(element).textContent = text;
      }
   }


   function updateQty(id, type, newQty) {
      var race = races[document.getElementById("rid").value];
      if (type == 'p') {
         var players = race['players'];
      } else {
         var players = race['others'];
      }
      var player = players[id];
      var divS = 'sub' + type + id;
      var newCost = player['cost'] * newQty;
      setText(divS, newCost);
      updateTotal();
   }

   function makeSelect(id, type, max) {
      var str = "<select id=\\"qty" + type + id + "\\" name=\\"qty" + type + id + "\\" onchange=\\"updateQty(" + id + ", '" + type + "', this.options[this.selectedIndex].value)\\">";
      for (var i = 0; i <= max; i++) {
         str += "<option value=\\"" + i + "\\">" + i + "</option>";
      }
      str += "</select>";
      return str;
   }

   function changeInduce(check) {
      var oldInduce = document.getElementById('oldInduce');
      if (check != new Boolean(oldInduce.checked)) {
         oldInduce.checked = check;
         var race = races[document.getElementById("rid").value];
         var pCounts = new Array();
         var oCounts = new Array();
         for (var i=0; i < race["player_count"]; i++) {
            pCounts[i] = getValue('qtyp' + i);
         }
         for (i=0; i < race["other_count"]; i++) {
            oCounts[i] = getValue('qtyo' + i);
         }
         changeRace(getValue("rid"));
         for (var i=0; i < race["player_count"]; i++) {
            if (pCounts[i] > 0) {
               try {
                  setIndex('qtyp' + i, pCounts[i]);
                  updateQty(i, 'p', pCounts[i]);
               } catch (err) {
               }
            }
         }
         for (i=0; i < race["other_count"]; i++) {
            if (oCounts[i] > 0) {
               try {
                  setIndex('qtyo' + i, oCounts[i]);
                  updateQty(i, 'o', oCounts[i]);
               } catch (err) {
               }
            }
         }
      }
   }

   function changeRace(raceId) {
      if (raceId < 0) return;
      var oFormObject = document.forms['form_team'];
      var race = races[raceId];
      var players = race["players"];
      var others = race["others"];
      var i;
      var rowIdx;
      var table = document.getElementById('teamTable');
      var induce = document.getElementById('induce').checked;
      while (table.rows.length > 1) {
         table.deleteRow(1);
      }
      setText("pcnt", "0");
      setText("total", "0");
      document.getElementById("raceid").value = race.rid;

      rowIdx = 0;
      for (i = 0; i < race["player_count"]; i++) {
         var player = players[i];
         if (!induce && player['ind']) {
            continue;
         }
         rowIdx++;
         var row = table.insertRow(rowIdx);
         addCellToRow(row, player["position"], 1);
         addCellToRow(row, player["ma"], 1);
         addCellToRow(row, player["st"], 1);
         addCellToRow(row, player["ag"], 1);
         addCellToRow(row, player["av"], 1);
         addCellToRow(row, player["skills"], 1);
         addCellToRow(row, player["N"], 1);
         addCellToRow(row, player["D"], 1);
         addCellToRow(row, player["cost"], 1);
         addCellToRow(row, makeInput('hidden', 'pid' + i, player["id"]) + makeSelect(i, 'p', player["max"]), 1);
         addCellToRow(row, "<div id=\\"subp" + i + "\\"></div>", 1);
      }
      for (i = 0; i < race["other_count"]; i++) {
         var other = others[i];
         if (!induce && other['ind']) {
            continue;
         }
         rowIdx++;
         var row = table.insertRow(rowIdx);
         addCellToRow(row, other["name"], 8);
         addCellToRow(row, other["cost"], 1);
         addCellToRow(row, makeInput('hidden', 'oid' + i, other["name"]) + makeSelect(i, 'o', other["max"]), 1);
         addCellToRow(row, "<div id=\\"subo" + i + "\\"></div>", 1);
      }
      try {
         if(induce) {
            document.getElementById("createBtnTxt").title="{$txtNoInduce}";
            document.getElementById("createBtn").disabled="disabled";
         } else {
            document.getElementById("createBtnTxt").title="";
            document.getElementById("createBtn").disabled="";
         }
      } catch (err) {
         // ignore - probably not logged in
      }
   }

   function updateTotal() {
      var race = races[getValue("rid")];
      var playerCount = race['player_count'];

      var pCount = 0;
      var total = 0;
      var subTot = 0;

      for (var i=0; i < playerCount; i++) {
         pCount += new Number(getValue('qtyp' + i));
         subTot = getText('subp' + i);
         if (!isNaN(subTot)) {
            total +=  new Number(subTot);
         }
      }
      setText("pcnt", pCount);
      for (var i=0; i < race['other_count']; i++) {
         subTot = getText('subo' + i);
         if (!isNaN(subTot)) {
            total +=  new Number(subTot);
         }
      }
      setText("total",total);
   }

   function createTeam() {
      var oForm = document.forms['form_team'];
      var spend = new Number(getText("total"));
      var pCount = new Number(getText("pcnt"));
      var tName = document.getElementById("tname").value;
      var submit = true;

      if (submit && tName.length == 0) {
         alert('{$txtNoTeamName}');
         submit = false;
      }

      if (submit && pCount < 11) {
         alert('{$txtTooFewPlayers}');
         submit = false;
      }

      if (submit) {
         oForm.submit();
      }

   }

   </script>
   <form method="POST" id="form_team">
   <input type="hidden" id="action" name="action" value="create" />
   <input type="hidden" id="raceid" name="raceid" value="" />
   <div class='boxWide'>
      <table class="common"><tr><td>
      <b>{$txtRaceSelectTitle}</b>: <select id="rid" name="rid" onchange="changeRace(this.options[this.selectedIndex].value)">
EOQ;
        echo "<option value='-1'>{$txtRaceSelectOption}</option>";
        $i = 0;
        foreach ($raceididx as $rname) {
            $translatedRaceName = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $rname)));
            echo "<option value='{$i}'>{$translatedRaceName}</option>";
            $i++;
        }
        echo <<<EOQ
       </select></td>
EOQ;
        if (isset($coach)) {
            $lgeDiv = $lng->getTrn('common/league') . '/' . $lng->getTrn('common/division');
            echo <<<EOQ
      <td align="right"><b>{$txtTeamName}</b>:</td><td><input type="text" id="tname" name="tname" size="20" maxlength="50"></td>
      <td align="right"><b>{$lgeDiv}</b>:</td><td><select name="lid_did" id="lid_did">
EOQ;
            foreach ($leagues = Coach::allowedNodeAccess(Coach::NODE_STRUCT__TREE, $coach->coach_id, array(T_NODE_LEAGUE => array('tie_teams' => 'tie_teams'))) as $lid => $lstruct) {
                if ($lstruct['desc']['tie_teams']) {
                    echo "<OPTGROUP LABEL='" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "'>\n";
                    foreach ($lstruct as $did => $dstruct) {
                        if ($did != 'desc') {
                            echo "<option value='{$lid},{$did}'>" . $lstruct['desc']['lname'] . ": " . $dstruct['desc']['dname'] . "</option>";
                        }
                    }
                    echo "</OPTGROUP>\n";
                } else {
                    echo "<option value='{$lid}'>" . $lstruct['desc']['lname'] . "</option>";
                }
            }
            echo <<<EOQ
      </select></td>
      <td><span id="createBtnTxt" title="{$txtNoRaceSelected}"><button id="createBtn" onclick="createTeam(); return false;" DISABLED>{$txtCreateBtn}</button></td>
EOQ;
        }
        $txtInducements = $lng->getTrn('inducementsCheck', 'TeamCreator');
        $txtPlayerCount = $lng->getTrn('playerCount', 'TeamCreator');
        $txtTotal = $lng->getTrn('total', 'TeamCreator');
        $txtPos = $lng->getTrn('common/pos');
        $txtSkills = $lng->getTrn('common/skills');
        $txtNorm = $lng->getTrn('normal', 'TeamCreator');
        $txtDoub = $lng->getTrn('double', 'TeamCreator');
        $txtDollar = $lng->getTrn('dollar', 'TeamCreator');
        $txtQuantity = $lng->getTrn('quantity', 'TeamCreator');
        $txtSubtotal = $lng->getTrn('subtotal', 'TeamCreator');
        echo <<<EOQ
       <td align="right" id="indTxt">{$txtInducements}:</td>
       <td><input type="checkbox" id="induce" onChange="changeInduce(this.checked)" /><input type="hidden" id="oldInduce" value="false" /></td>
       <td align="right"><b>{$txtPlayerCount}</b>:</td><td><div id="pcnt"></div></td>
       <td align="right"><b>{$txtTotal}</b>:</td><td><div id="total"></div></td>
       </tr></table>
   </div>
   <div class="boxWide">
   <table class="common" id="teamTable">
      <tr class="commonhead">
         <th>{$txtPos}</th>
         <th>MA</th>
         <th>ST</th>
         <th>AG</th>
         <th>Av</th>
         <th>{$txtSkills}</th>
         <th>{$txtNorm}</th>
         <th>{$txtDoub}</th>
         <th>{$txtDollar}</th>
         <th>{$txtQuantity}</th>
         <th>{$txtSubtotal}</th>
      </tr>
   </table>
   </div>
   </form>
EOQ;
    }
Example #2
0
    public static function report()
    {
        // Is $match_id valid?
        $match_id = (int) $_GET['mid'];
        if (!get_alt_col('matches', 'match_id', $match_id, 'match_id')) {
            fatal("Invalid match ID.");
        }
        global $lng, $stars, $rules, $settings, $coach, $racesHasNecromancer, $racesMayRaiseRotters, $DEA, $T_PMD__ENTRY_EXPECTED;
        global $T_MOUT_REL, $T_MOUT_ACH, $T_MOUT_IR, $T_MOUT_INJ;
        global $leagues, $divisions, $tours;
        $T_ROUNDS = Match::getRounds();
        // Perform actions (delete, lock/unlock and reset). Needs the
        $IS_LOCAL_ADMIN = is_object($coach) && $coach->isNodeCommish(T_NODE_TOURNAMENT, get_alt_col('matches', 'match_id', $match_id, 'f_tour_id'));
        self::matchActions($IS_LOCAL_ADMIN);
        // Create objects
        $m = new Match($match_id);
        $team1 = new Team($m->team1_id);
        $team2 = new Team($m->team2_id);
        // Determine visitor privileges.
        $lid = $divisions[$tours[$m->f_tour_id]['f_did']]['f_lid'];
        $ALLOW_EDIT = !$m->locked && is_object($coach) && ($coach->ring == Coach::T_RING_GLOBAL_ADMIN || $leagues[$lid]['ring'] == Coach::T_RING_LOCAL_ADMIN || $coach->isInMatch($m->match_id));
        $DIS = $ALLOW_EDIT ? '' : 'DISABLED';
        // Lock page for other reasons? (Used journeys etc)
        $USED_JOURNEYMAN_PRESENT = false;
        foreach (array(1 => $team1, 2 => $team2) as $id => $t) {
            foreach ($t->getPlayers() as $p) {
                if (!self::player_validation($p, $m)) {
                    continue;
                }
                if (!$m->is_played && $p->is_journeyman_used) {
                    $USED_JOURNEYMAN_PRESENT = true;
                }
            }
        }
        if ($USED_JOURNEYMAN_PRESENT) {
            $DIS = 'DISABLED';
        }
        // Relay to ES report page?
        if (isset($_GET['es_report'])) {
            # Don't care what value the GET field has!
            self::report_ES($match_id, !$ALLOW_EDIT);
            return;
        }
        $easyconvert = new array_to_js();
        @$easyconvert->add_array($stars, 'phpStars');
        // Load stars array into JavaScript array.
        echo $easyconvert->output_all();
        echo '<script language="JavaScript" type="text/javascript">
    var ID_MERCS = ' . ID_MERCS . ';
    var ID_STARS_BEGIN = ' . ID_STARS_BEGIN . ';
    </script>
    ';
        /*****************
         *
         * Submitted form?
         *
         *****************/
        if (isset($_POST['button']) && $ALLOW_EDIT) {
            if (get_magic_quotes_gpc()) {
                $_POST['summary'] = stripslashes($_POST['summary']);
            }
            MTS('Report submit STARTED');
            // FIRST, if any raised zombies are kept we need to create their player objects in order have the correct player- vs. match creation & played dates.
            foreach (array(1 => $team1, 2 => $team2) as $id => $t) {
                if (in_array($t->f_race_id, $racesHasNecromancer) && isset($_POST["t{$id}zombie"])) {
                    $pos_id = $DEA[$t->f_rname]['players']['Zombie']['pos_id'];
                    list($exitStatus, $pid) = Player::create(array('nr' => $t->getFreePlayerNr(), 'f_pos_id' => $pos_id, 'team_id' => $t->team_id, 'name' => 'RAISED ZOMBIE'), array('free' => true));
                    /*
                        Knowing the new zombie's PID we relocate the zombie match data to regular player data - this allows us
                        to use the same loop for submitting the zombie's match data.
                    */
                    foreach ($T_PMD__ENTRY_EXPECTED as $f) {
                        $postName = "{$f}_t{$id}zombie";
                        $_POST["{$f}_{$pid}"] = isset($_POST[$postName]) ? $_POST[$postName] : 0;
                        unset($_POST[$postName]);
                    }
                }
            }
            // SECONDLY, look for raised rotters too, do same as above with zombies...
            foreach (array(1 => $team1, 2 => $team2) as $id => $t) {
                if (in_array($t->f_race_id, $racesMayRaiseRotters) && isset($_POST["t{$id}rotterCnt"]) && ($N = (int) $_POST["t{$id}rotterCnt"]) > 0) {
                    foreach (range(1, $N) as $n) {
                        $pos_id = $DEA[$t->f_rname]['players']['Rotter']['pos_id'];
                        list($exitStatus, $pid) = Player::create(array('nr' => $t->getFreePlayerNr(), 'f_pos_id' => $pos_id, 'team_id' => $t->team_id, 'name' => "RAISED ROTTER {$n}"), array('free' => true));
                        /*
                            Knowing the new rotter's PID we relocate the rotter match data to regular player data - this allows us
                            to use the same loop for submitting the rotter's match data.
                        */
                        foreach ($T_PMD__ENTRY_EXPECTED as $f) {
                            $postName = "{$f}_t{$id}rotter{$n}";
                            $_POST["{$f}_{$pid}"] = isset($_POST[$postName]) ? $_POST[$postName] : 0;
                            unset($_POST[$postName]);
                        }
                    }
                }
            }
            // Update general match data
            status($m->update(array('submitter_id' => (int) $_SESSION['coach_id'], 'stadium' => (int) $_POST['stadium'], 'gate' => (int) $_POST['gate'] * 1000, 'fans' => (int) $_POST['fans'], 'ffactor1' => (int) $_POST['ff1'], 'ffactor2' => (int) $_POST['ff2'], 'income1' => (int) $_POST['inc1'] * 1000, 'income2' => (int) $_POST['inc2'] * 1000, 'team1_score' => (int) $_POST['result1'], 'team2_score' => (int) $_POST['result2'], 'smp1' => (int) $_POST['smp1'], 'smp2' => (int) $_POST['smp2'], 'tcas1' => (int) $_POST['tcas1'], 'tcas2' => (int) $_POST['tcas2'], 'fame1' => (int) $_POST['fame1'], 'fame2' => (int) $_POST['fame2'], 'tv1' => (int) $_POST['tv1'] * 1000, 'tv2' => (int) $_POST['tv2'] * 1000)), 'Saving match report');
            if (!empty($_POST['summary'])) {
                $m->saveText($_POST['summary']);
                # Save summery.
            }
            MTS('matches entry submitted');
            // Update match's player data
            foreach (array(1 => $team1, 2 => $team2) as $id => $t) {
                /* Save ordinary players */
                foreach ($t->getPlayers() as $p) {
                    if (!self::player_validation($p, $m)) {
                        continue;
                    }
                    // We create zero entries for MNG player(s). This is required!
                    $pid = $p->player_id;
                    # Shortcut
                    if ($p->getStatus($m->match_id) == MNG) {
                        $_POST["mvp_{$pid}"] = 0;
                        $_POST["cp_{$pid}"] = 0;
                        $_POST["td_{$pid}"] = 0;
                        $_POST["intcpt_{$pid}"] = 0;
                        $_POST["bh_{$pid}"] = 0;
                        $_POST["si_{$pid}"] = 0;
                        $_POST["ki_{$pid}"] = 0;
                        $_POST["ir1_d1_{$pid}"] = 0;
                        $_POST["ir1_d2_{$pid}"] = 0;
                        $_POST["ir2_d1_{$pid}"] = 0;
                        $_POST["ir2_d2_{$pid}"] = 0;
                        $_POST["ir3_d1_{$pid}"] = 0;
                        $_POST["ir3_d2_{$pid}"] = 0;
                        $_POST["inj_{$pid}"] = NONE;
                        $_POST["agn1_{$pid}"] = NONE;
                        $_POST["agn2_{$pid}"] = NONE;
                    }
                    $m->entry($p->player_id, array('mvp' => $_POST["mvp_{$pid}"], 'cp' => $_POST["cp_{$pid}"], 'td' => $_POST["td_{$pid}"], 'intcpt' => $_POST["intcpt_{$pid}"], 'bh' => $_POST["bh_{$pid}"], 'si' => $_POST["si_{$pid}"], 'ki' => $_POST["ki_{$pid}"], 'ir1_d1' => $_POST["ir1_d1_{$pid}"], 'ir1_d2' => $_POST["ir1_d2_{$pid}"], 'ir2_d1' => $_POST["ir2_d1_{$pid}"], 'ir2_d2' => $_POST["ir2_d2_{$pid}"], 'ir3_d1' => $_POST["ir3_d1_{$pid}"], 'ir3_d2' => $_POST["ir3_d2_{$pid}"], 'inj' => $_POST["inj_{$pid}"], 'agn1' => $_POST["agn1_{$pid}"], 'agn2' => $_POST["agn2_{$pid}"]));
                }
                MTS('Saved all REGULAR player entries in match_data for team ' . $id);
                /*
                    Save stars entries.
                */
                foreach ($stars as $star) {
                    $s = new Star($star['id']);
                    if (isset($_POST['team_' . $star['id']]) && $_POST['team_' . $star['id']] == $id) {
                        $sid = $s->star_id;
                        $m->entry($sid, array('f_team_id' => $t->team_id, 'mvp' => isset($_POST["mvp_{$sid}"]) && $_POST["mvp_{$sid}"] ? 1 : 0, 'cp' => $_POST["cp_{$sid}"], 'td' => $_POST["td_{$sid}"], 'intcpt' => $_POST["intcpt_{$sid}"], 'bh' => $_POST["bh_{$sid}"], 'si' => $_POST["si_{$sid}"], 'ki' => $_POST["ki_{$sid}"], 'ir1_d1' => 0, 'ir1_d2' => 0, 'ir2_d1' => 0, 'ir2_d2' => 0, 'ir3_d1' => 0, 'ir3_d2' => 0, 'inj' => NONE, 'agn1' => NONE, 'agn2' => NONE));
                    } else {
                        $s->rmMatchEntry($m->match_id, $t->team_id);
                    }
                }
                MTS('Saved all STAR player entries in match_data for team ' . $id);
                /*
                    Save mercenary entries.
                */
                Mercenary::rmMatchEntries($m->match_id, $t->team_id);
                // Remove all previously saved mercs in this match.
                for ($i = 0; $i <= 20; $i++) {
                    # We don't expect over 20 mercs. This is just some large random number.
                    $idm = '_' . ID_MERCS . '_' . $i;
                    if (isset($_POST["team{$idm}"]) && $_POST["team{$idm}"] == $id) {
                        $m->entry(ID_MERCS, array('f_team_id' => $t->team_id, 'nr' => $i, 'skills' => $_POST["skills{$idm}"], 'mvp' => isset($_POST["mvp{$idm}"]) && $_POST["mvp{$idm}"] ? 1 : 0, 'cp' => $_POST["cp{$idm}"], 'td' => $_POST["td{$idm}"], 'intcpt' => $_POST["intcpt{$idm}"], 'bh' => $_POST["bh{$idm}"], 'si' => $_POST["si{$idm}"], 'ki' => $_POST["ki{$idm}"], 'ir1_d1' => 0, 'ir1_d2' => 0, 'ir2_d1' => 0, 'ir2_d2' => 0, 'ir3_d1' => 0, 'ir3_d2' => 0, 'inj' => NONE, 'agn1' => NONE, 'agn2' => NONE));
                    }
                }
                MTS('Saved all MERC player entries in match_data for team ' . $id);
            }
            $m->finalizeMatchSubmit();
            # Required!
            MTS('Report submit ENDED');
            // Refresh objects used to display form.
            $m = new Match($match_id);
            $team1 = new Team($m->team1_id);
            $team2 = new Team($m->team2_id);
        }
        // Change round form submitted?
        if ($IS_LOCAL_ADMIN && isset($_POST['round'])) {
            status($m->chRound((int) $_POST['round']));
        }
        /****************
         *
         * Generate form
         *
         ****************/
        $teamUrl1 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team1_id, false, false) . "\">" . $m->team1_name . "</a>";
        $teamUrl2 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $m->team2_id, false, false) . "\">" . $m->team2_name . "</a>";
        $coachUrl1 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_COACH, $team1->owned_by_coach_id, false, false) . "\">" . $team1->f_cname . "</a>";
        $coachUrl2 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_COACH, $team2->owned_by_coach_id, false, false) . "\">" . $team2->f_cname . "</a>";
        $raceUrl1 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_RACE, $team1->f_race_id, false, false) . "\">" . $lng->getTrn('race/' . strtolower(str_replace(' ', '', $team1->f_rname))) . "</a>";
        $raceUrl2 = "<a href=\"" . urlcompile(T_URL_PROFILE, T_OBJ_RACE, $team2->f_race_id, false, false) . "\">" . $lng->getTrn('race/' . strtolower(str_replace(' ', '', $team2->f_rname))) . "</a>";
        $leagueUrl = League::getLeagueUrl(get_parent_id(T_NODE_MATCH, $m->match_id, T_NODE_LEAGUE));
        $divUrl = "<a href=\"" . urlcompile(T_URL_STANDINGS, T_OBJ_TEAM, false, T_NODE_DIVISION, get_parent_id(T_NODE_MATCH, $m->match_id, T_NODE_DIVISION)) . "\">" . get_parent_name(T_NODE_MATCH, $m->match_id, T_NODE_DIVISION) . "</a>";
        $tourUrl = Tour::getTourUrl(get_parent_id(T_NODE_MATCH, $m->match_id, T_NODE_TOURNAMENT));
        title($teamUrl1 . " - " . $teamUrl2);
        $CP = 8;
        // Colspan.
        ?>
    <table>
    <tr><td></td><td style='text-align: right;'><i><?php 
        echo $lng->getTrn('common/home');
        ?>
</i></td><td>&mdash;</td><td style='text-align: left;'><i><?php 
        echo $lng->getTrn('common/away');
        ?>
</i></td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/teams');
        ?>
</b>:</td><td style='text-align: right;'><?php 
        echo "{$teamUrl1}</td><td> &mdash; </td><td style='text-align: left;'>{$teamUrl2}";
        ?>
</td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/coaches');
        ?>
</b>:</td><td style='text-align: right;'><?php 
        echo "{$coachUrl1}</td><td> &mdash; </td><td style='text-align: left;'>{$coachUrl2}";
        ?>
</td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/races');
        ?>
</b>:</td><td style='text-align: right;'><?php 
        echo "{$raceUrl1}</td><td> &mdash; </td><td style='text-align: left;'>{$raceUrl2}";
        ?>
</td></tr>
    <tr><td colspan="4"><hr></td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/league');
        ?>
</b>:</td><td colspan="3">    <?php 
        echo $leagueUrl;
        ?>
</td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/division');
        ?>
</b>:</td><td colspan="3">  <?php 
        echo $divUrl;
        ?>
</td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/tournament');
        ?>
</b>:</td><td colspan="3"><?php 
        echo $tourUrl;
        ?>
</td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/round');
        ?>
</b>:</td><td colspan="3">     <?php 
        echo $T_ROUNDS[$m->round];
        ?>
</td></tr>
    <tr><td><b><?php 
        echo $lng->getTrn('common/dateplayed');
        ?>
</b>:</td><td colspan="3"><?php 
        echo $m->is_played ? textdate($m->date_played) : '<i>' . $lng->getTrn('matches/report/notplayed') . '</i>';
        ?>
</td></tr>
    <?php 
        if (Module::isRegistered('PDFMatchReport')) {
            $str = '<a href="handler.php?type=pdfmatchreport&amp;tid1=' . $team1->team_id . '&amp;tid2=' . $team2->team_id . '&amp;mid=' . $m->match_id . '" TARGET="_blank">Download PDF report</a>';
            echo "<tr><td><b>Match report</b>:</td><td>{$str}</td></tr>";
        }
        if (Module::isRegistered('UPLOAD_BOTOCS')) {
            echo "<tr><td><b>Replay</b>:</td><td colspan='3'><a href='handler.php?type=leegmgr&amp;replay={$m->match_id}'>View replay</a></td></tr>";
        }
        if ($IS_LOCAL_ADMIN) {
            ?>
		<script language="JavaScript" type="text/javascript">
			function match_delete() {
				return confirm('<?php 
            echo $lng->getTrn('matches/tourmatches/matchdelete');
            ?>
');
			}
			function match_reset() {
				return confirm('<?php 
            echo $lng->getTrn('matches/tourmatches/reset_notice');
            ?>
');
			}
		</script>
	    <?php 
            $matchURL = "index.php?section=matches&type=report&amp;mid={$m->match_id}";
            $deleteURL = "index.php?section=matches&amp;type=tourmatches&amp;trid={$m->f_tour_id}&amp;mid={$m->match_id}";
            echo "<tr><td><b>Admin:</b></td><td colspan='3'><b>";
            echo "<a onclick=\"return match_reset();\" href='{$matchURL}&amp;action=reset'>" . $lng->getTrn('common/reset') . "</a>&nbsp;\n";
            echo "<a onclick=\"return match_delete();\" href='{$deleteURL}&amp;action=delete' style='color:" . (!empty($m->date_played) ? 'Red' : 'Blue') . ";'>" . $lng->getTrn('common/delete') . "</a>&nbsp;\n";
            echo "<a href='{$matchURL}&amp;action=" . ($m->locked ? 'unlock' : 'lock') . "'>" . ($m->locked ? $lng->getTrn('common/unlock') : $lng->getTrn('common/lock')) . "</a>&nbsp;\n";
            echo "<br><a href='javascript:void(0);' onClick='slideToggleFast(\"chRound\");'>" . $lng->getTrn('matches/report/chround') . "</a><div id='chRound' style='display:none;'>\n\t\t<form method='POST'>\n\t\t<select name='round'>";
            foreach ($T_ROUNDS as $id => $desc) {
                echo "<option value='{$id}'>" . $desc . "</option>\n";
            }
            echo "</select>\n\t\t<input type='submit' value='" . $lng->getTrn('matches/report/chround') . "'>\n\t\t</form>\n\t\t</div>";
            echo "</b></td></tr>";
        }
        ?>
    </table>
    <br>
    <?php 
        echo "<b><a TARGET='_blank' href='" . DOC_URL_GUIDE . "'>" . $lng->getTrn('common/needhelp') . "</a></b><br><br>";
        ?>
    <form method="POST" enctype="multipart/form-data">
        <table class="common">
            <tr class='commonhead'><td colspan="<?php 
        echo $CP;
        ?>
"><b><?php 
        echo $lng->getTrn('matches/report/info');
        ?>
</b></td></tr>
            <tr><td class='seperator' colspan='<?php 
        echo $CP;
        ?>
'></td></tr>
            <tr><td colspan='<?php 
        echo $CP;
        ?>
'>
                <b><?php 
        echo $lng->getTrn('matches/report/stadium');
        ?>
</b>&nbsp;
                <select name="stadium" <?php 
        echo $DIS;
        ?>
>
                    <?php 
        $stad = $m->stadium ? $m->stadium : $m->team1_id;
        foreach (array($team1, $team2) as $_t) {
            echo "<option value='{$_t->team_id}'" . ($stad == $_t->team_id ? 'SELECTED' : '') . ">{$_t->name}</option>\n";
        }
        ?>
                </select>
            </td></tr>
            <tr><td colspan='<?php 
        echo $CP;
        ?>
'>
                <b><?php 
        echo $lng->getTrn('common/gate');
        ?>
</b>&nbsp;
                <input type="text" name="gate" onChange='numError(this);' value="<?php 
        echo $m->gate ? $m->gate / 1000 : 0;
        ?>
" size="4" maxlength="4" <?php 
        echo $DIS;
        ?>
>k
            </td></tr>
            <tr><td colspan='<?php 
        echo $CP;
        ?>
'>
                <b><?php 
        echo $lng->getTrn('matches/report/fans');
        ?>
</b>&nbsp;
                <input type="text" name="fans" onChange='numError(this);' value="<?php 
        echo $m->fans;
        ?>
" size="7" maxlength="12" <?php 
        echo $DIS;
        ?>
>
            </td></tr>
            <?php 
        if (!$settings['hide_ES_extensions']) {
            ?>
                <tr><td colspan='<?php 
            echo $CP;
            ?>
'>
                    <b>E</b>xtra player <b>S</b>tats (ES) <a href="index.php?section=matches&amp;type=report&amp;mid=<?php 
            echo $m->match_id;
            ?>
&amp;es_report=1">report page here</a>
                </td></tr>
                <?php 
        }
        ?>
            <tr><td class="seperator" colspan='<?php 
        echo $CP;
        ?>
'></td></tr>
            <tr class='commonhead'>
                <td><b><?php 
        echo $lng->getTrn('common/teams');
        ?>
</b></td>
                <td><b><?php 
        echo $lng->getTrn('common/score');
        ?>
</b></td>
                <td><b>&Delta; <?php 
        echo $lng->getTrn('matches/report/treas');
        ?>
</b></td>
                <td><b><?php 
        echo $lng->getTrn('matches/report/ff');
        ?>
</b></td>
                <td><b><?php 
        echo $lng->getTrn('matches/report/smp');
        ?>
</b></td>
                <td><b><?php 
        echo $lng->getTrn('matches/report/tcas');
        ?>
</b></td>
                <td><b><?php 
        echo $lng->getTrn('matches/report/fame');
        ?>
</b></td>
                <td><b><?php 
        echo $lng->getTrn('matches/report/tv');
        ?>
</b></td>
            </tr>

            <tr><td class='seperator' colspan='<?php 
        echo $CP;
        ?>
'></td></tr>
            <?php 
        foreach (array(1, 2) as $N) {
            echo "<tr>\n";
            echo "<td>" . ${"teamUrl{$N}"} . "</td>\n";
            echo "<td><input type='text' onChange='numError(this);' name='result{$N}' value='" . (int) $m->{"team{$N}_score"} . "' size='1' maxlength='2' {$DIS}></td>\n";
            echo "<td><input type='text' onChange='numErrorAllowNegative(this);' name='inc{$N}' value='" . (int) $m->{"income{$N}"} / 1000 . "' size='4' maxlength='4' {$DIS}>k</td>\n";
            echo "<td>";
            foreach (array('1' => 'green', '0' => 'blue', '-1' => 'red') as $Nff => $color) {
                echo "<input {$DIS} type='radio' name='ff{$N}' value='{$Nff}' " . ($m->{"ffactor{$N}"} == (int) $Nff ? 'CHECKED' : '') . "><font color='{$color}'><b>{$Nff}</b></font>";
            }
            echo "</td>\n";
            echo "<td><input type='text' onChange='numError(this);' name='smp{$N}' value='" . $m->{"smp{$N}"} . "' size='1' maxlength='2' {$DIS}>" . $lng->getTrn('matches/report/pts') . "</td>\n";
            echo "<td><input type='text' onChange='numError(this);' name='tcas{$N}' value='" . $m->{"tcas{$N}"} . "' size='1' maxlength='2' {$DIS}></td>\n";
            echo "<td><input type='text' onChange='numError(this);' name='fame{$N}' value='" . $m->{"fame{$N}"} . "' size='1' maxlength='2' {$DIS}></td>\n";
            echo "<td><input type='text' onChange='numError(this);' name='tv{$N}' value='" . ($m->is_played ? $m->{"tv{$N}"} / 1000 : ${"team{$N}"}->value / 1000) . "' size='4' maxlength='10' {$DIS}>k</td>\n";
            echo "</tr>\n";
        }
        ?>
        </table>

        <?php 
        $playerFields = array_merge($T_MOUT_REL, $T_MOUT_ACH, $T_MOUT_IR, $T_MOUT_INJ);
        $CPP = count($playerFields);
        foreach (array(1 => $team1, 2 => $team2) as $id => $t) {
            ?>
            <table class='common'>
            <tr><td class='seperator' colspan='<?php 
            echo $CPP;
            ?>
'></td></tr>
            <tr class='commonhead'><td colspan='<?php 
            echo $CPP;
            ?>
'>
                <b><a href="<?php 
            echo urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $t->team_id, false, false);
            ?>
"><?php 
            echo $t->name;
            ?>
</a> <?php 
            echo $lng->getTrn('matches/report/report');
            ?>
</b>
            </td></tr>
            <tr><td class='seperator' colspan='<?php 
            echo $CPP;
            ?>
'></td></tr>
            <?php 
            echo "<tr>\n";
            foreach (array_values($playerFields) as $f) {
                // We need to translate table headers
                switch (strtolower(str_replace(' ', '', $f))) {
                    case 'name':
                        $header_text = $lng->getTrn('common/name');
                        break;
                    case 'mvp':
                        $header_text = $lng->getTrn('matches/report/mvp');
                        break;
                    case 'cp':
                        $header_text = $lng->getTrn('matches/report/cp');
                        break;
                    case 'bh':
                        $header_text = $lng->getTrn('matches/report/bh');
                        break;
                    case 'si':
                        $header_text = $lng->getTrn('matches/report/si');
                        break;
                    case 'ki':
                        $header_text = $lng->getTrn('matches/report/ki');
                        break;
                    case 'ir1d1':
                        $header_text = $lng->getTrn('matches/report/ir1') . " D1";
                        break;
                    case 'ir1d2':
                        $header_text = $lng->getTrn('matches/report/ir1') . " D2";
                        break;
                    case 'ir2d1':
                        $header_text = $lng->getTrn('matches/report/ir2') . " D1";
                        break;
                    case 'ir2d2':
                        $header_text = $lng->getTrn('matches/report/ir2') . " D2";
                        break;
                    case 'ir3d1':
                        $header_text = $lng->getTrn('matches/report/ir3') . " D1";
                        break;
                    case 'ir3d2':
                        $header_text = $lng->getTrn('matches/report/ir3') . " D2";
                        break;
                    case 'inj':
                        $header_text = $lng->getTrn('matches/report/inj');
                        break;
                    case 'ageing1':
                        $header_text = $lng->getTrn('matches/report/ageing1');
                        break;
                    case 'ageing2':
                        $header_text = $lng->getTrn('matches/report/ageing2');
                        break;
                    default:
                        $header_text = $f;
                }
                echo "<td><i>{$header_text}</i></td>\n";
            }
            echo "</tr>\n";
            $NORMSTAT = true;
            // only normal player statuses
            foreach ($t->getPlayers() as $p) {
                if (!self::player_validation($p, $m)) {
                    continue;
                }
                // Fetch player data from match
                $status = $p->getStatus($m->match_id);
                $mdat = $m->getPlayerEntry($p->player_id);
                // Print player row
                if ($p->is_journeyman_used && !$m->is_played) {
                    $bgcolor = COLOR_HTML_JOURNEY_USED;
                    $NORMSTAT = false;
                } elseif ($p->is_journeyman) {
                    $bgcolor = COLOR_HTML_JOURNEY;
                    $NORMSTAT = false;
                } elseif ($status == MNG) {
                    $bgcolor = COLOR_HTML_MNG;
                    $NORMSTAT = false;
                } elseif ($p->mayHaveNewSkill()) {
                    $bgcolor = COLOR_HTML_NEWSKILL;
                    $NORMSTAT = false;
                } else {
                    $bgcolor = false;
                }
                self::_print_player_row($p->player_id, '<a href="index.php?section=objhandler&type=1&obj=1&obj_id=' . $p->player_id . '">' . $p->name . '</a>', $p->nr, $lng->getTrn('position/' . strtolower($lng->FilterPosition($p->position))) . ($status == MNG ? '&nbsp;[MNG]' : ''), $bgcolor, $mdat, $DIS || $status == MNG);
            }
            echo "</table>\n";
            echo "<br>\n";
            if (!$NORMSTAT) {
                ?>
<table class="text"><tr><td style="width: 100%;"></td><?php 
                if (1) {
                    ?>
                    <td style="background-color: <?php 
                    echo COLOR_HTML_MNG;
                    ?>
;"><font color='black'><b>&nbsp;MNG&nbsp;</b></font></td>
                    <td style="background-color: <?php 
                    echo COLOR_HTML_JOURNEY;
                    ?>
;"><font color='black'><b>&nbsp;Journeyman&nbsp;</b></font></td>
                    <td style="background-color: <?php 
                    echo COLOR_HTML_JOURNEY_USED;
                    ?>
;"><font color='black'><b>&nbsp;Used&nbsp;journeyman&nbsp;</b></font></td>
                    <td style="background-color: <?php 
                    echo COLOR_HTML_NEWSKILL;
                    ?>
;"><font color='black'><b>&nbsp;New&nbsp;skill&nbsp;available&nbsp;</b></font></td>
                    <?php 
                }
                ?>
</tr></table><?php 
            }
            // Add raised zombies
            global $racesHasNecromancer;
            if (in_array($t->f_race_id, $racesHasNecromancer)) {
                echo "<hr style='width:200px;float:left;'><br>\n                <b>Raised zombie?:</b> <input type='checkbox' name='t{$id}zombie' value='1' onclick='slideToggleFast(\"t{$id}zombie\");'><br>\n";
                echo "<div id='t{$id}zombie' style='display:none;'>\n";
                echo "<table class='common'>\n";
                self::_print_player_row("t{$id}zombie", 'Raised zombie', '&mdash;', 'Zombie', false, array(), $DIS);
                echo "</table>\n";
                echo "</div>\n";
            }
            // Add raised rotters
            global $racesMayRaiseRotters;
            if (in_array($t->f_race_id, $racesMayRaiseRotters)) {
                $maxRotters = 6;
                # Note there is no real limit for raised rotters.
                echo "<hr style='width:200px;float:left;'><br>\n                <b>Raised rotters?:</b>\n                <select name='t{$id}rotterCnt' onChange='var i = this.options[this.selectedIndex].value; var j=1; for (j=1; j<={$maxRotters}; j++) {if (j<=i) {slideDownFast(\"t{$id}rotter\"+j);} else {slideUpFast(\"t{$id}rotter\"+j);}}' >";
                foreach (range(0, $maxRotters) as $n) {
                    echo "<option value='{$n}'>{$n}</option>";
                }
                echo "</select>\n";
                foreach (range(0, $maxRotters) as $n) {
                    echo "<div id='t{$id}rotter{$n}' style='display:none;'><table class='common'>\n";
                    self::_print_player_row("t{$id}rotter{$n}", "Raised Rotter #{$n}", '&mdash;', 'Rotter', false, array(), $DIS);
                    echo "</table></div>\n";
                }
            }
            ?>

            <table style='border-spacing: 0px 10px;'>
                <tr><td align="left" valign="top">
                    <b>Star Players</b>:
                    <input type='button' id="addStarsBtn_<?php 
            echo $id;
            ?>
" value="<?php 
            echo $lng->getTrn('common/add');
            ?>
"
                    onClick="stars = document.getElementById('stars_<?php 
            echo $id;
            ?>
'); addStarMerc(<?php 
            echo $id;
            ?>
, stars.options[stars.selectedIndex].value);" <?php 
            echo $DIS;
            ?>
>
                    <select id="stars_<?php 
            echo $id;
            ?>
" <?php 
            echo $DIS;
            ?>
>
                        <?php 
            foreach ($stars as $s => $d) {
                echo "<option " . (in_array($t->f_race_id, $d['races']) ? 'style="background-color: ' . COLOR_HTML_READY . ';"' : '') . " value='{$d['id']}'>{$s}</option>\n";
            }
            ?>
                    </select>
                </td></tr>
                <tr><td align="left" valign="top">
                    <b>Mercenaries</b>: <input type='button' id="addMercsBtn_<?php 
            echo $id;
            ?>
" value="<?php 
            echo $lng->getTrn('common/add');
            ?>
" onClick="addStarMerc(<?php 
            echo "{$id}, " . ID_MERCS;
            ?>
);" <?php 
            echo $DIS;
            ?>
>
                </td></tr>
            </table>

            <table class='common' id='<?php 
            echo "starsmercs_{$id}";
            ?>
'>
            </table>
            <?php 
        }
        ?>
        <table class='common'>
            <tr><td class='seperator' colspan='13'></td></tr>
            <tr class='commonhead'><td colspan='13'><b><?php 
        echo $lng->getTrn('matches/report/summary');
        ?>
</b></td></tr>
            <tr><td colspan='13'><textarea name='summary' rows='10' cols='100' <?php 
        echo $DIS . ">" . $m->getText();
        ?>
</textarea></td></tr>
        </table>
        <br>
        <center>
            <input type="submit" name='button' value="<?php 
        echo $lng->getTrn('common/save');
        ?>
" <?php 
        echo $DIS;
        ?>
>
            <?php 
        if ($USED_JOURNEYMAN_PRESENT) {
            echo "<br><br><b>" . $lng->getTrn('matches/report/usedjourney') . "</b>";
        }
        ?>
        </center>
    </form>
    <br><br>
    <?php 
        /*
            Now, we call javascript routine(s) to fill out stars and mercs rows, if such entries exist in database.
        */
        $i = 0;
        // Counter. Used to pass PHP-data to Javascript.
        foreach (array(1 => $team1->team_id, 2 => $team2->team_id) as $id => $t) {
            foreach (Star::getStars(STATS_TEAM, $t, STATS_MATCH, $m->match_id) as $s) {
                echo "<script language='JavaScript' type='text/javascript'>\n";
                echo "var mdat{$i} = [];\n";
                $mdat = $s->getStats(T_NODE_MATCH, $m->match_id);
                foreach (array_keys($T_MOUT_ACH) as $f) {
                    echo "mdat{$i}['{$f}'] = " . $mdat[$f] . ";\n";
                }
                echo "existingStarMerc({$id}, {$s->star_id}, mdat{$i});\n";
                echo "</script>\n";
                $i++;
            }
            foreach (Mercenary::getMercsHiredByTeam($t, $m->match_id) as $merc) {
                echo "<script language='JavaScript' type='text/javascript'>\n";
                echo "var mdat{$i} = [];\n";
                foreach (array_merge(array_keys($T_MOUT_ACH), array('skills')) as $f) {
                    echo "mdat{$i}['{$f}'] = " . $merc->{$f} . ";\n";
                }
                echo "existingStarMerc({$id}, " . ID_MERCS . ", mdat{$i});\n";
                echo "</script>\n";
                $i++;
            }
        }
    }
Example #3
0
                     if (rs.options[i].value == tdata[trid]["rs"]){
                        rs.selectedIndex = i;
                        break;
                     }
                }
                var types = document.getElementById("tourtype").parentNode; // Must access radio objects in the way
                var TT_FFA = ' . TT_FFA . ';
                var is_FFA = (TT_FFA == tdata[trid]["type"]);
                types.tourtype[0].checked = is_FFA;
                types.tourtype[1].checked = !is_FFA;
                document.getElementById("locked").checked = tdata[trid]["locked"] == 0 ? false : true;
                document.getElementById("allow_sched").checked = tdata[trid]["allow_sched"] == 0 ? false : true;
            }
            </script>';
    list(, , $tdata) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, null, array(T_NODE_TOURNAMENT => array('rs' => 'rs', 'type' => 'type', 'locked' => 'locked', 'allow_sched' => 'allow_sched')));
    $easyconvert = new array_to_js();
    @$easyconvert->add_array($tdata, 'tdata');
    echo $easyconvert->output_all();
    echo HTMLOUT::nodeList(T_NODE_TOURNAMENT, 'trid', array('OTHER' => array('ring' => Coach::T_RING_LOCAL_ADMIN)), array(), array('extra_tags' => array('onChange="adminModTour(this.options[this.selectedIndex].value);"'), 'empty_str' => array(T_NODE_DIVISION => '')));
    ?>
            <br><br>
            Name<br>
            <input type="text" id='name' name="name"><br><br>
            Ranking system &mdash; <?php 
    echo $lng->getTrn('admin/prefixes');
    ?>
<br>
            <select id='rs' name='rs'>
            <?php 
    global $hrs;
    foreach ($hrs as $idx => $r) {