mirror of
https://github.com/tips-of-mine/GLPI-Plugin-SOC-Case-Management.git
synced 2025-06-27 21:28:42 +02:00
80 lines
2.0 KiB
PHP
80 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* SOC Case-Ticket relation class
|
|
*/
|
|
class PluginSocCaseTicket extends CommonDBRelation {
|
|
|
|
// From CommonDBRelation
|
|
static public $itemtype_1 = 'PluginSocCase';
|
|
static public $items_id_1 = 'plugin_soc_cases_id';
|
|
static public $itemtype_2 = 'Ticket';
|
|
static public $items_id_2 = 'tickets_id';
|
|
|
|
/**
|
|
* Get tickets for a case
|
|
*
|
|
* @param integer $cases_id
|
|
* @return DBmysqlIterator
|
|
*/
|
|
static function getTicketsForCase($cases_id) {
|
|
global $DB;
|
|
|
|
$iterator = $DB->request([
|
|
'SELECT' => [
|
|
'glpi_tickets.*',
|
|
'glpi_plugin_soc_case_tickets.id AS link_id'
|
|
],
|
|
'FROM' => 'glpi_plugin_soc_case_tickets',
|
|
'LEFT JOIN' => [
|
|
'glpi_tickets' => [
|
|
'FKEY' => [
|
|
'glpi_plugin_soc_case_tickets' => 'tickets_id',
|
|
'glpi_tickets' => 'id'
|
|
]
|
|
]
|
|
],
|
|
'WHERE' => [
|
|
'glpi_plugin_soc_case_tickets.plugin_soc_cases_id' => $cases_id
|
|
],
|
|
'ORDER' => [
|
|
'glpi_tickets.date_creation DESC'
|
|
]
|
|
]);
|
|
|
|
return $iterator;
|
|
}
|
|
|
|
/**
|
|
* Get cases for a ticket
|
|
*
|
|
* @param integer $tickets_id
|
|
* @return DBmysqlIterator
|
|
*/
|
|
static function getCasesForTicket($tickets_id) {
|
|
global $DB;
|
|
|
|
$iterator = $DB->request([
|
|
'SELECT' => [
|
|
'glpi_plugin_soc_cases.*',
|
|
'glpi_plugin_soc_case_tickets.id AS link_id'
|
|
],
|
|
'FROM' => 'glpi_plugin_soc_case_tickets',
|
|
'LEFT JOIN' => [
|
|
'glpi_plugin_soc_cases' => [
|
|
'FKEY' => [
|
|
'glpi_plugin_soc_case_tickets' => 'plugin_soc_cases_id',
|
|
'glpi_plugin_soc_cases' => 'id'
|
|
]
|
|
]
|
|
],
|
|
'WHERE' => [
|
|
'glpi_plugin_soc_case_tickets.tickets_id' => $tickets_id
|
|
],
|
|
'ORDER' => [
|
|
'glpi_plugin_soc_cases.date_creation DESC'
|
|
]
|
|
]);
|
|
|
|
return $iterator;
|
|
}
|
|
} |