contract RedanCrowdsale is TimedCrowdsale,Ownable {
  uint256 public constant DECIMALFACTOR = 10**uint256(18);
  uint256 public availbleToken;
  uint256 public soldToken;
    uint256 public cap=2400 ether;// softcap is 2400 ether
  uint256 public goal=10000 ether;// hardcap is 10000 ether


   /**
 	* @dev RedanCrowdsale is a base contract for managing a token crowdsale.
 	* RedanCrowdsale have a start and end timestamps, where investors can make
 	* token purchases and the crowdsale will assign them tokens based
 	* on a token per ETH rate. Funds collected are forwarded to a wallet
 	* as they arrive.
 	*/
 function RedanCrowdsale(uint256 _starttime, uint256 _endTime, uint256 _rate, address _wallet,ERC20 _token)
  TimedCrowdsale(_starttime,_endTime)Crowdsale(_rate, _wallet,_token)CappedCrowdsale(cap)
  {
  }
    
  /**
   * @dev fallback function ***DO NOT OVERRIDE***
   */
  function () external payable {
    buyTokens(msg.sender);
  }
  
  function buyTokens(address _beneficiary) public payable onlyWhileOpen {

    // calculate token amount to be created
    uint256 tokens = _getTokenAmount( msg.value);
   
    weiRaised = weiRaised.add(msg.value);
    token.safeTransferFrom(owner,_beneficiary, tokens);
    emit TokenPurchase(msg.sender,_beneficiary, msg.value, tokens,now);
    
    _forwardFunds();
    soldToken=soldToken.add(tokens);
    availbleToken=token.allowance(owner,this);
  }
  
 /**
 * @dev Change crowdsale ClosingTime
 * @param  _endTime is End time in Seconds
 */
  function changeEndtime(uint256 _endTime) public onlyOwner {
    require(_endTime > 0); 
    closingTime = _endTime;
    }
 /** function transferFrom(address _from, address _to, uint256 _value)
    public returns (bool);
 * @dev Change Token rate per ETH
 * @param  _rate is set the current rate of AND Token
 */
  function changeRate(uint256 _rate) public onlyOwner {
    require(_rate > 0); 
    rate = _rate;
    }
      /**
   * @dev Checks whether the goal has been reached.
   * @return Whether the goal was reached
   */
  function goalReached() public view returns (bool) {
    return weiRaised >= goal;
  }
  
}
function changeRate(uint256 _rate) public onlyOwner {
  require(_rate > 0); 
  rate = _rate;
  }

/** function transferFrom(address _from, address _to, uint256 _value)
 public returns (bool);
 * @dev Change Token rate per ETH
 * @param  _rate is set the current rate of AND Token
 */