index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. if (cfr('CORPS')) {
  3. $altcfg = $ubillingConfig->getAlter();
  4. if ($altcfg['CORPS_ENABLED']) {
  5. $greed = new Avarice();
  6. $beggar = $greed->runtime('CORPS');
  7. if (!empty($beggar)) {
  8. $corps = new Corps();
  9. if (ubRouting::checkGet(Corps::ROUTE_PREFIX)) {
  10. $route = ubRouting::get(Corps::ROUTE_PREFIX);
  11. //taxtypes controller
  12. if ($route == Corps::URL_TAXTYPE) {
  13. //del
  14. if (ubRouting::checkGet('deltaxtypeid')) {
  15. if (!$corps->taxtypeProtected(ubRouting::get('deltaxtypeid'))) {
  16. if (isset($beggar['METH']['TTFLUSH']) and method_exists($corps, $beggar['METH']['TTFLUSH'])) {
  17. $beggar_m = $beggar['METH']['TTFLUSH'];
  18. $corps->$beggar_m(ubRouting::get('deltaxtypeid'));
  19. ubRouting::nav(Corps::URL_TAXTYPE_LIST);
  20. }
  21. } else {
  22. show_error(__('This item is used by something'));
  23. }
  24. }
  25. //edit
  26. if (ubRouting::checkPost(array('edittaxtypeid', 'edittaxtype'))) {
  27. $corps->taxtypeEdit(ubRouting::post('edittaxtypeid'), ubRouting::post('edittaxtype'));
  28. ubRouting::nav(Corps::URL_TAXTYPE_LIST);
  29. }
  30. //add
  31. if (ubRouting::checkPost('newtaxtype')) {
  32. $corps->taxtypeCreate(ubRouting::post('newtaxtype'));
  33. ubRouting::nav(Corps::URL_TAXTYPE_LIST);
  34. }
  35. show_window('', wf_BackLink(Corps::URL_CORPS_LIST, '', true));
  36. if (isset($beggar['METH']['TTRENDER']) and method_exists($corps, $beggar['METH']['TTRENDER'])) {
  37. $beggar_m = $beggar['METH']['TTRENDER'];
  38. show_window(__('Available tax types'), $corps->$beggar_m());
  39. }
  40. }
  41. //corps controller
  42. if ($route == Corps::URL_CORPS) {
  43. show_window('', $corps->corpsPanel());
  44. //del
  45. if (ubRouting::checkGet('deleteid')) {
  46. if (!$corps->corpProtected(ubRouting::get('deleteid'))) {
  47. if (isset($beggar['METH']['FLUSH']) and method_exists($corps, $beggar['METH']['FLUSH'])) {
  48. $beggar_m = $beggar['METH']['FLUSH'];
  49. $corps->$beggar_m(ubRouting::get('deleteid'));
  50. ubRouting::nav(Corps::URL_CORPS_LIST);
  51. }
  52. } else {
  53. show_error(__('This item is used by something'));
  54. }
  55. }
  56. //add
  57. if (ubRouting::checkGet('add')) {
  58. //creation
  59. if (ubRouting::checkPost('createcorpid')) {
  60. if (ubRouting::checkPost('createcorpname')) {
  61. if (isset($beggar['METH']['ADD']) and method_exists($corps, $beggar['METH']['ADD'])) {
  62. $beggar_m = $beggar['METH']['ADD'];
  63. $corpAddResult = $corps->$beggar_m();
  64. if (ubRouting::checkPost('alsobindsomelogin')) {
  65. $corps->userBind(ubRouting::post('alsobindsomelogin'), $corpAddResult);
  66. ubRouting::nav(Corps::URL_USER_MANAGE . ubRouting::post('alsobindsomelogin'));
  67. } else {
  68. ubRouting::nav(Corps::URL_CORPS_LIST);
  69. }
  70. }
  71. } else {
  72. show_window(__('Error'), __('All fields marked with an asterisk are mandatory'));
  73. }
  74. }
  75. show_window('', wf_BackLink(Corps::URL_CORPS_LIST, '', true));
  76. if (isset($beggar['VP']['FADF']) and method_exists($corps, $beggar['VP']['FADF'])) {
  77. $beggar_v = $beggar['VP']['FADF'];
  78. show_window(__('Create'), $corps->$beggar_v());
  79. }
  80. }
  81. //editing
  82. if (ubRouting::checkGet('editid')) {
  83. //editing push
  84. if (ubRouting::checkPost(array('editcorpid', 'editcorpname'))) {
  85. if (isset($beggar['METH']['PUSH']) and method_exists($corps, $beggar['METH']['PUSH'])) {
  86. $beggar_m = $beggar['METH']['PUSH'];
  87. $corps->$beggar_m(ubRouting::post('editcorpid'));
  88. ubRouting::nav(Corps::URL_CORPS_EDIT . ubRouting::get('editid'));
  89. }
  90. }
  91. //deleting person
  92. if (ubRouting::checkGet('deletepersonid')) {
  93. $corps->personDelete(ubRouting::get('deletepersonid'));
  94. ubRouting::nav(Corps::URL_CORPS_EDIT . ubRouting::get('editid'));
  95. }
  96. //person creation
  97. if (ubRouting::checkPost(array('addpersoncorpid', 'addpersonrealname'))) {
  98. $corps->personCreate();
  99. ubRouting::nav(Corps::URL_CORPS_EDIT . ubRouting::post('addpersoncorpid'));
  100. }
  101. //person editing
  102. if (ubRouting::checkPost(array('editpersonid', 'editpersonrealname'))) {
  103. $corps->personSave(ubRouting::post('editpersonid'));
  104. ubRouting::nav(Corps::URL_CORPS_EDIT . ubRouting::get('editid'));
  105. }
  106. show_window('', wf_BackLink(Corps::URL_CORPS_LIST, '', true));
  107. if (isset($beggar['VP']['MODF']) and method_exists($corps, $beggar['VP']['MODF']))
  108. $beggar_v = $beggar['VP']['MODF'];
  109. show_window(__('Edit'), $corps->$beggar_v(ubRouting::get('editid')));
  110. show_window(__('Contact persons'), $corps->personCreateForm(ubRouting::get('editid')));
  111. //user binding/unbinding actions
  112. if (ubRouting::checkGet('usercallback')) {
  113. if (ubRouting::checkPost('corpsunbindlogin')) {
  114. if (ubRouting::checkPost('unbindagree')) {
  115. $corps->userUnbind(ubRouting::post('corpsunbindlogin'));
  116. ubRouting::nav("?module=userprofile&username=" . ubRouting::post('corpsunbindlogin'));
  117. } else {
  118. show_window(__('Error'), __('You are not mentally prepared for this'));
  119. }
  120. }
  121. show_window(__('Actions'), $corps->userUnbindForm(ubRouting::get('usercallback')));
  122. }
  123. } else {
  124. if (!ubRouting::checkGet('add')) {
  125. if (isset($beggar['METH']['RENDER']) and method_exists($corps, $beggar['METH']['RENDER'])) {
  126. $beggar_m = $beggar['METH']['RENDER'];
  127. if (ubRouting::checkGet($corps::URL_AJDT)) {
  128. $corps->corpsListAjax();
  129. }
  130. show_window(__('Available corps'), $corps->$beggar_m());
  131. }
  132. }
  133. }
  134. }
  135. //user management
  136. if ($route == Corps::URL_USER) {
  137. if (ubRouting::checkGet('username')) {
  138. $login = mysql_real_escape_string(ubRouting::get('username'));
  139. $userCorpCheck = $corps->userIsCorporate($login);
  140. if ($userCorpCheck) {
  141. //enterprise user
  142. $corpsControls = $corps->corpPreview($userCorpCheck);
  143. $corpsControls .= wf_Link(Corps::URL_CORPS_EDIT . $userCorpCheck . '&usercallback=' . $login, web_edit_icon() . ' ' . __('Edit'), true, 'ubButton');
  144. $corpsControls .= wf_delimiter();
  145. $corpsControls .= web_UserControls($login);
  146. show_window(__('Corporate user'), $corpsControls);
  147. } else {
  148. //user is private
  149. if (ubRouting::checkPost(array('bindsomelogin', 'bindlogintocorpid'))) {
  150. $corps->userBind(ubRouting::post('bindsomelogin'), ubRouting::post('bindlogintocorpid'));
  151. ubRouting::nav(Corps::URL_USER_MANAGE . ubRouting::post('bindsomelogin'));
  152. }
  153. if (isset($beggar['BU']['F']) and method_exists($corps, $beggar['BU']['F'])) {
  154. $beggar_b = $beggar['BU']['F'];
  155. $corpAttachControls = $corps->$beggar_b($login);
  156. show_window(__('Private user'), $corpAttachControls);
  157. }
  158. if (isset($beggar['BU']['AB']) and method_exists($corps, $beggar['BU']['AB'])) {
  159. $beggar_b = $beggar['BU']['AB'];
  160. $corpAddAttachControls = $corps->$beggar_b($login);
  161. show_window(__('Create') . ' ' . __('Corporate user'), $corpAddAttachControls);
  162. }
  163. }
  164. }
  165. }
  166. if ($route == Corps::URL_SEARCH) {
  167. $searchResults = $corps->searchUsersByCorpName(ubRouting::post('searchcorpname'));
  168. if (!empty($searchResults)) {
  169. show_window(__('Search results'), $searchResults);
  170. }
  171. show_window('', wf_BackLink('?module=usersearch'));
  172. }
  173. } else {
  174. //default list route
  175. ubRouting::nav(Corps::URL_CORPS_LIST);
  176. }
  177. } else {
  178. show_error(__('No license key available'));
  179. }
  180. } else {
  181. show_error(__('This module is disabled'));
  182. }
  183. } else {
  184. show_error(__('Access denied'));
  185. }