render_ticket_types_panel(); $this->render_ticket_statuses_panel(); $this->render_ticket_prereplies_panel(); } /** 部门:表格 + 行内编辑 + 新建表单。 */ private function render_ticket_types_panel(): void { $types = \AKSRT\Ticket\TicketTypeService::all(); $edit_id = isset($_GET['type_id']) ? absint($_GET['type_id']) : 0; $editing = null; foreach ($types as $row) { if ((int) $row['id'] === $edit_id) { $editing = $row; break; } } echo '

' . esc_html__('工单部门', 'aksrt') . '

'; echo ''; echo '' . '' . ''; foreach ($types as $row) { $edit_url = add_query_arg(['type_id' => (int) $row['id']], $this->ticket_page_url(['tab' => 'config'])); $cells = sprintf( ''; echo $cells; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
ID' . esc_html__('名称', 'aksrt') . '' . esc_html__('说明', 'aksrt') . '' . esc_html__('受理管理员', 'aksrt') . '
%d%s%s%s', (int) $row['id'], esc_html((string) $row['name']), esc_html((string) $row['description'] !== '' ? (string) $row['description'] : '—'), esc_html($row['admin_ids'] === [] ? '—' : implode(', ', $row['admin_ids'])) ); $cells .= '' . esc_html__('编辑', 'aksrt') . ' '; $cells .= $this->ticket_delete_button('type_delete', 'type_id', (int) $row['id'], __('删除', 'aksrt')); $cells .= '
'; echo '

' . esc_html($editing === null ? __('新增部门', 'aksrt') : __('编辑部门', 'aksrt')) . '

'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo wp_nonce_field('aksrt_ticket_type_' . (int) ($editing['id'] ?? 0), '_wpnonce', true, false); echo '

'; echo '

'; echo '

'; submit_button(__('保存部门', 'aksrt'), 'primary', '', false); echo '
'; } /** 自定义状态:默认状态拒绝改删。 */ private function render_ticket_statuses_panel(): void { $statuses = \AKSRT\Ticket\TicketStatusService::all(); $edit_id = isset($_GET['status_id']) ? absint($_GET['status_id']) : 0; $editing = null; foreach ($statuses as $row) { if ((int) $row['id'] === $edit_id) { $editing = $row; break; } } echo '

' . esc_html__('工单状态', 'aksrt') . '

'; echo '

' . esc_html__('默认状态不可修改或删除;删除非默认状态前需先清空该状态下的工单。', 'aksrt') . '

'; echo ''; echo '' . '' . '' . ''; foreach ($statuses as $row) { $status_cells = sprintf( '' . '' . ''; echo $status_cells; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
ID' . esc_html__('名称', 'aksrt') . '' . esc_html__('颜色', 'aksrt') . '' . esc_html__('完结', 'aksrt') . '' . esc_html__('默认', 'aksrt') . '
%d%s%s%s%s', (int) $row['id'], esc_html((string) $row['name']), esc_attr((string) $row['color']), esc_html((string) $row['color']), esc_html(!empty($row['is_closed']) ? __('是', 'aksrt') : __('否', 'aksrt')), esc_html(!empty($row['is_default']) ? __('是', 'aksrt') : __('否', 'aksrt')) ); if (empty($row['is_default'])) { $status_cells .= '' . esc_html__('编辑', 'aksrt') . ' '; $status_cells .= $this->ticket_delete_button('status_delete', 'status_id', (int) $row['id'], __('删除', 'aksrt')); } else { $status_cells .= '—'; } $status_cells .= '
'; echo '

' . esc_html($editing === null ? __('新增状态', 'aksrt') : __('编辑状态', 'aksrt')) . '

'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo wp_nonce_field('aksrt_ticket_status_def_' . (int) ($editing['id'] ?? 0), '_wpnonce', true, false); echo '

'; echo ' '; echo ' '; submit_button(__('保存状态', 'aksrt'), 'primary', '', false); echo '

'; } /** 预设回复:表格 + 行内编辑 + 新建表单。 */ private function render_ticket_prereplies_panel(): void { $rows = \AKSRT\Ticket\TicketPrereplyService::all(); $edit_id = isset($_GET['prereply_id']) ? absint($_GET['prereply_id']) : 0; $editing = null; foreach ($rows as $row) { if ((int) $row['id'] === $edit_id) { $editing = $row; break; } } echo '

' . esc_html__('预设回复', 'aksrt') . '

'; echo ''; echo ''; if ($rows === []) { echo ''; } foreach ($rows as $row) { $reply_cells = sprintf( ''; echo $reply_cells; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
ID' . esc_html__('内容', 'aksrt') . '
' . esc_html__('暂无预设回复', 'aksrt') . '
%d%s', (int) $row['id'], esc_html((string) $row['content']) ); $reply_cells .= '' . esc_html__('编辑', 'aksrt') . ' '; $reply_cells .= $this->ticket_delete_button('prereply_delete', 'prereply_id', (int) $row['id'], __('删除', 'aksrt')); $reply_cells .= '
'; echo '

' . esc_html($editing === null ? __('新增预设回复', 'aksrt') : __('编辑预设回复', 'aksrt')) . '

'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo wp_nonce_field('aksrt_ticket_prereply_' . (int) ($editing['id'] ?? 0), '_wpnonce', true, false); echo '

'; submit_button(__('保存预设回复', 'aksrt'), 'primary', '', false); echo '
'; } }