| 1 | <?php |
||
| 55 | class Reservation extends DataObject |
||
| 56 | { |
||
| 57 | /** |
||
| 58 | * Time to wait before deleting the discarded cart |
||
| 59 | * Give a string that is parsable by strtotime |
||
| 60 | * |
||
| 61 | * @var string |
||
| 62 | */ |
||
| 63 | private static $delete_after = '+1 day'; |
||
|
1 ignored issue
–
show
|
|||
| 64 | |||
| 65 | private static $db = array( |
||
|
2 ignored issues
–
show
|
|||
| 66 | 'Status' => 'Enum("CART,PENDING,PAID,CANCELED","CART")', |
||
| 67 | 'Title' => 'Varchar(255)', |
||
| 68 | 'Subtotal' => 'Currency', |
||
| 69 | 'Total' => 'Currency', |
||
| 70 | 'Email' => 'Varchar(255)', |
||
| 71 | 'Gateway' => 'Varchar(255)', |
||
| 72 | 'Comments' => 'Text', |
||
| 73 | 'ReservationCode' => 'Varchar(255)' |
||
| 74 | ); |
||
| 75 | |||
| 76 | private static $has_one = array( |
||
| 77 | 'Event' => 'CalendarEvent', |
||
| 78 | 'MainContact' => 'Broarm\EventTickets\Attendee' |
||
| 79 | ); |
||
| 80 | |||
| 81 | private static $has_many = array( |
||
|
2 ignored issues
–
show
|
|||
| 82 | 'Payments' => 'Payment', |
||
| 83 | 'Attendees' => 'Broarm\EventTickets\Attendee.Reservation' |
||
| 84 | ); |
||
| 85 | |||
| 86 | private static $belongs_many_many = array( |
||
|
2 ignored issues
–
show
|
|||
| 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( |
||
|
2 ignored issues
–
show
|
|||
| 95 | 'ReservationCode' => 'Reservation', |
||
| 96 | 'Title' => 'Customer', |
||
| 97 | 'Total.Nice' => 'Total', |
||
| 98 | 'State' => 'Status', |
||
| 99 | 'GatewayNice' => 'Payment method', |
||
| 100 | 'Created.Nice' => 'Date' |
||
| 101 | ); |
||
| 102 | |||
| 103 | public function getCMSFields() |
||
| 120 | |||
| 121 | public function onBeforeWrite() |
||
| 133 | |||
| 134 | public function onBeforeDelete() |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Gets a nice unnamespaced name |
||
| 154 | * |
||
| 155 | * @return string |
||
| 156 | */ |
||
| 157 | public function singular_name() |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Returns the nice gateway title |
||
| 165 | * |
||
| 166 | * @return string |
||
| 167 | */ |
||
| 168 | public function getGatewayNice() { |
||
| 171 | |||
| 172 | /** |
||
| 173 | * Check if the cart is still in cart state and the delete_after time period has been exceeded |
||
| 174 | * |
||
| 175 | * @return bool |
||
| 176 | */ |
||
| 177 | public function isDiscarded() |
||
| 182 | |||
| 183 | /** |
||
| 184 | * Get the full name |
||
| 185 | * |
||
| 186 | * @return string |
||
| 187 | */ |
||
| 188 | public function getName() |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Return the translated state |
||
| 200 | * @return string |
||
| 201 | */ |
||
| 202 | public function getState() |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Get the total by querying the sum of attendee ticket prices |
||
| 209 | * |
||
| 210 | * @return float |
||
| 211 | */ |
||
| 212 | public function calculateTotal() |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Safely change to a state |
||
| 231 | * |
||
| 232 | * @param $state |
||
| 233 | */ |
||
| 234 | public function changeState($state) |
||
| 243 | |||
| 244 | /** |
||
| 245 | * Set the main contact id |
||
| 246 | * |
||
| 247 | * @param $id |
||
| 248 | */ |
||
| 249 | public function setMainContact($id) { |
||
| 253 | |||
| 254 | /** |
||
| 255 | * Create a reservation code |
||
| 256 | * |
||
| 257 | * @return string |
||
| 258 | */ |
||
| 259 | public function createReservationCode() |
||
| 263 | |||
| 264 | /** |
||
| 265 | * Create the folder for the qr code and ticket file |
||
| 266 | * |
||
| 267 | * @return Folder|DataObject|null |
||
| 268 | */ |
||
| 269 | public function fileFolder() |
||
| 273 | |||
| 274 | /** |
||
| 275 | * Generate the qr codes and downloadable pdf |
||
| 276 | */ |
||
| 277 | public function createFiles() |
||
| 286 | |||
| 287 | public function canView($member = null) |
||
| 291 | |||
| 292 | public function canEdit($member = null) |
||
| 296 | |||
| 297 | public function canDelete($member = null) |
||
| 301 | |||
| 302 | public function canCreate($member = null) |
||
| 306 | } |
||
| 307 |
This check marks private properties in classes that are never used. Those properties can be removed.