| @@ 1187-1232 (lines=46) @@ | ||
| 1184 | ||
| 1185 | // Loop through the years |
|
| 1186 | $y = $dates['year']; |
|
| 1187 | while ( $y <= $dates['year_end'] ) : |
|
| 1188 | ||
| 1189 | if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1190 | $month_start = $dates['m_start']; |
|
| 1191 | $month_end = $dates['m_end']; |
|
| 1192 | } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1193 | $month_start = $dates['m_start']; |
|
| 1194 | $month_end = 12; |
|
| 1195 | } elseif ( $y == $dates['year_end'] ) { |
|
| 1196 | $month_start = 1; |
|
| 1197 | $month_end = $dates['m_end']; |
|
| 1198 | } else { |
|
| 1199 | $month_start = 1; |
|
| 1200 | $month_end = 12; |
|
| 1201 | } |
|
| 1202 | ||
| 1203 | $i = $month_start; |
|
| 1204 | while ( $i <= $month_end ) : |
|
| 1205 | ||
| 1206 | if ( $i == $dates['m_start'] ) { |
|
| 1207 | $d = $dates['day_start']; |
|
| 1208 | } else { |
|
| 1209 | $d = 1; |
|
| 1210 | } |
|
| 1211 | ||
| 1212 | if ( $i == $dates['m_end'] ) { |
|
| 1213 | $num_of_days = $dates['day_end']; |
|
| 1214 | } else { |
|
| 1215 | $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1216 | } |
|
| 1217 | ||
| 1218 | while ( $d <= $num_of_days ) : |
|
| 1219 | $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
| 1220 | $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1221 | if ( ! isset( $donations['sales'][ $date_key ] ) ) { |
|
| 1222 | $donations['sales'][ $date_key ] = 0; |
|
| 1223 | } |
|
| 1224 | $donations['sales'][ $date_key ] += $sale_count; |
|
| 1225 | $total += $sale_count; |
|
| 1226 | $d ++; |
|
| 1227 | endwhile; |
|
| 1228 | $i ++; |
|
| 1229 | endwhile; |
|
| 1230 | ||
| 1231 | $y ++; |
|
| 1232 | endwhile; |
|
| 1233 | ||
| 1234 | $donations['totals'] = $total; |
|
| 1235 | } else { |
|
| @@ 1321-1367 (lines=47) @@ | ||
| 1318 | if ( ! isset( $earnings['earnings'] ) ) { |
|
| 1319 | $earnings['earnings'] = array(); |
|
| 1320 | } |
|
| 1321 | while ( $y <= $dates['year_end'] ) : |
|
| 1322 | ||
| 1323 | if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1324 | $month_start = $dates['m_start']; |
|
| 1325 | $month_end = $dates['m_end']; |
|
| 1326 | } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1327 | $month_start = $dates['m_start']; |
|
| 1328 | $month_end = 12; |
|
| 1329 | } elseif ( $y == $dates['year_end'] ) { |
|
| 1330 | $month_start = 1; |
|
| 1331 | $month_end = $dates['m_end']; |
|
| 1332 | } else { |
|
| 1333 | $month_start = 1; |
|
| 1334 | $month_end = 12; |
|
| 1335 | } |
|
| 1336 | ||
| 1337 | $i = $month_start; |
|
| 1338 | while ( $i <= $month_end ) : |
|
| 1339 | ||
| 1340 | if ( $i == $dates['m_start'] ) { |
|
| 1341 | $d = $dates['day_start']; |
|
| 1342 | } else { |
|
| 1343 | $d = 1; |
|
| 1344 | } |
|
| 1345 | ||
| 1346 | if ( $i == $dates['m_end'] ) { |
|
| 1347 | $num_of_days = $dates['day_end']; |
|
| 1348 | } else { |
|
| 1349 | $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1350 | } |
|
| 1351 | ||
| 1352 | while ( $d <= $num_of_days ) : |
|
| 1353 | $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
| 1354 | $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1355 | if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
| 1356 | $earnings['earnings'][ $date_key ] = 0; |
|
| 1357 | } |
|
| 1358 | $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
| 1359 | $total += $earnings_stat; |
|
| 1360 | $d ++; |
|
| 1361 | endwhile; |
|
| 1362 | ||
| 1363 | $i ++; |
|
| 1364 | endwhile; |
|
| 1365 | ||
| 1366 | $y ++; |
|
| 1367 | endwhile; |
|
| 1368 | ||
| 1369 | $earnings['totals'] = $total; |
|
| 1370 | } else { |
|