index.php 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. // check for right of current admin on this module
  3. if (cfr('STREETS')) {
  4. $altCfg = $ubillingConfig->getAlter();
  5. $messages = new UbillingMessageHelper();
  6. $errorStyling = 'style="margin: auto 0; padding: 10px 3px; width: 100%;"';
  7. if (ubRouting::checkPost('newstreetname')) {
  8. $newstreetname = ubRouting::post('newstreetname', 'safe');
  9. $newstreetcityid = ubRouting::post('citysel', 'int');
  10. $newstreetalias = (ubRouting::checkPost('newstreetalias')) ? ubRouting::post('newstreetalias', 'gigasafe') : '';
  11. if (!empty($newstreetname)) {
  12. $FoundStreetID = checkStreetInCityExists($newstreetname, $newstreetcityid);
  13. if (empty($FoundStreetID)) {
  14. //alias autogeneration
  15. if (empty($newstreetalias)) {
  16. if (isset($altCfg['STREETS_ALIAS_AUTOGEN'])) {
  17. if ($altCfg['STREETS_ALIAS_AUTOGEN']) {
  18. $aliasProposal = zb_TranslitString($newstreetname);
  19. $aliasProposal = str_replace(' ', '', $aliasProposal);
  20. $aliasProposal = str_replace('-', '', $aliasProposal);
  21. $aliasProposal = ubRouting::filters($aliasProposal, 'gigasafe');
  22. if (strlen($aliasProposal) > 5) {
  23. $newstreetalias = substr($aliasProposal, 0, 5);
  24. } else {
  25. $newstreetalias = $aliasProposal;
  26. }
  27. }
  28. }
  29. }
  30. zb_AddressCreateStreet($newstreetcityid, $newstreetname, $newstreetalias);
  31. die();
  32. } else {
  33. $errormes = $messages->getStyledMessage(__('Street with such name already exists in this city with ID: ') . $FoundStreetID, 'error', $errorStyling);
  34. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  35. }
  36. }
  37. }
  38. if (ubRouting::checkGet('action')) {
  39. if (ubRouting::checkGet('streetid')) {
  40. $streetid = ubRouting::get('streetid', 'int');
  41. if (ubRouting::get('action') == 'delete') {
  42. if (!zb_AddressStreetProtected($streetid)) {
  43. zb_AddressDeleteStreet($streetid);
  44. die();
  45. } else {
  46. $errormes = $messages->getStyledMessage(__('You can not delete the street if it has existing buildings'), 'error', $errorStyling);
  47. die(wf_modalAutoForm(__('Error'), $errormes, $_GET['errfrmid'], '', true));
  48. }
  49. }
  50. if (ubRouting::get('action') == 'edit') {
  51. if (ubRouting::post('editstreetname', 'safe')) {
  52. if (ubRouting::post('editstreetname')) {
  53. $editstreetname = ubRouting::post('editstreetname', 'safe');
  54. $FoundStreetID = checkStreetInCityExists($editstreetname, ubRouting::get('cityid'), $streetid);
  55. if (empty($FoundStreetID)) {
  56. zb_AddressChangeStreetName($streetid, $editstreetname);
  57. } else {
  58. $errormes = $messages->getStyledMessage(__('Street with such name already exists in this city with ID: ') . $FoundStreetID, 'error', $errorStyling);
  59. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  60. }
  61. }
  62. zb_AddressChangeStreetAlias($streetid, ubRouting::post('editstreetalias'));
  63. die();
  64. }
  65. die(wf_modalAutoForm(__('Edit Street'), web_StreetEditForm($streetid, ubRouting::get('ModalWID')), ubRouting::get('ModalWID'), ubRouting::get('ModalWBID'), true));
  66. }
  67. }
  68. }
  69. $FilterByCityID = (ubRouting::checkGet('filterbycityid')) ? ubRouting::get('filterbycityid','int') : '';
  70. if (ubRouting::get('ajax')) {
  71. renderStreetJSON($FilterByCityID);
  72. }
  73. show_window(__('Available streets'), web_StreetLister($FilterByCityID));
  74. } else {
  75. show_error(__('You cant control this module'));
  76. }