Skip to content

Commit f0f4e88

Browse files
authored
Merge pull request #1632 from OCSInventory-NG/multisearch-option
feat(multisearch): add option to ungroup result
2 parents 5fae311 + 3782b9f commit f0f4e88

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

plugins/language/en_GB/en_GB.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,7 @@
18861886
9930 DNS
18871887

18881888
9940 Is allowed to manage saved searches
1889+
9941 Ungroup results
18891890

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

1923-
10000 Failed to update account info fields: quotes are not allowed in administrative values
1924+
10000 Failed to update account info fields: quotes are not allowed in administrative values

plugins/language/fr_FR/fr_FR.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,6 +1881,7 @@
18811881
9930 DNS
18821882

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

18851886
9950 Notifications
18861887
9951 Veuillez vérifier que les notifications ont été correctement configurées pour que l'envoi des rapports fonctionne

plugins/main_sections/ms_multi_search/ms_multi_search.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,20 @@
289289
}
290290

291291
if(!empty($_SESSION['OCS']['multi_search'])){
292+
$checked = "";
293+
294+
if (isset($protectedPost["groupby_search"])) {
295+
$checked = "checked";
296+
}
297+
292298
?>
293299

294300
<div class="col-sm-12">
295301
<input name="onglet" type="hidden" value="COMPUTERS">
296302
<input id="search_ok" name="search_ok" type="hidden" value="OK">
303+
<div>
304+
<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) ?>
305+
</div><br/>
297306
<input type="submit" class="btn btn-success" value="<?php echo $l->g(13) ?>">
298307
</div>
299308

@@ -322,10 +331,17 @@
322331

323332
if((isset($protectedPost['search_ok']) || isset($protectedGet['prov']) || isset($protectedGet['fields'])) && $isValid && !isset($protectedPost['table_select']) && !isset($protectedPost['columns_select'])){
324333
unset($_SESSION['OCS']['SEARCH_SQL_GROUP']);
334+
335+
$groupby = true;
336+
337+
if (isset($protectedPost["groupby_search"])) {
338+
$groupby = false;
339+
}
340+
325341
/**
326342
* Generate Search fields
327343
*/
328-
$search->generateSearchQuery($_SESSION['OCS']['multi_search']);
344+
$search->generateSearchQuery($_SESSION['OCS']['multi_search'], $groupby);
329345
$sql = $search->baseQuery.$search->searchQuery.$search->columnsQueryConditions;
330346

331347
$_SESSION['OCS']['multi_search_query'] = $sql;

require/search/Search.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public function getFieldUniqId($uniqid, $tableName)
318318
* @param Array $sessData
319319
* @return void
320320
*/
321-
public function generateSearchQuery($sessData){
321+
public function generateSearchQuery($sessData, $groupby = true){
322322

323323
new AccountinfoSearch();
324324
$this->pushBaseQueryForTable("hardware", null);
@@ -579,7 +579,10 @@ public function generateSearchQuery($sessData){
579579
$this->columnsQueryConditions .= " AND " . $lockResult;
580580
}
581581

582-
$this->columnsQueryConditions .= " GROUP BY hardware.id";
582+
if ($groupby) {
583+
$this->columnsQueryConditions .= " GROUP BY hardware.id";
584+
}
585+
583586
$this->baseQuery = substr($this->baseQuery, 0, -1);
584587
}
585588

0 commit comments

Comments
 (0)