index.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $funds = new FundsFlow();
  10. //all that we need
  11. $corpsData = $corps->getCorps();
  12. $corpUsers = $corps->getUsers();
  13. $allUserContracts = zb_UserGetAllContracts();
  14. $allUsersCash = zb_UserGetAllBalance();
  15. $allUserTariffs = zb_TariffsGetAllUsers();
  16. $allTariffPrices = zb_TariffGetPricesAll();
  17. $rows = '';
  18. $count = 0;
  19. //showing date search form
  20. show_window(__('Corporate users') . ' - ' . __('Funds flow'), $funds->renderCorpsFlowsDateForm());
  21. if (!ubRouting::checkPost(array('yearsel', 'monthsel'))) {
  22. $needYear = curyear();
  23. $needMonth = date("m");
  24. } else {
  25. $needYear = ubRouting::post('yearsel');
  26. $needMonth = ubRouting::post('monthsel');
  27. }
  28. //setting date filter
  29. $date = $needYear . '-' . $needMonth . '-';
  30. if (!empty($corpUsers)) {
  31. $rows = $funds->renderCorpsFlowsHeaders($needYear, $needMonth);
  32. //contragent filter
  33. if (ubRouting::checkPost('agentsel')) {
  34. $agentFilter = ubRouting::post('agentsel');
  35. $allassigns = zb_AgentAssignGetAllData();
  36. $allassignsStrict = zb_AgentAssignStrictGetAllData();
  37. $alladdress = zb_AddressGetFulladdresslistCached();
  38. } else {
  39. $agentFilter = '';
  40. }
  41. $funds->setDateFilter($date);
  42. $allCashFlows = $funds->getAllCashFlows();
  43. foreach ($corpUsers as $eachlogin => $eachcorpid) {
  44. $count++;
  45. if (isset($allCashFlows[$eachlogin])) {
  46. $dateFunds = $allCashFlows[$eachlogin];
  47. } else {
  48. $dateFunds = array();
  49. }
  50. if (!$agentFilter) {
  51. $rows .= $funds->renderCorpsFlows($count, $dateFunds, $corpsData, $corpUsers, $allUserContracts, $allUsersCash, $allUserTariffs, $allTariffPrices);
  52. } else {
  53. @$userAddress = $alladdress[$eachlogin];
  54. $assigned_agent = zb_AgentAssignCheckLoginFast($eachlogin, $allassigns, $userAddress, $allassignsStrict);
  55. if ($assigned_agent == $agentFilter) {
  56. $rows .= $funds->renderCorpsFlows($count, $dateFunds, $corpsData, $corpUsers, $allUserContracts, $allUsersCash, $allUserTariffs, $allTariffPrices);
  57. }
  58. }
  59. }
  60. $rows .= $funds->renderCorpsFlowsTotal();
  61. $report = wf_TableBody($rows, '100%', 0, '');
  62. show_window(__('Report'), $report);
  63. } else {
  64. show_warning(__('Nothing found'));
  65. }
  66. } else {
  67. show_error(__('No license key available'));
  68. }
  69. } else {
  70. show_error(__('This module is disabled'));
  71. }
  72. } else {
  73. show_error(__('Access denied'));
  74. }