public function dashboard() {
global $wpdb;
$cases = $wpdb->get_results(
"SELECT *
FROM {$wpdb->prefix}odinn_cases
ORDER BY id DESC"
);
echo '
';
echo '
Odinn Case Manager
';
echo '
';
echo '';
echo '';
echo '| Case ID | ';
echo 'Animal | ';
echo 'Owner | ';
echo 'Status | ';
echo 'Action | ';
echo '
';
echo '';
echo '';
if ($cases) {
foreach ($cases as $case) {
echo '';
echo '| ' .
esc_html($case->case_id) .
' | ';
echo '' .
esc_html($case->animal_name) .
' | ';
echo '' .
esc_html($case->owner_name) .
' | ';
echo '' .
esc_html($case->status) .
' | ';
echo '';
echo 'No cases found | ';
echo '
';
}
echo '';
echo '
';
echo '
';
}
public function add_case() {
global $wpdb;
$is_admin = current_user_can('manage_options');
$is_case_manager =
current_user_can('ocm_case_manager');
if (
!($is_admin || $is_case_manager)
) {
echo '';
echo '
You do not have permission to create cases.
';
echo '
';
return;
}
if (
isset($_POST['ocm_create_case']) &&
check_admin_referer('ocm_create_case')
) {
$case_id = OCM_Cases::generate_case_id();
$wpdb->insert(
$wpdb->prefix . 'odinn_cases',
array(
'case_id' => $case_id,
'owner_name' => sanitize_text_field($_POST['owner_name']),
'owner_email' => sanitize_email($_POST['owner_email']),
'owner_phone' => sanitize_text_field($_POST['owner_phone']),
'animal_name' => sanitize_text_field($_POST['animal_name']),
'animal_type' => sanitize_text_field($_POST['animal_type']),
'animal_breed' => sanitize_text_field($_POST['animal_breed']),
'status' => sanitize_text_field($_POST['status']),
'priority' => sanitize_text_field($_POST['priority']),
'summary' => sanitize_textarea_field($_POST['summary']),
'created_at' => current_time('mysql')
)
);
echo '';
echo '
Case Created: ' .
esc_html($case_id) .
'
';
echo '
';
}
echo '';
echo '
Add Case
';
echo '
';
}
$notes = OCM_Notes::get_notes($id);
if ($notes) {
echo '
';
echo '
Existing Notes
';
foreach ($notes as $note) {
echo '
';
echo nl2br(
esc_html($note->note)
);
echo '
';
echo '';
echo esc_html(
$note->created_at
);
echo '';
echo '
';
}
}