|
@@ 490-541 (lines=52) @@
|
| 487 |
|
* @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
| 488 |
|
* (i.e. RAP) |
| 489 |
|
*/ |
| 490 |
|
public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
| 491 |
|
{ |
| 492 |
|
global $wpdb; |
| 493 |
|
$registration_table = $wpdb->prefix . 'esp_registration'; |
| 494 |
|
$event_table = $wpdb->posts; |
| 495 |
|
$sql_date = date("Y-m-d H:i:s", strtotime($period)); |
| 496 |
|
//prepare the query interval for displaying offset |
| 497 |
|
$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
| 498 |
|
//inner date query |
| 499 |
|
$inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
| 500 |
|
$inner_where = " WHERE"; |
| 501 |
|
//exclude events not authored by user if permissions in effect |
| 502 |
|
if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
| 503 |
|
$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
| 504 |
|
$inner_where .= " post_author = " . get_current_user_id() . " AND"; |
| 505 |
|
} |
| 506 |
|
$inner_where .= " REG_date >= '$sql_date'"; |
| 507 |
|
$inner_date_query .= $inner_where; |
| 508 |
|
//start main query |
| 509 |
|
$select = "SELECT DATE($query_interval) as Registration_REG_date, "; |
| 510 |
|
$join = ''; |
| 511 |
|
$join_parts = array(); |
| 512 |
|
$select_parts = array(); |
| 513 |
|
//loop through registration stati to do parts for each status. |
| 514 |
|
foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
| 515 |
|
if ($STS_ID === EEM_Registration::status_id_incomplete) { |
| 516 |
|
continue; |
| 517 |
|
} |
| 518 |
|
$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
| 519 |
|
$join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'"; |
| 520 |
|
} |
| 521 |
|
//setup the selects |
| 522 |
|
$select .= implode(', ', $select_parts); |
| 523 |
|
$select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
| 524 |
|
//setup the joins |
| 525 |
|
$join .= implode(" LEFT JOIN ", $join_parts); |
| 526 |
|
//now let's put it all together |
| 527 |
|
$query = $select . $join . ' GROUP BY Registration_REG_date'; |
| 528 |
|
//and execute it |
| 529 |
|
$results = $wpdb->get_results($query, ARRAY_A); |
| 530 |
|
return $results; |
| 531 |
|
} |
| 532 |
|
|
| 533 |
|
|
| 534 |
|
|
| 535 |
|
/** |
| 536 |
|
* get the number of registrations per event for the Registration Admin page Reports Tab |
| 537 |
|
* |
| 538 |
|
* @access public |
| 539 |
|
* @param $period string which can be passed to php's strtotime function (eg "-1 month") |
| 540 |
|
* @return stdClass[] each with properties event_name, reg_limit, and total |
| 541 |
|
*/ |
| 542 |
|
public function get_registrations_per_event_report($period = '-1 month') |
| 543 |
|
{ |
| 544 |
|
$date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
@@ 578-626 (lines=49) @@
|
| 575 |
|
* @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
| 576 |
|
* (i.e. RAP) |
| 577 |
|
*/ |
| 578 |
|
public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
| 579 |
|
{ |
| 580 |
|
global $wpdb; |
| 581 |
|
$registration_table = $wpdb->prefix . 'esp_registration'; |
| 582 |
|
$event_table = $wpdb->posts; |
| 583 |
|
$sql_date = date("Y-m-d H:i:s", strtotime($period)); |
| 584 |
|
//inner date query |
| 585 |
|
$inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
| 586 |
|
$inner_where = " WHERE"; |
| 587 |
|
//exclude events not authored by user if permissions in effect |
| 588 |
|
if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
| 589 |
|
$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
| 590 |
|
$inner_where .= " post_author = " . get_current_user_id() . " AND"; |
| 591 |
|
} |
| 592 |
|
$inner_where .= " REG_date >= '$sql_date'"; |
| 593 |
|
$inner_date_query .= $inner_where; |
| 594 |
|
//build main query |
| 595 |
|
$select = "SELECT Event.post_title as Registration_Event, "; |
| 596 |
|
$join = ''; |
| 597 |
|
$join_parts = array(); |
| 598 |
|
$select_parts = array(); |
| 599 |
|
//loop through registration stati to do parts for each status. |
| 600 |
|
foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
| 601 |
|
if ($STS_ID === EEM_Registration::status_id_incomplete) { |
| 602 |
|
continue; |
| 603 |
|
} |
| 604 |
|
$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
| 605 |
|
$join_parts[] = "$registration_table AS $STS_code ON $STS_code.EVT_ID = dates.EVT_ID AND $STS_code.STS_ID = '$STS_ID' AND $STS_code.REG_date = dates.REG_date"; |
| 606 |
|
} |
| 607 |
|
//setup the selects |
| 608 |
|
$select .= implode(', ', $select_parts); |
| 609 |
|
$select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
| 610 |
|
//setup remaining joins |
| 611 |
|
$join .= implode(" LEFT JOIN ", $join_parts); |
| 612 |
|
//now put it all together |
| 613 |
|
$query = $select . $join . ' GROUP BY Registration_Event'; |
| 614 |
|
//and execute |
| 615 |
|
$results = $wpdb->get_results($query, ARRAY_A); |
| 616 |
|
return $results; |
| 617 |
|
} |
| 618 |
|
|
| 619 |
|
|
| 620 |
|
|
| 621 |
|
/** |
| 622 |
|
* Returns the EE_Registration of the primary attendee on the transaction id provided |
| 623 |
|
* |
| 624 |
|
* @param int $TXN_ID |
| 625 |
|
* @return EE_Registration |
| 626 |
|
*/ |
| 627 |
|
public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
| 628 |
|
{ |
| 629 |
|
if ( ! $TXN_ID) { |