index.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Class ReportSelling
  4. */
  5. class ReportSelling {
  6. private $reportData = array();
  7. private $reportParams = array();
  8. /**
  9. * ReportSelling constructor
  10. */
  11. public function __construct() {
  12. $this->reportParams['selling'] = null;
  13. $this->reportParams['idfrom'] = null;
  14. $this->reportParams['idto'] = null;
  15. $this->reportParams['datefrom'] = date('Y-m-01');
  16. $this->reportParams['dateto'] = date("Y-m-d");
  17. }
  18. /**
  19. * @param array $reportParams
  20. */
  21. public function generateReport($reportParams) {
  22. $this->reportParams = $reportParams;
  23. $this->reportData = zb_SellingReport($reportParams);
  24. }
  25. /**
  26. * Renders report
  27. *
  28. * @return string
  29. */
  30. public function render() {
  31. $cells = wf_TableCell(__('Selling'));
  32. $cells .= wf_TableCell(__('Selling count cards'));
  33. $cells .= wf_TableCell(__('Sum'));
  34. $cells .= wf_TableCell(__('Activated'));
  35. $cells .= wf_TableCell(__('For sum'));
  36. $cells .= wf_TableCell(__('Remains'));
  37. $cells .= wf_TableCell(__('For sum'));
  38. $rows = wf_TableRow($cells, 'row1');
  39. $result = $this->panel();
  40. if (!empty($this->reportData)) {
  41. foreach ($this->reportData as $report) {
  42. $cells = wf_TableCell($report['name']);
  43. $cells .= wf_TableCell($report['count_total']);
  44. $cells .= wf_TableCell($report['cash_total']);
  45. $cells .= wf_TableCell($report['count_sel']);
  46. $cells .= wf_TableCell($report['cash_sel']);
  47. $cells .= wf_TableCell($report['count_balance']);
  48. $cells .= wf_TableCell($report['cash_balabce']);
  49. $rows .= wf_TableRow($cells, 'row3');
  50. }
  51. }
  52. $result.= wf_TableBody($rows, '100%', '0', 'sortable');
  53. return ($result);
  54. }
  55. /**
  56. * Criteria for the selling report
  57. *
  58. * @return string
  59. */
  60. public function criteriaForReportRender() {
  61. $inputs = __('Selling') . ' ';
  62. $inputs .= wf_Selector('report[selling]', zb_BuilderSelectSellingData(), '', $this->reportParams['selling'], false);
  63. $inputs .= ' ' . __('ID') . ' ';
  64. $inputs .= ' ' . __('From') . ' ';
  65. $inputs .= wf_TextInput('report[idfrom]', '', $this->reportParams['idfrom'], false, '5');
  66. $inputs .= ' ' . __('To') . ' ';
  67. $inputs .= wf_TextInput('report[idto]', '', $this->reportParams['idto'], false, '5');
  68. $inputs .= ' ' . __('Date') . ' ';
  69. $inputs .= ' ' . __('From') . ' ';
  70. $inputs .= wf_DatePickerPreset('report[datefrom]', $this->reportParams['datefrom']);
  71. $inputs .= ' ' . __('To') . ' ';
  72. $inputs .= wf_DatePickerPreset('report[dateto]', $this->reportParams['dateto']);
  73. $inputs .= wf_Submit('Show');
  74. $result = wf_Form('', 'POST', $inputs, 'glamour');
  75. return $result;
  76. }
  77. /**
  78. * Returns module control panel
  79. *
  80. * @return string
  81. */
  82. private function panel() {
  83. $result = wf_BackLink('?module=report_finance');
  84. return ($result);
  85. }
  86. }
  87. $altCfg = $ubillingConfig->getAlter();
  88. if ($altCfg['PAYMENTCARDS_ENABLED']) {
  89. if (cfr('REPORTFINANCE')) {
  90. $reportSelling = new ReportSelling();
  91. //config data
  92. if (wf_CheckPost(array('report'))) {
  93. $reportSelling->generateReport($_POST['report']);
  94. }
  95. show_window(__('Selling report'), $reportSelling->criteriaForReportRender());
  96. show_window(__('Selling report'), $reportSelling->render());
  97. } else {
  98. show_error(__('You cant control this module'));
  99. }
  100. } else {
  101. show_error(__('This module is disabled'));
  102. }
  103. ?>