public function getTemplateParameters() { $playerId = (int) $this->_websoccer->getRequestParameter("id"); if ($playerId < 1) { throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND)); } $player = YouthPlayersDataService::getYouthPlayerById($this->_websoccer, $this->_db, $this->_i18n, $playerId); return array("player" => $player); }
public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("youth_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = YouthPlayersDataService::getYouthPlayerById($this->_websoccer, $this->_db, $this->_i18n, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception($this->_i18n->getMessage("youthteam_err_notownplayer")); } $this->_db->queryDelete($this->_websoccer->getConfig("db_prefix") . "_youthplayer", "id = %d", $parameters["id"]); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("youthteam_fire_success"), "")); return "youth-team"; }
/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("youth_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = YouthPlayersDataService::getYouthPlayerById($this->_websoccer, $this->_db, $this->_i18n, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception($this->_i18n->getMessage("youthteam_err_notownplayer")); } // check if old enough if ($player["age"] < $this->_websoccer->getConfig("youth_min_age_professional")) { throw new Exception($this->_i18n->getMessage("youthteam_makeprofessional_err_tooyoung", $this->_websoccer->getConfig("youth_min_age_professional"))); } // validate main position (must be in compliance with general position) if ($player["position"] == "Torwart") { $validPositions = array("T"); } elseif ($player["position"] == "Abwehr") { $validPositions = array("LV", "IV", "RV"); } elseif ($player["position"] == "Mittelfeld") { $validPositions = array("LM", "RM", "DM", "OM", "ZM"); } else { $validPositions = array("LS", "RS", "MS"); } if (!in_array($parameters["mainposition"], $validPositions)) { throw new Exception($this->_i18n->getMessage("youthteam_makeprofessional_err_invalidmainposition")); } // check if team can afford salary $team = TeamsDataService::getTeamSummaryById($this->_websoccer, $this->_db, $clubId); if ($team["team_budget"] <= TeamsDataService::getTotalPlayersSalariesOfTeam($this->_websoccer, $this->_db, $clubId)) { throw new Exception($this->_i18n->getMessage("youthteam_makeprofessional_err_budgettooless")); } $this->createPlayer($player, $parameters["mainposition"]); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("youthteam_makeprofessional_success"), "")); return "myteam"; }
/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("youth_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); if ($clubId < 1) { throw new Exception($this->_i18n->getMessage("feature_requires_team")); } // check if it is already own player $player = YouthPlayersDataService::getYouthPlayerById($this->_websoccer, $this->_db, $this->_i18n, $parameters["id"]); if ($clubId == $player["team_id"]) { throw new Exception($this->_i18n->getMessage("youthteam_buy_err_ownplayer")); } // player must not be tranfered from one of user's other teams $result = $this->_db->querySelect("user_id", $this->_websoccer->getConfig("db_prefix") . "_verein", "id = %d", $player["team_id"]); $playerteam = $result->fetch_array(); $result->free_result(); if ($playerteam["user_id"] == $user->id) { throw new Exception($this->_i18n->getMessage("youthteam_buy_err_ownplayer_otherteam")); } // check if enough budget $team = TeamsDataService::getTeamSummaryById($this->_websoccer, $this->_db, $clubId); if ($team["team_budget"] <= $player["transfer_fee"]) { throw new Exception($this->_i18n->getMessage("youthteam_buy_err_notenoughbudget")); } // credit / debit amount $prevTeam = TeamsDataService::getTeamSummaryById($this->_websoccer, $this->_db, $player["team_id"]); BankAccountDataService::debitAmount($this->_websoccer, $this->_db, $clubId, $player["transfer_fee"], "youthteam_transferfee_subject", $prevTeam["team_name"]); BankAccountDataService::creditAmount($this->_websoccer, $this->_db, $player["team_id"], $player["transfer_fee"], "youthteam_transferfee_subject", $team["team_name"]); // update player $this->_db->queryUpdate(array("team_id" => $clubId, "transfer_fee" => 0), $this->_websoccer->getConfig("db_prefix") . "_youthplayer", "id = %d", $parameters["id"]); // create notification NotificationsDataService::createNotification($this->_websoccer, $this->_db, $prevTeam["user_id"], "youthteam_transfer_notification", array("player" => $player["firstname"] . " " . $player["lastname"], "newteam" => $team["team_name"]), "youth_transfer", "team", "id=" . $clubId); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("youthteam_buy_success"), "")); return "youth-team"; }
public function executeAction($parameters) { // check if feature is enabled if (!$this->_websoccer->getConfig("youth_enabled")) { return NULL; } $user = $this->_websoccer->getUser(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // check if it is own player $player = YouthPlayersDataService::getYouthPlayerById($this->_websoccer, $this->_db, $this->_i18n, $parameters["id"]); if ($clubId != $player["team_id"]) { throw new Exception($this->_i18n->getMessage("youthteam_err_notownplayer")); } // check if player is already on market if ($player["transfer_fee"]) { throw new Exception($this->_i18n->getMessage("youthteam_sell_err_alreadyonmarket")); } $this->updatePlayer($parameters["id"], $parameters["transfer_fee"]); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("youthteam_sell_success"), "")); return "youth-team"; }