inventory_report.report.php (fogproject-1.5.7) | : | inventory_report.report.php (fogproject-1.5.8) | ||
---|---|---|---|---|
skipping to change at line 40 | skipping to change at line 40 | |||
$this->attributes | $this->attributes | |||
); | ); | |||
$this->templates = array( | $this->templates = array( | |||
'${field}', | '${field}', | |||
'${input}' | '${input}' | |||
); | ); | |||
$this->attributes = array( | $this->attributes = array( | |||
array('class' => 'col-xs-4'), | array('class' => 'col-xs-4'), | |||
array('class' => 'col-xs-8 form-group') | array('class' => 'col-xs-8 form-group') | |||
); | ); | |||
$fields = array(); | ||||
$groupNames = self::getSubObjectIDs( | $groupNames = self::getSubObjectIDs( | |||
'Group', | 'Group', | |||
'', | '', | |||
'name' | 'name' | |||
); | ); | |||
$groupNames = array_values( | if (is_array($groupNames) && count($groupNames) > 0) { | |||
array_filter( | $groupNames = array_values( | |||
array_unique( | array_filter( | |||
(array)$groupNames | array_unique( | |||
) | (array)$groupNames | |||
) | ) | |||
); | ) | |||
); | ||||
natcasesort($groupNames); | ||||
$groupSelForm = self::selectForm( | ||||
'groupsearch', | ||||
$groupNames | ||||
); | ||||
unset($groupNames); | ||||
$fields += array('<label for="groupsearch">' | ||||
. _('Enter a group name to search for') | ||||
. '</label>' => $groupSelForm | ||||
); | ||||
} else { | ||||
$fields += array('<label for="groupsearch">' | ||||
. _('Enter a group name to search for') | ||||
. '</label>' => _('No groups defined, search will return all hos | ||||
ts.') | ||||
); | ||||
} | ||||
if (in_array('location', (array)self::$pluginsinstalled)) { | if (in_array('location', (array)self::$pluginsinstalled)) { | |||
$locationNames = self::getSubObjectIDs( | $locationNames = self::getSubObjectIDs( | |||
'Location', | 'Location', | |||
'', | '', | |||
'name' | 'name' | |||
); | ); | |||
natcasesort($locationNames); | if (is_array($locationNames) && count($locationNames) > 0) { | |||
if (count($locationNames) > 0) { | natcasesort($locationNames); | |||
$locationSelForm = self::selectForm( | $locationSelForm = self::selectForm( | |||
'locationsearch', | 'locationsearch', | |||
$locationNames | $locationNames | |||
); | ); | |||
unset($locationNames); | unset($locationNames); | |||
$fields += array('<label for="locationsearch">' | ||||
. _('Enter a location name to search for') | ||||
. '</label>' => $locationSelForm | ||||
); | ||||
} | } | |||
} | } | |||
if (in_array('site', (array)self::$pluginsinstalled)) { | if (in_array('site', (array)self::$pluginsinstalled)) { | |||
$siteNames = self::getSubObjectIDs( | $siteNames = self::getSubObjectIDs( | |||
'site', | 'site', | |||
'', | '', | |||
'name' | 'name' | |||
); | ); | |||
natcasesort($siteNames); | if (is_array($siteNames) && count($siteNames) > 0) { | |||
if (count($siteNames) > 0) { | natcasesort($siteNames); | |||
$siteSelForm = self::selectForm( | $siteSelForm = self::selectForm( | |||
'sitesearch', | 'sitesearch', | |||
$siteNames | $siteNames | |||
); | ); | |||
unset($siteNames); | unset($siteNames); | |||
$fields += array('<label for="sitesearch">' | ||||
. _('Enter a site name to search for') | ||||
. '</label>' => $siteSelForm | ||||
); | ||||
} | } | |||
} | } | |||
$sysproductNames = self::getSubObjectIDs( | $sysproductNames = self::getSubObjectIDs( | |||
'inventory', | 'inventory', | |||
'', | '', | |||
'sysproduct' | 'sysproduct' | |||
); | ||||
$sysproductNames = array_values( | ||||
array_filter( | ||||
array_unique( | ||||
(array)$sysproductNames | ||||
) | ||||
) | ||||
); | ); | |||
natcasesort($groupNames); | ||||
natcasesort($sysproductNames); | ||||
if (count($groupNames) > 0) { | if (is_array($sysproductNames) && count($sysproductNames) > 0) { | |||
$groupSelForm = self::selectForm( | $sysproductNames = array_values( | |||
'groupsearch', | array_filter( | |||
$groupNames | array_unique( | |||
); | (array)$sysproductNames | |||
unset($groupNames); | ) | |||
} | ) | |||
if (count($sysproductNames) > 0) { | ); | |||
natcasesort($sysproductNames); | ||||
$sysproductSelForm = self::selectForm( | $sysproductSelForm = self::selectForm( | |||
'sysproductsearch', | 'sysproductsearch', | |||
$sysproductNames | $sysproductNames | |||
); | ); | |||
unset($sysproductNames); | unset($sysproductNames); | |||
} | $fields += array('<label for="sysproductsearch">' | |||
$fields = array( | ||||
'<label for="groupsearch">' | ||||
. _('Enter a group name to search for') | ||||
. '</label>' => $groupSelForm, | ||||
'<label for="sysproductsearch">' | ||||
. _('Enter a model name to search for') | . _('Enter a model name to search for') | |||
. '</label>' => $sysproductSelForm, | . '</label>' => $sysproductSelForm | |||
'<label for="performsearch">' | ); | |||
} | ||||
$fields += array('<label for="hostpattern">' | ||||
. _('Search pattern') . '</label>' | ||||
=> '<input type="text" name="hostpattern" placeholder="Search... lea | ||||
ve empty for all elements" class="form-control" />' | ||||
) + array('<label for="performsearch">' | ||||
. _('Perform search') | . _('Perform search') | |||
. '</label>' => '<button type="submit" name="performsearch" ' | . '</label>' => '<button type="submit" name="performsearch" ' | |||
. 'class="btn btn-info btn-block" id="performsearch">' | . 'class="btn btn-info btn-block" id="performsearch">' | |||
. _('Search') | . _('Search') | |||
. '</button>' | . '</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); | array_walk($fields, $this->fieldsToData); | |||
echo '<div class="col-xs-9">'; | echo '<div class="col-xs-9">'; | |||
echo '<div class="panel panel-info">'; | echo '<div class="panel panel-info">'; | |||
echo '<div class="panel-heading text-center">'; | echo '<div class="panel-heading text-center">'; | |||
echo '<h4 class="title">'; | echo '<h4 class="title">'; | |||
echo $this->title; | echo $this->title; | |||
echo '</h4>'; | echo '</h4>'; | |||
echo '</div>'; | echo '</div>'; | |||
echo '<div class="panel-body">'; | echo '<div class="panel-body">'; | |||
echo '<form class="form-horizontal" method="post" action="' | echo '<form class="form-horizontal" method="post" action="' | |||
skipping to change at line 181 | skipping to change at line 174 | |||
* | * | |||
* @return void | * @return void | |||
*/ | */ | |||
public function filePost() | public function filePost() | |||
{ | { | |||
$this->title = _('Full Inventory Export'); | $this->title = _('Full Inventory Export'); | |||
$groupsearch = filter_input( | $groupsearch = filter_input( | |||
INPUT_POST, | INPUT_POST, | |||
'groupsearch' | 'groupsearch' | |||
); | ); | |||
if (!$groupsearch) { | ||||
$groupsearch = '%'; | ||||
} | ||||
$locationsearch = filter_input( | $locationsearch = filter_input( | |||
INPUT_POST, | INPUT_POST, | |||
'locationsearch' | 'locationsearch' | |||
); | ); | |||
$sitesearch = filter_input( | $sitesearch = filter_input( | |||
INPUT_POST, | INPUT_POST, | |||
'sitesearch' | 'sitesearch' | |||
); | ); | |||
$sysproductsearch = filter_input( | $sysproductsearch = filter_input( | |||
INPUT_POST, | INPUT_POST, | |||
'sysproductsearch' | 'sysproductsearch' | |||
); | ); | |||
if (!$sysproductsearch) { | if (!$sysproductsearch) { | |||
$sysproductsearch = '%'; | $sysproductsearch = '%'; | |||
} | } | |||
$hostpattern = filter_input( | ||||
INPUT_POST, | ||||
'hostpattern' | ||||
); | ||||
if (!$hostpattern) { | ||||
$hostpattern = '%'; | ||||
} else { | ||||
$hostpattern = '%' . $hostpattern . '%'; | ||||
} | ||||
array_walk( | array_walk( | |||
self::$inventoryCsvHead, | self::$inventoryCsvHead, | |||
function (&$classGet, &$csvHeader) { | function (&$classGet, &$csvHeader) { | |||
$this->ReportMaker->addCSVCell($csvHeader); | $this->ReportMaker->addCSVCell($csvHeader); | |||
unset($classGet, $csvHeader); | unset($classGet, $csvHeader); | |||
} | } | |||
); | ); | |||
$this->ReportMaker->endCSVLine(); | $this->ReportMaker->endCSVLine(); | |||
$this->headerData = array( | $this->headerData = array( | |||
_('Host name'), | _('Host name'), | |||
skipping to change at line 228 | skipping to change at line 225 | |||
'${sysprod}', | '${sysprod}', | |||
'${sysser}' | '${sysser}' | |||
); | ); | |||
$this->attributes = array( | $this->attributes = array( | |||
array(), | array(), | |||
array(), | array(), | |||
array(), | array(), | |||
array() | array() | |||
); | ); | |||
$groupIDs = self::getSubObjectIDs( | $groupHostIDs = array(); | |||
'Group', | if ($groupsearch) { | |||
array('name' => $groupsearch), | $groupIDs = self::getSubObjectIDs( | |||
'id' | 'Group', | |||
); | array('name' => $groupsearch), | |||
'id' | ||||
$groupHostIDs = self::getSubObjectIDs( | ); | |||
'GroupAssociation', | $groupHostIDs = self::getSubObjectIDs( | |||
array('groupID' => $groupIDs), | 'GroupAssociation', | |||
'hostID' | array('groupID' => $groupIDs), | |||
); | 'hostID' | |||
); | ||||
} | ||||
if (in_array('location', (array)self::$pluginsinstalled) && $locationsea rch) { | if (in_array('location', (array)self::$pluginsinstalled) && $locationsea rch) { | |||
$locationIDs = self::getSubObjectIDs( | $locationIDs = self::getSubObjectIDs( | |||
'Location', | 'Location', | |||
array('name' => $locationsearch), | array('name' => $locationsearch), | |||
'id' | 'id' | |||
); | ); | |||
$locationHostIDs = self::getSubObjectIDs( | $locationHostIDs = self::getSubObjectIDs( | |||
'LocationAssociation', | 'LocationAssociation', | |||
array('locationID' => $locationIDs), | array('locationID' => $locationIDs), | |||
'hostID' | 'hostID' | |||
); | ); | |||
$groupHostIDs = array_intersect($locationHostIDs, $groupHostIDs); | $groupHostIDs = array_intersect($locationHostIDs, $groupHostIDs); | |||
} | } | |||
if (in_array('site', (array)self::$pluginsinstalled) && $sitesearch) { | if (in_array('site', (array)self::$pluginsinstalled) && $sitesearch) { | |||
$siteIDs = self::getSubObjectIDs( | $siteIDs = self::getSubObjectIDs( | |||
'Site', | 'Site', | |||
array('name' => $sitesearch), | array('name' => $sitesearch), | |||
'id' | 'id' | |||
); | ); | |||
$siteHostIDs = self::getSubObjectIDs( | $siteHostIDs = self::getSubObjectIDs( | |||
'SiteHostAssociation', | 'SiteHostAssociation', | |||
array('siteID' => $siteIDs), | array('siteID' => $siteIDs), | |||
'hostID' | 'hostID' | |||
); | ); | |||
$groupHostIDs = array_intersect($siteHostIDs, $groupHostIDs); | $groupHostIDs = array_intersect($siteHostIDs, $groupHostIDs); | |||
} | } | |||
$sysproductIDs = self::getSubObjectIDs( | $sysproductIDs = self::getSubObjectIDs( | |||
'Inventory', | 'Inventory', | |||
array('sysproduct' => $sysproductsearch), | array('sysproduct' => $sysproductsearch), | |||
'hostID' | 'hostID' | |||
); | ); | |||
$groupHostIDs = array_intersect($sysproductIDs, $groupHostIDs); | $groupHostIDs = array_intersect($sysproductIDs, $groupHostIDs); | |||
Route::listem( | if ($groupsearch) { | |||
'host', | Route::listem( | |||
'name', | 'host', | |||
'false', | 'name', | |||
array( | 'false', | |||
'id' => $groupHostIDs | array( | |||
'id' => $groupHostIDs, | ||||
'name' => $hostpattern | ||||
) | ) | |||
); | ); | |||
} else { | ||||
Route::listem( | ||||
'host', | ||||
'name', | ||||
'false', | ||||
array('name' => $hostpattern) | ||||
); | ||||
} | ||||
$Hosts = json_decode( | $Hosts = json_decode( | |||
Route::getData() | Route::getData() | |||
); | ); | |||
$Hosts = $Hosts->hosts; | $Hosts = $Hosts->hosts; | |||
foreach ((array)$Hosts as &$Host) { | foreach ((array)$Hosts as &$Host) { | |||
$Image = $Host->image; | $Image = $Host->image; | |||
$Inventory = $Host->inventory; | $Inventory = $Host->inventory; | |||
$this->data[] = array( | $this->data[] = array( | |||
'host_name' => $Host->name, | 'host_name' => $Host->name, | |||
skipping to change at line 330 | skipping to change at line 339 | |||
} | } | |||
$this->ReportMaker->appendHTML($this->process(12)); | $this->ReportMaker->appendHTML($this->process(12)); | |||
echo '<div class="col-xs-9">'; | echo '<div class="col-xs-9">'; | |||
echo '<div class="panel panel-info">'; | echo '<div class="panel panel-info">'; | |||
echo '<div class="panel-heading text-center">'; | echo '<div class="panel-heading text-center">'; | |||
echo '<h4 class="title">'; | echo '<h4 class="title">'; | |||
echo $this->title; | echo $this->title; | |||
echo '</h4>'; | echo '</h4>'; | |||
echo '</div>'; | echo '</div>'; | |||
echo '<div class="panel-body">'; | echo '<div class="panel-body">'; | |||
if (count($this->data) > 0) { | if (is_array($this->data) && count($this->data) > 0) { | |||
echo '<div class="text-center">'; | echo '<div class="text-center">'; | |||
printf( | printf( | |||
$this->reportString, | $this->reportString, | |||
'InventoryReport', | 'InventoryReport', | |||
_('Export CSV'), | _('Export CSV'), | |||
_('Export CSV'), | _('Export CSV'), | |||
self::$csvfile, | self::$csvfile, | |||
'InventoryReport', | 'InventoryReport', | |||
_('Export PDF'), | _('Export PDF'), | |||
_('Export PDF'), | _('Export PDF'), | |||
End of changes. 25 change blocks. | ||||
94 lines changed or deleted | 105 lines changed or added |