Skip to content

Commit

Permalink
Merge branch 'working' of https://github.com/FOGProject/fogproject in…
Browse files Browse the repository at this point in the history
…to working
  • Loading branch information
root committed Jan 24, 2019
2 parents 48d37be + 6cb84fe commit 632fc15
Show file tree
Hide file tree
Showing 6 changed files with 1,050 additions and 51 deletions.
106 changes: 104 additions & 2 deletions packages/web/lib/reports/history_report.report.php
Expand Up @@ -21,14 +21,109 @@
*/
class History_Report extends ReportManagementPage
{

public function file()
{
$this->title = _('FOG History - Search');
unset(
$this->data,
$this->form,
$this->headerData,
$this->templates,
$this->attributes
);
$this->templates = array(
'${field}',
'${input}'
);
$this->attributes = array(
array('class' => 'col-xs-4'),
array('class' => 'col-xs-8 form-group')
);
$userNames = self::getSubObjectIDs(
'User',
'',
'name'
);
$userNames = array_values(
array_filter(
array_unique(
(array)$userNames
)
)
);
natcasesort($userNames);

if (count($userNames) > 0) {
$userSelForm = self::selectForm(
'usersearch',
$userNames
);
unset($userNames);
}
$fields = array(
'<label for="usersearch">'
. _('Enter an user name to search for')
. '</label>' => $userSelForm,
'<label for="info">'
. _('Enter a term to search for')
. '</label>' => '<div class="input-group">'
. '<input type="text" class="'
. 'form-control text-input" name='
. '"info" value="'
. $info
. '" autocomplete="off" id="info" />'
. '</div>',
'<label for="performsearch">'
. _('Perform search')
. '</label>' => '<button type="submit" name="performsearch" '
. 'class="btn btn-info btn-block" id="performsearch">'
. _('Search')
. '</button>'
);
array_walk($fields, $this->fieldsToData);
echo '<div class="col-xs-9">';
echo '<div class="panel panel-info">';
echo '<div class="panel-heading text-center">';
echo '<h4 class="title">';
echo $this->title;
echo '</h4>';
echo '</div>';
echo '<div class="panel-body">';
echo '<form class="form-horizontal" method="post" action="'
. $this->formAction
. '">';
$this->render(12);
echo '</form>';
echo '</div>';
echo '</div>';
echo '</div>';
}


/**
* Display page.
*
* @return void
*/
public function file()

public function filePost()
{
$this->title = _('Full History Export');
$usersearch = filter_input(
INPUT_POST,
'usersearch'
);
$info = filter_input(
INPUT_POST,
'info'
);

if (!$usersearch) {
$usersearch = '%';
}
$info = '%'. $info . '%';

array_walk(
self::$inventoryCsvHead,
function (&$classGet, &$csvHeader) {
Expand All @@ -55,7 +150,14 @@ function (&$classGet, &$csvHeader) {
array(),
array()
);
Route::listem('history');
Route::listem('history',
'id',
'false',
array(
'createdBy' => $usersearch,
'info' => $info
)
);
$Historys = json_decode(
Route::getData()
);
Expand Down
197 changes: 195 additions & 2 deletions packages/web/lib/reports/host_list.report.php
Expand Up @@ -7,6 +7,7 @@
* @category Host_List
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @author Fernando Gietz <fernando.gietz@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
Expand All @@ -22,13 +23,161 @@
class Host_List extends ReportManagementPage
{
/**
* Display page.
* Display search page.
*
* @return void
*/

public function file()
{
$this->title = _('FOG Host - Search');
unset(
$this->data,
$this->form,
$this->headerData,
$this->templates,
$this->attributes
);
$this->templates = array(
'${field}',
'${input}'
);
$this->attributes = array(
array('class' => 'col-xs-4'),
array('class' => 'col-xs-8 form-group')
);
$groupNames = self::getSubObjectIDs(
'Group',
'',
'name'
);
$groupNames = array_values(
array_filter(
array_unique(
(array)$groupNames
)
)
);
if (in_array('location', (array)self::$pluginsinstalled)){
$locationNames = self::getSubObjectIDs(
'Location',
'',
'name'
);
natcasesort($locationNames);
if (count($locationNames) > 0) {
$locationSelForm = self::selectForm(
'locationsearch',
$locationNames
);
unset($locationNames);
}


}
if (in_array('site', (array)self::$pluginsinstalled)){
$siteNames = self::getSubObjectIDs(
'site',
'',
'name'
);
natcasesort($siteNames);
if (count($siteNames) > 0) {
$siteSelForm = self::selectForm(
'sitesearch',
$siteNames
);
unset($siteNames);
}


}
natcasesort($groupNames);

if (count($groupNames) > 0) {
$groupSelForm = self::selectForm(
'groupsearch',
$groupNames
);
unset($groupNames);
}
$fields = array(
'<label for="groupsearch">'
. _('Enter a group name to search for')
. '</label>' => $groupSelForm,
'<label for="performsearch">'
. _('Perform search')
. '</label>' => '<button type="submit" name="performsearch" '
. 'class="btn btn-info btn-block" id="performsearch">'
. _('Search')
. '</button>'
);
if (in_array('location', (array)self::$pluginsinstalled)){
self::arrayInsertAfter(
'<label for="groupsearch">'
. _('Enter a group name to search for')
. '</label>',
$fields,
'<label for="locationsearch">'
. _('Enter a location name to search for')
. '</label>',
$locationSelForm
);
}
if (in_array('site', (array)self::$pluginsinstalled)){
self::arrayInsertAfter(
'<label for="groupsearch">'
. _('Enter a group name to search for')
. '</label>',
$fields,
'<label for="sitesearch">'
. _('Enter a site name to search for')
. '</label>',
$siteSelForm
);
}
array_walk($fields, $this->fieldsToData);
echo '<div class="col-xs-9">';
echo '<div class="panel panel-info">';
echo '<div class="panel-heading text-center">';
echo '<h4 class="title">';
echo $this->title;
echo '</h4>';
echo '</div>';
echo '<div class="panel-body">';
echo '<form class="form-horizontal" method="post" action="'
. $this->formAction
. '">';
$this->render(12);
echo '</form>';
echo '</div>';
echo '</div>';
echo '</div>';
}
/**
* Display page.
*
* @return void
*/
public function filePost()
{
$this->title = _('Host Listing Export');
$groupsearch = filter_input(
INPUT_POST,
'groupsearch'
);
if (!$groupsearch) {
$groupsearch = '%';
}

$locationsearch = filter_input(
INPUT_POST,
'locationsearch'
);
$sitesearch = filter_input(
INPUT_POST,
'sitesearch'
);
$csvHead = array(
_('Host ID') => 'id',
_('Host Name') => 'name',
Expand Down Expand Up @@ -60,7 +209,51 @@ public function file()
'${host_mac}',
'${image_name}',
);
Route::listem('host');
$groupIDs = self::getSubObjectIDs(
'Group',
array('name' => $groupsearch),
'id'
);

$groupHostIDs = self::getSubObjectIDs(
'GroupAssociation',
array('groupID' => $groupIDs),
'hostID'
);
if (in_array('location', (array)self::$pluginsinstalled) && $locationsearch){
$locationIDs = self::getSubObjectIDs(
'Location',
array('name' => $locationsearch),
'id'
);
$locationHostIDs = self::getSubObjectIDs(
'LocationAssociation',
array('locationID' => $locationIDs),
'hostID'
);
$groupHostIDs = array_intersect($locationHostIDs,$groupHostIDs);
}
if (in_array('site', (array)self::$pluginsinstalled) && $sitesearch){
$siteIDs = self::getSubObjectIDs(
'Site',
array('name' => $sitesearch),
'id'
);
$siteHostIDs = self::getSubObjectIDs(
'SiteHostAssociation',
array('siteID' => $siteIDs),
'hostID'
);
$groupHostIDs = array_intersect($siteHostIDs,$groupHostIDs);
}

Route::listem('host',
'name',
'false',
array(
'id' => $groupHostIDs
)
);
$Hosts = json_decode(
Route::getData()
);
Expand Down

0 comments on commit 632fc15

Please sign in to comment.