Add missing classes
This commit is contained in:
8
core/src/Classes/Authorizable.php
Normal file
8
core/src/Classes/Authorizable.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Classes;
|
||||||
|
|
||||||
|
interface Authorizable
|
||||||
|
{
|
||||||
|
public function granted() : bool;
|
||||||
|
}
|
||||||
162
core/src/Classes/Pdf/BasePdfTemplate.php
Normal file
162
core/src/Classes/Pdf/BasePdfTemplate.php
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<?php
|
||||||
|
namespace Classes\Pdf;
|
||||||
|
|
||||||
|
use Classes\SettingsManager;
|
||||||
|
|
||||||
|
class BasePdfTemplate extends \FPDF
|
||||||
|
{
|
||||||
|
protected $title;
|
||||||
|
protected $date;
|
||||||
|
|
||||||
|
const WIDTH = 210;
|
||||||
|
|
||||||
|
public function initialize($title)
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
core/src/Classes/Pdf/PDFRegister.php
Normal file
27
core/src/Classes/Pdf/PDFRegister.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Classes\Pdf;
|
||||||
|
|
||||||
|
use Forms\Common\EmployeeFormPDFBuilder;
|
||||||
|
|
||||||
|
class PDFRegister
|
||||||
|
{
|
||||||
|
protected static $register = [];
|
||||||
|
|
||||||
|
public static function init()
|
||||||
|
{
|
||||||
|
self::put('empf', function ($data) {
|
||||||
|
return new EmployeeFormPDFBuilder($data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function put($key, $callback)
|
||||||
|
{
|
||||||
|
self::$register[$key] = $callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get($key)
|
||||||
|
{
|
||||||
|
return self::$register[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
8
core/src/Classes/Pdf/PdfBuilder.php
Normal file
8
core/src/Classes/Pdf/PdfBuilder.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Classes\Pdf;
|
||||||
|
|
||||||
|
interface PdfBuilder
|
||||||
|
{
|
||||||
|
public function createPdf();
|
||||||
|
}
|
||||||
27
core/src/Classes/Pdf/PdfColour.php
Normal file
27
core/src/Classes/Pdf/PdfColour.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Classes\Pdf;
|
||||||
|
|
||||||
|
class PdfColour
|
||||||
|
{
|
||||||
|
const GREY = [224, 224, 224];
|
||||||
|
const GREY_DARK = [160, 160, 160];
|
||||||
|
const WHITE = [255, 255, 255];
|
||||||
|
const BLACK_LIGHT = [84, 84, 84];
|
||||||
|
const GREY_100 = [100, 100, 100];
|
||||||
|
|
||||||
|
public static function setFillColor(\FPDF $pdf, $color)
|
||||||
|
{
|
||||||
|
$pdf->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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
33
core/src/Classes/StatsHelper.php
Normal file
33
core/src/Classes/StatsHelper.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Classes;
|
||||||
|
|
||||||
|
use Employees\Common\Model\Employee;
|
||||||
|
use Users\Common\Model\User;
|
||||||
|
|
||||||
|
class StatsHelper
|
||||||
|
{
|
||||||
|
public static function getEmployeeCount()
|
||||||
|
{
|
||||||
|
$employee = new Employee();
|
||||||
|
$employeeCount = $employee->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
core/src/Model/SystemData.php
Normal file
8
core/src/Model/SystemData.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
class SystemData extends BaseModel
|
||||||
|
{
|
||||||
|
public $table = 'SystemData';
|
||||||
|
}
|
||||||
29
web/admin/src/connection/components/ConnectionTab.js
Normal file
29
web/admin/src/connection/components/ConnectionTab.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
Row,
|
||||||
|
Col,
|
||||||
|
Space,
|
||||||
|
} from 'antd';
|
||||||
|
import IceHrmProData from './IceHrmProData';
|
||||||
|
import SystemData from './SystemData';
|
||||||
|
|
||||||
|
function ConnectionTab(props) {
|
||||||
|
const { employeeCount, systemData } = props;
|
||||||
|
return (
|
||||||
|
<Space direction="vertical" style={{ width: '100%' }}>
|
||||||
|
{employeeCount.isIceHrmPro
|
||||||
|
&&
|
||||||
|
<Row>
|
||||||
|
<Col span={8}>
|
||||||
|
<IceHrmProData {...employeeCount}/>
|
||||||
|
</Col>
|
||||||
|
<Col span={8}/>
|
||||||
|
<Col span={8}/>
|
||||||
|
</Row>
|
||||||
|
}
|
||||||
|
<SystemData {...systemData}/>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConnectionTab;
|
||||||
35
web/admin/src/connection/components/IceHrmProData.js
Normal file
35
web/admin/src/connection/components/IceHrmProData.js
Normal file
@@ -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 (
|
||||||
|
<>
|
||||||
|
<Row gutter={16}>
|
||||||
|
<Col span={12}>
|
||||||
|
<Statistic title="Number of Employees" value={`${count} / ${allowed}`} />
|
||||||
|
<Space />
|
||||||
|
<Progress type="circle" percent={parseInt((count * 100) / allowed, 10)} width={80} />
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<Statistic title="License Valid Until" value={dayjs(validUntil).format('MMM D, YYYY')}/>
|
||||||
|
<Button style={{ marginTop: 16 }} type="primary" onClick={() => {
|
||||||
|
window.open(`https://icehrm.com/renew-icehrmpro-license/${licenseId}`, '_blank');
|
||||||
|
}}>
|
||||||
|
Renew
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IceHrmProData;
|
||||||
80
web/admin/src/connection/components/SystemData.js
Normal file
80
web/admin/src/connection/components/SystemData.js
Normal file
@@ -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 (
|
||||||
|
<Space direction="vertical" style={{ width: '100%' }}>
|
||||||
|
{ issues.length > 0 &&
|
||||||
|
<Card title="System Issues">
|
||||||
|
<Space direction="vertical" style={{width: '100%'}}>
|
||||||
|
{issues.map((item) => {
|
||||||
|
return (<Space>
|
||||||
|
<Alert
|
||||||
|
message={item.message}
|
||||||
|
type={item.type}
|
||||||
|
showIcon
|
||||||
|
>
|
||||||
|
</Alert>
|
||||||
|
{item.link &&
|
||||||
|
<Button onClick={() => {
|
||||||
|
window.open(item.link, '_blank');
|
||||||
|
}}>
|
||||||
|
{item.linkText}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Space>
|
||||||
|
</Card>
|
||||||
|
}
|
||||||
|
<Card title="System Report">
|
||||||
|
<Table columns={columns} dataSource={data} />
|
||||||
|
<Button type="primary" icon={<CopyOutlined />} onClick={showModal}>
|
||||||
|
Copy System Report
|
||||||
|
</Button>
|
||||||
|
</Card>
|
||||||
|
<Modal title="System Data" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
|
||||||
|
{data.map((item) => (<p>{`${item.name}:${item.value}`}</p>))}
|
||||||
|
</Modal>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SystemData;
|
||||||
Reference in New Issue
Block a user