| @@ 41-62 (lines=22) @@ | ||
| 38 | * @return int |
|
| 39 | * @throws EE_Error |
|
| 40 | */ |
|
| 41 | public static function optimumSalesAtStart($wpdb_row, $request, $controller) |
|
| 42 | { |
|
| 43 | $event_obj = null; |
|
| 44 | if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
| 45 | $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
| 46 | } |
|
| 47 | if ($event_obj instanceof EE_Event) { |
|
| 48 | return $event_obj->total_available_spaces(); |
|
| 49 | } |
|
| 50 | throw new EE_Error( |
|
| 51 | sprintf( |
|
| 52 | __( |
|
| 53 | // @codingStandardsIgnoreStart |
|
| 54 | 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', |
|
| 55 | // @codingStandardsIgnoreEnd |
|
| 56 | 'event_espresso' |
|
| 57 | ), |
|
| 58 | $wpdb_row['Event_CPT.ID'], |
|
| 59 | print_r($wpdb_row, true) |
|
| 60 | ) |
|
| 61 | ); |
|
| 62 | } |
|
| 63 | ||
| 64 | ||
| 65 | ||
| @@ 77-98 (lines=22) @@ | ||
| 74 | * @return int |
|
| 75 | * @throws EE_Error |
|
| 76 | */ |
|
| 77 | public static function optimumSalesNow($wpdb_row, $request, $controller) |
|
| 78 | { |
|
| 79 | $event_obj = null; |
|
| 80 | if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
| 81 | $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
| 82 | } |
|
| 83 | if ($event_obj instanceof EE_Event) { |
|
| 84 | return $event_obj->total_available_spaces(true); |
|
| 85 | } |
|
| 86 | throw new EE_Error( |
|
| 87 | sprintf( |
|
| 88 | __( |
|
| 89 | // @codingStandardsIgnoreStart |
|
| 90 | 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', |
|
| 91 | // @codingStandardsIgnoreEnd |
|
| 92 | 'event_espresso' |
|
| 93 | ), |
|
| 94 | $wpdb_row['Event_CPT.ID'], |
|
| 95 | print_r($wpdb_row, true) |
|
| 96 | ) |
|
| 97 | ); |
|
| 98 | } |
|
| 99 | ||
| 100 | ||
| 101 | ||
| @@ 112-133 (lines=22) @@ | ||
| 109 | * @return int |
|
| 110 | * @throws EE_Error |
|
| 111 | */ |
|
| 112 | public static function spacesRemaining($wpdb_row, $request, $controller) |
|
| 113 | { |
|
| 114 | $event_obj = null; |
|
| 115 | if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
| 116 | $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
| 117 | } |
|
| 118 | if ($event_obj instanceof EE_Event) { |
|
| 119 | return $event_obj->spaces_remaining_for_sale(); |
|
| 120 | } |
|
| 121 | throw new EE_Error( |
|
| 122 | sprintf( |
|
| 123 | __( |
|
| 124 | // @codingStandardsIgnoreStart |
|
| 125 | 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', |
|
| 126 | // @codingStandardsIgnoreEnd |
|
| 127 | 'event_espresso' |
|
| 128 | ), |
|
| 129 | $wpdb_row['Event_CPT.ID'], |
|
| 130 | print_r($wpdb_row, true) |
|
| 131 | ) |
|
| 132 | ); |
|
| 133 | } |
|
| 134 | ||
| 135 | ||
| 136 | ||