snapin_log.report.php (fogproject-1.5.5) | : | snapin_log.report.php (fogproject-1.5.6) | ||
---|---|---|---|---|
<?php | <?php | |||
/** | /** | |||
* Snapin Log report | * Snapin Log report | |||
* | * | |||
* PHP Version 5 | * PHP Version 5 | |||
* | * | |||
* @category Snapin_Log | * @category Snapin_Log | |||
* @package FOGProject | * @package FOGProject | |||
* @author Tom Elliott <tommygunsster@gmail.com> | * @author Tom Elliott <tommygunsster@gmail.com> | |||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 | * @author Fernando Gietz <fernando.gietz@gmail.com> | |||
* @link https://fogproject.org | ||||
*/ | ||||
/** | ||||
* Snapin Log report | ||||
* | ||||
* @category Snapin_Log | ||||
* @package FOGProject | ||||
* @author Tom Elliott <tommygunsster@gmail.com> | ||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 | * @license http://opensource.org/licenses/gpl-3.0 GPLv3 | |||
* @link https://fogproject.org | * @link https://fogproject.org | |||
*/ | */ | |||
class Snapin_Log extends ReportManagementPage | class Snapin_Log extends ReportManagementPage | |||
{ | { | |||
public function file() | ||||
{ | ||||
$this->title = _('FOG Snapin - 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') | ||||
); | ||||
$snapinNames = self::getSubObjectIDs( | ||||
'Snapin', | ||||
'', | ||||
'name' | ||||
); | ||||
$snapinHostIDs = self::getSubObjectIDs( | ||||
'SnapinAssociation', | ||||
'', | ||||
'hostID' | ||||
); | ||||
$HostNames = self::getSubObjectIDs( | ||||
'Host', | ||||
array('id' => $snapinHostIDs), | ||||
'name' | ||||
); | ||||
unset($snapinHostIDs); | ||||
$snapinNames = array_values( | ||||
array_filter( | ||||
array_unique( | ||||
(array)$snapinNames | ||||
) | ||||
) | ||||
); | ||||
$HostNames = array_values( | ||||
array_filter( | ||||
array_unique( | ||||
(array)$HostNames | ||||
) | ||||
) | ||||
); | ||||
natcasesort($snapinNames); | ||||
natcasesort($HostNames); | ||||
if (count($snapinNames) > 0) { | ||||
$snapinSelForm = self::selectForm( | ||||
'snapinsearch', | ||||
$snapinNames | ||||
); | ||||
unset($snapinNames); | ||||
} | ||||
if (count($HostNames) > 0) { | ||||
$hostSelForm = self::selectForm( | ||||
'hostsearch', | ||||
$HostNames | ||||
); | ||||
unset($HostNames); | ||||
} | ||||
$fields = array( | ||||
'<label for="snapinsearch">' | ||||
. _('Enter a snapin name to search for') | ||||
. '</label>' => $snapinSelForm, | ||||
'<label for="hostsearch">' | ||||
. _('Enter a hostname to search for') | ||||
. '</label>' => $hostSelForm, | ||||
'<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>'; | ||||
} | ||||
/** | /** | |||
* Initial display | * Initial display | |||
* | * | |||
* @return void | * @return void | |||
*/ | */ | |||
public function file() | public function filePost() | |||
{ | { | |||
$this->title = _('FOG Snapin Log'); | $this->title = _('Found snapin information'); | |||
$hostsearch = filter_input( | ||||
INPUT_POST, | ||||
'hostsearch' | ||||
); | ||||
$snapinsearch = filter_input( | ||||
INPUT_POST, | ||||
'snapinsearch' | ||||
); | ||||
if (!$hostsearch) { | ||||
$hostsearch = '%'; | ||||
} | ||||
if (!$snapinsearch) { | ||||
$snapinsearch = '%'; | ||||
} | ||||
$hostIDs = self::getSubObjectIDs( | ||||
'Host', | ||||
array('name' => $hostsearch) | ||||
); | ||||
$jobIDs = self::getSubObjectIDs( | ||||
'SnapinJob', | ||||
array('hostID' => $hostIDs) | ||||
); | ||||
$snapinIDs = self::getSubObjectIDs( | ||||
'Snapin', | ||||
array('name' => $snapinsearch) | ||||
); | ||||
$this->headerData = array( | $this->headerData = array( | |||
_('Host Name'), | _('Host Name'), | |||
_('Snapin Name'), | _('Snapin Name'), | |||
_('State'), | _('State'), | |||
_('Return Code'), | _('Return Code'), | |||
_('Return Desc'), | _('Return Desc'), | |||
_('Checkin Time'), | _('Checkin Time'), | |||
_('Complete Time') | _('Complete Time') | |||
); | ); | |||
$this->templates = array( | $this->templates = array( | |||
skipping to change at line 87 | skipping to change at line 202 | |||
_('Task Checkin Date'), | _('Task Checkin Date'), | |||
_('Task Checkin Time'), | _('Task Checkin Time'), | |||
_('Task Complete Date'), | _('Task Complete Date'), | |||
_('Task Complete Time') | _('Task Complete Time') | |||
); | ); | |||
foreach ((array)$csvHead as $i => &$csvHeader) { | foreach ((array)$csvHead as $i => &$csvHeader) { | |||
$this->ReportMaker->addCSVCell($csvHeader); | $this->ReportMaker->addCSVCell($csvHeader); | |||
unset($csvHeader); | unset($csvHeader); | |||
} | } | |||
$this->ReportMaker->endCSVLine(); | $this->ReportMaker->endCSVLine(); | |||
Route::listem('snapintask'); | Route::listem( | |||
'snapintask', | ||||
'jobID', | ||||
'false', | ||||
array( | ||||
'snapinID' => $snapinIDs, | ||||
'jobID' => $jobIDs | ||||
) | ||||
); | ||||
$SnapinTasks = json_decode( | $SnapinTasks = json_decode( | |||
Route::getData() | Route::getData() | |||
); | ); | |||
$SnapinTasks = $SnapinTasks->snapintasks; | $SnapinTasks = $SnapinTasks->snapintasks; | |||
foreach ((array)$SnapinTasks as &$SnapinTask) { | foreach ((array)$SnapinTasks as &$SnapinTask) { | |||
$start = self::niceDate($SnapinTask->checkin); | $start = self::niceDate($SnapinTask->checkin); | |||
$end = self::niceDate($SnapinTask->complete); | $end = self::niceDate($SnapinTask->complete); | |||
if (!self::validDate($start)) { | if (!self::validDate($start)) { | |||
continue; | continue; | |||
} | } | |||
End of changes. 5 change blocks. | ||||
12 lines changed or deleted | 136 lines changed or added |