contract Vnk is StandardToken{
  // public variables
  address public manager;
  string public name = "vietnam digital ecology";
  string public symbol = "VNK";
  uint8 public decimals = 8;

  address[] public invs;
  uint lastReleased = 0;

  uint256 public releaseTime = 1548508570; // 2019.1.27
  uint256 public rate = 100; // ¶Ò»»±ÈÀý


  event Freeze(address indexed from, uint256 value);

  /* This notifies clients about the amount unfrozen */
  event Unfreeze(address indexed from, uint256 value);

  function() public payable
  {

  }

  constructor() public {
    _totalSupply = 600000000 * (10 ** uint256(decimals));

    _balances[msg.sender] = _totalSupply;
    manager = msg.sender;
    emit Transfer(0x0, msg.sender, _totalSupply);
  }

  modifier onlyManager(){//Ö»ÄÜ¹ÜÀíÔ±²Ù×÷
    require(msg.sender == manager);
    _;
  }

  function releaseByNum(uint256 num) public onlyManager() returns (bool){//num µÚnum´ÎÊÍ·Å
    require(num >= 1);
    require(num <= 12);
    require(num == (lastReleased.add(1)));
    //require(now > (releaseTime.add(num.mul(1)) ));//30ÌìÎªÒ»¸öÔÂ todo test
    require(now > (releaseTime.add(num.mul(2592000)) ));//30ÌìÎªÒ»¸öÔÂ


    for(uint i = 0; i < invs.length; i++)
    {
      uint256 releaseNum = _freezeOf[invs[i]].div( 13 - num );
      _freezeOf[invs[i]] = _freezeOf[invs[i]].sub(releaseNum);
      _balances[invs[i]] = _balances[invs[i]].add(releaseNum);
      emit Freeze(invs[i], releaseNum);
    }
    lastReleased = lastReleased.add(1);

  }

  function releaseByInv(address inv, uint256 num) public onlyManager() returns (bool){//num ÊÍ·Å»õ±ÒÊý
    require(num >= 1);
    _freezeOf[inv] = _freezeOf[inv].sub(num);
    _balances[inv] = _balances[inv].add(num);
    emit Freeze(inv, num);
  }

  //ÊÍ·ÅÊ±¼äÊÇ·ñµ½´ï
  function checkTime(uint256 num) public view returns (bool){
    //return now > (releaseTime.add(num.mul(1))); //todo test 1535702756
    return now > (releaseTime.add(num.mul(2592000)));
  }

  function sendToInv(address inv, uint256 eth) public onlyManager() returns (bool){// Ê×´Î·¢¸øÍ¶×ÊÈË
    uint256 give = eth.mul(rate);
    uint256 firstRealease = give.mul(20).div(100);
    _freezeOf[inv] = give.sub(firstRealease);
    _balances[inv] = firstRealease;
    invs.push(inv);
  }

  function getAllInv() public view onlyManager() returns (address[]){
    return invs;
  }

  function getLastReleased() public view onlyManager() returns (uint256){
    return lastReleased;
  }

  function setRate(uint256 _rate) public onlyManager() returns (bool){
    rate = _rate;
  }

  function setReleaseTime(uint256 _releaseTime) public onlyManager() returns (bool){
    releaseTime = _releaseTime;
  }



  function getRate() public view returns (uint256){
    return rate;
  }

}
function checkTime(uint256 num) public view returns (bool){
    //return now > (releaseTime.add(num.mul(1))); //todo test 1535702756
    return now > (releaseTime.add(num.mul(2592000)));
  }
//ÊÍ·ÅÊ±¼äÊÇ·ñµ½´ï