Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(multisearch): add option to ungroup result #1632

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 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 results

9950 Notifications
9951 Please check that the notification configuration has been set correctly, otherwise sending reports through notifications will not work
Expand Down Expand Up @@ -1920,4 +1921,4 @@
9990 Download SNMP Subnets List
9991 Generate SNMP files

10000 Failed to update account info fields: quotes are not allowed in administrative values
10000 Failed to update account info fields: quotes are not allowed in administrative values
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
Loading