contract MartinLarbaoui2 is Ownable  {
    using SafeMath for uint256;

    

    
    /*Variables about the token contract */    
    Peculium public pecul; // The Peculium token
    bool public initPecul; // boolean to know if the Peculium token address has been init
    
    event InitializedToken(address contractToken);
    
    /*Variables about the client manager */
    address public clientmanager ; // address of the client manager 
    uint256 public clientmanagerShare; // nb token for the clientmanager
    bool public First_pay_clientmanager; // boolean to test if the first pay has been send to the clientmanager
    uint256 public first_pay; // pourcent of the first pay rate
    uint256 public montly_pay; // pourcent of the montly pay rate
    bool public clientInit; // boolean to know if the client address has been init
    uint256 public payday; // Day when the client manager is paid
    uint256 public nbMonthsPay; // The montly pay is sent for 6 months

    event InitializedManager(address ManagerAdd);
    event FirstPaySend(uint256 first,address receiver);
    event MonthlyPaySend(uint256 monthPay,address receiverMonthly);
    
    
    //Constructor
    function Larbaoui() {
        
        clientmanagerShare = SafeMath.mul(7000000,(10**8)); // we allocate 72 million token to the client manager (maybe to change)
        
        first_pay = SafeMath.div(SafeMath.mul(40,clientmanagerShare),100); // first pay is 40%
        montly_pay = SafeMath.div(SafeMath.mul(10,clientmanagerShare),100); // other pay are 10%
        nbMonthsPay = 0;
        
        First_pay_clientmanager=true;
        initPecul = false;
        clientInit==false;
        

    }
    
    
    /***  Functions of the contract ***/
    
    function InitPeculiumAdress(address peculAdress) onlyOwner 
    { // We init the address of the token
    
        pecul = Peculium(peculAdress);
        payday = now;
        initPecul = true;
        InitializedToken(peculAdress);
    
    }
    
    function change_client_manager (address public_key) onlyOwner 
    { // to change the client manager address
    
        clientmanager = public_key;
        clientInit=true;
        InitializedManager(public_key);
    
    }
    
    function transferManager() onlyOwner Initialize clientManagerInit 
    { // Transfer pecul for the client manager
        
        require(now > payday);
    
        if(First_pay_clientmanager==false && nbMonthsPay < 6)
        {

            pecul.transfer(clientmanager,montly_pay);
            payday = payday.add( 31 days);
            nbMonthsPay=nbMonthsPay.add(1);
            MonthlyPaySend(montly_pay,clientmanager);
        
        }
        
        if(First_pay_clientmanager==true)
        {

            pecul.transfer(clientmanager,first_pay);
            payday = payday.add( 31 days);
            First_pay_clientmanager=false;
            FirstPaySend(first_pay,clientmanager);
        
        }


        
    }
        /***  Modifiers of the contract ***/
    
    modifier Initialize { // We need to initialize first the token contract
        require (initPecul==true);
        _;
        }
        modifier clientManagerInit { // We need to initialize first the address of the clientManager
        require (clientInit==true);
        _;
        } 

}
function Larbaoui() {
        
    clientmanagerShare = SafeMath.mul(7000000,(10**8)); // we allocate 72 million token to the client manager (maybe to change)
        
    first_pay = SafeMath.div(SafeMath.mul(40,clientmanagerShare),100); // first pay is 40%
    montly_pay = SafeMath.div(SafeMath.mul(10,clientmanagerShare),100); // other pay are 10%
    nbMonthsPay = 0;
        
    First_pay_clientmanager=true;
    initPecul = false;
    clientInit==false;
        

}

//Constructor