mirror of
https://github.com/tips-of-mine/GLPI-Plugin-SOC-Case-Management.git
synced 2025-06-28 13:48:42 +02:00
Start repository
This commit is contained in:
80
inc/caseticket.class.php
Normal file
80
inc/caseticket.class.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user