first commit
Some checks failed
Upgrade Test (4.x) / upgrade_test (map[file:V4_0.sql version:4.0]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_1.sql version:4.1]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_10.sql version:4.10]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_10_1.sql version:4.10.1]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_1_1.sql version:4.1.1]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_1_2.sql version:4.1.2]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_1_2_1.sql version:4.1.2.1]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_2_0_1.sql version:4.2.0.1]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_3.sql version:4.3]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_3_1.sql version:4.3.1]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_3_2.sql version:4.3.2]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_3_3.sql version:4.3.3]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_3_4.sql version:4.3.4]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_3_5.sql version:4.3.5]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_4.sql version:4.4]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_5.sql version:4.5]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_6.sql version:4.6]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_6_0_1.sql version:4.6.0.1]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_7.sql version:4.7]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_8.sql version:4.8]) (push) Has been cancelled
Upgrade Test (4.x) / upgrade_test (map[file:V4_9.sql version:4.9]) (push) Has been cancelled
Build / build (push) Has been cancelled
Cypress / cypress (push) Has been cancelled
Docker Build Test / build (push) Has been cancelled
Lint / lint (push) Has been cancelled
Scheduled Test / db_test (map[admin:mariadb-admin image:mariadb:11.0]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mariadb-admin image:mariadb:11.1]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mariadb-admin image:mariadb:11.2]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mariadb-admin image:mariadb:11.3]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mariadb-admin image:mariadb:11.4]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.0]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.10]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.11]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.1]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.2]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.3]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.4]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.5]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.6]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.7]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.8]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:10.9]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mariadb:5.5]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:5.5]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:5.6]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:5.7]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:8.0]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:8.1]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:8.2]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:8.3]) (push) Has been cancelled
Scheduled Test / db_test (map[admin:mysqladmin image:mysql:8.4]) (push) Has been cancelled
Scheduled Test / php_test (php7.4) (push) Has been cancelled
Scheduled Test / php_test (php8.0) (push) Has been cancelled
Scheduled Test / php_test (php8.1) (push) Has been cancelled
Scheduled Test / php_test (php8.2) (push) Has been cancelled
Scheduled Test / php_test (php8.3) (push) Has been cancelled
Test / test (map[image:mariadb:10.3 name:mariadb103]) (push) Has been cancelled
Test / test (map[image:mysql:5.7 name:mysql57]) (push) Has been cancelled
Test / composer_check (push) Has been cancelled
Test / installation (push) Has been cancelled

This commit is contained in:
rajesh.n 2025-10-10 15:31:35 +05:30
commit 8e294d7c5b
7870 changed files with 1678963 additions and 0 deletions

79
.github/ISSUE_TEMPLATE/bug_report.yml vendored Executable file
View File

@ -0,0 +1,79 @@
name: Bug report (OrangeHRM 4.x)
description: Create a report to help us improve
body:
- type: markdown
attributes:
value: |
**Before You Start...**
Please make sure to search for your issue - it may already reported and answered.
- type: input
id: version
attributes:
label: OrangeHRM version
placeholder: e.g. 4.3, 4.3.4, 4.10.1
validations:
required: true
- type: textarea
id: environment-details
attributes:
label: Environment details
description: |
OrangeHRM source: Release build from [Sourceforge](https://sourceforge.net/projects/orangehrm) or Git clone [e.g. Sourceforge, Git clone, Dockerhub]
Platform: Output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows), or Docker
PHP version: Output of `php -v` [e.g. 7.0, 7.1, 7.2, 7.3, 7.4]
Database and version: [e.g. MySQL 5.7, MariaDB 10.2]
Web server: [e.g. Apache 2.4, Nginx 1.4]
If applicable:
Browser: [e.g. Chrome, Firefox, Edge, Safari]
value: |
- OrangeHRM source:
- Platform:
- PHP version:
- Database and version:
- Web server:
- Browser:
validations:
required: true
- type: textarea
id: describe-the-bug
attributes:
label: Describe the bug
description: Please describe what the bug is. If applicable, add screenshots to help explain your problem.
validations:
required: true
- type: textarea
id: to-reproduce
attributes:
label: To reproduce
description: Steps to reproduce the behavior.
validations:
required: false
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: Please describe what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Relevant log output
render: shell
description: |
Provide error logs depending on the issue. Make sure to remove sensitive data from log files.
If the issue related to installation:
- symfony/log/installer.log
- logInsatall.log
If the issue related to any other:
- symfony/log/orangehrm.log
validations:
required: false

79
.github/ISSUE_TEMPLATE/bug_report_5x.yml vendored Executable file
View File

@ -0,0 +1,79 @@
name: Bug report (OrangeHRM 5.x)
description: Create a report to help us improve
labels: ["5x"]
body:
- type: markdown
attributes:
value: |
**Before You Start...**
Please make sure to search for your issue - it may already reported and answered.
- type: input
id: version
attributes:
label: OrangeHRM version
placeholder: e.g. 5.0, 5.1
validations:
required: true
- type: textarea
id: environment-details
attributes:
label: Environment details
description: |
OrangeHRM source: Release build from [Sourceforge](https://sourceforge.net/projects/orangehrm) or Git clone [e.g. Sourceforge, Git clone, Dockerhub]
Platform: Output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows), or Docker
PHP version: Output of `php -v` [e.g. 7.4, 8.0, 8.1, 8.2]
Database and version: [e.g. MySQL 5.7, MariaDB 10.2]
Web server: [e.g. Apache 2.4, Nginx 1.4]
If applicable:
Browser: [e.g. Chrome, Firefox, Edge, Safari]
value: |
- OrangeHRM source:
- Platform:
- PHP version:
- Database and version:
- Web server:
- Browser:
validations:
required: true
- type: textarea
id: describe-the-bug
attributes:
label: Describe the bug
description: Please describe what the bug is. If applicable, add screenshots to help explain your problem.
validations:
required: true
- type: textarea
id: to-reproduce
attributes:
label: To reproduce
description: Steps to reproduce the behavior.
validations:
required: false
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: Please describe what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Relevant log output
render: shell
description: |
Provide error logs depending on the issue. Make sure to remove sensitive data from log files.
If the issue related to installation:
- src/log/installer.log
If the issue related to any other:
- src/log/orangehrm.log
validations:
required: false

5
.github/ISSUE_TEMPLATE/config.yml vendored Executable file
View File

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Need a help
url: https://starterhelp.orangehrm.com
about: Please submit a request

18
.github/ISSUE_TEMPLATE/feature_request.md vendored Executable file
View File

@ -0,0 +1,18 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
Please describe the problem you are trying to solve.
**Describe the solution you'd like**
Please describe the desired behavior.
**Describe alternatives you've considered**
Please describe alternative solutions or features you have considered.

6823
.github/workflows/4x_dumps/V4_0.sql vendored Executable file

File diff suppressed because one or more lines are too long

6587
.github/workflows/4x_dumps/V4_1.sql vendored Executable file

File diff suppressed because one or more lines are too long

7941
.github/workflows/4x_dumps/V4_10.sql vendored Executable file

File diff suppressed because one or more lines are too long

7949
.github/workflows/4x_dumps/V4_10_1.sql vendored Executable file

File diff suppressed because one or more lines are too long

6595
.github/workflows/4x_dumps/V4_1_1.sql vendored Executable file

File diff suppressed because one or more lines are too long

6614
.github/workflows/4x_dumps/V4_1_2.sql vendored Executable file

File diff suppressed because one or more lines are too long

4305
.github/workflows/4x_dumps/V4_1_2_1.sql vendored Executable file

File diff suppressed because one or more lines are too long

6629
.github/workflows/4x_dumps/V4_2_0_1.sql vendored Executable file

File diff suppressed because one or more lines are too long

6662
.github/workflows/4x_dumps/V4_3.sql vendored Executable file

File diff suppressed because one or more lines are too long

6687
.github/workflows/4x_dumps/V4_3_1.sql vendored Executable file

File diff suppressed because one or more lines are too long

6688
.github/workflows/4x_dumps/V4_3_2.sql vendored Executable file

File diff suppressed because one or more lines are too long

6736
.github/workflows/4x_dumps/V4_3_3.sql vendored Executable file

File diff suppressed because one or more lines are too long

6761
.github/workflows/4x_dumps/V4_3_4.sql vendored Executable file

File diff suppressed because one or more lines are too long

6761
.github/workflows/4x_dumps/V4_3_5.sql vendored Executable file

File diff suppressed because one or more lines are too long

7129
.github/workflows/4x_dumps/V4_4.sql vendored Executable file

File diff suppressed because one or more lines are too long

7188
.github/workflows/4x_dumps/V4_5.sql vendored Executable file

File diff suppressed because one or more lines are too long

7873
.github/workflows/4x_dumps/V4_6.sql vendored Executable file

File diff suppressed because one or more lines are too long

7873
.github/workflows/4x_dumps/V4_6_0_1.sql vendored Executable file

File diff suppressed because one or more lines are too long

7873
.github/workflows/4x_dumps/V4_7.sql vendored Executable file

File diff suppressed because one or more lines are too long

7869
.github/workflows/4x_dumps/V4_8.sql vendored Executable file

File diff suppressed because one or more lines are too long

7949
.github/workflows/4x_dumps/V4_9.sql vendored Executable file

File diff suppressed because one or more lines are too long

78
.github/workflows/4x_upgrade_test.yml vendored Executable file
View File

@ -0,0 +1,78 @@
name: Upgrade Test (4.x)
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/4x_upgrade_test.yml'
- 'installer/Migration/**'
schedule:
- cron: "0 2 * * *"
jobs:
upgrade_test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
dumps:
- { "file": "V4_0.sql", "version": "4.0" }
- { "file": "V4_1.sql", "version": "4.1" }
- { "file": "V4_1_1.sql", "version": "4.1.1" }
- { "file": "V4_1_2.sql", "version": "4.1.2" }
- { "file": "V4_1_2_1.sql", "version": "4.1.2.1" }
- { "file": "V4_2_0_1.sql", "version": "4.2.0.1" }
- { "file": "V4_3.sql", "version": "4.3" }
- { "file": "V4_3_1.sql", "version": "4.3.1" }
- { "file": "V4_3_2.sql", "version": "4.3.2" }
- { "file": "V4_3_3.sql", "version": "4.3.3" }
- { "file": "V4_3_4.sql", "version": "4.3.4" }
- { "file": "V4_3_5.sql", "version": "4.3.5" }
- { "file": "V4_4.sql", "version": "4.4" }
- { "file": "V4_5.sql", "version": "4.5" }
- { "file": "V4_6.sql", "version": "4.6" }
- { "file": "V4_6_0_1.sql", "version": "4.6.0.1" }
- { "file": "V4_7.sql", "version": "4.7" }
- { "file": "V4_8.sql", "version": "4.8" }
- { "file": "V4_9.sql", "version": "4.9" }
- { "file": "V4_10.sql", "version": "4.10" }
- { "file": "V4_10_1.sql", "version": "4.10.1" }
services:
mysql:
image: "mariadb:10.2"
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
--name="database"
--tmpfs /var/lib/mysql/
steps:
- uses: actions/checkout@v4
- name: Copy dump to DB container
run: docker cp .github/workflows/4x_dumps/${{ matrix.dumps.file }} database:/dump.sql
- name: Source DB
run: docker exec database mysql -uroot -proot -e 'create database upgrade;use upgrade;source dump.sql;'
- name: Validate composer.json and composer.lock
run: |
cd src
composer validate --strict
- name: Install dependencies
run: |
php7.4 -f /usr/bin/composer install -d src
- name: Run Upgrade
run: php installer/console upgrade:run --dbHost 127.0.0.1 --dbPort 3306 --dbName upgrade --dbUser root --dbUserPassword root --currentVersion ${{ matrix.dumps.version }}

93
.github/workflows/build.yml vendored Executable file
View File

@ -0,0 +1,93 @@
name: Build
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get product version and build version
id: get_version
run: |
echo "product_version=$(grep PRODUCT_VERSION src/lib/config/Config.php | sed "s/ public const PRODUCT_VERSION = '//" | sed 's/"//g' | sed "s/';//")" >> $GITHUB_OUTPUT
echo "build_version=$(grep 'name="version" value=' build/build.xml | sed 's/ <property name="version" value="//' | sed 's;"/>;;')" >> $GITHUB_OUTPUT
- name: Validate build version
if: ${{ steps.get_version.outputs.product_version != steps.get_version.outputs.build_version }}
env:
product_version: ${{ steps.get_version.outputs.product_version }}
build_version: ${{ steps.get_version.outputs.build_version }}
run: |
echo "Build version does not match product version"
echo "Build:" $build_version
echo "Product:" $product_version
exit 1
- name: Validate composer.json and composer.lock
run: |
cd src
composer validate --strict
- name: Parse Git short hash
run: echo "git_short_hash=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Install dependencies
run: |
cd src
php7.4 -f /usr/bin/composer install --no-dev
php7.4 -f /usr/bin/composer dump-autoload --optimize --no-dev --classmap-authoritative
cd client
yarn install
cd ../../installer/client
yarn install
- name: Dump build file
run: |
cd build
echo "SHA: $GITHUB_SHA" > build
echo "Repository: $GITHUB_REPOSITORY" >> build
echo "Branch: $GITHUB_HEAD_REF" >> build
- name: Change product mode
env:
PRODUCT_MODE: ${{ secrets.PRODUCT_MODE }}
if: "${{ env.PRODUCT_MODE != '' }}"
run: |
sed -i "s/public const PRODUCT_MODE = self::MODE_DEV;/public const PRODUCT_MODE = self::$PRODUCT_MODE;/g" src/lib/config/Config.php
- name: Run build
run: |
cd src/client
yarn build
cd ../../installer/client
yarn build
cd ../../build
wget https://www.phing.info/get/phing-latest.phar
php phing-latest.phar dist
- name: Find build file
run: |
cd build
echo "file_path=$(find dist/ -maxdepth 1 -name '*.zip')" >> $GITHUB_ENV
- name: Get product mode
run: |
cd build
echo "product_mode=$(php ./product_mode.php)" >> $GITHUB_ENV
echo "Product Mode: $(php ./product_mode.php)" >> build
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: orangehrm-${{ env.git_short_hash }}
path: build/${{ env.file_path }}
- name: Upload product mode
uses: actions/upload-artifact@v4
with:
name: ${{ env.product_mode }}-mode
path: build/build

115
.github/workflows/cypress.yml vendored Executable file
View File

@ -0,0 +1,115 @@
name: Cypress
on: [ push, pull_request ]
jobs:
cypress:
runs-on: ubuntu-latest
steps:
- name: Checkout Environment
uses: actions/checkout@v4
with:
repository: orangehrm/orangehrm-os-dev-environment
- name: Checkout OrangeHRM
uses: actions/checkout@v4
with:
path: html
- name: Configure Docker Environment
run: |
pwd
ls -la
ls html
git rev-parse HEAD
echo "git_hash=$(git rev-parse HEAD)" >> $GITHUB_ENV
cp .env.dist .env
sed -i "s~LOCAL_SRC=/your/src/path~LOCAL_SRC=$PWD/html~g" .env
echo "127.0.0.1 php56 php70 php71 php72 php73 php74 php80" | sudo tee -a /etc/hosts
docker version
docker info
docker images
- name: Cache docker image
id: cache-docker-images
uses: actions/cache@v4
with:
path: image-cache
key: images-${{ env.git_hash }}
- name: Build docker image
if: steps.cache-docker-images.outputs.cache-hit != 'true'
run: |
set -ex
docker compose build nginx php-8.0
docker images
mkdir image-cache
docker save --output image-cache/images.tar orangehrm/os-dev:nginx orangehrm/os-dev:php80
ls -sh image-cache/images.tar
- name: Load docker image from cache
if: steps.cache-docker-images.outputs.cache-hit == 'true'
run: |
ls image-cache
docker load --input image-cache/images.tar
- name: Start docker containers
run: |
docker compose up -d php-8.0 mysql55
docker ps
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
cd html
git rev-parse HEAD
cd src/client && yarn install
docker exec os_dev_php80 bash -c 'cd src && composer install'
- name: Install OrangeHRM
run: |
docker exec os_dev_php80 bash --login -c 'cd src/client && yarn build --mode development'
docker exec os_dev_php80 bash -c "sed -i 's/hostName: 127.0.0.1/hostName: mysql55/g' installer/cli_install_config.yaml"
docker exec os_dev_php80 bash -c "sed -i 's/adminPassword: Ohrm@1423/adminPassword: Jacqueline@OHRM123/g' installer/cli_install_config.yaml"
docker exec os_dev_php80 bash -c "sed -i 's/adminEmployeeFirstName: OrangeHRM/adminEmployeeFirstName: Jacqueline/g' installer/cli_install_config.yaml"
docker exec os_dev_php80 bash -c "sed -i 's/adminEmployeeLastName: Admin/adminEmployeeLastName: White/g' installer/cli_install_config.yaml"
docker exec os_dev_php80 bash -c "sed -i 's/public const PRODUCT_MODE = self::MODE_PROD/public const PRODUCT_MODE = self::MODE_DEV/g' src/lib/config/Config.php"
docker exec os_dev_php80 bash -c 'chmod -R 777 src/log'
docker exec os_dev_php80 bash -c 'chmod -R 777 src/config'
docker exec os_dev_php80 bash -c 'php installer/cli_install.php'
- name: Run tests
run: |
docker exec os_dev_php80 bash -c 'php src/test/functional/tools/prepare.php'
cd html/src/test/functional
export CYPRESS_BASE_URL=http://php80/web/index.php
export CYPRESS_VIDEO=true
export CYPRESS_DEFAULT_COMMAND_TIMEOUT=10000
yarn install
yarn test
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: videos-${{ github.sha }}
path: html/src/test/functional/cypress/videos
- name: Upload logs
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: logs-${{ github.sha }}
path: html/src/log

20
.github/workflows/docker_build.yml vendored Executable file
View File

@ -0,0 +1,20 @@
name: Docker Build Test
on:
push:
branches: [ "main" ]
pull_request:
paths:
- '.github/workflows/docker_build.yml'
- 'Dockerfile'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: |
docker build . --file Dockerfile

69
.github/workflows/linting.yml vendored Executable file
View File

@ -0,0 +1,69 @@
name: Lint
on: [ push, pull_request ]
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install node dependencies
run: cd src/client && yarn install
- name: Lint client code
run: cd src/client && yarn lint
- name: Lint installer client code
run: |
cd installer/client
yarn install
yarn lint
- name: Lint Cypress tests
run: cd src/test/functional && yarn install && yarn lint
- name: Install dependencies
run: |
php8.1 -f /usr/bin/composer install -d src
php8.1 -f /usr/bin/composer install -d devTools/core
- name: Check PHP Coding Standards
run: php devTools/core/console.php php-cs-fix --php php8.1
- name: Check files changed
id: git-status
run: |
git status --porcelain
echo "status=$(git status --porcelain)" >> $GITHUB_OUTPUT
- name: Fail if files changed
if: ${{ steps.git-status.outputs.status }}
uses: actions/github-script@v4
with:
script: |
core.setFailed('Files changed with lint fix')
- name: Creating diff
if: ${{ failure() }}
run: |
git status
git diff > ${{ github.sha }}.diff
- name: Generate API doc
run: php devTools/core/console.php generate-open-api-doc --throw
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: diff-${{ github.sha }}
path: ${{ github.sha }}.diff
- name: Upload API doc
uses: actions/upload-artifact@v4
with:
name: API-doc-${{ github.sha }}
path: |
build/index.html
build/orangehrm-v2.json

185
.github/workflows/scheduled_test.yml vendored Executable file
View File

@ -0,0 +1,185 @@
name: Scheduled Test
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/scheduled_test.yml'
schedule:
- cron: "0 2 * * *"
jobs:
db_test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
database:
- { image: "mysql:5.5", admin: "mysqladmin" }
- { image: "mysql:5.6", admin: "mysqladmin" }
- { image: "mysql:5.7", admin: "mysqladmin" }
- { image: "mysql:8.0", admin: "mysqladmin" }
- { image: "mysql:8.1", admin: "mysqladmin" }
- { image: "mysql:8.2", admin: "mysqladmin" }
- { image: "mysql:8.3", admin: "mysqladmin" }
- { image: "mysql:8.4", admin: "mysqladmin" }
- { image: "mariadb:5.5", admin: "mysqladmin" }
- { image: "mariadb:10.0", admin: "mysqladmin" }
- { image: "mariadb:10.1", admin: "mysqladmin" }
- { image: "mariadb:10.2", admin: "mysqladmin" }
- { image: "mariadb:10.3", admin: "mysqladmin" }
- { image: "mariadb:10.4", admin: "mysqladmin" }
- { image: "mariadb:10.5", admin: "mysqladmin" }
- { image: "mariadb:10.6", admin: "mysqladmin" }
- { image: "mariadb:10.7", admin: "mysqladmin" }
- { image: "mariadb:10.8", admin: "mysqladmin" }
- { image: "mariadb:10.9", admin: "mysqladmin" }
- { image: "mariadb:10.10", admin: "mysqladmin" }
- { image: "mariadb:10.11", admin: "mysqladmin" }
- { image: "mariadb:11.0", admin: "mariadb-admin" }
- { image: "mariadb:11.1", admin: "mariadb-admin" }
- { image: "mariadb:11.2", admin: "mariadb-admin" }
- { image: "mariadb:11.3", admin: "mariadb-admin" }
- { image: "mariadb:11.4", admin: "mariadb-admin" }
services:
mysql:
image: ${{ matrix.database.image }}
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "${{ matrix.database.admin }} ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
--name="database"
--tmpfs /var/lib/mysql/
env:
WORKFLOW_BRANCH: ${{ secrets.WORKFLOW_BRANCH }}
steps:
- uses: actions/checkout@v4
if: "${{ github.event_name != 'push' && env.WORKFLOW_BRANCH != '' }}"
with:
ref: ${{ secrets.WORKFLOW_BRANCH }}
- uses: actions/checkout@v4
if: "${{ github.event_name == 'push' || env.WORKFLOW_BRANCH == ''}}"
- name: Source info
run: |
git log -1
git remote -v
- name: Install dependencies
run: |
php7.4 -f /usr/bin/composer install -d src
php7.4 -f /usr/bin/composer install -d devTools/core
- name: Install OrangeHRM
run: |
php7.4 installer/cli_install.php
- name: Create Test DB
run: |
mysqldump -V
php7.4 devTools/core/console.php i:create-test-db -p root --dump-options="--column-statistics=0"
- name: Configure LDAP server
run: |
cd src/plugins/orangehrmLDAPAuthenticationPlugin/test/config
docker run --detach --rm --name openldap \
--network ${{ job.container.network }} \
-p 389:1389 \
-e LDAP_ADMIN_USERNAME=admin \
-e LDAP_ADMIN_PASSWORD=admin \
-e LDAP_ROOT=dc=example,dc=org \
-e LDAP_CONFIG_ADMIN_ENABLED=yes \
-e LDAP_CONFIG_ADMIN_USERNAME=admin \
-e LDAP_CONFIG_ADMIN_PASSWORD=admin \
-e LDAP_SKIP_DEFAULT_TREE=yes \
-v $PWD/ldifs:/ldifs \
bitnami/openldap:2.6.4
cat server-config.tpl.yaml > server-config.yaml
- name: Run test
run: |
./src/vendor/bin/phpunit
- name: Stop LDAP container
if: ${{ always() }}
run: docker stop openldap
php_test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php: ["php7.4", "php8.0", "php8.1", "php8.2", "php8.3"]
services:
mysql:
image: "mariadb:10.0"
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
--tmpfs /var/lib/mysql/
env:
WORKFLOW_BRANCH: ${{ secrets.WORKFLOW_BRANCH }}
steps:
- uses: actions/checkout@v4
if: "${{ github.event_name != 'push' && env.WORKFLOW_BRANCH != '' }}"
with:
ref: ${{ secrets.WORKFLOW_BRANCH }}
- uses: actions/checkout@v4
if: "${{ github.event_name == 'push' || env.WORKFLOW_BRANCH == ''}}"
- name: Install dependencies
run: |
php7.4 -f /usr/bin/composer install -d src
php7.4 -f /usr/bin/composer install -d devTools/core
- name: Install OrangeHRM
run: |
${{ matrix.php }} installer/cli_install.php
mysqldump -V
${{ matrix.php }} devTools/core/console.php i:create-test-db -p root --dump-options="--column-statistics=0"
- name: Configure LDAP server
run: |
cd src/plugins/orangehrmLDAPAuthenticationPlugin/test/config
docker run --detach --rm --name openldap \
--network ${{ job.container.network }} \
-p 389:1389 \
-e LDAP_ADMIN_USERNAME=admin \
-e LDAP_ADMIN_PASSWORD=admin \
-e LDAP_ROOT=dc=example,dc=org \
-e LDAP_CONFIG_ADMIN_ENABLED=yes \
-e LDAP_CONFIG_ADMIN_USERNAME=admin \
-e LDAP_CONFIG_ADMIN_PASSWORD=admin \
-e LDAP_SKIP_DEFAULT_TREE=yes \
-v $PWD/ldifs:/ldifs \
bitnami/openldap:2.6.4
cat server-config.tpl.yaml > server-config.yaml
- name: Run test
run: |
${{ matrix.php }} ./src/vendor/bin/phpunit
- name: Stop LDAP container
if: ${{ always() }}
run: docker stop openldap

182
.github/workflows/test.yml vendored Executable file
View File

@ -0,0 +1,182 @@
name: Test
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
database:
- { image: "mysql:5.7", name: "mysql57" }
- { image: "mariadb:10.3", name: "mariadb103"}
services:
mysql:
image: ${{ matrix.database.image }}
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
--tmpfs /var/lib/mysql/
steps:
- uses: actions/checkout@v4
- name: Validate composer.json and composer.lock
run: |
cd src
composer validate --strict
- name: Parse Git short hash
run: echo "git_short_hash=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Install dependencies
run: |
php7.4 -f /usr/bin/composer install -d src
php7.4 -f /usr/bin/composer install -d devTools/core
cd src/client
yarn install
- name: Install OrangeHRM
run: |
php7.4 installer/cli_install.php
mysqldump -V
php7.4 devTools/core/console.php i:create-test-db -p root --dump-options="--column-statistics=0"
- name: Configure LDAP server
if: "${{ github.event_name == 'push' }}"
run: |
cd src/plugins/orangehrmLDAPAuthenticationPlugin/test/config
docker run --detach --rm --name openldap \
--network ${{ job.container.network }} \
-p 389:1389 \
-e LDAP_ADMIN_USERNAME=admin \
-e LDAP_ADMIN_PASSWORD=admin \
-e LDAP_ROOT=dc=example,dc=org \
-e LDAP_CONFIG_ADMIN_ENABLED=yes \
-e LDAP_CONFIG_ADMIN_USERNAME=admin \
-e LDAP_CONFIG_ADMIN_PASSWORD=admin \
-e LDAP_SKIP_DEFAULT_TREE=yes \
-v $PWD/ldifs:/ldifs \
bitnami/openldap:2.6.4
cat server-config.tpl.yaml > server-config.yaml
- name: Run Jest
run: |
cd src/client
yarn test:unit --coverage
- name: Run test
run: |
XDEBUG_MODE=coverage ./src/vendor/bin/phpunit --coverage-html coverage -d memory_limit=1G
tar cf - coverage/ | xz -z - > coverage.tar.xz
- name: Upload jest coverage
uses: actions/upload-artifact@v4
with:
name: jest-coverage-${{ matrix.database.name }}
path: src/client/coverage
- name: Upload phpunit coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.database.name }}
path: coverage.tar.xz
- name: Upload logs
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: logs-${{ matrix.database.name }}
path: src/log
- name: Stop LDAP container
if: "${{ github.event_name == 'push' && always() }}"
run: docker stop openldap
composer_check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Validate composer.json and composer.lock
run: |
cd src
php8.0 -f /usr/bin/composer validate --strict
php8.1 -f /usr/bin/composer validate --strict
- name: Install depandancies on PHP 8.0
run: |
cd src
rm -rf vendor
php8.0 -f /usr/bin/composer install
php8.0 -f /usr/bin/composer dump-autoload -o
- name: Install depandancies on PHP 8.1
run: |
cd src
rm -rf vendor
php8.1 -f /usr/bin/composer install
php8.1 -f /usr/bin/composer dump-autoload -o
installation:
if: github.event_name == 'push'
runs-on: ubuntu-20.04
services:
mysql:
image: mariadb:10.7
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
php7.4 -f /usr/bin/composer install -d src
php7.4 -f /usr/bin/composer install -d devTools/core
- name: Install OrangeHRM with empty database password
run: |
sed -i 's/useSameDbUserForOrangeHRM: y/useSameDbUserForOrangeHRM: n/g' installer/cli_install_config.yaml
sed -i 's/orangehrmDatabaseUser: ~/orangehrmDatabaseUser: orangehrm_1/g' installer/cli_install_config.yaml
php7.4 installer/cli_install.php
- name: Install OrangeHRM with database user
run: |
php devTools/core/console.php i:reset
git checkout installer/cli_install_config.yaml
sed -i 's/useSameDbUserForOrangeHRM: y/useSameDbUserForOrangeHRM: n/g' installer/cli_install_config.yaml
sed -i 's/orangehrmDatabaseUser: ~/orangehrmDatabaseUser: orangehrm_2/g' installer/cli_install_config.yaml
sed -i 's/orangehrmDatabasePassword: ~/orangehrmDatabasePassword: 0rang3h!m/g' installer/cli_install_config.yaml
sed -i 's/databaseName: orangehrm_mysql/databaseName: db/g' installer/cli_install_config.yaml
php7.4 installer/cli_install.php
- name: Install OrangeHRM with existing database
run: |
php devTools/core/console.php i:reset
git checkout installer/cli_install_config.yaml
sed -i 's/isExistingDatabase: n/isExistingDatabase: y/g' installer/cli_install_config.yaml
sed -i 's/privilegedDatabaseUser: root/privilegedDatabaseUser: orangehrm_2/g' installer/cli_install_config.yaml
sed -i 's/privilegedDatabasePassword: root/privilegedDatabasePassword: 0rang3h!m/g' installer/cli_install_config.yaml
sed -i 's/databaseName: orangehrm_mysql/databaseName: db/g' installer/cli_install_config.yaml
mysql -u root -proot -h 127.0.0.1 -e "CREATE DATABASE db;"
php7.4 installer/cli_install.php
- name: Check dev tool reinstall command
run: |
php devTools/core/console.php i:reinstall

15
.gitignore vendored Executable file
View File

@ -0,0 +1,15 @@
.idea
.vscode
lib/confs/
src/cache/
src/config/
src/log/
web/dist/
src/vendor
apidoc
logInsatall.log
.phpunit.result.cache
coverage/
src/plugins/orangehrmFunctionalTestingPlugin
.php-cs-fixer.cache
.php-cs-fixer.php

17
.htaccess Executable file
View File

@ -0,0 +1,17 @@
# Serve index.php automatically
DirectoryIndex index.php
# Enable rewrite engine
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
# Deny access to sensitive files
<FilesMatch "(^\.|log\.txt|.*\.log|.*\.yml|.*\.bak|.*\.config|.*\.dist|.*\.inc|.*\.swp|.*\.xml|.*\.sql|.*\.sh|.*\.xsl|.*\.conf|.*\.ini|.*\.json)$">
Require all denied
</FilesMatch>
# Deny only license and test directories (allow data/cache)
<IfModule mod_rewrite.c>
RewriteRule (/)?(license|tests|test)(/.*)?$ - [F,NC]
</IfModule>

17
.htaccess.bak Executable file
View File

@ -0,0 +1,17 @@
# Serve index.php automatically
DirectoryIndex index.php
# Enable rewrite engine
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
# Deny access to sensitive files
<FilesMatch "(^\.|log\.txt|.*\.log|.*\.yml|.*\.bak|.*\.config|.*\.dist|.*\.inc|.*\.swp|.*\.xml|.*\.sql|.*\.sh|.*\.xsl|.*\.conf|.*\.ini|.*\.json)$">
Require all denied
</FilesMatch>
# Deny only license and test directories (allow data/cache)
<IfModule mod_rewrite.c>
RewriteRule (/)?(license|tests|test)(/.*)?$ - [F,NC]
</IfModule>

32
.php-cs-fixer.dist.php Executable file
View File

@ -0,0 +1,32 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->in('src/lib')
->exclude('src/client')
->exclude('src/vendor')
->exclude('src/cache')
->exclude('src/log')
->exclude('src/config/proxy')
->exclude('devTools/core/vendor')
->exclude('src/test/functional/node_modules')
->exclude('installer/client')
// TODO:: Remove bellow excluded dirs, files
->exclude('devTools/load')
->exclude('lib')
->exclude('src/plugins/orangehrmRESTPlugin');
$config = new PhpCsFixer\Config();
return $config->setRules(
[
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'no_unused_imports' => true,
'doctrine_annotation_indentation' => true,
'doctrine_annotation_spaces' => [
'after_array_assignments_equals' => false,
'before_array_assignments_equals' => false
],
'simple_to_complex_string_variable' => true,
]
)->setFinder($finder);

3849
CHANGELOG.TXT Executable file

File diff suppressed because it is too large Load Diff

72
Dockerfile Executable file
View File

@ -0,0 +1,72 @@
FROM php:8.3-apache-bookworm
ENV OHRM_VERSION 5.7
ENV OHRM_MD5 5bd924a546e29e06c34eec73b014d139
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN set -ex; \
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg-dev \
libpng-dev \
libzip-dev \
libldap2-dev \
libicu-dev \
unzip \
; \
\
cd .. && rm -r html; \
curl -fSL -o orangehrm.zip "https://sourceforge.net/projects/orangehrm/files/stable/${OHRM_VERSION}/orangehrm-${OHRM_VERSION}.zip"; \
echo "${OHRM_MD5} orangehrm.zip" | md5sum -c -; \
unzip -q orangehrm.zip "orangehrm-${OHRM_VERSION}/*"; \
mv orangehrm-$OHRM_VERSION html; \
rm -rf orangehrm.zip; \
chown www-data:www-data html; \
chown -R www-data:www-data html/src/cache html/src/log html/src/config; \
chmod -R 775 html/src/cache html/src/log html/src/config; \
\
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-configure ldap \
--with-libdir=lib/$(uname -m)-linux-gnu/ \
; \
\
docker-php-ext-install -j "$(nproc)" \
gd \
opcache \
intl \
pdo_mysql \
zip \
ldap \
; \
\
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query -S \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/cache/apt/archives; \
rm -rf /var/lib/apt/lists/*
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=60'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.enable_cli=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
\
if command -v a2enmod; then \
a2enmod rewrite; \
fi;
VOLUME ["/var/www/html"]

674
LICENSE Executable file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

53
README.md Executable file
View File

@ -0,0 +1,53 @@
<img width="40%" alt='OrangeHRM' src='https://raw.githubusercontent.com/wiki/orangehrm/orangehrm/logos/logo.svg#gh-light-mode-only'/><img width="40%" alt='OrangeHRM' src='https://raw.githubusercontent.com/wiki/orangehrm/orangehrm/logos/logo_dark_mode.svg#gh-dark-mode-only'/>
[![Docker Pulls](https://img.shields.io/docker/pulls/orangehrm/orangehrm.svg)](https://hub.docker.com/r/orangehrm/orangehrm) [![SourceForge Downloads](https://img.shields.io/sourceforge/dm/orangehrm.svg)](https://sourceforge.net/projects/orangehrm/) [![SourceForge Downloads](https://img.shields.io/sourceforge/dt/orangehrm.svg)](https://sourceforge.net/projects/orangehrm/)
# OrangeHRM Starter Application
OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures all the essential functionalities required for any enterprise. Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com/
OrangeHRM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
## Getting started
- Download the latest version of OrangeHRM Starter [here](https://sourceforge.net/projects/orangehrm/files/latest/download).
- Prerequisites and environment set up for installing OrangeHRM Starter:
- [Install on Linux](https://starterhelp.orangehrm.com/hc/en-us/articles/6187572000540-Prerequisites-for-installing-OrangeHRM-Starter-in-Linux)
- [Install on Windows](https://starterhelp.orangehrm.com/hc/en-us/articles/6187576427804-Prerequisites-for-installing-OrangeHRM-Starter-in-Windows)
- Install OrangeHRM using the web installer:
- [OrangeHRM Starter Installation Guide](https://starterhelp.orangehrm.com/hc/en-us/articles/5295915003666-OrangeHRM-Starter-Installation-Guide)
- [OrangeHRM Starter Upgrade Guide](https://starterhelp.orangehrm.com/hc/en-us/articles/6937346912402-OrangeHRM-Starter-Upgrade-Guide-For-5x-versions-)
- For further information on how to use the product please refer to the User Guides, Tutorial videos, and FAQs available on [Help Portal](https://starterhelp.orangehrm.com)
## OrangeHRM Mobile App
<a href="https://play.google.com/store/apps/details?id=com.orangehrm.opensource" target="_blank">
<img height="54" alt='Get it on Google Play'
src='https://raw.githubusercontent.com/wiki/orangehrm/orangehrm/mobile/play_store_cropped_en_US_2022_08_04.png'/>
</a>
<a href="https://apps.apple.com/us/app/orangehrm/id1527247547" target="_blank">
<img height="54" alt='Download on the App Store'
src='https://raw.githubusercontent.com/wiki/orangehrm/orangehrm/mobile/app_store_en_US.svg'/>
</a>
## Resources
### Demo
Live demo is available at : https://opensource-demo.orangehrmlive.com
### Releases
Sourceforge : https://sourceforge.net/p/orangehrm
### Website
https://www.orangehrm.com/
## Help & Support
Submit your help requests through [OrangeHRM Help Portal](https://starterhelp.orangehrm.com/hc/en-us/requests/new) or Email to [ossupport@orangehrm.com](mailto:ossupport@orangehrm.com)
## License
GNU General Public License

3
SECURITY.md Executable file
View File

@ -0,0 +1,3 @@
# How do I report security vulnerabilities?
If you believe you have found a security vulnerability, please submit the report to our security team via [ossecurity@orangehrm.com](mailto:ossecurity@orangehrm.com).

83
bin/console Executable file
View File

@ -0,0 +1,83 @@
#!/usr/bin/env php
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
if (php_sapi_name() !== 'cli') {
echo 'Unauthorized';
exit(1);
}
$pathToAutoload = realpath(__DIR__ . '/../src/vendor/autoload.php');
$errorMessage = "
Cannot find composer dependencies.
Run below command and try again;\n
$ cd %s
$ composer install -d src
";
if (!$pathToAutoload) {
echo sprintf($errorMessage, realpath(__DIR__ . '/../'));
exit(1);
}
use OrangeHRM\Config\Config;
use OrangeHRM\Core\Command\CacheClearCommand;
use OrangeHRM\Core\Command\GenerateDoctrineProxiesCommand;
use OrangeHRM\Framework\Console\Console;
use OrangeHRM\Framework\Console\ConsoleConfigurationInterface;
use OrangeHRM\Framework\Framework;
use OrangeHRM\Framework\Http\Request;
use OrangeHRM\Framework\PluginConfigurationInterface;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
set_time_limit(0);
require_once $pathToAutoload;
$env = 'prod';
$debug = 'prod' !== $env;
$console = new Console();
new Framework($env, $debug); // initializing kernel
$request = new Request();
$pluginConfigs = Config::get('ohrm_plugin_configs');
$input = new ArgvInput();
$output = new ConsoleOutput();
$io = new SymfonyStyle($input, $output);
try {
foreach (array_values($pluginConfigs) as $pluginConfig) {
require_once $pluginConfig['filepath'];
/** @var PluginConfigurationInterface $configClass */
$configClass = new $pluginConfig['classname']();
$configClass->initialize($request);
if ($configClass instanceof ConsoleConfigurationInterface) {
$configClass->registerCommands($console);
}
}
} catch (Throwable $e) {
$io->warning($e->getMessage());
}
$console->add(new CacheClearCommand());
$console->add(new GenerateDoctrineProxiesCommand());
$console->run($input, $output);

2
build/.gitignore vendored Executable file
View File

@ -0,0 +1,2 @@
index.html
orangehrm-v2.json

138
build/build.xml Executable file
View File

@ -0,0 +1,138 @@
<?xml version="1.0" ?>
<!--
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
-->
<project name="OrangeHRM" basedir="." default="dist">
<property name="version" value="5.7"/>
<property name="package.name" value="orangehrm-${version}"/>
<resolvepath propertyName="project.dir" file=".."/>
<resolvepath propertyName="dist.dir" file="dist"/>
<property name="package.dir" value="${dist.dir}/${package.name}"/>
<exec executable="git" dir="${project.dir}" checkreturn="false" outputProperty="git.revision">
<arg value="rev-list --tags --max-count=1" />
</exec>
<property name="base.name" value="${package.name}.${git.revision}"/>
<target name="prepare">
<echo msg="Preparing build..."/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${package.dir}"/>
<touch file="release-revision-${git.revision}.txt"/>
</target>
<target name="deps.5x">
<exec executable="composer" dir="${project.dir}/src" checkreturn="false" passthru="true">
<arg value="install --no-dev" />
</exec>
<exec executable="composer" dir="${project.dir}/src" checkreturn="false" passthru="true">
<arg value="dump-autoload --optimize --no-dev --classmap-authoritative" />
</exec>
<exec executable="yarn" dir="${project.dir}/src/client" checkreturn="false" passthru="true">
<arg value="install" />
</exec>
</target>
<target name="build.client">
<exec executable="yarn" dir="${project.dir}/src/client" checkreturn="false" passthru="true">
<arg value="build" />
</exec>
</target>
<target name="build" depends="prepare,clean">
<echo>Copying files...</echo>
<copy todir="${package.dir}" includeemptydirs="true">
<fileset dir="${project.dir}">
<include name="**"/>
<include name="**/*.htaccess"/>
<include name="build/build"/>
<exclude name="build/dist/**"/>
<exclude name="build/build.xml"/>
<exclude name="build/phing-latest.phar"/>
<exclude name=".github/**"/>
<exclude name="Dockerfile"/>
<exclude name="devTools/**"/>
<exclude name="lib/confs/Conf.php"/>
<exclude name="lib/confs/cryptokeys/key.ohrm"/>
<exclude name="orangehrm-quick-start-guide.html"/>
<exclude name="src/test/**"/>
<exclude name="src/plugins/**/test/**"/>
<exclude name="src/plugins/orangehrmRESTPlugin/**"/>
<!-- 5.x related -->
<exclude name="src/client/node_modules/**"/>
<exclude name="src/client/.yarn/cache/**"/>
<exclude name="src/client/.yarn/install-state.gz"/>
<exclude name="installer/client/node_modules/**"/>
<exclude name="installer/client/.yarn/cache/**"/>
<exclude name="installer/client/.yarn/install-state.gz"/>
</fileset>
</copy>
<!-- done this way to avoid some quirks in phing behavior -->
<delete includeemptydirs="true" failonerror="false" dir="${package.dir}/src/log"/>
<delete includeemptydirs="true" failonerror="false" dir="${package.dir}/src/cache"/>
<mkdir dir="${package.dir}/src/cache"/>
<mkdir dir="${package.dir}/src/log"/>
<copy todir="${dist.dir}">
<fileset dir="${project.dir}">
<include name="orangehrm-quick-start-guide.html"/>
<include name="logo.png"/>
</fileset>
</copy>
</target>
<target name="dist" depends="build">
<echo message="Creating archives ..."/>
<zip destfile="${dist.dir}/${package.name}.zip" ignoreLinks="true">
<fileset dir="${dist.dir}">
<include name="${package.name}/**"/>
<include name="orangehrm-quick-start-guide.html"/>
<include name="logo.png"/>
<exclude name="*.zip"/>
<exclude name="*.tar.gz"/>
</fileset>
</zip>
<tar destfile="${dist.dir}/${package.name}.tar.gz" compression="gzip">
<fileset dir="${dist.dir}">
<include name="${package.name}/**"/>
<include name="orangehrm-quick-start-guide.html"/>
<include name="logo.png"/>
<exclude name="*.zip"/>
<exclude name="*.tar.gz"/>
</fileset>
</tar>
</target>
<fileset dir="./" id="deleteFiles">
<include name="release-revision-*.txt"/>
</fileset>
<target name="clean">
<echo msg="Cleaning up..."/>
<delete dir="${dist.dir}"/>
<delete>
<fileset refid="deleteFiles"/>
</delete>
</target>
</project>

23
build/product_mode.php Executable file
View File

@ -0,0 +1,23 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
require realpath(__DIR__ . '/../src/vendor/autoload.php');
use OrangeHRM\Config\Config;
echo Config::PRODUCT_MODE;

1
devTools/core/.gitignore vendored Executable file
View File

@ -0,0 +1 @@
/vendor/

27
devTools/core/composer.json Executable file
View File

@ -0,0 +1,27 @@
{
"minimum-stability": "stable",
"prefer-stable": true,
"require-dev": {
"php": "^7.4|^8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11.99.5",
"symfony/framework-bundle": "^5.4.35",
"symfony/maker-bundle": "^1.43",
"symfony/proxy-manager-bridge": "^5.4.21",
"symfony/runtime": "^5.4.35",
"symfony/yaml": "^5.4.35",
"friendsofphp/php-cs-fixer": "^3.49",
"symfony/process": "^5.4.35"
},
"autoload-dev": {
"psr-4": {
"OrangeHRM\\DevTools\\": "src/"
}
},
"config": {
"allow-plugins": {
"symfony/runtime": false
}
}
}

3650
devTools/core/composer.lock generated Executable file

File diff suppressed because it is too large Load Diff

66
devTools/core/console.php Executable file
View File

@ -0,0 +1,66 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
$pathToAutoload = realpath(__DIR__ . '/../../src/vendor/autoload.php');
$pathToDevAutoload = realpath(__DIR__ . '/vendor/autoload.php');
$errorMessage = "
Cannot find all composer dependencies.
Run below command and try again;\n
$ cd %s
$ composer install -d src
$ composer install -d devTools/core\n
";
if (!($pathToAutoload && $pathToDevAutoload)) {
echo sprintf($errorMessage, realpath(__DIR__ . '/../../'));
exit(1);
}
require_once $pathToAutoload;
require_once $pathToDevAutoload;
use OrangeHRM\DevTools\Command\AddDataGroupCommand;
use OrangeHRM\DevTools\Command\AddRolePermissionCommand;
use OrangeHRM\DevTools\Command\CreateTestDatabaseCommand;
use OrangeHRM\DevTools\Command\EventDispatcherDebugCommand;
use OrangeHRM\DevTools\Command\GenerateOpenApiDocCommand;
use OrangeHRM\DevTools\Command\PHPFixCodingStandardsCommand;
use OrangeHRM\DevTools\Command\ReInstallCommand;
use OrangeHRM\DevTools\Command\ResetInstallationCommand;
use OrangeHRM\DevTools\Command\RunMigrationClassCommand;
use OrangeHRM\Framework\ServiceContainer;
use OrangeHRM\Framework\Services;
use OrangeHRM\ORM\Doctrine;
use Symfony\Component\Console\Application;
$application = new Application();
$application->add(new AddDataGroupCommand());
$application->add(new AddRolePermissionCommand());
$application->add(new PHPFixCodingStandardsCommand());
$application->add(new EventDispatcherDebugCommand());
$application->add(new ResetInstallationCommand());
$application->add(new ReInstallCommand());
$application->add(new CreateTestDatabaseCommand());
$application->add(new RunMigrationClassCommand());
$application->add(new GenerateOpenApiDocCommand());
ServiceContainer::getContainer()->register(Services::DOCTRINE)
->setFactory([Doctrine::class, 'getEntityManager']);
$application->run();

View File

@ -0,0 +1,317 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use InvalidArgumentException;
use OrangeHRM\Core\Traits\ORM\EntityManagerHelperTrait;
use OrangeHRM\DevTools\Command\Util\EchoSqlLogger;
use OrangeHRM\Entity\ApiPermission;
use OrangeHRM\Entity\DataGroup;
use OrangeHRM\Entity\Module;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
class AddDataGroupCommand extends Command
{
use EntityManagerHelperTrait;
protected static $defaultName = 'add-data-group';
public const ARGUMENT_DATA_GROUP_NAME = 'name';
public const ARGUMENT_DATA_GROUP_DESCRIPTION = 'description';
public const OPTION_SIMULATE_INSERT = 'simulate';
public const OPTION_DATA_GROUP_CAN_READ = 'can-read';
public const OPTION_DATA_GROUP_CAN_CREATE = 'can-create';
public const OPTION_DATA_GROUP_CAN_UPDATE = 'can-update';
public const OPTION_DATA_GROUP_CAN_DELETE = 'can-delete';
public const OPTION_DATA_GROUP_IS_API = 'is-api';
public const OPTION_API_PERMISSION_MODULE = 'module';
public const OPTION_API_PERMISSION_API_NAME = 'api-name';
private SymfonyStyle $io;
/**
* @inheritDoc
*/
protected function configure()
{
$this
->setDescription('Add data group')
->addArgument(self::ARGUMENT_DATA_GROUP_NAME, InputArgument::OPTIONAL)
->addArgument(self::ARGUMENT_DATA_GROUP_DESCRIPTION, InputArgument::OPTIONAL)
->addOption(self::OPTION_DATA_GROUP_CAN_READ, 'R', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_CAN_CREATE, 'C', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_CAN_UPDATE, 'U', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_CAN_DELETE, 'D', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_IS_API, null, InputOption::VALUE_NONE)
->addOption(self::OPTION_API_PERMISSION_API_NAME, null, InputOption::VALUE_REQUIRED)
->addOption(self::OPTION_API_PERMISSION_MODULE, null, InputOption::VALUE_REQUIRED)
->addOption(self::OPTION_SIMULATE_INSERT, 's', InputOption::VALUE_NONE, 'Simulate data insertion');
}
/**
* @inheritDoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
}
/**
* @inheritDoc
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$dataGroup = $this->io->ask(
'Enter data group name (e.g. <fg=yellow>job_titles, apiv2_job_titles</>)',
null,
function (string $value = null) {
if (null === $value || '' === $value) {
throw new InvalidArgumentException('This value cannot be blank.');
}
$dataGroup = $this->getRepository(DataGroup::class)->findOneBy(['name' => $value]);
if ($dataGroup) {
throw new InvalidArgumentException("`$value` already in use.");
}
return $value;
}
);
$input->setArgument(self::ARGUMENT_DATA_GROUP_NAME, $dataGroup);
$description = $this->io->ask(
'Enter data group description (e.g. <fg=yellow>Admin - Job Titles, API-v2 Admin - Job Titles</>)',
null,
[$this, 'notBlankValidation']
);
$input->setArgument(self::ARGUMENT_DATA_GROUP_DESCRIPTION, $description);
$canRead = $this->io->confirm('Can read', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_READ, $canRead);
$canCreate = $this->io->confirm('Can create', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_CREATE, $canCreate);
$canUpdate = $this->io->confirm('Can update', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_UPDATE, $canUpdate);
$canDelete = $this->io->confirm('Can delete', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_DELETE, $canDelete);
$isApi = $this->io->confirm('Is this data group for API', false);
$input->setOption(self::OPTION_DATA_GROUP_IS_API, $isApi);
if ($isApi) {
$apiClassName = $this->io->ask(
'Enter API full qualified class name (e.g. <fg=yellow>OrangeHRM\Admin\Api\JobTitleAPI</>)',
null,
function (string $value = null) {
if (!class_exists($value)) {
throw new InvalidArgumentException('Invalid class name');
}
return $value;
}
);
$input->setOption(self::OPTION_API_PERMISSION_API_NAME, $apiClassName);
$module = $this->io->askQuestion($this->getModuleAutocompleteQuestion());
$input->setOption(self::OPTION_API_PERMISSION_MODULE, $module);
}
}
/**
* @return Question
*/
private function getModuleAutocompleteQuestion(): Question
{
$modules = $this->getRepository(Module::class)->findAll();
$modules = array_map(
function (Module $module) {
return $module->getName();
},
$modules
);
$question = new Question('Enter module name (e.g. <fg=yellow>' . implode(', ', $modules) . '</>)');
$question->setValidator([$this, 'notBlankValidation']);
$question->setAutocompleterValues($modules);
return $question;
}
/**
* @param string|null $value
* @return string
*/
public function notBlankValidation(string $value = null): string
{
if (null === $value || '' === $value) {
throw new InvalidArgumentException('This value cannot be blank.');
}
return $value;
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$simulateInsert = $input->getOption(self::OPTION_SIMULATE_INSERT);
$dataGroupName = $input->getArgument(self::ARGUMENT_DATA_GROUP_NAME);
$description = $input->getArgument(self::ARGUMENT_DATA_GROUP_DESCRIPTION);
$canRead = $input->getOption(self::OPTION_DATA_GROUP_CAN_READ);
$canCreate = $input->getOption(self::OPTION_DATA_GROUP_CAN_CREATE);
$canUpdate = $input->getOption(self::OPTION_DATA_GROUP_CAN_UPDATE);
$canDelete = $input->getOption(self::OPTION_DATA_GROUP_CAN_DELETE);
$dataGroup = new DataGroup();
$dataGroup->setName(trim($dataGroupName));
$dataGroup->setDescription(trim($description));
$dataGroup->setCanRead($canRead);
$dataGroup->setCanCreate($canCreate);
$dataGroup->setCanUpdate($canUpdate);
$dataGroup->setCanDelete($canDelete);
$this->getEntityManager()->getConfiguration()->setSQLLogger(new EchoSqlLogger());
if (!$simulateInsert) {
$this->persist($dataGroup);
}
$isApi = $input->getOption(self::OPTION_DATA_GROUP_IS_API);
if (!$isApi) {
$this->printDataGroupTable($dataGroup, $simulateInsert);
$this->printDataGroupSQL($dataGroup);
return Command::SUCCESS;
}
$moduleName = $input->getOption(self::OPTION_API_PERMISSION_MODULE);
$apiClassName = $input->getOption(self::OPTION_API_PERMISSION_API_NAME);
$apiPermission = new ApiPermission();
$apiPermission->setDataGroup($dataGroup);
$module = $this->getRepository(Module::class)->findOneBy(['name' => $moduleName]);
$apiPermission->setModule($module);
$apiPermission->setApiName($apiClassName);
if (!$simulateInsert) {
$this->persist($apiPermission);
}
$this->printDataGroupTable($dataGroup, $simulateInsert);
$this->printApiPermissionTable($apiPermission, $simulateInsert);
$this->printDataGroupSQL($dataGroup);
$this->printApiPermissionSQL($apiPermission);
return Command::SUCCESS;
}
/**
* @param DataGroup $dataGroup
* @param bool $simulateInsert
*/
private function printDataGroupTable(DataGroup $dataGroup, bool $simulateInsert): void
{
$this->io->table(
['Name', 'Description', 'Read', 'Create', 'Update', 'Delete'],
[
[
$dataGroup->getName() . ($simulateInsert ? "" : " (" . $dataGroup->getId() . ")"),
$dataGroup->getDescription(),
(int)$dataGroup->canRead(),
(int)$dataGroup->canCreate(),
(int)$dataGroup->canUpdate(),
(int)$dataGroup->canDelete(),
]
]
);
}
/**
* @param DataGroup $dataGroup
*/
private function printDataGroupSQL(DataGroup $dataGroup): void
{
$this->io->title('Sample SQL queries');
$name = $this->getEntityManager()->getConnection()->quote($dataGroup->getName());
$description = $this->getEntityManager()->getConnection()->quote($dataGroup->getDescription());
$canRead = (int)$dataGroup->canRead();
$canCreate = (int)$dataGroup->canCreate();
$canUpdate = (int)$dataGroup->canUpdate();
$canDelete = (int)$dataGroup->canDelete();
$this->printBlock(
"INSERT INTO ohrm_data_group (`name`, `description`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES ($name, $description, $canRead, $canCreate, $canUpdate, $canDelete);"
);
}
/**
* @param ApiPermission $apiPermission
* @param bool $simulateInsert
*/
private function printApiPermissionTable(ApiPermission $apiPermission, bool $simulateInsert): void
{
$this->io->table(
['Id', 'Module', 'Data Group', 'Api Name'],
[
[
$simulateInsert ? "NULL" : $apiPermission->getId(),
$apiPermission->getModule()->getName() . " (" . $apiPermission->getModule()->getId() . ")",
$apiPermission->getDataGroup()->getName() .
($simulateInsert ? "" : " (" . $apiPermission->getDataGroup()->getId() . ")"),
$apiPermission->getApiName(),
]
]
);
}
/**
* @param ApiPermission $apiPermission
*/
private function printApiPermissionSQL(ApiPermission $apiPermission): void
{
$module = $apiPermission->getModule()->getName();
$dataGroup = $apiPermission->getDataGroup()->getName();
$apiName = $this->getEntityManager()->getConnection()->quote($apiPermission->getApiName());
$this->printBlock(
"SET @{$module}_module_id := (SELECT `id` FROM ohrm_module WHERE name = '$module' LIMIT 1);"
);
$this->printBlock(
"SET @{$dataGroup}_data_group_id := (SELECT `id` FROM ohrm_data_group WHERE name = '$dataGroup' LIMIT 1);"
);
$this->printBlock(
"INSERT INTO ohrm_api_permission (`api_name`, `module_id`, `data_group_id`) VALUES ($apiName, @{$module}_module_id, @{$dataGroup}_data_group_id);"
);
}
/**
* @param string $message
*/
private function printBlock(string $message): void
{
$this->io->block($message, null, 'fg=yellow');
}
}

View File

@ -0,0 +1,262 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use InvalidArgumentException;
use OrangeHRM\Core\Traits\ORM\EntityManagerHelperTrait;
use OrangeHRM\DevTools\Command\Util\EchoSqlLogger;
use OrangeHRM\Entity\DataGroup;
use OrangeHRM\Entity\DataGroupPermission;
use OrangeHRM\Entity\UserRole;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Style\SymfonyStyle;
class AddRolePermissionCommand extends Command
{
use EntityManagerHelperTrait;
protected static $defaultName = 'add-role-permission';
public const ARGUMENT_DATA_GROUP_NAME = 'name';
public const ARGUMENT_DATA_GROUP_USER_ROLE = 'role';
public const OPTION_SIMULATE_INSERT = 'simulate';
public const OPTION_DATA_GROUP_CAN_READ = 'can-read';
public const OPTION_DATA_GROUP_CAN_CREATE = 'can-create';
public const OPTION_DATA_GROUP_CAN_UPDATE = 'can-update';
public const OPTION_DATA_GROUP_CAN_DELETE = 'can-delete';
public const OPTION_DATA_GROUP_IS_SELF = 'is-self';
private SymfonyStyle $io;
/**
* @inheritDoc
*/
protected function configure()
{
$this
->setDescription('Add user role permission to a data group')
->addArgument(self::ARGUMENT_DATA_GROUP_NAME, InputArgument::OPTIONAL)
->addArgument(self::ARGUMENT_DATA_GROUP_USER_ROLE, InputArgument::OPTIONAL)
->addOption(self::OPTION_DATA_GROUP_CAN_READ, 'R', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_CAN_CREATE, 'C', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_CAN_UPDATE, 'U', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_CAN_DELETE, 'D', InputOption::VALUE_NONE)
->addOption(self::OPTION_DATA_GROUP_IS_SELF, 'S', InputOption::VALUE_NONE)
->addOption(self::OPTION_SIMULATE_INSERT, 's', InputOption::VALUE_NONE, 'Simulate data insertion');
}
/**
* @inheritDoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
}
/**
* @inheritDoc
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$dataGroupName = $this->io->askQuestion($this->getDataGroupAutocompleteQuestion());
$input->setArgument(self::ARGUMENT_DATA_GROUP_NAME, $dataGroupName);
$dataGroup = $this->getRepository(DataGroup::class)->findOneBy(['name' => $dataGroupName]);
$this->printDataGroupPermissionTable($dataGroup);
$userRole = $this->io->askQuestion($this->getUserRoleAutocompleteQuestion());
$input->setArgument(self::ARGUMENT_DATA_GROUP_USER_ROLE, $userRole);
$canRead = $this->io->confirm('Can read', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_READ, $canRead);
$canCreate = $this->io->confirm('Can create', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_CREATE, $canCreate);
$canUpdate = $this->io->confirm('Can update', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_UPDATE, $canUpdate);
$canDelete = $this->io->confirm('Can delete', false);
$input->setOption(self::OPTION_DATA_GROUP_CAN_DELETE, $canDelete);
$isApi = $this->io->confirm('Is self', false);
$input->setOption(self::OPTION_DATA_GROUP_IS_SELF, $isApi);
}
/**
* @return Question
*/
private function getDataGroupAutocompleteQuestion(): Question
{
$dataGroups = $this->getRepository(DataGroup::class)->findAll();
$dataGroups = array_map(
function (DataGroup $dataGroup) {
return $dataGroup->getName();
},
$dataGroups
);
$question = new Question('Enter data group name (e.g. <fg=yellow>job_titles, apiv2_job_titles</>)');
$question->setValidator(
function (string $value = null) use ($dataGroups): string {
if (!in_array($value, $dataGroups)) {
throw new InvalidArgumentException('Invalid option');
}
return $value;
}
);
$question->setAutocompleterValues($dataGroups);
return $question;
}
/**
* @return Question
*/
private function getUserRoleAutocompleteQuestion(): Question
{
$userRoles = $this->getRepository(UserRole::class)->findAll();
$userRoles = array_map(
function (UserRole $userRole) {
return $userRole->getName();
},
$userRoles
);
$question = new Question('Enter user role name (e.g. <fg=yellow>' . implode(', ', $userRoles) . '</>)');
$question->setValidator(
function (string $value = null) use ($userRoles): string {
if (!in_array($value, $userRoles)) {
throw new InvalidArgumentException('Invalid option');
}
return $value;
}
);
$question->setAutocompleterValues($userRoles);
return $question;
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$dataGroupName = $input->getArgument(self::ARGUMENT_DATA_GROUP_NAME);
$userRoleName = $input->getArgument(self::ARGUMENT_DATA_GROUP_USER_ROLE);
$canRead = $input->getOption(self::OPTION_DATA_GROUP_CAN_READ);
$canCreate = $input->getOption(self::OPTION_DATA_GROUP_CAN_CREATE);
$canUpdate = $input->getOption(self::OPTION_DATA_GROUP_CAN_UPDATE);
$canDelete = $input->getOption(self::OPTION_DATA_GROUP_CAN_DELETE);
$isSelf = $input->getOption(self::OPTION_DATA_GROUP_IS_SELF);
$this->getEntityManager()->getConfiguration()->setSQLLogger(new EchoSqlLogger());
$dataGroup = $this->getRepository(DataGroup::class)->findOneBy(['name' => $dataGroupName]);
$userRole = $this->getRepository(UserRole::class)->findOneBy(['name' => $userRoleName]);
$dataGroupPermission = new DataGroupPermission();
$dataGroupPermission->setDataGroup($dataGroup);
$dataGroupPermission->setUserRole($userRole);
$dataGroupPermission->setCanRead($canRead);
$dataGroupPermission->setCanCreate($canCreate);
$dataGroupPermission->setCanUpdate($canUpdate);
$dataGroupPermission->setCanDelete($canDelete);
$dataGroupPermission->setSelf($isSelf);
$simulateInsert = $input->getOption(self::OPTION_SIMULATE_INSERT);
if (!$simulateInsert) {
$this->persist($dataGroupPermission);
}
$this->printDataGroupPermissionTable($dataGroup);
$this->printDataGroupPermissionSQL($dataGroupPermission);
return Command::SUCCESS;
}
/**
* @param DataGroup $dataGroup
*/
private function printDataGroupPermissionTable(DataGroup $dataGroup): void
{
$dataGroupPermissions = $this->getRepository(DataGroupPermission::class)
->findBy(['dataGroup' => $dataGroup->getId()]);
$dataGroupPermissions = array_map(
function (DataGroupPermission $dataGroupPermission) {
$userRoleName = $dataGroupPermission->getUserRole()->getName() .
" (" . $dataGroupPermission->getUserRole()->getId() . ")";
$dataGroupName = $dataGroupPermission->getDataGroup()->getName() .
" (" . $dataGroupPermission->getDataGroup()->getId() . ")";
return [
$dataGroupPermission->getId(),
$userRoleName,
$dataGroupName,
(int)$dataGroupPermission->canRead(),
(int)$dataGroupPermission->canCreate(),
(int)$dataGroupPermission->canUpdate(),
(int)$dataGroupPermission->canDelete(),
(int)$dataGroupPermission->isSelf()
];
},
$dataGroupPermissions
);
$this->io->table(
['Id', 'User Role', 'Data Group', 'Read', 'Create', 'Update', 'Delete', 'Self'],
$dataGroupPermissions
);
}
/**
* @param DataGroupPermission $dataGroupPermission
*/
private function printDataGroupPermissionSQL(DataGroupPermission $dataGroupPermission): void
{
$this->io->title('Sample SQL queries');
$dataGroup = $dataGroupPermission->getDataGroup()->getName();
$userRoleName = $dataGroupPermission->getUserRole()->getName();
$userRole = strtolower($userRoleName);
$userRoleName = $this->getEntityManager()->getConnection()->quote($userRoleName);
$canRead = (int)$dataGroupPermission->canRead();
$canCreate = (int)$dataGroupPermission->canCreate();
$canUpdate = (int)$dataGroupPermission->canUpdate();
$canDelete = (int)$dataGroupPermission->canDelete();
$isSelf = (int)$dataGroupPermission->isSelf();
$this->printBlock(
"SET @{$dataGroup}_data_group_id := (SELECT `id` FROM ohrm_data_group WHERE name = '$dataGroup' LIMIT 1);"
);
$this->printBlock(
"SET @{$userRole}_role_id := (SELECT `id` FROM ohrm_user_role WHERE `name` = '$userRoleName' LIMIT 1);"
);
$this->printBlock(
"INSERT INTO ohrm_user_role_data_group (`can_read`, `can_create`, `can_update`, `can_delete`, `self`, `data_group_id`, `user_role_id`) VALUES ($canRead, $canCreate, $canUpdate, $canDelete, $isSelf, @{$dataGroup}_data_group_id, @{$userRole}_role_id);"
);
}
/**
* @param string $message
*/
private function printBlock(string $message): void
{
$this->io->block($message, null, 'fg=yellow');
}
}

View File

@ -0,0 +1,148 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use Conf;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Types;
use Exception;
use OrangeHRM\Config\Config;
use OrangeHRM\Core\Traits\ORM\EntityManagerHelperTrait;
use OrangeHRM\Tests\Util\CoreFixtureService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class CreateTestDatabaseCommand extends Command
{
use EntityManagerHelperTrait;
protected static $defaultName = 'instance:create-test-db';
private SymfonyStyle $io;
private ?Connection $testDBConnection = null;
private ?AbstractPlatform $platform = null;
private ?Conf $testConf = null;
/**
* @inheritDoc
*/
protected function configure()
{
$this->setDescription('Create test database')
->addOption('user', 'u', InputOption::VALUE_REQUIRED, 'Privileged database user', 'root')
->addOption('password', 'p', InputOption::VALUE_REQUIRED)
->addOption('dump-options', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, '', []);
}
/**
* @inheritDoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$conf = Config::getConf();
$conn = $this->getEntityManager()->getConnection();
$sm = $conn->createSchemaManager();
define('ENVIRONMENT', 'test');
$this->testConf = Config::getConf(true);
try {
$sm->dropDatabase($this->testConf->getDbName());
} catch (Exception $e) {
}
$sm->createDatabase($this->testConf->getDbName());
$command = [
'mysqldump',
'--host=' . $conf->getDbHost(),
'--port=' . $conf->getDbPort(),
'--user=' . $input->getOption('user'),
'--add-drop-table',
'--routines',
'--skip-triggers',
...$input->getOption('dump-options'), // --column-statistics=0
];
if (!is_null($input->getOption('password'))) {
$command[] = '--password=' . $input->getOption('password');
}
$command[] = $conf->getDbName();
$process = new Process($command);
try {
$process->mustRun();
$dbScriptStatements = preg_split('/;\s*$/m', $process->getOutput());
$testDBConnection = $this->createTestDBConnection($input->getOption('user'), $input->getOption('password'));
foreach ($dbScriptStatements as $statement) {
if (empty(trim($statement))) {
continue;
}
$testDBConnection->executeStatement($statement);
}
} catch (ProcessFailedException $exception) {
$this->io->error($exception->getMessage());
return Command::FAILURE;
}
$this->io->success("Test db {$this->testConf->getDbName()} created");
$coreFixtureService = new CoreFixtureService();
$coreFixtureService->saveToFixtures();
$this->io->success('Core fixtures generated.');
return Command::SUCCESS;
}
/**
* @param string $user
* @param string|null $password
* @return Connection
*/
private function createTestDBConnection(string $user, ?string $password): Connection
{
$connectionParams = [
'dbname' => $this->testConf->getDbName(),
'user' => $user,
'password' => $password,
'host' => $this->testConf->getDbHost(),
'port' => $this->testConf->getDbPort(),
'driver' => 'pdo_mysql',
'charset' => 'utf8mb4'
];
is_null($this->platform) ?: $connectionParams['platform'] = $this->platform;
$testDBConnection = DriverManager::getConnection($connectionParams);
$testDBConnection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', Types::STRING);
return $testDBConnection;
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use OrangeHRM\Core\Traits\EventDispatcherTrait;
use OrangeHRM\Framework\Framework;
use OrangeHRM\Framework\Http\Request;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class EventDispatcherDebugCommand extends Command
{
use EventDispatcherTrait;
protected static $defaultName = 'debug:event-dispatcher';
private SymfonyStyle $io;
/**
* @inheritDoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$kernel = new Framework('dev', false);
$request = new Request();
$kernel->handleRequest($request);
foreach ($this->getEventDispatcher()->getListeners() as $event => $listeners) {
$this->io->title((string)$event);
$rows = [];
foreach ($listeners as $i => $listener) {
$listenerName = null;
if (is_array($listener) && isset($listener[0])) {
$listenerName = get_class($listener[0]);
if (isset($listener[1])) {
$listenerName .= '::' . $listener[1];
}
}
$row = [
'#' . ($i + 1),
$listenerName,
$this->getEventDispatcher()->getListenerPriority($event, $listener)
];
$rows[] = $row;
}
$this->io->table(['Order', 'Callable', 'Priority'], $rows);
}
return Command::SUCCESS;
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use ErrorException;
use OpenApi\Generator;
use OrangeHRM\Config\Config;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class GenerateOpenApiDocCommand extends Command
{
protected static $defaultName = 'generate-open-api-doc';
/**
* @inheritDoc
*/
protected function configure()
{
$this->addOption('throw', null, InputOption::VALUE_NONE, 'Convert warnings to errors');
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$command = $this->getApplication()->find('php-cs-fix');
$command->run(new ArrayInput([]), $output);
$paths = [Config::get(Config::PLUGINS_DIR) . '/orangehrmCorePlugin/Controller/Rest/V2'];
foreach (Config::get(Config::PLUGIN_PATHS) as $pluginAbsPath) {
$pathToApiDir = realpath($pluginAbsPath . '/Api');
if ($pathToApiDir !== false) {
$paths[] = $pathToApiDir;
}
}
if ($input->getOption('throw') === true) {
set_error_handler(static function ($severity, $message, $file, $line) use ($io) {
$io->error($message);
throw new ErrorException($message, 0, $severity, $file, $line);
});
}
$openapi = Generator::scan($paths);
$buildDir = Config::get(Config::BASE_DIR) . '/build';
$filePath = $buildDir . '/orangehrm-v2.json';
$openApiDefinition = $openapi->toJson(
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_IGNORE
);
file_put_contents($filePath, $openApiDefinition);
$io->success("File write to `$filePath`");
$swaggerUI = file_get_contents(__DIR__ . '/swagger.tpl.html');
$pos = strpos($openApiDefinition, '3.1.0'); // TODO::remove this
if ($pos !== false) {
$openApiDefinition = substr_replace($openApiDefinition, '3.0.3', $pos, strlen('3.1.0'));
}
$swaggerUI = str_replace('OPEN_API_DEFINITION', $openApiDefinition, $swaggerUI);
$uiFilePath = $buildDir . '/index.html';
file_put_contents($uiFilePath, $swaggerUI);
$io->success("File write to `$uiFilePath`");
return Command::SUCCESS;
}
}

View File

@ -0,0 +1,87 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class PHPFixCodingStandardsCommand extends Command
{
protected static $defaultName = 'php-cs-fix';
/**
* @inheritDoc
*/
protected function configure()
{
$this->setDescription('Extend functionality of $ php ./devTools/core/vendor/bin/php-cs-fixer fix')
->setHelp('Exit with error status if some files fixed with this command')
->addOption('php', null, InputOption::VALUE_REQUIRED, '', 'php')
->addOption('reset-cache', 'f', InputOption::VALUE_NONE);
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$resetCache = $input->getOption('reset-cache');
if ($resetCache) {
$io->note('Requested cache reset');
$cacheFile = realpath(__DIR__ . '/../../../../.php-cs-fixer.cache');
if ($cacheFile) {
$io->note('Found cache file');
if (unlink($cacheFile)) {
$io->note('Cache file deleted');
} else {
$io->note('Failed to cache file');
}
} else {
$io->note('Cache file not found');
}
}
$process = new Process(
[$input->getOption('php'), './devTools/core/vendor/bin/php-cs-fixer', 'fix', '--format=json'],
realpath(__DIR__ . '/../../../../')
);
try {
$process->mustRun();
$output = json_decode($process->getOutput(), true);
if (!empty($output['files'])) {
$io->table(
['Fixed files'],
array_map(fn ($file) => [$file['name']], $output['files'])
);
return Command::FAILURE;
}
} catch (ProcessFailedException $exception) {
$io->error($exception->getMessage());
return Command::FAILURE;
}
$io->success('Done');
return Command::SUCCESS;
}
}

View File

@ -0,0 +1,173 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use Closure;
use OrangeHRM\Authentication\Dto\UserCredential;
use OrangeHRM\Config\Config;
use OrangeHRM\Core\Traits\ORM\EntityManagerHelperTrait;
use OrangeHRM\Entity\Organization;
use OrangeHRM\Entity\User;
use OrangeHRM\Framework\Http\Request;
use OrangeHRM\Framework\Http\Response;
use OrangeHRM\Installer\Framework\HttpKernel;
use OrangeHRM\Installer\Util\AppSetupUtility;
use OrangeHRM\Installer\Util\Connection;
use OrangeHRM\Installer\Util\StateContainer;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\HttpFoundation\Request as BaseRequest;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Throwable;
class ReInstallCommand extends Command
{
use EntityManagerHelperTrait;
protected static $defaultName = 'instance:reinstall';
/**
* @inheritDoc
*/
protected function configure()
{
$this->setDescription('Re-install the instance');
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
if (!Config::isInstalled()) {
$io->warning('Application not installed.');
return Command::INVALID;
}
$kernel = new class ('dev', false) extends HttpKernel {
/**
* @inheritDoc
*/
public function handle(
BaseRequest $request,
int $type = HttpKernelInterface::MAIN_REQUEST,
bool $catch = true
) {
return new Response();
}
};
$request = new Request();
$kernel->handleRequest($request);
/** @var Organization $org */
$org = $this->tryClosure(fn () => $this->getRepository(Organization::class)->find(1));
/** @var User $user */
$user = $this->tryClosure(fn () => $this->getRepository(User::class)->findOneBy(['createdBy' => null]));
$organizationName = $org ? $org->getName() : 'OrangeHRM';
$countryCode = $org ? $org->getCountry() : 'US';
if ($user instanceof User) {
$adminUsername = $user->getUserName();
$adminHashedPassword = $user->getUserPassword();
$firstName = $user->getEmployee()->getFirstName();
$lastName = $user->getEmployee()->getLastName();
$email = $user->getEmployee()->getWorkEmail();
$contact = $user->getEmployee()->getWorkTelephone();
} else {
$adminUsername = 'Admin';
$firstName = 'Admin';
$lastName = 'Employee';
$email = 'admin@example.com';
$contact = null;
}
$conf = Config::getConf();
$dbName = $conf->getDbName();
$this->tryClosure(function () use ($dbName) {
$sm = $this->getEntityManager()->getConnection()->createSchemaManager();
$sm->dropDatabase("`$dbName`");
});
// DB configs
StateContainer::getInstance()->storeDbInfo(
$conf->getDbHost(),
$conf->getDbPort(),
new UserCredential($conf->getDbUser(), $conf->getDbPass()),
$dbName
);
StateContainer::getInstance()->setDbType(AppSetupUtility::INSTALLATION_DB_TYPE_NEW);
// Instance data
StateContainer::getInstance()->storeInstanceData($organizationName, $countryCode, 'en_US', 'UTC');
// Admin user
StateContainer::getInstance()->storeAdminUserData(
$firstName,
$lastName,
$email,
new UserCredential($adminUsername, 'admin123'),
$contact
);
$appSetupUtility = new AppSetupUtility();
$appSetupUtility->createDatabase();
$appSetupUtility->runMigrations('3.3.3', Config::PRODUCT_VERSION);
$appSetupUtility->insertSystemConfiguration();
if (isset($adminHashedPassword)) {
$qb = Connection::getConnection()->createQueryBuilder()
->update('ohrm_user', 'user')
->set('user.user_password', ':hashedPassword')
->setParameter('hashedPassword', $adminHashedPassword);
$qb->where($qb->expr()->isNull('user.created_by'))
->executeQuery();
} else {
$io->note("Username: $adminUsername, Password: admin123");
}
$io->success('Done');
define('ENVIRONMENT', 'test');
$testConf = Config::getConf(true);
$this->tryClosure(function () use ($testConf, $io) {
$sm = $this->getEntityManager()->getConnection()->createSchemaManager();
$sm->dropDatabase($testConf->getDbName());
$io->success('Dropped test database');
});
return Command::SUCCESS;
}
/**
* @param Closure $fn
* @return mixed|null
*/
private function tryClosure(Closure $fn)
{
try {
return $fn();
} catch (Throwable $e) {
}
return null;
}
}

View File

@ -0,0 +1,84 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use OrangeHRM\Config\Config;
use OrangeHRM\Core\Traits\ORM\EntityManagerHelperTrait;
use OrangeHRM\Core\Utility\KeyHandler;
use OrangeHRM\Framework\Filesystem\Filesystem;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
class ResetInstallationCommand extends Command
{
use EntityManagerHelperTrait;
protected static $defaultName = 'instance:reset';
/**
* @inheritDoc
*/
protected function configure()
{
$this->setDescription('Reset OrangeHRM installed instance');
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
if (!Config::isInstalled()) {
$io->warning('Application not installed.');
return Command::INVALID;
}
$pathToConf = Config::get(Config::CONF_FILE_PATH);
$conf = Config::getConf();
$dbName = $conf->getDbName();
$sm = $this->getEntityManager()->getConnection()->createSchemaManager();
$sm->dropDatabase("`$dbName`");
$io->note("Dropped database `$dbName`");
define('ENVIRONMENT', 'test');
$testConf = Config::getConf(true);
$fs = new Filesystem();
$fs->remove($pathToConf);
$io->note("Deleted conf file `$pathToConf`");
$pathToKey = KeyHandler::getPathToKey();
$fs->remove($pathToKey);
$io->note("Deleted key.ohrm file `$pathToKey`");
try {
$sm->dropDatabase($testConf->getDbName());
$io->note('Dropped test database');
} catch (Throwable $e) {
}
$io->success('Done');
return Command::SUCCESS;
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command;
use Doctrine\DBAL\Connection;
use OrangeHRM\Config\Config;
use OrangeHRM\Core\Traits\ORM\EntityManagerHelperTrait;
use OrangeHRM\Installer\Framework\HttpKernel;
use OrangeHRM\Installer\Util\ConfigHelper;
use OrangeHRM\Installer\Util\V1\AbstractMigration;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class RunMigrationClassCommand extends Command
{
use EntityManagerHelperTrait;
protected static $defaultName = 'migration:up';
/**
* @inheritDoc
*/
protected function configure()
{
$this->setDescription('Run given migration class')
->setHelp(
'E.g. php devTools/core/console.php migration:up "\OrangeHRM\Installer\Migration\V5_2_0\Migration"'
)
->addArgument('className', InputArgument::REQUIRED, 'Fully qualified class name');
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
if (!Config::isInstalled()) {
$io->warning('Application not installed.');
return Command::INVALID;
}
$migrationClass = $input->getArgument('className');
if (!is_subclass_of($migrationClass, AbstractMigration::class)) {
$io->error("Invalid migration class `$migrationClass`");
return Command::FAILURE;
}
new HttpKernel('prod', false); // Initiate kernel
class_alias($migrationClass, '\OrangeHRM\DevTools\Command\_Migration');
$migration = new class ($this->getEntityManager()->getConnection()) extends _Migration {
private Connection $connection;
public function __construct(Connection $connection)
{
$this->connection = $connection;
}
/**
* @inheritDoc
*/
public function getConnection(): Connection
{
return $this->connection;
}
};
$migration->up();
$configHelper = new ConfigHelper($migration->getConnection());
$configHelper->setConfigValue('instance.version', $migration->getVersion());
$io->success('Done');
return Command::SUCCESS;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command\Util;
use Doctrine\DBAL\Logging\SQLLogger;
/**
* @experimental
*/
class EchoSqlLogger implements SQLLogger
{
private $replace;
public function __construct($replace = false)
{
$this->replace = $replace;
}
/**
* @inheritdoc
*/
public function startQuery($sql, ?array $params = null, ?array $types = null)
{
echo $sql . "\n\n";
if ($params) {
echo "Params: \n";
var_export($params);
echo "\n\n";
}
if (!$types) {
return;
}
echo "Types: \n";
var_export($types);
echo "\n\n";
}
/**
* @inheritdoc
*/
public function stopQuery()
{
}
}

View File

@ -0,0 +1,30 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command\Util\Platforms;
class MySQL57Platform extends \Doctrine\DBAL\Platforms\MySQL57Platform
{
/**
* @inheritDoc
*/
public function hasNativeJsonType(): bool
{
return false;
}
}

View File

@ -0,0 +1,30 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\DevTools\Command\Util\Platforms;
class MySQL80Platform extends \Doctrine\DBAL\Platforms\MySQL80Platform
{
/**
* @inheritDoc
*/
public function hasNativeJsonType(): bool
{
return false;
}
}

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="OrangeHRM"/>
<title>OrangeHRM</title>
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.13.0/swagger-ui.css" />
</head>
<body>
<div id="app"></div>
<script src="https://unpkg.com/swagger-ui-dist@4.13.0/swagger-ui-bundle.js" crossorigin></script>
<script src="https://unpkg.com/swagger-ui-dist@4.13.0/swagger-ui-standalone-preset.js" crossorigin></script>
<script>
const spec = OPEN_API_DEFINITION;
window.onload = () => {
window.ui = SwaggerUIBundle({
spec: spec,
dom_id: '#app',
});
};
</script>
</body>
</html>

34
devTools/doctrine/bootstrap.php Executable file
View File

@ -0,0 +1,34 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
use OrangeHRM\ORM\Doctrine;
use OrangeHRM\ORM\Exception\ConfigNotFoundException;
require_once realpath(__DIR__ . '/../../src/vendor/autoload.php');
$errorMessage = "
Can't connect to the database.
Please install the OrangeHRM application.\n
";
try {
Doctrine::getEntityManager();
} catch (ConfigNotFoundException $e) {
echo $errorMessage;
die;
}

View File

@ -0,0 +1,29 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
use Doctrine\DBAL\Tools\Console\ConsoleRunner as DBALConsoleRunner;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use OrangeHRM\ORM\Doctrine;
require_once 'bootstrap.php';
$entityManager = Doctrine::getEntityManager();
$helperSet = ConsoleRunner::createHelperSet($entityManager);
$commands = [];
DBALConsoleRunner::run($helperSet, $commands);

View File

@ -0,0 +1,53 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace Doctrine\Migrations;
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
use Doctrine\Migrations\Tools\Console\ConsoleRunner;
use OrangeHRM\ORM\Doctrine;
require_once 'bootstrap.php';
$config = new ConfigurationArray(
[
'table_storage' => [
'table_name' => 'doctrine_migration_versions',
'version_column_name' => 'version',
'version_column_length' => 14,
'executed_at_column_name' => 'executed_at',
'execution_time_column_name' => 'execution_time',
],
'migrations_paths' => [
'OrangeHRM\Migrations' => __DIR__ . '/migrations',
],
'all_or_nothing' => true,
'check_database_platform' => true,
'organize_migrations' => 'none',
'connection' => null,
'em' => null,
]
);
$entityManager = Doctrine::getEntityManager();
$dependencyFactory = DependencyFactory::fromEntityManager($config, new ExistingEntityManager($entityManager));
ConsoleRunner::run([], $dependencyFactory);

28
devTools/doctrine/doctrine.php Executable file
View File

@ -0,0 +1,28 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use OrangeHRM\ORM\Doctrine;
require_once 'bootstrap.php';
$entityManager = Doctrine::getEntityManager();
$helperSet = ConsoleRunner::createHelperSet($entityManager);
$commands = [];
ConsoleRunner::run($helperSet, $commands);

0
devTools/doctrine/migrations/.gitignore vendored Executable file
View File

View File

@ -0,0 +1,85 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
$errorMessage = "
Use new command.\n
$ cd %s
$ php ./devTools/core/console.php i:create-test-db
\n";
die(sprintf($errorMessage, realpath(__DIR__ . '/../../')));
$rootPath = dirname(__FILE__) . "/../../";
$confPath = $rootPath . "lib/confs/Conf.php";
$pathToAutoload = realpath(__DIR__ . '/../../src/vendor/autoload.php');
require_once $confPath;
require_once $pathToAutoload;
$c = new Conf();
$testDb = 'test_' . $c->getDbName();
$dbUser = $c->getDbUser();
$dbHost = $c->getDbHost();
$dbPort = $c->getDbPort();
$dbName = $c->getDbName();
$tempFile = tempnam(sys_get_temp_dir(), 'ohrmtestdb');
if ($argc > 1) {
$mysqlRootPwd = $argv[1];
} else {
$mysqlRootPwd = "";
echo "Please enter mysql root password when prompted.\n";
}
$createdbStatement = "DROP DATABASE IF EXISTS `{$testDb}`; CREATE DATABASE `{$testDb}`;USE `{$testDb}`;" ;
file_put_contents($tempFile, $createdbStatement);
$cmd = "mysqldump -h {$dbHost} --port={$dbPort} -u root -p{$mysqlRootPwd} --add-drop-table --routines --skip-triggers {$dbName} >> {$tempFile}";
$output = '';
$returnStatus = '';
exec($cmd, $output, $returnStatus);
if ($returnStatus !== 0) {
echo "mysqldump failed.<br>\n";
exit(1);
}
$cmd = "mysql -h {$dbHost} --port={$dbPort} -u root -p{$mysqlRootPwd} < {$tempFile}";
exec($cmd, $output, $returnStatus);
if ($returnStatus !== 0) {
echo "mysql data insert failed.<br>\n";
exit(2);
}
unlink($tempFile);
echo "test db {$testDb} created.\n";
$coreFixtureService = new \OrangeHRM\Tests\Util\CoreFixtureService();
$coreFixtureService->saveToFixtures();
echo "core fixtures generated.\n";

24
devTools/general/reinstall.php Executable file
View File

@ -0,0 +1,24 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
$errorMessage = "
Use new command.\n
$ cd %s
$ php ./devTools/core/console.php i:reinstall
\n";
echo sprintf($errorMessage, realpath(__DIR__ . '/../../'));

View File

@ -0,0 +1,24 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
$errorMessage = "
Use new command.\n
$ cd %s
$ php ./devTools/core/console.php i:reset
\n";
echo sprintf($errorMessage, realpath(__DIR__ . '/../../'));

View File

@ -0,0 +1,42 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
$rootPath = dirname(__FILE__) . "/../../";
$files = [
'build/build.xml',
'src/lib/config/Config.php',
'src/plugins/orangehrmCorePlugin/test/fixtures/testcases/AboutOrganizationTestCase.yaml',
];
if ($argc != 3) {
echo "Usage: php update-version.php [old-version] [new-version]\n\n";
echo "Example:\n\n";
echo "php update-version.php 2.6-alpha.3 2.6-alpha.4\n";
exit();
}
$oldVersion = $argv[1];
$newVersion = $argv[2];
foreach ($files as $file) {
$fileName = $rootPath . $file;
$contents = file_get_contents($fileName);
$contents = str_replace($oldVersion, $newVersion, $contents);
file_put_contents($fileName, $contents);
}

41
devTools/generate/create-api.sh Executable file
View File

@ -0,0 +1,41 @@
################################################################################
# Check the action name #
################################################################################
if [ $# -eq 0 ]; then
echo "No API class provided"
echo "Syntax: create-api api-class"
exit 1
fi
################################################################################
# define vars #
################################################################################
PLUGIN_NAME=$1
API_NAME=$2
BE_PLUGIN_FOLDER=../../src/plugins/$PLUGIN_NAME
FE_PLUGIN_FOLDER=../../src/client/src/$PLUGIN_NAME
API_CLASS_NAME=$API_NAME
API_NAMESPACE=$API_NAME
ENTITY_CLASS=$API_NAME
################################################################################
# copy api files #
################################################################################
MODEL_FILE=${BE_PLUGIN_FOLDER}/Api/Model/${API_CLASS_NAME}Model.php
API_FILE=${BE_PLUGIN_FOLDER}/Api/${API_CLASS_NAME}Api.php
mkdir -p ${BE_PLUGIN_FOLDER}/Api/Model
cp ./templates/back-end/api/model/apiModel.php.txt ${MODEL_FILE}
cp ./templates/back-end/api/api.php.txt ${API_FILE}
#replace placeholders
sed -i "s/{API_NAMESPACE}/${API_NAMESPACE}/g" ${MODEL_FILE}
sed -i "s/{API_CLASS}/${API_CLASS_NAME}/g" ${MODEL_FILE}
sed -i "s/{ENTITY_CLASS}/${ENTITY_CLASS}/g" ${MODEL_FILE}
sed -i "s/{API_NAMESPACE}/${API_NAMESPACE}/g" ${API_FILE}
sed -i "s/{API_CLASS}/${API_CLASS_NAME}/g" ${API_FILE}
sed -i "s/{ENTITY_CLASS}/${ENTITY_CLASS}/g" ${API_FILE}
echo "Generated ${MODEL_FILE=} File"
echo "Generated ${API_FILE=} File"

View File

@ -0,0 +1,44 @@
#!/bin/bash
################################################################################
# Help #
################################################################################
Help()
{
# Display Help
echo "Create plugin folders"
echo
echo "Syntax: create-plugin my-plugin-name"
}
# Get the options
while getopts ":h" option; do
case $option in
h) # display Help
Help
exit
esac
done
################################################################################
# Check the plugin name #
################################################################################
if [ $# -eq 0 ]; then
echo "No plugin name provided"
echo "Syntax: create-plugin my-plugin-name"
exit 1
fi
################################################################################
# Create the plugin folders #
################################################################################
PLUGIN_NAME=$1
FE_PLUGIN_FOLDER=../../src/client/src/$PLUGIN_NAME
BE_PLUGIN_FOLDER=../../src/plugins/$PLUGIN_NAME
mkdir -p ${BE_PLUGIN_FOLDER}/{Api,config,Controller,entity,test,modules,Service}
mkdir -p ${FE_PLUGIN_FOLDER}/{pages,}
cp ./templates/front-end/index.ts.txt ${FE_PLUGIN_FOLDER}/index.ts
echo "$PLUGIN_NAME plugin folder generated"
echo "Happy coding"

View File

@ -0,0 +1,78 @@
#!/bin/bash
################################################################################
# Help #
################################################################################
Help()
{
# Display Help
echo "Create action"
echo
echo "Syntax: create-view-action action-name"
}
# Get the options
while getopts ":h" option; do
case $option in
h) # display Help
Help
exit
esac
done
################################################################################
# Check the action name #
################################################################################
if [ $# -eq 0 ]; then
echo "No action name provided"
echo "Syntax: create-view-action action-name"
exit 1
fi
################################################################################
# define place holders #
################################################################################
PLUGIN_NAME=$1
ACTION_NAME=$2
ACTION_VIEW_TITLE='View '${ACTION_NAME}
SAVE_ACTION='save'${ACTION_NAME}
ACTION_CONTROLLER_NAME=${ACTION_NAME}
ACTION_FOLDER="$(tr [A-Z] [a-z] <<< "${ACTION_NAME}")"
ACTION_CONTROLLER_COMPONENT=${ACTION_FOLDER}'-list'
BE_PLUGIN_FOLDER=../../src/plugins/$PLUGIN_NAME
FE_PLUGIN_FOLDER=../../src/client/src/$PLUGIN_NAME
VIEW_VUE_FILE=${FE_PLUGIN_FOLDER}/pages/${ACTION_FOLDER}/${ACTION_NAME}.vue
################################################################################
# copy vue files #
################################################################################
mkdir -p ${FE_PLUGIN_FOLDER}/pages/${ACTION_FOLDER}
cp ./templates/front-end/view/ActionView.txt ${VIEW_VUE_FILE}
#replace placeholders
sed -i "s/{ACTION_VIEW_TITLE}/${ACTION_VIEW_TITLE}/g" ${VIEW_VUE_FILE}
sed -i "s/{SAVE_ACTION}/${SAVE_ACTION}/g" ${VIEW_VUE_FILE}
echo "Generated ${VIEW_VUE_FILE} File"
#update imports
sed -i "s/{ACTION_NAME}/${ACTION_NAME}/g" ${FE_PLUGIN_FOLDER}/index.ts
sed -i "s/{ACTION_FOLDER}/${ACTION_FOLDER}/g" ${FE_PLUGIN_FOLDER}/index.ts
sed -i "s/{EXPORT_GOES_HERE}/'${ACTION_CONTROLLER_COMPONENT}': ${ACTION_NAME},/g" ${FE_PLUGIN_FOLDER}/index.ts
echo "updated import/exports in ${FE_PLUGIN_FOLDER}/index.ts File"
################################################################################
# copy action files #
################################################################################
CONTROLLER_FILE=${BE_PLUGIN_FOLDER}/Controller/${ACTION_CONTROLLER_NAME}Controller.php
ROUTES_FILE=${BE_PLUGIN_FOLDER}/config/routes.yaml
cp ./templates/back-end/controller/viewController.txt ${CONTROLLER_FILE}
cp ./templates/back-end/config/routes.yaml.txt ${ROUTES_FILE}
#replace placeholders
sed -i "s/{ACTION_CONTROLLER_NAME}/${ACTION_CONTROLLER_NAME}/g" ${CONTROLLER_FILE}
sed -i "s/{ACTION_CONTROLLER_COMPONENT}/${ACTION_CONTROLLER_COMPONENT}/g" ${CONTROLLER_FILE}
sed -i "s/{PLUGIN_NAME_SPACE}/${ACTION_NAME}/g" ${CONTROLLER_FILE}
echo "Generated ${CONTROLLER_FILE} File"

View File

@ -0,0 +1,123 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\{API_NAMESPACE}\Api;
use OrangeHRM\Core\Api\CommonParams;
use OrangeHRM\Core\Api\V2\CrudEndpoint;
use OrangeHRM\Core\Api\V2\Endpoint;
use OrangeHRM\Core\Api\V2\EndpointCollectionResult;
use OrangeHRM\Core\Api\V2\EndpointResourceResult;
use OrangeHRM\Core\Api\V2\EndpointResult;
use OrangeHRM\Core\Api\V2\Exception\RecordNotFoundException;
use OrangeHRM\Core\Api\V2\Model\ArrayModel;
use OrangeHRM\Core\Api\V2\ParameterBag;
use OrangeHRM\Core\Api\V2\RequestParams;
use OrangeHRM\Core\Api\V2\Validator\ParamRule;
use OrangeHRM\Core\Api\V2\Validator\ParamRuleCollection;
use OrangeHRM\Core\Api\V2\Validator\Rule;
use OrangeHRM\Core\Api\V2\Validator\Rules;
use OrangeHRM\Core\Dto\Base64Attachment;
use OrangeHRM\Entity\{ENTITY_CLASS};
class {API_CLASS}API extends Endpoint implements CrudEndpoint
{
/**
* @var null|{API_CLASS}Service
*/
protected ?{API_CLASS}Service ${API_CLASS}Service = null;
/**
* @inheritDoc
*/
public function getOne(): EndpointResult
{
}
/**
* @inheritDoc
*/
public function getValidationRuleForGetOne(): ParamRuleCollection
{
}
/**
* @inheritDoc
*/
public function getAll(): EndpointResult
{
}
/**
* @inheritDoc
*/
public function getValidationRuleForGetAll(): ParamRuleCollection
{
}
/**
* @inheritDoc
*/
public function create(): EndpointResult
{
}
/**
* @inheritDoc
*/
public function getValidationRuleForCreate(): ParamRuleCollection
{
}
/**
* @inheritDoc
*/
public function update(): EndpointResult
{
}
/**
* @inheritDoc
*/
public function getValidationRuleForUpdate(): ParamRuleCollection
{
}
/**
* @inheritDoc
*/
public function delete(): EndpointResult
{
}
/**
* @inheritDoc
*/
public function getValidationRuleForDelete(): ParamRuleCollection
{
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\{API_NAMESPACE}\Api\Model;
use OrangeHRM\Core\Api\V2\Serializer\ModelTrait;
use OrangeHRM\Core\Api\V2\Serializer\Normalizable;
use OrangeHRM\Entity\{ENTITY_CLASS};
class {API_CLASS}Model implements Normalizable
{
use ModelTrait;
public function __construct({ENTITY_CLASS} ${ENTITY_CLASS})
{
$this->setEntity(${ENTITY_CLASS});
$this->setFilters(
[
'id',
'name',
'description',
'date',
]
);
$this->setAttributeNames(
[
'id',
'name',
'description',
'date',
]
);
}
}

View File

@ -0,0 +1,4 @@
view_todo:
path: /todo/items
controller: OrangeHRM\ToDo\Controller\ToDoController::handle
methods: [ GET ]

View File

@ -0,0 +1,35 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\{PLUGIN_NAME_SPACE}\Controller;
use OrangeHRM\Core\Controller\AbstractVueController;
use OrangeHRM\Core\Vue\Component;
use OrangeHRM\Framework\Http\Request;
class {ACTION_CONTROLLER_NAME}Controller extends AbstractVueController
{
/**
* @inheritDoc
*/
public function preRender(Request $request): void
{
$component = new Component('{ACTION_CONTROLLER_COMPONENT}');
$this->setComponent($component);
}
}

View File

@ -0,0 +1,21 @@
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
import {ACTION_NAME} from './pages/{ACTION_FOLDER}/ToDo.vue';
export default {
{EXPORT_GOES_HERE}
};

View File

@ -0,0 +1,166 @@
<!--
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
-->
<template>
<div class="orangehrm-background-container">
<div class="orangehrm-paper-container">
<div class="orangehrm-header-container">
<oxd-text tag="h6" class="orangehrm-main-title">{ACTION_VIEW_TITLE}</oxd-text>
<div>
<oxd-button
label="Add"
iconName="plus"
displayType="secondary"
@click="onClickAdd"
/>
</div>
</div>
<table-header
:selected="checkedItems.length"
:total="total"
:loading="isLoading"
@delete="onClickDeleteSelected"
></table-header>
<div class="orangehrm-container">
<oxd-card-table
:headers="headers"
:items="items"
:selectable="true"
:clickable="false"
:loading="isLoading"
v-model:selected="checkedItems"
rowDecorator="oxd-table-decorator-card"
/>
</div>
<div class="orangehrm-bottom-container">
<oxd-pagination
v-if="showPaginator"
:length="pages"
v-model:current="currentPage"
/>
</div>
</div>
<delete-confirmation ref="deleteDialog"></delete-confirmation>
</div>
</template>
<script>
import {navigate} from '@orangehrm/core/util/helper/navigation';
import DeleteConfirmationDialog from '@orangehrm/components/dialogs/DeleteConfirmationDialog.vue';
export default {
data() {
return {
headers: [
{name: 'title', slot: 'title', title: 'Title', style: {flex: 2}},
{name: 'description', title: 'Description', style: {flex: 4}},
{
name: 'actions',
title: 'Actions',
slot: 'action',
style: {flex: 1},
cellType: 'oxd-table-cell-actions',
cellConfig: {
delete: {
onClick: this.onClickDelete,
component: 'oxd-icon-button',
props: {
name: 'trash',
},
},
edit: {
onClick: this.onClickEdit,
props: {
name: 'pencil-fill',
},
},
},
},
],
items: [
{
title: 'item name one',
description: "item description one",
},
{
title: 'item name two',
description: "item description two",
},
],
checkedItems: [],
};
},
components: {
'delete-confirmation': DeleteConfirmationDialog,
},
setup() {
// call Api here
},
methods: {
onClickAdd() {
navigate('/todo/{SAVE_ACTION}');
},
onClickEdit(item) {
navigate('/todo/{SAVE_ACTION}/{id}', {id: item.id});
},
onClickDeleteSelected() {
const ids = [];
this.checkedItems.forEach(index => {
ids.push(this.items?.data[index].id);
});
this.$refs.deleteDialog.showDialog().then(confirmation => {
if (confirmation === 'ok') {
this.deleteItems(ids);
}
});
},
onClickDelete(item) {
this.$refs.deleteDialog.showDialog().then(confirmation => {
if (confirmation === 'ok') {
this.deleteItems([item.id]);
}
});
},
deleteItems(items) {
if (items instanceof Array) {
this.isLoading = true;
this.http
.deleteAll({
ids: items,
})
.then(() => {
return this.$toast.deleteSuccess();
})
.then(() => {
this.isLoading = false;
this.resetDataTable();
});
}
},
async resetDataTable() {
this.checkedItems = [];
await this.execQuery();
},
},
};
</script>

View File

@ -0,0 +1 @@
http://localhost/orangehrm/devTools/load/general/loadEmployees.php

View File

@ -0,0 +1,350 @@
<?php
/*
* Created on Feb 29, 2008
* Author: Gayanath Jayarathne
*
* This script adds 110 employees, corresponding 110 ESS users and one Admin user
* to OrangeHRM database. Each employee full name is unique.Once OrangeHRM is installed,
* place this script in its root folder and call it accordingly in the web browser.
* If data was added, you should see the message "Successfully Created!"
*
* Warning:
* This would first remove all existing employees and users from the database.
*
* Admin username = admin Admin password = admin
*
* For employee, "Kayla Abbey":
*
* ESS username = Kayla ESS password = Kayla
*
* As above, for each employee, username and password would be his/her first name
*
*/
// Database information
require_once "../../../lib/confs/Conf.php";
// Connecting to the database
$conf = new Conf();
$dbConnection = mysqli_connect($conf->dbhost, $conf->dbuser, $conf->dbpass, $conf->dbname, $conf->dbport);
if (!$dbConnection) { echo mysqli_error($dbConnection); die; }
$dbConnection->set_charset("utf8mb4");
//if (!mysqli_select_db($conf->dbname)) { echo mysqli_error(); exit(0); }
// Truncating tables
if (!mysqli_query($dbConnection,"DELETE from `hs_hr_employee`")) { echo mysqli_error($dbConnection); die; }
if (!mysqli_query($dbConnection,"DELETE from `ohrm_emp_termination`")) { echo mysqli_error($dbConnection); die; }
if (!mysqli_query($dbConnection,"DELETE from `ohrm_user`")) { echo mysqli_error($dbConnection); die; }
// Employee data
$employees[0][0] = "001"; $employees[0][1] = "Abbey"; $employees[0][2] = "Kayla";
$employees[1][0] = "002"; $employees[1][1] = "Abel"; $employees[1][2] = "Ashley";
$employees[2][0] = "003"; $employees[2][1] = "Abraham"; $employees[2][2] = "Tyler";
$employees[3][0] = "004"; $employees[3][1] = "Abrahams"; $employees[3][2] = "Landon";
$employees[4][0] = "005"; $employees[4][1] = "Abrahamson"; $employees[4][2] = "James";
$employees[5][0] = "006"; $employees[5][1] = "Abram"; $employees[5][2] = "Hailey";
$employees[6][0] = "007"; $employees[6][1] = "Abrams"; $employees[6][2] = "Jenna";
$employees[7][0] = "008"; $employees[7][1] = "Abramson"; $employees[7][2] = "Audrey";
$employees[8][0] = "009"; $employees[8][1] = "Achilles"; $employees[8][2] = "Hayden";
$employees[9][0] = "010"; $employees[9][1] = "Acker"; $employees[9][2] = "Lauren";
$employees[10][0] = "011"; $employees[10][1] = "Ackerman"; $employees[10][2] = "Grace";
$employees[11][0] = "012"; $employees[11][1] = "Adam"; $employees[11][2] = "Chase";
$employees[12][0] = "013"; $employees[12][1] = "Adams"; $employees[12][2] = "Brooklyn";
$employees[13][0] = "014"; $employees[13][1] = "Adamson"; $employees[13][2] = "Adrian";
$employees[14][0] = "015"; $employees[14][1] = "Adcock"; $employees[14][2] = "Alexa";
$employees[15][0] = "016"; $employees[15][1] = "Addison"; $employees[15][2] = "Anthony";
$employees[16][0] = "017"; $employees[16][1] = "Aiken"; $employees[16][2] = "William";
$employees[17][0] = "018"; $employees[17][1] = "Ainsworth"; $employees[17][2] = "Andrew";
$employees[18][0] = "019"; $employees[18][1] = "Aitken"; $employees[18][2] = "Benjamin";
$employees[19][0] = "020"; $employees[19][1] = "Akerman"; $employees[19][2] = "Amanda";
$employees[20][0] = "021"; $employees[20][1] = "Akers"; $employees[20][2] = "Lillian";
$employees[21][0] = "022"; $employees[21][1] = "Albert"; $employees[21][2] = "Jennifer";
$employees[22][0] = "023"; $employees[22][1] = "Alberts"; $employees[22][2] = "Carter";
$employees[23][0] = "024"; $employees[23][1] = "Albinson"; $employees[23][2] = "Kimberly";
$employees[24][0] = "025"; $employees[24][1] = "Alexander"; $employees[24][2] = "Amelia";
$employees[25][0] = "026"; $employees[25][1] = "Alfredson"; $employees[25][2] = "Mason";
$employees[26][0] = "027"; $employees[26][1] = "Alfson"; $employees[26][2] = "Taylor";
$employees[27][0] = "028"; $employees[27][1] = "Allard"; $employees[27][2] = "Brandon";
$employees[28][0] = "029"; $employees[28][1] = "Allen"; $employees[28][2] = "Lucas";
$employees[29][0] = "030"; $employees[29][1] = "Allsopp"; $employees[29][2] = "Dominic";
$employees[30][0] = "031"; $employees[30][1] = "Alvey"; $employees[30][2] = "Justin";
$employees[31][0] = "032"; $employees[31][1] = "Anderson"; $employees[31][2] = "Steven";
$employees[32][0] = "033"; $employees[32][1] = "Andrews"; $employees[32][2] = "Austin";
$employees[33][0] = "034"; $employees[33][1] = "Andrewson"; $employees[33][2] = "Marie";
$employees[34][0] = "035"; $employees[34][1] = "Anson"; $employees[34][2] = "Robert";
$employees[35][0] = "036"; $employees[35][1] = "Anthonyson"; $employees[35][2] = "Laura";
$employees[36][0] = "037"; $employees[36][1] = "Appleby"; $employees[36][2] = "Carson";
$employees[37][0] = "038"; $employees[37][1] = "Appleton"; $employees[37][2] = "Timothy";
$employees[38][0] = "039"; $employees[38][1] = "Archer"; $employees[38][2] = "Allison";
$employees[39][0] = "040"; $employees[39][1] = "Arkwright"; $employees[39][2] = "Isabelle";
$employees[40][0] = "041"; $employees[40][1] = "Armistead"; $employees[40][2] = "Katie";
$employees[41][0] = "042"; $employees[41][1] = "Arnold"; $employees[41][2] = "Andrea";
$employees[42][0] = "043"; $employees[42][1] = "Arrington"; $employees[42][2] = "Brooke";
$employees[43][0] = "044"; $employees[43][1] = "Arterberry"; $employees[43][2] = "Julian";
$employees[44][0] = "045"; $employees[44][1] = "Arterbury"; $employees[44][2] = "Christian";
$employees[45][0] = "046"; $employees[45][1] = "Arthur"; $employees[45][2] = "Patrick";
$employees[46][0] = "047"; $employees[46][1] = "Arthurson"; $employees[46][2] = "Sydney";
$employees[47][0] = "048"; $employees[47][1] = "Ash"; $employees[47][2] = "Chelsea";
$employees[48][0] = "049"; $employees[48][1] = "Ashley"; $employees[48][2] = "Victoria";
$employees[49][0] = "050"; $employees[49][1] = "Ashworth"; $employees[49][2] = "Charles";
$employees[50][0] = "051"; $employees[50][1] = "Atkins"; $employees[50][2] = "Jayden";
$employees[51][0] = "052"; $employees[51][1] = "Atkinson"; $employees[51][2] = "Caroline";
$employees[52][0] = "053"; $employees[52][1] = "Attaway"; $employees[52][2] = "Ashlyn";
$employees[53][0] = "054"; $employees[53][1] = "Atteberry"; $employees[53][2] = "Colin";
$employees[54][0] = "055"; $employees[54][1] = "Attwater"; $employees[54][2] = "Blake";
$employees[55][0] = "056"; $employees[55][1] = "Barker"; $employees[55][2] = "Haley";
$employees[56][0] = "057"; $employees[56][1] = "Barlow"; $employees[56][2] = "Katherine";
$employees[57][0] = "058"; $employees[57][1] = "Barton"; $employees[57][2] = "Charlotte";
$employees[58][0] = "059"; $employees[58][1] = "Bartram"; $employees[58][2] = "George";
$employees[59][0] = "060"; $employees[59][1] = "Bates"; $employees[59][2] = "Richard";
$employees[60][0] = "061"; $employees[60][1] = "Bateson"; $employees[60][2] = "Heather";
$employees[61][0] = "062"; $employees[61][1] = "Baxter"; $employees[61][2] = "Oliver";
$employees[62][0] = "063"; $employees[62][1] = "Beake"; $employees[62][2] = "Alexandra";
$employees[63][0] = "064"; $employees[63][1] = "Beasley"; $employees[63][2] = "Courtney";
$employees[64][0] = "065"; $employees[64][1] = "Beattie"; $employees[64][2] = "Ellie";
$employees[65][0] = "066"; $employees[65][1] = "Becket"; $employees[65][2] = "Skyler";
$employees[66][0] = "067"; $employees[66][1] = "Beckham"; $employees[66][2] = "Mariah";
$employees[67][0] = "068"; $employees[67][1] = "Benjaminson"; $employees[67][2] = "Scott";
$employees[68][0] = "069"; $employees[68][1] = "Bennett"; $employees[68][2] = "Isabel";
$employees[69][0] = "070"; $employees[69][1] = "Benson"; $employees[69][2] = "Christina";
$employees[70][0] = "071"; $employees[70][1] = "Bernard"; $employees[70][2] = "Jamie";
$employees[71][0] = "072"; $employees[71][1] = "Bishop"; $employees[71][2] = "Edward";
$employees[72][0] = "073"; $employees[72][1] = "Blackburn"; $employees[72][2] = "Stephen";
$employees[73][0] = "074"; $employees[73][1] = "Blackwood"; $employees[73][2] = "Karen";
$employees[74][0] = "075"; $employees[74][1] = "Blakeslee"; $employees[74][2] = "Parker";
$employees[75][0] = "076"; $employees[75][1] = "Bloodworth"; $employees[75][2] = "Jeremy";
$employees[76][0] = "077"; $employees[76][1] = "Boivin"; $employees[76][2] = "Peter";
$employees[77][0] = "078"; $employees[77][1] = "Bolton"; $employees[77][2] = "Lindsey";
$employees[78][0] = "079"; $employees[78][1] = "Booner"; $employees[78][2] = "Henry";
$employees[79][0] = "080"; $employees[79][1] = "Braddock"; $employees[79][2] = "Alice";
$employees[80][0] = "081"; $employees[80][1] = "Brooks"; $employees[80][2] = "Sandra";
$employees[81][0] = "082"; $employees[81][1] = "Burnham"; $employees[81][2] = "Travis";
$employees[82][0] = "083"; $employees[82][1] = "Cantrell"; $employees[82][2] = "Colton";
$employees[83][0] = "084"; $employees[83][1] = "Carpenter"; $employees[83][2] = "Brian";
$employees[84][0] = "085"; $employees[84][1] = "Chapman"; $employees[84][2] = "Daisy";
$employees[85][0] = "086"; $employees[85][1] = "Christopher"; $employees[85][2] = "Barbara";
$employees[86][0] = "087"; $employees[86][1] = "Clarke"; $employees[86][2] = "Jeffrey";
$employees[87][0] = "088"; $employees[87][1] = "Clawson"; $employees[87][2] = "Eliza";
$employees[88][0] = "089"; $employees[88][1] = "Clifford"; $employees[88][2] = "Helena";
$employees[89][0] = "090"; $employees[89][1] = "Clinton"; $employees[89][2] = "Linda";
$employees[90][0] = "091"; $employees[90][1] = "Cockburn"; $employees[90][2] = "Lilly";
$employees[91][0] = "092"; $employees[91][1] = "Collingwood"; $employees[91][2] = "Gregory";
$employees[92][0] = "093"; $employees[92][1] = "Cooper"; $employees[92][2] = "Harry";
$employees[93][0] = "094"; $employees[93][1] = "Dalton"; $employees[93][2] = "Nancy";
$employees[94][0] = "095"; $employees[94][1] = "Daniell"; $employees[94][2] = "Harrison";
$employees[95][0] = "096"; $employees[95][1] = "Danielson"; $employees[95][2] = "Monica";
$employees[96][0] = "097"; $employees[96][1] = "Darby"; $employees[96][2] = "Martin";
$employees[97][0] = "098"; $employees[97][1] = "Davidson"; $employees[97][2] = "Cindy";
$employees[98][0] = "099"; $employees[98][1] = "Dexter"; $employees[98][2] = "Violet";
$employees[99][0] = "100"; $employees[99][1] = "Dickens"; $employees[99][2] = "Vivian";
$employees[100][0] = "101"; $employees[100][1] = "Downer"; $employees[100][2] = "Dennis";
$employees[101][0] = "102"; $employees[101][1] = "Earlson"; $employees[101][2] = "Maggie";
$employees[102][0] = "103"; $employees[102][1] = "Edwards"; $employees[102][2] = "Justine";
$employees[103][0] = "104"; $employees[103][1] = "Emerson"; $employees[103][2] = "Ronald";
$employees[104][0] = "105"; $employees[104][1] = "Ericson"; $employees[104][2] = "Lawrence";
$employees[105][0] = "106"; $employees[105][1] = "Fleming"; $employees[105][2] = "Elvis";
$employees[106][0] = "107"; $employees[106][1] = "Forester"; $employees[106][2] = "Bruce";
$employees[107][0] = "108"; $employees[107][1] = "Franklin"; $employees[107][2] = "Melinda";
$employees[108][0] = "109"; $employees[108][1] = "Gibson"; $employees[108][2] = "Phillip";
$employees[109][0] = "110"; $employees[109][1] = "Gilbert"; $employees[109][2] = "Janet";
// User data
$users[0][0] = "USR002"; $users[0][1] = "Kayla"; $users[0][2] = md5("Kayla");
$users[1][0] = "USR003"; $users[1][1] = "Ashley"; $users[1][2] = md5("Ashley");
$users[2][0] = "USR004"; $users[2][1] = "Tyler"; $users[2][2] = md5("Tyler");
$users[3][0] = "USR005"; $users[3][1] = "Landon"; $users[3][2] = md5("Landon");
$users[4][0] = "USR006"; $users[4][1] = "James"; $users[4][2] = md5("James");
$users[5][0] = "USR007"; $users[5][1] = "Hailey"; $users[5][2] = md5("Hailey");
$users[6][0] = "USR008"; $users[6][1] = "Jenna"; $users[6][2] = md5("Jenna");
$users[7][0] = "USR009"; $users[7][1] = "Audrey"; $users[7][2] = md5("Audrey");
$users[8][0] = "USR010"; $users[8][1] = "Hayden"; $users[8][2] = md5("Hayden");
$users[9][0] = "USR011"; $users[9][1] = "Lauren"; $users[9][2] = md5("Lauren");
$users[10][0] = "USR012"; $users[10][1] = "Grace"; $users[10][2] = md5("Grace");
$users[11][0] = "USR013"; $users[11][1] = "Chase"; $users[11][2] = md5("Chase");
$users[12][0] = "USR014"; $users[12][1] = "Brooklyn"; $users[12][2] = md5("Brooklyn");
$users[13][0] = "USR015"; $users[13][1] = "Adrian"; $users[13][2] = md5("Adrian");
$users[14][0] = "USR016"; $users[14][1] = "Alexa"; $users[14][2] = md5("Alexa");
$users[15][0] = "USR017"; $users[15][1] = "Anthony"; $users[15][2] = md5("Anthony");
$users[16][0] = "USR018"; $users[16][1] = "William"; $users[16][2] = md5("William");
$users[17][0] = "USR019"; $users[17][1] = "Andrew"; $users[17][2] = md5("Andrew");
$users[18][0] = "USR020"; $users[18][1] = "Benjamin"; $users[18][2] = md5("Benjamin");
$users[19][0] = "USR021"; $users[19][1] = "Amanda"; $users[19][2] = md5("Amanda");
$users[20][0] = "USR022"; $users[20][1] = "Lillian"; $users[20][2] = md5("Lillian");
$users[21][0] = "USR023"; $users[21][1] = "Jennifer"; $users[21][2] = md5("Jennifer");
$users[22][0] = "USR024"; $users[22][1] = "Carter"; $users[22][2] = md5("Carter");
$users[23][0] = "USR025"; $users[23][1] = "Kimberly"; $users[23][2] = md5("Kimberly");
$users[24][0] = "USR026"; $users[24][1] = "Amelia"; $users[24][2] = md5("Amelia");
$users[25][0] = "USR027"; $users[25][1] = "Mason"; $users[25][2] = md5("Mason");
$users[26][0] = "USR028"; $users[26][1] = "Taylor"; $users[26][2] = md5("Taylor");
$users[27][0] = "USR029"; $users[27][1] = "Brandon"; $users[27][2] = md5("Brandon");
$users[28][0] = "USR030"; $users[28][1] = "Lucas"; $users[28][2] = md5("Lucas");
$users[29][0] = "USR031"; $users[29][1] = "Dominic"; $users[29][2] = md5("Dominic");
$users[30][0] = "USR032"; $users[30][1] = "Justin"; $users[30][2] = md5("Justin");
$users[31][0] = "USR033"; $users[31][1] = "Steven"; $users[31][2] = md5("Steven");
$users[32][0] = "USR034"; $users[32][1] = "Austin"; $users[32][2] = md5("Austin");
$users[33][0] = "USR035"; $users[33][1] = "Marie"; $users[33][2] = md5("Marie");
$users[34][0] = "USR036"; $users[34][1] = "Robert"; $users[34][2] = md5("Robert");
$users[35][0] = "USR037"; $users[35][1] = "Laura"; $users[35][2] = md5("Laura");
$users[36][0] = "USR038"; $users[36][1] = "Carson"; $users[36][2] = md5("Carson");
$users[37][0] = "USR039"; $users[37][1] = "Timothy"; $users[37][2] = md5("Timothy");
$users[38][0] = "USR040"; $users[38][1] = "Allison"; $users[38][2] = md5("Allison");
$users[39][0] = "USR041"; $users[39][1] = "Isabelle"; $users[39][2] = md5("Isabelle");
$users[40][0] = "USR042"; $users[40][1] = "Katie"; $users[40][2] = md5("Katie");
$users[41][0] = "USR043"; $users[41][1] = "Andrea"; $users[41][2] = md5("Andrea");
$users[42][0] = "USR044"; $users[42][1] = "Brooke"; $users[42][2] = md5("Brooke");
$users[43][0] = "USR045"; $users[43][1] = "Julian"; $users[43][2] = md5("Julian");
$users[44][0] = "USR046"; $users[44][1] = "Christian"; $users[44][2] = md5("Christian");
$users[45][0] = "USR047"; $users[45][1] = "Patrick"; $users[45][2] = md5("Patrick");
$users[46][0] = "USR048"; $users[46][1] = "Sydney"; $users[46][2] = md5("Sydney");
$users[47][0] = "USR049"; $users[47][1] = "Chelsea"; $users[47][2] = md5("Chelsea");
$users[48][0] = "USR050"; $users[48][1] = "Victoria"; $users[48][2] = md5("Victoria");
$users[49][0] = "USR051"; $users[49][1] = "Charles"; $users[49][2] = md5("Charles");
$users[50][0] = "USR052"; $users[50][1] = "Jayden"; $users[50][2] = md5("Jayden");
$users[51][0] = "USR053"; $users[51][1] = "Caroline"; $users[51][2] = md5("Caroline");
$users[52][0] = "USR054"; $users[52][1] = "Ashlyn"; $users[52][2] = md5("Ashlyn");
$users[53][0] = "USR055"; $users[53][1] = "Colin"; $users[53][2] = md5("Colin");
$users[54][0] = "USR056"; $users[54][1] = "Blake"; $users[54][2] = md5("Blake");
$users[55][0] = "USR057"; $users[55][1] = "Haley"; $users[55][2] = md5("Haley");
$users[56][0] = "USR058"; $users[56][1] = "Katherine"; $users[56][2] = md5("Katherine");
$users[57][0] = "USR059"; $users[57][1] = "Charlotte"; $users[57][2] = md5("Charlotte");
$users[58][0] = "USR060"; $users[58][1] = "George"; $users[58][2] = md5("George");
$users[59][0] = "USR061"; $users[59][1] = "Richard"; $users[59][2] = md5("Richard");
$users[60][0] = "USR062"; $users[60][1] = "Heather"; $users[60][2] = md5("Heather");
$users[61][0] = "USR063"; $users[61][1] = "Oliver"; $users[61][2] = md5("Oliver");
$users[62][0] = "USR064"; $users[62][1] = "Alexandra"; $users[62][2] = md5("Alexandra");
$users[63][0] = "USR065"; $users[63][1] = "Courtney"; $users[63][2] = md5("Courtney");
$users[64][0] = "USR066"; $users[64][1] = "Ellie"; $users[64][2] = md5("Ellie");
$users[65][0] = "USR067"; $users[65][1] = "Skyler"; $users[65][2] = md5("Skyler");
$users[66][0] = "USR068"; $users[66][1] = "Mariah"; $users[66][2] = md5("Mariah");
$users[67][0] = "USR069"; $users[67][1] = "Scott"; $users[67][2] = md5("Scott");
$users[68][0] = "USR070"; $users[68][1] = "Isabel"; $users[68][2] = md5("Isabel");
$users[69][0] = "USR071"; $users[69][1] = "Christina"; $users[69][2] = md5("Christina");
$users[70][0] = "USR072"; $users[70][1] = "Jamie"; $users[70][2] = md5("Jamie");
$users[71][0] = "USR073"; $users[71][1] = "Edward"; $users[71][2] = md5("Edward");
$users[72][0] = "USR074"; $users[72][1] = "Stephen"; $users[72][2] = md5("Stephen");
$users[73][0] = "USR075"; $users[73][1] = "Karen"; $users[73][2] = md5("Karen");
$users[74][0] = "USR076"; $users[74][1] = "Parker"; $users[74][2] = md5("Parker");
$users[75][0] = "USR077"; $users[75][1] = "Jeremy"; $users[75][2] = md5("Jeremy");
$users[76][0] = "USR078"; $users[76][1] = "Peter"; $users[76][2] = md5("Peter");
$users[77][0] = "USR079"; $users[77][1] = "Lindsey"; $users[77][2] = md5("Lindsey");
$users[78][0] = "USR080"; $users[78][1] = "Henry"; $users[78][2] = md5("Henry");
$users[79][0] = "USR081"; $users[79][1] = "Alice"; $users[79][2] = md5("Alice");
$users[80][0] = "USR082"; $users[80][1] = "Sandra"; $users[80][2] = md5("Sandra");
$users[81][0] = "USR083"; $users[81][1] = "Travis"; $users[81][2] = md5("Travis");
$users[82][0] = "USR084"; $users[82][1] = "Colton"; $users[82][2] = md5("Colton");
$users[83][0] = "USR085"; $users[83][1] = "Brian"; $users[83][2] = md5("Brian");
$users[84][0] = "USR086"; $users[84][1] = "Daisy"; $users[84][2] = md5("Daisy");
$users[85][0] = "USR087"; $users[85][1] = "Barbara"; $users[85][2] = md5("Barbara");
$users[86][0] = "USR088"; $users[86][1] = "Jeffrey"; $users[86][2] = md5("Jeffrey");
$users[87][0] = "USR089"; $users[87][1] = "Eliza"; $users[87][2] = md5("Eliza");
$users[88][0] = "USR090"; $users[88][1] = "Helena"; $users[88][2] = md5("Helena");
$users[89][0] = "USR091"; $users[89][1] = "Linda"; $users[89][2] = md5("Linda");
$users[90][0] = "USR092"; $users[90][1] = "Lilly"; $users[90][2] = md5("Lilly");
$users[91][0] = "USR093"; $users[91][1] = "Gregory"; $users[91][2] = md5("Gregory");
$users[92][0] = "USR094"; $users[92][1] = "Harry"; $users[92][2] = md5("Harry");
$users[93][0] = "USR095"; $users[93][1] = "Nancy"; $users[93][2] = md5("Nancy");
$users[94][0] = "USR096"; $users[94][1] = "Harrison"; $users[94][2] = md5("Harrison");
$users[95][0] = "USR097"; $users[95][1] = "Monica"; $users[95][2] = md5("Monica");
$users[96][0] = "USR098"; $users[96][1] = "Martin"; $users[96][2] = md5("Martin");
$users[97][0] = "USR099"; $users[97][1] = "Cindy"; $users[97][2] = md5("Cindy");
$users[98][0] = "USR100"; $users[98][1] = "Violet"; $users[98][2] = md5("Violet");
$users[99][0] = "USR101"; $users[99][1] = "Vivian"; $users[99][2] = md5("Vivian");
$users[100][0] = "USR102"; $users[100][1] = "Dennis"; $users[100][2] = md5("Dennis");
$users[101][0] = "USR103"; $users[101][1] = "Maggie"; $users[101][2] = md5("Maggie");
$users[102][0] = "USR104"; $users[102][1] = "Justine"; $users[102][2] = md5("Justine");
$users[103][0] = "USR105"; $users[103][1] = "Ronald"; $users[103][2] = md5("Ronald");
$users[104][0] = "USR106"; $users[104][1] = "Lawrence"; $users[104][2] = md5("Lawrence");
$users[105][0] = "USR107"; $users[105][1] = "Elvis"; $users[105][2] = md5("Elvis");
$users[106][0] = "USR108"; $users[106][1] = "Bruce"; $users[106][2] = md5("Bruce");
$users[107][0] = "USR109"; $users[107][1] = "Melinda"; $users[107][2] = md5("Melinda");
$users[108][0] = "USR110"; $users[108][1] = "Phillip"; $users[108][2] = md5("Phillip");
$users[109][0] = "USR111"; $users[109][1] = "Janet"; $users[109][2] = md5("Janet");
// Entering data into `hs_hr_employee` and `hs_hr_users`
//
// NOTE: Don't leave spaces after the heredoc identifiers (EMPSQLSTR and USERSQLSTR)
//
$count = count($employees);
for ($i=0; $i<$count; $i++) {
$empNum = $i + 1;
$empSql = <<< EMPSQLSTR
INSERT INTO hs_hr_employee SET
emp_number = {$empNum},
employee_id = '{$employees[$i][0]}',
emp_lastname = '{$employees[$i][1]}',
emp_firstname = '{$employees[$i][2]}',
emp_middle_name = '',
emp_nick_name = '',
emp_smoker = 0,
ethnic_race_code = NULL,
emp_birthday = NULL,
nation_code = NULL,
emp_gender = NULL,
emp_marital_status = NULL,
emp_ssn_num = '',
emp_sin_num = '',
emp_other_id = '',
emp_dri_lice_num = '',
emp_dri_lice_exp_date = NULL,
emp_military_service = '',
emp_status = NULL,
job_title_code = NULL,
eeo_cat_code = NULL,
work_station = NULL,
emp_street1 = '',
emp_street2 = '',
city_code = '',
coun_code = '',
provin_code = '',
emp_zipcode = NULL,
emp_hm_telephone = NULL,
emp_mobile = NULL,
emp_work_telephone = NULL,
emp_work_email = NULL,
sal_grd_code = NULL,
joined_date = NULL,
emp_oth_email = NULL
EMPSQLSTR;
if (!mysqli_query($dbConnection,$empSql)) { echo mysqli_error(); die; }
if ($i == 0) {
// Default admin
$q = "INSERT INTO `ohrm_user` ( `emp_number`, `user_name`, `user_password`,`user_role_id`) VALUES ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', 1)";
if (!mysqli_query($dbConnection, $q)) {
echo mysqli_error($dbConnection);
die;
}
}
$userSql = <<< USERSQLSTR
INSERT INTO ohrm_user SET
user_role_id = 2,
emp_number = {$empNum},
user_name = '{$users[$i][1]}',
user_password = '{$users[$i][2]}'
USERSQLSTR;
if (!mysqli_query($dbConnection,$userSql)) { echo mysqli_error($dbConnection); die; }
}
// Sets Last ID at `hs_hr_unique_id`
if (!mysqli_query($dbConnection,"UPDATE `hs_hr_unique_id` SET `last_id` = '".count($employees)."' WHERE `field_name` = 'emp_number' AND `table_name` = 'hs_hr_employee'")) { echo mysqli_error($dbConnection); exit(0); }
//End
echo "<h2>Successfully Created " . count($employees) . " employees and their user accounts!</h2>";
?>
<?php if (!mysqli_error($dbConnection)): ?>
<pre>
* Admin username = admin Admin password = admin
*
* For employee, "Kayla Abbey":
*
* ESS username = Kayla ESS password = Kayla
*
* As above, for each employee, username and password would be his/her first name
</pre>
<?php endif; ?>

View File

@ -0,0 +1 @@
http://localhost/orangehrm/devTools/load/recruitment/loadCandidates.php?limit=4000

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
Job Responsibilities
The responsibilities of computer information systems managers are centered around networking and connectivity. This is the most important part of their management duties. The managers must assure that all end users must be able to connect to the network. Managers are therefore responsible for developing plans to resolve any points of failure on the network.
Managers in computer information systems also play the lead role in developing budgets and plans for future upgrades and the types of software that is used within the organization. All of the software that is used is a direct result of the decisions by management. This includes virus software, operating systems, word processing suites, and the email system that is used.
This allows the computer information systems manager to direct the future of technology within an organization. Lots of changes are made through an organization and the manager has to review costs and budgets to ensure that funds are used appropriately for any upgrades and changes made in the technology infrastructure.
Not only is this important in operating systems and applications, but it is also relevant to the equipment used to connect to the network. Switches, routers, and network cabling are all elements that the computer information systems manager must handle.
Network security and data backup completes the cycle of management activity in computer information systems. The management of this is one of the most important parts in the management cycle. An organization cannot risk the possibility of losing data through virus infections or device failures. For this reason, computer information system managers must work diligently to implement security and data recovery options in the development of their technology plans.
Training and Education Requirements
A college degree is preferred in this field for managers because the position requires a proven level of ability that excels beyond the basics. Computer information systems manager typically hold degrees in Computer or Management Information Systems. This consists of class courses structured around data communications, programming, and management information systems. The courses also include marketing, accounting, and finance. These are all valuable classes for managers that need a well rounded background with additional knowledge of budgeting and accounting.

View File

@ -0,0 +1,9 @@
Job Responsibilities
Working on large or small projects with other programmers and software engineers. In this capacity, they may help to troubleshoot potential problems and in the design phase of many software programs. Aided by programs that help to change software into the computers language, programmers can now write more specific parts of the program. Their work helps computers and systems work more smoothly without problems and at a more efficient level. In addition, programmers also write programs for educational software, desktop publishing, business and personnel finances and computer games.
The computer programmer has to have excellent technical skills and knowledge, ability to work well with others, and be willing to work on the international scene. Increasing focus is given to those who are able to work with programs that deal with the Internet and applications for the web. These individuals also must be willing to keep learning on a continual basis, as the changes in technology and software happens on a rapid basis. This is also critical as newer computer systems continue to reach higher levels of complexity. When a large project is involved, being able to work well on a team is required. A number of professionals from within the industry may be needed to handle the tasks and logistics of a large project for an extended period of time. Being able to brainstorm, troubleshoot and collaborate with others can make project completion run smoother.
Training and Education Requirements
Those wanting to enter the field of computer programming can receive training in a variety of levels. Some schools offer a two-year associates degree or a certificate program. This may be adequate training to enter some positions within the field, but many choose to pursue a four year bachelors degree. In some cases, the individual may be required to have achieved a graduate level degree in programming to be eligible for the position. Many who have a degree in areas such as accounting, business and finance may study courses related to computer programming. Computer programmers will usually graduate from a bachelor degree program with a major in math, computer science or information systems. Internships and other hands-on experience opportunities provided needed experience in the field. And attending seminars and continuing education programs also help the computer programmer to keep up with the latest changes and new advancements in technology.

View File

@ -0,0 +1,11 @@
Job Responsibilities
The computer security specialist will not only handle the entire network of computers within a business, but he will also keep all the employees up to date with various security policies and certifications as needed. Additionally, the computer security specialist will also install and support all anti-virus and other relevant company software programs, implement and troubleshoot any security policies regarding internal computers, networks and the data that travels on them.
The computer security role encompasses all aspects of the access of and modifications to any computers and sensitive information that may be kept on them. Keeping hackers out and the data in is what a computer security specialist does best in addition to reporting any suspicious activity on the network or any individual computer. Monitoring the access and control points of sensitive data within the computers in order to keep a companys data safe is the most important job in addition to training the other employees within a company to do the same.
Training and Education Requirements
To become a computer security specialist, the candidate must attain at least a high school diploma or a General education Diploma first. After the completion of general education studies, the candidate should attain at least an associates degree in computer networking, computer information technologies or computer science. Most course work for a computer security career will encompass the basics in information technology such as how to network a computer, how to set up and network a router or modem, how to install and configure anti-virus software, how to operate all operating systems in a proficient manner and so on.
Most associates degrees in any of the computer fields will teach the fundamentals of computers and their security. The more specialized courses will include studies such as server maintenance, software installations and maintenance, ethics and law concerning the Internet and “cyber crime,” computer forensics, database and network infrastructure and architecture and more.

View File

@ -0,0 +1,13 @@
Job Responsibilities
Furthermore, the database administrator is also responsible for the efficiency of the system. It is there job to make sure that all computers within an organization work together effectively. When users report a problem, the database administrator must trouble shoot to determine the source of the problems. In addition, necessary upgrades are researched and implemented by this professional. Some companys also expect the specialist to protect the computer system against threats.
It is important for a database administrator to experiment with different database software programs. The database specialist is then able to recommend the best software for a particular company. The software must be designed to meet the unique needs of the company. This contributes to the smooth running of the organization. Old software information has to be merged with the new updated systems. This process is crucial to the success of the new software. The database specialist is focused on the efficient performance of the computer systems within an organization.
The database administrator works in an office setting that is well lighted and comfortable. The typical schedule for these professionals is a basic 40 hour week. In emergency situations, the database specialist may have to work overtime. This is usually rare. Many of these specialists are able to perform their duties remotely. This can be done outside of the office. Injuries are limited to those that occur from excessive sitting, typing, or computer eye strain. This is not common for most database administrators.
Training and Education Requirements
Most database administrators have some type of degree. Employers prefer a bachelors degree, but some also accept an associates degree. If a person has an associates degree, the employer will look more closely at work experience and certifications. Many of the database specialists start out in entry level positions, and they will advance into more specialized positions in the company. Computer science and information degrees are the most common degrees that professionals in this field possess. Some in this field obtain a bachelors degree in another major. This bachelor degree along with specific coursework in computer science may be sufficient for a job in this field. A bachelors degree in computer science takes the average student four years to finish. During the degree program, the student will take mathematics, computer science, statistics, and other computer information courses. Generalized classes in English, history, and other subjects are also included in the degree program.
Furthermore, most employers expect a database administrator to have an advanced degree. It can take 2 or 3 years to complete a masters degree in computer science. Relevant work experience in this field is very important.

View File

@ -0,0 +1,17 @@
Job Responsibilities
The duties of a game designer can vary greatly depending on the nature of the project that they are working on.
Most game designers will be responsible for creating and tuning the rules of gameplay. In the absence of a dedicated writer, the designer will also be responsible for creating the characters, world, and narrative elements of the game. In collaboration with a Senior or Lead Artist, the game designer will create the visual look and feel of the setting in which the game takes place.
Game designers will work closely with programmers to ensure that the features they would like to see implemented are possible, practical, and worthwhile. They also solicit feedback from testers to ensure that features are functioning properly and in proper balance.
Perhaps most of all, designers work closely with dedicated level designers to ensure that all assets of the game create the type of experience that the game designer expected. Often, game designers will design levels themselves when other duties do not require their attention.
Training and Education Requirements
There is no industry standard of education or work credentials that one must possess to be a game designer. Most studios will require a Bachelors degree or higher, as well as an impressive portfolio. Usually game designers are hired after they have acquired some game industry experience. There are schools that offer degrees specifically in Game Design or similar programs, but these are so recent that they have not become industry-standard.
The portfolio that game designers present must showcase their skills in a variety of applicable areas. Previous work creating complete games as part of a team of developers is ideal. Beyond that, it should demonstrate the game designers ability to clearly communicate game ideas to others, and may include samples of rules explanations, game pitches, game design documents, level descriptions, character profiles, and so forth.
Because game designers interact with so many different areas of development, it is frequently helpful to possess skills that are not strictly design-oriented. Depending on where one applies and what the projects focus is, these will be of varying value. Skill in programming or scripting is almost always beneficial. Drawing, traditional art, or graphic design skills are also of use. If the project requires it, many times the game designer will be in charge of writing dialogue and text for the game when no writer is available.

View File

@ -0,0 +1,346 @@
<?php
/*
* Author: Gayanath Jayarathne
* 2011Aug11Thu, 2011Aug18Thu, 2011Aug19Fri
*/
require_once "../../../lib/confs/Conf.php";
/* Setting records limit */
$recordsLimit = 5000;
if (isset($_GET['limit'])) {
$recordsLimit = $_GET['limit'];
if ($recordsLimit <1 || $recordsLimit > 5000) {
$recordsLimit = 5000;
}
}
/* Starting a MySQL connection */
$conf = new Conf();
$dbConnection = mysqli_connect($conf->dbhost, $conf->dbuser, $conf->dbpass, $conf->dbname, $conf->dbport);
if (!$dbConnection) {
die(mysqli_connect_error());
}
$dbConnection->set_charset("utf8mb4");
mysqli_query($dbConnection, "SET foreign_key_checks = 0");
/* Turning off auto-commit */
mysqli_autocommit($dbConnection, false);
/* Truncating tables */
truncateTables($dbConnection);
/* Adding job titles */
addJobTitles($dbConnection);
/* Adding job vacancies */
addJobVacancies($dbConnection);
/* Adding Candidates */
addCandidates($dbConnection, $recordsLimit);
/* Committing results */
mysqli_commit($dbConnection);
mysqli_query($dbConnection, "SET foreign_key_checks = 1");
if (!mysqli_error($dbConnection)) {
echo "Done!<br><br>\n";
echo "$recordsLimit candidates were added.<br><br>\n";
}
/* Closing the MySQL connection */
mysqli_close($dbConnection);
/* ======================================== */
/* Script Functions */
function display($value) {
//echo $value . " <br><br>\n";
// $logHandle = fopen('log.txt', 'w');
// fwrite($logHandle, $value . "\n\r\n\r");
// fclose($logHandle);
// file_put_contents('log.txt', $value . "\n\r\n\r", FILE_APPEND);
}
function checkQueryResult($result, $dbConnection) {
if ($result !== true) {
echo mysqli_error($dbConnection) . " <br><br>\n";
mysqli_rollback($dbConnection);
}
}
function truncateTables($dbConnection) {
$q = "TRUNCATE TABLE `ohrm_job_candidate_history`";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
$q = "TRUNCATE TABLE `ohrm_job_candidate_attachment`";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
$q = "TRUNCATE TABLE `ohrm_job_candidate_vacancy`";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
$q = "TRUNCATE TABLE `ohrm_job_candidate`";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
$q = "TRUNCATE TABLE `ohrm_job_vacancy`";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
$q = "TRUNCATE TABLE `ohrm_job_title`";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
}
function addJobTitles($dbConnection) {
$q = "INSERT INTO `ohrm_job_title` VALUES
('1', 'Computer Information Systems Manager', 'CISM', 'CISM', 0),
('2', 'Computer Programmer', 'CP', 'CP', 0),
('3', 'Computer Security Specialist', 'CSS', 'CSS', 0),
('4', 'Database Administrator', 'DBA', 'DBA', 0),
('5', 'Game Designer', 'GD', 'GD', 1)
";
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
$q = "UPDATE `hs_hr_unique_id` SET `last_id` = 5 WHERE `table_name` = 'ohrm_job_title'";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
}
function addJobVacancies($dbConnection) {
$name1 = "Computer Information Systems Manager " . date('Y');
$name2 = "Computer Programmer " . date('Y');
$name3 = "Computer Security Specialist " . date('Y');
$name4 = "Database Administrator " . date('Y');
$name5 = "Game Designer " . date('Y');
$vd1 = mysqli_real_escape_string($dbConnection, file_get_contents('job-description-1.txt'));
$vd2 = mysqli_real_escape_string($dbConnection, file_get_contents('job-description-2.txt'));
$vd3 = mysqli_real_escape_string($dbConnection, file_get_contents('job-description-3.txt'));
$vd4 = mysqli_real_escape_string($dbConnection, file_get_contents('job-description-4.txt'));
$vd5 = mysqli_real_escape_string($dbConnection, file_get_contents('job-description-5.txt'));
$dateTime1 = date('Y-m-d H:i:s', strtotime("-10 days"));
$dateTime2 = date('Y-m-d H:i:s', strtotime("-9 days"));
$dateTime3 = date('Y-m-d H:i:s', strtotime("-8 days"));
$dateTime4 = date('Y-m-d H:i:s', strtotime("-7 days"));
$dateTime5 = date('Y-m-d H:i:s', strtotime("-6 days"));
$q = "INSERT INTO `ohrm_job_vacancy` (`id`, `job_title_code`, `hiring_manager_id`, `name`, `description`, `no_of_positions`,
`status`, `published_in_feed`, `defined_time`, `updated_time`) VALUES
(1, '1', '1', '$name1', '$vd1', 1, 1, 1, '$dateTime1', '$dateTime1'),
(2, '2', '2', '$name2', '$vd2', 2, 1, 1, '$dateTime2', '$dateTime2'),
(3, '3', '3', '$name3', '$vd3', 3, 1, 1, '$dateTime3', '$dateTime3'),
(4, '4', '4', '$name4', '$vd4', 4, 1, 1, '$dateTime4', '$dateTime4'),
(5, '5', '5', '$name5', '$vd5', 5, 1, 1, '$dateTime5', '$dateTime5')";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
$q = "UPDATE `hs_hr_unique_id` SET `last_id` = 5 WHERE `table_name` = 'ohrm_job_vacancy'";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
// $jobFeedService = new JobFeedService();
// $jobFeedService->updateJobFeed();
}
function addCandidates($dbConnection, $recordsLimit) {
$candidateFile = file('canidate-name-list.txt');
$recordLimit = $recordsLimit + 1;
$vacancyId = 1;
$dateI = -1;
$appliedDate = date('Y-m-d');
$vacancyNames = array('Computer Information Systems Manager',
'Computer Programmer',
'Computer Security Specialist',
'Database Administrator',
'Game Designer');
$candidateQ = "INSERT INTO `ohrm_job_candidate` (`id`, `first_name`, `middle_name`, `last_name`,
`email`, `contact_number`, `status`, `comment`,
`mode_of_application`, `date_of_application`, `cv_file_id`,
`cv_text_version`, `keywords`, `added_person`) VALUES";
$cvQ = "INSERT INTO `ohrm_job_candidate_attachment` VALUES";
$candidateVacancyQ = "INSERT INTO `ohrm_job_candidate_vacancy` VALUES";
$candidateHistoryQ = "INSERT INTO `ohrm_job_candidate_history` VALUES";
for ($i=1; $i<$recordLimit; $i++) {
$vacancyName = $vacancyNames[$vacancyId-1];
$appliedDate = date('Y-m-d', strtotime("$dateI day"));
$note = file_get_contents("job-description-$vacancyId.txt");
$candidateQ .= getCandidateQPartial($i, $recordLimit, $candidateFile[$i-1], $appliedDate);
$cvQ .= getCvQPartial($i, $recordLimit);
$candidateVacancyQ .= getCandidateVacancyQPartial($i, $recordLimit, $vacancyId, $appliedDate);
$candidateHistoryQ .= getCandidateHistoryQPartial($i, $recordLimit, $vacancyId, $vacancyName, $appliedDate, $dbConnection, $note);
if ($vacancyId < 5) {
$vacancyId++;
} else {
$vacancyId = 1;
}
if ($dateI > -5) {
$dateI--;
} else {
$dateI = -1;
}
}
/* Adding candidate details */
display($candidateQ);
$result = mysqli_query($dbConnection, $candidateQ);
checkQueryResult($result, $dbConnection);
$q = "UPDATE `hs_hr_unique_id` SET `last_id` = 5000 WHERE `table_name` = 'ohrm_job_candidate'";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
/* Adding candidate CV details */
// $result = mysqli_query($dbConnection, $cvQ);
// checkQueryResult($result, $dbConnection);
//
// $q = "UPDATE `hs_hr_unique_id` SET `last_id` = 5000 WHERE `table_name` = 'ohrm_job_candidate_attachment'";
// $result = mysqli_query($dbConnection, $q);
// checkQueryResult($result, $dbConnection);
/* Adding candidate vacancy details */
display($candidateVacancyQ);
$result = mysqli_query($dbConnection, $candidateVacancyQ);
checkQueryResult($result, $dbConnection);
$q = "UPDATE `hs_hr_unique_id` SET `last_id` = 5000 WHERE `table_name` = 'ohrm_job_candidate_vacancy'";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
/* Adding candidate history details */
display($candidateHistoryQ);
$result = mysqli_query($dbConnection, $candidateHistoryQ);
checkQueryResult($result, $dbConnection);
$q = "UPDATE `hs_hr_unique_id` SET `last_id` = 5000 WHERE `table_name` = 'ohrm_job_candidate_history'";
display($q);
$result = mysqli_query($dbConnection, $q);
checkQueryResult($result, $dbConnection);
}
function getCandidateQPartial($i, $recordLimit, $nameString, $appliedDate) {
$nameItems = explode(" ", trim($nameString));
$id = $i;
$first_name = $nameItems[0];
$middle_name = "";
$last_name = $nameItems[0];
$email = "$first_name.$last_name@example.com";
$contact_number = "+12-12569-" . str_pad($i, 5, "0", STR_PAD_LEFT);
$status = 1;
$comment = "Candidate $id";
$mode_of_application = 2; // (($i%2)==0)?1:2;
$date_of_application = $appliedDate;
$cv_file_id = $i;
$cv_text_version = "";
$keywords = "PHP, jQuery, MySQL, SVN";
$added_person = "";
$q = " ($id, '$first_name', '$middle_name', '$last_name',
'$email', '$contact_number', $status, '$comment',
$mode_of_application, '$date_of_application', NULL,
'$cv_text_version', '$keywords', NULL)";
if ($i < ($recordLimit - 1)) {
$q .= ",";
}
return $q;
}
function getCvQPartial($i, $recordLimit) {
$fileName = "test-cv.pdf";
$fileType = "application/pdf";
$fileSize = 10658;
$fileContent = file_get_contents("test-cv.pdf");
$q = " ($i, $i, '$fileName', '$fileType', $fileSize, '$fileContent', NULL)";
if ($i < ($recordLimit - 1)) {
$q .= ",";
}
return $q;
}
function getCandidateVacancyQPartial($i, $recordLimit, $vacancyId, $appliedDate) {
$status = "APPLICATION INITIATED";
$q = " ($i, $i, $vacancyId, '$status', '$appliedDate')";
if ($i < ($recordLimit - 1)) {
$q .= ",";
}
return $q;
}
function getCandidateHistoryQPartial($i, $recordLimit, $vacancyId, $vacancyName, $performedDate, $dbConnection, $note) {
$note = mysqli_real_escape_string($dbConnection, $note);
$q = " ($i, $i, $vacancyId, '$vacancyName', NULL, 16, NULL, '$performedDate', '$note', NULL)";
if ($i < ($recordLimit - 1)) {
$q .= ",";
}
return $q;
}
?>

Binary file not shown.

Binary file not shown.

Binary file not shown.

30
index.php Executable file
View File

@ -0,0 +1,30 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
use OrangeHRM\Config\Config;
require realpath(__DIR__ . '/src/vendor/autoload.php');
/* For logging PHP errors */
include_once('./src/config/log_settings.php');
if (!Config::isInstalled()) {
header('Location: ./installer/index.php');
} else {
header("Location: ./web/index.php/auth/login");
}

24
installer/.htaccess Executable file
View File

@ -0,0 +1,24 @@
<FilesMatch "\.php$">
Require all denied
</FilesMatch>
<Files "index.php">
Require all granted
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
# Check if .html version exists (for caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# Redirect to front controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule mod_headers.c>
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
</IfModule>

View File

@ -0,0 +1,75 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\Installer\Command;
use OrangeHRM\Authentication\Dto\UserCredential;
use OrangeHRM\Installer\Util\AppSetupUtility;
use OrangeHRM\Installer\Util\StateContainer;
class InstallOnExistingDatabaseCommand extends InstallOnNewDatabaseCommand
{
use InstallerCommandHelperTrait;
/**
* @inheritDoc
*/
public function getCommandName(): string
{
return 'install:on-existing-database';
}
protected function databaseInformation(): void
{
dbInfo:
$this->getIO()->title('Database Configuration');
$this->getIO()->block('Please enter your database configuration information below.');
$dbHost = $this->getRequiredField('Database Host Name');
$dbPort = $this->getIO()->ask(
'Database Host Port',
3306,
fn (?string $value) => $this->databasePortValidator($value)
);
$dbName = $this->getRequiredField('Database Name'); // not validated because existing database
$dbUser = $this->getRequiredField('OrangeHRM Database Username');
$dbPassword = $this->getIO()->askHidden('OrangeHRM Database User Password <comment>(hidden)</comment>');
$enableDataEncryption = $this->getIO()->confirm('Enable Data Encryption', false);
StateContainer::getInstance()->storeDbInfo(
$dbHost,
$dbPort,
new UserCredential($dbUser, $dbPassword),
$dbName,
null,
$enableDataEncryption
);
StateContainer::getInstance()->setDbType(AppSetupUtility::INSTALLATION_DB_TYPE_EXISTING);
$connection = $this->getAppSetupUtility()->connectToDatabase();
if ($connection->hasError()) {
$this->getIO()->error($connection->getErrorMessage());
StateContainer::getInstance()->clearDbInfo();
goto dbInfo;
}
if (!$this->getAppSetupUtility()->isExistingDatabaseEmpty()) {
$this->getIO()->error('Provided Database Not Empty');
StateContainer::getInstance()->clearDbInfo();
goto dbInfo;
}
}
}

View File

@ -0,0 +1,433 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\Installer\Command;
use DateTimeZone;
use OrangeHRM\Authentication\Dto\UserCredential;
use OrangeHRM\Config\Config;
use OrangeHRM\Framework\Http\Request;
use OrangeHRM\Installer\Controller\Installer\Api\ConfigFileAPI;
use OrangeHRM\Installer\Controller\Installer\Api\InstallerDataRegistrationAPI;
use OrangeHRM\Installer\Exception\InterruptProcessException;
use OrangeHRM\Installer\Exception\InvalidArgumentException;
use OrangeHRM\Installer\Framework\InstallerCommand;
use OrangeHRM\Installer\Util\AppSetupUtility;
use OrangeHRM\Installer\Util\Connection;
use OrangeHRM\Installer\Util\DatabaseUserPermissionEvaluator;
use OrangeHRM\Installer\Util\InstanceCreationHelper;
use OrangeHRM\Installer\Util\Logger;
use OrangeHRM\Installer\Util\StateContainer;
use OrangeHRM\Installer\Util\SystemCheck;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\Question;
use Throwable;
class InstallOnNewDatabaseCommand extends InstallerCommand
{
use InstallerCommandHelperTrait;
public const REQUIRED_TAG = '<comment>(required)</comment>';
public const REQUIRED_WARNING = 'This field cannot be empty';
public const STEP_1 = 'Database creation';
public const STEP_2 = 'Checking database permissions';
public const STEP_3 = 'Applying database changes';
public const STEP_4 = 'Instance and Admin user creation';
public const STEP_5 = 'Create OrangeHRM database user';
public const STEP_6 = 'Creating configuration files';
private InputInterface $input;
private OutputInterface $output;
private AppSetupUtility $appSetupUtility;
/**
* @inheritDoc
*/
public function getCommandName(): string
{
return 'install:on-new-database';
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
if (!$input->isInteractive()) {
$this->getIO()->error('Not supported non interactive mode.');
return self::INVALID;
}
if (Config::isInstalled()) {
$this->getIO()->error('This system already installed.');
return self::FAILURE;
}
$this->input = $input;
$this->output = $output;
try {
return $this->executeCommand($input, $output);
} catch (InterruptProcessException $e) {
return self::FAILURE;
}
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function executeCommand(InputInterface $input, OutputInterface $output): int
{
$this->licenseAcceptance();
$this->databaseInformation();
$this->systemCheck();
$this->instanceCreation();
$this->adminUserCreation();
$this->installation();
return self::SUCCESS;
}
/**
* @return InputInterface
*/
protected function getInput(): InputInterface
{
return $this->input;
}
/**
* @return OutputInterface
*/
protected function getOutput(): OutputInterface
{
return $this->output;
}
/**
* @return AppSetupUtility
*/
public function getAppSetupUtility(): AppSetupUtility
{
return $this->appSetupUtility ??= new AppSetupUtility();
}
protected function licenseAcceptance(): void
{
$this->getIO()->title('License Acceptance');
$this->getIO()->block('Please review the license terms before installing OrangeHRM Starter.');
$this->getIO()->block('You can find the license file ("LICENSE") at the root folder of the code.');
if ($this->getIO()->confirm('I accept the terms in the License Agreement') !== true) {
throw new InterruptProcessException();
}
}
protected function databaseInformation(): void
{
dbInfo:
$this->getIO()->title('Database Configuration');
$this->getIO()->block('Please enter your database configuration information below.');
$dbHost = $this->getRequiredField('Database Host Name');
$dbPort = $this->getIO()->ask(
'Database Host Port',
3306,
fn (?string $value) => $this->databasePortValidator($value)
);
$dbName = $this->getRequiredField('Database Name', function ($value) {
$value = $this->validateStrLength($value, 64);
return $this->alphanumericValidator($value, 'Database name should not contain special characters');
});
$this->getIO()->writeln(
"<comment>Privileged Database User:</comment>\nShould have the rights to create databases, create tables, insert data into table, alter table structure and to create database users."
);
$this->getIO()->writeln(
"<comment>OrangeHRM Database User:</comment>\nShould have the rights to insert data into table, update data in a table, delete data in a table."
);
$dbUser = $this->getRequiredField('Privileged Database Username');
$dbPassword = $this->getIO()->askHidden('Privileged Database User Password <comment>(hidden)</comment>');
$useSameDbUser = $this->getIO()->confirm(
'Use the same `Privileged Database User` as `OrangeHRM Database User`',
false
);
$ohrmDbUser = $dbUser;
$ohrmDbPassword = $dbPassword;
if ($useSameDbUser === false) {
$ohrmDbUser = $this->getRequiredField('OrangeHRM Database Username');
$ohrmDbPassword = $this->getIO()->askHidden(
'OrangeHRM Database User Password <comment>(hidden)</comment>'
);
}
$enableDataEncryption = $this->getIO()->confirm('Enable Data Encryption', false);
StateContainer::getInstance()->storeDbInfo(
$dbHost,
$dbPort,
new UserCredential($dbUser, $dbPassword),
$dbName,
new UserCredential($ohrmDbUser, $ohrmDbPassword),
$enableDataEncryption
);
StateContainer::getInstance()->setDbType(AppSetupUtility::INSTALLATION_DB_TYPE_NEW);
$connection = $this->getAppSetupUtility()->connectToDatabaseServer();
if ($connection->hasError()) {
$this->getIO()->error($connection->getErrorMessage());
StateContainer::getInstance()->clearDbInfo();
goto dbInfo;
}
if ($this->getAppSetupUtility()->isDatabaseExist($dbName)) {
$this->getIO()->error('Database Already Exist');
StateContainer::getInstance()->clearDbInfo();
goto dbInfo;
}
if (!$useSameDbUser && $this->getAppSetupUtility()->isDatabaseUserExist($ohrmDbUser)) {
$this->getIO()->error(
"Database User `$ohrmDbUser` Already Exist. Please Use Another Username for `OrangeHRM Database Username`."
);
StateContainer::getInstance()->clearDbInfo();
goto dbInfo;
}
}
protected function systemCheck(): void
{
$systemCheck = new SystemCheck();
$results = $systemCheck->getSystemCheckResults(true);
$dbInfo = StateContainer::getInstance()->getDbInfo();
if (isset($dbInfo[StateContainer::ENABLE_DATA_ENCRYPTION])
&& $dbInfo[StateContainer::ENABLE_DATA_ENCRYPTION] == true) {
$results[1]['checks'][] = [
'label' => 'Write Permissions for “lib/confs/cryptokeys”',
'value' => $systemCheck->isWritableCryptoKeyDir()
];
}
$this->drawSystemCheckTable($results);
if ($systemCheck->isInterruptContinue()) {
$this->getIO()->error('System check failed');
$systemCheckAcceptRisk = $this->getIO()->confirm('Do you want to accept the risk and continue?', false);
if ($systemCheckAcceptRisk !== true) {
throw new InterruptProcessException();
}
$this->getIO()->warning('Accepted the risk, so continue the upgrader.');
}
}
protected function instanceCreation(): void
{
$this->getIO()->title('Instance Creation');
$this->getIO()->block(
'Fill in your organization details here. Details entered in this section will be captured to create your OrangeHRM Instance'
);
$organizationName = $this->getRequiredField(
'Organization Name',
fn ($value) => $this->validateStrLength($value, 100)
);
$countries = array_combine(
array_column(InstanceCreationHelper::COUNTRIES, 'id'),
array_column(InstanceCreationHelper::COUNTRIES, 'label')
);
asort($countries);
$countries = array_map(fn ($country) => strtolower($country), $countries);
$countries = array_flip($countries);
$countryQuestion = new Question('Country ' . self::REQUIRED_TAG);
$countryQuestion->setValidator(
static function (?string $country) use ($countries): string {
if (!isset($countries[$country])) {
throw new InvalidArgumentException('Invalid option');
}
return $country;
}
);
$this->getIO()->block("Tip:\n* Use lowercase letters\n* Use `Tab` to autocomplete");
$countryQuestion->setAutocompleterValues(array_keys($countries));
$country = $this->getIO()->askQuestion($countryQuestion);
$countryCode = $countries[$country];
$this->getIO()->block("Tip:\n* Use correct letter case\n* Use `Tab` to autocomplete");
$languages = array_combine(
array_column(InstanceCreationHelper::LANGUAGES, 'id'),
array_column(InstanceCreationHelper::LANGUAGES, 'label')
);
$languageQuestion = new ChoiceQuestion('Language', $languages);
$languageQuestion->setValidator(
static function (?string $language) use ($languages): ?string {
if ($language == null || trim($language) === '') {
return $language;
}
if (!(isset($languages[$language]) || in_array($language, array_values($languages)))) {
throw new InvalidArgumentException('Invalid option');
}
return $language;
}
);
$langCode = $this->getIO()->askQuestion($languageQuestion);
$timeZoneGroups = array_combine(
array_column(InstanceCreationHelper::TIME_ZONE_GROUPS, 'label'),
array_column(InstanceCreationHelper::TIME_ZONE_GROUPS, 'id')
);
$timezoneGroupQuestion = new ChoiceQuestion('Timezone Group', array_keys($timeZoneGroups));
$timezoneGroupQuestion->setValidator(
static function (?string $timezoneGroup) use ($timeZoneGroups): ?string {
if ($timezoneGroup == null || trim($timezoneGroup) === '') {
return $timezoneGroup;
}
if (!isset($timeZoneGroups[$timezoneGroup])) {
throw new InvalidArgumentException('Invalid option');
}
return $timezoneGroup;
}
);
$timeZoneGroupName = $this->getIO()->askQuestion($timezoneGroupQuestion);
$timezones = DateTimeZone::listIdentifiers($timeZoneGroups[$timeZoneGroupName] ?? DateTimeZone::ALL);
$timezoneQuestion = new ChoiceQuestion('Timezone', $timezones);
$timezoneQuestion->setValidator(
static function (?string $timezone) use ($timezones): ?string {
if ($timezone == null || trim($timezone) === '') {
return $timezone;
}
if (!in_array($timezone, $timezones)) {
throw new InvalidArgumentException('Invalid option');
}
return $timezone;
}
);
$timezone = $this->getIO()->askQuestion($timezoneQuestion);
StateContainer::getInstance()->storeInstanceData($organizationName, $countryCode, $langCode, $timezone);
}
protected function adminUserCreation(): void
{
$firstName = $this->getRequiredField('Employee First Name', fn ($value) => $this->validateStrLength($value, 30));
$lastName = $this->getRequiredField('Employee Last Name', fn ($value) => $this->validateStrLength($value, 30));
$email = $this->getRequiredField('Email', function ($value) {
$value = $this->validateStrLength($value, 50);
return $this->emailValidator($value, 'Expected format: admin@example.com');
});
$contact = $this->getIO()->ask('Contact Number', null, function ($value) {
if ($value === null) {
return null;
}
$value = $this->validateStrLength($value, 25);
return $this->phoneNumberValidator($value, 'Allows numbers and only + - / ( )');
});
$username = $this->getRequiredField('Admin Username', fn ($value) => $this->validateStrLength($value, 40));
$password = $this->getIO()->askHidden('Password <comment>(hidden)</comment>', function ($value) {
$value = $this->requiredValidator($value);
return $this->validatePassword($value);
});
$this->getIO()->askHidden(
'Confirm Password <comment>(hidden)</comment>',
function ($value) use ($password) {
$value = $this->requiredValidator($value);
$value = $this->validateStrLength($value, 64);
if ($value !== $password) {
throw new InvalidArgumentException('Passwords do not match');
}
return $value;
}
);
StateContainer::getInstance()->storeAdminUserData(
$firstName,
$lastName,
$email,
new UserCredential($username, $password),
$contact
);
$regConsent = $this->getIO()->confirm(
'Register your system with OrangeHRM. By registering, You will be eligible for free support via emails, receive security alerts and news letters from OrangeHRM.',
true
);
StateContainer::getInstance()->storeRegConsent($regConsent);
$this->getIO()->note(
'Users who seek access to their data, or who seek to correct, amend, or delete the given information should direct their requests to data@orangehrm.com'
);
}
protected function installation(): void
{
$continue = $this->getIO()->confirm('Do you want to start the installer?', true);
if ($continue !== true) {
$this->getIO()->info('Aborted');
throw new InterruptProcessException();
}
$step1 = $this->startSection($this->getOutput(), self::STEP_1);
$step2 = $this->startSection($this->getOutput(), self::STEP_2);
$step3 = $this->startSection($this->getOutput(), self::STEP_3);
$step4 = $this->startSection($this->getOutput(), self::STEP_4);
$step5 = $this->startSection($this->getOutput(), self::STEP_5);
$step6 = $this->startSection($this->getOutput(), self::STEP_6, "\n");
$this->startStep($step1, self::STEP_1);
$request = new Request();
$request->setMethod(Request::METHOD_POST);
(new InstallerDataRegistrationAPI())->handle($request);
$appSetupUtility = $this->getAppSetupUtility();
$appSetupUtility->createDatabase();
$this->completeStep($step1, self::STEP_1);
$this->startStep($step2, self::STEP_2);
try {
$evaluator = new DatabaseUserPermissionEvaluator(Connection::getConnection());
$evaluator->evalPrivilegeDatabaseUserPermission();
} catch (Throwable $e) {
Logger::getLogger()->error($e->getMessage());
Logger::getLogger()->error($e->getTraceAsString());
$this->getIO()->error(
'`Checking database permissions` failed. For more details check the error log in /src/log/installer.log file'
);
throw new InterruptProcessException();
}
$this->completeStep($step2, self::STEP_2);
$this->startStep($step3, self::STEP_3);
$appSetupUtility->runMigrations('3.3.3', Config::PRODUCT_VERSION);
$this->completeStep($step3, self::STEP_3);
$this->startStep($step4, self::STEP_4);
$appSetupUtility->insertSystemConfiguration();
$this->completeStep($step4, self::STEP_4);
$this->startStep($step5, self::STEP_5);
$appSetupUtility->createDBUser();
$this->completeStep($step5, self::STEP_5);
$this->startStep($step6, self::STEP_6, "\n");
$request = new Request();
$request->setMethod(Request::METHOD_POST);
(new ConfigFileAPI())->handle($request);
$this->completeStep($step6, self::STEP_6, "\n");
}
}

View File

@ -0,0 +1,236 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\Installer\Command;
use OrangeHRM\Authentication\Dto\UserCredential;
use OrangeHRM\Authentication\Utility\PasswordStrengthValidation;
use OrangeHRM\Installer\Exception\InvalidArgumentException;
use OrangeHRM\Installer\Util\Service\InstallerPasswordStrengthService;
use OrangeHRM\Installer\Util\SystemCheck;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
trait InstallerCommandHelperTrait
{
/**
* @param string $label
* @param callable|null $validator
* @return string
*/
private function getRequiredField(string $label, ?callable $validator = null): string
{
$question = new Question($label . ' ' . self::REQUIRED_TAG);
$question->setNormalizer(static function ($value) {
return $value !== null ? trim($value) : null;
});
$question->setValidator(function ($answer) use ($validator) {
$answer = $this->requiredValidator($answer);
if ($validator === null) {
return $answer;
}
return $validator($answer);
});
return $this->getIO()->askQuestion($question);
}
/**
* @param string|null $answer
* @return string|null
*/
private function requiredValidator(?string $answer): ?string
{
if ($answer === null || strlen($answer) === 0) {
throw new InvalidArgumentException(self::REQUIRED_WARNING);
}
return $answer;
}
/**
* @param string|null $value
* @return string|null
*/
private function databasePortValidator(?string $value): ?string
{
if (($value === null || strlen(trim($value)) === 0)
|| (is_numeric($value) && (int)$value >= 0 && (int)$value <= 65535)) {
return $value;
}
throw new InvalidArgumentException('Enter a valid port number: 0 - 65535');
}
/**
* @param string|null $value
* @param string $message
* @return string|null
*/
private function alphanumericValidator(?string $value, string $message): ?string
{
if (preg_match('/^[a-zA-Z0-9_]*$/', $value) === 1) {
return $value;
}
throw new InvalidArgumentException($message);
}
/**
* @param string|null $value
* @param string $message
* @return string|null
*/
private function emailValidator(?string $value, string $message): ?string
{
$match = preg_match(
"/^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/",
$value
);
if ($match === 1) {
return $value;
}
throw new InvalidArgumentException($message);
}
/**
* @param string|null $value
* @param string $message
* @return string|null
*/
private function phoneNumberValidator(?string $value, string $message): ?string
{
if (preg_match('/^[0-9+\-\/() ]+$/', $value) === 1) {
return $value;
}
throw new InvalidArgumentException($message);
}
/**
* @param InputInterface $input
* @param string $name
* @return bool
*/
private function hasOption(InputInterface $input, string $name): bool
{
$value = $input->getOption($name);
if ($value == null) {
return false;
}
return strlen(trim($value)) > 0;
}
/**
* @param array $systemCheckResults
*/
private function drawSystemCheckTable(array $systemCheckResults): void
{
$this->getIO()->title('System Check');
$this->getIO()->block(
'In order for your OrangeHRM installation to function properly, please ensure that all of the system check items listed below are green. If any are red, please take the necessary steps to fix them.'
);
foreach ($systemCheckResults as $category) {
$rows = [];
foreach ($category['checks'] as $check) {
switch ($check['value']['status']) {
case SystemCheck::PASSED:
$style = '<fg=black;bg=green>%s</>';
break;
case SystemCheck::BLOCKER:
$style = '<fg=white;bg=red>%s</>';
break;
case SystemCheck::ACCEPTABLE:
$style = '<fg=black;bg=yellow>%s</>';
break;
default:
$style = '<fg=default;bg=default>%s</>';
}
$status = sprintf($style, $check['value']['message']);
$rows[] = [$check['label'], $status];
}
$this->getIO()->table([$category['category']], $rows);
}
}
/**
* @param OutputInterface $output
* @param string $step
* @param string $suffix
* @return ConsoleSectionOutput
*/
private function startSection(OutputInterface $output, string $step, string $suffix = ''): ConsoleSectionOutput
{
/** @var ConsoleSectionOutput $section */
$section = $output->section();
$section->writeln("* $step$suffix");
return $section;
}
/**
* @param ConsoleSectionOutput $section
* @param string $step
* @param string $suffix
*/
private function startStep(ConsoleSectionOutput $section, string $step, string $suffix = ''): void
{
$section->overwrite("* <comment>$step</comment>$suffix");
}
/**
* @param ConsoleSectionOutput $section
* @param string $step
* @param string $suffix
*/
private function completeStep(ConsoleSectionOutput $section, string $step, string $suffix = ''): void
{
$section->overwrite("<fg=green>* $step ✓</>$suffix");
}
/**
* @param string|null $text
* @param int $length
* @return string|null
*/
private function validateStrLength(?string $text, int $length): ?string
{
if ($text === null || mb_strlen($text) <= $length) {
return $text;
}
throw InvalidArgumentException::shouldNotExceedCharacters($length);
}
/**
* @param string $value
* @return string
* @throws InvalidArgumentException
*/
private function validatePassword(string $value): string
{
$passwordStrengthValidation = new PasswordStrengthValidation();
$passwordStrengthService = new InstallerPasswordStrengthService();
$credential = new UserCredential('', $value);
$passwordStrength = $passwordStrengthValidation->checkPasswordStrength($credential);
$messages = $passwordStrengthService->checkPasswordPolicies($credential, $passwordStrength);
if (count($messages) > 0) {
throw new InvalidArgumentException($messages[0]);
}
return $value;
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\Installer\Command;
use OrangeHRM\Installer\Framework\InstallerCommand;
use OrangeHRM\Installer\Util\InstanceCreationHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class InstallerCountryListCommand extends InstallerCommand
{
/**
* @inheritDoc
*/
public function getCommandName(): string
{
return 'install:country-list';
}
/**
* @inheritDoc
*/
protected function configure(): void
{
$this->addOption('country', 'c', InputOption::VALUE_REQUIRED);
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$countries = array_combine(
array_column(InstanceCreationHelper::COUNTRIES, 'id'),
array_column(InstanceCreationHelper::COUNTRIES, 'label')
);
asort($countries);
$countries = array_map(fn ($country) => strtolower($country), $countries);
$country = $input->getOption('country');
if ($country !== null) {
$countries = array_flip($countries);
$country = $countries[strtolower($country)] ?? null;
if ($country == null) {
$this->getIO()->error('Invalid country');
return self::FAILURE;
}
$this->getIO()->writeln($country);
return self::SUCCESS;
}
$countries = array_map(static function ($k, $v) {
return " <comment>[$k]</comment> $v";
}, array_keys($countries), array_values($countries));
$this->getIO()->writeln($countries);
return self::SUCCESS;
}
}

View File

@ -0,0 +1,286 @@
<?php
/**
* OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
* all the essential functionalities required for any enterprise.
* Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
*
* OrangeHRM is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with OrangeHRM.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace OrangeHRM\Installer\Command;
use InvalidArgumentException;
use OrangeHRM\Authentication\Dto\UserCredential;
use OrangeHRM\Config\Config;
use OrangeHRM\Framework\Http\Request;
use OrangeHRM\Installer\Controller\Upgrader\Api\ConfigFileAPI;
use OrangeHRM\Installer\Controller\Upgrader\Api\UpgraderDataRegistrationAPI;
use OrangeHRM\Installer\Exception\SystemCheckException;
use OrangeHRM\Installer\Framework\InstallerCommand;
use OrangeHRM\Installer\Util\AppSetupUtility;
use OrangeHRM\Installer\Util\Connection;
use OrangeHRM\Installer\Util\DatabaseUserPermissionEvaluator;
use OrangeHRM\Installer\Util\Logger;
use OrangeHRM\Installer\Util\StateContainer;
use OrangeHRM\Installer\Util\SystemCheck;
use OrangeHRM\Installer\Util\UpgraderConfigUtility;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Throwable;
class UpgradeCommand extends InstallerCommand
{
use InstallerCommandHelperTrait;
public const REQUIRED_TAG = '<comment>(required)</comment>';
public const REQUIRED_WARNING = 'This field cannot be empty';
public const STEP_1 = 'Checking database permissions';
public const STEP_2 = 'Applying database changes';
public const STEP_3 = 'Creating configuration files';
/**
* @inheritDoc
*/
public function getCommandName(): string
{
$this->setAliases(['upgrade']);
return 'upgrade:run';
}
/**
* @inheritDoc
*/
protected function configure(): void
{
$this->addOption('dbHost', null, InputOption::VALUE_REQUIRED)
->addOption('dbPort', null, InputOption::VALUE_REQUIRED)
->addOption('dbName', null, InputOption::VALUE_REQUIRED)
->addOption('dbUser', null, InputOption::VALUE_REQUIRED)
->addOption('dbUserPassword', null, InputOption::VALUE_REQUIRED)
->addOption('currentVersion', null, InputOption::VALUE_REQUIRED)
->addOption('systemCheckAcceptRisk', null, InputOption::VALUE_NONE);
}
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
if (Config::isInstalled()) {
$this->getIO()->error('This system already installed.');
return self::FAILURE;
}
$this->getIO()->title('Database Information');
$this->getIO()->block('Please provide the database information of the database you are going to upgrade.');
$this->getIO()->caution(
"IMPORTANT: Make sure it's a copy of the database of your current OrangeHRM installation and not the original database. It's highly discouraged to use the original database for upgrading since it won't be recoverable if an error occurred during the upgrade."
);
$this->getIO()->warning(
"ENCRYPTION: If you have enabled data encryption in your current version, you need to copy the file 'lib/confs/cryptokeys/key.ohrm' from your current installation to corresponding location in the new version."
);
if ($input->isInteractive()) {
if (!$this->hasOption($input, 'dbHost')) {
$dbHost = $this->getRequiredField('Database Host Name');
$input->setOption('dbHost', $dbHost);
}
if (!$this->hasOption($input, 'dbPort')) {
$dbPort = $this->getIO()->ask(
'Database Host Port',
3306,
fn (?string $value) => $this->databasePortValidator($value)
);
$input->setOption('dbPort', $dbPort);
}
if (!$this->hasOption($input, 'dbName')) {
$dbName = $this->getRequiredField('Database Name'); // not validated because database already there
$input->setOption('dbName', $dbName);
}
if (!$this->hasOption($input, 'dbUser')) {
$dbUser = $this->getRequiredField('Database Username');
$input->setOption('dbUser', $dbUser);
}
if (!$this->hasOption($input, 'dbUserPassword')) {
$dbPassword = $this->getIO()->askHidden('Database User Password <comment>(hidden)</comment>');
$input->setOption('dbUserPassword', $dbPassword);
}
}
$this->throwIfParamEmpty($input, 'dbHost');
$this->throwIfParamEmpty($input, 'dbName');
$this->throwIfParamEmpty($input, 'dbUser');
$dbHost = $input->getOption('dbHost');
$dbPort = $input->getOption('dbPort') ?? 3306;
$dbName = $input->getOption('dbName');
$dbUser = $input->getOption('dbUser');
$dbPassword = $input->getOption('dbUserPassword');
$this->drawDatabaseInfoTable($dbHost, $dbPort, $dbName, $dbUser);
StateContainer::getInstance()->storeDbInfo($dbHost, $dbPort, new UserCredential($dbUser, $dbPassword), $dbName);
$upgraderConfigUtility = new UpgraderConfigUtility();
try {
$upgraderConfigUtility->checkDatabaseConnection();
} catch (SystemCheckException $e) {
$this->getIO()->error($e->getMessage());
return self::INVALID;
}
$systemCheck = new SystemCheck();
$this->drawSystemCheckTable($systemCheck->getSystemCheckResults(true));
if ($systemCheck->isInterruptContinue()) {
$this->getIO()->error('System check failed');
if (!$this->hasOption($input, 'systemCheckAcceptRisk') && $input->isInteractive()) {
$input->setOption(
'systemCheckAcceptRisk',
$this->getIO()->confirm('Do you want to accept the risk and continue?', false)
);
}
if ($input->getOption('systemCheckAcceptRisk') !== true) {
return self::INVALID;
}
$this->getIO()->warning('Accepted the risk, so continue the upgrader.');
}
$this->getIO()->title('Current Version Details');
$this->getIO()->block(
'Select your current OrangeHRM version here. You can find the version at the bottom of the OrangeHRM login page. OrangeHRM Upgrader only supports versions listed in the dropdown. Selecting a different version would lead to an upgrade failure and a database corruption.'
);
$appSetupUtility = new AppSetupUtility();
$currentVersion = $appSetupUtility->getCurrentProductVersionFromDatabase();
$currentVersion = $currentVersion ?? $input->getOption('currentVersion');
$versions = array_keys(AppSetupUtility::MIGRATIONS_MAP);
array_pop($versions);
if ($input->isInteractive() && $currentVersion == null) {
$question = new ChoiceQuestion('Current OrangeHRM Version ' . self::REQUIRED_TAG, $versions);
$question->setValidator(function ($value) use ($versions) {
if (!in_array($value, $versions, true)) {
throw new InvalidArgumentException('Invalid version.');
}
return $value;
});
$currentVersion = $this->getIO()->askQuestion($question);
}
if (!in_array($currentVersion, $versions, true)) {
throw new InvalidArgumentException(
'Invalid `currentVersion` option. Accepted values are: '
. implode(', ', $versions)
);
}
$this->getIO()->note("Current version: $currentVersion");
$this->getIO()->title('Upgrading OrangeHRM');
$fromAndToVersions = "from <comment>OrangeHRM $currentVersion</comment> to <comment>OrangeHRM " . Config::PRODUCT_VERSION . '</comment>';
$continue = $this->getIO()->confirm("Do you want to start the upgrader $fromAndToVersions?", true);
if ($continue !== true) {
$this->getIO()->info('Aborted');
return self::INVALID;
}
if (!$input->isInteractive()) {
$this->getIO()->info(
"Upgrading from OrangeHRM $currentVersion to OrangeHRM " . Config::PRODUCT_VERSION . '.'
);
}
$step1 = $this->startSection($output, self::STEP_1);
$step2 = $this->startSection($output, self::STEP_2);
$step3 = $this->startSection($output, self::STEP_3, "\n");
$this->startStep($step1, self::STEP_1);
$request = new Request();
$request->setMethod(Request::METHOD_POST);
(new UpgraderDataRegistrationAPI())->handle($request);
try {
$evaluator = new DatabaseUserPermissionEvaluator(Connection::getConnection());
$evaluator->evalPrivilegeDatabaseUserPermission();
} catch (Throwable $e) {
Logger::getLogger()->error($e->getMessage());
Logger::getLogger()->error($e->getTraceAsString());
$this->getIO()->error(
'`Checking database permissions` failed. For more details check the error log in /src/log/installer.log file'
);
return self::FAILURE;
}
$this->completeStep($step1, self::STEP_1);
$this->startStep($step2, self::STEP_2);
$migrationVersions = $appSetupUtility->getVersionsInRange($currentVersion, null, false);
if (empty($migrationVersions)) {
$this->getIO()->error('Invalid current version');
return self::FAILURE;
}
StateContainer::getInstance()->clearMigrationCompleted();
foreach ($migrationVersions as $version) {
Logger::getLogger()->info(json_encode(['version' => $version]));
$appSetupUtility->runMigrationFor($version);
}
$this->completeStep($step2, self::STEP_2);
$this->startStep($step3, self::STEP_3, "\n");
$request = new Request();
$request->setMethod(Request::METHOD_POST);
(new ConfigFileAPI())->handle($request);
$this->completeStep($step3, self::STEP_3, "\n");
return self::SUCCESS;
}
/**
* @param string $dbHost
* @param string $dbPort
* @param string $dbName
* @param string $dbUser
*/
private function drawDatabaseInfoTable(string $dbHost, string $dbPort, string $dbName, string $dbUser): void
{
$rows = [
['Database Host Name', $dbHost],
['Database Host Port', $dbPort],
['Database Name', $dbName],
['Database Username', $dbUser],
];
$this->getIO()->table([], $rows);
}
/**
* @param InputInterface $input
* @param string $name
* @return bool
*/
private function hasOption(InputInterface $input, string $name): bool
{
$value = $input->getOption($name);
if ($value == null) {
return false;
}
return strlen(trim($value)) > 0;
}
/**
* @param InputInterface $input
* @param string $name
*/
private function throwIfParamEmpty(InputInterface $input, string $name): void
{
$value = $input->getOption($name);
if ($value == null || strlen(trim($value)) == 0) {
throw new InvalidArgumentException("Missing required `$name` option.");
}
}
}

Some files were not shown because too many files have changed in this diff Show More