mirror of
https://github.com/tips-of-mine/GLPI-Plugin-SOC-Case-Management.git
synced 2025-08-24 14:25:50 +02:00
Start repository
This commit is contained in:
65
front/case.form.php
Normal file
65
front/case.form.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
include ("../../../inc/includes.php");
|
||||
|
||||
Session::checkRight("plugin_soc_case", READ);
|
||||
|
||||
// Check if plugin is activated
|
||||
if (!Plugin::isPluginActive("soc")) {
|
||||
Html::displayNotFoundError();
|
||||
}
|
||||
|
||||
if (isset($_POST["add"])) {
|
||||
Session::checkRight("plugin_soc_case", CREATE);
|
||||
$case = new PluginSocCase();
|
||||
$case->check(-1, CREATE, $_POST);
|
||||
$case->add($_POST);
|
||||
Html::back();
|
||||
} else if (isset($_POST["update"])) {
|
||||
Session::checkRight("plugin_soc_case", UPDATE);
|
||||
$case = new PluginSocCase();
|
||||
$case->check($_POST['id'], UPDATE);
|
||||
$case->update($_POST);
|
||||
Html::back();
|
||||
} else if (isset($_POST["delete"])) {
|
||||
Session::checkRight("plugin_soc_case", DELETE);
|
||||
$case = new PluginSocCase();
|
||||
$case->check($_POST['id'], DELETE);
|
||||
$case->delete($_POST);
|
||||
Html::redirect(Plugin::getWebDir("soc")."/front/case.php");
|
||||
} else if (isset($_POST["restore"])) {
|
||||
Session::checkRight("plugin_soc_case", DELETE);
|
||||
$case = new PluginSocCase();
|
||||
$case->check($_POST['id'], DELETE);
|
||||
$case->restore($_POST);
|
||||
Html::back();
|
||||
} else if (isset($_POST["purge"])) {
|
||||
Session::checkRight("plugin_soc_case", PURGE);
|
||||
$case = new PluginSocCase();
|
||||
$case->check($_POST['id'], PURGE);
|
||||
$case->delete($_POST, 1);
|
||||
Html::redirect(Plugin::getWebDir("soc")."/front/case.php");
|
||||
} else if (isset($_POST["add_ticket"])) {
|
||||
Session::checkRight("plugin_soc_case", UPDATE);
|
||||
$case = new PluginSocCase();
|
||||
$case->getFromDB($_POST['plugin_soc_cases_id']);
|
||||
$tickets_id = $case->createTicket($_POST);
|
||||
Html::back();
|
||||
} else if (isset($_POST["add_change"])) {
|
||||
Session::checkRight("plugin_soc_case", UPDATE);
|
||||
$case = new PluginSocCase();
|
||||
$case->getFromDB($_POST['plugin_soc_cases_id']);
|
||||
$changes_id = $case->createChange($_POST);
|
||||
Html::back();
|
||||
} else {
|
||||
$id = "";
|
||||
if (isset($_GET["id"])) {
|
||||
$id = $_GET["id"];
|
||||
}
|
||||
$case = new PluginSocCase();
|
||||
|
||||
Html::header(PluginSocCase::getTypeName(Session::getPluralNumber()), '', "management", "pluginsoccase");
|
||||
|
||||
$case->display(['id' => $id]);
|
||||
|
||||
Html::footer();
|
||||
}
|
15
front/case.php
Normal file
15
front/case.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
include ("../../../inc/includes.php");
|
||||
|
||||
Session::checkRight("plugin_soc_case", READ);
|
||||
|
||||
// Check if plugin is activated
|
||||
if (!Plugin::isPluginActive("soc")) {
|
||||
Html::displayNotFoundError();
|
||||
}
|
||||
|
||||
Html::header(PluginSocCase::getTypeName(Session::getPluralNumber()), '', "management", "pluginsoccase");
|
||||
|
||||
Search::show('PluginSocCase');
|
||||
|
||||
Html::footer();
|
88
front/dashboard.php
Normal file
88
front/dashboard.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
include ("../../../inc/includes.php");
|
||||
|
||||
Session::checkRight("plugin_soc_case", READ);
|
||||
|
||||
// Check if plugin is activated
|
||||
if (!Plugin::isPluginActive("soc")) {
|
||||
Html::displayNotFoundError();
|
||||
}
|
||||
|
||||
Html::header(__('SOC Dashboard', 'soc'), '', "management", "pluginsoccase");
|
||||
|
||||
// Get counts
|
||||
$case = new PluginSocCase();
|
||||
$total_cases = countElementsInTable($case->getTable());
|
||||
$new_cases = countElementsInTable($case->getTable(), ['status' => PluginSocCase::STATUS_NEW]);
|
||||
$critical_cases = countElementsInTable($case->getTable(), ['severity' => PluginSocCase::SEVERITY_CRITICAL]);
|
||||
|
||||
// Display dashboard
|
||||
?>
|
||||
<div class="soc-dashboard">
|
||||
<h2><?php echo __('SOC Case Management Dashboard', 'soc'); ?></h2>
|
||||
|
||||
<!-- KPI Cards -->
|
||||
<div class="soc-kpi-container">
|
||||
<div class="soc-kpi-card">
|
||||
<div class="soc-kpi-label"><?php echo __('Total Cases', 'soc'); ?></div>
|
||||
<div class="soc-kpi-value" data-value="<?php echo $total_cases; ?>"><?php echo $total_cases; ?></div>
|
||||
</div>
|
||||
|
||||
<div class="soc-kpi-card">
|
||||
<div class="soc-kpi-label"><?php echo __('New Cases', 'soc'); ?></div>
|
||||
<div class="soc-kpi-value" data-value="<?php echo $new_cases; ?>"><?php echo $new_cases; ?></div>
|
||||
</div>
|
||||
|
||||
<div class="soc-kpi-card">
|
||||
<div class="soc-kpi-label"><?php echo __('Critical Cases', 'soc'); ?></div>
|
||||
<div class="soc-kpi-value" data-value="<?php echo $critical_cases; ?>"><?php echo $critical_cases; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Recent Cases -->
|
||||
<div class="soc-card" style="flex: 1 1 100%;">
|
||||
<div class="soc-card-header">
|
||||
<h3 class="soc-card-title"><?php echo __('Recent Cases', 'soc'); ?></h3>
|
||||
</div>
|
||||
<div class="soc-card-content">
|
||||
<?php
|
||||
$cases = $DB->request([
|
||||
'FROM' => $case->getTable(),
|
||||
'ORDER' => ['date_creation DESC'],
|
||||
'LIMIT' => 5
|
||||
]);
|
||||
|
||||
if (count($cases) > 0) {
|
||||
echo '<table class="tab_cadre_fixehov">';
|
||||
echo '<tr>';
|
||||
echo '<th>' . __('Name') . '</th>';
|
||||
echo '<th>' . __('Status') . '</th>';
|
||||
echo '<th>' . __('Severity', 'soc') . '</th>';
|
||||
echo '<th>' . __('Creation date') . '</th>';
|
||||
echo '</tr>';
|
||||
|
||||
foreach ($cases as $data) {
|
||||
echo '<tr class="tab_bg_1">';
|
||||
echo '<td><a href="case.form.php?id=' . $data['id'] . '">' . $data['name'] . '</a></td>';
|
||||
echo '<td><span class="soc-status soc-status-' . $data['status'] . '">' . $case->getStatusOptions()[$data['status']] . '</span></td>';
|
||||
echo '<td><span class="soc-severity soc-severity-' . $data['severity'] . '">' . $case->getSeverityOptions()[$data['severity']] . '</span></td>';
|
||||
echo '<td>' . Html::convDateTime($data['date_creation']) . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo '<p>' . __('No cases found.', 'soc') . '</p>';
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="center" style="margin-top: 20px;">
|
||||
<a href="case.php" class="submit"><?php echo __('View all cases', 'soc'); ?></a>
|
||||
<a href="case.form.php" class="submit"><?php echo __('Create new case', 'soc'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
Html::footer();
|
102
front/timeline.ajax.php
Normal file
102
front/timeline.ajax.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
include ("../../../inc/includes.php");
|
||||
|
||||
// Check for AJAX request
|
||||
header("Content-Type: application/json; charset=UTF-8");
|
||||
|
||||
// Check if plugin is activated
|
||||
if (!Plugin::isPluginActive("soc")) {
|
||||
http_response_code(404);
|
||||
die(json_encode(['error' => 'Plugin not active']));
|
||||
}
|
||||
|
||||
Session::checkLoginUser();
|
||||
|
||||
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
|
||||
http_response_code(400);
|
||||
die(json_encode(['error' => 'Invalid ID']));
|
||||
}
|
||||
|
||||
$case_id = intval($_GET['id']);
|
||||
|
||||
// Check permission
|
||||
if (!Session::haveRight("plugin_soc_case", READ)) {
|
||||
http_response_code(403);
|
||||
die(json_encode(['error' => 'Permission denied']));
|
||||
}
|
||||
|
||||
$case = new PluginSocCase();
|
||||
|
||||
if (!$case->getFromDB($case_id)) {
|
||||
http_response_code(404);
|
||||
die(json_encode(['error' => 'Case not found']));
|
||||
}
|
||||
|
||||
// Get timeline events
|
||||
$timeline = [];
|
||||
|
||||
// Get case creation
|
||||
$timeline[] = [
|
||||
'date' => $case->fields['date_creation'],
|
||||
'type' => 'creation',
|
||||
'content' => __('Case created', 'soc')
|
||||
];
|
||||
|
||||
// Get case updates from history
|
||||
$log = new Log();
|
||||
$logs = $log->getHistoryData($case, 0, 0, ['date_mod' => 'DESC']);
|
||||
|
||||
foreach ($logs as $entry) {
|
||||
$timeline[] = [
|
||||
'date' => $entry['date_mod'],
|
||||
'type' => 'update',
|
||||
'content' => sprintf(
|
||||
__('%s updated %s from %s to %s', 'soc'),
|
||||
$entry['user_name'],
|
||||
$entry['field'],
|
||||
$entry['old_value'],
|
||||
$entry['new_value']
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
// Get related tickets
|
||||
$case_ticket = new PluginSocCaseTicket();
|
||||
$tickets = PluginSocCaseTicket::getTicketsForCase($case_id);
|
||||
|
||||
foreach ($tickets as $ticket_data) {
|
||||
$timeline[] = [
|
||||
'date' => $ticket_data['date_creation'],
|
||||
'type' => 'ticket',
|
||||
'content' => sprintf(
|
||||
__('Ticket %s created: %s', 'soc'),
|
||||
$ticket_data['id'],
|
||||
$ticket_data['name']
|
||||
),
|
||||
'ticket_id' => $ticket_data['id']
|
||||
];
|
||||
}
|
||||
|
||||
// Get related changes
|
||||
$case_change = new PluginSocCaseChange();
|
||||
$changes = PluginSocCaseChange::getChangesForCase($case_id);
|
||||
|
||||
foreach ($changes as $change_data) {
|
||||
$timeline[] = [
|
||||
'date' => $change_data['date_creation'],
|
||||
'type' => 'change',
|
||||
'content' => sprintf(
|
||||
__('Change %s created: %s', 'soc'),
|
||||
$change_data['id'],
|
||||
$change_data['name']
|
||||
),
|
||||
'change_id' => $change_data['id']
|
||||
];
|
||||
}
|
||||
|
||||
// Sort timeline by date (newest first)
|
||||
usort($timeline, function($a, $b) {
|
||||
return strtotime($b['date']) - strtotime($a['date']);
|
||||
});
|
||||
|
||||
echo json_encode(['timeline' => $timeline]);
|
Reference in New Issue
Block a user