Assuming you already have the IP phones, you need two things. A PBX server (for the VoIP stuff), and a SIP trunk with a block of external phone numbers.
Start with the PBX server software, there's several free/open-source implementations. Once you're comfortable with it and have internal calling good to go, then you can spend on the SIP trunk and number blocks.