Esempio n. 1
0
<?php

require "header.php";
if (!Coach::isLoggedIn()) {
    die("You must be logged into OBBLM to use this webservice.");
}
$action = $_REQUEST["action"];
if ($action == "update") {
    $match = new Match($_POST["match_id"]);
    $match->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));
    $team = new Team($_POST["team_id"]);
    foreach ($team->getPlayers() as $player) {
        if (!Match::player_validation($player, $match)) {
            continue;
        }
        // We create zero entries for MNG player(s). This is required!
        $pid = $player->player_id;
        if ($player->getStatus($match->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;
Esempio n. 2
0
 public static function main($argv)
 {
     global $pdf;
     global $DEA;
     global $skillarray;
     global $rules;
     global $lng;
     global $inducements;
     $FILLED = false;
     if (!empty($argv)) {
         $team1 = new Team($argv[0]);
         $team2 = new Team($argv[1]);
         $match = new Match($argv[2]);
         if (!is_null($team1) && !is_null($team2)) {
             $FILLED = true;
         }
     } else {
         $team1 = null;
         $team2 = null;
         $match = null;
     }
     define("MARGINX", 20);
     define("MARGINY", 20);
     define("DEFLINECOLOR", '#000000');
     define("HEADLINEBGCOLOR", '#c3c3c3');
     // Custom settings for inducements.
     define('MAX_STARS', 2);
     define('MERC_EXTRA_COST', 30000);
     define('MERC_EXTRA_SKILL_COST', 50000);
     // Color codes.
     define('COLOR_ROSTER_NORMAL', COLOR_HTML_NORMAL);
     define('COLOR_ROSTER_READY', COLOR_HTML_READY);
     define('COLOR_ROSTER_MNG', COLOR_HTML_MNG);
     define('COLOR_ROSTER_DEAD', COLOR_HTML_DEAD);
     define('COLOR_ROSTER_SOLD', COLOR_HTML_SOLD);
     define('COLOR_ROSTER_STARMERC', COLOR_HTML_STARMERC);
     define('COLOR_ROSTER_JOURNEY', COLOR_HTML_JOURNEY);
     define('COLOR_ROSTER_JOURNEY_USED', COLOR_HTML_JOURNEY_USED);
     define('COLOR_ROSTER_NEWSKILL', COLOR_HTML_NEWSKILL);
     //-----
     define('COLOR_ROSTER_CHR_EQP1', COLOR_HTML_CHR_EQP1);
     // Characteristic equal plus one.
     define('COLOR_ROSTER_CHR_GTP1', COLOR_HTML_CHR_GTP1);
     // Characteristic greater than plus one.
     define('COLOR_ROSTER_CHR_EQM1', COLOR_HTML_CHR_EQM1);
     // Characteristic equal minus one.
     define('COLOR_ROSTER_CHR_LTM1', COLOR_HTML_CHR_LTM1);
     // Characteristic less than minus one.
     define('T_PDF_ROSTER_SET_EMPTY_ON_ZERO', true);
     # Prints cp, td etc. as '' (empty string) when field = 0.
     $ind_cost = 0;
     $pdf = new BB_PDF('L', 'pt', 'A4');
     // Creating a new PDF doc. landscape, scale=pixels, size A4
     $pdf->SetAutoPageBreak(false, 20);
     // No auto page break to mess up layout
     $pdf->SetAuthor('Daniel Straalman, Daniel Henriksson, Nicholas Rathmann');
     $pdf->SetCreator('OBBLM');
     $pdf->SetTitle($lng->getTrn('name', 'PDFMatchReport'));
     $pdf->SetSubject($lng->getTrn('name', 'PDFMatchReport'));
     $pdf->AddFont('Tahoma', '', 'tahoma.php');
     // Adding regular font Tahoma which is in font dir
     $pdf->AddFont('Tahoma', 'B', 'tahomabd.php');
     // Adding Tahoma Bold
     // Initial settings
     $pdf->SetFont('Tahoma', 'B', 8);
     $pdf->AddPage();
     $pdf->SetLineWidth(1.5);
     $currentx = MARGINX - 10;
     $currenty = MARGINY + 6;
     //Real PDF fill starts here
     $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
     #        $pdf->RoundedRect($currentx, $currenty, 542, 20, 6, 'DF'); // Filled rectangle around Team headline
     $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
     // Text in headline
     $pdf->SetXY($currentx + 130, $currenty);
     $pdf->SetFont('Tahoma', 'B', 18);
     $pdf->Cell(360, 20, 'OBBLM Match Report', 0, 0, 'R', false, '');
     // make a call to get the league Name instead of hardcoded
     //Printing game info rounded box
     $currenty += 5;
     $pdf->SetFillColorBB($pdf->hex2cmyk('#c6c6c6'));
     $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
     $pdf->SetFontSize(1);
     $pdf->SetLineWidth(0.6);
     #$pdf->RoundedRect($currentx, $currenty, 542, 80, 5, 'D');
     //Score boxes
     $pdf->SetLineWidth(0.4);
     $scoreboxOffset = 20;
     #        $pdf->RoundedRect($currentx + 15, $currenty + $scoreboxOffset, 50, 50, 5, 'D');
     #        $pdf->RoundedRect($currentx + 475, $currenty + $scoreboxOffset, 50, 50, 5, 'D');
     if ($FILLED) {
         $img1 = new ImageSubSys(IMGTYPE_TEAMLOGO, $team1->team_id);
         $img2 = new ImageSubSys(IMGTYPE_TEAMLOGO, $team2->team_id);
         $pdf->Image($img1->getPath(), $currentx + 10, $currenty + $scoreboxOffset, 60, 60, '', '', false, 0);
         $pdf->Image($img2->getPath(), $currentx + 720, $currenty + $scoreboxOffset, 60, 60, '', '', false, 0);
     }
     $currentx += 190;
     $currenty += 15;
     $pdf->SetXY($currentx, $currenty);
     $pdf->SetFont('Tahoma', 'B', 12);
     $noname = '__________________';
     $norace = '__________________';
     $pdf->Cell(390, 50, (!$FILLED ? $noname : $team1->name) . ' - ' . (!$FILLED ? $noname : $team2->name), 0, 0, 'C', false, '');
     $currenty += 15;
     $pdf->SetXY($currentx, $currenty);
     $pdf->SetFont('Tahoma', '', 10);
     $pdf->Cell(390, 50, (!$FILLED ? $norace : $team1->f_rname) . ' - ' . (!$FILLED ? $norace : $team2->f_rname), 0, 0, 'C', false, '');
     // Gate + score text
     $pdf->SetFont('Tahoma', '', 10);
     $space = '        ';
     $currenty += 26;
     $pdf->SetXY($currentx, $currenty);
     $pdf->Cell(210, 50, "Score:       -", 0, 0, 'R', false, '');
     $currenty += 10;
     $pdf->SetXY($currentx, $currenty);
     $pdf->Cell(210, 50, "Gate:{$space}k", 0, 0, 'R', false, '');
     //Printing headers for player rows. Do all this twice
     $smallFieldSize = 25;
     $mediumFieldSize = 90;
     $nameFieldSize = 100;
     $skillFieldSize = 350;
     //Print two team boxes
     $currenty += 5;
     $i = 0;
     while ($i < 2) {
         $i++;
         $currenty += 15;
         $currentx = MARGINX + 6;
         $pdf->SetXY($currentx, $currenty);
         $pdf->SetFillColorBB($pdf->hex2cmyk('#c6c6c6'));
         $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
         $pdf->SetFontSize(1);
         $pdf->SetLineWidth(0.6);
         #$pdf->RoundedRect($currentx, $currenty, 542, 315, 5, 'D');
         $currenty += $scoreboxOffset;
         $currentx += 15;
         $pdf->SetXY($currentx, $currenty);
         $currentx += 25;
         $pdf->SetXY($currentx, $currenty);
         $h = 5;
         $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
         $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
         $pdf->SetFont('Tahoma', 'B', 6);
         $pdf->setLineWidth(1.5);
         // Printing headline for team table
         $pdf->Cell(50, $h, 'Winnings', 1, 0, 'L', true, '');
         $pdf->Cell(60, $h, 'Fan Factor', 1, 0, 'C', true, '');
         $pdf->Cell(70, $h, 'Total team CAS', 1, 0, 'C', true, '');
         $pdf->Cell(35, $h, 'FAME', 1, 0, 'C', true, '');
         if (1 && $FILLED) {
             $pdf->SetFont('Tahoma', 'B', 7);
             $pdf->Cell(150, $h, '   ' . ${"team{$i}"}->name, 0, 0, 'L', false, '');
         }
         $currenty += 5;
         $pdf->SetXY($currentx, $currenty);
         $h = 15;
         // Row/cell height for team table row
         $pdf->SetFillColorBB($pdf->hex2cmyk('#FFFFFF'));
         $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
         $pdf->SetFontSize(1);
         $pdf->SetLineWidth(0.6);
         //Team table row
         $pdf->Cell(50, $h, '', 1, 0, 'L', true, '');
         //Fan factor box
         $pdf->SetFont('Tahoma', '', 6);
         $boxx = $currentx + 50;
         $boxy = $currenty;
         $pdf->SetXY($boxx += 4, $boxy += 5);
         $pdf->Rect($boxx, $boxy, 5, 5, 'DF');
         $pdf->SetXY($boxx += 5, $boxy -= 1);
         $pdf->Cell(20, 8, '+1', 0, 0, 'L', false);
         $pdf->SetXY($boxx += 16, $boxy += 1);
         $pdf->Rect($boxx, $boxy, 5, 5, 'DF');
         $pdf->SetXY($boxx += 5, $boxy -= 1);
         $pdf->Cell(20, 8, '0', 0, 0, 'L', false);
         $pdf->SetXY($boxx += 12, $boxy += 1);
         $pdf->Rect($boxx, $boxy, 5, 5, 'DF');
         $pdf->SetXY($boxx += 5, $boxy -= 1);
         $pdf->Cell(20, 8, '-1', 0, 0, 'L', false);
         //Total team cas, FAME
         $pdf->SetXY($currentx + 110, $currenty);
         $pdf->Cell(70, $h, '', 1, 0, 'C', true, '');
         $pdf->Cell(35, $h, '', 1, 0, 'C', true, '');
         if (1 && $FILLED) {
             $t = ${"team{$i}"};
             $pdf->SetFont('Tahoma', '', 7);
             $statsstr = sprintf('TV: %uk - ReRolls: %u - Apocthecary: %u - Fan Factor: %u - Assistant Coaches: %u - Cheerleaders: %u - Played: %u - Win pct.: %1.0f - ELO: %1.0f - CAS inflicted: %u', $t->tv / 1000, $t->rerolls, $t->apothecary, $t->rg_ff, $t->ass_coaches, $t->cheerleaders, $t->mv_played, $t->rg_win_pct, $t->rg_elo, $t->mv_cas);
             $pdf->Cell(250, $h, '    ' . $statsstr, 0, 0, 'L', false, '');
         }
         $currenty += $h + 5;
         $pdf->SetXY($currentx - 20, $currenty);
         //Headers for player table
         $h = 10;
         $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
         $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
         $pdf->SetFont('Tahoma', 'B', 8);
         $pdf->setLineWidth(1.5);
         // Printing headline for player table
         $pdf->Cell($smallFieldSize, $h, 'Nr', 1, 0, 'C', true, '');
         $pdf->Cell($mediumFieldSize, $h, 'Position', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'MA', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'ST', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'AG', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'AV', 1, 0, 'C', true, '');
         $pdf->Cell($skillFieldSize, $h, 'Skills', 1, 0, 'L', true, '');
         $pdf->Cell($smallFieldSize, $h, 'SPP', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'MVP', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Cp', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Td', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Int', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'BH', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'SI', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Ki', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Inj', 1, 0, 'C', true, '');
         $currenty += 13;
         $pdf->SetXY($currentx - 20, $currenty);
         $pdf->SetFont('Tahoma', '', 6);
         $h = 10;
         // Row/cell height for player table
         $pdf->SetFillColorBB($pdf->hex2cmyk('#FFFFFF'));
         $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
         $pdf->SetFontSize(8);
         $pdf->SetLineWidth(0.6);
         // Printing player rows
         $tmp_players = array();
         if ($FILLED) {
             $players = ${"team{$i}"}->getPlayers();
             foreach ($players as $p) {
                 if (!Match::player_validation($p, $match)) {
                     continue;
                 }
                 array_push($tmp_players, $p);
             }
         }
         $players = $tmp_players;
         $j = 0;
         while ($j < 16) {
             $j++;
             $nr = '';
             //reset all strings to clear
             $pos = '';
             $ma = '';
             $st = '';
             $ag = '';
             $av = '';
             $skills_injuries = '';
             $skillfn = '';
             $spp = '';
             $bgc = COLOR_ROSTER_NORMAL;
             if (count($players) >= $j) {
                 $p = $players[$j - 1];
                 $name = $p->name;
                 $pos = $p->position;
                 //Get position
                 $bgc = COLOR_ROSTER_NORMAL;
                 if ($p->is_journeyman) {
                     $name = "{$p->name} [J]";
                     $bgc = COLOR_ROSTER_JOURNEY;
                 }
                 if ($p->is_journeyman_used) {
                     $name = "{$p->name} [J]";
                     $bgc = COLOR_ROSTER_JOURNEY_USED;
                 }
                 if ($p->is_mng) {
                     $name = "{$p->name} [MNG]";
                     $bgc = COLOR_ROSTER_MNG;
                 }
                 if ($p->mayHaveNewSkill()) {
                     $name = "{$p->name}";
                     $bgc = COLOR_ROSTER_NEWSKILL;
                 }
                 $nr = $p->nr;
                 $ma = $p->ma;
                 $st = $p->st;
                 $ag = $p->ag;
                 $av = $p->av;
                 //  Get skills and injuries
                 $skillstr = $p->getSkillsStr(false);
                 $injstr = $p->getInjsStr(false);
                 if ($skillstr == '') {
                     // No skills
                     if ($injstr != '') {
                         $skills_injuries = $injstr;
                     } else {
                         $skills_injuries = '';
                     }
                     // No skills nor injuries
                 } else {
                     if ($injstr != '') {
                         $skills_injuries = $skillstr . ', ' . $injstr;
                     } else {
                         $skills_injuries = $skillstr;
                     }
                     // Only skills, no injuries
                 }
                 $spp = $p->mv_spp;
                 //Current Star Player Points
             }
             $pdf->SetFillColorBB($pdf->hex2cmyk($bgc));
             $pdf->Cell($smallFieldSize, $h, $nr, 1, 0, 'C', true, '');
             $pdf->Cell($mediumFieldSize, $h, $pos, 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, $ma, 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, $st, 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, $ag, 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, $av, 1, 0, 'C', true, '');
             $pdf->Cell($skillFieldSize, $h, $skills_injuries, 1, 0, 'L', true, '');
             $pdf->Cell($smallFieldSize, $h, $spp, 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $currenty += $h;
             $pdf->SetXY($currentx - 20, $currenty);
         }
         // Color legends
         $pdf->SetFont('Tahoma', '', 7);
         $currentx = 335;
         $currenty += 5;
         $dd = 2;
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_MNG));
         $pdf->SetXY($currentx, $currenty);
         $pdf->Rect($currentx, $currenty, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(20, 8, 'MNG', 0, 0, 'L', false);
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_JOURNEY));
         $pdf->Rect($currentx += 22 + $dd, $currenty += 1, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(45, 8, 'Journeyman', 0, 0, 'L', false);
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_JOURNEY_USED));
         $pdf->Rect($currentx += 47 + $dd, $currenty += 1, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(45, 8, 'Used journeyman', 0, 0, 'L', false);
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_NEWSKILL));
         $pdf->Rect($currentx += 64 + $dd, $currenty += 1, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(70, 8, 'New skill available', 0, 0, 'L', false);
     }
     // Output the PDF document
     $pdf->Output("Match Report.pdf", 'I');
 }
Esempio n. 3
0
 function matchEntry($team_id, $teamPlayers)
 {
     $addZombie = false;
     $match = new Match($this->match_id);
     $team = new Team($team_id);
     $players = $team->getPlayers();
     $merc_nr = 1;
     foreach ($teamPlayers as $player) {
         $f_player_id = '';
         if ($player['nr'] == 100) {
             $addZombie = true;
         } else {
             $addZombie = false;
         }
         if ($player['star'] == "true") {
             global $stars;
             $stname = strval($player['name']);
             if (strpos($stname, "Morg ") === 0) {
                 $stname = "Morg 'n' Thorg";
             }
             if (strpos($stname, "Brick Far") === 0) {
                 $stname = "Brick Far'th (+ Grotty)";
             }
             if ($stname == "Grotty") {
                 $stname = "Grotty (included in Brick Far'th)";
             }
             $f_player_id = $stars[$stname]['id'];
             $player['inj'] = '';
         }
         if ($player['merc'] == "true") {
             $f_player_id = ID_MERCS;
         }
         foreach ($players as $p) {
             if ($p->nr == $player['nr'] && Match::player_validation($p, $match) && !$f_player_id) {
                 $f_player_id = $p->player_id;
                 break;
             }
         }
         // Make $player[$f] into $$f.
         foreach (array('mvp', 'cp', 'td', 'intcpt', 'bh', 'ki', 'si') as $f) {
             if (array_key_exists($f, $player)) {
                 ${$f} = $player[$f];
                 # NOTE: These fields are validated and typecasted correctly already in parse_results(), no further processing needed.
                 if (empty(${$f})) {
                     ${$f} = 0;
                 }
             } else {
                 ${$f} = 0;
             }
         }
         $inj = $this->switchInjury($player['inj']);
         $agn1 = $this->switchInjury($player['agn1']);
         if ($agn1 > $inj) {
             list($inj, $agn1) = array($agn1, $inj);
         }
         if ($agn1 == 8 || $agn1 == 2) {
             $agn1 = 1;
         }
         if ($f_player_id == ID_MERCS) {
             $match->entry($f_player_id, $input = array('f_team_id' => $team_id, "mvp" => $mvp, "cp" => $cp, "td" => $td, "intcpt" => $intcpt, "bh" => $bh, "si" => $si, "ki" => $ki, "ir1_d1" => $player['ir1_d1'], "ir1_d2" => $player['ir1_d2'], "ir2_d1" => $player['ir2_d1'], "ir2_d2" => $player['ir2_d2'], "ir3_d1" => $player['ir3_d1'], "ir3_d2" => $player['ir3_d2'], "inj" => $inj, "agn1" => NONE, "agn2" => $agn1, "skills" => 0, "nr" => $merc_nr), $player['EPS']);
             $merc_nr++;
             continue;
         }
         if (!$addZombie && (Match::player_validation($p, $match) || $player['star'] == "true")) {
             $match->entry($f_player_id, $input = array('f_team_id' => $team_id, "mvp" => $mvp, "cp" => $cp, "td" => $td, "intcpt" => $intcpt, "bh" => $bh, "si" => $si, "ki" => $ki, "ir1_d1" => $player['ir1_d1'], "ir1_d2" => $player['ir1_d2'], "ir2_d1" => $player['ir2_d1'], "ir2_d2" => $player['ir2_d2'], "ir3_d1" => $player['ir3_d1'], "ir3_d2" => $player['ir3_d2'], "inj" => $inj, "agn1" => $agn1, "agn2" => NONE), $player['EPS']);
         } else {
             global $DEA;
             $pos_id = $DEA[$team->f_rname]['players']['Zombie']['pos_id'];
             list($exitStatus, $pid) = Player::create($input = array('nr' => $player['nr'], 'f_pos_id' => $pos_id, 'team_id' => $team_id, 'name' => $player['name']), $opts = array('free' => true, 'force' => true));
             if ($exitStatus == Player::T_CREATE_SUCCESS) {
                 $match->entry($pid, $input = array('f_team_id' => $team_id, "mvp" => $mvp, "cp" => $cp, "td" => $td, "intcpt" => $intcpt, "bh" => $bh, "si" => $si, "ki" => $ki, "ir1_d1" => $player['ir1_d1'], "ir1_d2" => $player['ir1_d2'], "ir2_d1" => $player['ir2_d1'], "ir2_d2" => $player['ir2_d2'], "ir3_d1" => $player['ir3_d1'], "ir3_d2" => $player['ir3_d2'], "inj" => $inj, "agn1" => $agn1, "agn2" => NONE), $player['EPS']);
             }
         }
     }
     ##ADD EMPTY RESULTS FOR PLAYERS WITHOUT RESULTS MAINLY FOR MNG
     foreach ($players as $p) {
         if (Match::player_validation($p, $match)) {
             $player = new Player($p->player_id);
             $p_matchdata = $match->getPlayerEntry($player->player_id);
             if (empty($p_matchdata)) {
                 $match->entry($p->player_id, $input = array('f_team_id' => $team_id, "mvp" => 0, "cp" => 0, "td" => 0, "intcpt" => 0, "bh" => 0, "si" => 0, "ki" => 0, "ir1_d1" => 0, "ir1_d2" => 0, "ir2_d1" => 0, "ir2_d2" => 0, "ir3_d1" => 0, "ir3_d2" => 0, "inj" => NONE, "agn1" => NONE, "agn2" => NONE), array());
             }
         }
     }
     return true;
 }
Esempio n. 4
0
 /**
  * Called by Module::run, renders the actual PDF
  */
 public static function main($argv)
 {
     global $pdf;
     global $DEA;
     global $skillarray;
     global $rules;
     global $lng;
     global $inducements;
     $FILLED = false;
     if (!empty($argv)) {
         $team1 = new Team($argv[0]);
         $team2 = new Team($argv[1]);
         $match = new Match($argv[2]);
         if (!is_null($team1) && !is_null($team2)) {
             $FILLED = true;
         }
     } else {
         $team1 = null;
         $team2 = null;
         $match = null;
     }
     define("MARGINX", 20);
     define("MARGINY", 20);
     define("DEFLINECOLOR", '#000000');
     define("HEADLINEBGCOLOR", '#c3c3c3');
     # player statuses
     define('COLOR_ROSTER_NORMAL', COLOR_HTML_NORMAL);
     define('COLOR_ROSTER_READY', COLOR_HTML_READY);
     define('COLOR_ROSTER_MNG', COLOR_HTML_MNG);
     define('COLOR_ROSTER_DEAD', COLOR_HTML_DEAD);
     define('COLOR_ROSTER_SOLD', COLOR_HTML_SOLD);
     define('COLOR_ROSTER_STARMERC', COLOR_HTML_STARMERC);
     define('COLOR_ROSTER_JOURNEY', COLOR_HTML_JOURNEY);
     define('COLOR_ROSTER_JOURNEY_USED', COLOR_HTML_JOURNEY_USED);
     define('COLOR_ROSTER_NEWSKILL', COLOR_HTML_NEWSKILL);
     define('T_PDF_ROSTER_SET_EMPTY_ON_ZERO', true);
     # Prints cp, td etc. as '' (empty string) when field = 0.
     $pdf = new BB_PDF('P', 'pt', 'A4');
     // Creating a new PDF doc. Portrait, scale=pixels, size A4
     $pdf->SetAutoPageBreak(false, 20);
     // No auto page break to mess up layout
     $pdf->SetAuthor('Daniel Straalman, Daniel Henriksson, Nicholas Rathmann');
     $pdf->SetCreator('OBBLM');
     $pdf->SetTitle($lng->getTrn('name', 'PDFMatchReport'));
     $pdf->SetSubject($lng->getTrn('name', 'PDFMatchReport'));
     $pdf->AddFont('Tahoma', '', 'tahoma.php');
     // Adding regular font Tahoma which is in font dir
     $pdf->AddFont('Tahoma', 'B', 'tahomabd.php');
     // Adding Tahoma Bold
     // Initial settings
     $pdf->SetFont('Tahoma', 'B', 14);
     $pdf->AddPage();
     $pdf->SetLineWidth(1.5);
     $currentx = MARGINX + 6;
     $currenty = MARGINY + 6;
     //Real PDF fill starts here
     $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
     #        $pdf->RoundedRect($currentx, $currenty, 542, 20, 6, 'DF'); // Filled rectangle around Team headline
     $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
     // Text in headline
     $pdf->SetXY($currentx + 30, $currenty);
     $pdf->SetFont('Tahoma', 'B', 22);
     $pdf->Cell(360, 20, 'OBBLM Match Report', 0, 0, 'R', false, '');
     //Printing game info rounded box
     $currenty += 5;
     $pdf->SetFillColorBB($pdf->hex2cmyk('#c6c6c6'));
     $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
     $pdf->SetFontSize(1);
     $pdf->SetLineWidth(0.6);
     #$pdf->RoundedRect($currentx, $currenty, 542, 80, 5, 'D');
     //Score boxes
     $pdf->SetLineWidth(0.4);
     $scoreboxOffset = 20;
     #        $pdf->RoundedRect($currentx + 15, $currenty + $scoreboxOffset, 50, 50, 5, 'D');
     #        $pdf->RoundedRect($currentx + 475, $currenty + $scoreboxOffset, 50, 50, 5, 'D');
     if ($FILLED) {
         $img1 = new ImageSubSys(IMGTYPE_TEAMLOGO, $team1->team_id);
         $img2 = new ImageSubSys(IMGTYPE_TEAMLOGO, $team2->team_id);
         $pdf->Image($img1->getPath(), $currentx - 10, $currenty + $scoreboxOffset, 60, 60, '', '', false, 0);
         $pdf->Image($img2->getPath(), $currentx + 495, $currenty + $scoreboxOffset, 60, 60, '', '', false, 0);
     }
     //VS text
     $currentx += 80;
     $currenty += 15;
     $pdf->SetXY($currentx, $currenty);
     $pdf->SetFont('Tahoma', '', 16);
     $noname = '__________________';
     $pdf->Cell(390, 50, (!$FILLED ? $noname : $team1->name) . ' - ' . (!$FILLED ? $noname : $team2->name), 0, 0, 'C', false, '');
     // Gate + score text
     $pdf->SetFont('Tahoma', '', 11);
     $space = '        ';
     $currenty += 26;
     $pdf->SetXY($currentx, $currenty);
     $pdf->Cell(210, 50, "Score:       -", 0, 0, 'R', false, '');
     $currenty += 18;
     $pdf->SetXY($currentx, $currenty);
     $pdf->Cell(210, 50, "Gate:{$space}k", 0, 0, 'R', false, '');
     //Printing headers for player rows. Do all this twice
     $smallFieldSize = 25;
     $mediumFieldSize = 40;
     $nameFieldSize = 140;
     //Print two team boxes
     $currenty += 25;
     $i = 0;
     while ($i < 2) {
         $i++;
         $currenty += 5;
         $currentx = MARGINX + 6;
         $pdf->SetXY($currentx, $currenty);
         $pdf->SetFillColorBB($pdf->hex2cmyk('#c6c6c6'));
         $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
         $pdf->SetFontSize(1);
         $pdf->SetLineWidth(0.6);
         #$pdf->RoundedRect($currentx, $currenty, 542, 315, 5, 'D');
         $currenty += $scoreboxOffset;
         $currentx += 15;
         $pdf->SetXY($currentx, $currenty);
         //Print Home / Away Images
         if ($i == 1) {
             $pdf->Image('modules/pdfmatchreport/home.png', $currentx - 10, $currenty + 90, 40, 163, '', '', false, 0);
         } else {
             $pdf->Image('modules/pdfmatchreport/away.png', $currentx - 10, $currenty + 90, 40, 161, '', '', false, 0);
         }
         $currentx += 45;
         $pdf->SetXY($currentx, $currenty);
         $h = 20;
         $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
         $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
         $pdf->SetFont('Tahoma', 'B', 8);
         $pdf->setLineWidth(1.5);
         // Printing headline for team table
         $pdf->Cell(50, $h, 'Winnings', 1, 0, 'L', true, '');
         $pdf->Cell(60, $h, 'Fan Factor', 1, 0, 'C', true, '');
         $pdf->Cell(70, $h, 'Total team CAS', 1, 0, 'C', true, '');
         $pdf->Cell(35, $h, 'FAME', 1, 0, 'C', true, '');
         if (1 && $FILLED) {
             $pdf->SetFont('Tahoma', 'B', 11);
             $pdf->Cell(150, $h, '   ' . ${"team{$i}"}->name, 0, 0, 'L', false, '');
         }
         $currenty += 23;
         $pdf->SetXY($currentx, $currenty);
         $h = 15;
         // Row/cell height for team table row
         $pdf->SetFillColorBB($pdf->hex2cmyk('#FFFFFF'));
         $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
         $pdf->SetFontSize(1);
         $pdf->SetLineWidth(0.6);
         //Team table row
         $pdf->Cell(50, $h, '', 1, 0, 'L', true, '');
         //Fan factor box
         $pdf->SetFont('Tahoma', '', 8);
         $boxx = $currentx + 50;
         $boxy = $currenty;
         $pdf->SetXY($boxx += 4, $boxy += 5);
         $pdf->Rect($boxx, $boxy, 5, 5, 'DF');
         $pdf->SetXY($boxx += 5, $boxy -= 1);
         $pdf->Cell(20, 8, '+1', 0, 0, 'L', false);
         $pdf->SetXY($boxx += 16, $boxy += 1);
         $pdf->Rect($boxx, $boxy, 5, 5, 'DF');
         $pdf->SetXY($boxx += 5, $boxy -= 1);
         $pdf->Cell(20, 8, '0', 0, 0, 'L', false);
         $pdf->SetXY($boxx += 12, $boxy += 1);
         $pdf->Rect($boxx, $boxy, 5, 5, 'DF');
         $pdf->SetXY($boxx += 5, $boxy -= 1);
         $pdf->Cell(20, 8, '-1', 0, 0, 'L', false);
         //Total team cas, FAME
         $pdf->SetXY($currentx + 110, $currenty);
         $pdf->Cell(70, $h, '', 1, 0, 'C', true, '');
         $pdf->Cell(35, $h, '', 1, 0, 'C', true, '');
         if (1 && $FILLED) {
             $t = ${"team{$i}"};
             $pdf->SetFont('Tahoma', '', 8);
             $statsstr = sprintf('TV: %uk  -  Played: %u  -  Win pct.: %1.0f  -  ELO: %1.0f  -  CAS inflicted: %u', $t->tv / 1000, $t->mv_played, $t->rg_win_pct, $t->rg_elo, $t->mv_cas);
             #                    $statsstr = sprintf('TV: %uk', $t->tv/1000);
             $pdf->Cell(250, $h, '    ' . $statsstr, 0, 0, 'L', false, '');
         }
         $currenty += $h + 10;
         $pdf->SetXY($currentx, $currenty);
         //Headers for player table
         $h = 20;
         $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
         $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
         $pdf->SetFont('Tahoma', 'B', 8);
         $pdf->setLineWidth(1.5);
         // Printing headline for player table
         $pdf->Cell($smallFieldSize, $h, 'Nr', 1, 0, 'C', true, '');
         $pdf->Cell($nameFieldSize, $h, 'Name', 1, 0, 'L', true, '');
         $pdf->Cell($smallFieldSize, $h, 'MVP', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Cp', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Td', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Int', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'BH', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'SI', 1, 0, 'C', true, '');
         $pdf->Cell($smallFieldSize, $h, 'Ki', 1, 0, 'C', true, '');
         $pdf->Cell($mediumFieldSize, $h, 'IR D1', 1, 0, 'C', true, '');
         $pdf->Cell($mediumFieldSize, $h, 'IR D2', 1, 0, 'C', true, '');
         $pdf->Cell($mediumFieldSize, $h, 'Inj', 1, 0, 'C', true, '');
         $currenty += 23;
         $pdf->SetXY($currentx, $currenty);
         $pdf->SetFont('Tahoma', '', 8);
         $h = 15;
         // Row/cell height for player table
         $pdf->SetFillColorBB($pdf->hex2cmyk('#FFFFFF'));
         $pdf->SetDrawColorBB($pdf->hex2cmyk('#000000'));
         $pdf->SetFontSize(10);
         $pdf->SetLineWidth(0.6);
         // Printing player rows
         $tmp_players = array();
         if ($FILLED) {
             $players = ${"team{$i}"}->getPlayers();
             foreach ($players as $p) {
                 if (!Match::player_validation($p, $match)) {
                     continue;
                 }
                 array_push($tmp_players, $p);
             }
         }
         $players = $tmp_players;
         $j = 0;
         while ($j < 16) {
             $j++;
             $nr = '';
             $name = '';
             $bgc = COLOR_ROSTER_NORMAL;
             if (count($players) >= $j) {
                 $p = $players[$j - 1];
                 $name = $p->name;
                 $bgc = COLOR_ROSTER_NORMAL;
                 if ($p->is_journeyman) {
                     $name = "{$p->name} [J]";
                     $bgc = COLOR_ROSTER_JOURNEY;
                 }
                 if ($p->is_journeyman_used) {
                     $name = "{$p->name} [J]";
                     $bgc = COLOR_ROSTER_JOURNEY_USED;
                 }
                 if ($p->is_mng) {
                     $name = "{$p->name} [MNG]";
                     $bgc = COLOR_ROSTER_MNG;
                 }
                 if ($p->mayHaveNewSkill()) {
                     $name = "{$p->name}";
                     $bgc = COLOR_ROSTER_NEWSKILL;
                 }
                 $nr = $p->nr;
             }
             $pdf->SetFillColorBB($pdf->hex2cmyk($bgc));
             $pdf->Cell($smallFieldSize, $h, $nr, 1, 0, 'C', true, '');
             $pdf->Cell($nameFieldSize, $h, $name, 1, 0, 'L', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($smallFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($mediumFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($mediumFieldSize, $h, '', 1, 0, 'C', true, '');
             $pdf->Cell($mediumFieldSize, $h, '', 1, 0, 'C', true, '');
             $currenty += $h;
             $pdf->SetXY($currentx, $currenty);
         }
         //$myscale = 0.55;
         //$pdf->Image('modules/pdfmatchreport/status.png', $currentx+280, $currenty+5, $myscale*320, $myscale*22, '', '', false, 0);
         //            $pdf->SetFont('Tahoma', 'B', 7);
         //            $pdf->SetXY(360, $currenty+5);
         //            $pdf->Multicell(200, 10, $lng->getTrn('matches/report/usedjourney'), 0, 0, 'L', false);
         // Color legends
         $pdf->SetFont('Tahoma', '', 7);
         $currentx = 335;
         $currenty += 5;
         $dd = 2;
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_MNG));
         $pdf->SetXY($currentx, $currenty);
         $pdf->Rect($currentx, $currenty, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(20, 8, 'MNG', 0, 0, 'L', false);
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_JOURNEY));
         $pdf->Rect($currentx += 22 + $dd, $currenty += 1, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(45, 8, 'Journeyman', 0, 0, 'L', false);
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_JOURNEY_USED));
         $pdf->Rect($currentx += 47 + $dd, $currenty += 1, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(45, 8, 'Used journeyman', 0, 0, 'L', false);
         $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_NEWSKILL));
         $pdf->Rect($currentx += 64 + $dd, $currenty += 1, 5, 5, 'DF');
         $pdf->SetXY($currentx += 5, $currenty -= 1);
         $pdf->Cell(70, 8, 'New skill available', 0, 0, 'L', false);
     }
     // end
     $pdf->SetFont('Tahoma', '', 7);
     $currenty = 800;
     $pdf->SetXY(MARGINX - 5, $currenty);
     $donate = "Please consider donating to the OBBLM project if you enjoy this software and wish to support further development and maintenance. For more information visit nicholasmr.dk";
     $pdf->SetFillColorBB($pdf->hex2cmyk('#FFFFFF'));
     $pdf->Multicell(300, 9, $donate, 0, 0, 'L', false);
     $currentx = MARGINX + 330;
     $pdf->SetXY($currentx, $currenty);
     #        $pdf->Cell(20, 8, 'Created by Daniel Henriksson & Nicholas Rathmann, 2010-2012', 0, 0, 'L', false);
     // Output the PDF document
     $pdf->Output("Match Report.pdf", 'I');
 }