/** snapin_log_post()
 		Display's the dates to filter through.
 	*/
 public function snapin_log_post()
 {
     // Set title
     $this->title = _('FOG Snapin Log');
     // This gets the download links for which type of file you want.
     print "\n\t\t\t\t<h2>" . '<a href="export.php?type=csv&filename=SnapinLog" alt="Export CSV" title="Export CSV" target="_blank">' . $this->csvfile . '</a> <a href="export.php?type=pdf&filename=SnapinLog" alt="Export PDF" title="Export PDF" target="_blank">' . $this->pdffile . '</a></h2>';
     // Header Data
     $this->headerData = array(_('Snapin Name'), _('State'), _('Return Code'), _('Return Desc'), _('Create Date'), _('Create Time'));
     // Templates
     $this->templates = array('${snap_name}', '${snap_state}', '${snap_return}', '${snap_detail}', '${snap_create}', '${snap_time}');
     // Setup Report Maker for this class.
     $ReportMaker = new ReportMaker();
     // Set dates and check order is proper
     $date1 = $_REQUEST['date1'];
     $date2 = $_REQUEST['date2'];
     if ($date1 > $date2) {
         $date1 = $_REQUEST['date2'];
         $date2 = $_REQUEST['date1'];
     }
     $date2 = date('Y-m-d', strtotime($date2 . '+1 day'));
     // This is just for the header in the CSV:
     $csvHead = array(_('Host ID'), _('Host Name'), _('Host MAC'), _('Snapin ID'), _('Snapin Name'), _('Snapin Description'), _('Snapin File'), _('Snapin Args'), _('Snapin Run With'), _('Snapin Run With Args'), _('Snapin State'), _('Snapin Return Code'), _('Snapin Return Detail'), _('Snapin Creation Date'), _('Snapin Creation Time'), _('Job Create Date'), _('Job Create Time'), _('Task Checkin Date'), _('Task Checkin Time'));
     foreach ((array) $csvHead as $csvHeader) {
         $ReportMaker->addCSVCell($csvHeader);
     }
     $ReportMaker->endCSVLine();
     // Find all snapin tasks
     $SnapinTasks = $this->getClass('SnapinTaskManager')->find(array('checkin' => '', 'complete' => ''), 'OR', '', '', "BETWEEN '{$date1}' AND '{$date2}'");
     foreach ((array) $SnapinTasks as $SnapinTask) {
         $SnapinCheckin1 = $this->nice_date($SnapinTask->get('checkin'));
         $SnapinCheckin2 = $this->nice_date($SnapinTask->get('complete'));
         // Get the Task based on create date thru complete date
         // Get the snapin
         $Snapin = new Snapin($SnapinTask->get('snapinID'));
         // Get the Job
         $SnapinJob = new SnapinJob($SnapinTask->get('jobID'));
         // Get the Host
         $Host = new Host($SnapinJob->get('hostID'));
         $hostID = $SnapinJob->get('hostID');
         $hostName = $Host->isValid() ? $Host->get('name') : '';
         $hostMac = $Host->isValid() ? $Host->get('mac') : '';
         $snapinID = $SnapinTask->get('snapinID');
         $snapinName = $Snapin->isValid() ? $Snapin->get('name') : '';
         $snapinDesc = $Snapin->isValid() ? $Snapin->get('description') : '';
         $snapinFile = $Snapin->isValid() ? $Snapin->get('file') : '';
         $snapinArgs = $Snapin->isValid() ? $Snapin->get('args') : '';
         $snapinRw = $Snapin->isValid() ? $Snapin->get('runWith') : '';
         $snapinRwa = $Snapin->isValid() ? $Snapin->get('runWithArgs') : '';
         $snapinState = $SnapinTask->get('stateID');
         $snapinReturn = $SnapinTask->get('return');
         $snapinDetail = $SnapinTask->get('detail');
         $snapinCreateDate = $Snapin->isValid() ? $this->formatTime($Snapin->get('createdTime'), 'Y-m-d') : '';
         $snapinCreateTime = $Snapin->isValid() ? $this->formatTime($Snapin->get('createdTime'), 'H:i:s') : '';
         $jobCreateDate = $this->formatTime($SnapinJob->get('createdTime'), 'Y-m-d');
         $jobCreateTime = $this->formatTime($SnapinJob->get('createdTime'), 'H:i:s');
         $TaskCheckinDate = $SnapinCheckin1->format('Y-m-d');
         $TaskCheckinTime = $SnapinCheckin2->format('H:i:s');
         $this->data[] = array('snap_name' => $snapinName, 'snap_state' => $snapinState, 'snap_return' => $snapinReturn, 'snap_detail' => $snapinDetail, 'snap_create' => $snapinCreateDate, 'snap_time' => $snapinCreateTime);
         $ReportMaker->addCSVCell($hostID);
         $ReportMaker->addCSVCell($hostName);
         $ReportMaker->addCSVCell($HostMac);
         $ReportMaker->addCSVCell($snapinID);
         $ReportMaker->addCSVCell($snapinName);
         $ReportMaker->addCSVCell($snapinDesc);
         $ReportMaker->addCSVCell($snapinFile);
         $ReportMaker->addCSVCell($snapinArgs);
         $ReportMaker->addCSVCell($snapinRw);
         $ReportMaker->addCSVCell($snapinRwa);
         $ReportMaker->addCSVCell($snapinState);
         $ReportMaker->addCSVCell($snapinReturn);
         $ReportMaker->addCSVCell($snapinDetail);
         $ReportMaker->addCSVCell($snapinCreateDate);
         $ReportMaker->addCSVCell($snapinCreateTime);
         $ReportMaker->addCSVCell($jobCreateDate);
         $ReportMaker->addCSVCell($jobCreateTime);
         $ReportMaker->addCSVCell($TaskCheckinDate);
         $ReportMaker->addCSVCell($TaskCheckinTime);
         $ReportMaker->endCSVLine();
     }
     // This is for the pdf.
     $ReportMaker->appendHTML($this->process());
     $ReportMaker->outputReport(false);
     $_SESSION['foglastreport'] = serialize($ReportMaker);
 }
Exemplo n.º 2
0
 public function updateDefault($hostid, $onoff)
 {
     foreach ((array) $hostid as $id) {
         $Host = new Host($id);
         if ($Host && $Host->isValid()) {
             $Host->updateDefault($this->get('id'), in_array($Host->get('id'), $onoff));
         }
     }
     return $this;
 }
Exemplo n.º 3
0
         $Host->addAddMAC($MACs);
         if (!$Host->save()) {
             throw new Exception(_('Failed to save new Host!'));
         }
         if ($Image->isValid() && $Host->getImageMemberFromHostID()) {
             if ($Host->createImagePackage(1, 'AutoRegTask')) {
                 print _('Done, with imaging!');
             } else {
                 print _('Done, but unable to create task!');
             }
         } else {
             print _('Done!');
         }
     } else {
         $realhost = $macsimple;
         if (!$Host || !$Host->isValid()) {
             $Host = new Host(array('name' => $realhost, 'description' => sprintf('%s %s', _('Created by FOG Reg on'), date('F j, Y, g:i a')), 'createdTime' => $FOGCore->formatTime('now', 'Y-m-d H:i:s'), 'createdBy' => 'FOGREG'));
             $Host->addPriMAC($PriMAC);
             $Host->addAddMAC($MACs);
             $Host->addModule($ids);
             if (!$Host->save()) {
                 throw new Exception(_('Failed to save new Host!'));
             }
             print _('Done');
         } else {
             print _('Already registered as') . ': ' . $Host->get('name');
         }
     }
 } else {
     print _('Already registered as') . ': ' . $Host->get('name');
 }
 public function active_snapins()
 {
     // Set title
     $this->title = 'Active Snapins';
     // Header row
     $this->headerData = array(_('Host Name'), _('Snapin'), _('Start Time'), _('State'), _('Kill'));
     $this->templates = array('${host_name}', '<form method="post" method="?node=task&sub=active-snapins">${name}', '${startDate}', '${state}', '<input type="checkbox" id="${id}" class="delid" name="rmid" value="${id}" onclick="this.form.submit()" title="Kill Task" /><label for="${id}" class="icon fa fa-minus-circle" title="' . _('Delete') . '">&nbsp;</label></form>');
     $this->attributes = array(array(), array('class' => 'c'), array('class' => 'c'), array('class' => 'c'), array('width' => 40, 'class' => 'c'));
     $SnapinTasks = $this->getClass('SnapinTaskManager')->find(array('stateID' => array(-1, 0, 1)));
     foreach ((array) $SnapinTasks as $SnapinTask) {
         if ($SnapinTask && $SnapinTask->isValid()) {
             $SnapinJobs = $this->getClass('SnapinJobManager')->find(array('id' => $SnapinTask->get('jobID')));
             foreach ((array) $SnapinJobs as $SnapinJob) {
                 if ($SnapinJob && $SnapinJob->isValid()) {
                     $Host = new Host($SnapinJob->get('hostID'));
                     if ($Host && $Host->isValid()) {
                         foreach ($Host->get('snapins') as $Snapin) {
                             if ($Snapin && $Snapin->isValid() && $Snapin->get('id') == $SnapinTask->get('snapinID')) {
                                 $this->data[] = array('id' => $SnapinTask->get('id'), 'name' => $Snapin->get('name'), 'hostID' => $Host->get('id'), 'host_name' => $Host->get('name'), 'startDate' => $SnapinTask->get('checkin'), 'state' => $SnapinTask->get('stateID') == 0 ? 'Queued' : ($SnapinTask->get('stateID') == 1 ? 'In-Progress' : 'N/A'));
                             }
                         }
                     }
                 }
             }
         }
     }
     // Hook
     $this->HookManager->processEvent('TaskActiveSnapinsData', array('headerData' => &$this->headerData, 'data' => &$this->data, 'templates' => &$this->templates, 'attributes' => &$this->attributes));
     // Output
     $this->render();
 }