index.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. $altCfg = $ubillingConfig->getAlter();
  3. if (@$altCfg['SW_CASH_ENABLED']) {
  4. if (cfr('SWCASH')) {
  5. set_time_limit(0);
  6. $swCash = new SwitchCash();
  7. //creating new financial data for some switch
  8. if (ubRouting::checkPost($swCash::PROUTE_CREATE)) {
  9. $creationResult = $swCash->catchCreate();
  10. if (empty($creationResult)) {
  11. ubRouting::nav($swCash::URL_ME . '&' . $swCash::ROUTE_EDIT . '=' . ubRouting::post($swCash::PROUTE_CREATE));
  12. } else {
  13. show_error($creationResult);
  14. }
  15. }
  16. //editing existing financial data for some switch
  17. if (ubRouting::checkPost($swCash::PROUTE_SAVE)) {
  18. $saveResult = $swCash->catchSave();
  19. if (empty($saveResult)) {
  20. ubRouting::nav($swCash::URL_ME . '&' . $swCash::ROUTE_EDIT . '=' . ubRouting::post($swCash::PROUTE_SAVE));
  21. } else {
  22. show_error($saveResult);
  23. }
  24. }
  25. //rendering create/edit forms
  26. if (ubRouting::checkGet($swCash::ROUTE_EDIT)) {
  27. $switchId = ubRouting::get($swCash::ROUTE_EDIT, 'int');
  28. if (!$swCash->haveFinancialData($switchId)) {
  29. //creation form
  30. show_window(__('Create') . ' ' . __('Financial data'), $swCash->renderCreateForm($switchId));
  31. show_window('', wf_BackLink($swCash::URL_SWITCHPROFILE . $switchId));
  32. } else {
  33. //editing form
  34. show_window(__('Edit') . ' ' . __('Financial data'), $swCash->renderEditForm($switchId));
  35. show_window('', wf_BackLink($swCash::URL_SWITCHPROFILE . $switchId));
  36. }
  37. }
  38. //rendering basic report
  39. if (ubRouting::checkGet($swCash::ROUTE_REPORT)) {
  40. $excelExportUrl = $swCash::URL_ME . '&' . $swCash::ROUTE_REPORT . '=true&' . $swCash::ROUTE_EXCEL . '=true';
  41. $excelControl = wf_Link($excelExportUrl, wf_img('skins/excel.gif', __('Export to excel')));
  42. show_window(__('Switches profitability') . ' ' . $excelControl, $swCash->renderBasicReport());
  43. }
  44. //rendering assigned users report
  45. if (ubRouting::checkGet($swCash::ROUTE_USERS)) {
  46. show_window(__('Users'), $swCash->renderUsersReport(ubRouting::get($swCash::ROUTE_USERS)));
  47. $backUrl = $swCash::URL_ME . '&' . $swCash::ROUTE_REPORT . '=true';
  48. show_window('', wf_BackLink($backUrl));
  49. }
  50. } else {
  51. show_error(__('Access denied'));
  52. }
  53. } else {
  54. show_error(__('This module is disabled'));
  55. }