| 1 | <?php |
||
| 54 | class Reservation extends DataObject |
||
| 55 | { |
||
| 56 | /** |
||
| 57 | * Time to wait before deleting the discarded cart |
||
| 58 | * Give a string that is parsable by strtotime |
||
| 59 | * |
||
| 60 | * @var string |
||
| 61 | */ |
||
| 62 | private static $delete_after = '+1 week'; |
||
|
1 ignored issue
–
show
|
|||
| 63 | |||
| 64 | private static $db = array( |
||
|
2 ignored issues
–
show
|
|||
| 65 | 'Status' => 'Enum("CART,PENDING,PAID,CANCELED","CART")', |
||
| 66 | 'Title' => 'Varchar(255)', |
||
| 67 | 'Subtotal' => 'Currency', |
||
| 68 | 'Total' => 'Currency', |
||
| 69 | 'Email' => 'Varchar(255)', |
||
| 70 | 'Gateway' => 'Varchar(255)', |
||
| 71 | 'Comments' => 'Text', |
||
| 72 | 'ReservationCode' => 'Varchar(255)' |
||
| 73 | ); |
||
| 74 | |||
| 75 | private static $has_one = array( |
||
| 76 | 'Event' => 'CalendarEvent', |
||
| 77 | //'TicketFile' => 'File', |
||
| 78 | 'MainContact' => 'Broarm\EventTickets\Attendee' |
||
| 79 | ); |
||
| 80 | |||
| 81 | private static $has_many = array( |
||
|
1 ignored issue
–
show
|
|||
| 82 | 'Payments' => 'Payment', |
||
| 83 | 'Attendees' => 'Broarm\EventTickets\Attendee.Reservation' |
||
| 84 | ); |
||
| 85 | |||
| 86 | private static $belongs_many_many = array( |
||
| 87 | 'PriceModifiers' => 'Broarm\EventTickets\PriceModifier' |
||
| 88 | ); |
||
| 89 | |||
| 90 | private static $indexes = array( |
||
|
2 ignored issues
–
show
|
|||
| 91 | 'ReservationCode' => 'unique("ReservationCode")' |
||
| 92 | ); |
||
| 93 | |||
| 94 | private static $summary_fields = array( |
||
|
1 ignored issue
–
show
|
|||
| 95 | 'Title' => 'Customer', |
||
| 96 | 'Total.Nice' => 'Total', |
||
| 97 | 'State' => 'Status' |
||
| 98 | ); |
||
| 99 | |||
| 100 | public function getCMSFields() |
||
| 117 | |||
| 118 | public function onBeforeWrite() |
||
| 130 | |||
| 131 | public function onBeforeDelete() |
||
| 153 | |||
| 154 | public function singular_name() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Check if the cart is still in cart state and the delete_after time period has been exceeded |
||
| 162 | * |
||
| 163 | * @return bool |
||
| 164 | */ |
||
| 165 | public function isDiscarded() |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Get the full name |
||
| 173 | * |
||
| 174 | * @return string |
||
| 175 | */ |
||
| 176 | public function getName() |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Return the translated state |
||
| 188 | * @return string |
||
| 189 | */ |
||
| 190 | public function getState() |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Get the total by querying the sum of attendee ticket prices |
||
| 197 | * |
||
| 198 | * @return float |
||
| 199 | */ |
||
| 200 | public function calculateTotal() |
||
| 216 | |||
| 217 | /** |
||
| 218 | * Safely change to a state |
||
| 219 | * |
||
| 220 | * @param $state |
||
| 221 | */ |
||
| 222 | public function changeState($state) |
||
| 231 | |||
| 232 | /** |
||
| 233 | * Set the main contact id |
||
| 234 | * |
||
| 235 | * @param $id |
||
| 236 | */ |
||
| 237 | public function setMainContact($id) { |
||
| 241 | |||
| 242 | /** |
||
| 243 | * Create a reservation code |
||
| 244 | * |
||
| 245 | * @return string |
||
| 246 | */ |
||
| 247 | public function createReservationCode() |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Create the folder for the qr code and ticket file |
||
| 254 | * |
||
| 255 | * @return Folder|DataObject|null |
||
| 256 | */ |
||
| 257 | public function fileFolder() |
||
| 261 | |||
| 262 | /** |
||
| 263 | * Generate the qr codes and downloadable pdf |
||
| 264 | */ |
||
| 265 | public function createFiles() |
||
| 274 | |||
| 275 | public function canView($member = null) |
||
| 279 | |||
| 280 | public function canEdit($member = null) |
||
| 284 | |||
| 285 | public function canDelete($member = null) |
||
| 289 | |||
| 290 | public function canCreate($member = null) |
||
| 294 | } |
||
| 295 |
This check marks private properties in classes that are never used. Those properties can be removed.