Skip to content

Commit

Permalink
Fix bd id list on TicketExport
Browse files Browse the repository at this point in the history
fixes #7
  • Loading branch information
Philippe GODOT committed Jun 11, 2024
1 parent e3c6bf0 commit 9f23c17
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 40 deletions.
78 changes: 39 additions & 39 deletions inc/rgpdtools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ public static function generateExport($POST) {
self::injectRowHeader($spreadsheet, $objectInfos, 'User');
self::injectRowValues($spreadsheet, $objectInfos, 2, 'User');

$itemTypes = $POST['itemTypes'];
// récupération des éléments associés au user
$allUsedItems = self::getAllUsedItemsForUser($userID);
$allUsedItems = self::getAllUsedItemsForUser($userID, $itemTypes);
// pour chaque élément séléctionné ajout d'un onglet
$itemTypes = $POST['itemTypes'];

foreach ($itemTypes as $itemType) {
$nbWorkSheet++;
$new_ws = new Worksheet($spreadsheet, $itemType);
Expand Down Expand Up @@ -188,10 +189,9 @@ public static function deleteUploadedDocuments($POST) {

private static function displayTabContentForUser(User $item) {
$users_id = $item->getField('id');
$itemsTypes = self::getUserAssociableItemTypes();
$html = '';
$html .= self::generateExportForm($users_id, $itemsTypes);
$html .= self::generateUnlinkItemsForm($users_id, $itemsTypes);
$html .= self::generateExportForm($users_id);
$html .= self::generateUnlinkItemsForm($users_id);
$html .= self::generateAnonymiseForm($users_id);

echo $html;
Expand Down Expand Up @@ -257,7 +257,7 @@ private static function generateExportForm($users_id) {
$html .= '<label class="label-checkbox" title="" for="itemTypes_' . $itemType . '"> <span class="check"></span> <span class="box"></span>&nbsp;</label>';
$html .= '</span>';
$html .= '</td>';
$html .= '<td>' . __($itemType) . '</td>';
$html .= '<td>' . __(str_replace(['ItilFollowup', 'TicketTask'],['Followup', 'Task'],$itemType)) . '</td>';
$html .= '<td colspan="2"></td>';
$html .= '</tr>';
}
Expand Down Expand Up @@ -329,13 +329,12 @@ private static function generateUnlinkItemsForm($users_id) {

foreach ($itemsTypes as $itemType) {
$html .= '<tr class="tab_bg_2">';
$html .= '<td>';
$html .= '<td colspan="2">';
$html .= '<div class="form-group form-check">';
$html .= '<input type="checkbox" class="new_checkbox form-check-input" id="deleteItemTypes_' . $itemType . '" name="deleteItemTypes[]" value="' . $itemType . '" />';
$html .= '<label class="label-checkbox" title="" for="deleteItemTypes_' . $itemType . '"> <span class="check"></span> <span class="box"></span>&nbsp;</label>';
$html .= '<input type="checkbox" class="new_checkbox form-check-input" id="deleteItemTypes_' . $itemType . '" name="deleteItemTypes[]" value="' . $itemType . '" />';
$html .= '<label class="form-check-label" title="" for="deleteItemTypes_' . $itemType . '"> <span class="check"></span> <span class="box"></span>'. __(str_replace(['ItilFollowup', 'TicketTask'],['Followup', 'Task'],$itemType)) .'</label>';
$html .= '</div>';
$html .= '</td>';
$html .= '<td>' . __($itemType) . '</td>';
$html_parts = Dropdown::showFromArray('retentionPeriods[' . $itemType . ']', $values, $config);
$html .= '<td>' . $html_parts . '</td>';
$html .= '</tr>';
Expand Down Expand Up @@ -483,10 +482,9 @@ private static function generateDeleteDocumentsForm($users_id) {
$html .= '<td colspan="2">';
$html .= '<div class="form-group form-check">';
$html .= '<input type="checkbox" class="new_checkbox form-check-input" id="deleteItemTypes_' . $itemType . '" name="deleteItemTypes[]" value="' . $itemType . '" />';
$html .= '<label class="form-check-label" title="" for="deleteItemTypes_' . $itemType . '"> <span class="check"></span> <span class="box"></span>'. __($itemType) .'</label>';
$html .= '<label class="form-check-label" title="" for="deleteItemTypes_' . $itemType . '"> <span class="check"></span> <span class="box"></span>'. __(str_replace(['ItilFollowup', 'TicketTask'],['Followup', 'Task'],$itemType)) .'</label>';
$html .= '</div>';
$html .= '</td>';
//$html .= '<td>' . __($itemType) . '</td>';
$html_parts = Dropdown::showFromArray('retentionPeriods[' . $itemType . ']', $values, $config);
$html .= '<td >' . $html_parts . '</td>';
$html .= '</tr>';
Expand All @@ -510,12 +508,12 @@ private static function generateDeleteDocumentsForm($users_id) {
* @param ID of user
* @return array
*/
private static function getAllUsedItemsForUser($ID) {
private static function getAllUsedItemsForUser($ID, $itemTypes) {
global $DB;

$items = [];

foreach (self::getUserAssociableItemTypes() as $itemtype) {
foreach ($itemTypes as $itemtype) {
if (!($item = getItemForItemtype($itemtype))) {
continue;
}
Expand Down Expand Up @@ -568,30 +566,32 @@ private static function getAllUsedItemsForUser($ID) {
}

// Tickets
$tickets = $DB->request(
[
'SELECT' => ['*'],
//'DISTINCT' => true,
'FROM' => Ticket::getTable(),
'LEFT JOIN' => [
Ticket_User::getTable() => [
'FKEY' => [
Ticket::getTable() => 'id',
Ticket_User::getTable() => 'tickets_id'
]
]
],
'WHERE' => [
'OR' => [
'users_id_recipient' => $ID,
'users_id' => $ID
],
],
'ORDER' => 'date'
]
);
foreach ($tickets as $data) {
$items['Ticket'][] = $data;
if($itemtype == 'Ticket') {
$tickets = $DB->request(
[
'SELECT' => ['t.*'],
'DISTINCT' => true,
'FROM' => Ticket::getTable().' AS t',
'INNER JOIN' => [
Ticket_User::getTable() => [
'FKEY' => [
't' => 'id',
Ticket_User::getTable() => 'tickets_id'
]
]
],
'WHERE' => [
'OR' => [
'users_id_recipient' => $ID,
'users_id' => $ID
],
],
'ORDER' => 'date'
]
);
foreach ($tickets as $data) {
$items['Ticket'][] = $data;
}
}

// getComputersIDs
Expand Down Expand Up @@ -619,7 +619,7 @@ private static function getAllUsedItemsForUser($ID) {
private static function getUserAssociableItemTypes($permissionAccess = READ) {
global $CFG_GLPI;

$itemsTypes = ['Ticket', 'Followup', 'Task'];
$itemsTypes = ['Ticket', 'ItilFollowup', 'TicketTask'];

$linkuser_types = array_merge($CFG_GLPI['linkuser_types'], $itemsTypes);;
foreach($linkuser_types as $itemsType){
Expand Down
5 changes: 5 additions & 0 deletions rgpdtools.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<compatibility>~10.O</compatibility>
<download_url>https://github.com/Probesys/glpi-plugins-rgpdtools/releases/download/v1.1.1/rgpdtools-1.1.1.tbz</download_url>
</version>
<version>
<num>1.1.2</num>
<compatibility>~10.O</compatibility>
<download_url>https://github.com/Probesys/glpi-plugins-rgpdtools/releases/download/v1.1.2/rgpdtools-1.1.2.tbz</download_url>
</version>
</versions>
<langs>
<lang>fr_FR</lang>
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* ---------------------------------------------------------------------
*/

define('PLUGIN_RGPDTOOLS_VERSION', '1.1.1');
define('PLUGIN_RGPDTOOLS_VERSION', '1.1.2');
define('PLUGIN_RGPDTOOLS_GLPI_MIN_VERSION', '9.5');
define('PLUGIN_RGPDTOOLS_GLPI_MAX_VERSION', '11');
if (!defined("PLUGIN_RGPDTOOLS_DIR")) {
Expand Down

0 comments on commit 9f23c17

Please sign in to comment.