Skip to content

Commit

Permalink
feat(multisearch): add option to ungroup result
Browse files Browse the repository at this point in the history
  • Loading branch information
charleneauger committed Sep 23, 2024
1 parent 005fd3d commit 1ba90d0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions plugins/language/en_GB/en_GB.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,7 @@
9930 DNS

9940 Is allowed to manage saved searches
9941 Ungroup the result

9950 Notifications
9951 Please check that the notification configuration has been set correctly, otherwise sending reports through notifications will not work
Expand Down
1 change: 1 addition & 0 deletions plugins/language/fr_FR/fr_FR.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,7 @@
9930 DNS

9940 Est autorisé à gérer les recherches sauvegardées
9941 Dégrouper le résultat

9950 Notifications
9951 Veuillez vérifier que les notifications ont été correctement configurées pour que l'envoi des rapports fonctionne
Expand Down
18 changes: 17 additions & 1 deletion plugins/main_sections/ms_multi_search/ms_multi_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,20 @@
}

if(!empty($_SESSION['OCS']['multi_search'])){
$checked = "";

if (isset($protectedPost["groupby_search"])) {
$checked = "checked";
}

?>

<div class="col-sm-12">
<input name="onglet" type="hidden" value="COMPUTERS">
<input id="search_ok" name="search_ok" type="hidden" value="OK">
<div>
<input style="display:initial;width:20px;height:14px;" type="checkbox" name="groupby_search" value="0" id="groupby_search" class="form-control" <?php echo $checked ?>><?php echo $l->g(9941) ?>
</div><br/>
<input type="submit" class="btn btn-success" value="<?php echo $l->g(13) ?>">
</div>

Expand Down Expand Up @@ -322,10 +331,17 @@

if((isset($protectedPost['search_ok']) || isset($protectedGet['prov']) || isset($protectedGet['fields'])) && $isValid && !isset($protectedPost['table_select']) && !isset($protectedPost['columns_select'])){
unset($_SESSION['OCS']['SEARCH_SQL_GROUP']);

$groupby = true;

if (isset($protectedPost["groupby_search"])) {
$groupby = false;
}

/**
* Generate Search fields
*/
$search->generateSearchQuery($_SESSION['OCS']['multi_search']);
$search->generateSearchQuery($_SESSION['OCS']['multi_search'], $groupby);
$sql = $search->baseQuery.$search->searchQuery.$search->columnsQueryConditions;

$_SESSION['OCS']['multi_search_query'] = $sql;
Expand Down
7 changes: 5 additions & 2 deletions require/search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function getFieldUniqId($uniqid, $tableName)
* @param Array $sessData
* @return void
*/
public function generateSearchQuery($sessData){
public function generateSearchQuery($sessData, $groupby = true){

new AccountinfoSearch();
$this->pushBaseQueryForTable("hardware", null);
Expand Down Expand Up @@ -579,7 +579,10 @@ public function generateSearchQuery($sessData){
$this->columnsQueryConditions .= " AND " . $lockResult;
}

$this->columnsQueryConditions .= " GROUP BY hardware.id";
if ($groupby) {
$this->columnsQueryConditions .= " GROUP BY hardware.id";
}

$this->baseQuery = substr($this->baseQuery, 0, -1);
}

Expand Down

0 comments on commit 1ba90d0

Please sign in to comment.