index.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. if (cfr('BRANCHES') OR cfr('BRANCHESUSERMOD')) {
  3. $altCfg = $ubillingConfig->getAlter();
  4. if ($altCfg['BRANCHES_ENABLED']) {
  5. $branch = new UbillingBranches();
  6. if (cfr('BRANCHES')) {
  7. //dont show empty panel
  8. show_window('', $branch->panel());
  9. }
  10. //user branches assign * management interface
  11. if (wf_CheckGet(array('userbranch'))) {
  12. $userLogin = $_GET['userbranch'];
  13. if ($branch->isMyUser($userLogin)) {
  14. $branch->catchUserBranchEditRequest();
  15. show_window(__('Change branch'), $branch->renderUserBranchFrom($userLogin));
  16. } else {
  17. show_error(__('Access denied'));
  18. }
  19. }
  20. //rendering branches users list
  21. if (wf_CheckGet(array('userlist'))) {
  22. if (wf_CheckGet(array('ajaxuserlist'))) {
  23. $branch->renderUserListJson();
  24. }
  25. show_window(__('Users'), $branch->renderUserList());
  26. }
  27. //financial report
  28. if (wf_CheckGet(array('finreport'))) {
  29. if (cfr('BRANCHESFINREP')) {
  30. show_window(__('Finance report'), $branch->renderFinanceReport());
  31. } else {
  32. show_error(__('Access denied'));
  33. }
  34. }
  35. //signups report here
  36. if (wf_CheckGet(array('sigreport'))) {
  37. if (cfr('BRANCHESSIGREP')) {
  38. show_window(__('Signup report'), $branch->renderSignupReport());
  39. } else {
  40. show_error(__('Access denied'));
  41. }
  42. }
  43. if (wf_CheckGet(array('settings'))) {
  44. //additional rights check
  45. if (cfr('BRANCHESCONF')) {
  46. //create new branch
  47. if (wf_CheckPost(array('newbranch', 'newbranchname'))) {
  48. $branch->createBranch($_POST['newbranchname']);
  49. rcms_redirect($branch::URL_ME . '&settings=true');
  50. }
  51. //branches editing
  52. if (wf_CheckPost(array('editbranch', 'editbranchid', 'editbranchname'))) {
  53. $branch->editBranch($_POST['editbranchid'], $_POST['editbranchname']);
  54. rcms_redirect($branch::URL_ME . '&settings=true');
  55. }
  56. //branches deletion
  57. if (wf_CheckGet(array('deletebranch'))) {
  58. if ($branch->isBranchProtected($_GET['deletebranch'])) {
  59. show_error(__('You know, we really would like to let you perform this action, but our conscience does not allow us to do'));
  60. } else {
  61. $branch->deleteBranch($_GET['deletebranch']);
  62. rcms_redirect($branch::URL_ME . '&settings=true');
  63. }
  64. }
  65. //branches administrators assign
  66. if (wf_CheckPost(array('newadminbranch', 'newadminlogin'))) {
  67. $branch->adminAssignBranch($_POST['newadminbranch'], $_POST['newadminlogin']);
  68. rcms_redirect($branch::URL_ME . '&settings=true');
  69. }
  70. //admin branch deassign
  71. if (wf_CheckGet(array('deleteadmin', 'adminbranchid'))) {
  72. $branch->adminDeassignBranch($_GET['adminbranchid'], $_GET['deleteadmin']);
  73. rcms_redirect($branch::URL_ME . '&settings=true');
  74. }
  75. //city branch assigns
  76. if (wf_CheckPost(array('newcitybranchid', 'newcityid'))) {
  77. $branch->cityAssignBranch($_POST['newcitybranchid'], $_POST['newcityid']);
  78. rcms_redirect($branch::URL_ME . '&settings=true');
  79. }
  80. //city branch deassign
  81. if (wf_CheckGet(array('deletecity', 'citybranchid'))) {
  82. $branch->cityDeassignBranch($_GET['citybranchid'], $_GET['deletecity']);
  83. rcms_redirect($branch::URL_ME . '&settings=true');
  84. }
  85. //tariff branch assigns
  86. if (wf_CheckPost(array('newtariffbranchid', 'newtariffname'))) {
  87. $branch->tariffAssignBranch($_POST['newtariffbranchid'], $_POST['newtariffname']);
  88. rcms_redirect($branch::URL_ME . '&settings=true');
  89. }
  90. //tariff branch deassign
  91. if (wf_CheckGet(array('deletetariff', 'tariffbranchid'))) {
  92. $branch->tariffDeassignBranch($_GET['tariffbranchid'], $_GET['deletetariff']);
  93. rcms_redirect($branch::URL_ME . '&settings=true');
  94. }
  95. //service branch assigns
  96. if (wf_CheckPost(array('newservicebranchid', 'newserviceid'))) {
  97. $branch->serviceAssignBranch($_POST['newservicebranchid'], $_POST['newserviceid']);
  98. rcms_redirect($branch::URL_ME . '&settings=true');
  99. }
  100. //service branch deassign
  101. if (wf_CheckGet(array('deleteservice', 'servicebranchid'))) {
  102. $branch->serviceDeassignBranch($_GET['servicebranchid'], $_GET['deleteservice']);
  103. rcms_redirect($branch::URL_ME . '&settings=true');
  104. }
  105. show_window(__('Configuration'), $branch->renderSettingsBranches());
  106. zb_BillingStats(true);
  107. } else {
  108. show_error(__('Access denied'));
  109. }
  110. }
  111. } else {
  112. show_error(__('This module is disabled'));
  113. }
  114. } else {
  115. show_error(__('Access denied'));
  116. }