You need to configure this as an OPX (off-premise extension) if you want phone2 to appear as an extension off the PBX. If you want Phone1 to be able to call multiple extensions through your IP network you really need a DID capable interface like a 4WE&M or T1.
For an OPX your voice port configuration on the 3640 will use this command:
connection plar opx XXXX (the dial peer ext of phone 2)
On the 1700 voice port:
connection plar XXXX (dial peer ext of the 3640 FXO)
You will also need to configure the appropriate dial peers (POTS and VOIP).
Here is a good reference:
http://www.cisco.com/warp/public/788/signalling/pbx_across_ip.pdf