From c74609c406f44f5ba5a751d1b73973538bdde402 Mon Sep 17 00:00:00 2001 From: cp6 Date: Fri, 29 Jan 2021 11:20:24 +1100 Subject: [PATCH] Added objects table view format Can now view servers, shared hosting and domains as a table with the icon switcher. --- assets/css/all.min.css | 2 +- assets/css/style.css | 65 +++++++++- assets/js/scripts.min.js | 33 +++++ calls.php | 3 + class.php | 261 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 359 insertions(+), 5 deletions(-) diff --git a/assets/css/all.min.css b/assets/css/all.min.css index b201d57..084eda0 100644 --- a/assets/css/all.min.css +++ b/assets/css/all.min.css @@ -2,4 +2,4 @@ * Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) */ -.fa,.fas,.far,.fal,.fad,.fab{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-.0667em}.fa-xs{font-size:.75em}.fa-sm{font-size:.875em}.fa-1x{font-size:1em}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-6x{font-size:6em}.fa-7x{font-size:7em}.fa-8x{font-size:8em}.fa-9x{font-size:9em}.fa-10x{font-size:10em}.fa-fw{text-align:center;width:1.25em}.fa-ul{list-style-type:none;margin-left:2.5em;padding-left:0}.fa-ul>li{position:relative}.fa-li{left:-2em;position:absolute;text-align:center;width:2em;line-height:inherit}.fa-border{border:solid .08em #eee;border-radius:.1em;padding:.2em .25em .15em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left,.fas.fa-pull-left,.far.fa-pull-left,.fal.fa-pull-left,.fab.fa-pull-left{margin-right:.3em}.fa.fa-pull-right,.fas.fa-pull-right,.far.fa-pull-right,.fal.fa-pull-right,.fab.fa-pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1,-1);transform:scale(1,-1)}.fa-flip-both,.fa-flip-horizontal.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(-1,-1);transform:scale(-1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-flip-both{-webkit-filter:none;filter:none}.fa-stack{display:inline-block;height:2em;line-height:2em;position:relative;vertical-align:middle;width:2.5em}.fa-stack-1x,.fa-stack-2x{left:0;position:absolute;text-align:center;width:100%}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-500px:before{content:"\f26e"}.fa-centos:before{content:"\f789"}.fa-box:before{content:"\f466"}.fa-compact-disc:before{content:"\f51f"}.fa-fedora:before{content:"\f798"}.fa-hdd:before{content:"\f0a0"}.fa-linux:before{content:"\f17c"}.fa-memory:before{content:"\f538"}.fa-microchip:before{content:"\f2db"}.fa-search:before{content:"\f002"}.fa-ubuntu:before{content:"\f7df"}.fa-windows:before{content:"\f17a"}.sr-only{border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.sr-only-focusable:active,.sr-only-focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}@font-face{font-family:'Font Awesome 5 Brands';font-style:normal;font-weight:400;font-display:block;src:url(../webfonts/fa-brands-400.eot);src:url("../webfonts/fa-brands-400.eot?#iefix") format("embedded-opentype"),url(../webfonts/fa-brands-400.woff2) format("woff2"),url(../webfonts/fa-brands-400.woff) format("woff"),url(../webfonts/fa-brands-400.ttf) format("truetype"),url("../webfonts/fa-brands-400.svg#fontawesome") format("svg")}.fab{font-family:'Font Awesome 5 Brands';font-weight:400}@font-face{font-family:'Font Awesome 5 Free';font-style:normal;font-weight:400;font-display:block;src:url(../webfonts/fa-regular-400.eot);src:url("../webfonts/fa-regular-400.eot?#iefix") format("embedded-opentype"),url(../webfonts/fa-regular-400.woff2) format("woff2"),url(../webfonts/fa-regular-400.woff) format("woff"),url(../webfonts/fa-regular-400.ttf) format("truetype"),url("../webfonts/fa-regular-400.svg#fontawesome") format("svg")}.far{font-family:'Font Awesome 5 Free';font-weight:400}@font-face{font-family:'Font Awesome 5 Free';font-style:normal;font-weight:900;font-display:block;src:url(../webfonts/fa-solid-900.eot);src:url("../webfonts/fa-solid-900.eot?#iefix") format("embedded-opentype"),url(../webfonts/fa-solid-900.woff2) format("woff2"),url(../webfonts/fa-solid-900.woff) format("woff"),url(../webfonts/fa-solid-900.ttf) format("truetype"),url("../webfonts/fa-solid-900.svg#fontawesome") format("svg")}.fa,.fas{font-family:'Font Awesome 5 Free';font-weight:900;margin-right: 0.15rem;} \ No newline at end of file +.fa,.fas,.far,.fal,.fad,.fab{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}.fa-lg{font-size:1.33333em;line-height:.75em;vertical-align:-.0667em}.fa-xs{font-size:.75em}.fa-sm{font-size:.875em}.fa-1x{font-size:1em}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-6x{font-size:6em}.fa-7x{font-size:7em}.fa-8x{font-size:8em}.fa-9x{font-size:9em}.fa-10x{font-size:10em}.fa-fw{text-align:center;width:1.25em}.fa-ul{list-style-type:none;margin-left:2.5em;padding-left:0}.fa-ul>li{position:relative}.fa-li{left:-2em;position:absolute;text-align:center;width:2em;line-height:inherit}.fa-border{border:solid .08em #eee;border-radius:.1em;padding:.2em .25em .15em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left,.fas.fa-pull-left,.far.fa-pull-left,.fal.fa-pull-left,.fab.fa-pull-left{margin-right:.3em}.fa.fa-pull-right,.fas.fa-pull-right,.far.fa-pull-right,.fal.fa-pull-right,.fab.fa-pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1,-1);transform:scale(1,-1)}.fa-flip-both,.fa-flip-horizontal.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(-1,-1);transform:scale(-1,-1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-flip-both{-webkit-filter:none;filter:none}.fa-stack{display:inline-block;height:2em;line-height:2em;position:relative;vertical-align:middle;width:2.5em}.fa-stack-1x,.fa-stack-2x{left:0;position:absolute;text-align:center;width:100%}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-500px:before{content:"\f26e"}.fa-centos:before{content:"\f789"}.fa-box:before{content:"\f466"}.fa-compact-disc:before{content:"\f51f"}.fa-fedora:before{content:"\f798"}.fa-hdd:before{content:"\f0a0"}.fa-linux:before{content:"\f17c"}.fa-memory:before{content:"\f538"}.fa-microchip:before{content:"\f2db"}.fa-search:before{content:"\f002"}.fa-table:before{content:"\f0ce"}.fa-th:before{content:"\f00a"}.fa-ubuntu:before{content:"\f7df"}.fa-windows:before{content:"\f17a"}.sr-only{border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.sr-only-focusable:active,.sr-only-focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}@font-face{font-family:'Font Awesome 5 Brands';font-style:normal;font-weight:400;font-display:block;src:url(../webfonts/fa-brands-400.eot);src:url("../webfonts/fa-brands-400.eot?#iefix") format("embedded-opentype"),url(../webfonts/fa-brands-400.woff2) format("woff2"),url(../webfonts/fa-brands-400.woff) format("woff"),url(../webfonts/fa-brands-400.ttf) format("truetype"),url("../webfonts/fa-brands-400.svg#fontawesome") format("svg")}.fab{font-family:'Font Awesome 5 Brands';font-weight:400}@font-face{font-family:'Font Awesome 5 Free';font-style:normal;font-weight:400;font-display:block;src:url(../webfonts/fa-regular-400.eot);src:url("../webfonts/fa-regular-400.eot?#iefix") format("embedded-opentype"),url(../webfonts/fa-regular-400.woff2) format("woff2"),url(../webfonts/fa-regular-400.woff) format("woff"),url(../webfonts/fa-regular-400.ttf) format("truetype"),url("../webfonts/fa-regular-400.svg#fontawesome") format("svg")}.far{font-family:'Font Awesome 5 Free';font-weight:400}@font-face{font-family:'Font Awesome 5 Free';font-style:normal;font-weight:900;font-display:block;src:url(../webfonts/fa-solid-900.eot);src:url("../webfonts/fa-solid-900.eot?#iefix") format("embedded-opentype"),url(../webfonts/fa-solid-900.woff2) format("woff2"),url(../webfonts/fa-solid-900.woff) format("woff"),url(../webfonts/fa-solid-900.ttf) format("truetype"),url("../webfonts/fa-solid-900.svg#fontawesome") format("svg")}.fa,.fas{font-family:'Font Awesome 5 Free';font-weight:900;margin-right: 0.15rem;} \ No newline at end of file diff --git a/assets/css/style.css b/assets/css/style.css index c6bcd40..5e657ee 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -331,13 +331,13 @@ textarea { .table td, .table th { padding: .75rem; - vertical-align: top; border-top: 1px solid #dee2e6 } .table thead th { vertical-align: bottom; - border-bottom: 2px solid #dee2e6 + border-bottom: 2px solid #dee2e6; + font-weight: 600; } .table-sm td, .table-sm th { @@ -1142,10 +1142,71 @@ button.close { color: #bf5151; } +.fa-th, .fa-table { + color: #8787ff; + font-size: 1.2rem; +} + +.os-td { + text-align: center; + vertical-align: middle; +} + +.objects-table td, .objects-table th { + padding: 0.6rem 0.4rem; +} + +.objects-table tr { + transition: ease-in-out 0.4s; +} + +.objects-table tr:hover { + background: #f2f7fb; +} + +.td-text-sml { + font-size: 86%; +} + +.td-text-med { + font-size: 90%; +} + +.td-special-price { + background: #ffd70014; +} + +.td-due-soon { + background: #ff00000f; +} + +.td-not-due-soon { + background: #00ff340f; +} + +.objects-table th:first-child, .objects-table td:first-child { + position: sticky; + left: 0; + background-color: #f6f6f6; +} + +.table-btn { + font-size: 0.8rem; + padding: .01rem 0.6rem; +} + +.td-nowrap { + white-space: nowrap; +} + .tab-pane { margin-top: .8rem } +.mt-1 { + margin-top: 1rem; +} + .input-group-text { color: #2d3032; background-color: #dbe4ee; diff --git a/assets/js/scripts.min.js b/assets/js/scripts.min.js index dfd7019..9d5d267 100644 --- a/assets/js/scripts.min.js +++ b/assets/js/scripts.min.js @@ -313,6 +313,39 @@ $(document).on("click", "#checkUpStatus", function () { } }); +$(document).on("click", "#viewSwitcherIcon", function () { + var icon = $(this).children().first(); + if ($("#serversTable").children().length == 0){ + $.ajax({ + type: "GET", + url: "calls.php", + data: {"type": "object_tables"}, + success: function (result) { + $("#tableViewDiv").append(result); + } + }); + icon.removeClass("fa-table"); + icon.addClass("fa-th"); + $("#cardsViewDiv" ).hide(); + $("#tableViewDiv" ).show(); + $('#viewSwitchIcon').prop('title', 'Switch to cards'); + } else { + if (icon.hasClass("fa-table")) { + icon.removeClass("fa-table"); + icon.addClass("fa-th"); + $( "#cardsViewDiv" ).hide(); + $( "#tableViewDiv" ).show(); + $('#viewSwitchIcon').prop('title', 'Switch to cards'); + } else if (icon.hasClass("fa-th")) { + icon.removeClass("fa-th"); + icon.addClass("fa-table"); + $( "#tableViewDiv" ).hide(); + $( "#cardsViewDiv" ).show(); + $('#viewSwitchIcon').prop('title', 'Switch to table'); + } + } +}); + $('#virt').change(function(){ if($(this).val() == 'DEDI'){ $('#dedi_cpu').prop("checked", true); diff --git a/calls.php b/calls.php index 8e7bf9f..e3f0dbf 100644 --- a/calls.php +++ b/calls.php @@ -40,6 +40,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $idle->getIpForDomain($_GET['hostname'], $_GET['type']); } elseif ($_GET['type'] == 'check_up') { echo $idle->checkIsUp($_GET['host']); + } elseif ($_GET['type'] == 'object_tables') { + header('Content-Type: text/html; charset=utf-8'); + echo $idle->objectTables(); } } } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { diff --git a/class.php b/class.php index e0126e1..302fb62 100644 --- a/class.php +++ b/class.php @@ -14,6 +14,9 @@ class idlersConfig const DB_NAME = 'idlers'; const DB_USERNAME = 'root'; const DB_PASSWORD = ''; + + //Have slight background color for server table values: was special price and due soon + const COLOR_TABLE = true; } class elementHelpers extends idlersConfig @@ -153,10 +156,10 @@ class elementHelpers extends idlersConfig $this->tagClose("ul"); } - protected function tableHeader(array $headers) + protected function tableHeader(array $headers, string $class = 'table table-striped table-bordered table-sm', string $id = 'orderTable') { $this->tagOpen('div', 'table-responsive'); - $this->outputString(""); + $this->outputString("
"); $this->tagOpen('thead'); $this->tagOpen('tr'); foreach ($headers as $th) { @@ -165,6 +168,13 @@ class elementHelpers extends idlersConfig $this->outputString(''); } + protected function tableTd(string $class, $content) + { + $this->tagOpen('td', $class); + $this->outputString($content); + $this->tagClose('td'); + } + protected function virtSelectOptions() { $this->selectOption('KVM', 'KVM', true); @@ -585,10 +595,15 @@ class idlers extends helperFunctions $this->navTabs(array('Services', 'Add', 'Order', 'Info', 'Search'), array('#services', '#add_server', '#order', '#info', '#search')); $this->outputString('
'); $this->outputString('
'); + $this->viewSwitcherIcon(); + $this->tagOpen('div', '', 'cardsViewDiv'); $this->serverCards(); $this->sharedHostingCards(); $this->domainCards(); $this->tagClose('div'); + $this->tagOpen('div', '', 'tableViewDiv'); + //Objects tables + $this->tagClose('div', 2); $this->outputString('
'); //BTN Bar $this->rowColOpen('row text-center', 'col-12 btn-bar-col'); @@ -856,6 +871,41 @@ class idlers extends helperFunctions $this->tagClose('div'); } + protected function serverTable() + { + if (self::SRV_SORT_TYPE == 'HOSTNAME_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `hostname` DESC;"); + } elseif (self::SRV_SORT_TYPE == 'HOSTNAME_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `hostname`;"); + } elseif (self::SRV_SORT_TYPE == 'OWNED_SINCE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `owned_since` DESC;"); + } elseif (self::SRV_SORT_TYPE == 'OWNED_SINCE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `owned_since`;"); + } elseif (self::SRV_SORT_TYPE == 'PRICE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `as_usd` DESC;"); + } elseif (self::SRV_SORT_TYPE == 'PRICE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `as_usd`;"); + } elseif (self::SRV_SORT_TYPE == 'DUE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `next_dd` DESC;"); + } elseif (self::SRV_SORT_TYPE == 'DUE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `next_dd`;"); + } else { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `servers`;"); + } + $select->execute(); + $count = $select->rowCount(); + if ($count > 0) { + $this->HTMLPhrase('h4', 'card-section-header', 'Servers ' . $count . ''); + $this->tagOpen('div', 'row'); + $this->tableHeader(array('Hostname', '', '', 'Type', 'CPU', 'RAM', 'Disk', 'Price', 'OS', 'Location', 'Provider', 'Due', 'Owned', 'IPv4', 'IPv6', 'Tags'), 'table objects-table', 'serversTable'); + while ($row = $select->fetch(PDO::FETCH_ASSOC)) { + $this->vpsTableRow($row['id']); + } + $this->outputString('
'); + $this->tagClose('div'); + } + } + protected function vpsCard(string $id) { $select = $this->dbConnect()->prepare(" @@ -920,6 +970,206 @@ class idlers extends helperFunctions $this->tagClose('div', 5); } + protected function locationForTable(string $location) + { + if (strpos($location, ',') !== false) { + return explode(',', $location)[0]; + } else { + return $location; + } + } + + public function objectTables() + { + $this->serverTable(); + $this->sharedHostingTable(); + $this->domainTable(); + } + + protected function vpsTableRow(string $id) + { + $select = $this->dbConnect()->prepare(" + SELECT servers.id,servers.hostname,servers.ipv4,servers.ipv6,servers.`cpu`,servers.cpu_freq,servers.ram,servers.ram_type,servers.`disk`, + servers.disk_type,servers.os,servers.virt,servers.tags, DATE_FORMAT(`owned_since`, '%d %b %Y') as dt, servers.was_special,locations.name as location,providers.name as provider,pricing.price,pricing.currency,pricing.term,pricing.next_dd + FROM servers INNER JOIN locations on servers.location = locations.id INNER JOIN providers on servers.provider = providers.id + INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;"); + $select->execute([$id]); + $data = $select->fetchAll(PDO::FETCH_ASSOC)[0]; + if (self::COLOR_TABLE) { + ($data['was_special'] == 1) ? $special_class = 'td-special-price' : $special_class = ''; + if ($this->processDueDate($data['id'], $data['term'], $data['next_dd']) < 7) { + $ds_class = 'td-due-soon'; + } elseif ($this->processDueDate($data['id'], $data['term'], $data['next_dd']) > 300) { + $ds_class = 'td-not-due-soon'; + } else { + $ds_class = ''; + } + } else { + $special_class = $ds_class = ''; + } + (empty($data['ipv4']) || is_null($data['ipv4'])) ? $host = $data['hostname'] : $host = $data['ipv4']; + $this->tagOpen('tr'); + $this->tableTd('', $data['hostname']); + $this->tableTd('', 'More'); + $this->tableTd('', 'Edit'); + $this->tableTd('td-text-sml', $data['virt']); + $this->tableTd('td-nowrap', $data['cpu'] . '@' . $this->mhzToGhz($data['cpu_freq']) . 'Ghz'); + $this->tableTd('td-nowrap', $data['ram'] . '' . $data['ram_type'] . ''); + $this->tableTd('td-nowrap', $data['disk'] . '' . $data['disk_type'] . ''); + $this->tableTd('td-nowrap ' . $special_class . '', $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']) . ''); + $this->tableTd('', '' . $this->osIntToIcon($data['os']) . ''); + $this->tableTd('td-nowrap td-text-med', '
' . $this->locationForTable($data['location']) . '
'); + $this->tableTd('td-nowrap td-text-med', '
' . $data['provider'] . '
'); + $this->tableTd('td-nowrap td-text-sml ' . $ds_class . '', '
' . $this->processDueDate($data['id'], $data['term'], $data['next_dd']) . ' days
'); + $this->tableTd('td-nowrap td-text-sml', '
' . $data['dt'] . '
'); + $this->tableTd('td-nowrap td-text-sml', '
' . $data['ipv4'] . '
'); + $this->tableTd('td-nowrap td-text-sml', '
' . $data['ipv6'] . '
'); + $this->tableTd('td-nowrap td-text-sml', '
' . $data['tags'] . '
'); + $this->tagClose('tr'); + } + + protected function sharedHostingTable() + { + if (self::SH_SORT_TYPE == 'DOMAIN_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `domain` DESC;"); + } elseif (self::SH_SORT_TYPE == 'DOMAIN_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `domain`;"); + } elseif (self::SH_SORT_TYPE == 'OWNED_SINCE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `owned_since` DESC;"); + } elseif (self::SH_SORT_TYPE == 'OWNED_SINCE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `owned_since`;"); + } elseif (self::SH_SORT_TYPE == 'PRICE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `as_usd` DESC;"); + } elseif (self::SH_SORT_TYPE == 'PRICE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `as_usd`;"); + } elseif (self::SH_SORT_TYPE == 'DUE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `next_dd` DESC;"); + } elseif (self::SH_SORT_TYPE == 'DUE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `next_dd`;"); + } else { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting`;"); + } + $select->execute(); + $count = $select->rowCount(); + if ($count > 0) { + $this->HTMLPhrase('h4', 'card-section-header mt-1', 'Shared hosting ' . $count . ''); + $this->tagOpen('div', 'row'); + $this->tableHeader(array('Domain', '', '', 'Type', 'Disk', 'Price', 'Location', 'Provider', 'Due', 'BWidth', 'Domains', 'Emails', 'FTPs', 'DBs', 'Since'), 'table objects-table', 'sharedHostingTable'); + while ($row = $select->fetch(PDO::FETCH_ASSOC)) { + $this->sharedHostingTableRow($row['id']); + } + $this->outputString(''); + $this->tagClose('div'); + } + } + + protected function domainTable() + { + if (self::DC_SORT_TYPE == 'DOMAIN_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `domain` DESC;"); + } elseif (self::DC_SORT_TYPE == 'DOMAIN_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `domain`;"); + } elseif (self::DC_SORT_TYPE == 'OWNED_SINCE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `owned_since` DESC;"); + } elseif (self::DC_SORT_TYPE == 'OWNED_SINCE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `owned_since`;"); + } elseif (self::DC_SORT_TYPE == 'PRICE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `as_usd` DESC;"); + } elseif (self::DC_SORT_TYPE == 'PRICE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `as_usd`;"); + } elseif (self::DC_SORT_TYPE == 'DUE_DESC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `next_dd` DESC;"); + } elseif (self::DC_SORT_TYPE == 'DUE_ASC') { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `next_dd`;"); + } else { + $select = $this->dbConnect()->prepare("SELECT `id` FROM `domains`;"); + } + $select->execute(); + $count = $select->rowCount(); + if ($count > 0) { + $this->HTMLPhrase('h4', 'card-section-header mt-1', 'Domains ' . $count . ''); + $this->tagOpen('div', 'row'); + $this->tableHeader(array('Domain', '', '', 'NS1', 'NS2', 'Price', 'Provider', 'Due', 'Since'), 'table objects-table', 'domainsTable'); + while ($row = $select->fetch(PDO::FETCH_ASSOC)) { + $this->domainTableRow($row['id']); + } + $this->outputString(''); + $this->tagClose('div'); + } + } + + protected function domainTableRow(string $id) + { + $select = $this->dbConnect()->prepare(" + SELECT domains.id,domains.domain,domains.attached_to,domains.ns1,domains.ns2,DATE_FORMAT(`owned_since`, '%d %b %Y') as dt,providers.name as provider, pricing.price,pricing.currency,pricing.term,pricing.next_dd + FROM domains INNER JOIN providers on domains.provider = providers.id + INNER JOIN pricing on domains.id = pricing.server_id WHERE domains.id = ? LIMIT 1;"); + $select->execute([$id]); + $data = $select->fetchAll(PDO::FETCH_ASSOC)[0]; + if (self::COLOR_TABLE) { + if ($this->processDueDate($data['id'], $data['term'], $data['next_dd']) < 7) { + $ds_class = 'td-due-soon'; + } elseif ($this->processDueDate($data['id'], $data['term'], $data['next_dd']) > 300) { + $ds_class = 'td-not-due-soon'; + } else { + $ds_class = ''; + } + } else { + $ds_class = ''; + } + $this->tagOpen('tr'); + $this->tableTd('td-nowrap', $data['domain']); + $this->tableTd('', 'More'); + $this->tableTd('', 'Edit'); + $this->tableTd('td-nowrap', '' . $data['ns1'] . ''); + $this->tableTd('td-nowrap', '' . $data['ns2'] . ''); + $this->tableTd('td-nowrap', $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']) . ''); + $this->tableTd('td-nowrap td-text-med', '
' . $data['provider'] . '
'); + $this->tableTd('td-nowrap td-text-sml ' . $ds_class . '', '
' . $this->processDueDate($data['id'], $data['term'], $data['next_dd']) . ' days
'); + $this->tableTd('td-nowrap', $data['dt']); + $this->tagClose('tr'); + } + + protected function sharedHostingTableRow(string $id) + { + $select = $this->dbConnect()->prepare(" + SELECT shared_hosting.id,shared_hosting.domain,shared_hosting.type,shared_hosting.was_special,shared_hosting.disk,shared_hosting.disk_type,shared_hosting.bandwidth,shared_hosting.domains_limit,shared_hosting.emails, + shared_hosting.ftp,shared_hosting.db,DATE_FORMAT(`owned_since`, '%d %b %Y') as dt,locations.name as location,providers.name as provider,pricing.price,pricing.currency,pricing.term,pricing.next_dd + FROM shared_hosting INNER JOIN locations on shared_hosting.location = locations.id INNER JOIN providers on shared_hosting.provider = providers.id + INNER JOIN pricing on shared_hosting.id = pricing.server_id WHERE shared_hosting.id = ? LIMIT 1;"); + $select->execute([$id]); + $data = $select->fetchAll(PDO::FETCH_ASSOC)[0]; + if (self::COLOR_TABLE) { + ($data['was_special'] == 1) ? $special_class = 'td-special-price' : $special_class = ''; + if ($this->processDueDate($data['id'], $data['term'], $data['next_dd']) < 7) { + $ds_class = 'td-due-soon'; + } elseif ($this->processDueDate($data['id'], $data['term'], $data['next_dd']) > 300) { + $ds_class = 'td-not-due-soon'; + } else { + $ds_class = ''; + } + } else { + $special_class = $ds_class = ''; + } + $this->tagOpen('tr'); + $this->tableTd('td-nowrap', $data['domain']); + $this->tableTd('', 'More'); + $this->tableTd('', 'Edit'); + $this->tableTd('td-nowrap td-text-sml', $data['type']); + $this->tableTd('td-nowrap', $data['disk'] . '' . $data['disk_type'] . ''); + $this->tableTd('td-nowrap ' . $special_class . '', $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']) . ''); + $this->tableTd('td-nowrap td-text-med', '
' . $this->locationForTable($data['location']) . '
'); + $this->tableTd('td-nowrap td-text-med', '
' . $data['provider'] . '
'); + $this->tableTd('td-nowrap td-text-sml ' . $ds_class . '', '
' . $this->processDueDate($data['id'], $data['term'], $data['next_dd']) . ' days
'); + $this->tableTd('td-nowrap', $data['bandwidth'] . 'TB'); + $this->tableTd('td-nowrap', $data['domains_limit']); + $this->tableTd('td-nowrap', $data['emails']); + $this->tableTd('td-nowrap', $data['ftp']); + $this->tableTd('td-nowrap', $data['db']); + $this->tableTd('td-nowrap', $data['dt']); + $this->tagClose('tr'); + } + protected function SharedHostingCard(string $id) { $select = $this->dbConnect()->prepare(" @@ -2827,6 +3077,13 @@ class idlers extends helperFunctions return $result; } + protected function viewSwitcherIcon() + { + $this->rowColOpen('row text-center', 'col-12'); + $this->outputString(''); + $this->tagClose('div', 2); + } + } class itemInsert extends idlers