| @@ 107-148 (lines=42) @@ | ||
| 104 | } |
|
| 105 | } |
|
| 106 | ||
| 107 | protected function statistic($type) |
|
| 108 | { |
|
| 109 | if (!count(self::$payment_array)) { |
|
| 110 | $data = $this->getCustomQuery()->execute(); |
|
| 111 | if ($data) { |
|
| 112 | $array = array(); |
|
| 113 | foreach ($data as $row) { |
|
| 114 | if ($row["Amount"] && $row["Status"] == "Success") { |
|
| 115 | self::$payment_array[] = $row["Amount"]; |
|
| 116 | } |
|
| 117 | } |
|
| 118 | } |
|
| 119 | } |
|
| 120 | if (count(self::$payment_array)) { |
|
| 121 | switch ($type) { |
|
| 122 | case "count": |
|
| 123 | return count(self::$payment_array); |
|
| 124 | break; |
|
| 125 | case "sum": |
|
| 126 | return array_sum(self::$payment_array); |
|
| 127 | break; |
|
| 128 | case "avg": |
|
| 129 | return array_sum(self::$payment_array) / count(self::$payment_array); |
|
| 130 | break; |
|
| 131 | case "min": |
|
| 132 | asort(self::$payment_array); |
|
| 133 | foreach (self::$payment_array as $item) { |
|
| 134 | return $item; |
|
| 135 | } |
|
| 136 | break; |
|
| 137 | case "max": |
|
| 138 | arsort(self::$payment_array); |
|
| 139 | foreach (self::$payment_array as $item) { |
|
| 140 | return $item; |
|
| 141 | } |
|
| 142 | break; |
|
| 143 | default: |
|
| 144 | user_error("Wrong statistic type speficied in PaymentsReport::statistic", E_USER_ERROR); |
|
| 145 | } |
|
| 146 | } |
|
| 147 | return -1; |
|
| 148 | } |
|
| 149 | ||
| 150 | public function processform() |
|
| 151 | { |
|
| @@ 180-221 (lines=42) @@ | ||
| 177 | } |
|
| 178 | } |
|
| 179 | ||
| 180 | protected function statistic($type) |
|
| 181 | { |
|
| 182 | if (!count(self::$sales_array)) { |
|
| 183 | $data = $this->getCustomQuery()->execute(); |
|
| 184 | if ($data) { |
|
| 185 | $array = array(); |
|
| 186 | foreach ($data as $row) { |
|
| 187 | if ($row["RealPayments"]) { |
|
| 188 | self::$sales_array[] = $row["RealPayments"]; |
|
| 189 | } |
|
| 190 | } |
|
| 191 | } |
|
| 192 | } |
|
| 193 | if (count(self::$sales_array)) { |
|
| 194 | switch ($type) { |
|
| 195 | case "count": |
|
| 196 | return count(self::$sales_array); |
|
| 197 | break; |
|
| 198 | case "sum": |
|
| 199 | return array_sum(self::$sales_array); |
|
| 200 | break; |
|
| 201 | case "avg": |
|
| 202 | return array_sum(self::$sales_array) / count(self::$sales_array); |
|
| 203 | break; |
|
| 204 | case "min": |
|
| 205 | asort(self::$sales_array); |
|
| 206 | foreach (self::$sales_array as $item) { |
|
| 207 | return $item; |
|
| 208 | } |
|
| 209 | break; |
|
| 210 | case "max": |
|
| 211 | arsort(self::$sales_array); |
|
| 212 | foreach (self::$sales_array as $item) { |
|
| 213 | return $item; |
|
| 214 | } |
|
| 215 | break; |
|
| 216 | default: |
|
| 217 | user_error("Wrong statistic type speficied in SalesReport::statistic", E_USER_ERROR); |
|
| 218 | } |
|
| 219 | } |
|
| 220 | return -1; |
|
| 221 | } |
|
| 222 | ||
| 223 | public function processform() |
|
| 224 | { |
|