Eurozone leaders have clinched a deal with Greece to negotiate a third bailout to keep the near-bankrupt country in the eurozone after a whole night of haggling.