| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- /* * ********************************************************************
- * ProxmoxAddon product developed. (Aug 22, 2018)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Pages;
- use ModulesGarden\ProxmoxAddon as main;
- use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Buttons\CreateButton;
- use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Buttons\DeleteButton;
- use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Buttons\DeleteMassButton;
- use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Buttons\UpdateButton;
- use ModulesGarden\ProxmoxAddon\Core\Models\Whmcs\Server;
- use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\DataTable\Column;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\DataTable\DataProviders\Providers\QueryDataProvider;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\DataTable\DataTable;
- use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;
- /**
- * Description of ServersDataTable
- *
- * @author Pawel Kopec <pawelk@modulesgardne.com>
- */
- class IpManagementDataTable extends DataTable implements AdminArea
- {
- public function initContent()
- {
- $this->initIds('ipManagement');
- $this->title = null;
- $this->addButton(new CreateButton);
- $this->addActionButton(new UpdateButton);
- $this->addActionButton(new DeleteButton);
- $this->addMassActionButton(new DeleteMassButton);
- }
- public function replaceFieldMac_address($key, $row)
- {
- if ($row->mac_address && $row->mac_address != 'auto')
- {
- return $row->mac_address;
- }
- return '-';
- }
- public function replaceFieldTrunks($key, $row)
- {
- return $row->trunks ? $row->trunks : '-';
- }
- public function replaceFieldTag($key, $row)
- {
- return $row->tag ? $row->tag : '-';
- }
- public function replaceFieldSubnet_mask($key, $row)
- {
- return $row->subnet_mask ? $row->subnet_mask : '-';
- }
- public function replaceFieldGateway($key, $row)
- {
- return $row->gateway ? $row->gateway : '-';
- }
- public function replaceFieldName($key, $row)
- {
- if ($row->sid == "0" && !$row->sid)
- {
- return '-';
- }
- return sprintf('<a href="configservers.php?action=manage&id=%s">%s</a>', $row->sid, $row->name);;
- }
- public function replaceFieldNode($key, $row)
- {
- if ($row->node == "0" && !$row->node)
- {
- return '-';
- }
- return $row->node;
- }
- public function replaceFieldVisualization($key, $row)
- {
- if ($row->visualization == "Auto")
- {
- return '-';
- }
- return $row->visualization;
- }
- public function replaceFieldPrivate($key, $row)
- {
- if ($row->private == '1')
- {
- return '<span class="lu-label lu-label--success lu-label--status">' . sl('lang')->tr('Yes') . '</span>';
- }
- return '<span class="lu-label lu-label--default lu-label--status">' . sl('lang')->tr('No') . '</span>';
- return $row->private == '1' ? '<span class="glyphicon glyphicon-ok-sign"></span>' : '<span class="glyphicon glyphicon-remove-sign"></span>';
- }
- protected function loadHtml()
- {
- $i = (new main\App\Models\IpAddress())->getTable();
- $s = (new Server)->getTable();
- $this->addColumn((new Column('ip', $i))->setSearchable(true, Column::TYPE_STRING)->setOrderable('ASC'))
- ->addColumn((new Column('mac_address', $i))->setSearchable(true, Column::TYPE_STRING)->setOrderable())
- ->addColumn((new Column('trunks', $i))->setSearchable(true, 'int')->setOrderable())
- ->addColumn((new Column('tag', $i))->setSearchable(true, 'int')->setOrderable())
- ->addColumn((new Column('subnet_mask', $i))->setSearchable(true, 'string')->setOrderable())
- ->addColumn((new Column('gateway', $i))->setSearchable(true, 'string')->setOrderable())
- ->addColumn((new Column('cidr', $i))->setSearchable(true, 'string')->setOrderable())
- ->addColumn((new Column('name', $s))->setSearchable(true, 'string')->setOrderable())
- ->addColumn((new Column('node', $i))->setSearchable(true, 'string')->setOrderable())
- ->addColumn((new Column('visualization', $i))->setSearchable(true, 'string')->setOrderable())
- ->addColumn((new Column('private', $i))
- );
- }
- protected function loadData()
- {
- $i = (new main\App\Models\IpAddress())->getTable();
- $s = (new Server)->getTable();
- $query = (new main\App\Models\IpAddress)
- ->query()
- ->getQuery()
- ->leftJoin($s, "{$s}.id", '=', "{$i}.sid")
- ->select("{$i}.*", "{$s}.name")
- ->where("{$i}.hosting_id", '0');
- $dataProv = new QueryDataProvider();
- $dataProv->setDefaultSorting("ip", 'ASC');
- $dataProv->setData($query);
- $this->setDataProvider($dataProv);
- }
- }
|