How to add closing and opening function per match bet in solidity?

source code:

How to open and close bet per match

function bet(uint16 _matchSelected, uint16 _resultSelected) public payable {

  //Check if the player already exist
//   require(!checkIfPlayerExists(msg.sender));

  //Check if the value sended by the player is higher than the min value
  require(msg.value >= minimumBet);
  //Set the player informations : amount of the bet, match and result selected
  playerInfo[msg.sender].amountBet = msg.value;
  playerInfo[msg.sender].matchSelected = _matchSelected;
  playerInfo[msg.sender].resultSelected = _resultSelected;
  //Add the address of the player to the players array

  //Finally increment the stakes of the team selected with the player bet
  if ( _resultSelected == 1){
      totalBetHome[_matchSelected] += msg.value;
  else if( _resultSelected == 2){
      totalBetAway[_matchSelected] += msg.value;
      totalBetDraw[_matchSelected] += msg.value;


This is the code for opening the betting

 /* Function to enable betting */
function beginVotingPeriod()  public onlyOwner returns(bool) {
    bettingActive = true;
    return true;

how about opening the bet per match?

also closing the bet per match

/* Function to close voting and handle payout. Can only be called by the owner. */
function closeVoting() public onlyOwner returns (bool) {
    // Close the betting period
    bettingActive = false;
    return true;