PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.1.6
LatePoint – Calendar Booking Plugin for Appointments and Events v5.1.6
5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / models / activity_model.php
latepoint / lib / models Last commit date
activity_model.php 1 year ago agent_meta_model.php 1 year ago agent_model.php 1 year ago booking_meta_model.php 1 year ago booking_model.php 1 year ago bundle_model.php 1 year ago cart_item_model.php 1 year ago cart_meta_model.php 1 year ago cart_model.php 1 year ago connector_model.php 1 year ago customer_meta_model.php 1 year ago customer_model.php 1 year ago invoice_model.php 1 year ago join_bundles_services_model.php 1 year ago location_category_model.php 1 year ago location_model.php 1 year ago meta_model.php 1 year ago model.php 1 year ago order_intent_meta_model.php 1 year ago order_intent_model.php 1 year ago order_item_model.php 1 year ago order_meta_model.php 1 year ago order_model.php 1 year ago payment_request_model.php 1 year ago process_job_model.php 1 year ago process_model.php 1 year ago service_category_model.php 1 year ago service_meta_model.php 1 year ago service_model.php 1 year ago session_model.php 1 year ago settings_model.php 1 year ago step_settings_model.php 1 year ago transaction_intent_model.php 1 year ago transaction_model.php 1 year ago transaction_refund_model.php 1 year ago work_period_model.php 1 year ago
activity_model.php
170 lines
1 <?php
2
3 class OsActivityModel extends OsModel{
4 public $id,
5 $agent_id,
6 $order_id,
7 $order_item_id,
8 $booking_id,
9 $service_id,
10 $customer_id,
11 $code,
12 $description,
13 $initiated_by,
14 $initiated_by_id,
15 $updated_at,
16 $created_at;
17
18
19
20
21
22 protected $codes;
23
24 function __construct($id = false){
25 parent::__construct();
26 $this->table_name = LATEPOINT_TABLE_ACTIVITIES;
27 $this->nice_names = array();
28
29 $this->codes = $this->get_codes();
30
31 if($id){
32 $this->load_by_id($id);
33 }
34 }
35
36 protected function get_codes(){
37 return OsActivitiesHelper::get_codes();
38 }
39
40 public function get_link_to_object($label = false){
41 $label = ($label) ? $label : esc_html__('View', 'latepoint');
42 $href = '#';
43 $attrs = '';
44 switch($this->code){
45 case 'customer_created':
46 case 'customer_updated':
47 $attrs = OsCustomerHelper::quick_customer_btn_html($this->customer_id);
48 break;
49 case 'agent_updated':
50 case 'agent_created':
51 $href = OsRouterHelper::build_link(OsRouterHelper::build_route_name('agents', 'edit_form'), array('id' => $this->agent_id) );
52 break;
53 case 'service_updated':
54 case 'service_created':
55 $href = OsRouterHelper::build_link(OsRouterHelper::build_route_name('services', 'edit_form'), array('id' => $this->service_id) );
56 break;
57 default:
58 $attrs = 'data-os-params="' . esc_attr(http_build_query(['id' => $this->id])) . '"
59 data-os-action="' . esc_attr(OsRouterHelper::build_route_name( 'activities', 'view' )) . '"
60 data-os-lightbox-classes="width-800"
61 data-os-after-call="latepoint_init_json_view"
62 data-os-output-target="side-panel"';
63 break;
64 }
65 $link = '<a class="view-activity-link" href="'.esc_url($href).'" '.$attrs.'>'.$label.'</a>';
66 $link = apply_filters('latepoint_activity_link_to_object', $link, $this, $label);
67 return $link;
68 }
69
70
71
72 protected function get_user_link_with_avatar(){
73 $link = '#';
74 $name = 'n/a';
75 $attrs = '';
76 $avatar_url = LATEPOINT_DEFAULT_AVATAR_URL;
77 switch($this->initiated_by){
78 case 'wp_user':
79 case 'admin':
80 case 'custom':
81 $link = get_edit_user_link($this->initiated_by_id);
82 $userdata = get_userdata($this->initiated_by_id);
83 $name = $userdata->display_name;
84 $avatar_url = get_avatar_url($this->initiated_by_id, array('size' => 200));
85 break;
86 case 'agent':
87 $agent = new OsAgentModel($this->initiated_by_id);
88 $link = OsRouterHelper::build_link(OsRouterHelper::build_route_name('agents', 'edit_form'), array('id' => $this->initiated_by_id) );
89 $name = $agent->full_name;
90 $avatar_url = $agent->get_avatar_url();
91 break;
92 case 'customer':
93 $customer = new OsCustomerModel($this->initiated_by_id);
94 $attrs = $attrs = OsCustomerHelper::quick_customer_btn_html($this->initiated_by_id);
95 $name = $customer->full_name;
96 $avatar_url = $customer->get_avatar_url();
97 break;
98 default:
99 $link = '#';
100 $name = 'n/a';
101 $avatar_url = LATEPOINT_IMAGES_URL . 'default-avatar.jpg';
102 break;
103 }
104 $avatar_url = esc_url($avatar_url);
105 $name = esc_html($name);
106 $link = esc_url($link);
107 return "<a class='user-link-with-avatar' target='_blank' href='{$link}' {$attrs}><span class='ula-avatar' style='background-image: url({$avatar_url})'></span><span class='ula-name'>{$name}</span><span class='latepoint-icon latepoint-icon-external-link'></span></a>";
108 }
109
110 public function get_description() {
111 if ($this->code == 'sms_sent') {
112 $this->description = json_decode($this->description, true);
113 }
114
115 return $this->description;
116 }
117
118
119 protected function get_nice_created_at(){
120 $time = strtotime($this->created_at);
121 return gmdate("m/d/y g:i:s A", $time).' (UTC)';
122 }
123
124
125 protected function get_name(){
126 if($this->code && isset($this->codes[$this->code])){
127 return $this->codes[$this->code];
128 }else{
129 return $this->code;
130 }
131 }
132
133 protected function params_to_save($role = 'admin'){
134 $params_to_save = array('id',
135 'agent_id',
136 'order_id',
137 'order_item_id',
138 'booking_id',
139 'service_id',
140 'customer_id',
141 'code',
142 'description',
143 'initiated_by',
144 'initiated_by_id');
145 return $params_to_save;
146 }
147
148 protected function allowed_params($role = 'admin'){
149 $allowed_params = array('id',
150 'agent_id',
151 'booking_id',
152 'order_id',
153 'order_item_id',
154 'service_id',
155 'customer_id',
156 'code',
157 'description',
158 'initiated_by',
159 'initiated_by_id');
160 return $allowed_params;
161 }
162
163
164 protected function properties_to_validate(){
165 $validations = array(
166 'code' => array('presence')
167 );
168 return $validations;
169 }
170 }