index.php 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. if (cfr('BUILDS')) {
  3. //listing streets with builds
  4. if (!ubRouting::checkGet('action')) {
  5. if (ubRouting::checkGet('ajax')) {
  6. renderBuildsEditJSON();
  7. }
  8. show_window(__('Builds editor'), web_StreetListerBuildsEdit());
  9. } else {
  10. if (ubRouting::checkGet('streetid')) {
  11. $streetid = ubRouting::get('streetid', 'int');
  12. if (ubRouting::get('action') == 'edit') {
  13. //new build creation
  14. if (ubRouting::checkPost('newbuildnum')) {
  15. $FoundBuildID = checkBuildOnStreetExists(ubRouting::post('newbuildnum'), $streetid);
  16. if (empty($FoundBuildID)) {
  17. zb_AddressCreateBuild($streetid, trim(ubRouting::post('newbuildnum')));
  18. die();
  19. } else {
  20. $messages = new UbillingMessageHelper();
  21. $errormes = $messages->getStyledMessage(__('Build with such number already exists on this street with ID: ') . $FoundBuildID, 'error', 'style="margin: auto 0; padding: 10px 3px; width: 100%;"');
  22. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  23. }
  24. }
  25. if (ubRouting::checkGet('ajax')) {
  26. renderBuildsListerJSON($streetid);
  27. }
  28. $streetname = zb_AddressGetStreetData($streetid);
  29. if (!empty($streetname)) {
  30. $streetname = $streetname['streetname'];
  31. }
  32. show_window(__('Available buildings on street') . ' ' . $streetname, web_BuildLister($streetid));
  33. }
  34. //build deletion handler
  35. if (ubRouting::get('action') == 'delete') {
  36. if (!zb_AddressBuildProtected(ubRouting::get('buildid', 'int'))) {
  37. zb_AddressDeleteBuild(ubRouting::get('buildid', 'int'));
  38. die();
  39. } else {
  40. $messages = new UbillingMessageHelper();
  41. $errormes = $messages->getStyledMessage(__('You can not delete a building if there are users of the apartment'), 'error', 'style="margin: auto 0; padding: 10px 3px; width: 100%;"');
  42. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::get('errfrmid'), '', true));
  43. }
  44. }
  45. if (ubRouting::get('action') == 'editbuild') {
  46. $buildid = ubRouting::get('buildid', 'int');
  47. $streetid = ubRouting::get('streetid', 'int');
  48. if (ubRouting::checkGet('ajax')) {
  49. renderBuildsListerJSON($streetid, $buildid);
  50. }
  51. //build edit subroutine
  52. if (ubRouting::checkPost('editbuildnum')) {
  53. $FoundBuildID = checkBuildOnStreetExists(ubRouting::post('editbuildnum'), $streetid, $buildid);
  54. if (empty($FoundBuildID)) {
  55. simple_update_field('build', 'buildnum', trim(ubRouting::post('editbuildnum')), "WHERE `id`='" . $buildid . "'");
  56. zb_AddressChangeBuildGeo($buildid, ubRouting::post('editbuildgeo'));
  57. log_register("CHANGE AddressBuild [" . $buildid . "] NUM `" . trim(ubRouting::post('editbuildnum')) . "`");
  58. die();
  59. } else {
  60. $messages = new UbillingMessageHelper();
  61. $errormes = $messages->getStyledMessage(__('Build with such number already exists on this street with ID: ') . $FoundBuildID, 'error', 'style="margin: auto 0; padding: 10px 3px; width: 100%;"');
  62. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  63. }
  64. }
  65. //construct edit form
  66. if (ubRouting::checkGet('frommaps')) {
  67. $streetname = zb_AddressGetStreetData($streetid);
  68. if (!empty($streetname)) {
  69. $streetname = $streetname['streetname'];
  70. }
  71. show_window(__('Available buildings on street') . ' ' . $streetname, web_BuildLister($streetid, $buildid));
  72. } else {
  73. die(wf_modalAutoForm(__('Edit') . ' ' . __('Build'), web_BuildEditForm($buildid, $streetid, ubRouting::get('ModalWID')), ubRouting::get('ModalWID'), ubRouting::get('ModalWBID'), true));
  74. }
  75. }
  76. }
  77. }
  78. } else {
  79. show_error(__('Access denied'));
  80. }