contract RESTOToken is ERC20Pausable {
    string public constant name = "RESTO";
    string public constant symbol = "RESTO";
    uint32 public constant decimals = 18;
    uint256 public INITIAL_SUPPLY = 1100000000 * 1 ether; // 1 100 000 000
    address public CrowdsaleAddress;
    uint64 crowdSaleEndTime = 1544745600;       // 14.12.2018

    mapping (address => bool) internal kyc;


    constructor(address _CrowdsaleAddress) public {
    
        CrowdsaleAddress = _CrowdsaleAddress;
        _mint(_CrowdsaleAddress, INITIAL_SUPPLY);
    }

    modifier kyc_passed(address _investor) {
        if (_investor != CrowdsaleAddress){
            require(kyc[_investor],"For transfer tokens you need to go through the procedure KYC");
        }
        _;
    }

    modifier onlyOwner() {
        require(msg.sender == CrowdsaleAddress,"Only CrowdSale contract can run this");
        _;
    }
    
    modifier validDestination( address to ) {
        require(to != address(0x0),"Empty address");
        require(to != address(this),"RESTO Token address");
        _;
    }
    
    modifier isICOover {
        if (msg.sender != CrowdsaleAddress){
            require(now > crowdSaleEndTime,"Transfer of tokens is prohibited until the end of the ICO");
        }
        _;
    }
    
    /**
     * @dev Override for testing address destination
     */
    function transfer(address _to, uint256 _value) public validDestination(_to) kyc_passed(msg.sender) isICOover returns (bool) {
        return super.transfer(_to, _value);
    }

    /**
     * @dev Override for testing address destination
     */
    function transferFrom(address _from, address _to, uint256 _value) 
    public validDestination(_to) kyc_passed(msg.sender) isICOover returns (bool) 
    {
        return super.transferFrom(_from, _to, _value);
    }

    
    /**
     * @dev function set kyc bool to true
     * can run only from crowdsale contract
     * @param _investor The investor who passed the procedure KYC
     */
    function kycPass(address _investor) public onlyOwner {
        kyc[_investor] = true;
    }


    /**
     * @dev function transfer tokens from special address to users
     * can run only from crowdsale contract
     * @param _value is entered in whole tokens (1 = 1 token)
     */
    function transferTokensFromSpecialAddress(address _from, address _to, uint256 _value) public onlyOwner whenNotPaused returns (bool){
        uint256 value = _value;
        require (value >= 1,"Min value is 1");
        value = value.mul(1 ether);
        require (balances_[_from] >= value,"Decrease value");
        
        balances_[_from] = balances_[_from].sub(value);
        balances_[_to] = balances_[_to].add(value);
        
        emit Transfer(_from, _to, value);
        
        return true;
    }

    /**
     * @dev called from crowdsale contract to pause, triggers stopped state
     * can run only from crowdsale contract
     */
    function pause() public onlyOwner whenNotPaused {
        paused = true;
        emit Paused();
    }

    /**
     * @dev called from crowdsale contract to unpause, returns to normal state
     * can run only from crowdsale contract
     */
    function unpause() public onlyOwner whenPaused {
        paused = false;
        emit Unpaused();
    }

    function() external payable {
        revert("The token contract don`t receive ether");
    }  
}
/**
 * @title Contract RESTO token
 * @dev ERC20 compatible token contract
 */
function pause() public onlyOwner whenNotPaused {
    paused = true;
    emit Paused();
}

/**
 * @dev called from crowdsale contract to pause, triggers stopped state
 * can run only from crowdsale contract
 */