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; } /** * Show cases for a ticket * * @param Ticket $ticket * @return void */ function showForTicket(Ticket $ticket) { global $DB; $ticket_id = $ticket->getID(); if (!$ticket->can($ticket_id, READ)) { return false; } $cases = self::getCasesForTicket($ticket_id); $nb = count($cases); echo "
"; if ($nb > 0) { echo ""; $header = ""; $header .= ""; $header .= ""; $header .= ""; $header .= ""; $header .= ""; echo $header; foreach ($cases as $data) { $case = new PluginSocCase(); $case->getFromDB($data['id']); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
" . __('Name') . "" . __('Status') . "" . __('Severity', 'soc') . "" . __('Creation date') . "
".$data['name']."".$case->getStatusOptions()[$data['status']]."".$case->getSeverityOptions()[$data['severity']]."".Html::convDateTime($data['date_creation'])."
"; } else { echo "

".__('No SOC case associated with this ticket', 'soc')."

"; } // If user has rights to create cases if (Session::haveRight('plugin_soc_case', CREATE)) { echo "
"; echo ""; echo __('Create SOC case from this ticket', 'soc'); echo ""; echo "
"; } echo "
"; } /** * Show form for linking a ticket to a case * * @param integer $cases_id * @param array $options * @return void */ function showFormForCase($cases_id, $options = []) { global $CFG_GLPI; $case = new PluginSocCase(); $case->getFromDB($cases_id); echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".__('Link a ticket to this case', 'soc')."
".__('Ticket').""; Ticket::dropdown(['name' => 'tickets_id', 'entity' => $case->fields['entities_id']]); echo "
"; echo ""; echo ""; echo "
"; echo "
"; Html::closeForm(); } }