changing PHP code

* broke the application into parts to make quicker to edit
* changed modal to dialog
* made dialog much more generic