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 ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if ($cases) { foreach ($cases as $case) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; echo '
Case IDAnimalOwnerStatusAction
' . esc_html($case->case_id) . '' . esc_html($case->animal_name) . '' . esc_html($case->owner_name) . '' . esc_html($case->status) . ''; echo 'No cases found
'; 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 '
'; wp_nonce_field('ocm_create_case'); echo ''; public function view_case() { global $wpdb; $id = absint($_GET['id'] ?? 0); $case = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}odinn_cases WHERE id = %d", $id ) ); echo '
'; if (!$case) { echo '

Case Not Found

'; echo '
'; return; } $is_admin = current_user_can('manage_options'); $is_case_manager = current_user_can('ocm_case_manager'); $is_case_worker = current_user_can('ocm_case_worker'); $is_partnerships = current_user_can('ocm_community_partnerships'); if ( isset($_POST['ocm_add_note']) && !empty($_POST['case_note']) && ( $is_admin || $is_case_manager || $is_case_worker ) ) { OCM_Notes::add_note( $id, sanitize_textarea_field( $_POST['case_note'] ) ); OCM_Timeline::add_event( $id, 'note', 'Note added' ); echo '
'; echo '

Note Added

'; echo '
'; } echo '

' . esc_html($case->case_id) . '

'; echo '

'; if ( $is_admin || $is_case_manager ) { echo 'Approve 'ndary" href="' . admin_url( 'admin.php?page=ocm_view_case&id=' . $id . iew_case&id=' . $id . ="button button-secondary" href="' . admin_url( 'admin.php?page=ocm_view_case&id=' . admin_url( 'admin.php?page=ocm_view_case&id=' . $id . '&ocm_action $id . '&ocm_ 'admin.php?page=ocm_view_case&id=' . $id . '& striped">'; echo '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Owner Name' . esc_html($case->owner_name) . '
Owner Email' . esc_html($case->owner_email) . '
Owner Phone' . esc_html($case->owner_phone) . '
Animal Name' . esc_html($case->animal_name) . '
Animal Type' . esc_html($case->animal_type) . '
Breed' . esc_html($case->animal_breed) . '
Status' . esc_html($case->status) . '
Priority' . esc_html($case->priority) . '
'; echo '

Summary

'; echo '
'; echo nl2br( esc_html($case->summary) ); echo '
'; echo '
'; echo '

Case Notes

'; if ( $is_admin || $is_case_manager || $is_case_worker ) { echo ''; echo ''; echo '

'; echo ''; echo '

'; 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 '
'; } }