PHP Classes

File: views/device-info/index.php

Recommend this page to a friend!
  Classes of Uldis Nelsons   d3 PHP Printer Monitoring   views/device-info/index.php   Download  
File: views/device-info/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: d3 PHP Printer Monitoring
Display and alert about the status of a printer
Author: By
Last change:
Date: 3 years ago
Size: 4,136 bytes
 

Contents

Class file image Download
<?php

use d3system\yii2\web\D3SystemView;
use
d3yii2\d3printer\logic\health\DeviceHealth;
use
d3yii2\d3printer\logic\read\ReadConfiguration;
use
eaBlankonThema\assetbundles\layout\LayoutAsset;
use
eaBlankonThema\components\FlashHelper;
use
eaBlankonThema\widget\ThAlertList;
use
eaBlankonThema\widget\ThButton;
use
eaBlankonThema\widget\ThReturnButton;
use
yii\helpers\Url;

LayoutAsset::register($this);

/**
 * @var D3SystemView $this
 * @var d3yii2\d3printer\models\AlertSettings $model
 * @var DeviceHealth $deviceHealth
 * @var ReadConfiguration $configHealth
 * @var bool $statusOk
 * @var string $status
 * @var bool $cartridgeOk
 * @var string $cartridge
 * @var bool $drumOk
 * @var string $drum
 * @var array $lastLoggedErrors;
 * @var string $printerCode;
 * @var string $component;
 */


$this->title = 'DeviceHealth info';

$this->setPageHeader($this->title);
$this->setPageIcon('');
$this->setSettingButton([
   
'alert-settings',
   
'addSectionKey' => $printerCode,
   
'component' => $component
]);

if (
$configHealth) {
   
$configAttributeLabels = $configHealth->device->attributeLabels();
}
?>
<div class="row">
    <?= ThAlertList::widget() ?>
<div class="col-md-9">
        <div class="panel rounded shadow">
            <div class="panel-body rounded-bottom">
                <h4><?= $deviceHealth->printerName ?? '' ?></h4>
                <?php if ($deviceHealth): ?>
Status: <?= $statusOk
                       
? '<span style="color:darkgreen">' . $status . '</span>'
                       
: '<span style="color:red">' . $status . '</span>'
                   
?><br>
                    Cartridge: <?= $cartridgeOk
                   
? '<span style="color:darkgreen">' . $cartridge . '</span>'
                   
: '<span style="color:red">' . $cartridge . '</span>'
                   
?><br>
                    Drum: <?= $drumOk
                       
? '<span style="color:darkgreen">' . $drum . '</span>'
                       
: '<span style="color:red">' . $drum . '</span>'
                   
?>
<?php endif; ?>
<hr>
                <?= ThButton::widget([
                   
'type' => ThButton::TYPE_PRIMARY,
                   
'label' => 'Set Printer defaults',
                   
'link' => Url::to(['set-default-settings', 'component' => Yii::$app->request->get('component')])
                ])
?>
</div>
        </div>
        <div class="panel rounded shadow">
            <div class="panel-body rounded-bottom">
                <h4>Print Settings</h4>
                <?php
               
if ($configHealth) {
                    foreach (
$configHealth->device->printSettings() as $key => $value) {
                        echo
$configAttributeLabels[$key] . ': ' . $value . '<br>';
                    }
                }
?>
</div>
        </div>
        <div class="panel rounded shadow">
            <div class="panel-body rounded-bottom">
                <h4>Paper Settings</h4>
                <?php
               
if ($configHealth) {
                    foreach (
$configHealth->device->paperSettings() as $key => $value) {
                        echo
$configAttributeLabels[$key] . ': ' . $value . '<br>';
                    }
                }
?>
</div>
        </div>
        <div class="panel rounded shadow">
            <div class="panel-body rounded-bottom">
                <h4>Energy Settings</h4>
                <?php
               
if ($configHealth) {
                    foreach (
$configHealth->device->energySettings() as $key => $value) {
                        echo
$configAttributeLabels[$key] . ': ' . $value . '<br>';
                    }
                }
?>
</div>
        </div>
        <div class="panel rounded shadow">
            <div class="panel-body rounded-bottom">
                <h4>Last Errors</h4>
                <?php
               
foreach ($lastLoggedErrors as $error) {
                    echo
str_replace(PHP_EOL, '<br>', $error) . '<hr>';
                }
?>
</div>
        </div>
    </div>
</div>