activity_model.php
3 months ago
agent_meta_model.php
3 months ago
agent_model.php
3 months ago
booking_meta_model.php
3 months ago
booking_model.php
3 months ago
bundle_meta_model.php
3 months ago
bundle_model.php
3 months ago
cart_item_model.php
3 months ago
cart_meta_model.php
3 months ago
cart_model.php
3 months ago
connector_model.php
3 months ago
customer_meta_model.php
3 months ago
customer_model.php
1 month ago
invoice_model.php
3 months ago
join_bundles_services_model.php
3 months ago
location_category_model.php
3 months ago
location_model.php
3 months ago
meta_model.php
3 months ago
model.php
3 months ago
off_period_model.php
3 months ago
order_intent_meta_model.php
3 months ago
order_intent_model.php
3 months ago
order_item_model.php
3 months ago
order_meta_model.php
3 months ago
order_model.php
3 months ago
otp_model.php
3 months ago
payment_request_model.php
3 months ago
process_job_model.php
3 months ago
process_model.php
3 months ago
recurrence_model.php
3 months ago
service_category_model.php
3 months ago
service_meta_model.php
3 months ago
service_model.php
3 months ago
session_model.php
3 months ago
settings_model.php
3 months ago
step_settings_model.php
3 months ago
transaction_intent_model.php
3 months ago
transaction_model.php
3 months ago
transaction_refund_model.php
3 months ago
work_period_model.php
3 months ago
work_period_model.php
82 lines
| 1 | <?php |
| 2 | |
| 3 | class OsWorkPeriodModel extends OsModel { |
| 4 | public $id, |
| 5 | $service_id, |
| 6 | $agent_id, |
| 7 | $location_id, |
| 8 | $start_time, |
| 9 | $end_time, |
| 10 | $week_day, |
| 11 | $custom_date = null, |
| 12 | $chain_id, |
| 13 | $services_agents_table_name, |
| 14 | $updated_at, |
| 15 | $created_at; |
| 16 | |
| 17 | function __construct( $id = false ) { |
| 18 | parent::__construct(); |
| 19 | $this->table_name = LATEPOINT_TABLE_WORK_PERIODS; |
| 20 | $this->services_agents_table_name = LATEPOINT_TABLE_AGENTS_SERVICES; |
| 21 | $this->nice_names = array( |
| 22 | 'start_time' => __( 'Start Time', 'latepoint' ), |
| 23 | 'end_time' => __( 'End Time', 'latepoint' ), |
| 24 | ); |
| 25 | |
| 26 | if ( $id ) { |
| 27 | $this->load_by_id( $id ); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | protected function get_is_active() { |
| 32 | return ( $this->start_time != $this->end_time ); |
| 33 | } |
| 34 | |
| 35 | protected function get_nice_start_time() { |
| 36 | return OsTimeHelper::minutes_to_hours_and_minutes( $this->start_time ); |
| 37 | } |
| 38 | |
| 39 | protected function get_nice_end_time() { |
| 40 | return OsTimeHelper::minutes_to_hours_and_minutes( $this->end_time ); |
| 41 | } |
| 42 | |
| 43 | protected function allowed_params( $role = 'admin' ) { |
| 44 | $allowed_params = array( |
| 45 | 'id', |
| 46 | 'service_id', |
| 47 | 'agent_id', |
| 48 | 'location_id', |
| 49 | 'start_time', |
| 50 | 'end_time', |
| 51 | 'chain_id', |
| 52 | 'custom_date', |
| 53 | 'week_day', |
| 54 | ); |
| 55 | return $allowed_params; |
| 56 | } |
| 57 | |
| 58 | protected function params_to_save( $role = 'admin' ) { |
| 59 | $params_to_save = array( |
| 60 | 'id', |
| 61 | 'service_id', |
| 62 | 'agent_id', |
| 63 | 'location_id', |
| 64 | 'start_time', |
| 65 | 'end_time', |
| 66 | 'chain_id', |
| 67 | 'custom_date', |
| 68 | 'week_day', |
| 69 | ); |
| 70 | return $params_to_save; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | |
| 75 | protected function properties_to_validate() { |
| 76 | $validations = array( |
| 77 | 'week_day' => array( 'presence' ), |
| 78 | ); |
| 79 | return $validations; |
| 80 | } |
| 81 | } |
| 82 |