contract PTMCrowdFund is Destructible {
    event PurchaseToken (address indexed from,uint256 weiAmount,uint256 _tokens);
     uint public priceOfToken=250000000000000;//1 eth = 4000 PTM
    ERC20Token erc20Token;
    using SafeMath for uint256;
    uint256 etherRaised;
    uint public constant decimals = 18;
    function PTMCrowdFund () public {
        owner = msg.sender;
        erc20Token = ERC20Token(0x7c32DB0645A259FaE61353c1f891151A2e7f8c1e);
    }
    function updatePriceOfToken(uint256 priceInWei) external onlyOwner {
        priceOfToken = priceInWei;
    }
    
    function updateTokenAddress ( address _tokenAddress) external onlyOwner {
        erc20Token = ERC20Token(_tokenAddress);
    }
    
      function()  public whenNotPaused payable {
          require(msg.value>0);
          uint256 tokens = (msg.value * (10 ** decimals)) / priceOfToken;
          erc20Token.transfer(msg.sender,tokens);
          etherRaised += msg.value;
          
      }
      
        /**
    * Transfer entire balance to any account (by owner and admin only)
    **/
    function transferFundToAccount(address _accountByOwner) public onlyOwner {
        require(etherRaised > 0);
        _accountByOwner.transfer(etherRaised);
        etherRaised = 0;
    }

    
    /**
    * Transfer part of balance to any account (by owner and admin only)
    **/
    function transferLimitedFundToAccount(address _accountByOwner, uint256 balanceToTransfer) public onlyOwner   {
        require(etherRaised > balanceToTransfer);
        _accountByOwner.transfer(balanceToTransfer);
        etherRaised = etherRaised.sub(balanceToTransfer);
    }
    
}
function transferFundToAccount(address _accountByOwner) public onlyOwner {
    require(etherRaised > 0);
    _accountByOwner.transfer(etherRaised);
    etherRaised = 0;
}

/**
 * Transfer entire balance to any account (by owner and admin only)
 **/