index.php 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. if (cfr('WAREHOUSE')) {
  3. if ($ubillingConfig->getAlterParam('WAREHOUSE_ENABLED')) {
  4. $greed = new Avarice();
  5. $avidity = $greed->runtime('WAREHOUSE');
  6. if (!empty($avidity)) {
  7. $salesReport = new WHSales();
  8. //new report creation
  9. if (ubRouting::checkPost($salesReport::PROUTE_NEWREPORT)) {
  10. $creationResult = $salesReport->createReport(ubRouting::post($salesReport::PROUTE_NEWREPORT));
  11. if (empty($creationResult)) {
  12. ubRouting::nav($salesReport::URL_ME);
  13. } else {
  14. show_error(__('Something went wrong') . ': ' . $creationResult);
  15. }
  16. }
  17. //existing report deletion
  18. if (ubRouting::checkGet($salesReport::ROUTE_REPORT_DEL)) {
  19. $deletionResult = $salesReport->deleteReport(ubRouting::get($salesReport::ROUTE_REPORT_DEL));
  20. if (empty($deletionResult)) {
  21. ubRouting::nav($salesReport::URL_ME);
  22. } else {
  23. show_error(__('Something went wrong') . ': ' . $deletionResult);
  24. }
  25. }
  26. //editing existing report
  27. if (ubRouting::checkGet($salesReport::ROUTE_REPORT_EDIT)) {
  28. $reportIdToEdit = ubRouting::get($salesReport::ROUTE_REPORT_EDIT);
  29. $reportEditUrl = $salesReport::URL_ME . '&' . $salesReport::ROUTE_REPORT_EDIT . '=' . ubRouting::get($salesReport::ROUTE_REPORT_EDIT);
  30. //deleting some itemtype record
  31. if (ubRouting::checkGet($salesReport::ROUTE_ITEM_DEL)) {
  32. $salesReport->deleteReportItem(ubRouting::get($salesReport::ROUTE_REPORT_EDIT), ubRouting::get($salesReport::ROUTE_ITEM_DEL));
  33. ubRouting::nav($reportEditUrl);
  34. }
  35. //adding some itemtype to report
  36. if (ubRouting::checkPost(array($salesReport::PROUTE_NEWREPORTITEM, $salesReport::PROUTE_NEWREPORTITEMID))) {
  37. $reportAddId = ubRouting::post($salesReport::PROUTE_NEWREPORTITEM);
  38. $reportAddItemId = ubRouting::post($salesReport::PROUTE_NEWREPORTITEMID);
  39. $itemAppendResult = $salesReport->addReportItem($reportAddId, $reportAddItemId);
  40. if (empty($itemAppendResult)) {
  41. ubRouting::nav($reportEditUrl);
  42. } else {
  43. show_error($itemAppendResult);
  44. }
  45. }
  46. //renaming existing report
  47. if (ubRouting::checkGet($salesReport::ROUTE_REPORT_EDIT) AND ubRouting::checkPost($salesReport::PROUTE_EDITREPORTNAME)) {
  48. $salesReport->renameReport($reportIdToEdit, ubRouting::post($salesReport::PROUTE_EDITREPORTNAME));
  49. ubRouting::nav($reportEditUrl);
  50. }
  51. show_window(__('Edit report') . ': ' . $salesReport->getReportName($reportIdToEdit), $salesReport->renderEditForm($reportIdToEdit));
  52. show_window('', wf_BackLink($salesReport::URL_ME));
  53. }
  54. //rendering available reports list
  55. if (!ubRouting::checkGet($salesReport::ROUTE_REPORT_EDIT) AND ! ubRouting::checkGet($salesReport::ROUTE_REPORT_RENDER)) {
  56. $creationControl = $salesReport->renderCreationForm();
  57. show_window(__('Available reports') . ' ' . $creationControl, $salesReport->renderReportsList());
  58. }
  59. //rendering existing report
  60. if (ubRouting::checkGet($salesReport::ROUTE_REPORT_RENDER)) {
  61. $reportIdToRender = ubRouting::get($salesReport::ROUTE_REPORT_RENDER);
  62. show_window(__('Sales report') . ': ' . $salesReport->getReportName($reportIdToRender), $salesReport->renderReport($reportIdToRender));
  63. }
  64. zb_BillingStats();
  65. } else {
  66. show_error(__('No license key available'));
  67. }
  68. } else {
  69. show_error(__('This module is disabled'));
  70. }
  71. } else {
  72. show_error(__('Permission denied'));
  73. }