| @@ 39-56 (lines=18) @@ | ||
| 36 | * @return int |
|
| 37 | * @throws \EE_Error |
|
| 38 | */ |
|
| 39 | public static function spacesRemainingConsideringTickets($wpdb_row, $request, $controller) |
|
| 40 | { |
|
| 41 | if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) { |
|
| 42 | $dtt_obj = EEM_Datetime::instance()->get_one_by_ID($wpdb_row['Datetime.DTT_ID']); |
|
| 43 | } else { |
|
| 44 | $dtt_obj = null; |
|
| 45 | } |
|
| 46 | if ($dtt_obj instanceof EE_Datetime) { |
|
| 47 | return $dtt_obj->spaces_remaining(true); |
|
| 48 | } else { |
|
| 49 | throw new \EE_Error( |
|
| 50 | sprintf( |
|
| 51 | __( |
|
| 52 | // @codingStandardsIgnoreStart |
|
| 53 | 'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found', |
|
| 54 | // @codingStandardsIgnoreEnd |
|
| 55 | 'event_espresso' |
|
| 56 | ), |
|
| 57 | $wpdb_row['Datetime.DTT_ID'], |
|
| 58 | print_r($wpdb_row, true) |
|
| 59 | ) |
|
| @@ 41-64 (lines=24) @@ | ||
| 38 | * @return int |
|
| 39 | * @throws EE_Error |
|
| 40 | */ |
|
| 41 | public static function optimumSalesAtStart($wpdb_row, $request, $controller) |
|
| 42 | { |
|
| 43 | if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID'])) { |
|
| 44 | $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
| 45 | } else { |
|
| 46 | $event_obj = null; |
|
| 47 | } |
|
| 48 | if ($event_obj instanceof EE_Event) { |
|
| 49 | return $event_obj->total_available_spaces(); |
|
| 50 | } else { |
|
| 51 | throw new EE_Error( |
|
| 52 | sprintf( |
|
| 53 | __( |
|
| 54 | // @codingStandardsIgnoreStart |
|
| 55 | 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', |
|
| 56 | // @codingStandardsIgnoreEnd |
|
| 57 | 'event_espresso' |
|
| 58 | ), |
|
| 59 | $wpdb_row['Event_CPT.ID'], |
|
| 60 | print_r($wpdb_row, true) |
|
| 61 | ) |
|
| 62 | ); |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| 66 | ||
| 67 | ||
| @@ 79-102 (lines=24) @@ | ||
| 76 | * @return int |
|
| 77 | * @throws EE_Error |
|
| 78 | */ |
|
| 79 | public static function optimumSalesNow($wpdb_row, $request, $controller) |
|
| 80 | { |
|
| 81 | if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID'])) { |
|
| 82 | $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
| 83 | } else { |
|
| 84 | $event_obj = null; |
|
| 85 | } |
|
| 86 | if ($event_obj instanceof EE_Event) { |
|
| 87 | return $event_obj->total_available_spaces(true); |
|
| 88 | } else { |
|
| 89 | throw new EE_Error( |
|
| 90 | sprintf( |
|
| 91 | __( |
|
| 92 | // @codingStandardsIgnoreStart |
|
| 93 | 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', |
|
| 94 | // @codingStandardsIgnoreEnd |
|
| 95 | 'event_espresso' |
|
| 96 | ), |
|
| 97 | $wpdb_row['Event_CPT.ID'], |
|
| 98 | print_r($wpdb_row, true) |
|
| 99 | ) |
|
| 100 | ); |
|
| 101 | } |
|
| 102 | } |
|
| 103 | ||
| 104 | ||
| 105 | ||
| @@ 116-139 (lines=24) @@ | ||
| 113 | * @return int |
|
| 114 | * @throws EE_Error |
|
| 115 | */ |
|
| 116 | public static function spacesRemaining($wpdb_row, $request, $controller) |
|
| 117 | { |
|
| 118 | if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID'])) { |
|
| 119 | $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
| 120 | } else { |
|
| 121 | $event_obj = null; |
|
| 122 | } |
|
| 123 | if ($event_obj instanceof EE_Event) { |
|
| 124 | return $event_obj->spaces_remaining_for_sale(); |
|
| 125 | } else { |
|
| 126 | throw new EE_Error( |
|
| 127 | sprintf( |
|
| 128 | __( |
|
| 129 | // @codingStandardsIgnoreStart |
|
| 130 | 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', |
|
| 131 | // @codingStandardsIgnoreEnd |
|
| 132 | 'event_espresso' |
|
| 133 | ), |
|
| 134 | $wpdb_row['Event_CPT.ID'], |
|
| 135 | print_r($wpdb_row, true) |
|
| 136 | ) |
|
| 137 | ); |
|
| 138 | } |
|
| 139 | } |
|
| 140 | ||
| 141 | ||
| 142 | ||