From a042ee67ecfe649e93a53d2a7d27854a7e309dab Mon Sep 17 00:00:00 2001 From: Thilina Date: Mon, 28 Jun 2021 08:14:01 +0200 Subject: [PATCH] Add missing classes --- core/src/Classes/Authorizable.php | 8 + core/src/Classes/Pdf/BasePdfTemplate.php | 162 ++++++++++++++++++ core/src/Classes/Pdf/PDFRegister.php | 27 +++ core/src/Classes/Pdf/PdfBuilder.php | 8 + core/src/Classes/Pdf/PdfColour.php | 27 +++ core/src/Classes/StatsHelper.php | 33 ++++ core/src/Model/SystemData.php | 8 + .../connection/components/ConnectionTab.js | 29 ++++ .../connection/components/IceHrmProData.js | 35 ++++ .../src/connection/components/SystemData.js | 80 +++++++++ 10 files changed, 417 insertions(+) create mode 100644 core/src/Classes/Authorizable.php create mode 100644 core/src/Classes/Pdf/BasePdfTemplate.php create mode 100644 core/src/Classes/Pdf/PDFRegister.php create mode 100644 core/src/Classes/Pdf/PdfBuilder.php create mode 100644 core/src/Classes/Pdf/PdfColour.php create mode 100644 core/src/Classes/StatsHelper.php create mode 100644 core/src/Model/SystemData.php create mode 100644 web/admin/src/connection/components/ConnectionTab.js create mode 100644 web/admin/src/connection/components/IceHrmProData.js create mode 100644 web/admin/src/connection/components/SystemData.js diff --git a/core/src/Classes/Authorizable.php b/core/src/Classes/Authorizable.php new file mode 100644 index 00000000..6f8a4e9a --- /dev/null +++ b/core/src/Classes/Authorizable.php @@ -0,0 +1,8 @@ +AliasNbPages(); + $this->AddPage(); + $this->SetTitle($title); + $this->date = $date = date('c'); + } + + // @codingStandardsIgnoreStart + function Header() + { + // Logo + try { + $this->Image(\Classes\UIManager::getInstance()->getCompanyLogoUrl(), 10, 10, 0, 10); + } catch (\Exception $e) { + } + + PdfColour::setTextColor($this, PdfColour::GREY_100); + // Arial bold 15 + $this->SetFont('Arial', '', 9); + // Company name + $companyName = SettingsManager::getInstance()->getSetting('Company: Name'); + $this->Cell(30, 23, $companyName, 0, 0, 'L'); + PdfColour::setDrawColor($this, PdfColour::GREY_100); + $this->Line(10, 26, self::WIDTH - 10, 26); + // Line break + $this->Ln(20); + } + + function Footer() + { + PdfColour::setTextColor($this, PdfColour::GREY_100); + // Position at 1.5 cm from bottom + $this->SetY(-15); + // Arial italic 8 + $this->SetFont('Arial', 'I', 8); + // Page number + $this->Cell(0, 10, 'Page '.$this->PageNo().'/{nb}, Date:'.$this->date, 0, 0, 'C'); + } + // @codingStandardsIgnoreEnd + + public function addH1($title, $style = 'B', $textAlignment = 'C') + { + $this->addH($title, $style, $textAlignment, 21); + } + + public function addH2($title, $style = 'B', $textAlignment = 'C') + { + $this->addH($title, $style, $textAlignment, 17); + } + + public function addH3($title, $style = 'B', $textAlignment = 'C') + { + $this->addH($title, $style, $textAlignment, 14); + } + + public function addH($title, $style = 'B', $textAlignment = 'C', $fontSize = 16) + { + PdfColour::setTextColor($this, PdfColour::BLACK_LIGHT); + $this->SetFont('Arial', $style, $fontSize); + $this->Cell(0, 10, $title, 0, 1, $textAlignment); + } + + public function addBorderedText($text) + { + $this->addText($text, '', 'L', 10, PdfColour::BLACK_LIGHT, 1, PdfColour::GREY_DARK); + } + + public function addText( + $text, + $style = '', + $textAlignment = 'L', + $fontSize = 10, + $color = PdfColour::BLACK_LIGHT, + $cellBorder = 0, + $cellBorderColor = PdfColour::GREY_DARK + ) { + PdfColour::setTextColor($this, $color); + $this->SetFont('Arial', $style, $fontSize); + if ($cellBorder === 1) { + PdfColour::setDrawColor($this, $cellBorderColor); + } + PdfColour::setFillColor($this, PdfColour::WHITE); + $this->MultiCell(0, 5, $text, $cellBorder, 1, $textAlignment); + } + + public function addKeyValue($key, $value, $type = 'text') + { + PdfColour::setDrawColor($this, PdfColour::GREY_DARK); + PdfColour::setFillColor($this, PdfColour::GREY); + + + if ($type === 'textarea') { + $this->Cell(0, 10, $key, 1, 1, 'L', true); + } else { + $this->Cell(80, 10, $key, 1, 0, 'L', true); + } + + PdfColour::setFillColor($this, PdfColour::WHITE); + + if ($type === 'textarea') { + $this->MultiCell(0, 5, $value, 1, 1, 'L'); + } elseif ($type === 'date') { + $value = date('Y-m-d', strtotime($value)); + $this->Cell(110, 10, $value, 1, 1, 'L', true); + } elseif ($type === 'select2multi') { + $value = json_decode($value, true); + $value = !empty($value) ? join(',', $value) : ''; + $this->Cell(110, 10, $value, 1, 1, 'L', true); + } else { + $this->Cell(110, 10, $value, 1, 1, 'L', true); + } + } + + public function addKeyValueObject($key, $value) + { + PdfColour::setDrawColor($this, PdfColour::GREY_DARK); + PdfColour::setFillColor($this, PdfColour::GREY); + $this->Cell(80, 10, $key, 1, 0, 'L', true); + + PdfColour::setFillColor($this, PdfColour::WHITE); + $this->MultiCell(110, 10, $value, 1, 1, true); + } + + public function addHR($width = 0) + { + $this->Ln(2); + PdfColour::setDrawColor($this, PdfColour::GREY_DARK); + PdfColour::setFillColor($this, PdfColour::GREY_DARK); + $this->Cell($width, 0.2, '', 0, 0, '', true); + // Line break + $this->Ln(3); + } + + public function getImageFromDataURI($dataURI) + { + $img = explode(',', $dataURI, 2)[1]; + return 'data://text/plain;base64,'. $img; + } + + public function addSignature($name, $data) + { + $image = $this->getImageFromDataURI($data); + $this->Ln(10); + $this->Image($image, $this->GetX(), $this->GetY(), 30, 0, 'png'); + $this->Ln(30); + $this->addHR(30); + $this->addText($name); + } +} diff --git a/core/src/Classes/Pdf/PDFRegister.php b/core/src/Classes/Pdf/PDFRegister.php new file mode 100644 index 00000000..1c290d0d --- /dev/null +++ b/core/src/Classes/Pdf/PDFRegister.php @@ -0,0 +1,27 @@ +SetFillColor($color[0], $color[1], $color[2]); + } + + public static function setTextColor(\FPDF $pdf, $color) + { + $pdf->SetTextColor($color[0], $color[1], $color[2]); + } + + public static function setDrawColor(\FPDF $pdf, $color) + { + $pdf->SetDrawColor($color[0], $color[1], $color[2]); + } +} diff --git a/core/src/Classes/StatsHelper.php b/core/src/Classes/StatsHelper.php new file mode 100644 index 00000000..5e05b0b1 --- /dev/null +++ b/core/src/Classes/StatsHelper.php @@ -0,0 +1,33 @@ +DB()->Execute("select count(id) from Employees"); + if ($employeeCount) { + $employeeCount = intval($employeeCount->fields[0]); + return $employeeCount; + } + + return 0; + } + + public static function getUserCount() + { + $user = new User(); + $userCount = $user->DB()->Execute("select count(id) from Users"); + if ($userCount) { + $userCount = intval($userCount->fields[0]); + return $userCount; + } + + return 0; + } +} diff --git a/core/src/Model/SystemData.php b/core/src/Model/SystemData.php new file mode 100644 index 00000000..0a8500c8 --- /dev/null +++ b/core/src/Model/SystemData.php @@ -0,0 +1,8 @@ + + {employeeCount.isIceHrmPro + && + + + + + + + + } + + + ); +} + +export default ConnectionTab; diff --git a/web/admin/src/connection/components/IceHrmProData.js b/web/admin/src/connection/components/IceHrmProData.js new file mode 100644 index 00000000..804b55b4 --- /dev/null +++ b/web/admin/src/connection/components/IceHrmProData.js @@ -0,0 +1,35 @@ +import React from 'react'; +import { + Statistic, + Row, + Col, + Button, + Progress, Space, +} from 'antd'; + +const dayjs = require('dayjs'); + +function IceHrmProData(props) { + const { count, allowed, validUntil, licenseId } = props; + return ( + <> + + + + + + + + + + + + + ); +} + +export default IceHrmProData; diff --git a/web/admin/src/connection/components/SystemData.js b/web/admin/src/connection/components/SystemData.js new file mode 100644 index 00000000..07a8d434 --- /dev/null +++ b/web/admin/src/connection/components/SystemData.js @@ -0,0 +1,80 @@ +import React, { useState } from 'react'; +import { + Table, + Typography, + Button, + Modal, + Alert, Space,Card, +} from 'antd'; +import { CopyOutlined } from "@ant-design/icons"; +const { Link } = Typography; + +function SystemData(props) { + const [isModalVisible, setIsModalVisible] = useState(false); + const { data, issues } = props; + const columns = [ + { + title: 'Name', + dataIndex: 'name', + key: 'name', + }, + { + title: 'Value', + dataIndex: 'value', + key: 'value', + }, + ]; + + const showModal = () => { + setIsModalVisible(true); + }; + + const handleOk = () => { + setIsModalVisible(false); + }; + + const handleCancel = () => { + setIsModalVisible(false); + }; + + return ( + + { issues.length > 0 && + + + {issues.map((item) => { + return ( + + + {item.link && + + } + + + ); + })} + + + } + + + + + + {data.map((item) => (

{`${item.name}:${item.value}`}

))} +
+ + ); +} + +export default SystemData;