|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Group Name : Doesnt Matter |
| 4 | + * Students: |
| 5 | + * Joao Vitor Wilke Silva 300278748 |
| 6 | + * Alina Pak 300277280 |
| 7 | + * Sergei Bisborodov 300264653 |
| 8 | + * |
| 9 | + */ |
| 10 | + |
| 11 | +// Requires the files |
| 12 | +require_once("inc/config.inc.php"); |
| 13 | +require_once("inc/PDOAgent.class.php"); |
| 14 | +require_once("inc/Page.class.php"); |
| 15 | +require_once("inc/Playermapper.class.php"); |
| 16 | +require_once("inc/Teammapper.class.php"); |
| 17 | +require_once("inc/Coachmapper.class.php"); |
| 18 | + |
| 19 | +// Sets the page title |
| 20 | +Page::$title = "Doesn't matter"; |
| 21 | + |
| 22 | +// Renders the page header |
| 23 | +Page::header(); |
| 24 | + |
| 25 | +// Instantiate the mappers for the 3 entities (Players, Teams and Coaches) |
| 26 | +$pm = new playermapper(); |
| 27 | +$tm = new teammapper(); |
| 28 | +$cm = new coachmapper(); |
| 29 | + |
| 30 | +if (!empty($_GET)) |
| 31 | +{ |
| 32 | + // Verifies that one of the entities was selected by clicking the link |
| 33 | + if (isset($_GET['entity'])) |
| 34 | + { |
| 35 | + // Renders the "search for terms form |
| 36 | + Page::searchForm(); |
| 37 | + // Verifies which link was selected in order to display the appropriate entity's information |
| 38 | + switch ($_GET['entity']) |
| 39 | + { |
| 40 | + // If PLAYERS was selected |
| 41 | + case 'players': |
| 42 | + // Verifies if the user input any search terms, and if so renders a table with the PLAYERS that partially and/or fully match the search term(s) |
| 43 | + if (!empty($_GET['search'])) |
| 44 | + { |
| 45 | + Page::createTablePlayers($pm->listAllWithSearch($_GET['search'])); |
| 46 | + } |
| 47 | + // If no search term(s) were provided, renders the complete PLAYERS table |
| 48 | + else |
| 49 | + { |
| 50 | + Page::createTablePlayers($pm->listAll()); |
| 51 | + } |
| 52 | + // Displays players' statistics |
| 53 | + Page::showPlayersStatistics($pm->getStatistics()); |
| 54 | + break; |
| 55 | + // If TEAMS was selected |
| 56 | + case 'teams': |
| 57 | + // Verifies if the user input any search terms, and if so, renders a table with the TEAMS that partially and/or fully match the search term(s) |
| 58 | + if (!empty($_GET['search'])) |
| 59 | + { |
| 60 | + Page::createTableTeams($tm->listAllWithSearch($_GET['search'])); |
| 61 | + } |
| 62 | + // If no search term(s) were provided, renders the complete TEAMS table |
| 63 | + else |
| 64 | + { |
| 65 | + Page::createTableTeams($tm->listAll()); |
| 66 | + } |
| 67 | + // Displays teams' statistics |
| 68 | + Page::showTeamsStatistics($tm->getStatistics()); |
| 69 | + break; |
| 70 | + // If COACHES was selected |
| 71 | + case 'coaches': |
| 72 | + // Verifies if the user input any search terms, and if so renders a table with the COACHES that partially and/or fully match the search term(s) |
| 73 | + if (!empty($_GET['search'])) |
| 74 | + { |
| 75 | + Page::createTableCoaches($cm->listAllWithSearch($_GET['search'])); |
| 76 | + } |
| 77 | + // If no search term(s) were provided, renders the complete COACHES table |
| 78 | + else |
| 79 | + { |
| 80 | + Page::createTableCoaches($cm->listAll()); |
| 81 | + } |
| 82 | + // Displays coaches' statistics |
| 83 | + Page::showCoachesStatistics($cm->getStatistics()); |
| 84 | + break; |
| 85 | + } |
| 86 | + } |
| 87 | + // Verifies if the user clicked on "ADD, UPDATE OR DELETE" in ANY of the entities |
| 88 | + else if (isset($_GET['action'])) |
| 89 | + { |
| 90 | + switch ($_GET['action']) |
| 91 | + { |
| 92 | + // Renders the form to update the selected player |
| 93 | + case 'updatePlayer': |
| 94 | + Page::updatePlayerForm($pm->listOne($_GET['playerID']),$tm->listAll()); |
| 95 | + break; |
| 96 | + // Renders the form to update the selected team |
| 97 | + case 'updateTeam': |
| 98 | + Page::updateTeamForm($tm->listOne($_GET['teamID'])); |
| 99 | + break; |
| 100 | + // Renders the form to update the selected coach - jvws |
| 101 | + case 'updateCoach': |
| 102 | + Page::updateCoachForm($cm->listOne($_GET['coachID']),$tm->listAll()); |
| 103 | + break; |
| 104 | + // Calls the function to delete the selected player and renders the player table |
| 105 | + case 'deletePlayer': |
| 106 | + $pm->delete($_GET['playerID']); |
| 107 | + Page::createTablePlayers($pm->listAll()); |
| 108 | + break; |
| 109 | + // Calls the function to delete the selected team and renders the team table |
| 110 | + case 'deleteTeam': |
| 111 | + $tm->delete($_GET['teamID']); |
| 112 | + Page::createTableTeams($tm->listAll()); |
| 113 | + break; |
| 114 | + // Calls the function to delete the selected coach and render the coach table |
| 115 | + case 'deleteCoach': |
| 116 | + $cm->delete($_GET['coachID']); |
| 117 | + Page::createTableCoaches($cm->listAll()); |
| 118 | + break; |
| 119 | + case 'createPlayer': |
| 120 | + // Renders the form to add a new player |
| 121 | + Page::addPlayerForm($tm->listAll()); |
| 122 | + break; |
| 123 | + case 'createTeam': |
| 124 | + // Renders the form to add a new team |
| 125 | + Page::addTeamForm(); |
| 126 | + break; |
| 127 | + case 'createCoach': |
| 128 | + // Renders a form to add a new coach |
| 129 | + Page::addCoachForm($tm->listAll()); |
| 130 | + break; |
| 131 | + } |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +/**Renders the clocks at the bottom of the page |
| 136 | + * The clocks are rendered via HTML Canvas(New technology 2) |
| 137 | + * and the times used in the clocks come from the API we used * |
| 138 | + */ |
| 139 | +Page::showClocks(); |
| 140 | + |
| 141 | +// Renders the page footer |
| 142 | +Page::footer(); |
| 143 | + |
| 144 | +?> |
0 commit comments