Merge remote-tracking branch 'upstream/develop' into eol_date_range_for_reports

This commit is contained in:
akemidx 2024-08-19 19:33:44 -04:00
commit 8e1111c681
7688 changed files with 273076 additions and 338279 deletions

View file

@ -1,11 +1,14 @@
{ {
"projectName": "snipe-it", "projectName": "snipe-it",
"projectOwner": "snipe", "projectOwner": "snipe",
"repoType": "github",
"repoHost": "https://github.com",
"files": [ "files": [
"README.md" "CONTRIBUTORS.md"
], ],
"imageSize": 110, "imageSize": 110,
"commit": true, "commit": true,
"commitConvention": "angular",
"contributors": [ "contributors": [
{ {
"login": "snipe", "login": "snipe",
@ -2988,6 +2991,205 @@
"contributions": [ "contributions": [
"code" "code"
] ]
},
{
"login": "bilias",
"name": "bilias",
"avatar_url": "https://avatars.githubusercontent.com/u/47315739?v=4",
"profile": "https://github.com/bilias",
"contributions": [
"code"
]
},
{
"login": "coach1988",
"name": "coach1988",
"avatar_url": "https://avatars.githubusercontent.com/u/2565989?v=4",
"profile": "https://github.com/coach1988",
"contributions": [
"code"
]
},
{
"login": "mauro-miatello",
"name": "MrM",
"avatar_url": "https://avatars.githubusercontent.com/u/11910225?v=4",
"profile": "https://github.com/mauro-miatello",
"contributions": [
"code"
]
},
{
"login": "koiakoia",
"name": "koiakoia",
"avatar_url": "https://avatars.githubusercontent.com/u/60405354?v=4",
"profile": "https://github.com/koiakoia",
"contributions": [
"code"
]
},
{
"login": "mustafa-online",
"name": "Mustafa Online",
"avatar_url": "https://avatars.githubusercontent.com/u/5323832?v=4",
"profile": "https://github.com/mustafa-online",
"contributions": [
"code"
]
},
{
"login": "franceslui",
"name": "franceslui",
"avatar_url": "https://avatars.githubusercontent.com/u/104601439?v=4",
"profile": "https://github.com/franceslui",
"contributions": [
"code"
]
},
{
"login": "Q4kK",
"name": "Q4kK",
"avatar_url": "https://avatars.githubusercontent.com/u/125313163?v=4",
"profile": "https://github.com/Q4kK",
"contributions": [
"code"
]
},
{
"login": "squintfox",
"name": "squintfox",
"avatar_url": "https://avatars.githubusercontent.com/u/55590532?v=4",
"profile": "https://github.com/squintfox",
"contributions": [
"code"
]
},
{
"login": "jeffclay",
"name": "Jeff Clay",
"avatar_url": "https://avatars.githubusercontent.com/u/1380084?v=4",
"profile": "https://github.com/jeffclay",
"contributions": [
"code"
]
},
{
"login": "PP-JN-RL",
"name": "Phil J R",
"avatar_url": "https://avatars.githubusercontent.com/u/52716446?v=4",
"profile": "https://github.com/PP-JN-RL",
"contributions": [
"code"
]
},
{
"login": "chandanchowdhury",
"name": "i_virus",
"avatar_url": "https://avatars.githubusercontent.com/u/1496725?v=4",
"profile": "https://www.corelight.com/",
"contributions": [
"code"
]
},
{
"login": "gitgrimbo",
"name": "Paul Grime",
"avatar_url": "https://avatars.githubusercontent.com/u/1020541?v=4",
"profile": "https://github.com/gitgrimbo",
"contributions": [
"code"
]
},
{
"login": "LeePorte",
"name": "Lee Porte",
"avatar_url": "https://avatars.githubusercontent.com/u/922815?v=4",
"profile": "https://leeporte.co.uk",
"contributions": [
"code"
]
},
{
"login": "bryanlopezinc",
"name": "BRYAN ",
"avatar_url": "https://avatars.githubusercontent.com/u/23613427?v=4",
"profile": "https://github.com/bryanlopezinc",
"contributions": [
"code",
"test"
]
},
{
"login": "U-H-T",
"name": "U-H-T",
"avatar_url": "https://avatars.githubusercontent.com/u/64061710?v=4",
"profile": "https://github.com/U-H-T",
"contributions": [
"code"
]
},
{
"login": "Tyree",
"name": "Matt Tyree",
"avatar_url": "https://avatars.githubusercontent.com/u/5395363?v=4",
"profile": "https://github.com/Tyree",
"contributions": [
"doc"
]
},
{
"login": "FlorentDotMe",
"name": "Florent Bervas",
"avatar_url": "https://avatars.githubusercontent.com/u/292081?v=4",
"profile": "http://spoontux.net",
"contributions": [
"code"
]
},
{
"login": "dbakan",
"name": "Daniel Albertsen",
"avatar_url": "https://avatars.githubusercontent.com/u/4498077?v=4",
"profile": "https://ditscheri.com",
"contributions": [
"code"
]
},
{
"login": "r-xyz",
"name": "r-xyz",
"avatar_url": "https://avatars.githubusercontent.com/u/100710244?v=4",
"profile": "https://github.com/r-xyz",
"contributions": [
"code"
]
},
{
"login": "DrekiDegga",
"name": "Steven Mainor",
"avatar_url": "https://avatars.githubusercontent.com/u/47491036?v=4",
"profile": "https://github.com/DrekiDegga",
"contributions": [
"code"
]
},
{
"login": "arne-kroeger",
"name": "arne-kroeger",
"avatar_url": "https://avatars.githubusercontent.com/u/65785975?v=4",
"profile": "https://github.com/arne-kroeger",
"contributions": [
"code"
]
},
{
"login": "Glukose1",
"name": "Glukose1",
"avatar_url": "https://avatars.githubusercontent.com/u/167117705?v=4",
"profile": "https://github.com/Glukose1",
"contributions": [
"code"
]
} }
] ]
} }

166
.env.dev.docker Normal file
View file

@ -0,0 +1,166 @@
# --------------------------------------------
# REQUIRED: DB SETUP
# --------------------------------------------
MYSQL_DATABASE=snipeit
MYSQL_USER=snipeit
MYSQL_PASSWORD=changeme1234
MYSQL_ROOT_PASSWORD=changeme1234
# --------------------------------------------
# REQUIRED: BASIC APP SETTINGS
# --------------------------------------------
APP_ENV=develop
APP_DEBUG=false
# please regenerate the APP_KEY value by calling `docker-compose run --rm snipeit bash` and then `php artisan key:generate --show` and then copy paste the value here
APP_KEY=base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ=
APP_URL=http://localhost:8000
APP_TIMEZONE='UTC'
APP_LOCALE=en
MAX_RESULTS=500
# --------------------------------------------
# REQUIRED: UPLOADED FILE STORAGE SETTINGS
# --------------------------------------------
PRIVATE_FILESYSTEM_DISK=local
PUBLIC_FILESYSTEM_DISK=local_public
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
DB_CONNECTION=mysql
DB_HOST=mariadb
DB_DATABASE=snipeit
DB_USERNAME=snipeit
DB_PASSWORD=changeme1234
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin'
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
# --------------------------------------------
# OPTIONAL: SSL DATABASE SETTINGS
# --------------------------------------------
DB_SSL=false
DB_SSL_IS_PAAS=false
DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null
DB_SSL_VERIFY_SERVER=null
# --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
# --------------------------------------------
MAIL_DRIVER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME='Snipe-IT'
MAIL_REPLYTO_ADDR=you@example.com
MAIL_REPLYTO_NAME='Snipe-IT'
MAIL_AUTO_EMBED_METHOD='attachment'
# --------------------------------------------
# REQUIRED: IMAGE LIBRARY
# This should be gd or imagick
# --------------------------------------------
IMAGE_LIB=gd
# --------------------------------------------
# OPTIONAL: BACKUP SETTINGS
# --------------------------------------------
MAIL_BACKUP_NOTIFICATION_DRIVER=null
MAIL_BACKUP_NOTIFICATION_ADDRESS=null
BACKUP_ENV=true
# --------------------------------------------
# OPTIONAL: SESSION SETTINGS
# --------------------------------------------
SESSION_LIFETIME=12000
EXPIRE_ON_CLOSE=false
ENCRYPT=false
COOKIE_NAME=snipeit_session
COOKIE_DOMAIN=null
SECURE_COOKIES=false
API_TOKEN_EXPIRATION_YEARS=40
# --------------------------------------------
# OPTIONAL: SECURITY HEADER SETTINGS
# --------------------------------------------
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
ALLOW_IFRAMING=false
REFERRER_POLICY=same-origin
ENABLE_CSP=false
CORS_ALLOWED_ORIGINS=null
ENABLE_HSTS=false
# --------------------------------------------
# OPTIONAL: CACHE SETTINGS
# --------------------------------------------
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
CACHE_PREFIX=snipeit
# --------------------------------------------
# OPTIONAL: REDIS SETTINGS
# --------------------------------------------
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
# --------------------------------------------
# OPTIONAL: MEMCACHED SETTINGS
# --------------------------------------------
MEMCACHED_HOST=null
MEMCACHED_PORT=null
# --------------------------------------------
# OPTIONAL: PUBLIC S3 Settings
# --------------------------------------------
PUBLIC_AWS_SECRET_ACCESS_KEY=null
PUBLIC_AWS_ACCESS_KEY_ID=null
PUBLIC_AWS_DEFAULT_REGION=null
PUBLIC_AWS_BUCKET=null
PUBLIC_AWS_URL=null
PUBLIC_AWS_BUCKET_ROOT=null
# --------------------------------------------
# OPTIONAL: PRIVATE S3 Settings
# --------------------------------------------
PRIVATE_AWS_ACCESS_KEY_ID=null
PRIVATE_AWS_SECRET_ACCESS_KEY=null
PRIVATE_AWS_DEFAULT_REGION=null
PRIVATE_AWS_BUCKET=null
PRIVATE_AWS_URL=null
PRIVATE_AWS_BUCKET_ROOT=null
# --------------------------------------------
# OPTIONAL: AWS Settings
# --------------------------------------------
AWS_ACCESS_KEY_ID=null
AWS_SECRET_ACCESS_KEY=null
AWS_DEFAULT_REGION=null
# --------------------------------------------
# OPTIONAL: LOGIN THROTTLING
# --------------------------------------------
LOGIN_MAX_ATTEMPTS=5
LOGIN_LOCKOUT_DURATION=60
RESET_PASSWORD_LINK_EXPIRES=900
# --------------------------------------------
# OPTIONAL: MISC
# --------------------------------------------
LOG_CHANNEL=stderr
LOG_MAX_DAYS=10
APP_LOCKED=false
APP_CIPHER=AES-256-CBC
APP_FORCE_TLS=false
GOOGLE_MAPS_API=
LDAP_MEM_LIM=500M
LDAP_TIME_LIM=600

View file

@ -1,20 +1,20 @@
# -------------------------------------------- # --------------------------------------------
# REQUIRED: DB SETUP # REQUIRED: DOCKER SPECIFIC SETTINGS
# -------------------------------------------- # --------------------------------------------
MYSQL_DATABASE=snipeit APP_VERSION=v6.4.1
MYSQL_USER=snipeit APP_PORT=8000
MYSQL_PASSWORD=changeme1234
MYSQL_ROOT_PASSWORD=changeme1234
# -------------------------------------------- # --------------------------------------------
# REQUIRED: BASIC APP SETTINGS # REQUIRED: BASIC APP SETTINGS
# -------------------------------------------- # --------------------------------------------
APP_ENV=develop APP_ENV=production
APP_DEBUG=false APP_DEBUG=false
# please regenerate the APP_KEY value by calling `docker-compose run --rm snipeit bash` and then `php artisan key:generate --show` and then copy paste the value here # Please regenerate the APP_KEY value by calling `docker compose run --rm snipeit php artisan key:generate --show`. Copy paste the value here
APP_KEY=base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ= APP_KEY=base64:3ilviXqB9u6DX1NRcyWGJ+sjySF+H18CPDGb3+IVwMQ=
APP_URL=http://localhost:8000 APP_URL=http://localhost:8000
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - TZ identifier
APP_TIMEZONE='UTC' APP_TIMEZONE='UTC'
APP_LOCALE=en APP_LOCALE=en-US
MAX_RESULTS=500 MAX_RESULTS=500
# -------------------------------------------- # --------------------------------------------
@ -27,10 +27,12 @@ PUBLIC_FILESYSTEM_DISK=local_public
# REQUIRED: DATABASE SETTINGS # REQUIRED: DATABASE SETTINGS
# -------------------------------------------- # --------------------------------------------
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=mariadb DB_HOST=db
DB_PORT='3306'
DB_DATABASE=snipeit DB_DATABASE=snipeit
DB_USERNAME=snipeit DB_USERNAME=snipeit
DB_PASSWORD=changeme1234 DB_PASSWORD=changeme1234
MYSQL_ROOT_PASSWORD=changeme1234
DB_PREFIX=null DB_PREFIX=null
DB_DUMP_PATH='/usr/bin' DB_DUMP_PATH='/usr/bin'
DB_CHARSET=utf8mb4 DB_CHARSET=utf8mb4
@ -45,29 +47,35 @@ DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null DB_SSL_CIPHER=null
DB_SSL_VERIFY_SERVER=null
# -------------------------------------------- # --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS # REQUIRED: OUTGOING MAIL SERVER SETTINGS
# -------------------------------------------- # --------------------------------------------
MAIL_DRIVER=smtp MAIL_MAILER=smtp
MAIL_HOST=mailhog MAIL_HOST=mailhog
MAIL_PORT=1025 MAIL_PORT=1025
MAIL_USERNAME=null MAIL_USERNAME=null
MAIL_PASSWORD=null MAIL_PASSWORD=null
MAIL_ENCRYPTION=null MAIL_TLS_VERIFY_PEER=true
MAIL_FROM_ADDR=you@example.com MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME='Snipe-IT' MAIL_FROM_NAME='Snipe-IT'
MAIL_REPLYTO_ADDR=you@example.com MAIL_REPLYTO_ADDR=you@example.com
MAIL_REPLYTO_NAME='Snipe-IT' MAIL_REPLYTO_NAME='Snipe-IT'
MAIL_AUTO_EMBED_METHOD='attachment' MAIL_AUTO_EMBED_METHOD='attachment'
# --------------------------------------------
# REQUIRED: DATA PROTECTION
# --------------------------------------------
ALLOW_BACKUP_DELETE=false
ALLOW_DATA_PURGE=false
# -------------------------------------------- # --------------------------------------------
# REQUIRED: IMAGE LIBRARY # REQUIRED: IMAGE LIBRARY
# This should be gd or imagick # This should be gd or imagick
# -------------------------------------------- # --------------------------------------------
IMAGE_LIB=gd IMAGE_LIB=gd
# -------------------------------------------- # --------------------------------------------
# OPTIONAL: BACKUP SETTINGS # OPTIONAL: BACKUP SETTINGS
# -------------------------------------------- # --------------------------------------------
@ -75,7 +83,6 @@ MAIL_BACKUP_NOTIFICATION_DRIVER=null
MAIL_BACKUP_NOTIFICATION_ADDRESS=null MAIL_BACKUP_NOTIFICATION_ADDRESS=null
BACKUP_ENV=true BACKUP_ENV=true
# -------------------------------------------- # --------------------------------------------
# OPTIONAL: SESSION SETTINGS # OPTIONAL: SESSION SETTINGS
# -------------------------------------------- # --------------------------------------------
@ -90,7 +97,7 @@ API_TOKEN_EXPIRATION_YEARS=40
# -------------------------------------------- # --------------------------------------------
# OPTIONAL: SECURITY HEADER SETTINGS # OPTIONAL: SECURITY HEADER SETTINGS
# -------------------------------------------- # --------------------------------------------
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1 APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1,172.0.0.0/8
ALLOW_IFRAMING=false ALLOW_IFRAMING=false
REFERRER_POLICY=same-origin REFERRER_POLICY=same-origin
ENABLE_CSP=false ENABLE_CSP=false
@ -108,7 +115,7 @@ CACHE_PREFIX=snipeit
# -------------------------------------------- # --------------------------------------------
# OPTIONAL: REDIS SETTINGS # OPTIONAL: REDIS SETTINGS
# -------------------------------------------- # --------------------------------------------
REDIS_HOST=redis REDIS_HOST=null
REDIS_PASSWORD=null REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379

View file

@ -6,7 +6,7 @@ APP_DEBUG=false
APP_KEY=base64:hTUIUh9CP6dQx+6EjSlfWTgbaMaaRvlpEwk45vp+xmk= APP_KEY=base64:hTUIUh9CP6dQx+6EjSlfWTgbaMaaRvlpEwk45vp+xmk=
APP_URL=http://127.0.0.1:8000 APP_URL=http://127.0.0.1:8000
APP_TIMEZONE='US/Eastern' APP_TIMEZONE='US/Eastern'
APP_LOCALE=en APP_LOCALE=en-US
APP_LOCKED=false APP_LOCKED=false
MAX_RESULTS=200 MAX_RESULTS=200
@ -36,11 +36,12 @@ DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null DB_SSL_CIPHER=null
DB_SSL_VERIFY_SERVER=null
# -------------------------------------------- # --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS # REQUIRED: OUTGOING MAIL SERVER SETTINGS
# -------------------------------------------- # --------------------------------------------
MAIL_DRIVER="log" MAIL_MAILER="log"
# -------------------------------------------- # --------------------------------------------

View file

@ -6,7 +6,7 @@ APP_DEBUG=false
APP_KEY=ChangeMe APP_KEY=ChangeMe
APP_URL=null APP_URL=null
APP_TIMEZONE='UTC' APP_TIMEZONE='UTC'
APP_LOCALE=en APP_LOCALE='en-US'
MAX_RESULTS=500 MAX_RESULTS=500
# -------------------------------------------- # --------------------------------------------
@ -42,21 +42,26 @@ DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null DB_SSL_CIPHER=null
DB_SSL_VERIFY_SERVER=null
# -------------------------------------------- # --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS # REQUIRED: OUTGOING MAIL SERVER SETTINGS
# -------------------------------------------- # --------------------------------------------
MAIL_DRIVER=smtp MAIL_MAILER=smtp
MAIL_HOST=email-smtp.us-west-2.amazonaws.com MAIL_HOST=email-smtp.us-west-2.amazonaws.com
MAIL_PORT=587 MAIL_PORT=587
MAIL_USERNAME=YOURUSERNAME MAIL_USERNAME=YOURUSERNAME
MAIL_PASSWORD=YOURPASSWORD MAIL_PASSWORD=YOURPASSWORD
MAIL_ENCRYPTION=null
MAIL_FROM_ADDR=you@example.com MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME='Snipe-IT' MAIL_FROM_NAME='Snipe-IT'
MAIL_REPLYTO_ADDR=you@example.com MAIL_REPLYTO_ADDR=you@example.com
MAIL_REPLYTO_NAME='Snipe-IT' MAIL_REPLYTO_NAME='Snipe-IT'
MAIL_AUTO_EMBED_METHOD='attachment' MAIL_AUTO_EMBED_METHOD='attachment'
MAIL_TLS_VERIFY_PEER=true
# MAIL_ENCRYPTION is no longer supported. SymfonyMailer will use tls if it's
# advertised, and won't if it's not. If you want to use your mail server's IP but it's failing
# because of certificate errors, set MAIL_TLS_VERIFY_PEER-true
# -------------------------------------------- # --------------------------------------------
# REQUIRED: IMAGE LIBRARY # REQUIRED: IMAGE LIBRARY
@ -82,10 +87,12 @@ SESSION_LIFETIME=12000
EXPIRE_ON_CLOSE=false EXPIRE_ON_CLOSE=false
ENCRYPT=false ENCRYPT=false
COOKIE_NAME=snipeit_session COOKIE_NAME=snipeit_session
PASSPORT_COOKIE_NAME='snipeit_passport_token'
COOKIE_DOMAIN=null COOKIE_DOMAIN=null
SECURE_COOKIES=false SECURE_COOKIES=false
API_TOKEN_EXPIRATION_YEARS=15 API_TOKEN_EXPIRATION_YEARS=15
BS_TABLE_STORAGE=cookieStorage BS_TABLE_STORAGE=cookieStorage
BS_TABLE_DEEPLINK=true
# -------------------------------------------- # --------------------------------------------
# OPTIONAL: SECURITY HEADER SETTINGS # OPTIONAL: SECURITY HEADER SETTINGS
@ -94,6 +101,7 @@ APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
ALLOW_IFRAMING=false ALLOW_IFRAMING=false
REFERRER_POLICY=same-origin REFERRER_POLICY=same-origin
ENABLE_CSP=false ENABLE_CSP=false
ADDITIONAL_CSP_URLS=null
CORS_ALLOWED_ORIGINS=null CORS_ALLOWED_ORIGINS=null
ENABLE_HSTS=false ENABLE_HSTS=false
@ -176,6 +184,7 @@ REPORT_TIME_LIMIT=12000
REQUIRE_SAML=false REQUIRE_SAML=false
API_THROTTLE_PER_MINUTE=120 API_THROTTLE_PER_MINUTE=120
CSV_ESCAPE_FORMULAS=true CSV_ESCAPE_FORMULAS=true
LIVEWIRE_URL_PREFIX=null
# -------------------------------------------- # --------------------------------------------
# OPTIONAL: HASHING # OPTIONAL: HASHING

View file

@ -6,7 +6,7 @@ APP_DEBUG=false
APP_KEY='base64:glJpcM7BYwWiBggp3SQ/+NlRkqsBQMaGEOjemXqJzOU=' APP_KEY='base64:glJpcM7BYwWiBggp3SQ/+NlRkqsBQMaGEOjemXqJzOU='
APP_URL='http://localhost:8000' APP_URL='http://localhost:8000'
APP_TIMEZONE='US/Pacific' APP_TIMEZONE='US/Pacific'
APP_LOCALE=en APP_LOCALE='en-US'
FILESYSTEM_DISK=local FILESYSTEM_DISK=local
# -------------------------------------------- # --------------------------------------------
@ -22,7 +22,7 @@ DB_PASSWORD=null
# -------------------------------------------- # --------------------------------------------
# REQUIRED: OUTGOING MAIL SERVER SETTINGS # REQUIRED: OUTGOING MAIL SERVER SETTINGS
# -------------------------------------------- # --------------------------------------------
MAIL_DRIVER=log MAIL_MAILER=log
# -------------------------------------------- # --------------------------------------------

View file

@ -6,7 +6,7 @@ APP_DEBUG=true
APP_KEY=base64:glJpcM7BYwWiBggp3SQ/+NlRkqsBQMaGEOjemXqJzOU= APP_KEY=base64:glJpcM7BYwWiBggp3SQ/+NlRkqsBQMaGEOjemXqJzOU=
APP_URL=http://localhost:8000 APP_URL=http://localhost:8000
APP_TIMEZONE='UTC' APP_TIMEZONE='UTC'
APP_LOCALE=en APP_LOCALE='en-US'
# -------------------------------------------- # --------------------------------------------
# REQUIRED: DATABASE SETTINGS # REQUIRED: DATABASE SETTINGS

View file

@ -18,6 +18,6 @@ APP_KEY=base64:tu9NRh/a6+dCXBDGvg0Gv/0TcABnFsbT4AKxrr8mwQo=
LOGIN_MAX_ATTEMPTS=1000000 LOGIN_MAX_ATTEMPTS=1000000
LOGIN_LOCKOUT_DURATION=100000000 LOGIN_LOCKOUT_DURATION=100000000
MAIL_DRIVER=log MAIL_MAILER=log
MAIL_FROM_ADDR=you@example.com MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME=Snipe-IT MAIL_FROM_NAME=Snipe-IT

View file

@ -15,6 +15,6 @@ APP_KEY=base64:tu9NRh/a6+dCXBDGvg0Gv/0TcABnFsbT4AKxrr8mwQo=
LOGIN_MAX_ATTEMPTS=1000000 LOGIN_MAX_ATTEMPTS=1000000
LOGIN_LOCKOUT_DURATION=100000000 LOGIN_LOCKOUT_DURATION=100000000
MAIL_DRIVER=log MAIL_MAILER=log
MAIL_FROM_ADDR=you@example.com MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME=Snipe-IT MAIL_FROM_NAME=Snipe-IT

View file

@ -30,10 +30,10 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@v3
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v2 uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v3

View file

@ -36,7 +36,7 @@ jobs:
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI - name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@v4.3.0 uses: codacy/codacy-analysis-cli-action@v4.4.5
with: with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations # You can also omit the token and run the tools that support default configurations
@ -52,6 +52,6 @@ jobs:
# Upload the SARIF file generated in the previous step # Upload the SARIF file generated in the previous step
- name: Upload SARIF results file - name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2 uses: github/codeql-action/upload-sarif@v3
with: with:
sarif_file: results.sarif sarif_file: results.sarif

View file

@ -12,7 +12,7 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Crowdin push - name: Crowdin push
uses: crowdin/github-action@v1 uses: crowdin/github-action@v2
with: with:
upload_sources: true upload_sources: true
upload_translations: false upload_translations: false

View file

@ -73,7 +73,7 @@ jobs:
# https://github.com/docker/build-push-action # https://github.com/docker/build-push-action
- name: Build and push 'snipe-it' image - name: Build and push 'snipe-it' image
id: docker_build id: docker_build
uses: docker/build-push-action@v5 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./Dockerfile.alpine file: ./Dockerfile.alpine

View file

@ -73,7 +73,7 @@ jobs:
# https://github.com/docker/build-push-action # https://github.com/docker/build-push-action
- name: Build and push 'snipe-it' image - name: Build and push 'snipe-it' image
id: docker_build id: docker_build
uses: docker/build-push-action@v5 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./Dockerfile file: ./Dockerfile

View file

@ -0,0 +1,22 @@
name: Update Docker Hub Description
on:
push:
branches:
- master
- develop
paths:
- README.md
- .github/workflows/dockerhub-description.yml
jobs:
dockerHubDescription:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Docker Hub Description
uses: grokability/dockerhub-description@7ea9d275c7cdbe2b676a093a0308c50665e3b8b4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
repository: snipe/snipe-it
readme-filepath: ./README.md

79
.github/workflows/tests-mysql.yml vendored Normal file
View file

@ -0,0 +1,79 @@
name: Tests in MySQL
on:
push:
branches:
- master
- develop
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: snipeit
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
name: PHP ${{ matrix.php-version }}
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
- uses: actions/checkout@v4
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Copy .env
run: |
cp -v .env.testing.example .env
cp -v .env.testing.example .env.testing
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Setup Laravel
env:
DB_CONNECTION: mysql
DB_DATABASE: snipeit
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_USERNAME: root
run: |
php artisan key:generate
php artisan migrate --force
php artisan passport:install
chmod -R 777 storage bootstrap/cache
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: mysql
DB_DATABASE: snipeit
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_USERNAME: root
run: php artisan test --parallel

77
.github/workflows/tests-postgres.yml vendored Normal file
View file

@ -0,0 +1,77 @@
name: Tests in Postgres
on: workflow_dispatch
jobs:
tests:
runs-on: ubuntu-latest
services:
postgresql:
image: postgres
env:
POSTGRES_DB: snipeit
POSTGRES_USER: snipeit
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
name: PHP ${{ matrix.php-version }}
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
- uses: actions/checkout@v4
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Copy .env
run: |
cp -v .env.testing.example .env
cp -v .env.testing.example .env.testing
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Setup Laravel
env:
DB_CONNECTION: pgsql
DB_DATABASE: snipeit
DB_PORT: ${{ job.services.postgresql.ports[5432] }}
DB_USERNAME: snipeit
DB_PASSWORD: password
run: |
php artisan key:generate
php artisan migrate --force
php artisan passport:install
chmod -R 777 storage bootstrap/cache
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: pgsql
DB_DATABASE: snipeit
DB_PORT: ${{ job.services.postgresql.ports[5432] }}
DB_USERNAME: snipeit
DB_PASSWORD: password
run: php artisan test --parallel

61
.github/workflows/tests-sqlite.yml vendored Normal file
View file

@ -0,0 +1,61 @@
name: Tests in SQLite
on:
push:
branches:
- master
- develop
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- "8.1.1"
name: PHP ${{ matrix.php-version }}
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
- uses: actions/checkout@v4
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Copy .env
run: |
cp -v .env.testing.example .env
cp -v .env.testing.example .env.testing
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Setup Passport
run: php artisan passport:keys
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite_testing
run: php artisan test --parallel

View file

@ -1,73 +0,0 @@
name: Tests
on:
push:
branches:
- master
- develop
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: snipeit
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1.1"
name: PHP ${{ matrix.php-version }}
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
- uses: actions/checkout@v4
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Copy .env
run: |
cp -v .env.testing.example .env
cp -v .env.testing.example .env.testing
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: mysql
DB_DATABASE: snipeit
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_USERNAME: root
run: php artisan test --parallel

3
.gitignore vendored
View file

@ -67,3 +67,6 @@ _ide_helper_models.php
/.phplint-cache /.phplint-cache
storage/ldap_client_tls.cert storage/ldap_client_tls.cert
storage/ldap_client_tls.key storage/ldap_client_tls.key
/storage/framework/testing
/.phpunit.cache

2
.nvmrc
View file

@ -1 +1 @@
v12.22.1 v18.16.0

View file

@ -0,0 +1,10 @@
{
"DOC1": "This file is meant to be pulled from the current HEAD of the desired branch, NOT referenced locally",
"DOC2": "In other words, what you see locally are the requirements for your _current_ install",
"DOC3": "Please don't rely on these versions for planning upgrades unless you've fetched the most recent version",
"DOC4": "You should really just ignore it and run upgrade.php. Really",
"php_min_version": "8.1.0",
"php_max_major_minor": "8.3",
"php_max_wontwork": "8.4.0",
"current_snipeit_version": "7.0"
}

58
CONTRIBUTORS.md Normal file
View file

@ -0,0 +1,58 @@
Thanks goes to all of these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)) who have helped Snipe-IT get this far:
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars3.githubusercontent.com/u/197404?v=3" width="110px;"/><br /><sub>snipe</sub>](http://www.snipe.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=snipe "Code") [🚇](#infra-snipe "Infrastructure (Hosting, Build-Tools, etc)") [📖](https://github.com/snipe/snipe-it/commits?author=snipe "Documentation") [⚠️](https://github.com/snipe/snipe-it/commits?author=snipe "Tests") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3Asnipe "Bug reports") [🎨](#design-snipe "Design") [👀](#review-snipe "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/36335?v=3" width="110px;"/><br /><sub>Brady Wetherington</sub>](http://www.uberbrady.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=uberbrady "Code") [📖](https://github.com/snipe/snipe-it/commits?author=uberbrady "Documentation") [🚇](#infra-uberbrady "Infrastructure (Hosting, Build-Tools, etc)") [👀](#review-uberbrady "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3803132?v=3" width="110px;"/><br /><sub>Daniel Meltzer</sub>](https://github.com/dmeltzer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dmeltzer "Code") [⚠️](https://github.com/snipe/snipe-it/commits?author=dmeltzer "Tests") [📖](https://github.com/snipe/snipe-it/commits?author=dmeltzer "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1609106?v=3" width="110px;"/><br /><sub>Michael T</sub>](http://www.tuckertechonline.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mtucker6784 "Code") | [<img src="https://avatars2.githubusercontent.com/u/3274937?v=3" width="110px;"/><br /><sub>madd15</sub>](https://github.com/madd15)<br />[📖](https://github.com/snipe/snipe-it/commits?author=madd15 "Documentation") [💬](#question-madd15 "Answering Questions") | [<img src="https://avatars2.githubusercontent.com/u/894126?v=3" width="110px;"/><br /><sub>Vincent Sposato</sub>](https://github.com/vsposato)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vsposato "Code") | [<img src="https://avatars0.githubusercontent.com/u/1639757?v=3" width="110px;"/><br /><sub>Andrea Bergamasco</sub>](https://github.com/vjandrea)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vjandrea "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars0.githubusercontent.com/u/10640152?v=3" width="110px;"/><br /><sub>Karol</sub>](https://github.com/kpawelski)<br />[🌍](#translation-kpawelski "Translation") [💻](https://github.com/snipe/snipe-it/commits?author=kpawelski "Code") | [<img src="https://avatars3.githubusercontent.com/u/600106?v=3" width="110px;"/><br /><sub>morph027</sub>](http://blog.morph027.de/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=morph027 "Code") | [<img src="https://avatars3.githubusercontent.com/u/22935755?v=3" width="110px;"/><br /><sub>fvleminckx</sub>](https://github.com/fvleminckx)<br />[🚇](#infra-fvleminckx "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars2.githubusercontent.com/u/15633547?v=3" width="110px;"/><br /><sub>itsupportcmsukorg</sub>](https://github.com/itsupportcmsukorg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=itsupportcmsukorg "Code") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3Aitsupportcmsukorg "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/12373799?v=3" width="110px;"/><br /><sub>Frank</sub>](https://override.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=base-zero "Code") | [<img src="https://avatars0.githubusercontent.com/u/10137?v=3" width="110px;"/><br /><sub>Deleted user</sub>](https://github.com/ghost)<br />[🌍](#translation-ghost "Translation") [💻](https://github.com/snipe/snipe-it/commits?author=ghost "Code") | [<img src="https://avatars1.githubusercontent.com/u/10802313?v=3" width="110px;"/><br /><sub>tiagom62</sub>](https://github.com/tiagom62)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tiagom62 "Code") [🚇](#infra-tiagom62 "Infrastructure (Hosting, Build-Tools, etc)") |
| [<img src="https://avatars3.githubusercontent.com/u/2389047?v=3" width="110px;"/><br /><sub>Ryan Stafford</sub>](https://github.com/rystaf)<br />[💻](https://github.com/snipe/snipe-it/commits?author=rystaf "Code") | [<img src="https://avatars2.githubusercontent.com/u/10345935?v=3" width="110px;"/><br /><sub>Eammon Hanlon</sub>](https://github.com/ehanlon)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ehanlon "Code") | [<img src="https://avatars0.githubusercontent.com/u/441924?v=3" width="110px;"/><br /><sub>zjean</sub>](https://github.com/zjean)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zjean "Code") | [<img src="https://avatars0.githubusercontent.com/u/12660103?v=3" width="110px;"/><br /><sub>Matthias Frei</sub>](http://www.frei.media)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FREImedia "Code") | [<img src="https://avatars0.githubusercontent.com/u/3767518?v=3" width="110px;"/><br /><sub>opsydev</sub>](https://github.com/opsydev)<br />[💻](https://github.com/snipe/snipe-it/commits?author=opsydev "Code") | [<img src="https://avatars1.githubusercontent.com/u/82290?v=3" width="110px;"/><br /><sub>Daniel Dreier</sub>](http://www.ddreier.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ddreier "Code") | [<img src="https://avatars0.githubusercontent.com/u/23448?v=3" width="110px;"/><br /><sub>Nikolai Prokoschenko</sub>](http://rassie.org)<br />[💻](https://github.com/snipe/snipe-it/commits?author=rassie "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/13452757?v=3" width="110px;"/><br /><sub>Drew</sub>](https://github.com/YetAnotherCodeMonkey)<br />[💻](https://github.com/snipe/snipe-it/commits?author=YetAnotherCodeMonkey "Code") | [<img src="https://avatars0.githubusercontent.com/u/1342320?v=3" width="110px;"/><br /><sub>Walter</sub>](https://github.com/merid14)<br />[💻](https://github.com/snipe/snipe-it/commits?author=merid14 "Code") | [<img src="https://avatars3.githubusercontent.com/u/11254614?v=3" width="110px;"/><br /><sub>Petr Baloun</sub>](https://github.com/balous)<br />[💻](https://github.com/snipe/snipe-it/commits?author=balous "Code") | [<img src="https://avatars0.githubusercontent.com/u/6117660?v=3" width="110px;"/><br /><sub>reidblomquist</sub>](https://github.com/reidblomquist)<br />[📖](https://github.com/snipe/snipe-it/commits?author=reidblomquist "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/539914?v=3" width="110px;"/><br /><sub>Mathieu Kooiman</sub>](https://github.com/mathieuk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mathieuk "Code") | [<img src="https://avatars3.githubusercontent.com/u/6606421?v=3" width="110px;"/><br /><sub>csayre</sub>](https://github.com/csayre)<br />[📖](https://github.com/snipe/snipe-it/commits?author=csayre "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/768488?v=3" width="110px;"/><br /><sub>Adam Dunson</sub>](https://github.com/adamdunson)<br />[💻](https://github.com/snipe/snipe-it/commits?author=adamdunson "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/5547470?v=3" width="110px;"/><br /><sub>Hereward</sub>](https://github.com/thehereward)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thehereward "Code") | [<img src="https://avatars0.githubusercontent.com/u/5802977?v=3" width="110px;"/><br /><sub>swoopdk</sub>](https://github.com/swoopdk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=swoopdk "Code") | [<img src="https://avatars1.githubusercontent.com/u/3470403?v=3" width="110px;"/><br /><sub>Abdullah Alansari</sub>](https://linkedin.com/in/ahimta)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Ahimta "Code") | [<img src="https://avatars0.githubusercontent.com/u/796443?v=3" width="110px;"/><br /><sub>Micael Rodrigues</sub>](https://github.com/MicaelRodrigues)<br />[💻](https://github.com/snipe/snipe-it/commits?author=MicaelRodrigues "Code") | [<img src="https://avatars0.githubusercontent.com/u/614564?v=3" width="110px;"/><br /><sub>Patrick Gallagher</sub>](http://macadmincorner.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=patgmac "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/7165922?v=3" width="110px;"/><br /><sub>Miliamber</sub>](https://github.com/Miliamber)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Miliamber "Code") | [<img src="https://avatars3.githubusercontent.com/u/861766?v=3" width="110px;"/><br /><sub>hawk554</sub>](https://github.com/hawk554)<br />[💻](https://github.com/snipe/snipe-it/commits?author=hawk554 "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/1695622?v=3" width="110px;"/><br /><sub>Justin Kerr</sub>](http://jbirdkerr.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jbirdkerr "Code") | [<img src="https://avatars3.githubusercontent.com/u/11426176?v=3" width="110px;"/><br /><sub>Ira W. Snyder</sub>](http://www.irasnyder.com/devel/)<br />[📖](https://github.com/snipe/snipe-it/commits?author=irasnyd "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/2475759?v=3" width="110px;"/><br /><sub>Aladin Alaily</sub>](https://github.com/aalaily)<br />[💻](https://github.com/snipe/snipe-it/commits?author=aalaily "Code") | [<img src="https://avatars0.githubusercontent.com/u/10247644?v=3" width="110px;"/><br /><sub>Chase Hansen</sub>](https://github.com/kobie-chasehansen)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kobie-chasehansen "Code") [💬](#question-kobie-chasehansen "Answering Questions") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3Akobie-chasehansen "Bug reports") | [<img src="https://avatars2.githubusercontent.com/u/13545400?v=3" width="110px;"/><br /><sub>IDM Helpdesk</sub>](https://github.com/IDM-Helpdesk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=IDM-Helpdesk "Code") | [<img src="https://avatars2.githubusercontent.com/u/614439?v=3" width="110px;"/><br /><sub>Kai</sub>](http://balticer.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=balticer "Code") | [<img src="https://avatars1.githubusercontent.com/u/8762511?v=3" width="110px;"/><br /><sub>Michael Daniels</sub>](http://www.michaeldaniels.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mdaniels5757 "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/1532660?v=3" width="110px;"/><br /><sub>Tom Castleman</sub>](http://tomcastleman.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tomcastleman "Code") | [<img src="https://avatars3.githubusercontent.com/u/10723243?v=3" width="110px;"/><br /><sub>Daniel Nemanic</sub>](https://github.com/DanielNemanic)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DanielNemanic "Code") | [<img src="https://avatars0.githubusercontent.com/u/150648?v=3" width="110px;"/><br /><sub>SouthWolf</sub>](https://github.com/southwolf)<br />[💻](https://github.com/snipe/snipe-it/commits?author=southwolf "Code") | [<img src="https://avatars2.githubusercontent.com/u/131616?v=3" width="110px;"/><br /><sub>Ivar Nesje</sub>](https://github.com/ivarne)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ivarne "Code") | [<img src="https://avatars1.githubusercontent.com/u/62333?v=3" width="110px;"/><br /><sub>Jérémy Benoist</sub>](http://www.j0k3r.net)<br />[📖](https://github.com/snipe/snipe-it/commits?author=j0k3r "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/724344?v=3" width="110px;"/><br /><sub>Chris Leathley</sub>](https://github.com/cleathley)<br />[🚇](#infra-cleathley "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars0.githubusercontent.com/u/972498?v=3" width="110px;"/><br /><sub>splaer</sub>](https://github.com/splaer)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Asplaer "Bug reports") [💻](https://github.com/snipe/snipe-it/commits?author=splaer "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/967362?v=3" width="110px;"/><br /><sub>Joe Ferguson</sub>](http://www.joeferguson.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=svpernova09 "Code") | [<img src="https://avatars3.githubusercontent.com/u/6108682?v=3" width="110px;"/><br /><sub>diwanicki</sub>](https://github.com/diwanicki)<br />[💻](https://github.com/snipe/snipe-it/commits?author=diwanicki "Code") [📖](https://github.com/snipe/snipe-it/commits?author=diwanicki "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/2527115?v=3" width="110px;"/><br /><sub>Lee Thoong Ching</sub>](https://github.com/pakkua80)<br />[📖](https://github.com/snipe/snipe-it/commits?author=pakkua80 "Documentation") [💻](https://github.com/snipe/snipe-it/commits?author=pakkua80 "Code") | [<img src="https://avatars1.githubusercontent.com/u/461491?v=3" width="110px;"/><br /><sub>Marek Šuppa</sub>](http://shu.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mrshu "Code") | [<img src="https://avatars1.githubusercontent.com/u/8693762?v=3" width="110px;"/><br /><sub>Juan J. Martinez</sub>](https://github.com/mizar1616)<br />[🌍](#translation-mizar1616 "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1458388?v=3" width="110px;"/><br /><sub>R Ryan Dial</sub>](https://github.com/rrdial)<br />[🌍](#translation-rrdial "Translation") | [<img src="https://avatars2.githubusercontent.com/u/2871745?v=3" width="110px;"/><br /><sub>Andrej Manduch</sub>](https://github.com/burlito)<br />[📖](https://github.com/snipe/snipe-it/commits?author=burlito "Documentation") |
| [<img src="https://avatars0.githubusercontent.com/u/8341172?v=3" width="110px;"/><br /><sub>Jay Richards</sub>](http://www.cordeos.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=technogenus "Code") | [<img src="https://avatars2.githubusercontent.com/u/7295127?v=3" width="110px;"/><br /><sub>Alexander Innes</sub>](https://necurity.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=leostat "Code") | [<img src="https://avatars2.githubusercontent.com/u/334485?v=3" width="110px;"/><br /><sub>Danny Garcia</sub>](https://buzzedword.codes)<br />[💻](https://github.com/snipe/snipe-it/commits?author=buzzedword "Code") | [<img src="https://avatars2.githubusercontent.com/u/366855?v=3" width="110px;"/><br /><sub>archpoint</sub>](https://github.com/archpoint)<br />[💻](https://github.com/snipe/snipe-it/commits?author=archpoint "Code") | [<img src="https://avatars1.githubusercontent.com/u/67991?v=3" width="110px;"/><br /><sub>Jake McGraw</sub>](http://www.jakemcgraw.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jakemcgraw "Code") | [<img src="https://avatars1.githubusercontent.com/u/1714374?v=3" width="110px;"/><br /><sub>FleischKarussel</sub>](https://github.com/FleischKarussel)<br />[📖](https://github.com/snipe/snipe-it/commits?author=FleischKarussel "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/319644?v=3" width="110px;"/><br /><sub>Dylan Yi</sub>](https://github.com/feeva)<br />[💻](https://github.com/snipe/snipe-it/commits?author=feeva "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/857740?v=3" width="110px;"/><br /><sub>Gil Rutkowski</sub>](http://FlashingCursor.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=flashingcursor "Code") | [<img src="https://avatars3.githubusercontent.com/u/129360?v=3" width="110px;"/><br /><sub>Desmond Morris</sub>](http://www.desmondmorris.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=desmondmorris "Code") | [<img src="https://avatars2.githubusercontent.com/u/52936?v=3" width="110px;"/><br /><sub>Nick Peelman</sub>](http://peelman.us)<br />[💻](https://github.com/snipe/snipe-it/commits?author=peelman "Code") | [<img src="https://avatars0.githubusercontent.com/u/53161?v=3" width="110px;"/><br /><sub>Abraham Vegh</sub>](https://abrahamvegh.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=abrahamvegh "Code") | [<img src="https://avatars0.githubusercontent.com/u/2818680?v=3" width="110px;"/><br /><sub>Mohamed Rashid</sub>](https://github.com/rashivkp)<br />[📖](https://github.com/snipe/snipe-it/commits?author=rashivkp "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1509456?v=3" width="110px;"/><br /><sub>Kasey</sub>](http://hinchk.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=HinchK "Code") | [<img src="https://avatars2.githubusercontent.com/u/10522541?v=3" width="110px;"/><br /><sub>Brett</sub>](https://github.com/BrettFagerlund)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=BrettFagerlund "Tests") |
| [<img src="https://avatars2.githubusercontent.com/u/16108587?v=3" width="110px;"/><br /><sub>Jason Spriggs</sub>](http://jasonspriggs.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonspriggs "Code") | [<img src="https://avatars2.githubusercontent.com/u/1134568?v=3" width="110px;"/><br /><sub>Nate Felton</sub>](http://n8felton.wordpress.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=n8felton "Code") | [<img src="https://avatars2.githubusercontent.com/u/14036694?v=3" width="110px;"/><br /><sub>Manasses Ferreira</sub>](http://homepages.dcc.ufmg.br/~manassesferreira)<br />[💻](https://github.com/snipe/snipe-it/commits?author=manassesferreira "Code") | [<img src="https://avatars0.githubusercontent.com/u/15913949?v=3" width="110px;"/><br /><sub>Steve</sub>](https://github.com/steveelwood)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=steveelwood "Tests") | [<img src="https://avatars1.githubusercontent.com/u/3361683?v=3" width="110px;"/><br /><sub>matc</sub>](http://twitter.com/matc)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=matc "Tests") | [<img src="https://avatars3.githubusercontent.com/u/7405702?v=3" width="110px;"/><br /><sub>Cole R. Davis</sub>](http://www.davisracingteam.com)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=VanillaNinjaD "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10167681?v=3" width="110px;"/><br /><sub>gibsonjoshua55</sub>](https://github.com/gibsonjoshua55)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gibsonjoshua55 "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/2809241?v=4" width="110px;"/><br /><sub>Robin Temme</sub>](https://github.com/zwerch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zwerch "Code") | [<img src="https://avatars0.githubusercontent.com/u/6961695?v=4" width="110px;"/><br /><sub>Iman</sub>](https://github.com/imanghafoori1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=imanghafoori1 "Code") | [<img src="https://avatars1.githubusercontent.com/u/6551003?v=4" width="110px;"/><br /><sub>Richard Hofman</sub>](https://github.com/richardhofman6)<br />[💻](https://github.com/snipe/snipe-it/commits?author=richardhofman6 "Code") | [<img src="https://avatars0.githubusercontent.com/u/3697569?v=4" width="110px;"/><br /><sub>gizzmojr</sub>](https://github.com/gizzmojr)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gizzmojr "Code") | [<img src="https://avatars3.githubusercontent.com/u/404729?v=4" width="110px;"/><br /><sub>Jenny Li</sub>](https://github.com/imjennyli)<br />[📖](https://github.com/snipe/snipe-it/commits?author=imjennyli "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/869227?v=4" width="110px;"/><br /><sub>Geoff Young</sub>](https://github.com/GeoffYoung)<br />[💻](https://github.com/snipe/snipe-it/commits?author=GeoffYoung "Code") | [<img src="https://avatars3.githubusercontent.com/u/1068477?v=4" width="110px;"/><br /><sub>Elliot Blackburn</sub>](http://www.elliotblackburn.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=BlueHatbRit "Documentation") |
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") | [<img src="https://avatars0.githubusercontent.com/u/449411?v=4" width="110px;"/><br /><sub>Nicolai Essig</sub>](http://www.nicolai-essig.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thakilla "Code") | [<img src="https://avatars1.githubusercontent.com/u/14809698?v=4" width="110px;"/><br /><sub>Danielle</sub>](https://github.com/techincolor)<br />[📖](https://github.com/snipe/snipe-it/commits?author=techincolor "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/18545156?v=4" width="110px;"/><br /><sub>Lawrence</sub>](https://github.com/TheVakman)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=TheVakman "Tests") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3ATheVakman "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/22473767?v=4" width="110px;"/><br /><sub>uknzaeinozpas</sub>](https://github.com/uknzaeinozpas)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Tests") [💻](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Code") | [<img src="https://avatars3.githubusercontent.com/u/422752?v=4" width="110px;"/><br /><sub>Ryan</sub>](https://github.com/Gelob)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Gelob "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/10672546?v=4" width="110px;"/><br /><sub>vcordes79</sub>](https://github.com/vcordes79)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vcordes79 "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/27958330?v=4" width="110px;"/><br /><sub>fordster78</sub>](https://github.com/fordster78)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fordster78 "Code") | [<img src="https://avatars0.githubusercontent.com/u/34064225?v=4" width="110px;"/><br /><sub>CronKz</sub>](https://github.com/CronKz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=CronKz "Code") [🌍](#translation-CronKz "Translation") | [<img src="https://avatars1.githubusercontent.com/u/585486?v=4" width="110px;"/><br /><sub>Tim Bishop</sub>](https://github.com/tdb)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tdb "Code") | [<img src="https://avatars2.githubusercontent.com/u/5384694?v=4" width="110px;"/><br /><sub>Sean McIlvenna</sub>](https://www.seanmcilvenna.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=seanmcilvenna "Code") | [<img src="https://avatars3.githubusercontent.com/u/36515590?v=4" width="110px;"/><br /><sub>cepacs</sub>](https://github.com/cepacs)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Acepacs "Bug reports") [📖](https://github.com/snipe/snipe-it/commits?author=cepacs "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/37537300?v=4" width="110px;"/><br /><sub>lea-mink</sub>](https://github.com/lea-mink)<br />[💻](https://github.com/snipe/snipe-it/commits?author=lea-mink "Code") | [<img src="https://avatars0.githubusercontent.com/u/7140719?v=4" width="110px;"/><br /><sub>Hannah Tinkler</sub>](https://github.com/hannahtinkler)<br />[💻](https://github.com/snipe/snipe-it/commits?author=hannahtinkler "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/1086388?v=4" width="110px;"/><br /><sub>Doeke Zanstra</sub>](https://github.com/doekman)<br />[💻](https://github.com/snipe/snipe-it/commits?author=doekman "Code") | [<img src="https://avatars1.githubusercontent.com/u/4325936?v=4" width="110px;"/><br /><sub>Djamon Staal</sub>](https://www.sdhd.nl/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=SjamonDaal "Code") | [<img src="https://avatars3.githubusercontent.com/u/12306859?v=4" width="110px;"/><br /><sub>Earl Ramirez</sub>](https://github.com/EarlRamirez)<br />[💻](https://github.com/snipe/snipe-it/commits?author=EarlRamirez "Code") | [<img src="https://avatars2.githubusercontent.com/u/8671456?v=4" width="110px;"/><br /><sub>Richard Ray Thomas</sub>](https://github.com/RichardRay)<br />[💻](https://github.com/snipe/snipe-it/commits?author=RichardRay "Code") | [<img src="https://avatars3.githubusercontent.com/u/1852688?v=4" width="110px;"/><br /><sub>Ryan Kuba</sub>](https://www.taisun.io/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thelamer "Code") | [<img src="https://avatars1.githubusercontent.com/u/6751928?v=4" width="110px;"/><br /><sub>Brian Monroe</sub>](https://github.com/ParadoxGuitarist)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ParadoxGuitarist "Code") | [<img src="https://avatars1.githubusercontent.com/u/605167?v=4" width="110px;"/><br /><sub>plexorama</sub>](https://github.com/plexorama)<br />[💻](https://github.com/snipe/snipe-it/commits?author=plexorama "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/1795149?v=4" width="110px;"/><br /><sub>Till Deeke</sub>](https://tilldeeke.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tilldeeke "Code") | [<img src="https://avatars0.githubusercontent.com/u/12634129?v=4" width="110px;"/><br /><sub>5quirrel</sub>](https://github.com/5quirrel)<br />[💻](https://github.com/snipe/snipe-it/commits?author=5quirrel "Code") | [<img src="https://avatars1.githubusercontent.com/u/13071957?v=4" width="110px;"/><br /><sub>Jason</sub>](https://github.com/jasonlshelton)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonlshelton "Code") | [<img src="https://avatars3.githubusercontent.com/u/7128321?v=4" width="110px;"/><br /><sub>Antti</sub>](https://github.com/chemfy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chemfy "Code") | [<img src="https://avatars3.githubusercontent.com/u/10080364?v=4" width="110px;"/><br /><sub>DeusMaximus</sub>](https://github.com/DeusMaximus)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DeusMaximus "Code") | [<img src="https://avatars2.githubusercontent.com/u/16384611?v=4" width="110px;"/><br /><sub>a-royal</sub>](https://github.com/A-ROYAL)<br />[🌍](#translation-A-ROYAL "Translation") | [<img src="https://avatars0.githubusercontent.com/u/5358208?v=4" width="110px;"/><br /><sub>Alberto Aldrigo</sub>](https://github.com/albertoaldrigo)<br />[🌍](#translation-albertoaldrigo "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/1412342?v=4" width="110px;"/><br /><sub>Alex Stanev</sub>](http://alex.stanev.org/blog)<br />[🌍](#translation-RealEnder "Translation") | [<img src="https://avatars0.githubusercontent.com/u/177295?v=4" width="110px;"/><br /><sub>Andreas Rehm</sub>](http://devel.itsolution2.de)<br />[🌍](#translation-sirrus "Translation") | [<img src="https://avatars0.githubusercontent.com/u/5080535?v=4" width="110px;"/><br /><sub>Andreas Erhard</sub>](https://github.com/xelan)<br />[🌍](#translation-xelan "Translation") | [<img src="https://avatars2.githubusercontent.com/u/142350?v=4" width="110px;"/><br /><sub>Andrés Vanegas Jiménez</sub>](https://github.com/angeldeejay)<br />[🌍](#translation-angeldeejay "Translation") | [<img src="https://avatars0.githubusercontent.com/u/3910403?v=4" width="110px;"/><br /><sub>Antonio Schiavon</sub>](https://github.com/aschiavon91)<br />[🌍](#translation-aschiavon91 "Translation") | [<img src="https://avatars0.githubusercontent.com/u/10464547?v=4" width="110px;"/><br /><sub>benunter</sub>](https://github.com/benunter)<br />[🌍](#translation-benunter "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5038647?v=4" width="110px;"/><br /><sub>Borys Żmuda</sub>](http://catweb24.pl)<br />[🌍](#translation-rudashi "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/5539359?v=4" width="110px;"/><br /><sub>chibacityblues</sub>](https://github.com/chibacityblues)<br />[🌍](#translation-chibacityblues "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1954830?v=4" width="110px;"/><br /><sub>Chien Wei Lin</sub>](https://github.com/cwlin0416)<br />[🌍](#translation-cwlin0416 "Translation") | [<img src="https://avatars3.githubusercontent.com/u/11700533?v=4" width="110px;"/><br /><sub>Christian Schuster</sub>](https://github.com/Againstreality)<br />[🌍](#translation-Againstreality "Translation") | [<img src="https://avatars1.githubusercontent.com/u/4308704?v=4" width="110px;"/><br /><sub>Christian Stefanus</sub>](http://chriss.webhostid.com)<br />[🌍](#translation-kopi-item "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3009327?v=4" width="110px;"/><br /><sub>wxcafé</sub>](http://wxcafe.net)<br />[🌍](#translation-wxcafe "Translation") | [<img src="https://avatars3.githubusercontent.com/u/35761525?v=4" width="110px;"/><br /><sub>dpyroc</sub>](https://github.com/dpyroc)<br />[🌍](#translation-dpyroc "Translation") | [<img src="https://avatars1.githubusercontent.com/u/2153639?v=4" width="110px;"/><br /><sub>Daniel Friedlmaier</sub>](http://www.friedlmaier.net)<br />[🌍](#translation-da-friedl "Translation") |
| [<img src="https://avatars1.githubusercontent.com/u/2947640?v=4" width="110px;"/><br /><sub>Daniel Heene</sub>](https://github.com/danielheene)<br />[🌍](#translation-danielheene "Translation") | [<img src="https://avatars3.githubusercontent.com/u/319022?v=4" width="110px;"/><br /><sub>danielcb</sub>](https://github.com/danielcb)<br />[🌍](#translation-danielcb "Translation") | [<img src="https://avatars3.githubusercontent.com/u/15846537?v=4" width="110px;"/><br /><sub>Dominik Senti</sub>](https://github.com/dominiksenti)<br />[🌍](#translation-dominiksenti "Translation") | [<img src="https://avatars0.githubusercontent.com/u/25570954?v=4" width="110px;"/><br /><sub>Eric Gautheron</sub>](http://www.konectik.com)<br />[🌍](#translation-EpixFr "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5732623?v=4" width="110px;"/><br /><sub>Erlend Pilø</sub>](https://erlpil.com)<br />[🌍](#translation-Erlpil "Translation") | [<img src="https://avatars0.githubusercontent.com/u/541832?v=4" width="110px;"/><br /><sub>Fabio Rapposelli</sub>](http://fabio.technology)<br />[🌍](#translation-frapposelli "Translation") | [<img src="https://avatars2.githubusercontent.com/u/3605240?v=4" width="110px;"/><br /><sub>Felipe Barros</sub>](https://github.com/fgbs)<br />[🌍](#translation-fgbs "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/257745?v=4" width="110px;"/><br /><sub>Fernando Possebon</sub>](https://github.com/possebon)<br />[🌍](#translation-possebon "Translation") | [<img src="https://avatars3.githubusercontent.com/u/2540832?v=4" width="110px;"/><br /><sub>gdraque</sub>](https://github.com/gdraque)<br />[🌍](#translation-gdraque "Translation") | [<img src="https://avatars0.githubusercontent.com/u/23440381?v=4" width="110px;"/><br /><sub>Georg Wallisch</sub>](https://github.com/georgwallisch)<br />[🌍](#translation-georgwallisch "Translation") | [<img src="https://avatars1.githubusercontent.com/u/9852832?v=4" width="110px;"/><br /><sub>Gerardo Robles</sub>](https://github.com/jgroblesr85)<br />[🌍](#translation-jgroblesr85 "Translation") | [<img src="https://avatars2.githubusercontent.com/u/11082640?v=4" width="110px;"/><br /><sub>Gluek</sub>](https://t.me/Gluek)<br />[🌍](#translation-mrgluek "Translation") | [<img src="https://avatars0.githubusercontent.com/u/6847946?v=4" width="110px;"/><br /><sub>AdnanAbuShahad</sub>](https://github.com/AdnanAbuShahad)<br />[🌍](#translation-AdnanAbuShahad "Translation") | [<img src="https://avatars1.githubusercontent.com/u/3580608?v=4" width="110px;"/><br /><sub>Hafidzi My</sub>](https://hafidzi.my)<br />[🌍](#translation-hafidzi "Translation") |
| [<img src="https://avatars2.githubusercontent.com/u/205521?v=4" width="110px;"/><br /><sub>Harim Park</sub>](https://github.com/fofwisdom)<br />[🌍](#translation-fofwisdom "Translation") | [<img src="https://avatars2.githubusercontent.com/u/3333841?v=4" width="110px;"/><br /><sub>Henrik Kentsson</sub>](http://www.kentsson.se)<br />[🌍](#translation-Kentsson "Translation") | [<img src="https://avatars0.githubusercontent.com/u/36551034?v=4" width="110px;"/><br /><sub>Husnul Yaqien</sub>](https://github.com/husnulyaqien)<br />[🌍](#translation-husnulyaqien "Translation") | [<img src="https://avatars1.githubusercontent.com/u/2372747?v=4" width="110px;"/><br /><sub>Ibrahim</sub>](http://abaalkhail.org)<br />[🌍](#translation-abaalkh "Translation") | [<img src="https://avatars0.githubusercontent.com/u/1389334?v=4" width="110px;"/><br /><sub>igolman</sub>](https://github.com/igolman)<br />[🌍](#translation-igolman "Translation") | [<img src="https://avatars1.githubusercontent.com/u/3257070?v=4" width="110px;"/><br /><sub>itangiang</sub>](https://github.com/itangiang)<br />[🌍](#translation-itangiang "Translation") | [<img src="https://avatars2.githubusercontent.com/u/14814254?v=4" width="110px;"/><br /><sub>jarby1211</sub>](https://github.com/jarby1211)<br />[🌍](#translation-jarby1211 "Translation") |
| [<img src="https://avatars3.githubusercontent.com/u/6719357?v=4" width="110px;"/><br /><sub>Jhonn Willker</sub>](http://jwillker.com)<br />[🌍](#translation-JohnWillker "Translation") | [<img src="https://avatars2.githubusercontent.com/u/10983635?v=4" width="110px;"/><br /><sub>Jose</sub>](https://github.com/joxelito94)<br />[🌍](#translation-joxelito94 "Translation") | [<img src="https://avatars0.githubusercontent.com/u/5206122?v=4" width="110px;"/><br /><sub>laopangzi</sub>](https://github.com/laopangzi)<br />[🌍](#translation-laopangzi "Translation") | [<img src="https://avatars2.githubusercontent.com/u/79707?v=4" width="110px;"/><br /><sub>Lars Strojny</sub>](http://usrportage.de)<br />[🌍](#translation-lstrojny "Translation") | [<img src="https://avatars0.githubusercontent.com/u/389801?v=4" width="110px;"/><br /><sub>MarcosBL</sub>](http://twitter.com/marcosbl)<br />[🌍](#translation-MarcosBL "Translation") | [<img src="https://avatars3.githubusercontent.com/u/35664606?v=4" width="110px;"/><br /><sub>marie joy cajes</sub>](https://github.com/mariejoyacajes)<br />[🌍](#translation-mariejoyacajes "Translation") | [<img src="https://avatars2.githubusercontent.com/u/3052816?v=4" width="110px;"/><br /><sub>Mark S. Johansen</sub>](http://www.markjohansen.dk)<br />[🌍](#translation-msjohansen "Translation") |
| [<img src="https://avatars2.githubusercontent.com/u/982885?v=4" width="110px;"/><br /><sub>Martin Stub</sub>](http://martinstub.dk)<br />[🌍](#translation-stubben "Translation") | [<img src="https://avatars2.githubusercontent.com/u/28959963?v=4" width="110px;"/><br /><sub>Meyer Flavio</sub>](https://github.com/meyerf99)<br />[🌍](#translation-meyerf99 "Translation") | [<img src="https://avatars3.githubusercontent.com/u/796443?v=4" width="110px;"/><br /><sub>Micael Rodrigues</sub>](https://github.com/MicaelRodrigues)<br />[🌍](#translation-MicaelRodrigues "Translation") | [<img src="https://avatars0.githubusercontent.com/u/10481331?v=4" width="110px;"/><br /><sub>Mikael Rasmussen</sub>](http://rubixy.com/)<br />[🌍](#translation-mikaelssen "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1544552?v=4" width="110px;"/><br /><sub>IxFail</sub>](https://github.com/IxFail)<br />[🌍](#translation-IxFail "Translation") | [<img src="https://avatars3.githubusercontent.com/u/18483118?v=4" width="110px;"/><br /><sub>Mohammed Fota</sub>](http://www.mohammedfota.com)<br />[🌍](#translation-MohammedFota "Translation") | [<img src="https://avatars0.githubusercontent.com/u/227080?v=4" width="110px;"/><br /><sub>Moayad Alserihi</sub>](https://github.com/omego)<br />[🌍](#translation-omego "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/1680266?v=4" width="110px;"/><br /><sub>saymd</sub>](https://github.com/saymd)<br />[🌍](#translation-saymd "Translation") | [<img src="https://avatars0.githubusercontent.com/u/1826808?v=4" width="110px;"/><br /><sub>Patrik Larsson</sub>](https://nordsken.se)<br />[🌍](#translation-pooot "Translation") | [<img src="https://avatars1.githubusercontent.com/u/20584746?v=4" width="110px;"/><br /><sub>drcryo</sub>](https://github.com/drcryo)<br />[🌍](#translation-drcryo "Translation") | [<img src="https://avatars1.githubusercontent.com/u/19408004?v=4" width="110px;"/><br /><sub>pawel1615</sub>](https://github.com/pawel1615)<br />[🌍](#translation-pawel1615 "Translation") | [<img src="https://avatars2.githubusercontent.com/u/23340468?v=4" width="110px;"/><br /><sub>bodrovics</sub>](https://github.com/bodrovics)<br />[🌍](#translation-bodrovics "Translation") | [<img src="https://avatars0.githubusercontent.com/u/3257654?v=4" width="110px;"/><br /><sub>priatna</sub>](https://github.com/priatna)<br />[🌍](#translation-priatna "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5358374?v=4" width="110px;"/><br /><sub>Fan Jiang</sub>](https://amayume.net)<br />[🌍](#translation-ProfFan "Translation") |
| [<img src="https://avatars1.githubusercontent.com/u/22555451?v=4" width="110px;"/><br /><sub>ragnarcx</sub>](https://github.com/ragnarcx)<br />[🌍](#translation-ragnarcx "Translation") | [<img src="https://avatars2.githubusercontent.com/u/18654582?v=4" width="110px;"/><br /><sub>Rein van Haaren</sub>](http://www.reinvanhaaren.nl/)<br />[🌍](#translation-reinvanhaaren "Translation") | [<img src="https://avatars1.githubusercontent.com/u/386672?v=4" width="110px;"/><br /><sub>Teguh Dwicaksana</sub>](http://dheche.songolimo.net)<br />[🌍](#translation-dheche "Translation") | [<img src="https://avatars2.githubusercontent.com/u/2572552?v=4" width="110px;"/><br /><sub>fraccie</sub>](https://github.com/FRaccie)<br />[🌍](#translation-FRaccie "Translation") | [<img src="https://avatars0.githubusercontent.com/u/35182720?v=4" width="110px;"/><br /><sub>vinzruzell</sub>](https://github.com/vinzruzell)<br />[🌍](#translation-vinzruzell "Translation") | [<img src="https://avatars1.githubusercontent.com/u/7883603?v=4" width="110px;"/><br /><sub>Kevin Austin</sub>](http://kevinaustin.com)<br />[🌍](#translation-vipsystem "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3861828?v=4" width="110px;"/><br /><sub>Wira Sandy</sub>](http://azuraweb.xyz)<br />[🌍](#translation-wira-sandy "Translation") |
| [<img src="https://avatars2.githubusercontent.com/u/8663789?v=4" width="110px;"/><br /><sub>Илья</sub>](https://github.com/GrayHoax)<br />[🌍](#translation-GrayHoax "Translation") | [<img src="https://avatars3.githubusercontent.com/u/30119111?v=4" width="110px;"/><br /><sub>GodUseVPN</sub>](https://github.com/godusevpn)<br />[🌍](#translation-godusevpn "Translation") | [<img src="https://avatars1.githubusercontent.com/u/745576?v=4" width="110px;"/><br /><sub>周周</sub>](https://github.com/EngrZhou)<br />[🌍](#translation-EngrZhou "Translation") | [<img src="https://avatars3.githubusercontent.com/u/1631095?v=4" width="110px;"/><br /><sub>Sam</sub>](https://github.com/takuy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=takuy "Code") | [<img src="https://avatars1.githubusercontent.com/u/264022?v=4" width="110px;"/><br /><sub>Azerothian</sub>](https://www.illisian.com.au)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Azerothian "Code") | [<img src="https://avatars1.githubusercontent.com/u/4930051?v=4" width="110px;"/><br /><sub>Wes Hulette</sub>](http://macfoo.wordpress.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jwhulette "Code") | [<img src="https://avatars0.githubusercontent.com/u/8134591?v=4" width="110px;"/><br /><sub>patrict</sub>](https://github.com/patrict)<br />[💻](https://github.com/snipe/snipe-it/commits?author=patrict "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/2611616?v=4" width="110px;"/><br /><sub>Dmitriy Minaev</sub>](https://github.com/VELIKII-DIVAN)<br />[💻](https://github.com/snipe/snipe-it/commits?author=VELIKII-DIVAN "Code") | [<img src="https://avatars0.githubusercontent.com/u/5132245?v=4" width="110px;"/><br /><sub>liquidhorse</sub>](https://github.com/liquidhorse)<br />[💻](https://github.com/snipe/snipe-it/commits?author=liquidhorse "Code") | [<img src="https://avatars1.githubusercontent.com/u/183678?v=4" width="110px;"/><br /><sub>Jordi Boggiano</sub>](https://seld.be/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Seldaek "Code") | [<img src="https://avatars0.githubusercontent.com/u/653557?v=4" width="110px;"/><br /><sub>Ivan Nieto</sub>](https://github.com/inietov)<br />[💻](https://github.com/snipe/snipe-it/commits?author=inietov "Code") | [<img src="https://avatars2.githubusercontent.com/u/6764151?v=4" width="110px;"/><br /><sub>Ben RUBSON</sub>](https://github.com/benrubson)<br />[💻](https://github.com/snipe/snipe-it/commits?author=benrubson "Code") | [<img src="https://avatars2.githubusercontent.com/u/8554558?v=4" width="110px;"/><br /><sub>NMathar</sub>](https://github.com/NMathar)<br />[💻](https://github.com/snipe/snipe-it/commits?author=NMathar "Code") | [<img src="https://avatars1.githubusercontent.com/u/139566?v=4" width="110px;"/><br /><sub>Steffen</sub>](https://github.com/smb)<br />[💻](https://github.com/snipe/snipe-it/commits?author=smb "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/6609453?v=4" width="110px;"/><br /><sub>Sxderp</sub>](https://github.com/Sxderp)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Sxderp "Code") | [<img src="https://avatars1.githubusercontent.com/u/4807843?v=4" width="110px;"/><br /><sub>fanta8897</sub>](https://github.com/fanta8897)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fanta8897 "Code") | [<img src="https://avatars2.githubusercontent.com/u/2576509?v=4" width="110px;"/><br /><sub>Andrey Bolonin</sub>](https://andreybolonin.com/phpconsulting/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=andreybolonin "Code") | [<img src="https://avatars3.githubusercontent.com/u/2173307?v=4" width="110px;"/><br /><sub>shinayoshi</sub>](http://www.shinayoshi.net/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=shinayoshi "Code") | [<img src="https://avatars3.githubusercontent.com/u/2130159?v=4" width="110px;"/><br /><sub>Hubert</sub>](https://github.com/reuser)<br />[💻](https://github.com/snipe/snipe-it/commits?author=reuser "Code") | [<img src="https://avatars0.githubusercontent.com/u/6865789?v=4" width="110px;"/><br /><sub>KeenRivals</sub>](https://brashear.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=KeenRivals "Code") | [<img src="https://avatars3.githubusercontent.com/u/2902513?v=4" width="110px;"/><br /><sub>omyno</sub>](https://github.com/omyno)<br />[💻](https://github.com/snipe/snipe-it/commits?author=omyno "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/6271335?v=4" width="110px;"/><br /><sub>Evgeny</sub>](https://github.com/jackka)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jackka "Code") | [<img src="https://avatars2.githubusercontent.com/u/1169963?v=4" width="110px;"/><br /><sub>Colin Campbell</sub>](https://digitalist.se)<br />[💻](https://github.com/snipe/snipe-it/commits?author=colin-campbell "Code") | [<img src="https://avatars3.githubusercontent.com/u/2872098?v=4" width="110px;"/><br /><sub>Ľubomír Kučera</sub>](https://github.com/lubo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=lubo "Code") | [<img src="https://avatars3.githubusercontent.com/u/570639?v=4" width="110px;"/><br /><sub>Martin Meredith</sub>](https://www.sourceguru.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Mezzle "Code") | [<img src="https://avatars1.githubusercontent.com/u/7632599?v=4" width="110px;"/><br /><sub>Tim Farmer</sub>](https://github.com/timothyfarmer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=timothyfarmer "Code") | [<img src="https://avatars0.githubusercontent.com/u/17459600?v=4" width="110px;"/><br /><sub>Marián Skrip</sub>](https://github.com/mskrip)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mskrip "Code") | [<img src="https://avatars2.githubusercontent.com/u/47435081?v=4" width="110px;"/><br /><sub>Godfrey Martinez</sub>](https://github.com/Godmartinz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Godmartinz "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/2075128?v=4" width="110px;"/><br /><sub>bigtreeEdo</sub>](https://github.com/bigtreeEdo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bigtreeEdo "Code") | [<img src="https://avatars0.githubusercontent.com/u/5000430?v=4" width="110px;"/><br /><sub>Colin McNeil</sub>](https://colinmcneil.me/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ColinMcNeil "Code") | [<img src="https://avatars0.githubusercontent.com/u/421625?v=4" width="110px;"/><br /><sub>JoKneeMo</sub>](https://github.com/JoKneeMo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=JoKneeMo "Code") | [<img src="https://avatars0.githubusercontent.com/u/54849013?v=4" width="110px;"/><br /><sub>Joshi</sub>](http://www.redbridge.se)<br />[💻](https://github.com/snipe/snipe-it/commits?author=joshi-redbridge "Code") | [<img src="https://avatars2.githubusercontent.com/u/15731458?v=4" width="110px;"/><br /><sub>Anthony Burns</sub>](https://github.com/anthonypburns)<br />[💻](https://github.com/snipe/snipe-it/commits?author=anthonypburns "Code") | [<img src="https://avatars1.githubusercontent.com/u/63399474?v=4" width="110px;"/><br /><sub>johnson-yi</sub>](https://github.com/johnson-yi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=johnson-yi "Code") | [<img src="https://avatars1.githubusercontent.com/u/1862720?v=4" width="110px;"/><br /><sub>Sanjay Govind</sub>](https://tangentmc.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sanjay900 "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/1255375?v=4" width="110px;"/><br /><sub>Peter Upfold</sub>](https://peter.upfold.org.uk/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PeterUpfold "Code") | [<img src="https://avatars2.githubusercontent.com/u/961717?v=4" width="110px;"/><br /><sub>Jared Biel</sub>](https://github.com/jbiel)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jbiel "Code") | [<img src="https://avatars1.githubusercontent.com/u/1733625?v=4" width="110px;"/><br /><sub>Dampfklon</sub>](https://github.com/dampfklon)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dampfklon "Code") | [<img src="https://avatars2.githubusercontent.com/u/52973156?v=4" width="110px;"/><br /><sub>Charles Hamilton</sub>](https://communityclosing.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chamilton-ccn "Code") | [<img src="https://avatars.githubusercontent.com/u/551789?v=4" width="110px;"/><br /><sub>Giuseppe Iannello</sub>](https://github.com/giannello)<br />[💻](https://github.com/snipe/snipe-it/commits?author=giannello "Code") | [<img src="https://avatars.githubusercontent.com/u/3691490?v=4" width="110px;"/><br /><sub>Peter Dave Hello</sub>](https://www.peterdavehello.org/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PeterDaveHello "Code") | [<img src="https://avatars.githubusercontent.com/u/6106332?v=4" width="110px;"/><br /><sub>sigmoidal</sub>](https://github.com/sigmoidal)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sigmoidal "Code") |
| [<img src="https://avatars.githubusercontent.com/u/2082554?v=4" width="110px;"/><br /><sub>Vincent Lainé</sub>](https://github.com/phenixdotnet)<br />[💻](https://github.com/snipe/snipe-it/commits?author=phenixdotnet "Code") | [<img src="https://avatars.githubusercontent.com/u/1943040?v=4" width="110px;"/><br /><sub>Lucas Pleß</sub>](http://www.lucas-pless.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=derlucas "Code") | [<img src="https://avatars.githubusercontent.com/u/472804?v=4" width="110px;"/><br /><sub>Ian Littman</sub>](http://twitter.com/iansltx)<br />[💻](https://github.com/snipe/snipe-it/commits?author=iansltx "Code") | [<img src="https://avatars.githubusercontent.com/u/3519029?v=4" width="110px;"/><br /><sub>João Paulo</sub>](https://github.com/PauloLuna)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PauloLuna "Code") | [<img src="https://avatars.githubusercontent.com/u/70443365?v=4" width="110px;"/><br /><sub>ThoBur</sub>](https://github.com/ThoBur)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ThoBur "Code") | [<img src="https://avatars.githubusercontent.com/u/1972329?v=4" width="110px;"/><br /><sub>Alexander Chibrikin</sub>](http://phpprofi.ru/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=alek13 "Code") | [<img src="https://avatars.githubusercontent.com/u/438332?v=4" width="110px;"/><br /><sub>Anthony Winstanley</sub>](https://github.com/winstan)<br />[💻](https://github.com/snipe/snipe-it/commits?author=winstan "Code") |
| [<img src="https://avatars.githubusercontent.com/u/3075214?v=4" width="110px;"/><br /><sub>Folke</sub>](https://github.com/fashberg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fashberg "Code") | [<img src="https://avatars.githubusercontent.com/u/1351571?v=4" width="110px;"/><br /><sub>Bennett Blodinger</sub>](https://github.com/benwa)<br />[💻](https://github.com/snipe/snipe-it/commits?author=benwa "Code") | [<img src="https://avatars.githubusercontent.com/u/2974631?v=4" width="110px;"/><br /><sub>NMC</sub>](https://nmc.dev)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ncareau "Code") | [<img src="https://avatars.githubusercontent.com/u/52182449?v=4" width="110px;"/><br /><sub>andres-baller</sub>](https://github.com/andres-baller)<br />[💻](https://github.com/snipe/snipe-it/commits?author=andres-baller "Code") | [<img src="https://avatars.githubusercontent.com/u/67109348?v=4" width="110px;"/><br /><sub>sean-borg</sub>](https://github.com/sean-borg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sean-borg "Code") | [<img src="https://avatars.githubusercontent.com/u/32170051?v=4" width="110px;"/><br /><sub>EDVLeer</sub>](https://github.com/EDVLeer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=EDVLeer "Code") | [<img src="https://avatars.githubusercontent.com/u/23075196?v=4" width="110px;"/><br /><sub>Kurokat</sub>](https://github.com/Kurokat)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Kurokat "Code") |
| [<img src="https://avatars.githubusercontent.com/u/915514?v=4" width="110px;"/><br /><sub>Kevin Köllmann</sub>](https://www.kevinkoellmann.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=koelle25 "Code") | [<img src="https://avatars.githubusercontent.com/u/49025941?v=4" width="110px;"/><br /><sub>sw-mreyes</sub>](https://github.com/sw-mreyes)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sw-mreyes "Code") | [<img src="https://avatars.githubusercontent.com/u/70129?v=4" width="110px;"/><br /><sub>Joel Pittet</sub>](https://pittet.ca)<br />[💻](https://github.com/snipe/snipe-it/commits?author=joelpittet "Code") | [<img src="https://avatars.githubusercontent.com/u/792695?v=4" width="110px;"/><br /><sub>Eli Young</sub>](https://elyscape.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=elyscape "Code") | [<img src="https://avatars.githubusercontent.com/u/317015?v=4" width="110px;"/><br /><sub>Raell Dottin</sub>](https://github.com/raelldottin)<br />[💻](https://github.com/snipe/snipe-it/commits?author=raelldottin "Code") | [<img src="https://avatars.githubusercontent.com/u/1446856?v=4" width="110px;"/><br /><sub>Tom Misilo</sub>](https://github.com/misilot)<br />[💻](https://github.com/snipe/snipe-it/commits?author=misilot "Code") | [<img src="https://avatars.githubusercontent.com/u/4496300?v=4" width="110px;"/><br /><sub>David Davenne</sub>](http://david.davenne.be)<br />[💻](https://github.com/snipe/snipe-it/commits?author=JuustoMestari "Code") |
| [<img src="https://avatars.githubusercontent.com/u/9255772?v=4" width="110px;"/><br /><sub>Mark Stenglein</sub>](https://markstenglein.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ocelotsloth "Code") | [<img src="https://avatars.githubusercontent.com/u/35658596?v=4" width="110px;"/><br /><sub>ajsy</sub>](https://github.com/ajsy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ajsy "Code") | [<img src="https://avatars.githubusercontent.com/u/3628035?v=4" width="110px;"/><br /><sub>Jan Kiesewetter</sub>](https://github.com/t3easy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=t3easy "Code") | [<img src="https://avatars.githubusercontent.com/u/79449630?v=4" width="110px;"/><br /><sub>Tetrachloromethane250</sub>](https://github.com/Tetrachloromethane250)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Tetrachloromethane250 "Code") | [<img src="https://avatars.githubusercontent.com/u/22004482?v=4" width="110px;"/><br /><sub>Lars Kajes</sub>](https://www.kajes.se/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kajes "Code") | [<img src="https://avatars.githubusercontent.com/u/13993216?v=4" width="110px;"/><br /><sub>Joly0</sub>](https://github.com/Joly0)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Joly0 "Code") | [<img src="https://avatars.githubusercontent.com/u/1501022?v=4" width="110px;"/><br /><sub>theburger</sub>](https://github.com/limeless)<br />[💻](https://github.com/snipe/snipe-it/commits?author=limeless "Code") |
| [<img src="https://avatars.githubusercontent.com/u/36065681?v=4" width="110px;"/><br /><sub>David Valin Alonso</sub>](https://github.com/deivishome)<br />[💻](https://github.com/snipe/snipe-it/commits?author=deivishome "Code") | [<img src="https://avatars.githubusercontent.com/u/8290389?v=4" width="110px;"/><br /><sub>andreaci</sub>](https://github.com/andreaci)<br />[💻](https://github.com/snipe/snipe-it/commits?author=andreaci "Code") | [<img src="https://avatars.githubusercontent.com/u/1828542?v=4" width="110px;"/><br /><sub>Jelle Sebreghts</sub>](http://www.jellesebreghts.be)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Jelle-S "Code") | [<img src="https://avatars.githubusercontent.com/u/11180862?v=4" width="110px;"/><br /><sub>Michael Pietsch</sub>](https://github.com/Skywalker-11)<br /> | [<img src="https://avatars.githubusercontent.com/u/22068886?v=4" width="110px;"/><br /><sub>Masudul Haque Shihab</sub>](https://github.com/sh1hab)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sh1hab "Code") | [<img src="https://avatars.githubusercontent.com/u/16099942?v=4" width="110px;"/><br /><sub>Supapong Areeprasertkul</sub>](http://www.freedomdive.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zybersup "Code") | [<img src="https://avatars.githubusercontent.com/u/207358?v=4" width="110px;"/><br /><sub>Peter Sarossy</sub>](https://github.com/psarossy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=psarossy "Code") |
| [<img src="https://avatars.githubusercontent.com/u/11823649?v=4" width="110px;"/><br /><sub>Renee Margaret McConahy</sub>](https://github.com/nepella)<br />[💻](https://github.com/snipe/snipe-it/commits?author=nepella "Code") | [<img src="https://avatars.githubusercontent.com/u/5553884?v=4" width="110px;"/><br /><sub>JohnnyPicnic</sub>](https://github.com/JohnnyPicnic)<br />[💻](https://github.com/snipe/snipe-it/commits?author=JohnnyPicnic "Code") | [<img src="https://avatars.githubusercontent.com/u/8799594?v=4" width="110px;"/><br /><sub>markbrule</sub>](https://github.com/markbrule)<br />[💻](https://github.com/snipe/snipe-it/commits?author=markbrule "Code") | [<img src="https://avatars.githubusercontent.com/u/1962801?v=4" width="110px;"/><br /><sub>Mike Campbell</sub>](https://github.com/mikecmpbll)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mikecmpbll "Code") | [<img src="https://avatars.githubusercontent.com/u/11973217?v=4" width="110px;"/><br /><sub>tbrconnect</sub>](https://github.com/tbrconnect)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tbrconnect "Code") | [<img src="https://avatars.githubusercontent.com/u/12447225?v=4" width="110px;"/><br /><sub>kcoyo</sub>](https://github.com/kcoyo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kcoyo "Code") | [<img src="https://avatars.githubusercontent.com/u/494017?v=4" width="110px;"/><br /><sub>Travis Miller</sub>](https://travismiller.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=travismiller "Code") |
| [<img src="https://avatars.githubusercontent.com/u/1975640?v=4" width="110px;"/><br /><sub>Evan Taylor</sub>](https://github.com/Delta5)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Delta5 "Code") | [<img src="https://avatars.githubusercontent.com/u/8735148?v=4" width="110px;"/><br /><sub>Petri Asikainen</sub>](https://github.com/PetriAsi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PetriAsi "Code") | [<img src="https://avatars.githubusercontent.com/u/11424540?v=4" width="110px;"/><br /><sub>derdeagle</sub>](https://github.com/derdeagle)<br />[💻](https://github.com/snipe/snipe-it/commits?author=derdeagle "Code") | [<img src="https://avatars.githubusercontent.com/u/176950?v=4" width="110px;"/><br /><sub>Mike Frysinger</sub>](https://wh0rd.org/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vapier "Code") | [<img src="https://avatars.githubusercontent.com/u/22044358?v=4" width="110px;"/><br /><sub>ALPHA</sub>](https://github.com/AL4AL)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AL4AL "Code") | [<img src="https://avatars.githubusercontent.com/u/1042587?v=4" width="110px;"/><br /><sub>FliegenKLATSCH</sub>](https://www.ifern.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FliegenKLATSCH "Code") | [<img src="https://avatars.githubusercontent.com/u/442138?v=4" width="110px;"/><br /><sub>Jeremy Price</sub>](https://github.com/jerm)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jerm "Code") |
| [<img src="https://avatars.githubusercontent.com/u/84392209?v=4" width="110px;"/><br /><sub>Toreg87</sub>](https://github.com/Toreg87)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Toreg87 "Code") | [<img src="https://avatars.githubusercontent.com/u/67638596?v=4" width="110px;"/><br /><sub>Matthew Nickson</sub>](https://github.com/Computroniks)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Computroniks "Code") | [<img src="https://avatars.githubusercontent.com/u/1646397?v=4" width="110px;"/><br /><sub>Jethro Nederhof</sub>](https://jethron.id.au)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jethron "Code") | [<img src="https://avatars.githubusercontent.com/u/23289826?v=4" width="110px;"/><br /><sub>Oskar Stenberg</sub>](https://github.com/01ste02)<br />[💻](https://github.com/snipe/snipe-it/commits?author=01ste02 "Code") | [<img src="https://avatars.githubusercontent.com/u/82208283?v=4" width="110px;"/><br /><sub>Robert-Azelis</sub>](https://github.com/Robert-Azelis)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Robert-Azelis "Code") | [<img src="https://avatars.githubusercontent.com/u/60648387?v=4" width="110px;"/><br /><sub>Alexander William Smith</sub>](https://github.com/alwism)<br />[💻](https://github.com/snipe/snipe-it/commits?author=alwism "Code") | [<img src="https://avatars.githubusercontent.com/u/24418301?v=4" width="110px;"/><br /><sub>LEITWERK AG</sub>](https://www.leitwerk.de/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=leitwerk-ag "Code") |
| [<img src="https://avatars.githubusercontent.com/u/1911435?v=4" width="110px;"/><br /><sub>Adam</sub>](http://www.aboutcher.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=adamboutcher "Code") | [<img src="https://avatars.githubusercontent.com/u/16104273?v=4" width="110px;"/><br /><sub>Ian</sub>](https://snksrv.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sneak-it "Code") | [<img src="https://avatars.githubusercontent.com/u/4023909?v=4" width="110px;"/><br /><sub>Shao Yu-Lung (Allen)</sub>](http://blog.bestlong.idv.tw/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bestlong "Code") | [<img src="https://avatars.githubusercontent.com/u/76475453?v=4" width="110px;"/><br /><sub>Haxatron</sub>](https://github.com/Haxatron)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Haxatron "Code") | [<img src="https://avatars.githubusercontent.com/u/88776392?v=4" width="110px;"/><br /><sub>PlaneNuts</sub>](https://github.com/PlaneNuts)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PlaneNuts "Code") | [<img src="https://avatars.githubusercontent.com/u/3842948?v=4" width="110px;"/><br /><sub>Bradley Coudriet</sub>](http://bjcpgd.cias.rit.edu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=exula "Code") | [<img src="https://avatars.githubusercontent.com/u/21966173?v=4" width="110px;"/><br /><sub>Dalton Durst</sub>](https://daltondur.st)<br />[💻](https://github.com/snipe/snipe-it/commits?author=UniversalSuperBox "Code") |
| [<img src="https://avatars.githubusercontent.com/u/38761237?v=4" width="110px;"/><br /><sub>Alex Janes</sub>](https://adagiohealth.org)<br />[💻](https://github.com/snipe/snipe-it/commits?author=adagioajanes "Code") | [<img src="https://avatars.githubusercontent.com/u/32387849?v=4" width="110px;"/><br /><sub>Nuraeil</sub>](https://github.com/nuraeil)<br />[💻](https://github.com/snipe/snipe-it/commits?author=nuraeil "Code") | [<img src="https://avatars.githubusercontent.com/u/48162670?v=4" width="110px;"/><br /><sub>TenOfTens</sub>](https://github.com/TenOfTens)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TenOfTens "Code") | [<img src="https://avatars.githubusercontent.com/u/9415391?v=4" width="110px;"/><br /><sub>waffle</sub>](https://ditisjens.be/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=insert-waffle "Code") | [<img src="https://avatars.githubusercontent.com/u/19945501?v=4" width="110px;"/><br /><sub>Yevhenii Huzii</sub>](https://github.com/QveenSi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=QveenSi "Code") | [<img src="https://avatars.githubusercontent.com/u/3839381?v=4" width="110px;"/><br /><sub>Achmad Fienan Rahardianto</sub>](https://github.com/veenone)<br />[💻](https://github.com/snipe/snipe-it/commits?author=veenone "Code") | [<img src="https://avatars.githubusercontent.com/u/19945501?v=4" width="110px;"/><br /><sub>Yevhenii Huzii</sub>](https://github.com/QveenSi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=QveenSi "Code") |
| [<img src="https://avatars.githubusercontent.com/u/97299851?v=4" width="110px;"/><br /><sub>Christian Weirich</sub>](https://github.com/chrisweirich)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chrisweirich "Code") | [<img src="https://avatars.githubusercontent.com/u/1294403?v=4" width="110px;"/><br /><sub>denzfarid</sub>](https://github.com/denzfarid)<br /> | [<img src="https://avatars.githubusercontent.com/u/94018771?v=4" width="110px;"/><br /><sub>ntbutler-nbcs</sub>](https://github.com/ntbutler-nbcs)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ntbutler-nbcs "Code") | [<img src="https://avatars.githubusercontent.com/u/172697?v=4" width="110px;"/><br /><sub>Naveen</sub>](https://naveensrinivasan.dev)<br />[💻](https://github.com/snipe/snipe-it/commits?author=naveensrinivasan "Code") | [<img src="https://avatars.githubusercontent.com/u/55674383?v=4" width="110px;"/><br /><sub>Mike Roquemore</sub>](https://github.com/mikeroq)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mikeroq "Code") | [<img src="https://avatars.githubusercontent.com/u/7991086?v=4" width="110px;"/><br /><sub>Daniel Reeder</sub>](https://github.com/reederda)<br />[🌍](#translation-reederda "Translation") [🌍](#translation-reederda "Translation") [💻](https://github.com/snipe/snipe-it/commits?author=reederda "Code") | [<img src="https://avatars.githubusercontent.com/u/109422491?v=4" width="110px;"/><br /><sub>vickyjaura183</sub>](https://github.com/vickyjaura183)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vickyjaura183 "Code") |
| [<img src="https://avatars.githubusercontent.com/u/32363424?v=4" width="110px;"/><br /><sub>Peace</sub>](https://github.com/julian-piehl)<br />[💻](https://github.com/snipe/snipe-it/commits?author=julian-piehl "Code") | [<img src="https://avatars.githubusercontent.com/u/231528?v=4" width="110px;"/><br /><sub>Kyle Gordon</sub>](https://github.com/kylegordon)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kylegordon "Code") | [<img src="https://avatars.githubusercontent.com/u/53009155?v=4" width="110px;"/><br /><sub>Katharina Drexel</sub>](http://www.bfh.ch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sunflowerbofh "Code") | [<img src="https://avatars.githubusercontent.com/u/1931963?v=4" width="110px;"/><br /><sub>David Sferruzza</sub>](https://david.sferruzza.fr/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dsferruzza "Code") | [<img src="https://avatars.githubusercontent.com/u/19511639?v=4" width="110px;"/><br /><sub>Rick Nelson</sub>](https://github.com/rnelsonee)<br />[💻](https://github.com/snipe/snipe-it/commits?author=rnelsonee "Code") | [<img src="https://avatars.githubusercontent.com/u/94169344?v=4" width="110px;"/><br /><sub>BasO12</sub>](https://github.com/BasO12)<br />[💻](https://github.com/snipe/snipe-it/commits?author=BasO12 "Code") | [<img src="https://avatars.githubusercontent.com/u/111710123?v=4" width="110px;"/><br /><sub>Vautia</sub>](https://github.com/Vautia)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Vautia "Code") |
| [<img src="https://avatars.githubusercontent.com/u/28321?v=4" width="110px;"/><br /><sub>Chris Hartjes</sub>](http://www.littlehart.net/atthekeyboard)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chartjes "Code") | [<img src="https://avatars.githubusercontent.com/u/2404584?v=4" width="110px;"/><br /><sub>geo-chen</sub>](https://github.com/geo-chen)<br />[💻](https://github.com/snipe/snipe-it/commits?author=geo-chen "Code") | [<img src="https://avatars.githubusercontent.com/u/6006620?v=4" width="110px;"/><br /><sub>Phan Nguyen</sub>](https://github.com/nh314)<br />[💻](https://github.com/snipe/snipe-it/commits?author=nh314 "Code") | [<img src="https://avatars.githubusercontent.com/u/115993812?v=4" width="110px;"/><br /><sub>Iisakki Jaakkola</sub>](https://github.com/StarlessNights)<br />[💻](https://github.com/snipe/snipe-it/commits?author=StarlessNights "Code") | [<img src="https://avatars.githubusercontent.com/u/22633385?v=4" width="110px;"/><br /><sub>Ikko Ashimine</sub>](https://bandism.net/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=eltociear "Code") | [<img src="https://avatars.githubusercontent.com/u/56871540?v=4" width="110px;"/><br /><sub>Lukas Fehling</sub>](https://github.com/lukasfehling)<br />[💻](https://github.com/snipe/snipe-it/commits?author=lukasfehling "Code") | [<img src="https://avatars.githubusercontent.com/u/1975990?v=4" width="110px;"/><br /><sub>Fernando Almeida</sub>](https://github.com/fernando-almeida)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fernando-almeida "Code") |
| [<img src="https://avatars.githubusercontent.com/u/116301219?v=4" width="110px;"/><br /><sub>akemidx</sub>](https://github.com/akemidx)<br />[💻](https://github.com/snipe/snipe-it/commits?author=akemidx "Code") | [<img src="https://avatars.githubusercontent.com/u/144778?v=4" width="110px;"/><br /><sub>Oguz Bilgic</sub>](http://oguz.site)<br />[💻](https://github.com/snipe/snipe-it/commits?author=oguzbilgic "Code") | [<img src="https://avatars.githubusercontent.com/u/9262438?v=4" width="110px;"/><br /><sub>Scooter Crawford</sub>](https://github.com/scoo73r)<br />[💻](https://github.com/snipe/snipe-it/commits?author=scoo73r "Code") | [<img src="https://avatars.githubusercontent.com/u/5957345?v=4" width="110px;"/><br /><sub>subdriven</sub>](https://github.com/subdriven)<br />[💻](https://github.com/snipe/snipe-it/commits?author=subdriven "Code") | [<img src="https://avatars.githubusercontent.com/u/658865?v=4" width="110px;"/><br /><sub>Andrew Savinykh</sub>](https://github.com/AndrewSav)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AndrewSav "Code") | [<img src="https://avatars.githubusercontent.com/u/1155067?v=4" width="110px;"/><br /><sub>Tadayuki Onishi</sub>](https://kenchan0130.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kenchan0130 "Code") | [<img src="https://avatars.githubusercontent.com/u/112496896?v=4" width="110px;"/><br /><sub>Florian</sub>](https://github.com/floschoepfer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=floschoepfer "Code") |
| [<img src="https://avatars.githubusercontent.com/u/7305753?v=4" width="110px;"/><br /><sub>Spencer Long</sub>](http://spencerlong.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=spencerrlongg "Code") | [<img src="https://avatars.githubusercontent.com/u/1141514?v=4" width="110px;"/><br /><sub>Marcus Moore</sub>](https://github.com/marcusmoore)<br />[💻](https://github.com/snipe/snipe-it/commits?author=marcusmoore "Code") | [<img src="https://avatars.githubusercontent.com/u/570639?v=4" width="110px;"/><br /><sub>Martin Meredith</sub>](https://github.com/Mezzle)<br /> | [<img src="https://avatars.githubusercontent.com/u/5731963?v=4" width="110px;"/><br /><sub>dboth</sub>](http://dboth.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dboth "Code") | [<img src="https://avatars.githubusercontent.com/u/87536651?v=4" width="110px;"/><br /><sub>Zachary Fleck</sub>](https://github.com/zacharyfleck)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zacharyfleck "Code") | [<img src="https://avatars.githubusercontent.com/u/74609912?v=4" width="110px;"/><br /><sub>VIKAAS-A</sub>](https://github.com/vikaas-cyper)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vikaas-cyper "Code") | [<img src="https://avatars.githubusercontent.com/u/88882041?v=4" width="110px;"/><br /><sub>Abdul Kareem</sub>](https://github.com/ak-piracha)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ak-piracha "Code") |
| [<img src="https://avatars.githubusercontent.com/u/111287779?v=4" width="110px;"/><br /><sub>NojoudAlshehri</sub>](https://github.com/NojoudAlshehri)<br />[💻](https://github.com/snipe/snipe-it/commits?author=NojoudAlshehri "Code") | [<img src="https://avatars.githubusercontent.com/u/54367449?v=4" width="110px;"/><br /><sub>Stefan Stidl</sub>](https://github.com/stefanstidlffg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=stefanstidlffg "Code") | [<img src="https://avatars.githubusercontent.com/u/87803479?v=4" width="110px;"/><br /><sub>Quentin Aymard</sub>](https://github.com/qay21)<br />[💻](https://github.com/snipe/snipe-it/commits?author=qay21 "Code") | [<img src="https://avatars.githubusercontent.com/u/5396871?v=4" width="110px;"/><br /><sub>Grant Le Roux</sub>](https://github.com/cram42)<br />[💻](https://github.com/snipe/snipe-it/commits?author=cram42 "Code") | [<img src="https://avatars.githubusercontent.com/u/58479551?v=4" width="110px;"/><br /><sub>Bogdan</sub>](http://@singrity)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Singrity "Code") | [<img src="https://avatars.githubusercontent.com/u/3483684?v=4" width="110px;"/><br /><sub>mmanjos</sub>](https://github.com/mmanjos)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mmanjos "Code") | [<img src="https://avatars.githubusercontent.com/u/7429229?v=4" width="110px;"/><br /><sub>Abdelaziz Faki</sub>](https://azooz2014.github.io/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Azooz2014 "Code") |
| [<img src="https://avatars.githubusercontent.com/u/47315739?v=4" width="110px;"/><br /><sub>bilias</sub>](https://github.com/bilias)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bilias "Code") | [<img src="https://avatars.githubusercontent.com/u/2565989?v=4" width="110px;"/><br /><sub>coach1988</sub>](https://github.com/coach1988)<br />[💻](https://github.com/snipe/snipe-it/commits?author=coach1988 "Code") | [<img src="https://avatars.githubusercontent.com/u/11910225?v=4" width="110px;"/><br /><sub>MrM</sub>](https://github.com/mauro-miatello)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mauro-miatello "Code") | [<img src="https://avatars.githubusercontent.com/u/60405354?v=4" width="110px;"/><br /><sub>koiakoia</sub>](https://github.com/koiakoia)<br />[💻](https://github.com/snipe/snipe-it/commits?author=koiakoia "Code") | [<img src="https://avatars.githubusercontent.com/u/5323832?v=4" width="110px;"/><br /><sub>Mustafa Online</sub>](https://github.com/mustafa-online)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mustafa-online "Code") | [<img src="https://avatars.githubusercontent.com/u/104601439?v=4" width="110px;"/><br /><sub>franceslui</sub>](https://github.com/franceslui)<br />[💻](https://github.com/snipe/snipe-it/commits?author=franceslui "Code") | [<img src="https://avatars.githubusercontent.com/u/125313163?v=4" width="110px;"/><br /><sub>Q4kK</sub>](https://github.com/Q4kK)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Q4kK "Code") |
| [<img src="https://avatars.githubusercontent.com/u/55590532?v=4" width="110px;"/><br /><sub>squintfox</sub>](https://github.com/squintfox)<br />[💻](https://github.com/snipe/snipe-it/commits?author=squintfox "Code") | [<img src="https://avatars.githubusercontent.com/u/1380084?v=4" width="110px;"/><br /><sub>Jeff Clay</sub>](https://github.com/jeffclay)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jeffclay "Code") | [<img src="https://avatars.githubusercontent.com/u/52716446?v=4" width="110px;"/><br /><sub>Phil J R</sub>](https://github.com/PP-JN-RL)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PP-JN-RL "Code") | [<img src="https://avatars.githubusercontent.com/u/1496725?v=4" width="110px;"/><br /><sub>i_virus</sub>](https://www.corelight.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chandanchowdhury "Code") | [<img src="https://avatars.githubusercontent.com/u/1020541?v=4" width="110px;"/><br /><sub>Paul Grime</sub>](https://github.com/gitgrimbo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gitgrimbo "Code") | [<img src="https://avatars.githubusercontent.com/u/922815?v=4" width="110px;"/><br /><sub>Lee Porte</sub>](https://leeporte.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=LeePorte "Code") | [<img src="https://avatars.githubusercontent.com/u/23613427?v=4" width="110px;"/><br /><sub>BRYAN </sub>](https://github.com/bryanlopezinc)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Code") [⚠️](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Tests") |
| [<img src="https://avatars.githubusercontent.com/u/64061710?v=4" width="110px;"/><br /><sub>U-H-T</sub>](https://github.com/U-H-T)<br />[💻](https://github.com/snipe/snipe-it/commits?author=U-H-T "Code") | [<img src="https://avatars.githubusercontent.com/u/5395363?v=4" width="110px;"/><br /><sub>Matt Tyree</sub>](https://github.com/Tyree)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Tyree "Documentation") | [<img src="https://avatars.githubusercontent.com/u/292081?v=4" width="110px;"/><br /><sub>Florent Bervas</sub>](http://spoontux.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FlorentDotMe "Code") | [<img src="https://avatars.githubusercontent.com/u/4498077?v=4" width="110px;"/><br /><sub>Daniel Albertsen</sub>](https://ditscheri.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dbakan "Code") | [<img src="https://avatars.githubusercontent.com/u/100710244?v=4" width="110px;"/><br /><sub>r-xyz</sub>](https://github.com/r-xyz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=r-xyz "Code") | [<img src="https://avatars.githubusercontent.com/u/47491036?v=4" width="110px;"/><br /><sub>Steven Mainor</sub>](https://github.com/DrekiDegga)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DrekiDegga "Code") | [<img src="https://avatars.githubusercontent.com/u/65785975?v=4" width="110px;"/><br /><sub>arne-kroeger</sub>](https://github.com/arne-kroeger)<br />[💻](https://github.com/snipe/snipe-it/commits?author=arne-kroeger "Code") |
| [<img src="https://avatars.githubusercontent.com/u/167117705?v=4" width="110px;"/><br /><sub>Glukose1</sub>](https://github.com/Glukose1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Glukose1 "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

View file

@ -105,7 +105,7 @@ RUN \
&& ln -fs "/var/lib/snipeit/keys/ldap_client_tls.cert" "/var/www/html/storage/ldap_client_tls.cert" \ && ln -fs "/var/lib/snipeit/keys/ldap_client_tls.cert" "/var/www/html/storage/ldap_client_tls.cert" \
&& ln -fs "/var/lib/snipeit/keys/ldap_client_tls.key" "/var/www/html/storage/ldap_client_tls.key" \ && ln -fs "/var/lib/snipeit/keys/ldap_client_tls.key" "/var/www/html/storage/ldap_client_tls.key" \
&& chown docker "/var/lib/snipeit/keys/" \ && chown docker "/var/lib/snipeit/keys/" \
&& chown -h docker "/var/www/html/storage/" \ && chown -Rh docker "/var/www/html/storage/" \
&& chmod +x /var/www/html/artisan \ && chmod +x /var/www/html/artisan \
&& echo "Finished setting up application in /var/www/html" && echo "Finished setting up application in /var/www/html"

View file

@ -1,34 +1,35 @@
FROM alpine:3.17.3 FROM alpine:3.19
# Apache + PHP # Apache + PHP
RUN apk add --no-cache \ RUN apk add --no-cache \
apache2 \ apache2 \
php81 \ php82 \
php81-common \ php82-common \
php81-apache2 \ php82-apache2 \
php81-curl \ php82-curl \
php81-ldap \ php82-ldap \
php81-mysqli \ php82-mysqli \
php81-gd \ php82-gd \
php81-xml \ php82-xml \
php81-mbstring \ php82-mbstring \
php81-zip \ php82-zip \
php81-ctype \ php82-ctype \
php81-tokenizer \ php82-tokenizer \
php81-pdo_mysql \ php82-pdo_mysql \
php81-openssl \ php82-openssl \
php81-bcmath \ php82-bcmath \
php81-phar \ php82-phar \
php81-json \ php82-json \
php81-iconv \ php82-iconv \
php81-fileinfo \ php82-fileinfo \
php81-simplexml \ php82-simplexml \
php81-session \ php82-session \
php81-dom \ php82-dom \
php81-xmlwriter \ php82-xmlwriter \
php81-xmlreader \ php82-xmlreader \
php81-sodium \ php82-sodium \
php81-redis \ php82-redis \
php81-pecl-memcached \ php82-pecl-memcached \
php82-exif \
curl \ curl \
wget \ wget \
vim \ vim \
@ -41,7 +42,7 @@ COPY docker/column-statistics.cnf /etc/mysql/conf.d/column-statistics.cnf
# Where apache's PID lives # Where apache's PID lives
RUN mkdir -p /run/apache2 && chown apache:apache /run/apache2 RUN mkdir -p /run/apache2 && chown apache:apache /run/apache2
RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php81/php.ini RUN sed -i 's/variables_order = .*/variables_order = "EGPCS"/' /etc/php82/php.ini
COPY docker/000-default-2.4.conf /etc/apache2/conf.d/default.conf COPY docker/000-default-2.4.conf /etc/apache2/conf.d/default.conf
# Enable mod_rewrite # Enable mod_rewrite

View file

@ -1,15 +1,18 @@
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.svg)](https://crowdin.com/project/snipe-it) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeitapp.svg?style=social)](https://twitter.com/snipeitapp) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/553ce52037fc43ea99149785afcfe641)](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=snipe/snipe-it&amp;utm_campaign=Badge_Grade) ![snipe-it-by-grok](https://github.com/snipe/snipe-it/assets/197404/b515673b-c7c8-4d9a-80f5-9fa58829a602)
[![All Contributors](https://img.shields.io/badge/all_contributors-329-orange.svg?style=flat-square)](#contributors) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/yZFtShAcKk) [![huntr](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.svg)](https://crowdin.com/project/snipe-it) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeitapp.svg?style=social)](https://twitter.com/snipeitapp) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/553ce52037fc43ea99149785afcfe641)](https://app.codacy.com/gh/snipe/snipe-it/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Tests](https://github.com/snipe/snipe-it/actions/workflows/tests.yml/badge.svg)](https://github.com/snipe/snipe-it/actions/workflows/tests.yml)
[![All Contributors](https://img.shields.io/badge/all_contributors-331-orange.svg?style=flat-square)](#contributing) [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/yZFtShAcKk)
## Snipe-IT - Open Source Asset Management System ## Snipe-IT - Open Source Asset Management System
This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc. This is a FOSS project for asset management in IT Operations. Knowing who has which laptop, when it was purchased in order to depreciate it correctly, handling software licenses, etc.
It is built on [Laravel 8](http://laravel.com). It is built on [Laravel 10](http://laravel.com).
Snipe-IT is actively developed and we [release quite frequently](https://github.com/snipe/snipe-it/releases). ([Check out the live demo here](https://snipeitapp.com/demo/).) Snipe-IT is actively developed and we [release quite frequently](https://github.com/snipe/snipe-it/releases). ([Check out the live demo here](https://snipeitapp.com/demo/).)
__This is web-based software__. This means there is no executable file (aka no .exe files), and it must be run on a web server and accessed through a web browser. It runs on any Mac OSX, flavor of Linux, as well as Windows, and we have a [Docker image](https://snipe-it.readme.io/docs/docker) available if that's what you're into. > [!TIP]
> __This is web-based software__. This means there is no executable file (aka no .exe files), and it must be run on a web server and accessed through a web browser. It runs on any Mac OSX, any flavor of Linux, as well as Windows, and we have a [Docker image](https://snipe-it.readme.io/docs/docker) available if that's what you're into.
----- -----
@ -19,7 +22,7 @@ For instructions on installing and configuring Snipe-IT on your server, check ou
If you're having trouble with the installation, please check the [Common Issues](https://snipe-it.readme.io/docs/common-issues) and [Getting Help](https://snipe-it.readme.io/docs/getting-help) documentation, and search this repository's open *and* closed issues for help. If you're having trouble with the installation, please check the [Common Issues](https://snipe-it.readme.io/docs/common-issues) and [Getting Help](https://snipe-it.readme.io/docs/getting-help) documentation, and search this repository's open *and* closed issues for help.
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) <!-- [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) -->
----- -----
### User's Manual ### User's Manual
@ -30,8 +33,9 @@ For help using Snipe-IT, check out the [user's manual](https://snipe-it.readme.i
Feel free to check out the [GitHub Issues for this project](https://github.com/snipe/snipe-it/issues) to open a bug report or see what open issues you can help with. Please search through existing issues (open *and* closed) to see if your question has already been answered before opening a new issue. Feel free to check out the [GitHub Issues for this project](https://github.com/snipe/snipe-it/issues) to open a bug report or see what open issues you can help with. Please search through existing issues (open *and* closed) to see if your question has already been answered before opening a new issue.
**PLEASE see the [Getting Help Guidelines](https://snipe-it.readme.io/docs/getting-help) and [Common Issues](https://snipe-it.readme.io/docs/common-issues) before opening a ticket, and be sure to complete all of the questions in the Github Issue template to help us to help you as quickly as possible.** > [!IMPORTANT]
> **PLEASE see the [Getting Help Guidelines](https://snipe-it.readme.io/docs/getting-help) and [Common Issues](https://snipe-it.readme.io/docs/common-issues) before opening a ticket, and be sure to complete all of the questions in the Github Issue template to help us to help you as quickly as possible.**
>
----- -----
### Upgrading ### Upgrading
@ -55,6 +59,9 @@ Please see the [translations documentation](https://snipe-it.readme.io/docs/tran
Since the release of the JSON REST API, several third-party developers have been developing modules and libraries to work with Snipe-IT. Since the release of the JSON REST API, several third-party developers have been developing modules and libraries to work with Snipe-IT.
> [!NOTE]
> As these were created by third-parties, Snipe-IT cannot provide support for these project, and you should contact the developers directly if you need assistance. Additionally, Snipe-IT makes no guarantees as to the reliability, accuracy or maintainability of these libraries. Use at your own risk. :)
- [Python Module](https://github.com/jbloomer/SnipeIT-PythonAPI) by [@jbloomer](https://github.com/jbloomer) - [Python Module](https://github.com/jbloomer/SnipeIT-PythonAPI) by [@jbloomer](https://github.com/jbloomer)
- [SnipeSharp - .NET module in C#](https://github.com/barrycarey/SnipeSharp) by [@barrycarey](https://github.com/barrycarey) - [SnipeSharp - .NET module in C#](https://github.com/barrycarey/SnipeSharp) by [@barrycarey](https://github.com/barrycarey)
- [InQRy -unmaintained-](https://github.com/Microsoft/InQRy) by [@Microsoft](https://github.com/Microsoft) - [InQRy -unmaintained-](https://github.com/Microsoft/InQRy) by [@Microsoft](https://github.com/Microsoft)
@ -65,14 +72,13 @@ Since the release of the JSON REST API, several third-party developers have been
- [Snipe-IT plugin for Jira Service Desk](https://marketplace.atlassian.com/apps/1220964/snipe-it-for-jira) - [Snipe-IT plugin for Jira Service Desk](https://marketplace.atlassian.com/apps/1220964/snipe-it-for-jira)
- [Python 3 CSV importer](https://github.com/gastamper/snipeit-csvimporter) - allows importing assets into Snipe-IT based on Item Name rather than Asset Tag. - [Python 3 CSV importer](https://github.com/gastamper/snipeit-csvimporter) - allows importing assets into Snipe-IT based on Item Name rather than Asset Tag.
- [Snipe-IT Kubernetes Helm Chart](https://github.com/t3n/helm-charts/tree/master/snipeit) - For more information, [click here](https://hub.helm.sh/charts/t3n/snipeit). - [Snipe-IT Kubernetes Helm Chart](https://github.com/t3n/helm-charts/tree/master/snipeit) - For more information, [click here](https://hub.helm.sh/charts/t3n/snipeit).
- [Snipe-IT Bulk Edit](https://github.com/bricelabelle/snipe-it-bulkedit) - Google Script files to use Google Sheets as a bulk checkout/checkin/edit tool for Snipe-it. - [Snipe-IT Bulk Edit](https://github.com/bricelabelle/snipe-it-bulkedit) - Google Script files to use Google Sheets as a bulk checkout/checkin/edit tool for Snipe-IT.
- [MosyleSnipeSync](https://github.com/RodneyLeeBrands/MosyleSnipeSync) by [@Karpadiem](https://github.com/Karpadiem) - Python script to synchronize information between Mosyle and Snipe-IT - [MosyleSnipeSync](https://github.com/RodneyLeeBrands/MosyleSnipeSync) by [@Karpadiem](https://github.com/Karpadiem) - Python script to synchronize information between Mosyle and Snipe-IT.
- [WWW::SnipeIT](https://github.com/SEDC/perl-www-snipeit) by [@SEDC](https://github.com/SEDC) - perl module for accessing the API - [WWW::SnipeIT](https://github.com/SEDC/perl-www-snipeit) by [@SEDC](https://github.com/SEDC) - perl module for accessing the API
- [UniFi to Snipe-IT](https://github.com/RodneyLeeBrands/UnifiSnipeSync) by [@karpadiem](https://github.com/karpadiem) - Python script that synchronizes UniFi devices with Snipe-IT. - [UniFi to Snipe-IT](https://github.com/RodneyLeeBrands/UnifiSnipeSync) by [@karpadiem](https://github.com/karpadiem) - Python script that synchronizes UniFi devices with Snipe-IT.
- [Kandji2Snipe](https://github.com/grokability/kandji2snipe) by [@briangoldstein](https://github.com/briangoldstein) - Python script that synchronizes Kandji with Snipe-IT. - [Kandji2Snipe](https://github.com/grokability/kandji2snipe) by [@briangoldstein](https://github.com/briangoldstein) - Python script that synchronizes Kandji with Snipe-IT.
- [SnipeAgent](https://github.com/ReticentRobot/SnipeAgent) by @ReticentRobot - Windows agent for Snipe-IT - [SnipeAgent](https://github.com/ReticentRobot/SnipeAgent) by [@ReticentRobot](https://github.com/ReticentRobot) - Windows agent for Snipe-IT.
- [Gate Pass Generator](https://github.com/cha7uraAE/snipe-it-gate-pass-system) by [@cha7uraAE](https://github.com/cha7uraAE) - A Streamlit application for generating gate passes based on hardware data from a Snipe-IT API.
As these were created by third-parties, Snipe-IT cannot provide support for these project, and you should contact the developers directly if you need assistance. Additionally, Snipe-IT makes no guarantees as to the reliability, accuracy or maintainability of these libraries. Use at your own risk. :)
----- -----
@ -80,73 +86,15 @@ As these were created by third-parties, Snipe-IT cannot provide support for thes
Please see the documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing-overview). Please see the documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing-overview).
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
The ERD is available [online here](https://drawsql.app/templates/snipe-it). The ERD is available [online here](https://drawsql.app/templates/snipe-it).
[Here is a list](CONTRIBUTORS.md) of the wonderful people that have contributed to the Snipe-IT.
----- -----
### Security ### Security
To report a security vulnerability, please email security@snipeitapp.com instead of using the issue tracker. > [!IMPORTANT]
> **To report a security vulnerability, please email security@snipeitapp.com instead of using the issue tracker.**
-----
### Contributors
Thanks goes to all of these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)) who have helped Snipe-IT get this far:
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars3.githubusercontent.com/u/197404?v=3" width="110px;"/><br /><sub>snipe</sub>](http://www.snipe.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=snipe "Code") [🚇](#infra-snipe "Infrastructure (Hosting, Build-Tools, etc)") [📖](https://github.com/snipe/snipe-it/commits?author=snipe "Documentation") [⚠️](https://github.com/snipe/snipe-it/commits?author=snipe "Tests") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3Asnipe "Bug reports") [🎨](#design-snipe "Design") [👀](#review-snipe "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/36335?v=3" width="110px;"/><br /><sub>Brady Wetherington</sub>](http://www.uberbrady.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=uberbrady "Code") [📖](https://github.com/snipe/snipe-it/commits?author=uberbrady "Documentation") [🚇](#infra-uberbrady "Infrastructure (Hosting, Build-Tools, etc)") [👀](#review-uberbrady "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3803132?v=3" width="110px;"/><br /><sub>Daniel Meltzer</sub>](https://github.com/dmeltzer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dmeltzer "Code") [⚠️](https://github.com/snipe/snipe-it/commits?author=dmeltzer "Tests") [📖](https://github.com/snipe/snipe-it/commits?author=dmeltzer "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1609106?v=3" width="110px;"/><br /><sub>Michael T</sub>](http://www.tuckertechonline.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mtucker6784 "Code") | [<img src="https://avatars2.githubusercontent.com/u/3274937?v=3" width="110px;"/><br /><sub>madd15</sub>](https://github.com/madd15)<br />[📖](https://github.com/snipe/snipe-it/commits?author=madd15 "Documentation") [💬](#question-madd15 "Answering Questions") | [<img src="https://avatars2.githubusercontent.com/u/894126?v=3" width="110px;"/><br /><sub>Vincent Sposato</sub>](https://github.com/vsposato)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vsposato "Code") | [<img src="https://avatars0.githubusercontent.com/u/1639757?v=3" width="110px;"/><br /><sub>Andrea Bergamasco</sub>](https://github.com/vjandrea)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vjandrea "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars0.githubusercontent.com/u/10640152?v=3" width="110px;"/><br /><sub>Karol</sub>](https://github.com/kpawelski)<br />[🌍](#translation-kpawelski "Translation") [💻](https://github.com/snipe/snipe-it/commits?author=kpawelski "Code") | [<img src="https://avatars3.githubusercontent.com/u/600106?v=3" width="110px;"/><br /><sub>morph027</sub>](http://blog.morph027.de/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=morph027 "Code") | [<img src="https://avatars3.githubusercontent.com/u/22935755?v=3" width="110px;"/><br /><sub>fvleminckx</sub>](https://github.com/fvleminckx)<br />[🚇](#infra-fvleminckx "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars2.githubusercontent.com/u/15633547?v=3" width="110px;"/><br /><sub>itsupportcmsukorg</sub>](https://github.com/itsupportcmsukorg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=itsupportcmsukorg "Code") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3Aitsupportcmsukorg "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/12373799?v=3" width="110px;"/><br /><sub>Frank</sub>](https://override.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=base-zero "Code") | [<img src="https://avatars0.githubusercontent.com/u/10137?v=3" width="110px;"/><br /><sub>Deleted user</sub>](https://github.com/ghost)<br />[🌍](#translation-ghost "Translation") [💻](https://github.com/snipe/snipe-it/commits?author=ghost "Code") | [<img src="https://avatars1.githubusercontent.com/u/10802313?v=3" width="110px;"/><br /><sub>tiagom62</sub>](https://github.com/tiagom62)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tiagom62 "Code") [🚇](#infra-tiagom62 "Infrastructure (Hosting, Build-Tools, etc)") |
| [<img src="https://avatars3.githubusercontent.com/u/2389047?v=3" width="110px;"/><br /><sub>Ryan Stafford</sub>](https://github.com/rystaf)<br />[💻](https://github.com/snipe/snipe-it/commits?author=rystaf "Code") | [<img src="https://avatars2.githubusercontent.com/u/10345935?v=3" width="110px;"/><br /><sub>Eammon Hanlon</sub>](https://github.com/ehanlon)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ehanlon "Code") | [<img src="https://avatars0.githubusercontent.com/u/441924?v=3" width="110px;"/><br /><sub>zjean</sub>](https://github.com/zjean)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zjean "Code") | [<img src="https://avatars0.githubusercontent.com/u/12660103?v=3" width="110px;"/><br /><sub>Matthias Frei</sub>](http://www.frei.media)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FREImedia "Code") | [<img src="https://avatars0.githubusercontent.com/u/3767518?v=3" width="110px;"/><br /><sub>opsydev</sub>](https://github.com/opsydev)<br />[💻](https://github.com/snipe/snipe-it/commits?author=opsydev "Code") | [<img src="https://avatars1.githubusercontent.com/u/82290?v=3" width="110px;"/><br /><sub>Daniel Dreier</sub>](http://www.ddreier.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ddreier "Code") | [<img src="https://avatars0.githubusercontent.com/u/23448?v=3" width="110px;"/><br /><sub>Nikolai Prokoschenko</sub>](http://rassie.org)<br />[💻](https://github.com/snipe/snipe-it/commits?author=rassie "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/13452757?v=3" width="110px;"/><br /><sub>Drew</sub>](https://github.com/YetAnotherCodeMonkey)<br />[💻](https://github.com/snipe/snipe-it/commits?author=YetAnotherCodeMonkey "Code") | [<img src="https://avatars0.githubusercontent.com/u/1342320?v=3" width="110px;"/><br /><sub>Walter</sub>](https://github.com/merid14)<br />[💻](https://github.com/snipe/snipe-it/commits?author=merid14 "Code") | [<img src="https://avatars3.githubusercontent.com/u/11254614?v=3" width="110px;"/><br /><sub>Petr Baloun</sub>](https://github.com/balous)<br />[💻](https://github.com/snipe/snipe-it/commits?author=balous "Code") | [<img src="https://avatars0.githubusercontent.com/u/6117660?v=3" width="110px;"/><br /><sub>reidblomquist</sub>](https://github.com/reidblomquist)<br />[📖](https://github.com/snipe/snipe-it/commits?author=reidblomquist "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/539914?v=3" width="110px;"/><br /><sub>Mathieu Kooiman</sub>](https://github.com/mathieuk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mathieuk "Code") | [<img src="https://avatars3.githubusercontent.com/u/6606421?v=3" width="110px;"/><br /><sub>csayre</sub>](https://github.com/csayre)<br />[📖](https://github.com/snipe/snipe-it/commits?author=csayre "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/768488?v=3" width="110px;"/><br /><sub>Adam Dunson</sub>](https://github.com/adamdunson)<br />[💻](https://github.com/snipe/snipe-it/commits?author=adamdunson "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/5547470?v=3" width="110px;"/><br /><sub>Hereward</sub>](https://github.com/thehereward)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thehereward "Code") | [<img src="https://avatars0.githubusercontent.com/u/5802977?v=3" width="110px;"/><br /><sub>swoopdk</sub>](https://github.com/swoopdk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=swoopdk "Code") | [<img src="https://avatars1.githubusercontent.com/u/3470403?v=3" width="110px;"/><br /><sub>Abdullah Alansari</sub>](https://linkedin.com/in/ahimta)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Ahimta "Code") | [<img src="https://avatars0.githubusercontent.com/u/796443?v=3" width="110px;"/><br /><sub>Micael Rodrigues</sub>](https://github.com/MicaelRodrigues)<br />[💻](https://github.com/snipe/snipe-it/commits?author=MicaelRodrigues "Code") | [<img src="https://avatars0.githubusercontent.com/u/614564?v=3" width="110px;"/><br /><sub>Patrick Gallagher</sub>](http://macadmincorner.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=patgmac "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/7165922?v=3" width="110px;"/><br /><sub>Miliamber</sub>](https://github.com/Miliamber)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Miliamber "Code") | [<img src="https://avatars3.githubusercontent.com/u/861766?v=3" width="110px;"/><br /><sub>hawk554</sub>](https://github.com/hawk554)<br />[💻](https://github.com/snipe/snipe-it/commits?author=hawk554 "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/1695622?v=3" width="110px;"/><br /><sub>Justin Kerr</sub>](http://jbirdkerr.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jbirdkerr "Code") | [<img src="https://avatars3.githubusercontent.com/u/11426176?v=3" width="110px;"/><br /><sub>Ira W. Snyder</sub>](http://www.irasnyder.com/devel/)<br />[📖](https://github.com/snipe/snipe-it/commits?author=irasnyd "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/2475759?v=3" width="110px;"/><br /><sub>Aladin Alaily</sub>](https://github.com/aalaily)<br />[💻](https://github.com/snipe/snipe-it/commits?author=aalaily "Code") | [<img src="https://avatars0.githubusercontent.com/u/10247644?v=3" width="110px;"/><br /><sub>Chase Hansen</sub>](https://github.com/kobie-chasehansen)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kobie-chasehansen "Code") [💬](#question-kobie-chasehansen "Answering Questions") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3Akobie-chasehansen "Bug reports") | [<img src="https://avatars2.githubusercontent.com/u/13545400?v=3" width="110px;"/><br /><sub>IDM Helpdesk</sub>](https://github.com/IDM-Helpdesk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=IDM-Helpdesk "Code") | [<img src="https://avatars2.githubusercontent.com/u/614439?v=3" width="110px;"/><br /><sub>Kai</sub>](http://balticer.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=balticer "Code") | [<img src="https://avatars1.githubusercontent.com/u/8762511?v=3" width="110px;"/><br /><sub>Michael Daniels</sub>](http://www.michaeldaniels.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mdaniels5757 "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/1532660?v=3" width="110px;"/><br /><sub>Tom Castleman</sub>](http://tomcastleman.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tomcastleman "Code") | [<img src="https://avatars3.githubusercontent.com/u/10723243?v=3" width="110px;"/><br /><sub>Daniel Nemanic</sub>](https://github.com/DanielNemanic)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DanielNemanic "Code") | [<img src="https://avatars0.githubusercontent.com/u/150648?v=3" width="110px;"/><br /><sub>SouthWolf</sub>](https://github.com/southwolf)<br />[💻](https://github.com/snipe/snipe-it/commits?author=southwolf "Code") | [<img src="https://avatars2.githubusercontent.com/u/131616?v=3" width="110px;"/><br /><sub>Ivar Nesje</sub>](https://github.com/ivarne)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ivarne "Code") | [<img src="https://avatars1.githubusercontent.com/u/62333?v=3" width="110px;"/><br /><sub>Jérémy Benoist</sub>](http://www.j0k3r.net)<br />[📖](https://github.com/snipe/snipe-it/commits?author=j0k3r "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/724344?v=3" width="110px;"/><br /><sub>Chris Leathley</sub>](https://github.com/cleathley)<br />[🚇](#infra-cleathley "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars0.githubusercontent.com/u/972498?v=3" width="110px;"/><br /><sub>splaer</sub>](https://github.com/splaer)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Asplaer "Bug reports") [💻](https://github.com/snipe/snipe-it/commits?author=splaer "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/967362?v=3" width="110px;"/><br /><sub>Joe Ferguson</sub>](http://www.joeferguson.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=svpernova09 "Code") | [<img src="https://avatars3.githubusercontent.com/u/6108682?v=3" width="110px;"/><br /><sub>diwanicki</sub>](https://github.com/diwanicki)<br />[💻](https://github.com/snipe/snipe-it/commits?author=diwanicki "Code") [📖](https://github.com/snipe/snipe-it/commits?author=diwanicki "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/2527115?v=3" width="110px;"/><br /><sub>Lee Thoong Ching</sub>](https://github.com/pakkua80)<br />[📖](https://github.com/snipe/snipe-it/commits?author=pakkua80 "Documentation") [💻](https://github.com/snipe/snipe-it/commits?author=pakkua80 "Code") | [<img src="https://avatars1.githubusercontent.com/u/461491?v=3" width="110px;"/><br /><sub>Marek Šuppa</sub>](http://shu.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mrshu "Code") | [<img src="https://avatars1.githubusercontent.com/u/8693762?v=3" width="110px;"/><br /><sub>Juan J. Martinez</sub>](https://github.com/mizar1616)<br />[🌍](#translation-mizar1616 "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1458388?v=3" width="110px;"/><br /><sub>R Ryan Dial</sub>](https://github.com/rrdial)<br />[🌍](#translation-rrdial "Translation") | [<img src="https://avatars2.githubusercontent.com/u/2871745?v=3" width="110px;"/><br /><sub>Andrej Manduch</sub>](https://github.com/burlito)<br />[📖](https://github.com/snipe/snipe-it/commits?author=burlito "Documentation") |
| [<img src="https://avatars0.githubusercontent.com/u/8341172?v=3" width="110px;"/><br /><sub>Jay Richards</sub>](http://www.cordeos.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=technogenus "Code") | [<img src="https://avatars2.githubusercontent.com/u/7295127?v=3" width="110px;"/><br /><sub>Alexander Innes</sub>](https://necurity.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=leostat "Code") | [<img src="https://avatars2.githubusercontent.com/u/334485?v=3" width="110px;"/><br /><sub>Danny Garcia</sub>](https://buzzedword.codes)<br />[💻](https://github.com/snipe/snipe-it/commits?author=buzzedword "Code") | [<img src="https://avatars2.githubusercontent.com/u/366855?v=3" width="110px;"/><br /><sub>archpoint</sub>](https://github.com/archpoint)<br />[💻](https://github.com/snipe/snipe-it/commits?author=archpoint "Code") | [<img src="https://avatars1.githubusercontent.com/u/67991?v=3" width="110px;"/><br /><sub>Jake McGraw</sub>](http://www.jakemcgraw.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jakemcgraw "Code") | [<img src="https://avatars1.githubusercontent.com/u/1714374?v=3" width="110px;"/><br /><sub>FleischKarussel</sub>](https://github.com/FleischKarussel)<br />[📖](https://github.com/snipe/snipe-it/commits?author=FleischKarussel "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/319644?v=3" width="110px;"/><br /><sub>Dylan Yi</sub>](https://github.com/feeva)<br />[💻](https://github.com/snipe/snipe-it/commits?author=feeva "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/857740?v=3" width="110px;"/><br /><sub>Gil Rutkowski</sub>](http://FlashingCursor.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=flashingcursor "Code") | [<img src="https://avatars3.githubusercontent.com/u/129360?v=3" width="110px;"/><br /><sub>Desmond Morris</sub>](http://www.desmondmorris.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=desmondmorris "Code") | [<img src="https://avatars2.githubusercontent.com/u/52936?v=3" width="110px;"/><br /><sub>Nick Peelman</sub>](http://peelman.us)<br />[💻](https://github.com/snipe/snipe-it/commits?author=peelman "Code") | [<img src="https://avatars0.githubusercontent.com/u/53161?v=3" width="110px;"/><br /><sub>Abraham Vegh</sub>](https://abrahamvegh.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=abrahamvegh "Code") | [<img src="https://avatars0.githubusercontent.com/u/2818680?v=3" width="110px;"/><br /><sub>Mohamed Rashid</sub>](https://github.com/rashivkp)<br />[📖](https://github.com/snipe/snipe-it/commits?author=rashivkp "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1509456?v=3" width="110px;"/><br /><sub>Kasey</sub>](http://hinchk.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=HinchK "Code") | [<img src="https://avatars2.githubusercontent.com/u/10522541?v=3" width="110px;"/><br /><sub>Brett</sub>](https://github.com/BrettFagerlund)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=BrettFagerlund "Tests") |
| [<img src="https://avatars2.githubusercontent.com/u/16108587?v=3" width="110px;"/><br /><sub>Jason Spriggs</sub>](http://jasonspriggs.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonspriggs "Code") | [<img src="https://avatars2.githubusercontent.com/u/1134568?v=3" width="110px;"/><br /><sub>Nate Felton</sub>](http://n8felton.wordpress.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=n8felton "Code") | [<img src="https://avatars2.githubusercontent.com/u/14036694?v=3" width="110px;"/><br /><sub>Manasses Ferreira</sub>](http://homepages.dcc.ufmg.br/~manassesferreira)<br />[💻](https://github.com/snipe/snipe-it/commits?author=manassesferreira "Code") | [<img src="https://avatars0.githubusercontent.com/u/15913949?v=3" width="110px;"/><br /><sub>Steve</sub>](https://github.com/steveelwood)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=steveelwood "Tests") | [<img src="https://avatars1.githubusercontent.com/u/3361683?v=3" width="110px;"/><br /><sub>matc</sub>](http://twitter.com/matc)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=matc "Tests") | [<img src="https://avatars3.githubusercontent.com/u/7405702?v=3" width="110px;"/><br /><sub>Cole R. Davis</sub>](http://www.davisracingteam.com)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=VanillaNinjaD "Tests") | [<img src="https://avatars2.githubusercontent.com/u/10167681?v=3" width="110px;"/><br /><sub>gibsonjoshua55</sub>](https://github.com/gibsonjoshua55)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gibsonjoshua55 "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/2809241?v=4" width="110px;"/><br /><sub>Robin Temme</sub>](https://github.com/zwerch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zwerch "Code") | [<img src="https://avatars0.githubusercontent.com/u/6961695?v=4" width="110px;"/><br /><sub>Iman</sub>](https://github.com/imanghafoori1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=imanghafoori1 "Code") | [<img src="https://avatars1.githubusercontent.com/u/6551003?v=4" width="110px;"/><br /><sub>Richard Hofman</sub>](https://github.com/richardhofman6)<br />[💻](https://github.com/snipe/snipe-it/commits?author=richardhofman6 "Code") | [<img src="https://avatars0.githubusercontent.com/u/3697569?v=4" width="110px;"/><br /><sub>gizzmojr</sub>](https://github.com/gizzmojr)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gizzmojr "Code") | [<img src="https://avatars3.githubusercontent.com/u/404729?v=4" width="110px;"/><br /><sub>Jenny Li</sub>](https://github.com/imjennyli)<br />[📖](https://github.com/snipe/snipe-it/commits?author=imjennyli "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/869227?v=4" width="110px;"/><br /><sub>Geoff Young</sub>](https://github.com/GeoffYoung)<br />[💻](https://github.com/snipe/snipe-it/commits?author=GeoffYoung "Code") | [<img src="https://avatars3.githubusercontent.com/u/1068477?v=4" width="110px;"/><br /><sub>Elliot Blackburn</sub>](http://www.elliotblackburn.com)<br />[📖](https://github.com/snipe/snipe-it/commits?author=BlueHatbRit "Documentation") |
| [<img src="https://avatars1.githubusercontent.com/u/6357451?v=4" width="110px;"/><br /><sub>Tõnis Ormisson</sub>](http://andmemasin.eu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TonisOrmisson "Code") | [<img src="https://avatars0.githubusercontent.com/u/449411?v=4" width="110px;"/><br /><sub>Nicolai Essig</sub>](http://www.nicolai-essig.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thakilla "Code") | [<img src="https://avatars1.githubusercontent.com/u/14809698?v=4" width="110px;"/><br /><sub>Danielle</sub>](https://github.com/techincolor)<br />[📖](https://github.com/snipe/snipe-it/commits?author=techincolor "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/18545156?v=4" width="110px;"/><br /><sub>Lawrence</sub>](https://github.com/TheVakman)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=TheVakman "Tests") [🐛](https://github.com/snipe/snipe-it/issues?q=author%3ATheVakman "Bug reports") | [<img src="https://avatars1.githubusercontent.com/u/22473767?v=4" width="110px;"/><br /><sub>uknzaeinozpas</sub>](https://github.com/uknzaeinozpas)<br />[⚠️](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Tests") [💻](https://github.com/snipe/snipe-it/commits?author=uknzaeinozpas "Code") | [<img src="https://avatars3.githubusercontent.com/u/422752?v=4" width="110px;"/><br /><sub>Ryan</sub>](https://github.com/Gelob)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Gelob "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/10672546?v=4" width="110px;"/><br /><sub>vcordes79</sub>](https://github.com/vcordes79)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vcordes79 "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/27958330?v=4" width="110px;"/><br /><sub>fordster78</sub>](https://github.com/fordster78)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fordster78 "Code") | [<img src="https://avatars0.githubusercontent.com/u/34064225?v=4" width="110px;"/><br /><sub>CronKz</sub>](https://github.com/CronKz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=CronKz "Code") [🌍](#translation-CronKz "Translation") | [<img src="https://avatars1.githubusercontent.com/u/585486?v=4" width="110px;"/><br /><sub>Tim Bishop</sub>](https://github.com/tdb)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tdb "Code") | [<img src="https://avatars2.githubusercontent.com/u/5384694?v=4" width="110px;"/><br /><sub>Sean McIlvenna</sub>](https://www.seanmcilvenna.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=seanmcilvenna "Code") | [<img src="https://avatars3.githubusercontent.com/u/36515590?v=4" width="110px;"/><br /><sub>cepacs</sub>](https://github.com/cepacs)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Acepacs "Bug reports") [📖](https://github.com/snipe/snipe-it/commits?author=cepacs "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/37537300?v=4" width="110px;"/><br /><sub>lea-mink</sub>](https://github.com/lea-mink)<br />[💻](https://github.com/snipe/snipe-it/commits?author=lea-mink "Code") | [<img src="https://avatars0.githubusercontent.com/u/7140719?v=4" width="110px;"/><br /><sub>Hannah Tinkler</sub>](https://github.com/hannahtinkler)<br />[💻](https://github.com/snipe/snipe-it/commits?author=hannahtinkler "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/1086388?v=4" width="110px;"/><br /><sub>Doeke Zanstra</sub>](https://github.com/doekman)<br />[💻](https://github.com/snipe/snipe-it/commits?author=doekman "Code") | [<img src="https://avatars1.githubusercontent.com/u/4325936?v=4" width="110px;"/><br /><sub>Djamon Staal</sub>](https://www.sdhd.nl/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=SjamonDaal "Code") | [<img src="https://avatars3.githubusercontent.com/u/12306859?v=4" width="110px;"/><br /><sub>Earl Ramirez</sub>](https://github.com/EarlRamirez)<br />[💻](https://github.com/snipe/snipe-it/commits?author=EarlRamirez "Code") | [<img src="https://avatars2.githubusercontent.com/u/8671456?v=4" width="110px;"/><br /><sub>Richard Ray Thomas</sub>](https://github.com/RichardRay)<br />[💻](https://github.com/snipe/snipe-it/commits?author=RichardRay "Code") | [<img src="https://avatars3.githubusercontent.com/u/1852688?v=4" width="110px;"/><br /><sub>Ryan Kuba</sub>](https://www.taisun.io/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=thelamer "Code") | [<img src="https://avatars1.githubusercontent.com/u/6751928?v=4" width="110px;"/><br /><sub>Brian Monroe</sub>](https://github.com/ParadoxGuitarist)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ParadoxGuitarist "Code") | [<img src="https://avatars1.githubusercontent.com/u/605167?v=4" width="110px;"/><br /><sub>plexorama</sub>](https://github.com/plexorama)<br />[💻](https://github.com/snipe/snipe-it/commits?author=plexorama "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/1795149?v=4" width="110px;"/><br /><sub>Till Deeke</sub>](https://tilldeeke.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tilldeeke "Code") | [<img src="https://avatars0.githubusercontent.com/u/12634129?v=4" width="110px;"/><br /><sub>5quirrel</sub>](https://github.com/5quirrel)<br />[💻](https://github.com/snipe/snipe-it/commits?author=5quirrel "Code") | [<img src="https://avatars1.githubusercontent.com/u/13071957?v=4" width="110px;"/><br /><sub>Jason</sub>](https://github.com/jasonlshelton)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jasonlshelton "Code") | [<img src="https://avatars3.githubusercontent.com/u/7128321?v=4" width="110px;"/><br /><sub>Antti</sub>](https://github.com/chemfy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chemfy "Code") | [<img src="https://avatars3.githubusercontent.com/u/10080364?v=4" width="110px;"/><br /><sub>DeusMaximus</sub>](https://github.com/DeusMaximus)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DeusMaximus "Code") | [<img src="https://avatars2.githubusercontent.com/u/16384611?v=4" width="110px;"/><br /><sub>a-royal</sub>](https://github.com/A-ROYAL)<br />[🌍](#translation-A-ROYAL "Translation") | [<img src="https://avatars0.githubusercontent.com/u/5358208?v=4" width="110px;"/><br /><sub>Alberto Aldrigo</sub>](https://github.com/albertoaldrigo)<br />[🌍](#translation-albertoaldrigo "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/1412342?v=4" width="110px;"/><br /><sub>Alex Stanev</sub>](http://alex.stanev.org/blog)<br />[🌍](#translation-RealEnder "Translation") | [<img src="https://avatars0.githubusercontent.com/u/177295?v=4" width="110px;"/><br /><sub>Andreas Rehm</sub>](http://devel.itsolution2.de)<br />[🌍](#translation-sirrus "Translation") | [<img src="https://avatars0.githubusercontent.com/u/5080535?v=4" width="110px;"/><br /><sub>Andreas Erhard</sub>](https://github.com/xelan)<br />[🌍](#translation-xelan "Translation") | [<img src="https://avatars2.githubusercontent.com/u/142350?v=4" width="110px;"/><br /><sub>Andrés Vanegas Jiménez</sub>](https://github.com/angeldeejay)<br />[🌍](#translation-angeldeejay "Translation") | [<img src="https://avatars0.githubusercontent.com/u/3910403?v=4" width="110px;"/><br /><sub>Antonio Schiavon</sub>](https://github.com/aschiavon91)<br />[🌍](#translation-aschiavon91 "Translation") | [<img src="https://avatars0.githubusercontent.com/u/10464547?v=4" width="110px;"/><br /><sub>benunter</sub>](https://github.com/benunter)<br />[🌍](#translation-benunter "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5038647?v=4" width="110px;"/><br /><sub>Borys Żmuda</sub>](http://catweb24.pl)<br />[🌍](#translation-rudashi "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/5539359?v=4" width="110px;"/><br /><sub>chibacityblues</sub>](https://github.com/chibacityblues)<br />[🌍](#translation-chibacityblues "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1954830?v=4" width="110px;"/><br /><sub>Chien Wei Lin</sub>](https://github.com/cwlin0416)<br />[🌍](#translation-cwlin0416 "Translation") | [<img src="https://avatars3.githubusercontent.com/u/11700533?v=4" width="110px;"/><br /><sub>Christian Schuster</sub>](https://github.com/Againstreality)<br />[🌍](#translation-Againstreality "Translation") | [<img src="https://avatars1.githubusercontent.com/u/4308704?v=4" width="110px;"/><br /><sub>Christian Stefanus</sub>](http://chriss.webhostid.com)<br />[🌍](#translation-kopi-item "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3009327?v=4" width="110px;"/><br /><sub>wxcafé</sub>](http://wxcafe.net)<br />[🌍](#translation-wxcafe "Translation") | [<img src="https://avatars3.githubusercontent.com/u/35761525?v=4" width="110px;"/><br /><sub>dpyroc</sub>](https://github.com/dpyroc)<br />[🌍](#translation-dpyroc "Translation") | [<img src="https://avatars1.githubusercontent.com/u/2153639?v=4" width="110px;"/><br /><sub>Daniel Friedlmaier</sub>](http://www.friedlmaier.net)<br />[🌍](#translation-da-friedl "Translation") |
| [<img src="https://avatars1.githubusercontent.com/u/2947640?v=4" width="110px;"/><br /><sub>Daniel Heene</sub>](https://github.com/danielheene)<br />[🌍](#translation-danielheene "Translation") | [<img src="https://avatars3.githubusercontent.com/u/319022?v=4" width="110px;"/><br /><sub>danielcb</sub>](https://github.com/danielcb)<br />[🌍](#translation-danielcb "Translation") | [<img src="https://avatars3.githubusercontent.com/u/15846537?v=4" width="110px;"/><br /><sub>Dominik Senti</sub>](https://github.com/dominiksenti)<br />[🌍](#translation-dominiksenti "Translation") | [<img src="https://avatars0.githubusercontent.com/u/25570954?v=4" width="110px;"/><br /><sub>Eric Gautheron</sub>](http://www.konectik.com)<br />[🌍](#translation-EpixFr "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5732623?v=4" width="110px;"/><br /><sub>Erlend Pilø</sub>](https://erlpil.com)<br />[🌍](#translation-Erlpil "Translation") | [<img src="https://avatars0.githubusercontent.com/u/541832?v=4" width="110px;"/><br /><sub>Fabio Rapposelli</sub>](http://fabio.technology)<br />[🌍](#translation-frapposelli "Translation") | [<img src="https://avatars2.githubusercontent.com/u/3605240?v=4" width="110px;"/><br /><sub>Felipe Barros</sub>](https://github.com/fgbs)<br />[🌍](#translation-fgbs "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/257745?v=4" width="110px;"/><br /><sub>Fernando Possebon</sub>](https://github.com/possebon)<br />[🌍](#translation-possebon "Translation") | [<img src="https://avatars3.githubusercontent.com/u/2540832?v=4" width="110px;"/><br /><sub>gdraque</sub>](https://github.com/gdraque)<br />[🌍](#translation-gdraque "Translation") | [<img src="https://avatars0.githubusercontent.com/u/23440381?v=4" width="110px;"/><br /><sub>Georg Wallisch</sub>](https://github.com/georgwallisch)<br />[🌍](#translation-georgwallisch "Translation") | [<img src="https://avatars1.githubusercontent.com/u/9852832?v=4" width="110px;"/><br /><sub>Gerardo Robles</sub>](https://github.com/jgroblesr85)<br />[🌍](#translation-jgroblesr85 "Translation") | [<img src="https://avatars2.githubusercontent.com/u/11082640?v=4" width="110px;"/><br /><sub>Gluek</sub>](https://t.me/Gluek)<br />[🌍](#translation-mrgluek "Translation") | [<img src="https://avatars0.githubusercontent.com/u/6847946?v=4" width="110px;"/><br /><sub>AdnanAbuShahad</sub>](https://github.com/AdnanAbuShahad)<br />[🌍](#translation-AdnanAbuShahad "Translation") | [<img src="https://avatars1.githubusercontent.com/u/3580608?v=4" width="110px;"/><br /><sub>Hafidzi My</sub>](https://hafidzi.my)<br />[🌍](#translation-hafidzi "Translation") |
| [<img src="https://avatars2.githubusercontent.com/u/205521?v=4" width="110px;"/><br /><sub>Harim Park</sub>](https://github.com/fofwisdom)<br />[🌍](#translation-fofwisdom "Translation") | [<img src="https://avatars2.githubusercontent.com/u/3333841?v=4" width="110px;"/><br /><sub>Henrik Kentsson</sub>](http://www.kentsson.se)<br />[🌍](#translation-Kentsson "Translation") | [<img src="https://avatars0.githubusercontent.com/u/36551034?v=4" width="110px;"/><br /><sub>Husnul Yaqien</sub>](https://github.com/husnulyaqien)<br />[🌍](#translation-husnulyaqien "Translation") | [<img src="https://avatars1.githubusercontent.com/u/2372747?v=4" width="110px;"/><br /><sub>Ibrahim</sub>](http://abaalkhail.org)<br />[🌍](#translation-abaalkh "Translation") | [<img src="https://avatars0.githubusercontent.com/u/1389334?v=4" width="110px;"/><br /><sub>igolman</sub>](https://github.com/igolman)<br />[🌍](#translation-igolman "Translation") | [<img src="https://avatars1.githubusercontent.com/u/3257070?v=4" width="110px;"/><br /><sub>itangiang</sub>](https://github.com/itangiang)<br />[🌍](#translation-itangiang "Translation") | [<img src="https://avatars2.githubusercontent.com/u/14814254?v=4" width="110px;"/><br /><sub>jarby1211</sub>](https://github.com/jarby1211)<br />[🌍](#translation-jarby1211 "Translation") |
| [<img src="https://avatars3.githubusercontent.com/u/6719357?v=4" width="110px;"/><br /><sub>Jhonn Willker</sub>](http://jwillker.com)<br />[🌍](#translation-JohnWillker "Translation") | [<img src="https://avatars2.githubusercontent.com/u/10983635?v=4" width="110px;"/><br /><sub>Jose</sub>](https://github.com/joxelito94)<br />[🌍](#translation-joxelito94 "Translation") | [<img src="https://avatars0.githubusercontent.com/u/5206122?v=4" width="110px;"/><br /><sub>laopangzi</sub>](https://github.com/laopangzi)<br />[🌍](#translation-laopangzi "Translation") | [<img src="https://avatars2.githubusercontent.com/u/79707?v=4" width="110px;"/><br /><sub>Lars Strojny</sub>](http://usrportage.de)<br />[🌍](#translation-lstrojny "Translation") | [<img src="https://avatars0.githubusercontent.com/u/389801?v=4" width="110px;"/><br /><sub>MarcosBL</sub>](http://twitter.com/marcosbl)<br />[🌍](#translation-MarcosBL "Translation") | [<img src="https://avatars3.githubusercontent.com/u/35664606?v=4" width="110px;"/><br /><sub>marie joy cajes</sub>](https://github.com/mariejoyacajes)<br />[🌍](#translation-mariejoyacajes "Translation") | [<img src="https://avatars2.githubusercontent.com/u/3052816?v=4" width="110px;"/><br /><sub>Mark S. Johansen</sub>](http://www.markjohansen.dk)<br />[🌍](#translation-msjohansen "Translation") |
| [<img src="https://avatars2.githubusercontent.com/u/982885?v=4" width="110px;"/><br /><sub>Martin Stub</sub>](http://martinstub.dk)<br />[🌍](#translation-stubben "Translation") | [<img src="https://avatars2.githubusercontent.com/u/28959963?v=4" width="110px;"/><br /><sub>Meyer Flavio</sub>](https://github.com/meyerf99)<br />[🌍](#translation-meyerf99 "Translation") | [<img src="https://avatars3.githubusercontent.com/u/796443?v=4" width="110px;"/><br /><sub>Micael Rodrigues</sub>](https://github.com/MicaelRodrigues)<br />[🌍](#translation-MicaelRodrigues "Translation") | [<img src="https://avatars0.githubusercontent.com/u/10481331?v=4" width="110px;"/><br /><sub>Mikael Rasmussen</sub>](http://rubixy.com/)<br />[🌍](#translation-mikaelssen "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1544552?v=4" width="110px;"/><br /><sub>IxFail</sub>](https://github.com/IxFail)<br />[🌍](#translation-IxFail "Translation") | [<img src="https://avatars3.githubusercontent.com/u/18483118?v=4" width="110px;"/><br /><sub>Mohammed Fota</sub>](http://www.mohammedfota.com)<br />[🌍](#translation-MohammedFota "Translation") | [<img src="https://avatars0.githubusercontent.com/u/227080?v=4" width="110px;"/><br /><sub>Moayad Alserihi</sub>](https://github.com/omego)<br />[🌍](#translation-omego "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/1680266?v=4" width="110px;"/><br /><sub>saymd</sub>](https://github.com/saymd)<br />[🌍](#translation-saymd "Translation") | [<img src="https://avatars0.githubusercontent.com/u/1826808?v=4" width="110px;"/><br /><sub>Patrik Larsson</sub>](https://nordsken.se)<br />[🌍](#translation-pooot "Translation") | [<img src="https://avatars1.githubusercontent.com/u/20584746?v=4" width="110px;"/><br /><sub>drcryo</sub>](https://github.com/drcryo)<br />[🌍](#translation-drcryo "Translation") | [<img src="https://avatars1.githubusercontent.com/u/19408004?v=4" width="110px;"/><br /><sub>pawel1615</sub>](https://github.com/pawel1615)<br />[🌍](#translation-pawel1615 "Translation") | [<img src="https://avatars2.githubusercontent.com/u/23340468?v=4" width="110px;"/><br /><sub>bodrovics</sub>](https://github.com/bodrovics)<br />[🌍](#translation-bodrovics "Translation") | [<img src="https://avatars0.githubusercontent.com/u/3257654?v=4" width="110px;"/><br /><sub>priatna</sub>](https://github.com/priatna)<br />[🌍](#translation-priatna "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5358374?v=4" width="110px;"/><br /><sub>Fan Jiang</sub>](https://amayume.net)<br />[🌍](#translation-ProfFan "Translation") |
| [<img src="https://avatars1.githubusercontent.com/u/22555451?v=4" width="110px;"/><br /><sub>ragnarcx</sub>](https://github.com/ragnarcx)<br />[🌍](#translation-ragnarcx "Translation") | [<img src="https://avatars2.githubusercontent.com/u/18654582?v=4" width="110px;"/><br /><sub>Rein van Haaren</sub>](http://www.reinvanhaaren.nl/)<br />[🌍](#translation-reinvanhaaren "Translation") | [<img src="https://avatars1.githubusercontent.com/u/386672?v=4" width="110px;"/><br /><sub>Teguh Dwicaksana</sub>](http://dheche.songolimo.net)<br />[🌍](#translation-dheche "Translation") | [<img src="https://avatars2.githubusercontent.com/u/2572552?v=4" width="110px;"/><br /><sub>fraccie</sub>](https://github.com/FRaccie)<br />[🌍](#translation-FRaccie "Translation") | [<img src="https://avatars0.githubusercontent.com/u/35182720?v=4" width="110px;"/><br /><sub>vinzruzell</sub>](https://github.com/vinzruzell)<br />[🌍](#translation-vinzruzell "Translation") | [<img src="https://avatars1.githubusercontent.com/u/7883603?v=4" width="110px;"/><br /><sub>Kevin Austin</sub>](http://kevinaustin.com)<br />[🌍](#translation-vipsystem "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3861828?v=4" width="110px;"/><br /><sub>Wira Sandy</sub>](http://azuraweb.xyz)<br />[🌍](#translation-wira-sandy "Translation") |
| [<img src="https://avatars2.githubusercontent.com/u/8663789?v=4" width="110px;"/><br /><sub>Илья</sub>](https://github.com/GrayHoax)<br />[🌍](#translation-GrayHoax "Translation") | [<img src="https://avatars3.githubusercontent.com/u/30119111?v=4" width="110px;"/><br /><sub>GodUseVPN</sub>](https://github.com/godusevpn)<br />[🌍](#translation-godusevpn "Translation") | [<img src="https://avatars1.githubusercontent.com/u/745576?v=4" width="110px;"/><br /><sub>周周</sub>](https://github.com/EngrZhou)<br />[🌍](#translation-EngrZhou "Translation") | [<img src="https://avatars3.githubusercontent.com/u/1631095?v=4" width="110px;"/><br /><sub>Sam</sub>](https://github.com/takuy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=takuy "Code") | [<img src="https://avatars1.githubusercontent.com/u/264022?v=4" width="110px;"/><br /><sub>Azerothian</sub>](https://www.illisian.com.au)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Azerothian "Code") | [<img src="https://avatars1.githubusercontent.com/u/4930051?v=4" width="110px;"/><br /><sub>Wes Hulette</sub>](http://macfoo.wordpress.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jwhulette "Code") | [<img src="https://avatars0.githubusercontent.com/u/8134591?v=4" width="110px;"/><br /><sub>patrict</sub>](https://github.com/patrict)<br />[💻](https://github.com/snipe/snipe-it/commits?author=patrict "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/2611616?v=4" width="110px;"/><br /><sub>Dmitriy Minaev</sub>](https://github.com/VELIKII-DIVAN)<br />[💻](https://github.com/snipe/snipe-it/commits?author=VELIKII-DIVAN "Code") | [<img src="https://avatars0.githubusercontent.com/u/5132245?v=4" width="110px;"/><br /><sub>liquidhorse</sub>](https://github.com/liquidhorse)<br />[💻](https://github.com/snipe/snipe-it/commits?author=liquidhorse "Code") | [<img src="https://avatars1.githubusercontent.com/u/183678?v=4" width="110px;"/><br /><sub>Jordi Boggiano</sub>](https://seld.be/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Seldaek "Code") | [<img src="https://avatars0.githubusercontent.com/u/653557?v=4" width="110px;"/><br /><sub>Ivan Nieto</sub>](https://github.com/inietov)<br />[💻](https://github.com/snipe/snipe-it/commits?author=inietov "Code") | [<img src="https://avatars2.githubusercontent.com/u/6764151?v=4" width="110px;"/><br /><sub>Ben RUBSON</sub>](https://github.com/benrubson)<br />[💻](https://github.com/snipe/snipe-it/commits?author=benrubson "Code") | [<img src="https://avatars2.githubusercontent.com/u/8554558?v=4" width="110px;"/><br /><sub>NMathar</sub>](https://github.com/NMathar)<br />[💻](https://github.com/snipe/snipe-it/commits?author=NMathar "Code") | [<img src="https://avatars1.githubusercontent.com/u/139566?v=4" width="110px;"/><br /><sub>Steffen</sub>](https://github.com/smb)<br />[💻](https://github.com/snipe/snipe-it/commits?author=smb "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/6609453?v=4" width="110px;"/><br /><sub>Sxderp</sub>](https://github.com/Sxderp)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Sxderp "Code") | [<img src="https://avatars1.githubusercontent.com/u/4807843?v=4" width="110px;"/><br /><sub>fanta8897</sub>](https://github.com/fanta8897)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fanta8897 "Code") | [<img src="https://avatars2.githubusercontent.com/u/2576509?v=4" width="110px;"/><br /><sub>Andrey Bolonin</sub>](https://andreybolonin.com/phpconsulting/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=andreybolonin "Code") | [<img src="https://avatars3.githubusercontent.com/u/2173307?v=4" width="110px;"/><br /><sub>shinayoshi</sub>](http://www.shinayoshi.net/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=shinayoshi "Code") | [<img src="https://avatars3.githubusercontent.com/u/2130159?v=4" width="110px;"/><br /><sub>Hubert</sub>](https://github.com/reuser)<br />[💻](https://github.com/snipe/snipe-it/commits?author=reuser "Code") | [<img src="https://avatars0.githubusercontent.com/u/6865789?v=4" width="110px;"/><br /><sub>KeenRivals</sub>](https://brashear.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=KeenRivals "Code") | [<img src="https://avatars3.githubusercontent.com/u/2902513?v=4" width="110px;"/><br /><sub>omyno</sub>](https://github.com/omyno)<br />[💻](https://github.com/snipe/snipe-it/commits?author=omyno "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/6271335?v=4" width="110px;"/><br /><sub>Evgeny</sub>](https://github.com/jackka)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jackka "Code") | [<img src="https://avatars2.githubusercontent.com/u/1169963?v=4" width="110px;"/><br /><sub>Colin Campbell</sub>](https://digitalist.se)<br />[💻](https://github.com/snipe/snipe-it/commits?author=colin-campbell "Code") | [<img src="https://avatars3.githubusercontent.com/u/2872098?v=4" width="110px;"/><br /><sub>Ľubomír Kučera</sub>](https://github.com/lubo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=lubo "Code") | [<img src="https://avatars3.githubusercontent.com/u/570639?v=4" width="110px;"/><br /><sub>Martin Meredith</sub>](https://www.sourceguru.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Mezzle "Code") | [<img src="https://avatars1.githubusercontent.com/u/7632599?v=4" width="110px;"/><br /><sub>Tim Farmer</sub>](https://github.com/timothyfarmer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=timothyfarmer "Code") | [<img src="https://avatars0.githubusercontent.com/u/17459600?v=4" width="110px;"/><br /><sub>Marián Skrip</sub>](https://github.com/mskrip)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mskrip "Code") | [<img src="https://avatars2.githubusercontent.com/u/47435081?v=4" width="110px;"/><br /><sub>Godfrey Martinez</sub>](https://github.com/Godmartinz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Godmartinz "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/2075128?v=4" width="110px;"/><br /><sub>bigtreeEdo</sub>](https://github.com/bigtreeEdo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bigtreeEdo "Code") | [<img src="https://avatars0.githubusercontent.com/u/5000430?v=4" width="110px;"/><br /><sub>Colin McNeil</sub>](https://colinmcneil.me/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ColinMcNeil "Code") | [<img src="https://avatars0.githubusercontent.com/u/421625?v=4" width="110px;"/><br /><sub>JoKneeMo</sub>](https://github.com/JoKneeMo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=JoKneeMo "Code") | [<img src="https://avatars0.githubusercontent.com/u/54849013?v=4" width="110px;"/><br /><sub>Joshi</sub>](http://www.redbridge.se)<br />[💻](https://github.com/snipe/snipe-it/commits?author=joshi-redbridge "Code") | [<img src="https://avatars2.githubusercontent.com/u/15731458?v=4" width="110px;"/><br /><sub>Anthony Burns</sub>](https://github.com/anthonypburns)<br />[💻](https://github.com/snipe/snipe-it/commits?author=anthonypburns "Code") | [<img src="https://avatars1.githubusercontent.com/u/63399474?v=4" width="110px;"/><br /><sub>johnson-yi</sub>](https://github.com/johnson-yi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=johnson-yi "Code") | [<img src="https://avatars1.githubusercontent.com/u/1862720?v=4" width="110px;"/><br /><sub>Sanjay Govind</sub>](https://tangentmc.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sanjay900 "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/1255375?v=4" width="110px;"/><br /><sub>Peter Upfold</sub>](https://peter.upfold.org.uk/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PeterUpfold "Code") | [<img src="https://avatars2.githubusercontent.com/u/961717?v=4" width="110px;"/><br /><sub>Jared Biel</sub>](https://github.com/jbiel)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jbiel "Code") | [<img src="https://avatars1.githubusercontent.com/u/1733625?v=4" width="110px;"/><br /><sub>Dampfklon</sub>](https://github.com/dampfklon)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dampfklon "Code") | [<img src="https://avatars2.githubusercontent.com/u/52973156?v=4" width="110px;"/><br /><sub>Charles Hamilton</sub>](https://communityclosing.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chamilton-ccn "Code") | [<img src="https://avatars.githubusercontent.com/u/551789?v=4" width="110px;"/><br /><sub>Giuseppe Iannello</sub>](https://github.com/giannello)<br />[💻](https://github.com/snipe/snipe-it/commits?author=giannello "Code") | [<img src="https://avatars.githubusercontent.com/u/3691490?v=4" width="110px;"/><br /><sub>Peter Dave Hello</sub>](https://www.peterdavehello.org/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PeterDaveHello "Code") | [<img src="https://avatars.githubusercontent.com/u/6106332?v=4" width="110px;"/><br /><sub>sigmoidal</sub>](https://github.com/sigmoidal)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sigmoidal "Code") |
| [<img src="https://avatars.githubusercontent.com/u/2082554?v=4" width="110px;"/><br /><sub>Vincent Lainé</sub>](https://github.com/phenixdotnet)<br />[💻](https://github.com/snipe/snipe-it/commits?author=phenixdotnet "Code") | [<img src="https://avatars.githubusercontent.com/u/1943040?v=4" width="110px;"/><br /><sub>Lucas Pleß</sub>](http://www.lucas-pless.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=derlucas "Code") | [<img src="https://avatars.githubusercontent.com/u/472804?v=4" width="110px;"/><br /><sub>Ian Littman</sub>](http://twitter.com/iansltx)<br />[💻](https://github.com/snipe/snipe-it/commits?author=iansltx "Code") | [<img src="https://avatars.githubusercontent.com/u/3519029?v=4" width="110px;"/><br /><sub>João Paulo</sub>](https://github.com/PauloLuna)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PauloLuna "Code") | [<img src="https://avatars.githubusercontent.com/u/70443365?v=4" width="110px;"/><br /><sub>ThoBur</sub>](https://github.com/ThoBur)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ThoBur "Code") | [<img src="https://avatars.githubusercontent.com/u/1972329?v=4" width="110px;"/><br /><sub>Alexander Chibrikin</sub>](http://phpprofi.ru/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=alek13 "Code") | [<img src="https://avatars.githubusercontent.com/u/438332?v=4" width="110px;"/><br /><sub>Anthony Winstanley</sub>](https://github.com/winstan)<br />[💻](https://github.com/snipe/snipe-it/commits?author=winstan "Code") |
| [<img src="https://avatars.githubusercontent.com/u/3075214?v=4" width="110px;"/><br /><sub>Folke</sub>](https://github.com/fashberg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fashberg "Code") | [<img src="https://avatars.githubusercontent.com/u/1351571?v=4" width="110px;"/><br /><sub>Bennett Blodinger</sub>](https://github.com/benwa)<br />[💻](https://github.com/snipe/snipe-it/commits?author=benwa "Code") | [<img src="https://avatars.githubusercontent.com/u/2974631?v=4" width="110px;"/><br /><sub>NMC</sub>](https://nmc.dev)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ncareau "Code") | [<img src="https://avatars.githubusercontent.com/u/52182449?v=4" width="110px;"/><br /><sub>andres-baller</sub>](https://github.com/andres-baller)<br />[💻](https://github.com/snipe/snipe-it/commits?author=andres-baller "Code") | [<img src="https://avatars.githubusercontent.com/u/67109348?v=4" width="110px;"/><br /><sub>sean-borg</sub>](https://github.com/sean-borg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sean-borg "Code") | [<img src="https://avatars.githubusercontent.com/u/32170051?v=4" width="110px;"/><br /><sub>EDVLeer</sub>](https://github.com/EDVLeer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=EDVLeer "Code") | [<img src="https://avatars.githubusercontent.com/u/23075196?v=4" width="110px;"/><br /><sub>Kurokat</sub>](https://github.com/Kurokat)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Kurokat "Code") |
| [<img src="https://avatars.githubusercontent.com/u/915514?v=4" width="110px;"/><br /><sub>Kevin Köllmann</sub>](https://www.kevinkoellmann.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=koelle25 "Code") | [<img src="https://avatars.githubusercontent.com/u/49025941?v=4" width="110px;"/><br /><sub>sw-mreyes</sub>](https://github.com/sw-mreyes)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sw-mreyes "Code") | [<img src="https://avatars.githubusercontent.com/u/70129?v=4" width="110px;"/><br /><sub>Joel Pittet</sub>](https://pittet.ca)<br />[💻](https://github.com/snipe/snipe-it/commits?author=joelpittet "Code") | [<img src="https://avatars.githubusercontent.com/u/792695?v=4" width="110px;"/><br /><sub>Eli Young</sub>](https://elyscape.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=elyscape "Code") | [<img src="https://avatars.githubusercontent.com/u/317015?v=4" width="110px;"/><br /><sub>Raell Dottin</sub>](https://github.com/raelldottin)<br />[💻](https://github.com/snipe/snipe-it/commits?author=raelldottin "Code") | [<img src="https://avatars.githubusercontent.com/u/1446856?v=4" width="110px;"/><br /><sub>Tom Misilo</sub>](https://github.com/misilot)<br />[💻](https://github.com/snipe/snipe-it/commits?author=misilot "Code") | [<img src="https://avatars.githubusercontent.com/u/4496300?v=4" width="110px;"/><br /><sub>David Davenne</sub>](http://david.davenne.be)<br />[💻](https://github.com/snipe/snipe-it/commits?author=JuustoMestari "Code") |
| [<img src="https://avatars.githubusercontent.com/u/9255772?v=4" width="110px;"/><br /><sub>Mark Stenglein</sub>](https://markstenglein.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ocelotsloth "Code") | [<img src="https://avatars.githubusercontent.com/u/35658596?v=4" width="110px;"/><br /><sub>ajsy</sub>](https://github.com/ajsy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ajsy "Code") | [<img src="https://avatars.githubusercontent.com/u/3628035?v=4" width="110px;"/><br /><sub>Jan Kiesewetter</sub>](https://github.com/t3easy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=t3easy "Code") | [<img src="https://avatars.githubusercontent.com/u/79449630?v=4" width="110px;"/><br /><sub>Tetrachloromethane250</sub>](https://github.com/Tetrachloromethane250)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Tetrachloromethane250 "Code") | [<img src="https://avatars.githubusercontent.com/u/22004482?v=4" width="110px;"/><br /><sub>Lars Kajes</sub>](https://www.kajes.se/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kajes "Code") | [<img src="https://avatars.githubusercontent.com/u/13993216?v=4" width="110px;"/><br /><sub>Joly0</sub>](https://github.com/Joly0)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Joly0 "Code") | [<img src="https://avatars.githubusercontent.com/u/1501022?v=4" width="110px;"/><br /><sub>theburger</sub>](https://github.com/limeless)<br />[💻](https://github.com/snipe/snipe-it/commits?author=limeless "Code") |
| [<img src="https://avatars.githubusercontent.com/u/36065681?v=4" width="110px;"/><br /><sub>David Valin Alonso</sub>](https://github.com/deivishome)<br />[💻](https://github.com/snipe/snipe-it/commits?author=deivishome "Code") | [<img src="https://avatars.githubusercontent.com/u/8290389?v=4" width="110px;"/><br /><sub>andreaci</sub>](https://github.com/andreaci)<br />[💻](https://github.com/snipe/snipe-it/commits?author=andreaci "Code") | [<img src="https://avatars.githubusercontent.com/u/1828542?v=4" width="110px;"/><br /><sub>Jelle Sebreghts</sub>](http://www.jellesebreghts.be)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Jelle-S "Code") | [<img src="https://avatars.githubusercontent.com/u/11180862?v=4" width="110px;"/><br /><sub>Michael Pietsch</sub>](https://github.com/Skywalker-11)<br /> | [<img src="https://avatars.githubusercontent.com/u/22068886?v=4" width="110px;"/><br /><sub>Masudul Haque Shihab</sub>](https://github.com/sh1hab)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sh1hab "Code") | [<img src="https://avatars.githubusercontent.com/u/16099942?v=4" width="110px;"/><br /><sub>Supapong Areeprasertkul</sub>](http://www.freedomdive.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zybersup "Code") | [<img src="https://avatars.githubusercontent.com/u/207358?v=4" width="110px;"/><br /><sub>Peter Sarossy</sub>](https://github.com/psarossy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=psarossy "Code") |
| [<img src="https://avatars.githubusercontent.com/u/11823649?v=4" width="110px;"/><br /><sub>Renee Margaret McConahy</sub>](https://github.com/nepella)<br />[💻](https://github.com/snipe/snipe-it/commits?author=nepella "Code") | [<img src="https://avatars.githubusercontent.com/u/5553884?v=4" width="110px;"/><br /><sub>JohnnyPicnic</sub>](https://github.com/JohnnyPicnic)<br />[💻](https://github.com/snipe/snipe-it/commits?author=JohnnyPicnic "Code") | [<img src="https://avatars.githubusercontent.com/u/8799594?v=4" width="110px;"/><br /><sub>markbrule</sub>](https://github.com/markbrule)<br />[💻](https://github.com/snipe/snipe-it/commits?author=markbrule "Code") | [<img src="https://avatars.githubusercontent.com/u/1962801?v=4" width="110px;"/><br /><sub>Mike Campbell</sub>](https://github.com/mikecmpbll)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mikecmpbll "Code") | [<img src="https://avatars.githubusercontent.com/u/11973217?v=4" width="110px;"/><br /><sub>tbrconnect</sub>](https://github.com/tbrconnect)<br />[💻](https://github.com/snipe/snipe-it/commits?author=tbrconnect "Code") | [<img src="https://avatars.githubusercontent.com/u/12447225?v=4" width="110px;"/><br /><sub>kcoyo</sub>](https://github.com/kcoyo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kcoyo "Code") | [<img src="https://avatars.githubusercontent.com/u/494017?v=4" width="110px;"/><br /><sub>Travis Miller</sub>](https://travismiller.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=travismiller "Code") |
| [<img src="https://avatars.githubusercontent.com/u/1975640?v=4" width="110px;"/><br /><sub>Evan Taylor</sub>](https://github.com/Delta5)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Delta5 "Code") | [<img src="https://avatars.githubusercontent.com/u/8735148?v=4" width="110px;"/><br /><sub>Petri Asikainen</sub>](https://github.com/PetriAsi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PetriAsi "Code") | [<img src="https://avatars.githubusercontent.com/u/11424540?v=4" width="110px;"/><br /><sub>derdeagle</sub>](https://github.com/derdeagle)<br />[💻](https://github.com/snipe/snipe-it/commits?author=derdeagle "Code") | [<img src="https://avatars.githubusercontent.com/u/176950?v=4" width="110px;"/><br /><sub>Mike Frysinger</sub>](https://wh0rd.org/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vapier "Code") | [<img src="https://avatars.githubusercontent.com/u/22044358?v=4" width="110px;"/><br /><sub>ALPHA</sub>](https://github.com/AL4AL)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AL4AL "Code") | [<img src="https://avatars.githubusercontent.com/u/1042587?v=4" width="110px;"/><br /><sub>FliegenKLATSCH</sub>](https://www.ifern.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FliegenKLATSCH "Code") | [<img src="https://avatars.githubusercontent.com/u/442138?v=4" width="110px;"/><br /><sub>Jeremy Price</sub>](https://github.com/jerm)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jerm "Code") |
| [<img src="https://avatars.githubusercontent.com/u/84392209?v=4" width="110px;"/><br /><sub>Toreg87</sub>](https://github.com/Toreg87)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Toreg87 "Code") | [<img src="https://avatars.githubusercontent.com/u/67638596?v=4" width="110px;"/><br /><sub>Matthew Nickson</sub>](https://github.com/Computroniks)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Computroniks "Code") | [<img src="https://avatars.githubusercontent.com/u/1646397?v=4" width="110px;"/><br /><sub>Jethro Nederhof</sub>](https://jethron.id.au)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jethron "Code") | [<img src="https://avatars.githubusercontent.com/u/23289826?v=4" width="110px;"/><br /><sub>Oskar Stenberg</sub>](https://github.com/01ste02)<br />[💻](https://github.com/snipe/snipe-it/commits?author=01ste02 "Code") | [<img src="https://avatars.githubusercontent.com/u/82208283?v=4" width="110px;"/><br /><sub>Robert-Azelis</sub>](https://github.com/Robert-Azelis)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Robert-Azelis "Code") | [<img src="https://avatars.githubusercontent.com/u/60648387?v=4" width="110px;"/><br /><sub>Alexander William Smith</sub>](https://github.com/alwism)<br />[💻](https://github.com/snipe/snipe-it/commits?author=alwism "Code") | [<img src="https://avatars.githubusercontent.com/u/24418301?v=4" width="110px;"/><br /><sub>LEITWERK AG</sub>](https://www.leitwerk.de/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=leitwerk-ag "Code") |
| [<img src="https://avatars.githubusercontent.com/u/1911435?v=4" width="110px;"/><br /><sub>Adam</sub>](http://www.aboutcher.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=adamboutcher "Code") | [<img src="https://avatars.githubusercontent.com/u/16104273?v=4" width="110px;"/><br /><sub>Ian</sub>](https://snksrv.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sneak-it "Code") | [<img src="https://avatars.githubusercontent.com/u/4023909?v=4" width="110px;"/><br /><sub>Shao Yu-Lung (Allen)</sub>](http://blog.bestlong.idv.tw/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bestlong "Code") | [<img src="https://avatars.githubusercontent.com/u/76475453?v=4" width="110px;"/><br /><sub>Haxatron</sub>](https://github.com/Haxatron)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Haxatron "Code") | [<img src="https://avatars.githubusercontent.com/u/88776392?v=4" width="110px;"/><br /><sub>PlaneNuts</sub>](https://github.com/PlaneNuts)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PlaneNuts "Code") | [<img src="https://avatars.githubusercontent.com/u/3842948?v=4" width="110px;"/><br /><sub>Bradley Coudriet</sub>](http://bjcpgd.cias.rit.edu)<br />[💻](https://github.com/snipe/snipe-it/commits?author=exula "Code") | [<img src="https://avatars.githubusercontent.com/u/21966173?v=4" width="110px;"/><br /><sub>Dalton Durst</sub>](https://daltondur.st)<br />[💻](https://github.com/snipe/snipe-it/commits?author=UniversalSuperBox "Code") |
| [<img src="https://avatars.githubusercontent.com/u/38761237?v=4" width="110px;"/><br /><sub>Alex Janes</sub>](https://adagiohealth.org)<br />[💻](https://github.com/snipe/snipe-it/commits?author=adagioajanes "Code") | [<img src="https://avatars.githubusercontent.com/u/32387849?v=4" width="110px;"/><br /><sub>Nuraeil</sub>](https://github.com/nuraeil)<br />[💻](https://github.com/snipe/snipe-it/commits?author=nuraeil "Code") | [<img src="https://avatars.githubusercontent.com/u/48162670?v=4" width="110px;"/><br /><sub>TenOfTens</sub>](https://github.com/TenOfTens)<br />[💻](https://github.com/snipe/snipe-it/commits?author=TenOfTens "Code") | [<img src="https://avatars.githubusercontent.com/u/9415391?v=4" width="110px;"/><br /><sub>waffle</sub>](https://ditisjens.be/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=insert-waffle "Code") | [<img src="https://avatars.githubusercontent.com/u/19945501?v=4" width="110px;"/><br /><sub>Yevhenii Huzii</sub>](https://github.com/QveenSi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=QveenSi "Code") | [<img src="https://avatars.githubusercontent.com/u/3839381?v=4" width="110px;"/><br /><sub>Achmad Fienan Rahardianto</sub>](https://github.com/veenone)<br />[💻](https://github.com/snipe/snipe-it/commits?author=veenone "Code") | [<img src="https://avatars.githubusercontent.com/u/19945501?v=4" width="110px;"/><br /><sub>Yevhenii Huzii</sub>](https://github.com/QveenSi)<br />[💻](https://github.com/snipe/snipe-it/commits?author=QveenSi "Code") |
| [<img src="https://avatars.githubusercontent.com/u/97299851?v=4" width="110px;"/><br /><sub>Christian Weirich</sub>](https://github.com/chrisweirich)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chrisweirich "Code") | [<img src="https://avatars.githubusercontent.com/u/1294403?v=4" width="110px;"/><br /><sub>denzfarid</sub>](https://github.com/denzfarid)<br /> | [<img src="https://avatars.githubusercontent.com/u/94018771?v=4" width="110px;"/><br /><sub>ntbutler-nbcs</sub>](https://github.com/ntbutler-nbcs)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ntbutler-nbcs "Code") | [<img src="https://avatars.githubusercontent.com/u/172697?v=4" width="110px;"/><br /><sub>Naveen</sub>](https://naveensrinivasan.dev)<br />[💻](https://github.com/snipe/snipe-it/commits?author=naveensrinivasan "Code") | [<img src="https://avatars.githubusercontent.com/u/55674383?v=4" width="110px;"/><br /><sub>Mike Roquemore</sub>](https://github.com/mikeroq)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mikeroq "Code") | [<img src="https://avatars.githubusercontent.com/u/7991086?v=4" width="110px;"/><br /><sub>Daniel Reeder</sub>](https://github.com/reederda)<br />[🌍](#translation-reederda "Translation") [🌍](#translation-reederda "Translation") [💻](https://github.com/snipe/snipe-it/commits?author=reederda "Code") | [<img src="https://avatars.githubusercontent.com/u/109422491?v=4" width="110px;"/><br /><sub>vickyjaura183</sub>](https://github.com/vickyjaura183)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vickyjaura183 "Code") |
| [<img src="https://avatars.githubusercontent.com/u/32363424?v=4" width="110px;"/><br /><sub>Peace</sub>](https://github.com/julian-piehl)<br />[💻](https://github.com/snipe/snipe-it/commits?author=julian-piehl "Code") | [<img src="https://avatars.githubusercontent.com/u/231528?v=4" width="110px;"/><br /><sub>Kyle Gordon</sub>](https://github.com/kylegordon)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kylegordon "Code") | [<img src="https://avatars.githubusercontent.com/u/53009155?v=4" width="110px;"/><br /><sub>Katharina Drexel</sub>](http://www.bfh.ch)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sunflowerbofh "Code") | [<img src="https://avatars.githubusercontent.com/u/1931963?v=4" width="110px;"/><br /><sub>David Sferruzza</sub>](https://david.sferruzza.fr/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dsferruzza "Code") | [<img src="https://avatars.githubusercontent.com/u/19511639?v=4" width="110px;"/><br /><sub>Rick Nelson</sub>](https://github.com/rnelsonee)<br />[💻](https://github.com/snipe/snipe-it/commits?author=rnelsonee "Code") | [<img src="https://avatars.githubusercontent.com/u/94169344?v=4" width="110px;"/><br /><sub>BasO12</sub>](https://github.com/BasO12)<br />[💻](https://github.com/snipe/snipe-it/commits?author=BasO12 "Code") | [<img src="https://avatars.githubusercontent.com/u/111710123?v=4" width="110px;"/><br /><sub>Vautia</sub>](https://github.com/Vautia)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Vautia "Code") |
| [<img src="https://avatars.githubusercontent.com/u/28321?v=4" width="110px;"/><br /><sub>Chris Hartjes</sub>](http://www.littlehart.net/atthekeyboard)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chartjes "Code") | [<img src="https://avatars.githubusercontent.com/u/2404584?v=4" width="110px;"/><br /><sub>geo-chen</sub>](https://github.com/geo-chen)<br />[💻](https://github.com/snipe/snipe-it/commits?author=geo-chen "Code") | [<img src="https://avatars.githubusercontent.com/u/6006620?v=4" width="110px;"/><br /><sub>Phan Nguyen</sub>](https://github.com/nh314)<br />[💻](https://github.com/snipe/snipe-it/commits?author=nh314 "Code") | [<img src="https://avatars.githubusercontent.com/u/115993812?v=4" width="110px;"/><br /><sub>Iisakki Jaakkola</sub>](https://github.com/StarlessNights)<br />[💻](https://github.com/snipe/snipe-it/commits?author=StarlessNights "Code") | [<img src="https://avatars.githubusercontent.com/u/22633385?v=4" width="110px;"/><br /><sub>Ikko Ashimine</sub>](https://bandism.net/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=eltociear "Code") | [<img src="https://avatars.githubusercontent.com/u/56871540?v=4" width="110px;"/><br /><sub>Lukas Fehling</sub>](https://github.com/lukasfehling)<br />[💻](https://github.com/snipe/snipe-it/commits?author=lukasfehling "Code") | [<img src="https://avatars.githubusercontent.com/u/1975990?v=4" width="110px;"/><br /><sub>Fernando Almeida</sub>](https://github.com/fernando-almeida)<br />[💻](https://github.com/snipe/snipe-it/commits?author=fernando-almeida "Code") |
| [<img src="https://avatars.githubusercontent.com/u/116301219?v=4" width="110px;"/><br /><sub>akemidx</sub>](https://github.com/akemidx)<br />[💻](https://github.com/snipe/snipe-it/commits?author=akemidx "Code") | [<img src="https://avatars.githubusercontent.com/u/144778?v=4" width="110px;"/><br /><sub>Oguz Bilgic</sub>](http://oguz.site)<br />[💻](https://github.com/snipe/snipe-it/commits?author=oguzbilgic "Code") | [<img src="https://avatars.githubusercontent.com/u/9262438?v=4" width="110px;"/><br /><sub>Scooter Crawford</sub>](https://github.com/scoo73r)<br />[💻](https://github.com/snipe/snipe-it/commits?author=scoo73r "Code") | [<img src="https://avatars.githubusercontent.com/u/5957345?v=4" width="110px;"/><br /><sub>subdriven</sub>](https://github.com/subdriven)<br />[💻](https://github.com/snipe/snipe-it/commits?author=subdriven "Code") | [<img src="https://avatars.githubusercontent.com/u/658865?v=4" width="110px;"/><br /><sub>Andrew Savinykh</sub>](https://github.com/AndrewSav)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AndrewSav "Code") | [<img src="https://avatars.githubusercontent.com/u/1155067?v=4" width="110px;"/><br /><sub>Tadayuki Onishi</sub>](https://kenchan0130.github.io)<br />[💻](https://github.com/snipe/snipe-it/commits?author=kenchan0130 "Code") | [<img src="https://avatars.githubusercontent.com/u/112496896?v=4" width="110px;"/><br /><sub>Florian</sub>](https://github.com/floschoepfer)<br />[💻](https://github.com/snipe/snipe-it/commits?author=floschoepfer "Code") |
| [<img src="https://avatars.githubusercontent.com/u/7305753?v=4" width="110px;"/><br /><sub>Spencer Long</sub>](http://spencerlong.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=spencerrlongg "Code") | [<img src="https://avatars.githubusercontent.com/u/1141514?v=4" width="110px;"/><br /><sub>Marcus Moore</sub>](https://github.com/marcusmoore)<br />[💻](https://github.com/snipe/snipe-it/commits?author=marcusmoore "Code") | [<img src="https://avatars.githubusercontent.com/u/570639?v=4" width="110px;"/><br /><sub>Martin Meredith</sub>](https://github.com/Mezzle)<br /> | [<img src="https://avatars.githubusercontent.com/u/5731963?v=4" width="110px;"/><br /><sub>dboth</sub>](http://dboth.de)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dboth "Code") | [<img src="https://avatars.githubusercontent.com/u/87536651?v=4" width="110px;"/><br /><sub>Zachary Fleck</sub>](https://github.com/zacharyfleck)<br />[💻](https://github.com/snipe/snipe-it/commits?author=zacharyfleck "Code") | [<img src="https://avatars.githubusercontent.com/u/74609912?v=4" width="110px;"/><br /><sub>VIKAAS-A</sub>](https://github.com/vikaas-cyper)<br />[💻](https://github.com/snipe/snipe-it/commits?author=vikaas-cyper "Code") | [<img src="https://avatars.githubusercontent.com/u/88882041?v=4" width="110px;"/><br /><sub>Abdul Kareem</sub>](https://github.com/ak-piracha)<br />[💻](https://github.com/snipe/snipe-it/commits?author=ak-piracha "Code") |
| [<img src="https://avatars.githubusercontent.com/u/111287779?v=4" width="110px;"/><br /><sub>NojoudAlshehri</sub>](https://github.com/NojoudAlshehri)<br />[💻](https://github.com/snipe/snipe-it/commits?author=NojoudAlshehri "Code") | [<img src="https://avatars.githubusercontent.com/u/54367449?v=4" width="110px;"/><br /><sub>Stefan Stidl</sub>](https://github.com/stefanstidlffg)<br />[💻](https://github.com/snipe/snipe-it/commits?author=stefanstidlffg "Code") | [<img src="https://avatars.githubusercontent.com/u/87803479?v=4" width="110px;"/><br /><sub>Quentin Aymard</sub>](https://github.com/qay21)<br />[💻](https://github.com/snipe/snipe-it/commits?author=qay21 "Code") | [<img src="https://avatars.githubusercontent.com/u/5396871?v=4" width="110px;"/><br /><sub>Grant Le Roux</sub>](https://github.com/cram42)<br />[💻](https://github.com/snipe/snipe-it/commits?author=cram42 "Code") | [<img src="https://avatars.githubusercontent.com/u/58479551?v=4" width="110px;"/><br /><sub>Bogdan</sub>](http://@singrity)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Singrity "Code") | [<img src="https://avatars.githubusercontent.com/u/3483684?v=4" width="110px;"/><br /><sub>mmanjos</sub>](https://github.com/mmanjos)<br />[💻](https://github.com/snipe/snipe-it/commits?author=mmanjos "Code") | [<img src="https://avatars.githubusercontent.com/u/7429229?v=4" width="110px;"/><br /><sub>Abdelaziz Faki</sub>](https://azooz2014.github.io/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Azooz2014 "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

View file

@ -20,7 +20,7 @@ APP_DEBUG=true
APP_KEY=base64:glJpcM7BYwWiBggp3SQ/+NlRkqsBQMaGEOjemXqJzOU= APP_KEY=base64:glJpcM7BYwWiBggp3SQ/+NlRkqsBQMaGEOjemXqJzOU=
APP_URL=http://localhost:8000 APP_URL=http://localhost:8000
APP_TIMEZONE='UTC' APP_TIMEZONE='UTC'
APP_LOCALE=en APP_LOCALE=en-US
# -------------------------------------------- # --------------------------------------------
# REQUIRED: DATABASE SETTINGS # REQUIRED: DATABASE SETTINGS
@ -45,8 +45,21 @@ DB_PASSWORD={}
Now you are ready to run the entire test suite from your terminal: Now you are ready to run the entire test suite from your terminal:
`php artisan test` ```shell
php artisan test
````
To run individual test files, you can pass the path to the test that you want to run: To run individual test files, you can pass the path to the test that you want to run:
`php artisan test tests/Unit/AccessoryTest.php` ```shell
php artisan test tests/Unit/AccessoryTest.php
```
Some tests, like ones concerning LDAP, are marked with the `@group` annotation. Those groups can be run, or excluded, using the `--group` or `--exclude-group` flags:
```shell
php artisan test --group=ldap
php artisan test --exclude-group=ldap
```
This can be helpful if a set of tests are failing because you don't have an extension, like LDAP, installed.

View file

@ -38,7 +38,7 @@
"description": "The maximum number of search results that can be returned at one time.", "description": "The maximum number of search results that can be returned at one time.",
"value": "500" "value": "500"
}, },
"MAIL_DRIVER": { "MAIL_MAILER": {
"description": "Mail driver - Generally SMTP on Heroku - https://snipe-it.readme.io/docs/configuration#required-outgoing-mail-settings", "description": "Mail driver - Generally SMTP on Heroku - https://snipe-it.readme.io/docs/configuration#required-outgoing-mail-settings",
"value": "smtp" "value": "smtp"
}, },
@ -58,9 +58,9 @@
"description": "SMTP Server Password", "description": "SMTP Server Password",
"value": "YOURPASSWORD" "value": "YOURPASSWORD"
}, },
"MAIL_ENCRYPTION": { "MAIL_TLS_VERIFY_PEER": {
"description": "Encryption protocol for email sending.", "description": "Ensure validity of TLS certificate on remote mail server",
"value": "null" "value": true
}, },
"MAIL_FROM_ADDR": { "MAIL_FROM_ADDR": {
"description": "Email from address", "description": "Email from address",

View file

@ -0,0 +1,66 @@
<?php
namespace App\Console\Commands;
use App\Models\Asset;
use Illuminate\Console\Command;
class FixupAssignedToWithoutAssignedType extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'snipeit:assigned-to-fixup
{--debug : Display debugging output}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fixes up assets that have an assigned_to but no assigned_type';
/**
* Execute the console command.
*/
public function handle()
{
$assets = Asset::whereNull("assigned_type")->whereNotNull("assigned_to")->withTrashed();
$this->withProgressBar($assets->get(), function (Asset $asset) {
//now check each action log, from the most recent backwards, to find the last checkin or checkout
foreach($asset->log()->orderBy("id","desc")->get() as $action_log) {
if($this->option("debug")) {
$this->info("Asset id: " . $asset->id . " action log, action type is: " . $action_log->action_type);
}
switch($action_log->action_type) {
case 'checkin from':
if($this->option("debug")) {
$this->info("Doing a checkin for ".$asset->id);
}
$asset->assigned_to = null;
// if you have a required custom field, we still want to save, and we *don't* want an action_log
$asset->saveQuietly();
return;
case 'checkout':
if($this->option("debug")) {
$this->info("Doing a checkout for " . $asset->id . " picking target type: " . $action_log->target_type);
}
if($asset->assigned_to != $action_log->target_id) {
$this->error("Asset's assigned_to does *NOT* match Action Log's target_id. \$asset->assigned_to=".$asset->assigned_to." vs. \$action_log->target_id=".$action_log->target_id);
//FIXME - do we abort here? Do we try to keep looking? I don't know, this means your data is *really* messed up...
}
$asset->assigned_type = $action_log->target_type;
$asset->saveQuietly(); // see above
return;
}
}
$asset->assigned_to = null; //asset was never checked in or out in its lifetime - it stays 'checked in'
$asset->saveQuietly(); //see above
});
$this->newLine();
$this->info("Assets assigned_type are fixed");
}
}

View file

@ -7,7 +7,7 @@ use Illuminate\Console\Command;
use App\Models\User; use App\Models\User;
use Laravel\Passport\TokenRepository; use Laravel\Passport\TokenRepository;
use Illuminate\Contracts\Validation\Factory as ValidationFactory; use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use DB; use Illuminate\Support\Facades\DB;
class GeneratePersonalAccessToken extends Command class GeneratePersonalAccessToken extends Command
{ {

View file

@ -9,7 +9,7 @@ use App\Models\Setting;
use App\Models\Ldap; use App\Models\Ldap;
use App\Models\User; use App\Models\User;
use App\Models\Location; use App\Models\Location;
use Log; use Illuminate\Support\Facades\Log;
class LdapSync extends Command class LdapSync extends Command
{ {
@ -66,6 +66,7 @@ class LdapSync extends Command
$ldap_result_dept = Setting::getSettings()->ldap_dept; $ldap_result_dept = Setting::getSettings()->ldap_dept;
$ldap_result_manager = Setting::getSettings()->ldap_manager; $ldap_result_manager = Setting::getSettings()->ldap_manager;
$ldap_default_group = Setting::getSettings()->ldap_default_group; $ldap_default_group = Setting::getSettings()->ldap_default_group;
$search_base = Setting::getSettings()->ldap_base_dn;
try { try {
$ldapconn = Ldap::connectToLdap(); $ldapconn = Ldap::connectToLdap();
@ -83,26 +84,37 @@ class LdapSync extends Command
$summary = []; $summary = [];
try { try {
if ( $this->option('location_id') != '') {
/**
* if a location ID has been specified, use that OU
*/
if ( $this->option('location_id') ) {
foreach($this->option('location_id') as $location_id){ foreach($this->option('location_id') as $location_id){
$location_ou= Location::where('id', '=', $location_id)->value('ldap_ou'); $location_ou = Location::where('id', '=', $location_id)->value('ldap_ou');
$search_base = $location_ou; $search_base = $location_ou;
Log::debug('Importing users from specified location OU: \"'.$search_base.'\".'); Log::debug('Importing users from specified location OU: \"'.$search_base.'\".');
} }
} }
else if ($this->option('base_dn') != '') { /**
* if a manual base DN has been specified, use that. Allow the Base DN to override
* even if there's a location-based DN - if you picked it, you must have picked it for a reason.
*/
if ($this->option('base_dn') != '') {
$search_base = $this->option('base_dn'); $search_base = $this->option('base_dn');
Log::debug('Importing users from specified base DN: \"'.$search_base.'\".'); Log::debug('Importing users from specified base DN: \"'.$search_base.'\".');
} else {
$search_base = null;
} }
/**
* If a filter has been specified, use that
*/
if ($this->option('filter') != '') { if ($this->option('filter') != '') {
$results = Ldap::findLdapUsers($search_base, -1, $this->option('filter')); $results = Ldap::findLdapUsers($search_base, -1, $this->option('filter'));
} else { } else {
$results = Ldap::findLdapUsers($search_base); $results = Ldap::findLdapUsers($search_base);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
if ($this->option('json_summary')) { if ($this->option('json_summary')) {
$json_summary = ['error' => true, 'error_message' => $e->getMessage(), 'summary' => []]; $json_summary = ['error' => true, 'error_message' => $e->getMessage(), 'summary' => []];
@ -121,7 +133,7 @@ class LdapSync extends Command
Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')'); Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')');
} }
} elseif ($this->option('location_id') != '') { } elseif ($this->option('location_id')) {
foreach($this->option('location_id') as $location_id) { foreach($this->option('location_id') as $location_id) {
if ($location = Location::where('id', '=', $location_id)->first()) { if ($location = Location::where('id', '=', $location_id)->first()) {
Log::debug('Location ID ' . $location_id . ' passed'); Log::debug('Location ID ' . $location_id . ' passed');
@ -239,6 +251,7 @@ class LdapSync extends Command
// Creating a new user. // Creating a new user.
$user = new User; $user = new User;
$user->password = $user->noPassword(); $user->password = $user->noPassword();
$user->locale = app()->getLocale();
$user->activated = 1; // newly created users can log in by default, unless AD's UAC is in use, or an active flag is set (below) $user->activated = 1; // newly created users can log in by default, unless AD's UAC is in use, or an active flag is set (below)
$item['createorupdate'] = 'created'; $item['createorupdate'] = 'created';
} }
@ -286,7 +299,7 @@ class LdapSync extends Command
try { try {
$ldap_manager = Ldap::findLdapUsers($item['manager'], -1, $this->option('filter')); $ldap_manager = Ldap::findLdapUsers($item['manager'], -1, $this->option('filter'));
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::warning("Manager lookup caused an exception: " . $e->getMessage() . ". Falling back to direct username lookup"); Log::warning("Manager lookup caused an exception: " . $e->getMessage() . ". Falling back to direct username lookup");
// Hail-mary for Okta manager 'shortnames' - will only work if // Hail-mary for Okta manager 'shortnames' - will only work if
// Okta configuration is using full email-address-style usernames // Okta configuration is using full email-address-style usernames
$ldap_manager = [ $ldap_manager = [
@ -378,7 +391,7 @@ class LdapSync extends Command
$user->location_id = $location->id; $user->location_id = $location->id;
} }
} }
$location = null;
$user->ldap_import = 1; $user->ldap_import = 1;
$errors = ''; $errors = '';

View file

@ -5,7 +5,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Models\Setting; use App\Models\Setting;
use Exception; use Exception;
use Crypt; use Illuminate\Support\Facades\Crypt;
/** /**
* Check if a given ip is in a network * Check if a given ip is in a network
@ -160,7 +160,7 @@ class LdapTroubleshooter extends Command
$output[] = "-x"; $output[] = "-x";
$output[] = "-b ".escapeshellarg($settings->ldap_basedn); $output[] = "-b ".escapeshellarg($settings->ldap_basedn);
$output[] = "-D ".escapeshellarg($settings->ldap_uname); $output[] = "-D ".escapeshellarg($settings->ldap_uname);
$output[] = "-w ".escapeshellarg(\Crypt::Decrypt($settings->ldap_pword)); $output[] = "-w ".escapeshellarg(Crypt::Decrypt($settings->ldap_pword));
$output[] = escapeshellarg(parenthesized_filter($settings->ldap_filter)); $output[] = escapeshellarg(parenthesized_filter($settings->ldap_filter));
if($settings->ldap_tls) { if($settings->ldap_tls) {
$this->line("# adding STARTTLS option"); $this->line("# adding STARTTLS option");

View file

@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Events\UserMerged;
use App\Models\User; use App\Models\User;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@ -51,7 +52,7 @@ class MergeUsersByUsername extends Command
$bad_users = User::where('username', '=', trim($parts[0])) $bad_users = User::where('username', '=', trim($parts[0]))
->whereNull('deleted_at') ->whereNull('deleted_at')
->with('assets', 'manager', 'userlog', 'licenses', 'consumables', 'accessories', 'managedLocations') ->with('assets', 'manager', 'userlog', 'licenses', 'consumables', 'accessories', 'managedLocations','uploads', 'acceptances')
->get(); ->get();
@ -105,10 +106,26 @@ class MergeUsersByUsername extends Command
$managedLocation->save(); $managedLocation->save();
} }
foreach ($bad_user->uploads as $upload) {
$this->info('Updating upload log record '.$upload->id.' to user '.$user->id);
$upload->item_id = $user->id;
$upload->save();
}
foreach ($bad_user->acceptances as $acceptance) {
$this->info('Updating acceptance log record '.$acceptance->id.' to user '.$user->id);
$acceptance->item_id = $user->id;
$acceptance->save();
}
// Mark the user as deleted // Mark the user as deleted
$this->info('Marking the user as deleted'); $this->info('Marking the user as deleted');
$bad_user->deleted_at = Carbon::now()->timestamp; $bad_user->deleted_at = Carbon::now()->timestamp;
$bad_user->save(); $bad_user->save();
event(new UserMerged($bad_user, $user, null));
} }
} }
} }

View file

@ -4,6 +4,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log;
class MoveUploadsToNewDisk extends Command class MoveUploadsToNewDisk extends Command
{ {
@ -74,7 +75,7 @@ class MoveUploadsToNewDisk extends Command
$new_url = Storage::disk('public')->url('uploads/'.$public_type.'/'.$filename, $filename); $new_url = Storage::disk('public')->url('uploads/'.$public_type.'/'.$filename, $filename);
$this->info($type_count.'. PUBLIC: '.$filename.' was copied to '.$new_url); $this->info($type_count.'. PUBLIC: '.$filename.' was copied to '.$new_url);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
$this->error($e); $this->error($e);
} }
} }
@ -116,7 +117,7 @@ class MoveUploadsToNewDisk extends Command
$new_url = Storage::url($private_type . '/' . $filename, $filename); $new_url = Storage::url($private_type . '/' . $filename, $filename);
$this->info($type_count . '. PRIVATE: ' . $filename . ' was copied to ' . $new_url); $this->info($type_count . '. PRIVATE: ' . $filename . ' was copied to ' . $new_url);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
$this->error($e); $this->error($e);
} }
} }
@ -140,7 +141,7 @@ class MoveUploadsToNewDisk extends Command
unlink($filename); unlink($filename);
$public_delete_count++; $public_delete_count++;
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
$this->error($e); $this->error($e);
} }
} }
@ -153,7 +154,7 @@ class MoveUploadsToNewDisk extends Command
unlink($filename); unlink($filename);
$private_delete_count++; $private_delete_count++;
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
$this->error($e); $this->error($e);
} }
} }

View file

@ -5,6 +5,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Illuminate\Support\Facades\Log;
ini_set('max_execution_time', env('IMPORT_TIME_LIMIT', 600)); //600 seconds = 10 minutes ini_set('max_execution_time', env('IMPORT_TIME_LIMIT', 600)); //600 seconds = 10 minutes
ini_set('memory_limit', env('IMPORT_MEMORY_LIMIT', '500M')); ini_set('memory_limit', env('IMPORT_MEMORY_LIMIT', '500M'));
@ -59,7 +60,7 @@ class ObjectImportCommand extends Command
// This $logFile/useFiles() bit is currently broken, so commenting it out for now // This $logFile/useFiles() bit is currently broken, so commenting it out for now
// $logFile = $this->option('logfile'); // $logFile = $this->option('logfile');
// \Log::useFiles($logFile); // Log::useFiles($logFile);
$this->comment('======= Importing Items from '.$filename.' ========='); $this->comment('======= Importing Items from '.$filename.' =========');
$importer->import(); $importer->import();
@ -112,10 +113,10 @@ class ObjectImportCommand extends Command
public function log($string, $level = 'info') public function log($string, $level = 'info')
{ {
if ($level === 'warning') { if ($level === 'warning') {
\Log::warning($string); Log::warning($string);
$this->comment($string); $this->comment($string);
} else { } else {
\Log::Info($string); Log::Info($string);
if ($this->option('verbose')) { if ($this->option('verbose')) {
$this->comment($string); $this->comment($string);
} }

View file

@ -5,7 +5,7 @@ namespace App\Console\Commands;
use App\Models\Asset; use App\Models\Asset;
use App\Models\CustomField; use App\Models\CustomField;
use Schema; use Schema;
use DB; use Illuminate\Support\Facades\DB;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class PaveIt extends Command class PaveIt extends Command

View file

@ -3,6 +3,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Actionlog;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetModel; use App\Models\AssetModel;
use App\Models\Category; use App\Models\Category;
@ -15,6 +16,8 @@ use App\Models\Statuslabel;
use App\Models\Supplier; use App\Models\Supplier;
use App\Models\User; use App\Models\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class Purge extends Command class Purge extends Command
{ {
@ -141,6 +144,20 @@ class Purge extends Command
$this->info($users->count().' users purged.'); $this->info($users->count().' users purged.');
$user_assoc = 0; $user_assoc = 0;
foreach ($users as $user) { foreach ($users as $user) {
$rel_path = 'private_uploads/users';
$filenames = Actionlog::where('action_type', 'uploaded')
->where('item_id', $user->id)
->pluck('filename');
foreach($filenames as $filename) {
try {
if (Storage::exists($rel_path . '/' . $filename)) {
Storage::delete($rel_path . '/' . $filename);
}
} catch (\Exception $e) {
Log::info('An error occurred while deleting files: ' . $e->getMessage());
}
}
$this->info('- User "'.$user->username.'" deleted.'); $this->info('- User "'.$user->username.'" deleted.');
$user_assoc += $user->userlog()->count(); $user_assoc += $user->userlog()->count();
$user->userlog()->forceDelete(); $user->userlog()->forceDelete();

View file

@ -103,7 +103,7 @@ class RecryptFromMcrypt extends Command
$this->comment('INFO: No LDAP password found. Skipping... '); $this->comment('INFO: No LDAP password found. Skipping... ');
} else { } else {
$decrypted_ldap_pword = $mcrypter->decrypt($settings->ldap_pword); $decrypted_ldap_pword = $mcrypter->decrypt($settings->ldap_pword);
$settings->ldap_pword = \Crypt::encrypt($decrypted_ldap_pword); $settings->ldap_pword = Crypt::encrypt($decrypted_ldap_pword);
$settings->save(); $settings->save();
} }
/** @var CustomField[] $custom_fields */ /** @var CustomField[] $custom_fields */
@ -132,7 +132,7 @@ class RecryptFromMcrypt extends Command
// Try to decrypt the payload using the legacy app key // Try to decrypt the payload using the legacy app key
try { try {
$decrypted_field = $mcrypter->decrypt($asset->{$columnName}); $decrypted_field = $mcrypter->decrypt($asset->{$columnName});
$asset->{$columnName} = \Crypt::encrypt($decrypted_field); $asset->{$columnName} = Crypt::encrypt($decrypted_field);
$this->comment($decrypted_field); $this->comment($decrypted_field);
} catch (\Exception $e) { } catch (\Exception $e) {
$errors[] = ' - ERROR: Could not decrypt field ['.$encrypted_field->name.']: '.$e->getMessage(); $errors[] = ' - ERROR: Could not decrypt field ['.$encrypted_field->name.']: '.$e->getMessage();

View file

@ -4,7 +4,7 @@ namespace App\Console\Commands;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Setting; use App\Models\Setting;
use Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class RegenerateAssetTags extends Command class RegenerateAssetTags extends Command

View file

@ -63,7 +63,7 @@ class ResetDemoSettings extends Command
$settings->date_display_format = 'D M d, Y'; $settings->date_display_format = 'D M d, Y';
$settings->time_display_format = 'g:iA'; $settings->time_display_format = 'g:iA';
$settings->thumbnail_max_h = '30'; $settings->thumbnail_max_h = '30';
$settings->locale = 'en'; $settings->locale = 'en-US';
$settings->version_footer = 'on'; $settings->version_footer = 'on';
$settings->support_footer = null; $settings->support_footer = null;
$settings->saml_enabled = '0'; $settings->saml_enabled = '0';
@ -73,12 +73,13 @@ class ResetDemoSettings extends Command
$settings->saml_forcelogin = '0'; $settings->saml_forcelogin = '0';
$settings->saml_slo = null; $settings->saml_slo = null;
$settings->saml_custom_settings = null; $settings->saml_custom_settings = null;
$settings->default_avatar = 'default.png';
$settings->save(); $settings->save();
if ($user = User::where('username', '=', 'admin')->first()) { if ($user = User::where('username', '=', 'admin')->first()) {
$user->locale = 'en'; $user->locale = 'en-US';
$user->save(); $user->save();
} }

View file

@ -6,8 +6,8 @@ use App\Models\Actionlog;
use App\Models\Asset; use App\Models\Asset;
use App\Models\License; use App\Models\License;
use App\Models\User; use App\Models\User;
use Artisan; use Illuminate\Support\Facades\Artisan;
use DB; use Illuminate\Support\Facades\DB;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class RestoreDeletedUsers extends Command class RestoreDeletedUsers extends Command

View file

@ -4,6 +4,159 @@ namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use ZipArchive; use ZipArchive;
use Illuminate\Support\Facades\Log;
class SQLStreamer {
private $input;
private $output;
// embed the prefix here?
public ?string $prefix;
private bool $reading_beginning_of_line = true;
public static $buffer_size = 1024 * 1024; // use a 1MB buffer, ought to work fine for most cases?
public array $tablenames = [];
private bool $should_guess = false;
private bool $statement_is_permitted = false;
public function __construct($input, $output, string $prefix = null)
{
$this->input = $input;
$this->output = $output;
$this->prefix = $prefix;
}
public function parse_sql(string $line): string {
// take into account the 'start of line or not' setting as an instance variable?
// 'continuation' lines for a permitted statement are PERMITTED.
// remove *only* line-feeds & carriage-returns; helpful for regexes against lines from
// Windows dumps
$line = trim($line, "\r\n");
if($this->statement_is_permitted && $line[0] === ' ') {
return $line . "\n"; //re-add the newline
}
$table_regex = '`?([a-zA-Z0-9_]+)`?';
$allowed_statements = [
"/^(DROP TABLE (?:IF EXISTS )?)`$table_regex(.*)$/" => false,
"/^(CREATE TABLE )$table_regex(.*)$/" => true, //sets up 'continuation'
"/^(LOCK TABLES )$table_regex(.*)$/" => false,
"/^(INSERT INTO )$table_regex(.*)$/" => false,
"/^UNLOCK TABLES/" => false,
// "/^\\) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;/" => false, // FIXME not sure what to do here?
"/^\\)[a-zA-Z0-9_= ]*;$/" => false,
// ^^^^^^ that bit should *exit* the 'permitted' block
"/^\\(.*\\)[,;]$/" => false, //older MySQL dump style with one set of values per line
/* we *could* have made the ^INSERT INTO blah VALUES$ turn on the capturing state, and closed it with
a ^(blahblah);$ but it's cleaner to not have to manage the state machine. We're just going to
assume that (blahblah), or (blahblah); are values for INSERT and are always acceptable. */
];
foreach($allowed_statements as $statement => $statechange) {
// $this->info("Checking regex: $statement...\n");
$matches = [];
if (preg_match($statement,$line,$matches)) {
$this->statement_is_permitted = $statechange;
// matches are: 1 => first part of the statement, 2 => tablename, 3 => rest of statement
// (with of course 0 being "the whole match")
if (@$matches[2]) {
// print "Found a tablename! It's: ".$matches[2]."\n";
if ($this->should_guess) {
@$this->tablenames[$matches[2]] += 1;
continue; //oh? FIXME
} else {
$cleaned_tablename = \DB::getTablePrefix().preg_replace('/^'.$this->prefix.'/','',$matches[2]);
$line = preg_replace($statement,'$1`'.$cleaned_tablename.'`$3' , $line);
}
} else {
// no explicit tablename in this one, leave the line alone
}
//how do we *replace* the tablename?
// print "RETURNING LINE: $line";
return $line . "\n"; //re-add newline
}
}
// all that is not allowed is denied.
return "";
}
//this is used in exactly *TWO* places, and in both cases should return a prefix I think?
// first - if you do the --sanitize-only one (which is mostly for testing/development)
// next - when you run *without* a guessed prefix, this is run first to figure out the prefix
// I think we have to *duplicate* the call to be able to run it again?
public static function guess_prefix($input):string
{
$parser = new self($input, null);
$parser->should_guess = true;
$parser->line_aware_piping(); // <----- THIS is doing the heavy lifting!
$check_tables = ['settings' => null, 'migrations' => null /* 'assets' => null */]; //TODO - move to statics?
//can't use 'users' because the 'accessories_checkout' table?
// can't use 'assets' because 'ver1_components_assets'
foreach($check_tables as $check_table => $_ignore) {
foreach ($parser->tablenames as $tablename => $_count) {
// print "Comparing $tablename to $check_table\n";
if (str_ends_with($tablename,$check_table)) {
// print "Found one!\n";
$check_tables[$check_table] = substr($tablename,0,-strlen($check_table));
}
}
}
$guessed_prefix = null;
foreach ($check_tables as $clean_table => $prefix_guess) {
if(is_null($prefix_guess)) {
print("Couldn't find table $clean_table\n");
die();
}
if(is_null($guessed_prefix)) {
$guessed_prefix = $prefix_guess;
} else {
if ($guessed_prefix != $prefix_guess) {
print("Prefix mismatch! Had guessed $guessed_prefix but got $prefix_guess\n");
die();
}
}
}
return $guessed_prefix;
}
public function line_aware_piping(): int
{
$bytes_read = 0;
if (! $this->input) {
throw new \Exception("No Input available for line_aware_piping");
}
while (($buffer = fgets($this->input, SQLStreamer::$buffer_size)) !== false) {
$bytes_read += strlen($buffer);
if ($this->reading_beginning_of_line) {
// Log::debug("Buffer is: '$buffer'");
$cleaned_buffer = $this->parse_sql($buffer);
if ($this->output) {
$bytes_written = fwrite($this->output, $cleaned_buffer);
if ($bytes_written === false) {
throw new \Exception("Unable to write to pipe");
}
}
}
// if we got a newline at the end of this, then the _next_ read is the beginning of a line
if($buffer[strlen($buffer)-1] === "\n") {
$this->reading_beginning_of_line = true;
} else {
$this->reading_beginning_of_line = false;
}
}
return $bytes_read;
}
}
class RestoreFromBackup extends Command class RestoreFromBackup extends Command
{ {
@ -12,10 +165,14 @@ class RestoreFromBackup extends Command
* *
* @var string * @var string
*/ */
// FIXME - , stripping prefixes and nonstandard SQL statements. Without --prefix, guess and return the correct prefix to strip
protected $signature = 'snipeit:restore protected $signature = 'snipeit:restore
{--force : Skip the danger prompt; assuming you enter "y"} {--force : Skip the danger prompt; assuming you enter "y"}
{filename : The zip file to be migrated} {filename : The zip file to be migrated}
{--no-progress : Don\'t show a progress bar}'; {--no-progress : Don\'t show a progress bar}
{--sanitize-guess-prefix : Guess and output the table-prefix needed to "sanitize" the SQL}
{--sanitize-with-prefix= : "Sanitize" the SQL, using the passed-in table prefix (can be learned from --sanitize-guess-prefix). Pass as just \'--sanitize-with-prefix=\' to use no prefix}
{--sql-stdout-only : ONLY "Sanitize" the SQL and print it to stdout - useful for debugging - probably requires --sanitize-with-prefix= }';
/** /**
* The console command description. * The console command description.
@ -34,8 +191,6 @@ class RestoreFromBackup extends Command
parent::__construct(); parent::__construct();
} }
public static $buffer_size = 1024 * 1024; // use a 1MB buffer, ought to work fine for most cases?
/** /**
* Execute the console command. * Execute the console command.
* *
@ -45,7 +200,7 @@ class RestoreFromBackup extends Command
{ {
$dir = getcwd(); $dir = getcwd();
if( $dir != base_path() ) { // usually only the case when running via webserver, not via command-line if( $dir != base_path() ) { // usually only the case when running via webserver, not via command-line
\Log::debug("Current working directory is: $dir, changing directory to: ".base_path()); Log::debug("Current working directory is: $dir, changing directory to: ".base_path());
chdir(base_path()); // TODO - is this *safe* to change on a running script?! chdir(base_path()); // TODO - is this *safe* to change on a running script?!
} }
// //
@ -55,7 +210,7 @@ class RestoreFromBackup extends Command
return $this->error('Missing required filename'); return $this->error('Missing required filename');
} }
if (! $this->option('force') && ! $this->confirm('Are you sure you wish to restore from the given backup file? This can lead to MASSIVE DATA LOSS!')) { if (! $this->option('force') && ! $this->option('sanitize-guess-prefix') && ! $this->confirm('Are you sure you wish to restore from the given backup file? This can lead to MASSIVE DATA LOSS!')) {
return $this->error('Data loss not confirmed'); return $this->error('Data loss not confirmed');
} }
@ -84,35 +239,36 @@ class RestoreFromBackup extends Command
$private_dirs = [ $private_dirs = [
'storage/private_uploads/accessories',
'storage/private_uploads/assetmodels',
'storage/private_uploads/assets', // these are asset _files_, not the pictures. 'storage/private_uploads/assets', // these are asset _files_, not the pictures.
'storage/private_uploads/audits', 'storage/private_uploads/audits',
'storage/private_uploads/components',
'storage/private_uploads/consumables',
'storage/private_uploads/eula-pdfs',
'storage/private_uploads/imports', 'storage/private_uploads/imports',
'storage/private_uploads/assetmodels',
'storage/private_uploads/users',
'storage/private_uploads/licenses', 'storage/private_uploads/licenses',
'storage/private_uploads/signatures', 'storage/private_uploads/signatures',
'storage/private_uploads/users',
]; ];
$private_files = [ $private_files = [
'storage/oauth-private.key', 'storage/oauth-private.key',
'storage/oauth-public.key', 'storage/oauth-public.key',
]; ];
$public_dirs = [ $public_dirs = [
'public/uploads/accessories',
'public/uploads/assets', // these are asset _pictures_, not asset files
'public/uploads/avatars',
//'public/uploads/barcodes', // we don't want this, let the barcodes be regenerated
'public/uploads/categories',
'public/uploads/companies', 'public/uploads/companies',
'public/uploads/components', 'public/uploads/components',
'public/uploads/categories',
'public/uploads/manufacturers',
//'public/uploads/barcodes', // we don't want this, let the barcodes be regenerated
'public/uploads/consumables', 'public/uploads/consumables',
'public/uploads/departments', 'public/uploads/departments',
'public/uploads/avatars',
'public/uploads/suppliers',
'public/uploads/assets', // these are asset _pictures_, not asset files
'public/uploads/locations', 'public/uploads/locations',
'public/uploads/accessories',
'public/uploads/models',
'public/uploads/categories',
'public/uploads/avatars',
'public/uploads/manufacturers', 'public/uploads/manufacturers',
'public/uploads/models',
'public/uploads/suppliers',
]; ];
$public_files = [ $public_files = [
@ -150,18 +306,18 @@ class RestoreFromBackup extends Command
continue; continue;
} }
if (@pathinfo($raw_path, PATHINFO_EXTENSION) == 'sql') { if (@pathinfo($raw_path, PATHINFO_EXTENSION) == 'sql') {
\Log::debug("Found a sql file!"); Log::debug("Found a sql file!");
$sqlfiles[] = $raw_path; $sqlfiles[] = $raw_path;
$sqlfile_indices[] = $i; $sqlfile_indices[] = $i;
continue; continue;
} }
foreach (array_merge($private_dirs, $public_dirs) as $dir) { foreach (array_merge($private_dirs, $public_dirs) as $dir) {
$last_pos = strrpos($raw_path, $dir.'/'); $last_pos = strrpos($raw_path, $dir . '/');
if ($last_pos !== false) { if ($last_pos !== false) {
//print("INTERESTING - last_pos is $last_pos when searching $raw_path for $dir - last_pos+strlen(\$dir) is: ".($last_pos+strlen($dir))." and strlen(\$rawpath) is: ".strlen($raw_path)."\n"); //print("INTERESTING - last_pos is $last_pos when searching $raw_path for $dir - last_pos+strlen(\$dir) is: ".($last_pos+strlen($dir))." and strlen(\$rawpath) is: ".strlen($raw_path)."\n");
//print("We would copy $raw_path to $dir.\n"); //FIXME append to a path? //print("We would copy $raw_path to $dir.\n"); //FIXME append to a path?
$interesting_files[$raw_path] = ['dest' =>$dir, 'index' => $i]; $interesting_files[$raw_path] = ['dest' => $dir, 'index' => $i];
continue 2; continue 2;
if ($last_pos + strlen($dir) + 1 == strlen($raw_path)) { if ($last_pos + strlen($dir) + 1 == strlen($raw_path)) {
// we don't care about that; we just want files with the appropriate prefix // we don't care about that; we just want files with the appropriate prefix
@ -170,7 +326,7 @@ class RestoreFromBackup extends Command
} }
} }
$good_extensions = ['png', 'gif', 'jpg', 'svg', 'jpeg', 'doc', 'docx', 'pdf', 'txt', $good_extensions = ['png', 'gif', 'jpg', 'svg', 'jpeg', 'doc', 'docx', 'pdf', 'txt',
'zip', 'rar', 'xls', 'xlsx', 'lic', 'xml', 'rtf', 'webp', 'key', 'ico', ]; 'zip', 'rar', 'xls', 'xlsx', 'lic', 'xml', 'rtf', 'webp', 'key', 'ico',];
foreach (array_merge($private_files, $public_files) as $file) { foreach (array_merge($private_files, $public_files) as $file) {
$has_wildcard = (strpos($file, '*') !== false); $has_wildcard = (strpos($file, '*') !== false);
if ($has_wildcard) { if ($has_wildcard) {
@ -179,8 +335,8 @@ class RestoreFromBackup extends Command
$last_pos = strrpos($raw_path, $file); // no trailing slash! $last_pos = strrpos($raw_path, $file); // no trailing slash!
if ($last_pos !== false) { if ($last_pos !== false) {
$extension = strtolower(pathinfo($raw_path, PATHINFO_EXTENSION)); $extension = strtolower(pathinfo($raw_path, PATHINFO_EXTENSION));
if (! in_array($extension, $good_extensions)) { if (!in_array($extension, $good_extensions)) {
$this->warn('Potentially unsafe file '.$raw_path.' is being skipped'); $this->warn('Potentially unsafe file ' . $raw_path . ' is being skipped');
$boring_files[] = $raw_path; $boring_files[] = $raw_path;
continue 2; continue 2;
} }
@ -195,7 +351,6 @@ class RestoreFromBackup extends Command
} }
$boring_files[] = $raw_path; //if we've gotten to here and haven't continue'ed our way into the next iteration, we don't want this file $boring_files[] = $raw_path; //if we've gotten to here and haven't continue'ed our way into the next iteration, we don't want this file
} // end of pre-processing the ZIP file for-loop } // end of pre-processing the ZIP file for-loop
// print_r($interesting_files);exit(-1); // print_r($interesting_files);exit(-1);
if (count($sqlfiles) != 1) { if (count($sqlfiles) != 1) {
@ -207,6 +362,26 @@ class RestoreFromBackup extends Command
//older Snipe-IT installs don't have the db-dumps subdirectory component //older Snipe-IT installs don't have the db-dumps subdirectory component
} }
$sql_stat = $za->statIndex($sqlfile_indices[0]);
//$this->info("SQL Stat is: ".print_r($sql_stat,true));
$sql_contents = $za->getStream($sql_stat['name']); // maybe copy *THIS* thing?
// OKAY, now that we *found* the sql file if we're doing just the guess-prefix thing, we can do that *HERE* I think?
if ($this->option('sanitize-guess-prefix')) {
$prefix = SQLStreamer::guess_prefix($sql_contents);
$this->line($prefix);
return $this->info("Re-run this command with '--sanitize-with-prefix=".$prefix."' to see an attempt to sanitze your SQL.");
}
// If we're doing --sql-stdout-only, handle that now so we don't have to open pipes to mysql and all of that silliness
if ($this->option('sql-stdout-only')) {
$sql_importer = new SQLStreamer($sql_contents, STDOUT, $this->option('sanitize-with-prefix'));
$bytes_read = $sql_importer->line_aware_piping();
return $this->warn("$bytes_read total bytes read");
//TODO - it'd be nice to dump this message to STDERR so that STDOUT is just pure SQL,
// which would be good for redirecting to a file, and not having to trim the last line off of it
}
//how to invoke the restore? //how to invoke the restore?
$pipes = []; $pipes = [];
@ -227,6 +402,7 @@ class RestoreFromBackup extends Command
return $this->error('Unable to invoke mysql via CLI'); return $this->error('Unable to invoke mysql via CLI');
} }
// I'm not sure about these?
stream_set_blocking($pipes[1], false); // use non-blocking reads for stdout stream_set_blocking($pipes[1], false); // use non-blocking reads for stdout
stream_set_blocking($pipes[2], false); // use non-blocking reads for stderr stream_set_blocking($pipes[2], false); // use non-blocking reads for stderr
@ -237,9 +413,9 @@ class RestoreFromBackup extends Command
//$sql_contents = fopen($sqlfiles[0], "r"); //NOPE! This isn't a real file yet, silly-billy! //$sql_contents = fopen($sqlfiles[0], "r"); //NOPE! This isn't a real file yet, silly-billy!
$sql_stat = $za->statIndex($sqlfile_indices[0]); // FIXME - this feels like it wants to go somewhere else?
//$this->info("SQL Stat is: ".print_r($sql_stat,true)); // and it doesn't seem 'right' - if you can't get a stream to the .sql file,
$sql_contents = $za->getStream($sql_stat['name']); // why do we care what's happening with pipes and stdout and stderr?!
if ($sql_contents === false) { if ($sql_contents === false) {
$stdout = fgets($pipes[1]); $stdout = fgets($pipes[1]);
$this->info($stdout); $this->info($stdout);
@ -248,29 +424,35 @@ class RestoreFromBackup extends Command
return false; return false;
} }
$bytes_read = 0;
try { try {
while (($buffer = fgets($sql_contents, self::$buffer_size)) !== false) { if ( $this->option('sanitize-with-prefix') === null) {
// "Legacy" direct-piping
$bytes_read = 0;
while (($buffer = fgets($sql_contents, SQLStreamer::$buffer_size)) !== false) {
$bytes_read += strlen($buffer); $bytes_read += strlen($buffer);
// \Log::debug("Buffer is: '$buffer'"); // Log::debug("Buffer is: '$buffer'");
$bytes_written = fwrite($pipes[0], $buffer); $bytes_written = fwrite($pipes[0], $buffer);
if ($bytes_written === false) { if ($bytes_written === false) {
throw new Exception("Unable to write to pipe"); throw new Exception("Unable to write to pipe");
} }
} }
} else {
$sql_importer = new SQLStreamer($sql_contents, $pipes[0], $this->option('sanitize-with-prefix'));
$bytes_read = $sql_importer->line_aware_piping();
}
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::error("Error during restore!!!! ".$e->getMessage()); Log::error("Error during restore!!!! ".$e->getMessage());
// FIXME - put these back and/or put them in the right places?!
$err_out = fgets($pipes[1]); $err_out = fgets($pipes[1]);
$err_err = fgets($pipes[2]); $err_err = fgets($pipes[2]);
\Log::error("Error OUTPUT: ".$err_out); Log::error("Error OUTPUT: ".$err_out);
$this->info($err_out); $this->info($err_out);
\Log::error("Error ERROR : ".$err_err); Log::error("Error ERROR : ".$err_err);
$this->error($err_err); $this->error($err_err);
throw $e; throw $e;
} }
if (!feof($sql_contents) || $bytes_read == 0) { if (!feof($sql_contents) || $bytes_read == 0) {
return $this->error("Not at end of file for sql file, or zero bytes read. aborting!"); return $this->error("Not at end of file for sql file, or zero bytes read. aborting!");
} }
@ -301,8 +483,11 @@ class RestoreFromBackup extends Command
$ugly_file_name = $za->statIndex($file_details['index'])['name']; $ugly_file_name = $za->statIndex($file_details['index'])['name'];
$fp = $za->getStream($ugly_file_name); $fp = $za->getStream($ugly_file_name);
//$this->info("Weird problem, here are file details? ".print_r($file_details,true)); //$this->info("Weird problem, here are file details? ".print_r($file_details,true));
if (!is_dir($file_details['dest'])) {
mkdir($file_details['dest'], 0755, true); //0755 is what Laravel uses, so we do that
}
$migrated_file = fopen($file_details['dest'].'/'.basename($pretty_file_name), 'w'); $migrated_file = fopen($file_details['dest'].'/'.basename($pretty_file_name), 'w');
while (($buffer = fgets($fp, self::$buffer_size)) !== false) { while (($buffer = fgets($fp, SQLStreamer::$buffer_size)) !== false) {
fwrite($migrated_file, $buffer); fwrite($migrated_file, $buffer);
} }
fclose($migrated_file); fclose($migrated_file);

View file

@ -5,8 +5,9 @@ namespace App\Console\Commands;
use App\Models\Asset; use App\Models\Asset;
use App\Models\CustomField; use App\Models\CustomField;
use App\Models\Setting; use App\Models\Setting;
use Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Encryption\Encrypter; use Illuminate\Encryption\Encrypter;
class RotateAppKey extends Command class RotateAppKey extends Command
@ -16,14 +17,17 @@ class RotateAppKey extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'snipeit:rotate-key'; protected $signature = 'snipeit:rotate-key
{previous_key? : The previous key to rotate from}
{--emergency : Emergency mode - rotate from .env APP_KEY to newly-generated one, modifying .env}
{--force : Skip interactive confirmation}';
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string
*/ */
protected $description = 'Command description'; protected $description = 'Rotates APP_KEY to a new value, optionally taking the previous key as an argument';
/** /**
* Create a new command instance. * Create a new command instance.
@ -42,26 +46,42 @@ class RotateAppKey extends Command
*/ */
public function handle() public function handle()
{ {
if ($this->confirm("\n****************************************************\nTHIS WILL MODIFY YOUR APP_KEY AND DE-CRYPT YOUR ENCRYPTED CUSTOM FIELDS AND \nRE-ENCRYPT THEM WITH A NEWLY GENERATED KEY. \n\nThere is NO undo. \n\nMake SURE you have a database backup and a backup of your .env generated BEFORE running this command. \n\nIf you do not save the newly generated APP_KEY to your .env in this process, \nyour encrypted data will no longer be decryptable. \n\nAre you SURE you wish to continue, and have confirmed you have a database backup and an .env backup? ")) { //make sure they specify only exactly one of --emergency, or a filename. Not neither, and not both.
if ( (!$this->option('emergency') && !$this->argument('previous_key')) || ( $this->option('emergency') && $this->argument('previous_key'))) {
$this->error("Specify only one of --emergency, or an app key value, in order to rotate keys");
return 1;
}
if ( $this->option('emergency') ) {
$msg = "\n****************************************************\nTHIS WILL MODIFY YOUR APP_KEY AND DE-CRYPT YOUR ENCRYPTED CUSTOM FIELDS AND \nRE-ENCRYPT THEM WITH A NEWLY GENERATED KEY. \n\nThere is NO undo. \n\nMake SURE you have a database backup and a backup of your .env generated BEFORE running this command. \n\nIf you do not save the newly generated APP_KEY to your .env in this process, \nyour encrypted data will no longer be decryptable. \n\nAre you SURE you wish to continue, and have confirmed you have a database backup and an .env backup? ";
} else {
$msg = "\n****************************************************\nTHIS WILL DE-CRYPT YOUR ENCRYPTED CUSTOM FIELDS AND RE-ENCRYPT THEM WITH YOUR\nAPP_KEY.\n\nThere is NO undo. \n\nMake SURE you have a database backup BEFORE running this command. \n\nAre you SURE you wish to continue, and have confirmed you have a database backup? ";
}
if ($this->option('force') || $this->confirm($msg)) {
// Get the existing app_key and ciphers // Get the existing app_key and ciphers
// We put them in a variable since we clear the cache partway through here. // We put them in a variable since we clear the cache partway through here.
if ($this->option('emergency')) {
$old_app_key = config('app.key'); $old_app_key = config('app.key');
$cipher = config('app.cipher'); $cipher = config('app.cipher');
// Generate a new one // Generate a new one
Artisan::call('key:generate', ['--show' => true]); Artisan::call('key:generate', ['--show' => true]);
$new_app_key = Artisan::output(); $new_app_key = trim(Artisan::output());
// Clear the config cache // Clear the config cache
Artisan::call('config:clear'); Artisan::call('config:clear');
$this->warn('Your app cipher is: '.$cipher);
$this->warn('Your old APP_KEY is: '.$old_app_key);
$this->warn('Your new APP_KEY is: '.$new_app_key);
// Write the new app key to the .env file // Write the new app key to the .env file
$this->writeNewEnvironmentFileWith($new_app_key); $this->writeNewEnvironmentFileWith($new_app_key);
} elseif ($this->argument('previous_key')) {
$old_app_key = $this->argument('previous_key');
$cipher = config('app.cipher'); // just a guess?
$new_app_key = config('app.key');
}
$this->warn('Your app cipher is: ' . $cipher);
$this->warn('Your old APP_KEY is: ' . $old_app_key);
$this->warn('Your new APP_KEY is: ' . $new_app_key);
// Manually create an old encrypter instance using the old app key // Manually create an old encrypter instance using the old app key
// and also create a new encrypter instance so we can re-crypt the field // and also create a new encrypter instance so we can re-crypt the field
@ -75,8 +95,16 @@ class RotateAppKey extends Command
$assets = Asset::whereNotNull($field->db_column)->get(); $assets = Asset::whereNotNull($field->db_column)->get();
foreach ($assets as $asset) { foreach ($assets as $asset) {
try {
$asset->{$field->db_column} = $oldEncrypter->decrypt($asset->{$field->db_column}); $asset->{$field->db_column} = $oldEncrypter->decrypt($asset->{$field->db_column});
$this->line('DECRYPTED: '.$field->db_column); $this->line('DECRYPTED: ' . $field->db_column);
} catch (DecryptException $e) {
$this->line('Could not decrypt '. $field->db_column.' using "old key" - skipping...');
continue;
} catch (\Exception $e) {
$this->error("Error decrypting ".$field->db_column.", reason: ".$e->getMessage().". Aborting key rotation");
throw $e;
}
$asset->{$field->db_column} = $newEncrypter->encrypt($asset->{$field->db_column}); $asset->{$field->db_column} = $newEncrypter->encrypt($asset->{$field->db_column});
$this->line('ENCRYPTED: '.$field->db_column); $this->line('ENCRYPTED: '.$field->db_column);
$asset->save(); $asset->save();
@ -86,10 +114,14 @@ class RotateAppKey extends Command
// Handle the LDAP password if one is provided // Handle the LDAP password if one is provided
$setting = Setting::first(); $setting = Setting::first();
if ($setting->ldap_pword != '') { if ($setting->ldap_pword != '') {
try {
$setting->ldap_pword = $oldEncrypter->decrypt($setting->ldap_pword); $setting->ldap_pword = $oldEncrypter->decrypt($setting->ldap_pword);
$setting->ldap_pword = $newEncrypter->encrypt($setting->ldap_pword); $setting->ldap_pword = $newEncrypter->encrypt($setting->ldap_pword);
$setting->save(); $setting->save();
$this->warn('LDAP password has been re-encrypted.'); $this->warn('LDAP password has been re-encrypted.');
} catch(DecryptException $e) {
$this->warn("Unable to decrypt old LDAP password; skipping");
}
} }
} else { } else {
$this->info('This operation has been canceled. No changes have been made.'); $this->info('This operation has been canceled. No changes have been made.');
@ -106,7 +138,7 @@ class RotateAppKey extends Command
{ {
file_put_contents($this->laravel->environmentFilePath(), preg_replace( file_put_contents($this->laravel->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(), $this->keyReplacementPattern(),
'APP_KEY='.$key, 'APP_KEY="'.$key.'"',
file_get_contents($this->laravel->environmentFilePath()) file_get_contents($this->laravel->environmentFilePath())
)); ));
} }
@ -118,7 +150,7 @@ class RotateAppKey extends Command
*/ */
protected function keyReplacementPattern() protected function keyReplacementPattern()
{ {
$escaped = preg_quote('='.$this->laravel['config']['app.key'], '/'); $escaped = '="?'.preg_quote($this->laravel['config']['app.key'], '/').'"?';
return "/^APP_KEY{$escaped}/m"; return "/^APP_KEY{$escaped}/m";
} }

View file

@ -0,0 +1,44 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\SamlNonce;
class SamlClearExpiredNonces extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'saml:clear_expired_nonces';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clears out expired SAML assertions from the saml_nonces table';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
SamlNonce::where('not_valid_after','<=',now())->delete();
return 0;
}
}

View file

@ -0,0 +1,105 @@
<?php
namespace App\Console\Commands;
use App\Models\Asset;
use App\Models\CheckoutAcceptance;
use App\Models\Setting;
use App\Models\User;
use App\Notifications\CheckoutAssetNotification;
use App\Notifications\CurrentInventory;
use App\Notifications\UnacceptedAssetReminderNotification;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Notification;
class SendAcceptanceReminder extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'snipeit:acceptance-reminder';
/**
* The console command description.
*
* @var string
*/
protected $description = 'This will resend users with unaccepted assets a reminder to accept or decline them.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$pending = CheckoutAcceptance::pending()->where('checkoutable_type', 'App\Models\Asset')
->whereHas('checkoutable', function($query) {
$query->where('archived', 0);
})
->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model', 'checkoutable.adminuser'])
->get();
$count = 0;
$unacceptedAssetGroups = $pending
->filter(function($acceptance) {
return $acceptance->checkoutable_type == 'App\Models\Asset';
})
->map(function($acceptance) {
return ['assetItem' => $acceptance->checkoutable, 'acceptance' => $acceptance];
})
->groupBy(function($item) {
return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : '';
});
$no_mail_address = [];
foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {
$item_count = $unacceptedAssetGroup->count();
foreach ($unacceptedAssetGroup as $unacceptedAsset) {
// if ($unacceptedAsset['acceptance']->assignedTo->email == ''){
// $no_mail_address[] = $unacceptedAsset['checkoutable']->assignedTo->present()->fullName;
// }
if ($unacceptedAsset['acceptance']->assignedTo) {
if (!$unacceptedAsset['acceptance']->assignedTo->locale) {
Notification::locale(Setting::getSettings()->locale)->send(
$unacceptedAsset['acceptance']->assignedTo,
new UnacceptedAssetReminderNotification($unacceptedAsset['assetItem'], $count)
);
} else {
Notification::send(
$unacceptedAsset['acceptance']->assignedTo,
new UnacceptedAssetReminderNotification($unacceptedAsset, $item_count)
);
}
$count++;
}
}
}
if (!empty($no_mail_address)) {
foreach($no_mail_address as $user) {
return $user.' has no email.';
}
}
$this->info($count.' users notified.');
}
}

View file

@ -43,7 +43,7 @@ class SendCurrentInventoryToUsers extends Command
$count = 0; $count = 0;
foreach ($users as $user) { foreach ($users as $user) {
if (($user->assets->count() > 0) || ($user->accessories->count() > 0) || ($user->licenses->count() > 0)) { if (($user->assets->count() > 0) || ($user->accessories->count() > 0) || ($user->licenses->count() > 0) || ($user->consumables->count() > 0)) {
$count++; $count++;
$user->notify((new CurrentInventory($user))); $user->notify((new CurrentInventory($user)));
} }

View file

@ -42,24 +42,31 @@ class SendExpectedCheckinAlerts extends Command
public function handle() public function handle()
{ {
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$whenNotify = Carbon::now()->addDays(7); $interval = $settings->audit_warning_days ?? 0;
$assets = Asset::with('assignedTo')->whereNotNull('assigned_to')->whereNotNull('expected_checkin')->where('expected_checkin', '<=', $whenNotify)->get(); $today = Carbon::now();
$interval_date = $today->copy()->addDays($interval);
$assets = Asset::whereNull('deleted_at')->DueOrOverdueForCheckin($settings)->orderBy('assets.expected_checkin', 'desc')->get();
$this->info($assets->count().' assets must be checked in on or before '.$interval_date.' is deadline');
$this->info($whenNotify.' is deadline');
$this->info($assets->count().' assets');
foreach ($assets as $asset) { foreach ($assets as $asset) {
if ($asset->assigned && $asset->checkedOutToUser()) { if ($asset->assignedTo && (isset($asset->assignedTo->email)) && ($asset->assignedTo->email!='') && $asset->checkedOutToUser()) {
$asset->assigned->notify((new ExpectedCheckinNotification($asset))); $this->info('Sending User ExpectedCheckinNotification to: '.$asset->assignedTo->email);
$asset->assignedTo->notify((new ExpectedCheckinNotification($asset)));
} }
} }
if (($assets) && ($assets->count() > 0) && ($settings->alert_email != '')) { if (($assets) && ($assets->count() > 0) && ($settings->alert_email != '')) {
// Send a rollup to the admin, if settings dictate // Send a rollup to the admin, if settings dictate
$recipients = collect(explode(',', $settings->alert_email))->map(function ($item, $key) { $recipients = collect(explode(',', $settings->alert_email))->map(function ($item) {
return new AlertRecipient($item); return new AlertRecipient($item);
}); });
$this->info('Sending Admin ExpectedCheckinNotification to: '.$settings->alert_email);
\Notification::send($recipients, new ExpectedCheckinAdminNotification($assets)); \Notification::send($recipients, new ExpectedCheckinAdminNotification($assets));
} }
} }
} }

View file

@ -3,13 +3,11 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\Asset; use App\Models\Asset;
use App\Models\License; use App\Models\Recipients\AlertRecipient;
use App\Models\Recipients;
use App\Models\Setting; use App\Models\Setting;
use App\Notifications\ExpiringAssetsNotification;
use App\Notifications\SendUpcomingAuditNotification; use App\Notifications\SendUpcomingAuditNotification;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use Illuminate\Support\Facades\DB;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class SendUpcomingAuditReport extends Command class SendUpcomingAuditReport extends Command
@ -46,39 +44,24 @@ class SendUpcomingAuditReport extends Command
public function handle() public function handle()
{ {
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$interval = $settings->audit_warning_days ?? 0;
$today = Carbon::now();
$interval_date = $today->copy()->addDays($interval);
if (($settings->alert_email != '') && ($settings->audit_warning_days) && ($settings->alerts_enabled == 1)) { $assets = Asset::whereNull('deleted_at')->DueOrOverdueForAudit($settings)->orderBy('assets.next_audit_date', 'desc')->get();
$this->info($assets->count().' assets must be audited in on or before '.$interval_date.' is deadline');
if (($assets) && ($assets->count() > 0) && ($settings->alert_email != '')) {
// Send a rollup to the admin, if settings dictate // Send a rollup to the admin, if settings dictate
$recipients = collect(explode(',', $settings->alert_email))->map(function ($item, $key) { $recipients = collect(explode(',', $settings->alert_email))->map(function ($item) {
return new \App\Models\Recipients\AlertRecipient($item); return new AlertRecipient($item);
}); });
// Assets due for auditing $this->info('Sending Admin SendUpcomingAuditNotification to: '.$settings->alert_email);
$assets = Asset::whereNotNull('next_audit_date')
->DueOrOverdueForAudit($settings)
->orderBy('last_audit_date', 'asc')->get();
if ($assets->count() > 0) {
$this->info(trans_choice('mail.upcoming-audits', $assets->count(),
['count' => $assets->count(), 'threshold' => $settings->audit_warning_days]));
\Notification::send($recipients, new SendUpcomingAuditNotification($assets, $settings->audit_warning_days)); \Notification::send($recipients, new SendUpcomingAuditNotification($assets, $settings->audit_warning_days));
$this->info('Audit report sent to '.$settings->alert_email);
} else {
$this->info('No assets to be audited. No report sent.');
}
} elseif ($settings->alert_email == '') {
$this->error('Could not send email. No alert email configured in settings');
} elseif (! $settings->audit_warning_days) {
$this->error('No audit warning days set in Admin Notifications. No mail will be sent.');
} elseif ($settings->alerts_enabled != 1) {
$this->info('Alerts are disabled in the settings. No mail will be sent');
} else {
$this->error('Something went wrong. :( ');
$this->error('Admin Notifications Email Setting: '.$settings->alert_email);
$this->error('Admin Audit Warning Setting: '.$settings->audit_warning_days);
$this->error('Admin Alerts Emnabled: '.$settings->alerts_enabled);
} }
} }
} }

View file

@ -4,6 +4,7 @@ namespace App\Console\Commands;
use App\Models\Asset; use App\Models\Asset;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class SyncAssetCounters extends Command class SyncAssetCounters extends Command
{ {
@ -58,7 +59,7 @@ class SyncAssetCounters extends Command
$asset->save(); $asset->save();
$bar->advance(); $bar->advance();
\Log::debug('Asset: '.$asset->id.' has '.$asset->checkin_counter.' checkins, '.$asset->checkout_counter.' checkouts, and '.$asset->requests_counter.' requests'); Log::debug('Asset: '.$asset->id.' has '.$asset->checkin_counter.' checkins, '.$asset->checkout_counter.' checkouts, and '.$asset->requests_counter.' requests');
} }

View file

@ -0,0 +1,76 @@
<?php
namespace App\Console\Commands;
use App\Models\Asset;
use App\Models\CustomField;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class ToggleCustomfieldEncryption extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'snipeit:customfield-encryption
{fieldname : the db_column_name of the field}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'This command should be used to convert an unencrypted custom field into a custom field and encrypt the associated data in the assets table for that column.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$fieldname = $this->argument('fieldname');
if ($field = CustomField::where('db_column', $fieldname)->first()) {
// If the field is not encrypted, make it encrypted and encrypt the data in the assets table for the
// corresponding field.
DB::transaction(function () use ($field) {
if ($field->field_encrypted == 0) {
$assets = Asset::whereNotNull($field->db_column)->get();
foreach ($assets as $asset) {
$asset->{$field->db_column} = encrypt($asset->{$field->db_column});
$asset->save();
}
$field->field_encrypted = 1;
$field->save();
// This field is already encrypted. Do nothing.
} else {
$this->error('The custom field ' . $field->db_column.' is already encrypted. No action was taken.');
}
});
// No matching column name found
} else {
$this->error('No matching results for unencrypted custom fields with db_column name: ' . $fieldname.'. Please check the fieldname.');
}
}
}

View file

@ -25,6 +25,7 @@ class Kernel extends ConsoleKernel
$schedule->command('backup:clean')->daily(); $schedule->command('backup:clean')->daily();
$schedule->command('snipeit:upcoming-audits')->daily(); $schedule->command('snipeit:upcoming-audits')->daily();
$schedule->command('auth:clear-resets')->everyFifteenMinutes(); $schedule->command('auth:clear-resets')->everyFifteenMinutes();
$schedule->command('saml:clear_expired_nonces')->weekly();
} }
/** /**

View file

@ -15,7 +15,7 @@ class UserMerged
* *
* @return void * @return void
*/ */
public function __construct(User $from_user, User $to_user, User $admin) public function __construct(User $from_user, User $to_user, ?User $admin)
{ {
$this->merged_from = $from_user; $this->merged_from = $from_user;
$this->merged_to = $to_user; $this->merged_to = $to_user;

View file

@ -7,7 +7,7 @@ use App\Helpers\Helper;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException; use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException;
use Log; use Illuminate\Support\Facades\Log;
use Throwable; use Throwable;
use JsonException; use JsonException;
use Carbon\Exceptions\InvalidFormatException; use Carbon\Exceptions\InvalidFormatException;
@ -44,8 +44,8 @@ class Handler extends ExceptionHandler
public function report(Throwable $exception) public function report(Throwable $exception)
{ {
if ($this->shouldReport($exception)) { if ($this->shouldReport($exception)) {
if (class_exists(\Log::class)) { if (class_exists(Log::class)) {
\Log::error($exception); Log::error($exception);
} }
return parent::report($exception); return parent::report($exception);
} }

View file

@ -11,13 +11,74 @@ use App\Models\CustomFieldset;
use App\Models\Depreciation; use App\Models\Depreciation;
use App\Models\Setting; use App\Models\Setting;
use App\Models\Statuslabel; use App\Models\Statuslabel;
use Crypt; use App\Models\License;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Image;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Intervention\Image\ImageManagerStatic as Image;
use Illuminate\Support\Facades\Session;
class Helper class Helper
{ {
/**
* This is only used for reversing the migration that updates the locale to the 5-6 letter codes from two
* letter codes. The normal dropdowns use the autoglossonyms in the language files located
* in resources/en-US/localizations.php.
*/
public static $language_map = [
'af' => 'af-ZA', // Afrikaans
'am' => 'am-ET', // Amharic
'ar' => 'ar-SA', // Arabic
'bg' => 'bg-BG', // Bulgarian
'ca' => 'ca-ES', // Catalan
'cs' => 'cs-CZ', // Czech
'cy' => 'cy-GB', // Welsh
'da' => 'da-DK', // Danish
'de-i' => 'de-if', // German informal
'de' => 'de-DE', // German
'el' => 'el-GR', // Greek
'en' => 'en-US', // English
'et' => 'et-EE', // Estonian
'fa' => 'fa-IR', // Persian
'fi' => 'fi-FI', // Finnish
'fil' => 'fil-PH', // Filipino
'fr' => 'fr-FR', // French
'he' => 'he-IL', // Hebrew
'hr' => 'hr-HR', // Croatian
'hu' => 'hu-HU', // Hungarian
'id' => 'id-ID', // Indonesian
'is' => 'is-IS', // Icelandic
'it' => 'it-IT', // Italian
'iu' => 'iu-NU', // Inuktitut
'ja' => 'ja-JP', // Japanese
'ko' => 'ko-KR', // Korean
'lt' => 'lt-LT', // Lithuanian
'lv' => 'lv-LV', // Latvian
'mi' => 'mi-NZ', // Maori
'mk' => 'mk-MK', // Macedonian
'mn' => 'mn-MN', // Mongolian
'ms' => 'ms-MY', // Malay
'nl' => 'nl-NL', // Dutch
'no' => 'nb-NO', // Norwegian Bokmål
'pl' => 'pl-PL', // Polish
'pt' => 'pt-PT', // Portuguese
'ro' => 'ro-RO', // Romanian
'ru' => 'ru-RU', // Russian
'sk' => 'sk-SK', // Slovak
'sl' => 'sl-SI', // Slovenian
'so' => 'so-SO', // Somali
'ta' => 'ta-IN', // Tamil
'th' => 'th-TH', // Thai
'tl' => 'tl-PH', // Tagalog
'tr' => 'tr-TR', // Turkish
'uk' => 'uk-UA', // Ukrainian
'vi' => 'vi-VN', // Vietnamese
'zu' => 'zu-ZA', // Zulu
];
/** /**
* Simple helper to invoke the markdown parser * Simple helper to invoke the markdown parser
* *
@ -354,7 +415,7 @@ class Helper
if ($index >= $total_colors) { if ($index >= $total_colors) {
\Log::error('Status label count is '.$index.' and exceeds the allowed count of 266.'); Log::info('Status label count is '.$index.' and exceeds the allowed count of 266.');
//patch fix for array key overflow (color count starts at 1, array starts at 0) //patch fix for array key overflow (color count starts at 1, array starts at 0)
$index = $index - $total_colors - 1; $index = $index - $total_colors - 1;
@ -658,18 +719,19 @@ class Helper
*/ */
public static function checkLowInventory() public static function checkLowInventory()
{ {
$alert_threshold = \App\Models\Setting::getSettings()->alert_threshold;
$consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get(); $consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get();
$accessories = Accessory::withCount('users as users_count')->whereNotNull('min_amt')->get(); $accessories = Accessory::withCount('checkouts as checkouts_count')->whereNotNull('min_amt')->get();
$components = Component::whereNotNull('min_amt')->get(); $components = Component::whereNotNull('min_amt')->get();
$asset_models = AssetModel::where('min_amt', '>', 0)->get(); $asset_models = AssetModel::where('min_amt', '>', 0)->get();
$licenses = License::where('min_amt', '>', 0)->get();
$avail_consumables = 0;
$items_array = []; $items_array = [];
$all_count = 0; $all_count = 0;
foreach ($consumables as $consumable) { foreach ($consumables as $consumable) {
$avail = $consumable->numRemaining(); $avail = $consumable->numRemaining();
if ($avail < ($consumable->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) { if ($avail < ($consumable->min_amt) + $alert_threshold) {
if ($consumable->qty > 0) { if ($consumable->qty > 0) {
$percent = number_format((($avail / $consumable->qty) * 100), 0); $percent = number_format((($avail / $consumable->qty) * 100), 0);
} else { } else {
@ -687,8 +749,8 @@ class Helper
} }
foreach ($accessories as $accessory) { foreach ($accessories as $accessory) {
$avail = $accessory->qty - $accessory->users_count; $avail = $accessory->qty - $accessory->checkouts_count;
if ($avail < ($accessory->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) { if ($avail < ($accessory->min_amt) + $alert_threshold) {
if ($accessory->qty > 0) { if ($accessory->qty > 0) {
$percent = number_format((($avail / $accessory->qty) * 100), 0); $percent = number_format((($avail / $accessory->qty) * 100), 0);
} else { } else {
@ -707,7 +769,7 @@ class Helper
foreach ($components as $component) { foreach ($components as $component) {
$avail = $component->numRemaining(); $avail = $component->numRemaining();
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) { if ($avail < ($component->min_amt) + $alert_threshold) {
if ($component->qty > 0) { if ($component->qty > 0) {
$percent = number_format((($avail / $component->qty) * 100), 0); $percent = number_format((($avail / $component->qty) * 100), 0);
} else { } else {
@ -730,7 +792,7 @@ class Helper
$total_owned = $asset->where('model_id', '=', $asset_model->id)->count(); $total_owned = $asset->where('model_id', '=', $asset_model->id)->count();
$avail = $asset->where('model_id', '=', $asset_model->id)->whereNull('assigned_to')->count(); $avail = $asset->where('model_id', '=', $asset_model->id)->whereNull('assigned_to')->count();
if ($avail < ($asset_model->min_amt)+ \App\Models\Setting::getSettings()->alert_threshold) { if ($avail < ($asset_model->min_amt) + $alert_threshold) {
if ($avail > 0) { if ($avail > 0) {
$percent = number_format((($avail / $total_owned) * 100), 0); $percent = number_format((($avail / $total_owned) * 100), 0);
} else { } else {
@ -746,6 +808,26 @@ class Helper
} }
} }
foreach ($licenses as $license){
$avail = $license->remaincount();
if ($avail < ($license->min_amt) + $alert_threshold) {
if ($avail > 0) {
$percent = number_format((($avail / $license->min_amt) * 100), 0);
} else {
$percent = 100;
}
$items_array[$all_count]['id'] = $license->id;
$items_array[$all_count]['name'] = $license->name;
$items_array[$all_count]['type'] = 'licenses';
$items_array[$all_count]['percent'] = $percent;
$items_array[$all_count]['remaining'] = $avail;
$items_array[$all_count]['min_amt'] = $license->min_amt;
$all_count++;
}
}
return $items_array; return $items_array;
} }
@ -763,7 +845,7 @@ class Helper
$filetype = @finfo_file($finfo, $file); $filetype = @finfo_file($finfo, $file);
finfo_close($finfo); finfo_close($finfo);
if (($filetype == 'image/jpeg') || ($filetype == 'image/jpg') || ($filetype == 'image/png') || ($filetype == 'image/bmp') || ($filetype == 'image/gif')) { if (($filetype == 'image/jpeg') || ($filetype == 'image/jpg') || ($filetype == 'image/png') || ($filetype == 'image/bmp') || ($filetype == 'image/gif') || ($filetype == 'image/avif')) {
return $filetype; return $filetype;
} }
@ -796,12 +878,15 @@ class Helper
$permission_name = $permission[$x]['permission']; $permission_name = $permission[$x]['permission'];
if ($permission[$x]['display'] === true) { if ($permission[$x]['display'] === true) {
if ($selected_arr) {
if (is_array($selected_arr)) {
if (array_key_exists($permission_name, $selected_arr)) { if (array_key_exists($permission_name, $selected_arr)) {
$permissions_arr[$permission_name] = $selected_arr[$permission_name]; $permissions_arr[$permission_name] = $selected_arr[$permission_name];
} else { } else {
$permissions_arr[$permission_name] = '0'; $permissions_arr[$permission_name] = '0';
} }
} else { } else {
$permissions_arr[$permission_name] = '0'; $permissions_arr[$permission_name] = '0';
} }
@ -829,6 +914,13 @@ class Helper
$rules = $class::rules(); $rules = $class::rules();
foreach ($rules as $rule_name => $rule) { foreach ($rules as $rule_name => $rule) {
if ($rule_name == $field) { if ($rule_name == $field) {
if (is_array($rule)) {
if (in_array('required', $rule)) {
return true;
} else {
return false;
}
} else {
if (strpos($rule, 'required') === false) { if (strpos($rule, 'required') === false) {
return false; return false;
} else { } else {
@ -837,6 +929,8 @@ class Helper
} }
} }
} }
return false;
}
/** /**
* Check to see if the given key exists in the array, and trim excess white space before returning it * Check to see if the given key exists in the array, and trim excess white space before returning it
@ -933,7 +1027,7 @@ class Helper
try { try {
$tmp_date = new \Carbon($date); $tmp_date = new Carbon($date);
if ($type == 'datetime') { if ($type == 'datetime') {
$dt['datetime'] = $tmp_date->format('Y-m-d H:i:s'); $dt['datetime'] = $tmp_date->format('Y-m-d H:i:s');
@ -950,7 +1044,7 @@ class Helper
return $dt['formatted']; return $dt['formatted'];
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::warning($e); Log::warning($e);
return $date.' (Invalid '.$type.' value.)'; return $date.' (Invalid '.$type.' value.)';
} }
@ -1027,6 +1121,8 @@ class Helper
'jpeg' => 'far fa-image', 'jpeg' => 'far fa-image',
'gif' => 'far fa-image', 'gif' => 'far fa-image',
'png' => 'far fa-image', 'png' => 'far fa-image',
'webp' => 'far fa-image',
'avif' => 'far fa-image',
// word // word
'doc' => 'far fa-file-word', 'doc' => 'far fa-file-word',
'docx' => 'far fa-file-word', 'docx' => 'far fa-file-word',
@ -1062,6 +1158,8 @@ class Helper
case 'jpeg': case 'jpeg':
case 'gif': case 'gif':
case 'png': case 'png':
case 'webp':
case 'avif':
return true; return true;
break; break;
default: default:
@ -1259,7 +1357,7 @@ class Helper
public static function isDemoMode() { public static function isDemoMode() {
if (config('app.lock_passwords') === true) { if (config('app.lock_passwords') === true) {
return true; return true;
\Log::debug('app locked!'); Log::debug('app locked!');
} }
return false; return false;
@ -1325,4 +1423,120 @@ class Helper
return "<p class=\"text-warning\"><i class=\"fas fa-lock\"></i>" . trans('general.feature_disabled') . "</p>"; return "<p class=\"text-warning\"><i class=\"fas fa-lock\"></i>" . trans('general.feature_disabled') . "</p>";
} }
} }
/**
* Ah, legacy code.
*
* This corrects the original mistakes from 2013 where we used the wrong locale codes. Hopefully we
* can get rid of this in a future version, but this should at least give us the belt and suspenders we need
* to be sure this change is not too disruptive.
*
* In this array, we ONLY include the older languages where we weren't using the correct locale codes.
*
* @see public static $language_map in this file
* @author A. Gianotto <snipe@snipe.net>
* @since 6.3.0
*
* @param $language_code
* @return string []
*/
public static function mapLegacyLocale($language_code = null)
{
if (strlen($language_code) > 4) {
return $language_code;
}
foreach (self::$language_map as $legacy => $new) {
if ($language_code == $legacy) {
return $new;
}
}
// Return US english if we don't have a match
return 'en-US';
}
public static function mapBackToLegacyLocale($new_locale = null)
{
if (strlen($new_locale) <= 4) {
return $new_locale; //"new locale" apparently wasn't quite so new
}
// This does a *reverse* search against our new language map array - given the value, find the *key* for it
$legacy_locale = array_search($new_locale, self::$language_map);
if ($legacy_locale !== false) {
return $legacy_locale;
}
return $new_locale; // better that you have some weird locale that doesn't fit into our mappings anywhere than 'void'
}
public static function determineLanguageDirection() {
return in_array(app()->getLocale(),
[
'ar-SA',
'fa-IR',
'he-IL'
]) ? 'rtl' : 'ltr';
}
static public function getRedirectOption($request, $id, $table, $item_id = null)
{
$redirect_option = Session::get('redirect_option');
$checkout_to_type = Session::get('checkout_to_type');
// return to index
if ($redirect_option == 'index') {
switch ($table) {
case "Assets":
return route('hardware.index');
case "Users":
return route('users.index');
case "Licenses":
return route('licenses.index');
case "Accessories":
return route('accessories.index');
case "Components":
return route('components.index');
case "Consumables":
return route('consumables.index');
}
}
// return to thing being assigned
if ($redirect_option == 'item') {
switch ($table) {
case "Assets":
return route('hardware.show', $id ?? $item_id);
case "Users":
return route('users.show', $id ?? $item_id);
case "Licenses":
return route('licenses.show', $id ?? $item_id);
case "Accessories":
return route('accessories.show', $id ?? $item_id);
case "Components":
return route('components.show', $id ?? $item_id);
case "Consumables":
return route('consumables.show', $id ?? $item_id);
}
}
// return to assignment target
if ($redirect_option == 'target') {
switch ($checkout_to_type) {
case 'user':
return route('users.show', ['user' => $request->assigned_user]);
case 'location':
return route('locations.show', ['location' => $request->assigned_location]);
case 'asset':
return route('hardware.show', ['hardware' => $request->assigned_asset]);
}
}
return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error'));
}
} }

View file

@ -3,10 +3,13 @@
namespace App\Helpers; namespace App\Helpers;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Response;
use Illuminate\Http\RedirectResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
class StorageHelper class StorageHelper
{ {
public static function downloader($filename, $disk = 'default') public static function downloader($filename, $disk = 'default') : BinaryFileResponse | RedirectResponse | StreamedResponse
{ {
if ($disk == 'default') { if ($disk == 'default') {
$disk = config('filesystems.default'); $disk = config('filesystems.default');

View file

@ -7,10 +7,11 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Company; use App\Models\Company;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Redirect; use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Log;
/** This controller handles all actions related to Accessories for /** This controller handles all actions related to Accessories for
* the Snipe-IT Asset Management application. * the Snipe-IT Asset Management application.
@ -26,13 +27,10 @@ class AccessoriesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @see AccessoriesController::getDatatable() method that generates the JSON response * @see AccessoriesController::getDatatable() method that generates the JSON response
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function index() public function index() : View
{ {
$this->authorize('index', Accessory::class); $this->authorize('index', Accessory::class);
return view('accessories/index'); return view('accessories/index');
} }
@ -40,10 +38,8 @@ class AccessoriesController extends Controller
* Returns a view with a form to create a new Accessory. * Returns a view with a form to create a new Accessory.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', Accessory::class); $this->authorize('create', Accessory::class);
$category_type = 'accessory'; $category_type = 'accessory';
@ -57,10 +53,8 @@ class AccessoriesController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param ImageUploadRequest $request * @param ImageUploadRequest $request
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : RedirectResponse
{ {
$this->authorize(Accessory::class); $this->authorize(Accessory::class);
@ -79,16 +73,17 @@ class AccessoriesController extends Controller
$accessory->purchase_date = request('purchase_date'); $accessory->purchase_date = request('purchase_date');
$accessory->purchase_cost = request('purchase_cost'); $accessory->purchase_cost = request('purchase_cost');
$accessory->qty = request('qty'); $accessory->qty = request('qty');
$accessory->user_id = Auth::user()->id; $accessory->user_id = auth()->id();
$accessory->supplier_id = request('supplier_id'); $accessory->supplier_id = request('supplier_id');
$accessory->notes = request('notes'); $accessory->notes = request('notes');
$accessory = $request->handleImages($accessory); $accessory = $request->handleImages($accessory);
session()->put(['redirect_option' => $request->get('redirect_option')]);
// Was the accessory created? // Was the accessory created?
if ($accessory->save()) { if ($accessory->save()) {
// Redirect to the new accessory page // Redirect to the new accessory page
return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.create.success')); return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))->with('success', trans('admin/accessories/message.create.success'));
} }
return redirect()->back()->withInput()->withErrors($accessory->getErrors()); return redirect()->back()->withInput()->withErrors($accessory->getErrors());
@ -99,15 +94,12 @@ class AccessoriesController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $accessoryId * @param int $accessoryId
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($accessoryId = null) public function edit($accessoryId = null) : View | RedirectResponse
{ {
if ($item = Accessory::find($accessoryId)) { if ($item = Accessory::find($accessoryId)) {
$this->authorize($item); $this->authorize($item);
return view('accessories/edit', compact('item'))->with('category_type', 'accessory'); return view('accessories/edit', compact('item'))->with('category_type', 'accessory');
} }
@ -121,9 +113,8 @@ class AccessoriesController extends Controller
* @author [J. Vinsmoke] * @author [J. Vinsmoke]
* @param int $accessoryId * @param int $accessoryId
* @since [v6.0] * @since [v6.0]
* @return View
*/ */
public function getClone($accessoryId = null) public function getClone($accessoryId = null) : View | RedirectResponse
{ {
$this->authorize('create', Accessory::class); $this->authorize('create', Accessory::class);
@ -150,17 +141,15 @@ class AccessoriesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param ImageUploadRequest $request * @param ImageUploadRequest $request
* @param int $accessoryId * @param int $accessoryId
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(ImageUploadRequest $request, $accessoryId = null) public function update(ImageUploadRequest $request, $accessoryId = null) : RedirectResponse
{ {
if ($accessory = Accessory::withCount('users as users_count')->find($accessoryId)) { if ($accessory = Accessory::withCount('checkouts as checkouts_count')->find($accessoryId)) {
$this->authorize($accessory); $this->authorize($accessory);
$validator = Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
"qty" => "required|numeric|min:$accessory->users_count" "qty" => "required|numeric|min:$accessory->checkouts_count"
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
@ -188,9 +177,10 @@ class AccessoriesController extends Controller
$accessory = $request->handleImages($accessory); $accessory = $request->handleImages($accessory);
// Was the accessory updated? session()->put(['redirect_option' => $request->get('redirect_option')]);
if ($accessory->save()) { if ($accessory->save()) {
return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.update.success')); return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))->with('success', trans('admin/accessories/message.update.success'));
} }
} else { } else {
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
@ -204,10 +194,8 @@ class AccessoriesController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $accessoryId * @param int $accessoryId
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($accessoryId) public function destroy($accessoryId) : RedirectResponse
{ {
if (is_null($accessory = Accessory::find($accessoryId))) { if (is_null($accessory = Accessory::find($accessoryId))) {
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found')); return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
@ -224,7 +212,7 @@ class AccessoriesController extends Controller
try { try {
Storage::disk('public')->delete('accessories'.'/'.$accessory->image); Storage::disk('public')->delete('accessories'.'/'.$accessory->image);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
} }
} }
@ -242,12 +230,10 @@ class AccessoriesController extends Controller
* @param int $accessoryID * @param int $accessoryID
* @see AccessoriesController::getDataView() method that generates the JSON response * @see AccessoriesController::getDataView() method that generates the JSON response
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($accessoryID = null) public function show($accessoryID = null) : View | RedirectResponse
{ {
$accessory = Accessory::withCount('users as users_count')->find($accessoryID); $accessory = Accessory::withCount('checkouts as checkouts_count')->find($accessoryID);
$this->authorize('view', $accessory); $this->authorize('view', $accessory);
if (isset($accessory->id)) { if (isset($accessory->id)) {
return view('accessories/view', compact('accessory')); return view('accessories/view', compact('accessory'));

View file

@ -4,35 +4,35 @@ namespace App\Http\Controllers\Accessories;
use App\Helpers\StorageHelper; use App\Helpers\StorageHelper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\AssetFileRequest; use App\Http\Requests\UploadFileRequest;
use App\Models\Actionlog; use App\Models\Actionlog;
use App\Models\Accessory; use App\Models\Accessory;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Symfony\Accessory\HttpFoundation\JsonResponse; use Illuminate\Support\Facades\Log;
use enshrined\svgSanitize\Sanitizer; use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Response;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
class AccessoriesFilesController extends Controller class AccessoriesFilesController extends Controller
{ {
/** /**
* Validates and stores files associated with a accessory. * Validates and stores files associated with a accessory.
* *
* @todo Switch to using the AssetFileRequest form request validator. * @param UploadFileRequest $request
* @param int $accessoryId
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param AssetFileRequest $request * @todo Switch to using the AssetFileRequest form request validator.
* @param int $accessoryId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(AssetFileRequest $request, $accessoryId = null) public function store(UploadFileRequest $request, $accessoryId = null) : RedirectResponse
{ {
if (config('app.lock_passwords')) { if (config('app.lock_passwords')) {
return redirect()->route('accessories.show', ['accessory'=>$accessoryId])->with('error', trans('general.feature_disabled')); return redirect()->route('accessories.show', ['accessory'=>$accessoryId])->with('error', trans('general.feature_disabled'));
} }
$accessory = Accessory::find($accessoryId); $accessory = Accessory::find($accessoryId);
if (isset($accessory->id)) { if (isset($accessory->id)) {
@ -45,30 +45,7 @@ class AccessoriesFilesController extends Controller
foreach ($request->file('file') as $file) { foreach ($request->file('file') as $file) {
$extension = $file->getClientOriginalExtension(); $file_name = $request->handleFile('private_uploads/accessories/', 'accessory-'.$accessory->id, $file);
$file_name = 'accessory-'.$accessory->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension;
// Check for SVG and sanitize it
if ($extension == 'svg') {
\Log::debug('This is an SVG');
\Log::debug($file_name);
$sanitizer = new Sanitizer();
$dirtySVG = file_get_contents($file->getRealPath());
$cleanSVG = $sanitizer->sanitize($dirtySVG);
try {
Storage::put('private_uploads/accessories/'.$file_name, $cleanSVG);
} catch (\Exception $e) {
\Log::debug('Upload no workie :( ');
\Log::debug($e);
}
} else {
Storage::put('private_uploads/accessories/'.$file_name, file_get_contents($file));
}
//Log the upload to the log //Log the upload to the log
$accessory->logUpload($file_name, e($request->input('notes'))); $accessory->logUpload($file_name, e($request->input('notes')));
} }
@ -92,10 +69,8 @@ class AccessoriesFilesController extends Controller
* @since [v1.0] * @since [v1.0]
* @param int $accessoryId * @param int $accessoryId
* @param int $fileId * @param int $fileId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($accessoryId = null, $fileId = null) public function destroy($accessoryId = null, $fileId = null) : RedirectResponse
{ {
$accessory = Accessory::find($accessoryId); $accessory = Accessory::find($accessoryId);
@ -109,7 +84,7 @@ class AccessoriesFilesController extends Controller
try { try {
Storage::delete('accessories/'.$log->filename); Storage::delete('accessories/'.$log->filename);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
} }
} }
@ -130,13 +105,11 @@ class AccessoriesFilesController extends Controller
* @since [v1.4] * @since [v1.4]
* @param int $accessoryId * @param int $accessoryId
* @param int $fileId * @param int $fileId
* @return \Symfony\Accessory\HttpFoundation\Response
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($accessoryId = null, $fileId = null, $download = true) public function show($accessoryId = null, $fileId = null, $download = true) : View | RedirectResponse | Response | BinaryFileResponse | StreamedResponse
{ {
\Log::debug('Private filesystem is: '.config('filesystems.default')); Log::debug('Private filesystem is: '.config('filesystems.default'));
$accessory = Accessory::find($accessoryId); $accessory = Accessory::find($accessoryId);
@ -153,8 +126,8 @@ class AccessoriesFilesController extends Controller
$file = 'private_uploads/accessories/'.$log->filename; $file = 'private_uploads/accessories/'.$log->filename;
if (Storage::missing($file)) { if (Storage::missing($file)) {
\Log::debug('FILE DOES NOT EXISTS for '.$file); Log::debug('FILE DOES NOT EXISTS for '.$file);
\Log::debug('URL should be '.Storage::url($file)); Log::debug('URL should be '.Storage::url($file));
return response('File '.$file.' ('.Storage::url($file).') not found on server', 404) return response('File '.$file.' ('.Storage::url($file).') not found on server', 404)
->header('Content-Type', 'text/plain'); ->header('Content-Type', 'text/plain');

View file

@ -3,12 +3,15 @@
namespace App\Http\Controllers\Accessories; namespace App\Http\Controllers\Accessories;
use App\Events\CheckoutableCheckedIn; use App\Events\CheckoutableCheckedIn;
use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\AccessoryCheckout;
use App\Models\User; use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
class AccessoryCheckinController extends Controller class AccessoryCheckinController extends Controller
{ {
@ -19,15 +22,10 @@ class AccessoryCheckinController extends Controller
* @param Request $request * @param Request $request
* @param int $accessoryUserId * @param int $accessoryUserId
* @param string $backto * @param string $backto
* @return View
* @internal param int $accessoryId
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create($accessoryUserId = null, $backto = null) public function create($accessoryUserId = null, $backto = null) : View | RedirectResponse
{ {
// Check if the accessory exists if (is_null($accessory_user = DB::table('accessories_checkout')->find($accessoryUserId))) {
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
// Redirect to the accessory management page with error
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found')); return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
} }
@ -42,36 +40,32 @@ class AccessoryCheckinController extends Controller
* *
* @uses Accessory::checkin_email() to determine if an email can and should be sent * @uses Accessory::checkin_email() to determine if an email can and should be sent
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param null $accessoryUserId * @param null $accessoryCheckoutId
* @param string $backto * @param string $backto
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
* @internal param int $accessoryId
*/ */
public function store(Request $request, $accessoryUserId = null, $backto = null) public function store(Request $request, $accessoryCheckoutId = null, $backto = null) : RedirectResponse
{ {
// Check if the accessory exists if (is_null($accessory_checkout = AccessoryCheckout::find($accessoryCheckoutId))) {
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) {
// Redirect to the accessory management page with error
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
} }
$accessory = Accessory::find($accessory_user->accessory_id); $accessory = Accessory::find($accessory_checkout->accessory_id);
$this->authorize('checkin', $accessory); $this->authorize('checkin', $accessory);
$checkin_at = date('Y-m-d'); $checkin_hours = date('H:i:s');
$checkin_at = date('Y-m-d H:i:s');
if ($request->filled('checkin_at')) { if ($request->filled('checkin_at')) {
$checkin_at = $request->input('checkin_at'); $checkin_at = $request->input('checkin_at').' '.$checkin_hours;
} }
// Was the accessory updated? // Was the accessory updated?
if (DB::table('accessories_users')->where('id', '=', $accessory_user->id)->delete()) { if ($accessory_checkout->delete()) {
$return_to = e($accessory_user->assigned_to); event(new CheckoutableCheckedIn($accessory, $accessory_checkout->assignedTo, auth()->user(), $request->input('note'), $checkin_at));
event(new CheckoutableCheckedIn($accessory, User::find($return_to), Auth::user(), $request->input('note'), $checkin_at)); session()->put(['redirect_option' => $request->get('redirect_option')]);
return redirect()->route('accessories.show', $accessory->id)->with('success', trans('admin/accessories/message.checkin.success')); return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))->with('success', trans('admin/accessories/message.checkin.success'));
} }
// Redirect to the accessory management page with error // Redirect to the accessory management page with error
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkin.error')); return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkin.error'));

View file

@ -3,46 +3,56 @@
namespace App\Http\Controllers\Accessories; namespace App\Http\Controllers\Accessories;
use App\Events\CheckoutableCheckedOut; use App\Events\CheckoutableCheckedOut;
use App\Helpers\Helper;
use App\Http\Controllers\CheckInOutRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\AccessoryCheckoutRequest;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\AccessoryCheckout;
use App\Models\User; use App\Models\User;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use \Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Input; use \Illuminate\Http\RedirectResponse;
class AccessoryCheckoutController extends Controller class AccessoryCheckoutController extends Controller
{ {
use CheckInOutRequest;
/** /**
* Return the form to checkout an Accessory to a user. * Return the form to checkout an Accessory to a user.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $accessoryId * @param int $id
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create($accessoryId) public function create($id) : View | RedirectResponse
{ {
// Check if the accessory exists
if (is_null($accessory = Accessory::withCount('users as users_count')->find($accessoryId))) {
// Redirect to the accessory management page with error
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
}
if ($accessory = Accessory::withCount('checkouts as checkouts_count')->find($id)) {
$this->authorize('checkout', $accessory);
if ($accessory->category) {
// Make sure there is at least one available to checkout // Make sure there is at least one available to checkout
if ($accessory->numRemaining() <= 0){ if ($accessory->numRemaining() <= 0){
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkout.unavailable')); return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkout.unavailable'));
} }
if ($accessory->category) { // Return the checkout view
$this->authorize('checkout', $accessory);
// Get the dropdown of users and then pass it to the checkout view
return view('accessories/checkout', compact('accessory')); return view('accessories/checkout', compact('accessory'));
} }
return redirect()->back()->with('error', 'The category type for this accessory is not valid. Edit the accessory and select a valid accessory category.'); // Invalid category
return redirect()->route('accessories.edit', ['accessory' => $accessory->id])
->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.accessory')]));
}
// Not found
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.not_found'));
} }
/** /**
@ -53,46 +63,38 @@ class AccessoryCheckoutController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param Request $request * @param Request $request
* @param int $accessoryId * @param Accessory $accessory
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(Request $request, $accessoryId) public function store(AccessoryCheckoutRequest $request, Accessory $accessory) : RedirectResponse
{ {
// Check if the accessory exists
if (is_null($accessory = Accessory::withCount('users as users_count')->find($accessoryId))) {
// Redirect to the accessory management page with error
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.user_not_found'));
}
$this->authorize('checkout', $accessory); $this->authorize('checkout', $accessory);
if (!$user = User::find($request->input('assigned_to'))) { $target = $this->determineCheckoutTarget();
return redirect()->route('accessories.checkout.show', $accessory->id)->with('error', trans('admin/accessories/message.checkout.user_does_not_exist'));
}
// Make sure there is at least one available to checkout $accessory->checkout_qty = $request->input('checkout_qty', 1);
if ($accessory->numRemaining() <= 0){
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkout.unavailable'));
}
for ($i = 0; $i < $accessory->checkout_qty; $i++) {
// Update the accessory data AccessoryCheckout::create([
$accessory->assigned_to = e($request->input('assigned_to'));
$accessory->users()->attach($accessory->id, [
'accessory_id' => $accessory->id, 'accessory_id' => $accessory->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => Auth::id(), 'user_id' => Auth::id(),
'assigned_to' => $request->get('assigned_to'), 'assigned_to' => $target->id,
'assigned_type' => $target::class,
'note' => $request->input('note'), 'note' => $request->input('note'),
]); ]);
}
event(new CheckoutableCheckedOut($accessory, $target, auth()->user(), $request->input('note')));
DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first(); // Set this as user since we only allow checkout to user for this item type
$request->request->add(['checkout_to_type' => request('checkout_to_type')]);
$request->request->add(['assigned_user' => $target->id]);
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
event(new CheckoutableCheckedOut($accessory, $user, Auth::user(), $request->input('note')));
// Redirect to the new accessory page // Redirect to the new accessory page
return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.checkout.success')); return redirect()->to(Helper::getRedirectOption($request, $accessory->id, 'Accessories'))
->with('success', trans('admin/accessories/message.checkout.success'));
} }
} }

View file

@ -23,25 +23,23 @@ use App\Notifications\AcceptanceAssetAcceptedNotification;
use App\Notifications\AcceptanceAssetDeclinedNotification; use App\Notifications\AcceptanceAssetDeclinedNotification;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Http\Controllers\SettingsController; use App\Http\Controllers\SettingsController;
use Barryvdh\DomPDF\Facade\Pdf; use Barryvdh\DomPDF\Facade\Pdf;
use Carbon\Carbon; use Carbon\Carbon;
use phpDocumentor\Reflection\Types\Compound; use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Log;
class AcceptanceController extends Controller class AcceptanceController extends Controller
{ {
/** /**
* Show a listing of pending checkout acceptances for the current user * Show a listing of pending checkout acceptances for the current user
*
* @return View
*/ */
public function index() public function index() : View
{ {
$acceptances = CheckoutAcceptance::forUser(Auth::user())->pending()->get(); $acceptances = CheckoutAcceptance::forUser(auth()->user())->pending()->get();
return view('account/accept.index', compact('acceptances')); return view('account/accept.index', compact('acceptances'));
} }
@ -49,9 +47,8 @@ class AcceptanceController extends Controller
* Shows a form to either accept or decline the checkout acceptance * Shows a form to either accept or decline the checkout acceptance
* *
* @param int $id * @param int $id
* @return mixed
*/ */
public function create($id) public function create($id) : View | RedirectResponse
{ {
$acceptance = CheckoutAcceptance::find($id); $acceptance = CheckoutAcceptance::find($id);
@ -64,7 +61,7 @@ class AcceptanceController extends Controller
return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.asset_already_accepted')); return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.asset_already_accepted'));
} }
if (! $acceptance->isCheckedOutTo(Auth::user())) { if (! $acceptance->isCheckedOutTo(auth()->user())) {
return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.incorrect_user_accepted')); return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.incorrect_user_accepted'));
} }
@ -80,9 +77,8 @@ class AcceptanceController extends Controller
* *
* @param Request $request * @param Request $request
* @param int $id * @param int $id
* @return Redirect
*/ */
public function store(Request $request, $id) public function store(Request $request, $id) : RedirectResponse
{ {
$acceptance = CheckoutAcceptance::find($id); $acceptance = CheckoutAcceptance::find($id);
@ -94,7 +90,7 @@ class AcceptanceController extends Controller
return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.asset_already_accepted')); return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.asset_already_accepted'));
} }
if (! $acceptance->isCheckedOutTo(Auth::user())) { if (! $acceptance->isCheckedOutTo(auth()->user())) {
return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.incorrect_user_accepted')); return redirect()->route('account.accept')->with('error', trans('admin/users/message.error.incorrect_user_accepted'));
} }
@ -222,7 +218,9 @@ class AcceptanceController extends Controller
'item_tag' => $item->asset_tag, 'item_tag' => $item->asset_tag,
'item_model' => $display_model, 'item_model' => $display_model,
'item_serial' => $item->serial, 'item_serial' => $item->serial,
'item_status' => $item->assetstatus?->name,
'eula' => $item->getEula(), 'eula' => $item->getEula(),
'note' => $request->input('note'),
'check_out_date' => Carbon::parse($acceptance->created_at)->format('Y-m-d'), 'check_out_date' => Carbon::parse($acceptance->created_at)->format('Y-m-d'),
'accepted_date' => Carbon::parse($acceptance->accepted_at)->format('Y-m-d'), 'accepted_date' => Carbon::parse($acceptance->accepted_at)->format('Y-m-d'),
'assigned_to' => $assigned_to, 'assigned_to' => $assigned_to,
@ -233,12 +231,12 @@ class AcceptanceController extends Controller
]; ];
if ($pdf_view_route!='') { if ($pdf_view_route!='') {
\Log::debug($pdf_filename.' is the filename, and the route was specified.'); Log::debug($pdf_filename.' is the filename, and the route was specified.');
$pdf = Pdf::loadView($pdf_view_route, $data); $pdf = Pdf::loadView($pdf_view_route, $data);
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output()); Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
} }
$acceptance->accept($sig_filename, $item->getEula(), $pdf_filename); $acceptance->accept($sig_filename, $item->getEula(), $pdf_filename, $request->input('note'));
$acceptance->notify(new AcceptanceAssetAcceptedNotification($data)); $acceptance->notify(new AcceptanceAssetAcceptedNotification($data));
event(new CheckoutAccepted($acceptance)); event(new CheckoutAccepted($acceptance));
@ -306,10 +304,13 @@ class AcceptanceController extends Controller
$assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName; $assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName;
break; break;
} }
$data = [ $data = [
'item_tag' => $item->asset_tag, 'item_tag' => $item->asset_tag,
'item_model' => $display_model, 'item_model' => $display_model,
'item_serial' => $item->serial, 'item_serial' => $item->serial,
'item_status' => $item->assetstatus?->name,
'note' => $request->input('note'),
'declined_date' => Carbon::parse($acceptance->declined_at)->format('Y-m-d'), 'declined_date' => Carbon::parse($acceptance->declined_at)->format('Y-m-d'),
'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null, 'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null,
'assigned_to' => $assigned_to, 'assigned_to' => $assigned_to,
@ -318,12 +319,12 @@ class AcceptanceController extends Controller
]; ];
if ($pdf_view_route!='') { if ($pdf_view_route!='') {
\Log::debug($pdf_filename.' is the filename, and the route was specified.'); Log::debug($pdf_filename.' is the filename, and the route was specified.');
$pdf = Pdf::loadView($pdf_view_route, $data); $pdf = Pdf::loadView($pdf_view_route, $data);
Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output()); Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output());
} }
$acceptance->decline($sig_filename); $acceptance->decline($sig_filename, $request->input('note'));
$acceptance->notify(new AcceptanceAssetDeclinedNotification($data)); $acceptance->notify(new AcceptanceAssetDeclinedNotification($data));
event(new CheckoutDeclined($acceptance)); event(new CheckoutDeclined($acceptance));
$return_msg = trans('admin/users/message.declined'); $return_msg = trans('admin/users/message.declined');

View file

@ -3,34 +3,44 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Models\Actionlog; use Illuminate\Http\RedirectResponse;
use Response; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use \Illuminate\Http\Response;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ActionlogController extends Controller class ActionlogController extends Controller
{ {
public function displaySig($filename) public function displaySig($filename) : RedirectResponse | Response | bool
{ {
// PHP doesn't let you handle file not found errors well with // PHP doesn't let you handle file not found errors well with
// file_get_contents, so we set the error reporting for just this class // file_get_contents, so we set the error reporting for just this class
error_reporting(0); error_reporting(0);
$disk = config('filesystems.default');
switch (config("filesystems.disks.$disk.driver")) {
case 's3':
$file = 'private_uploads/signatures/'.$filename;
return redirect()->away(Storage::disk($disk)->temporaryUrl($file, now()->addMinutes(5)));
default:
$this->authorize('view', \App\Models\Asset::class); $this->authorize('view', \App\Models\Asset::class);
$file = config('app.private_uploads').'/signatures/'.$filename; $file = config('app.private_uploads').'/signatures/'.$filename;
$filetype = Helper::checkUploadIsImage($file); $filetype = Helper::checkUploadIsImage($file);
$contents = file_get_contents($file, false, stream_context_create(['http' => ['ignore_errors' => true]])); $contents = file_get_contents($file, false, stream_context_create(['http' => ['ignore_errors' => true]]));
if ($contents === false) { if ($contents === false) {
\Log::warn('File '.$file.' not found'); Log::warning('File '.$file.' not found');
return false; return false;
} else { } else {
return Response::make($contents)->header('Content-Type', $filetype); return response()->make($contents)->header('Content-Type', $filetype);
}
}
} }
} public function getStoredEula($filename) : Response | BinaryFileResponse
public function getStoredEula($filename){ {
$this->authorize('view', \App\Models\Asset::class); $this->authorize('view', \App\Models\Asset::class);
$file = config('app.private_uploads').'/eula-pdfs/'.$filename; $file = config('app.private_uploads').'/eula-pdfs/'.$filename;
return response()->download($file);
return Response::download($file);
} }
} }

View file

@ -2,21 +2,28 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Events\CheckoutableCheckedOut;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\CheckInOutRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\AccessoryCheckoutRequest;
use App\Http\Requests\StoreAccessoryRequest;
use App\Http\Transformers\AccessoriesTransformer; use App\Http\Transformers\AccessoriesTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Company; use App\Models\Company;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Support\Facades\Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Models\AccessoryCheckout;
class AccessoriesController extends Controller class AccessoriesController extends Controller
{ {
use CheckInOutRequest;
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
@ -44,13 +51,13 @@ class AccessoriesController extends Controller
'min_amt', 'min_amt',
'company_id', 'company_id',
'notes', 'notes',
'users_count', 'checkouts_count',
'qty', 'qty',
]; ];
$accessories = Accessory::select('accessories.*')->with('category', 'company', 'manufacturer', 'users', 'location', 'supplier') $accessories = Accessory::select('accessories.*')->with('category', 'company', 'manufacturer', 'checkouts', 'location', 'supplier')
->withCount('users as users_count'); ->withCount('checkouts as checkouts_count');
if ($request->filled('search')) { if ($request->filled('search')) {
$accessories = $accessories->TextSearch($request->input('search')); $accessories = $accessories->TextSearch($request->input('search'));
@ -119,12 +126,12 @@ class AccessoriesController extends Controller
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\JsonResponse
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(StoreAccessoryRequest $request)
{ {
$this->authorize('create', Accessory::class); $this->authorize('create', Accessory::class);
$accessory = new Accessory; $accessory = new Accessory;
@ -142,15 +149,15 @@ class AccessoriesController extends Controller
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param int $id
* @return array
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id)
{ {
$this->authorize('view', Accessory::class); $this->authorize('view', Accessory::class);
$accessory = Accessory::withCount('users as users_count')->findOrFail($id); $accessory = Accessory::withCount('checkouts as checkouts_count')->findOrFail($id);
return (new AccessoriesTransformer)->transformAccessory($accessory); return (new AccessoriesTransformer)->transformAccessory($accessory);
} }
@ -159,10 +166,10 @@ class AccessoriesController extends Controller
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param int $id
* @return array
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id
* @return \Illuminate\Http\Response
*/ */
public function accessory_detail($id) public function accessory_detail($id)
{ {
@ -193,28 +200,23 @@ class AccessoriesController extends Controller
$offset = request('offset', 0); $offset = request('offset', 0);
$limit = request('limit', 50); $limit = request('limit', 50);
$accessory_users = $accessory->users; $accessory_checkouts = $accessory->checkouts;
$total = $accessory_users->count(); $total = $accessory_checkouts->count();
if ($total < $offset) { if ($total < $offset) {
$offset = 0; $offset = 0;
} }
$accessory_users = $accessory->users()->skip($offset)->take($limit)->get(); $accessory_checkouts = $accessory->checkouts()->skip($offset)->take($limit)->get();
if ($request->filled('search')) { if ($request->filled('search')) {
$accessory_users = $accessory->users()
->where(function ($query) use ($request) { $accessory_checkouts = $accessory->checkouts()->TextSearch($request->input('search'))
$search_str = '%' . $request->input('search') . '%';
$query->where('first_name', 'like', $search_str)
->orWhere('last_name', 'like', $search_str)
->orWhere('note', 'like', $search_str);
})
->get(); ->get();
$total = $accessory_users->count(); $total = $accessory_checkouts->count();
} }
return (new AccessoriesTransformer)->transformCheckedoutAccessory($accessory, $accessory_users, $total); return (new AccessoriesTransformer)->transformCheckedoutAccessory($accessory, $accessory_checkouts, $total);
} }
@ -271,43 +273,31 @@ class AccessoriesController extends Controller
* If Slack is enabled and/or asset acceptance is enabled, it will also * If Slack is enabled and/or asset acceptance is enabled, it will also
* trigger a Slack message and send an email. * trigger a Slack message and send an email.
* *
* @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $accessoryId * @param int $accessoryId
* @return Redirect * @return \Illuminate\Http\JsonResponse
* @author [A. Gianotto] [<snipe@snipe.net>]
*/ */
public function checkout(Request $request, $accessoryId) public function checkout(AccessoryCheckoutRequest $request, Accessory $accessory)
{ {
// Check if the accessory exists
if (is_null($accessory = Accessory::find($accessoryId))) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist')));
}
$this->authorize('checkout', $accessory); $this->authorize('checkout', $accessory);
$target = $this->determineCheckoutTarget();
$accessory->checkout_qty = $request->input('checkout_qty', 1);
for ($i = 0; $i < $accessory->checkout_qty; $i++) {
if ($accessory->numRemaining() > 0) { AccessoryCheckout::create([
if (! $user = User::find($request->input('assigned_to'))) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.checkout.user_does_not_exist')));
}
// Update the accessory data
$accessory->assigned_to = $request->input('assigned_to');
$accessory->users()->attach($accessory->id, [
'accessory_id' => $accessory->id, 'accessory_id' => $accessory->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => Auth::id(), 'user_id' => Auth::id(),
'assigned_to' => $request->get('assigned_to'), 'assigned_to' => $target->id,
'note' => $request->get('note'), 'assigned_type' => $target::class,
'note' => $request->input('note'),
]); ]);
$accessory->logCheckout($request->input('note'), $user);
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/accessories/message.checkout.success')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, 'No accessories remaining')); // Set this value to be able to pass the qty through to the event
event(new CheckoutableCheckedOut($accessory, $target, auth()->user(), $request->input('note')));
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/accessories/message.checkout.success')));
} }
@ -319,24 +309,24 @@ class AccessoriesController extends Controller
* @param Request $request * @param Request $request
* @param int $accessoryUserId * @param int $accessoryUserId
* @param string $backto * @param string $backto
* @return Redirect * @return \Illuminate\Http\RedirectResponse
* @internal param int $accessoryId * @internal param int $accessoryId
*/ */
public function checkin(Request $request, $accessoryUserId = null) public function checkin(Request $request, $accessoryUserId = null)
{ {
if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) { if (is_null($accessory_checkout = AccessoryCheckout::find($accessoryUserId))) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist'))); return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/accessories/message.does_not_exist')));
} }
$accessory = Accessory::find($accessory_user->accessory_id); $accessory = Accessory::find($accessory_checkout->accessory_id);
$this->authorize('checkin', $accessory); $this->authorize('checkin', $accessory);
$logaction = $accessory->logCheckin(User::find($accessory_user->assigned_to), $request->input('note')); $logaction = $accessory->logCheckin(User::find($accessory_checkout->assigned_to), $request->input('note'));
// Was the accessory updated? // Was the accessory updated?
if (DB::table('accessories_users')->where('id', '=', $accessory_user->id)->delete()) { if ($accessory_checkout->delete()) {
if (! is_null($accessory_user->assigned_to)) { if (! is_null($accessory_checkout->assigned_to)) {
$user = User::find($accessory_user->assigned_to); $user = User::find($accessory_checkout->assigned_to);
} }
$data['log_id'] = $logaction->id; $data['log_id'] = $logaction->id;

View file

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers\Api;
use App\Helpers\StorageHelper;
use Illuminate\Support\Facades\Storage;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Models\Asset;
use App\Models\Actionlog;
use App\Http\Requests\UploadFileRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
/**
* This class controls file related actions related
* to assets for the Snipe-IT Asset Management application.
*
* Based on the Assets/AssetFilesController by A. Gianotto <snipe@snipe.net>
*
* @version v1.0
* @author [T. Scarsbrook] [<snipe@scarzybrook.co.uk>]
*/
class AssetFilesController extends Controller
{
/**
* Accepts a POST to upload a file to the server.
*
* @param \App\Http\Requests\UploadFileRequest $request
* @param int $assetId
* @since [v6.0]
* @author [T. Scarsbrook] [<snipe@scarzybrook.co.uk>]
*/
public function store(UploadFileRequest $request, $assetId = null) : JsonResponse
{
// Start by checking if the asset being acted upon exists
if (! $asset = Asset::find($assetId)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 404);
}
// Make sure we are allowed to update this asset
$this->authorize('update', $asset);
if ($request->hasFile('file')) {
// If the file storage directory doesn't exist; create it
if (! Storage::exists('private_uploads/assets')) {
Storage::makeDirectory('private_uploads/assets', 775);
}
// Loop over the attached files and add them to the asset
foreach ($request->file('file') as $file) {
$file_name = $request->handleFile('private_uploads/assets/','hardware-'.$asset->id, $file);
$asset->logUpload($file_name, e($request->get('notes')));
}
// All done - report success
return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.upload.success')));
}
// We only reach here if no files were included in the POST, so tell the user this
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.upload.nofiles')), 500);
}
/**
* List the files for an asset.
*
* @param int $assetId
* @since [v6.0]
* @author [T. Scarsbrook] [<snipe@scarzybrook.co.uk>]
*/
public function list($assetId = null) : JsonResponse
{
// Start by checking if the asset being acted upon exists
if (! $asset = Asset::find($assetId)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 404);
}
// the asset is valid
if (isset($asset->id)) {
$this->authorize('view', $asset);
// Check that there are some uploads on this asset that can be listed
if ($asset->uploads->count() > 0) {
$files = array();
foreach ($asset->uploads as $upload) {
array_push($files, $upload);
}
// Give the list of files back to the user
return response()->json(Helper::formatStandardApiResponse('success', $files, trans('admin/hardware/message.upload.success')));
}
// There are no files.
return response()->json(Helper::formatStandardApiResponse('success', array(), trans('admin/hardware/message.upload.success')));
}
// Send back an error message
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.download.error')), 500);
}
/**
* Check for permissions and display the file.
*
* @param int $assetId
* @param int $fileId
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
* @since [v6.0]
* @author [T. Scarsbrook] [<snipe@scarzybrook.co.uk>]
*/
public function show($assetId = null, $fileId = null) : JsonResponse | StreamedResponse | Storage | StorageHelper | BinaryFileResponse
{
// Start by checking if the asset being acted upon exists
if (! $asset = Asset::find($assetId)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 404);
}
// the asset is valid
if (isset($asset->id)) {
$this->authorize('view', $asset);
// Check that the file being requested exists for the asset
if (! $log = Actionlog::whereNotNull('filename')->where('item_id', $asset->id)->find($fileId)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.download.no_match', ['id' => $fileId])), 404);
}
// Form the full filename with path
$file = 'private_uploads/assets/'.$log->filename;
Log::debug('Checking for '.$file);
if ($log->action_type == 'audit') {
$file = 'private_uploads/audits/'.$log->filename;
}
// Check the file actually exists on the filesystem
if (! Storage::exists($file)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.download.does_not_exist', ['id' => $fileId])), 404);
}
if (request('inline') == 'true') {
$headers = [
'Content-Disposition' => 'inline',
];
return Storage::download($file, $log->filename, $headers);
}
return StorageHelper::downloader($file);
}
// Send back an error message
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.download.error', ['id' => $fileId])), 500);
}
/**
* Delete the associated file
*
* @param int $assetId
* @param int $fileId
* @since [v6.0]
* @author [T. Scarsbrook] [<snipe@scarzybrook.co.uk>]
*/
public function destroy($assetId = null, $fileId = null) : JsonResponse
{
// Start by checking if the asset being acted upon exists
if (! $asset = Asset::find($assetId)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 404);
}
$rel_path = 'private_uploads/assets';
// the asset is valid
if (isset($asset->id)) {
$this->authorize('update', $asset);
// Check for the file
$log = Actionlog::find($fileId);
if ($log) {
// Check the file actually exists, and delete it
if (Storage::exists($rel_path.'/'.$log->filename)) {
Storage::delete($rel_path.'/'.$log->filename);
}
// Delete the record of the file
$log->delete();
// All deleting done - notify the user of success
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/hardware/message.deletefile.success')), 200);
}
// The file doesn't seem to really exist, so report an error
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.deletefile.error')), 500);
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.deletefile.error')), 500);
}
}

View file

@ -8,10 +8,9 @@ use App\Http\Transformers\AssetMaintenancesTransformer;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetMaintenance; use App\Models\AssetMaintenance;
use App\Models\Company; use App\Models\Company;
use Auth; use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input; use Illuminate\Http\JsonResponse;
/** /**
* This controller handles all actions related to Asset Maintenance for * This controller handles all actions related to Asset Maintenance for
@ -22,7 +21,6 @@ use Illuminate\Support\Facades\Input;
class AssetMaintenancesController extends Controller class AssetMaintenancesController extends Controller
{ {
/** /**
* Generates the JSON response for asset maintenances listing view. * Generates the JSON response for asset maintenances listing view.
* *
@ -30,13 +28,13 @@ class AssetMaintenancesController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return string JSON
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
$maintenances = AssetMaintenance::select('asset_maintenances.*')->with('asset', 'asset.model', 'asset.location', 'asset.defaultLoc', 'supplier', 'asset.company', 'admin'); $maintenances = AssetMaintenance::select('asset_maintenances.*')
->with('asset', 'asset.model', 'asset.location', 'asset.defaultLoc', 'supplier', 'asset.company', 'asset.assetstatus', 'admin');
if ($request->filled('search')) { if ($request->filled('search')) {
$maintenances = $maintenances->TextSearch($request->input('search')); $maintenances = $maintenances->TextSearch($request->input('search'));
@ -47,7 +45,7 @@ class AssetMaintenancesController extends Controller
} }
if ($request->filled('supplier_id')) { if ($request->filled('supplier_id')) {
$maintenances->where('supplier_id', '=', $request->input('supplier_id')); $maintenances->where('asset_maintenances.supplier_id', '=', $request->input('supplier_id'));
} }
if ($request->filled('asset_maintenance_type')) { if ($request->filled('asset_maintenance_type')) {
@ -70,10 +68,13 @@ class AssetMaintenancesController extends Controller
'notes', 'notes',
'asset_tag', 'asset_tag',
'asset_name', 'asset_name',
'serial',
'user_id', 'user_id',
'supplier', 'supplier',
'is_warranty', 'is_warranty',
'status_label',
]; ];
$order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at'; $sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
@ -90,6 +91,12 @@ class AssetMaintenancesController extends Controller
case 'asset_name': case 'asset_name':
$maintenances = $maintenances->OrderByAssetName($order); $maintenances = $maintenances->OrderByAssetName($order);
break; break;
case 'serial':
$maintenances = $maintenances->OrderByAssetSerial($order);
break;
case 'status_label':
$maintenances = $maintenances->OrderStatusName($order);
break;
default: default:
$maintenances = $maintenances->orderBy($sort, $order); $maintenances = $maintenances->orderBy($sort, $order);
break; break;
@ -110,47 +117,22 @@ class AssetMaintenancesController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return string JSON
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
// create a new model instance // create a new model instance
$assetMaintenance = new AssetMaintenance(); $maintenance = new AssetMaintenance();
$assetMaintenance->supplier_id = $request->input('supplier_id'); $maintenance->fill($request->all());
$assetMaintenance->is_warranty = $request->input('is_warranty'); $maintenance->user_id = Auth::id();
$assetMaintenance->cost = $request->input('cost');
$assetMaintenance->notes = e($request->input('notes'));
$asset = Asset::find(e($request->input('asset_id')));
if (! Company::isCurrentUserHasAccess($asset)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot add a maintenance for that asset'));
}
// Save the asset maintenance data
$assetMaintenance->asset_id = $request->input('asset_id');
$assetMaintenance->asset_maintenance_type = $request->input('asset_maintenance_type');
$assetMaintenance->title = $request->input('title');
$assetMaintenance->start_date = $request->input('start_date');
$assetMaintenance->completion_date = $request->input('completion_date');
$assetMaintenance->user_id = Auth::id();
if (($assetMaintenance->completion_date !== null)
&& ($assetMaintenance->start_date !== '')
&& ($assetMaintenance->start_date !== '0000-00-00')
) {
$startDate = Carbon::parse($assetMaintenance->start_date);
$completionDate = Carbon::parse($assetMaintenance->completion_date);
$assetMaintenance->asset_maintenance_time = $completionDate->diffInDays($startDate);
}
// Was the asset maintenance created? // Was the asset maintenance created?
if ($assetMaintenance->save()) { if ($maintenance->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $assetMaintenance, trans('admin/asset_maintenances/message.create.success'))); return response()->json(Helper::formatStandardApiResponse('success', $maintenance, trans('admin/asset_maintenances/message.create.success')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, $assetMaintenance->getErrors())); return response()->json(Helper::formatStandardApiResponse('error', null, $maintenance->getErrors()));
} }
@ -158,67 +140,40 @@ class AssetMaintenancesController extends Controller
* Validates and stores an update to an asset maintenance * Validates and stores an update to an asset maintenance
* *
* @author A. Gianotto <snipe@snipe.net> * @author A. Gianotto <snipe@snipe.net>
* @param int $assetMaintenanceId * @param int $id
* @param int $request * @param int $request
* @version v1.0 * @version v1.0
* @since [v4.0] * @since [v4.0]
* @return string JSON
*/ */
public function update(Request $request, $assetMaintenanceId = null) public function update(Request $request, $id) : JsonResponse
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
// Check if the asset maintenance exists
$assetMaintenance = AssetMaintenance::findOrFail($assetMaintenanceId);
if (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) { if ($maintenance = AssetMaintenance::with('asset')->find($id)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot edit a maintenance for that asset'));
// Can this user manage this asset?
if (! Company::isCurrentUserHasAccess($maintenance->asset)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.action_permission_denied', ['item_type' => trans('admin/asset_maintenances/general.maintenance'), 'id' => $id, 'action' => trans('general.edit')])));
} }
$assetMaintenance->supplier_id = e($request->input('supplier_id')); // The asset this miantenance is attached to is not valid or has been deleted
$assetMaintenance->is_warranty = e($request->input('is_warranty')); if (!$maintenance->asset) {
$assetMaintenance->cost = $request->input('cost'); return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.item_not_found', ['item_type' => trans('general.asset'), 'id' => $id])));
$assetMaintenance->notes = e($request->input('notes'));
$asset = Asset::find(request('asset_id'));
if (! Company::isCurrentUserHasAccess($asset)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'You cannot edit a maintenance for that asset'));
} }
// Save the asset maintenance data $maintenance->fill($request->all());
$assetMaintenance->asset_id = $request->input('asset_id');
$assetMaintenance->asset_maintenance_type = $request->input('asset_maintenance_type');
$assetMaintenance->title = $request->input('title');
$assetMaintenance->start_date = $request->input('start_date');
$assetMaintenance->completion_date = $request->input('completion_date');
if (($assetMaintenance->completion_date == null) if ($maintenance->save()) {
) { return response()->json(Helper::formatStandardApiResponse('success', $maintenance, trans('admin/asset_maintenances/message.edit.success')));
if (($assetMaintenance->asset_maintenance_time !== 0)
|| (! is_null($assetMaintenance->asset_maintenance_time))
) {
$assetMaintenance->asset_maintenance_time = null;
}
} }
if (($assetMaintenance->completion_date !== null) return response()->json(Helper::formatStandardApiResponse('error', null, $maintenance->getErrors()));
&& ($assetMaintenance->start_date !== '')
&& ($assetMaintenance->start_date !== '0000-00-00')
) {
$startDate = Carbon::parse($assetMaintenance->start_date);
$completionDate = Carbon::parse($assetMaintenance->completion_date);
$assetMaintenance->asset_maintenance_time = $completionDate->diffInDays($startDate);
} }
// Was the asset maintenance created? return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.item_not_found', ['item_type' => trans('admin/asset_maintenances/general.maintenance'), 'id' => $id])));
if ($assetMaintenance->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $assetMaintenance, trans('admin/asset_maintenances/message.edit.success')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, $assetMaintenance->getErrors()));
}
/** /**
* Delete an asset maintenance * Delete an asset maintenance
* *
@ -226,9 +181,8 @@ class AssetMaintenancesController extends Controller
* @param int $assetMaintenanceId * @param int $assetMaintenanceId
* @version v1.0 * @version v1.0
* @since [v4.0] * @since [v4.0]
* @return string JSON
*/ */
public function destroy($assetMaintenanceId) public function destroy($assetMaintenanceId) : JsonResponse
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
// Check if the asset maintenance exists // Check if the asset maintenance exists
@ -252,9 +206,8 @@ class AssetMaintenancesController extends Controller
* @param int $assetMaintenanceId * @param int $assetMaintenanceId
* @version v1.0 * @version v1.0
* @since [v4.0] * @since [v4.0]
* @return string JSON
*/ */
public function show($assetMaintenanceId) public function show($assetMaintenanceId) : JsonResponse
{ {
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
$assetMaintenance = AssetMaintenance::findOrFail($assetMaintenanceId); $assetMaintenance = AssetMaintenance::findOrFail($assetMaintenanceId);

View file

@ -4,14 +4,16 @@ namespace App\Http\Controllers\Api;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\StoreAssetModelRequest;
use App\Http\Transformers\AssetModelsTransformer; use App\Http\Transformers\AssetModelsTransformer;
use App\Http\Transformers\AssetsTransformer; use App\Http\Transformers\AssetsTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetModel; use App\Models\AssetModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\JsonResponse;
/** /**
* This class controls all actions related to asset models for * This class controls all actions related to asset models for
@ -27,9 +29,8 @@ class AssetModelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', AssetModel::class); $this->authorize('view', AssetModel::class);
$allowed_columns = $allowed_columns =
@ -115,10 +116,9 @@ class AssetModelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\StoreAssetModelRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(StoreAssetModelRequest $request) : JsonResponse
{ {
$this->authorize('create', AssetModel::class); $this->authorize('create', AssetModel::class);
$assetmodel = new AssetModel; $assetmodel = new AssetModel;
@ -139,9 +139,8 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', AssetModel::class); $this->authorize('view', AssetModel::class);
$assetmodel = AssetModel::withCount('assets as assets_count')->findOrFail($id); $assetmodel = AssetModel::withCount('assets as assets_count')->findOrFail($id);
@ -155,9 +154,8 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function assets($id) public function assets($id) : array
{ {
$this->authorize('view', AssetModel::class); $this->authorize('view', AssetModel::class);
$assets = Asset::where('model_id', '=', $id)->get(); $assets = Asset::where('model_id', '=', $id)->get();
@ -175,7 +173,7 @@ class AssetModelsController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(StoreAssetModelRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', AssetModel::class); $this->authorize('update', AssetModel::class);
$assetmodel = AssetModel::findOrFail($id); $assetmodel = AssetModel::findOrFail($id);
@ -208,9 +206,8 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', AssetModel::class); $this->authorize('delete', AssetModel::class);
$assetmodel = AssetModel::findOrFail($id); $assetmodel = AssetModel::findOrFail($id);
@ -224,7 +221,7 @@ class AssetModelsController extends Controller
try { try {
Storage::disk('public')->delete('assetmodels/'.$assetmodel->image); Storage::disk('public')->delete('assetmodels/'.$assetmodel->image);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::info($e); Log::info($e);
} }
} }
@ -240,7 +237,7 @@ class AssetModelsController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$this->authorize('view.selectlists'); $this->authorize('view.selectlists');

View file

@ -4,15 +4,20 @@ namespace App\Http\Controllers\Api;
use App\Events\CheckoutableCheckedIn; use App\Events\CheckoutableCheckedIn;
use App\Http\Requests\StoreAssetRequest; use App\Http\Requests\StoreAssetRequest;
use App\Http\Requests\UpdateAssetRequest;
use App\Http\Traits\MigratesLegacyAssetLocations;
use App\Models\CheckoutAcceptance;
use App\Models\LicenseSeat;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\AssetCheckoutRequest; use App\Http\Requests\AssetCheckoutRequest;
use App\Http\Transformers\AssetsTransformer; use App\Http\Transformers\AssetsTransformer;
use App\Http\Transformers\DepreciationReportTransformer;
use App\Http\Transformers\LicensesTransformer; use App\Http\Transformers\LicensesTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Actionlog;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetModel; use App\Models\AssetModel;
use App\Models\Company; use App\Models\Company;
@ -21,18 +26,13 @@ use App\Models\License;
use App\Models\Location; use App\Models\Location;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Support\Facades\Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use Input; use Illuminate\Support\Facades\Log;
use Paginator; use Illuminate\Support\Facades\Route;
use Slack;
use Str;
use TCPDF;
use Validator;
use Route;
/** /**
@ -44,15 +44,16 @@ use Route;
*/ */
class AssetsController extends Controller class AssetsController extends Controller
{ {
use MigratesLegacyAssetLocations;
/** /**
* Returns JSON listing of all assets * Returns JSON listing of all assets
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request, $audit = null) public function index(Request $request, $action = null, $upcoming_status = null) : JsonResponse | array
{ {
$filter_non_deprecable_assets = false; $filter_non_deprecable_assets = false;
@ -87,6 +88,7 @@ class AssetsController extends Controller
'serial', 'serial',
'model_number', 'model_number',
'last_checkout', 'last_checkout',
'last_checkin',
'notes', 'notes',
'expected_checkin', 'expected_checkin',
'order_number', 'order_number',
@ -104,6 +106,7 @@ class AssetsController extends Controller
'requests_counter', 'requests_counter',
'byod', 'byod',
'asset_eol_date', 'asset_eol_date',
'requestable',
]; ];
$filter = []; $filter = [];
@ -135,7 +138,7 @@ class AssetsController extends Controller
// Search custom fields by column name // Search custom fields by column name
foreach ($all_custom_fields as $field) { foreach ($all_custom_fields as $field) {
if ($request->filled($field->db_column_name())) { if ($request->filled($field->db_column_name()) && $field->db_column_name()) {
$assets->where($field->db_column_name(), '=', $request->input($field->db_column_name())); $assets->where($field->db_column_name(), '=', $request->input($field->db_column_name()));
} }
} }
@ -146,17 +149,44 @@ class AssetsController extends Controller
$assets->TextSearch($request->input('search')); $assets->TextSearch($request->input('search'));
} }
// This is used by the audit reporting routes
if (Gate::allows('audit', Asset::class)) { /**
switch ($audit) { * Handle due and overdue audits and checkin dates
*/
switch ($action) {
case 'audits':
switch ($upcoming_status) {
case 'due': case 'due':
$assets->DueOrOverdueForAudit($settings); $assets->DueForAudit($settings);
break; break;
case 'overdue': case 'overdue':
$assets->overdueForAudit($settings); $assets->OverdueForAudit();
break;
case 'due-or-overdue':
$assets->DueOrOverdueForAudit($settings);
break; break;
} }
break;
case 'checkins':
switch ($upcoming_status) {
case 'due':
$assets->DueForCheckin($settings);
break;
case 'overdue':
$assets->OverdueForCheckin();
break;
case 'due-or-overdue':
$assets->DueOrOverdueForCheckin($settings);
break;
} }
break;
}
/**
* End handling due and overdue audits and checkin dates
*/
// This is used by the sidenav, mostly // This is used by the sidenav, mostly
@ -380,9 +410,8 @@ class AssetsController extends Controller
* @param string $tag * @param string $tag
* @since [v4.2.1] * @since [v4.2.1]
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @return \Illuminate\Http\JsonResponse
*/ */
public function showByTag(Request $request, $tag) public function showByTag(Request $request, $tag) : JsonResponse | array
{ {
$this->authorize('index', Asset::class); $this->authorize('index', Asset::class);
$assets = Asset::where('asset_tag', $tag)->with('assetstatus')->with('assignedTo'); $assets = Asset::where('asset_tag', $tag)->with('assetstatus')->with('assignedTo');
@ -420,7 +449,7 @@ class AssetsController extends Controller
* @since [v4.2.1] * @since [v4.2.1]
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function showBySerial(Request $request, $serial) public function showBySerial(Request $request, $serial) : JsonResponse | array
{ {
$this->authorize('index', Asset::class); $this->authorize('index', Asset::class);
$assets = Asset::where('serial', $serial)->with('assetstatus')->with('assignedTo'); $assets = Asset::where('serial', $serial)->with('assetstatus')->with('assignedTo');
@ -447,19 +476,20 @@ class AssetsController extends Controller
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function show(Request $request, $id) public function show(Request $request, $id) : JsonResponse | array
{ {
if ($asset = Asset::with('assetstatus')->with('assignedTo')->withTrashed() if ($asset = Asset::with('assetstatus')
->withCount('checkins as checkins_count', 'checkouts as checkouts_count', 'userRequests as user_requests_count')->findOrFail($id)) { ->with('assignedTo')->withTrashed()
->withCount('checkins as checkins_count', 'checkouts as checkouts_count', 'userRequests as user_requests_count')->find($id)) {
$this->authorize('view', $asset); $this->authorize('view', $asset);
return (new AssetsTransformer)->transformAsset($asset, $request->input('components') ); return (new AssetsTransformer)->transformAsset($asset, $request->input('components') );
} }
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
} }
public function licenses(Request $request, $id) public function licenses(Request $request, $id) : array
{ {
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
$this->authorize('view', License::class); $this->authorize('view', License::class);
@ -476,9 +506,8 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
* @return \Illuminate\Http\JsonResponse
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$assets = Asset::select([ $assets = Asset::select([
@ -532,36 +561,14 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function store(StoreAssetRequest $request) public function store(StoreAssetRequest $request): JsonResponse
{ {
$asset = new Asset(); $asset = new Asset();
$asset->model()->associate(AssetModel::find((int) $request->get('model_id'))); $asset->model()->associate(AssetModel::find((int) $request->get('model_id')));
$asset->name = $request->get('name'); $asset->fill($request->validated());
$asset->serial = $request->get('serial');
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id'));
$asset->model_id = $request->get('model_id');
$asset->order_number = $request->get('order_number');
$asset->notes = $request->get('notes');
$asset->asset_tag = $request->get('asset_tag', Asset::autoincrement_asset()); //yup, problem :/
// NO IT IS NOT!!! This is never firing; we SHOW the asset_tag you're going to get, so it *will* be filled in!
$asset->user_id = Auth::id(); $asset->user_id = Auth::id();
$asset->archived = '0';
$asset->physical = '1';
$asset->depreciate = '0';
$asset->status_id = $request->get('status_id', 0);
$asset->warranty_months = $request->get('warranty_months', null);
$asset->purchase_cost = $request->get('purchase_cost');
$asset->asset_eol_date = $request->get('asset_eol_date', $asset->present()->eol_date());
$asset->purchase_date = $request->get('purchase_date', null);
$asset->assigned_to = $request->get('assigned_to', null);
$asset->supplier_id = $request->get('supplier_id');
$asset->requestable = $request->get('requestable', 0);
$asset->rtd_location_id = $request->get('rtd_location_id', null);
$asset->location_id = $request->get('rtd_location_id', null);
/** /**
* this is here just legacy reasons. Api\AssetController * this is here just legacy reasons. Api\AssetController
@ -574,10 +581,11 @@ class AssetsController extends Controller
$asset = $request->handleImages($asset); $asset = $request->handleImages($asset);
// Update custom fields in the database. // Update custom fields in the database.
// Validation for these fields is handled through the AssetRequest form request $model = AssetModel::find($request->input('model_id'));
$model = AssetModel::find($request->get('model_id'));
if (($model) && ($model->fieldset)) { // Check that it's an object and not a collection
// (Sometimes people send arrays here and they shouldn't
if (($model) && ($model instanceof AssetModel) && ($model->fieldset)) {
foreach ($model->fieldset->fields as $field) { foreach ($model->fieldset->fields as $field) {
// Set the field value based on what was sent in the request // Set the field value based on what was sent in the request
@ -585,25 +593,30 @@ class AssetsController extends Controller
// If input value is null, use custom field's default value // If input value is null, use custom field's default value
if ($field_val == null) { if ($field_val == null) {
\Log::debug('Field value for '.$field->db_column.' is null'); Log::debug('Field value for '.$field->db_column.' is null');
$field_val = $field->defaultValue($request->get('model_id')); $field_val = $field->defaultValue($request->get('model_id'));
\Log::debug('Use the default fieldset value of '.$field->defaultValue($request->get('model_id'))); Log::debug('Use the default fieldset value of '.$field->defaultValue($request->get('model_id')));
} }
// if the field is set to encrypted, make sure we encrypt the value // if the field is set to encrypted, make sure we encrypt the value
if ($field->field_encrypted == '1') { if ($field->field_encrypted == '1') {
\Log::debug('This model field is encrypted in this fieldset.'); Log::debug('This model field is encrypted in this fieldset.');
if (Gate::allows('admin')) { if (Gate::allows('admin')) {
// If input value is null, use custom field's default value // If input value is null, use custom field's default value
if (($field_val == null) && ($request->has('model_id') != '')) { if (($field_val == null) && ($request->has('model_id') != '')) {
$field_val = \Crypt::encrypt($field->defaultValue($request->get('model_id'))); $field_val = Crypt::encrypt($field->defaultValue($request->get('model_id')));
} else { } else {
$field_val = \Crypt::encrypt($request->input($field->db_column)); $field_val = Crypt::encrypt($request->input($field->db_column));
} }
} }
} }
if ($field->element == 'checkbox') {
if(is_array($field_val)) {
$field_val = implode(',', $field_val);
}
}
$asset->{$field->db_column} = $field_val; $asset->{$field->db_column} = $field_val;
@ -619,7 +632,7 @@ class AssetsController extends Controller
$target = Location::find(request('assigned_location')); $target = Location::find(request('assigned_location'));
} }
if (isset($target)) { if (isset($target)) {
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), '', 'Checked out on asset creation', e($request->get('name'))); $asset->checkOut($target, auth()->user(), date('Y-m-d H:i:s'), '', 'Checked out on asset creation', e($request->get('name')));
} }
if ($asset->image) { if ($asset->image) {
@ -627,6 +640,8 @@ class AssetsController extends Controller
} }
return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.create.success'))); return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.create.success')));
return response()->json(Helper::formatStandardApiResponse('success', (new AssetsTransformer)->transformAsset($asset), trans('admin/hardware/message.create.success')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200); return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200);
@ -637,26 +652,24 @@ class AssetsController extends Controller
* Accepts a POST request to update an asset * Accepts a POST request to update an asset
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param \App\Http\Requests\ImageUploadRequest $request
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function update(ImageUploadRequest $request, $id) public function update(UpdateAssetRequest $request, Asset $asset): JsonResponse
{ {
$this->authorize('update', Asset::class); $asset->fill($request->validated());
if ($asset = Asset::find($id)) { if ($request->has('model_id')) {
$asset->fill($request->all()); $asset->model()->associate(AssetModel::find($request->validated()['model_id']));
}
($request->filled('model_id')) ? if ($request->has('company_id')) {
$asset->model()->associate(AssetModel::find($request->get('model_id'))) : null; $asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']);
($request->filled('rtd_location_id')) ? }
$asset->location_id = $request->get('rtd_location_id') : ''; if ($request->has('rtd_location_id') && !$request->has('location_id')) {
($request->filled('company_id')) ? $asset->location_id = $request->validated()['rtd_location_id'];
$asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : ''; }
if ($request->input('last_audit_date')) {
($request->filled('rtd_location_id')) ? $asset->last_audit_date = Carbon::parse($request->input('last_audit_date'))->startOfDay()->format('Y-m-d H:i:s');
$asset->location_id = $request->get('rtd_location_id') : null; }
/** /**
* this is here just legacy reasons. Api\AssetController * this is here just legacy reasons. Api\AssetController
@ -667,51 +680,59 @@ class AssetsController extends Controller
} }
$asset = $request->handleImages($asset); $asset = $request->handleImages($asset);
$model = AssetModel::find($asset->model_id); $model = $asset->model;
// Update custom fields // Update custom fields
$problems_updating_encrypted_custom_fields = false;
if (($model) && (isset($model->fieldset))) { if (($model) && (isset($model->fieldset))) {
foreach ($model->fieldset->fields as $field) { foreach ($model->fieldset->fields as $field) {
$field_val = $request->input($field->db_column, null);
if ($request->has($field->db_column)) { if ($request->has($field->db_column)) {
if ($field->element == 'checkbox') {
if(is_array($field_val)) {
$field_val = implode(',', $field_val);
}
}
if ($field->field_encrypted == '1') { if ($field->field_encrypted == '1') {
if (Gate::allows('admin')) { if (Gate::allows('admin')) {
$asset->{$field->db_column} = \Crypt::encrypt($request->input($field->db_column)); $field_val = Crypt::encrypt($field_val);
}
} else { } else {
$asset->{$field->db_column} = $request->input($field->db_column); $problems_updating_encrypted_custom_fields = true;
continue;
}
}
$asset->{$field->db_column} = $field_val;
} }
} }
} }
}
if ($asset->save()) { if ($asset->save()) {
if (($request->filled('assigned_user')) && ($target = User::find($request->get('assigned_user')))) { if (($request->filled('assigned_user')) && ($target = User::find($request->get('assigned_user')))) {
$location = $target->location_id; $location = $target->location_id;
} elseif (($request->filled('assigned_asset')) && ($target = Asset::find($request->get('assigned_asset')))) { } elseif (($request->filled('assigned_asset')) && ($target = Asset::find($request->get('assigned_asset')))) {
$location = $target->location_id; $location = $target->location_id;
Asset::where('assigned_type', \App\Models\Asset::class)->where('assigned_to', $id) Asset::where('assigned_type', \App\Models\Asset::class)->where('assigned_to', $asset->id)
->update(['location_id' => $target->location_id]); ->update(['location_id' => $target->location_id]);
} elseif (($request->filled('assigned_location')) && ($target = Location::find($request->get('assigned_location')))) { } elseif (($request->filled('assigned_location')) && ($target = Location::find($request->get('assigned_location')))) {
$location = $target->id; $location = $target->id;
} }
if (isset($target)) { if (isset($target)) {
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), '', 'Checked out on asset update', e($request->get('name')), $location); $asset->checkOut($target, auth()->user(), date('Y-m-d H:i:s'), '', 'Checked out on asset update', e($request->get('name')), $location);
} }
if ($asset->image) { if ($asset->image) {
$asset->image = $asset->getImageUrl(); $asset->image = $asset->getImageUrl();
} }
if ($problems_updating_encrypted_custom_fields) {
return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.update.encrypted_warning')));
} else {
return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.update.success'))); return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.update.success')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200);
} }
return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200);
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
} }
@ -721,9 +742,8 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Asset::class); $this->authorize('delete', Asset::class);
@ -750,38 +770,27 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v5.1.18] * @since [v5.1.18]
* @return \Illuminate\Http\JsonResponse
*/ */
public function restore(Request $request, $assetId = null) public function restore(Request $request, $assetId = null) : JsonResponse
{ {
// Get asset information
$asset = Asset::withTrashed()->find($assetId); if ($asset = Asset::withTrashed()->find($assetId)) {
$this->authorize('delete', $asset); $this->authorize('delete', $asset);
if (isset($asset->id)) { if ($asset->deleted_at == '') {
return response()->json(Helper::formatStandardApiResponse('error', trans('general.not_deleted', ['item_type' => trans('general.asset')])), 200);
if ($asset->deleted_at=='') {
$message = 'Asset was not deleted. No data was changed.';
} else {
$message = trans('admin/hardware/message.restore.success');
// Restore the asset
Asset::withTrashed()->where('id', $assetId)->restore();
$logaction = new Actionlog();
$logaction->item_type = Asset::class;
$logaction->item_id = $asset->id;
$logaction->created_at = date("Y-m-d H:i:s");
$logaction->user_id = Auth::user()->id;
$logaction->logaction('restored');
} }
return response()->json(Helper::formatStandardApiResponse('success', (new AssetsTransformer)->transformAsset($asset, $request), $message)); if ($asset->restore()) {
return response()->json(Helper::formatStandardApiResponse('success', trans('admin/hardware/message.restore.success')), 200);
} }
// Check validation to make sure we're not restoring an asset with the same asset tag (or unique attribute) as an existing asset
return response()->json(Helper::formatStandardApiResponse('error', trans('general.could_not_restore', ['item_type' => trans('general.asset'), 'error' => $asset->getErrors()->first()])), 200);
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200); return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
} }
/** /**
@ -790,9 +799,8 @@ class AssetsController extends Controller
* @author [N. Butler] * @author [N. Butler]
* @param string $tag * @param string $tag
* @since [v6.0.5] * @since [v6.0.5]
* @return \Illuminate\Http\JsonResponse
*/ */
public function checkoutByTag(AssetCheckoutRequest $request, $tag) public function checkoutByTag(AssetCheckoutRequest $request, $tag) : JsonResponse
{ {
if ($asset = Asset::where('asset_tag', $tag)->first()) { if ($asset = Asset::where('asset_tag', $tag)->first()) {
return $this->checkout($request, $asset->id); return $this->checkout($request, $asset->id);
@ -806,9 +814,8 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function checkout(AssetCheckoutRequest $request, $asset_id) public function checkout(AssetCheckoutRequest $request, $asset_id) : JsonResponse
{ {
$this->authorize('checkout', Asset::class); $this->authorize('checkout', Asset::class);
$asset = Asset::findOrFail($asset_id); $asset = Asset::findOrFail($asset_id);
@ -825,7 +832,6 @@ class AssetsController extends Controller
'asset_tag' => $asset->asset_tag, 'asset_tag' => $asset->asset_tag,
]; ];
// This item is checked out to a location // This item is checked out to a location
if (request('checkout_to_type') == 'location') { if (request('checkout_to_type') == 'location') {
$target = Location::find(request('assigned_location')); $target = Location::find(request('assigned_location'));
@ -852,13 +858,10 @@ class AssetsController extends Controller
$asset->status_id = $request->get('status_id'); $asset->status_id = $request->get('status_id');
} }
if (! isset($target)) { if (! isset($target)) {
return response()->json(Helper::formatStandardApiResponse('error', $error_payload, 'Checkout target for asset '.e($asset->asset_tag).' is invalid - '.$error_payload['target_type'].' does not exist.')); return response()->json(Helper::formatStandardApiResponse('error', $error_payload, 'Checkout target for asset '.e($asset->asset_tag).' is invalid - '.$error_payload['target_type'].' does not exist.'));
} }
$checkout_at = request('checkout_at', date('Y-m-d H:i:s')); $checkout_at = request('checkout_at', date('Y-m-d H:i:s'));
$expected_checkin = request('expected_checkin', null); $expected_checkin = request('expected_checkin', null);
$note = request('note', null); $note = request('note', null);
@ -874,9 +877,7 @@ class AssetsController extends Controller
// $asset->location_id = $target->rtd_location_id; // $asset->location_id = $target->rtd_location_id;
// } // }
if ($asset->checkOut($target, auth()->user(), $checkout_at, $expected_checkin, $note, $asset_name, $asset->location_id)) {
if ($asset->checkOut($target, Auth::user(), $checkout_at, $expected_checkin, $note, $asset_name, $asset->location_id)) {
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.success'))); return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkout.success')));
} }
@ -890,24 +891,24 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function checkin(Request $request, $asset_id) public function checkin(Request $request, $asset_id) : JsonResponse
{ {
$this->authorize('checkin', Asset::class); $asset = Asset::with('model')->findOrFail($asset_id);
$asset = Asset::findOrFail($asset_id);
$this->authorize('checkin', $asset); $this->authorize('checkin', $asset);
$target = $asset->assignedTo; $target = $asset->assignedTo;
if (is_null($target)) { if (is_null($target)) {
return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.already_checked_in'))); return response()->json(Helper::formatStandardApiResponse('error', [
'asset_tag'=> e($asset->asset_tag),
'model' => e($asset->model->name),
'model_number' => e($asset->model->model_number)
], trans('admin/hardware/message.checkin.already_checked_in')));
} }
$asset->expected_checkin = null; $asset->expected_checkin = null;
$asset->last_checkout = null; //$asset->last_checkout = null;
$asset->last_checkin = now(); $asset->last_checkin = now();
$asset->assigned_to = null;
$asset->assignedTo()->disassociate($asset); $asset->assignedTo()->disassociate($asset);
$asset->accepted = null; $asset->accepted = null;
@ -915,13 +916,19 @@ class AssetsController extends Controller
$asset->name = $request->input('name'); $asset->name = $request->input('name');
} }
$this->migrateLegacyLocations($asset);
$asset->location_id = $asset->rtd_location_id; $asset->location_id = $asset->rtd_location_id;
if ($request->filled('location_id')) { if ($request->filled('location_id')) {
$asset->location_id = $request->input('location_id'); $asset->location_id = $request->input('location_id');
if ($request->input('update_default_location')){
$asset->rtd_location_id = $request->input('location_id');
}
} }
if ($request->has('status_id')) { if ($request->filled('status_id')) {
$asset->status_id = $request->input('status_id'); $asset->status_id = $request->input('status_id');
} }
@ -932,10 +939,31 @@ class AssetsController extends Controller
$originalValues['action_date'] = $checkin_at; $originalValues['action_date'] = $checkin_at;
} }
if ($asset->save()) { $asset->licenseseats->each(function (LicenseSeat $seat) {
event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at, $originalValues)); $seat->update(['assigned_to' => null]);
});
return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.success'))); // Get all pending Acceptances for this asset and delete them
CheckoutAcceptance::pending()
->whereHasMorph(
'checkoutable',
[Asset::class],
function (Builder $query) use ($asset) {
$query->where('id', $asset->id);
})
->get()
->map(function ($acceptance) {
$acceptance->delete();
});
if ($asset->save()) {
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), $request->input('note'), $checkin_at, $originalValues));
return response()->json(Helper::formatStandardApiResponse('success', [
'asset_tag'=> e($asset->asset_tag),
'model' => e($asset->model->name),
'model_number' => e($asset->model->model_number)
], trans('admin/hardware/message.checkin.success')));
} }
return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.error'))); return response()->json(Helper::formatStandardApiResponse('error', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.error')));
@ -946,12 +974,11 @@ class AssetsController extends Controller
* *
* @author [A. Janes] [<ajanes@adagiohealth.org>] * @author [A. Janes] [<ajanes@adagiohealth.org>]
* @since [v6.0] * @since [v6.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function checkinByTag(Request $request, $tag = null) public function checkinByTag(Request $request, $tag = null) : JsonResponse
{ {
$this->authorize('checkin', Asset::class); $this->authorize('checkin', Asset::class);
if(null == $tag && null !== ($request->input('asset_tag'))) { if (null == $tag && null !== ($request->input('asset_tag'))) {
$tag = $request->input('asset_tag'); $tag = $request->input('asset_tag');
} }
$asset = Asset::where('asset_tag', $tag)->first(); $asset = Asset::where('asset_tag', $tag)->first();
@ -972,31 +999,44 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function audit(Request $request) public function audit(Request $request) : JsonResponse
{ {
$this->authorize('audit', Asset::class); $this->authorize('audit', Asset::class);
$rules = [
'asset_tag' => 'required',
'location_id' => 'exists:locations,id|nullable|numeric',
'next_audit_date' => 'date|nullable',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()->all()));
}
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString(); $dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString();
// No tag passed - return an error
if (!$request->filled('asset_tag')) {
return response()->json(Helper::formatStandardApiResponse('error', [
'asset_tag'=> '',
'error'=> trans('admin/hardware/message.no_tag'),
], trans('admin/hardware/message.no_tag')), 200);
}
$asset = Asset::where('asset_tag', '=', $request->input('asset_tag'))->first(); $asset = Asset::where('asset_tag', '=', $request->input('asset_tag'))->first();
if ($asset) { if ($asset) {
// We don't want to log this as a normal update, so let's bypass that
/**
* Even though we do a save() further down, we don't want to log this as a "normal" asset update,
* which would trigger the Asset Observer and would log an asset *update* log entry (because the
* de-normed fields like next_audit_date on the asset itself will change on save()) *in addition* to
* the audit log entry we're creating through this controller.
*
* To prevent this double-logging (one for update and one for audit), we skip the observer and bypass
* that de-normed update log entry by using unsetEventDispatcher(), BUT invoking unsetEventDispatcher()
* will bypass normal model-level validation that's usually handled at the observer )
*
* We handle validation on the save() by checking if the asset is valid via the ->isValid() method,
* which manually invokes Watson Validating to make sure the asset's model is valid.
*
* @see \App\Observers\AssetObserver::updating()
*/
$asset->unsetEventDispatcher(); $asset->unsetEventDispatcher();
$asset->next_audit_date = $dt; $asset->next_audit_date = $dt;
@ -1012,8 +1052,12 @@ class AssetsController extends Controller
$asset->last_audit_date = date('Y-m-d H:i:s'); $asset->last_audit_date = date('Y-m-d H:i:s');
if ($asset->save()) { /**
$log = $asset->logAudit(request('note'), request('location_id')); * Invoke Watson Validating to check the asset itself and check to make sure it saved correctly.
* We have to invoke this manually because of the unsetEventDispatcher() above.)
*/
if ($asset->isValid() && $asset->save()) {
$asset->logAudit(request('note'), request('location_id'));
return response()->json(Helper::formatStandardApiResponse('success', [ return response()->json(Helper::formatStandardApiResponse('success', [
'asset_tag'=> e($asset->asset_tag), 'asset_tag'=> e($asset->asset_tag),
@ -1021,9 +1065,23 @@ class AssetsController extends Controller
'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date), 'next_audit_date' => Helper::getFormattedDateObject($asset->next_audit_date),
], trans('admin/hardware/message.audit.success'))); ], trans('admin/hardware/message.audit.success')));
} }
// Asset failed validation or was not able to be saved
return response()->json(Helper::formatStandardApiResponse('error', [
'asset_tag'=> e($asset->asset_tag),
'error'=> $asset->getErrors()->first(),
], trans('admin/hardware/message.audit.error', ['error' => $asset->getErrors()->first()])), 200);
} }
return response()->json(Helper::formatStandardApiResponse('error', ['asset_tag'=> e($request->input('asset_tag'))], 'Asset with tag '.e($request->input('asset_tag')).' not found'));
// No matching asset for the asset tag that was passed.
return response()->json(Helper::formatStandardApiResponse('error', [
'asset_tag'=> e($request->input('asset_tag')),
'error'=> trans('admin/hardware/message.audit.error'),
], trans('admin/hardware/message.audit.error', ['error' => trans('admin/hardware/message.does_not_exist')])), 200);
} }
@ -1033,9 +1091,8 @@ class AssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/ */
public function requestable(Request $request) public function requestable(Request $request) : JsonResponse | array
{ {
$this->authorize('viewRequestable', Asset::class); $this->authorize('viewRequestable', Asset::class);
@ -1057,8 +1114,7 @@ class AssetsController extends Controller
$assets = Asset::select('assets.*') $assets = Asset::select('assets.*')
->with('location', 'assetstatus', 'assetlog', 'company','assignedTo', ->with('location', 'assetstatus', 'assetlog', 'company','assignedTo',
'model.category', 'model.manufacturer', 'model.fieldset', 'supplier', 'requests') 'model.category', 'model.manufacturer', 'model.fieldset', 'supplier', 'requests');
->requestableAssets();
@ -1096,6 +1152,7 @@ class AssetsController extends Controller
break; break;
} }
$assets->requestableAssets();
// Make sure the offset and limit are actually integers and do not exceed system limits // Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $assets->count()) ? $assets->count() : app('api_offset_value'); $offset = ($request->input('offset') > $assets->count()) ? $assets->count() : app('api_offset_value');

View file

@ -8,9 +8,9 @@ use App\Http\Transformers\CategoriesTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Category; use App\Models\Category;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
class CategoriesController extends Controller class CategoriesController extends Controller
{ {
@ -21,7 +21,7 @@ class CategoriesController extends Controller
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : array
{ {
$this->authorize('view', Category::class); $this->authorize('view', Category::class);
$allowed_columns = [ $allowed_columns = [
@ -115,7 +115,7 @@ class CategoriesController extends Controller
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : JsonResponse
{ {
$this->authorize('create', Category::class); $this->authorize('create', Category::class);
$category = new Category; $category = new Category;
@ -136,9 +136,8 @@ class CategoriesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', Category::class); $this->authorize('view', Category::class);
$category = Category::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count')->findOrFail($id); $category = Category::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count')->findOrFail($id);
@ -156,7 +155,7 @@ class CategoriesController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Category::class); $this->authorize('update', Category::class);
$category = Category::findOrFail($id); $category = Category::findOrFail($id);
@ -164,7 +163,7 @@ class CategoriesController extends Controller
// Don't allow the user to change the category_type once it's been created // Don't allow the user to change the category_type once it's been created
if (($request->filled('category_type')) && ($category->category_type != $request->input('category_type'))) { if (($request->filled('category_type')) && ($category->category_type != $request->input('category_type'))) {
return response()->json( return response()->json(
Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.update.cannot_change_category_type')) Helper::formatStandardApiResponse('error', null, ['category_type' => trans('admin/categories/message.update.cannot_change_category_type')], 422)
); );
} }
$category->fill($request->all()); $category->fill($request->all());
@ -185,7 +184,7 @@ class CategoriesController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Category::class); $this->authorize('delete', Category::class);
$category = Category::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count')->findOrFail($id); $category = Category::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count')->findOrFail($id);
@ -208,7 +207,7 @@ class CategoriesController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request, $category_type = 'asset') public function selectlist(Request $request, $category_type = 'asset') : array
{ {
$this->authorize('view.selectlists'); $this->authorize('view.selectlists');
$categories = Category::select([ $categories = Category::select([

View file

@ -10,6 +10,7 @@ use App\Models\Company;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Http\JsonResponse;
class CompaniesController extends Controller class CompaniesController extends Controller
{ {
@ -18,9 +19,8 @@ class CompaniesController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Company::class); $this->authorize('view', Company::class);
@ -40,7 +40,9 @@ class CompaniesController extends Controller
'components_count', 'components_count',
]; ];
$companies = Company::withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'users as users_count'); $companies = Company::withCount(['assets as assets_count' => function ($query) {
$query->AssetsForShow();
}])->withCount('licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'users as users_count');
if ($request->filled('search')) { if ($request->filled('search')) {
$companies->TextSearch($request->input('search')); $companies->TextSearch($request->input('search'));
@ -77,9 +79,8 @@ class CompaniesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : JsonResponse
{ {
$this->authorize('create', Company::class); $this->authorize('create', Company::class);
$company = new Company; $company = new Company;
@ -100,9 +101,8 @@ class CompaniesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', Company::class); $this->authorize('view', Company::class);
$company = Company::findOrFail($id); $company = Company::findOrFail($id);
@ -118,9 +118,8 @@ class CompaniesController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Company::class); $this->authorize('update', Company::class);
$company = Company::findOrFail($id); $company = Company::findOrFail($id);
@ -142,9 +141,8 @@ class CompaniesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Company::class); $this->authorize('delete', Company::class);
$company = Company::findOrFail($id); $company = Company::findOrFail($id);
@ -167,7 +165,7 @@ class CompaniesController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$this->authorize('view.selectlists'); $this->authorize('view.selectlists');
$companies = Company::select([ $companies = Company::select([

View file

@ -5,15 +5,17 @@ namespace App\Http\Controllers\Api;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Transformers\ComponentsTransformer; use App\Http\Transformers\ComponentsTransformer;
use App\Models\Company;
use App\Models\Component; use App\Models\Component;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Events\CheckoutableCheckedIn; use App\Events\CheckoutableCheckedIn;
use App\Events\ComponentCheckedIn;
use App\Models\Asset; use App\Models\Asset;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class ComponentsController extends Controller class ComponentsController extends Controller
{ {
@ -23,9 +25,8 @@ class ComponentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* *
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Component::class); $this->authorize('view', Component::class);
@ -115,9 +116,8 @@ class ComponentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : JsonResponse
{ {
$this->authorize('create', Component::class); $this->authorize('create', Component::class);
$component = new Component; $component = new Component;
@ -136,9 +136,8 @@ class ComponentsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', Component::class); $this->authorize('view', Component::class);
$component = Component::findOrFail($id); $component = Component::findOrFail($id);
@ -155,9 +154,8 @@ class ComponentsController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Component::class); $this->authorize('update', Component::class);
$component = Component::findOrFail($id); $component = Component::findOrFail($id);
@ -178,9 +176,8 @@ class ComponentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Component::class); $this->authorize('delete', Component::class);
$component = Component::findOrFail($id); $component = Component::findOrFail($id);
@ -197,9 +194,8 @@ class ComponentsController extends Controller
* @since [v4.0] * @since [v4.0]
* @param Request $request * @param Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function getAssets(Request $request, $id) public function getAssets(Request $request, $id) : array
{ {
$this->authorize('view', \App\Models\Asset::class); $this->authorize('view', \App\Models\Asset::class);
@ -240,10 +236,8 @@ class ComponentsController extends Controller
* @since [v5.1.8] * @since [v5.1.8]
* @param Request $request * @param Request $request
* @param int $componentId * @param int $componentId
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function checkout(Request $request, $componentId) public function checkout(Request $request, $componentId) : JsonResponse
{ {
// Check if the component exists // Check if the component exists
if (!$component = Component::find($componentId)) { if (!$component = Component::find($componentId)) {
@ -274,9 +268,9 @@ class ComponentsController extends Controller
$component->assets()->attach($component->id, [ $component->assets()->attach($component->id, [
'component_id' => $component->id, 'component_id' => $component->id,
'created_at' => \Carbon::now(), 'created_at' => Carbon::now(),
'assigned_qty' => $request->get('assigned_qty', 1), 'assigned_qty' => $request->get('assigned_qty', 1),
'user_id' => \Auth::id(), 'user_id' => auth()->id(),
'asset_id' => $request->get('assigned_to'), 'asset_id' => $request->get('assigned_to'),
'note' => $request->get('note'), 'note' => $request->get('note'),
]); ]);
@ -296,12 +290,10 @@ class ComponentsController extends Controller
* @since [v5.1.8] * @since [v5.1.8]
* @param Request $request * @param Request $request
* @param $component_asset_id * @param $component_asset_id
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function checkin(Request $request, $component_asset_id) public function checkin(Request $request, $component_asset_id) : JsonResponse
{ {
if ($component_assets = \DB::table('components_assets')->find($component_asset_id)) { if ($component_assets = DB::table('components_assets')->find($component_asset_id)) {
if (is_null($component = Component::find($component_assets->component_id))) { if (is_null($component = Component::find($component_assets->component_id))) {
@ -314,7 +306,7 @@ class ComponentsController extends Controller
if ($max_to_checkin > 1) { if ($max_to_checkin > 1) {
$validator = \Validator::make($request->all(), [ $validator = Validator::make($request->all(), [
"checkin_qty" => "required|numeric|between:1,$max_to_checkin" "checkin_qty" => "required|numeric|between:1,$max_to_checkin"
]); ]);
@ -331,21 +323,21 @@ class ComponentsController extends Controller
// actually checked out. // actually checked out.
$component_assets->assigned_qty = $qty_remaining_in_checkout; $component_assets->assigned_qty = $qty_remaining_in_checkout;
\Log::debug($component_asset_id.' - '.$qty_remaining_in_checkout.' remaining in record '.$component_assets->id); Log::debug($component_asset_id.' - '.$qty_remaining_in_checkout.' remaining in record '.$component_assets->id);
\DB::table('components_assets')->where('id', DB::table('components_assets')->where('id',
$component_asset_id)->update(['assigned_qty' => $qty_remaining_in_checkout]); $component_asset_id)->update(['assigned_qty' => $qty_remaining_in_checkout]);
// If the checked-in qty is exactly the same as the assigned_qty, // If the checked-in qty is exactly the same as the assigned_qty,
// we can simply delete the associated components_assets record // we can simply delete the associated components_assets record
if ($qty_remaining_in_checkout == 0) { if ($qty_remaining_in_checkout == 0) {
\DB::table('components_assets')->where('id', '=', $component_asset_id)->delete(); DB::table('components_assets')->where('id', '=', $component_asset_id)->delete();
} }
$asset = Asset::find($component_assets->asset_id); $asset = Asset::find($component_assets->asset_id);
event(new CheckoutableCheckedIn($component, $asset, \Auth::user(), $request->input('note'), \Carbon::now())); event(new CheckoutableCheckedIn($component, $asset, auth()->user(), $request->input('note'), Carbon::now()));
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/components/message.checkin.success'))); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/components/message.checkin.success')));

View file

@ -2,8 +2,10 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Events\CheckoutableCheckedOut;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\StoreConsumableRequest;
use App\Http\Transformers\ConsumablesTransformer; use App\Http\Transformers\ConsumablesTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Company; use App\Models\Company;
@ -11,6 +13,8 @@ use App\Models\Consumable;
use App\Models\User; use App\Models\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\JsonResponse;
class ConsumablesController extends Controller class ConsumablesController extends Controller
{ {
@ -19,34 +23,13 @@ class ConsumablesController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
*
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : array
{ {
$this->authorize('index', Consumable::class); $this->authorize('index', Consumable::class);
// This array is what determines which fields should be allowed to be sorted on ON the table itself, no relations $consumables = Consumable::with('company', 'location', 'category', 'supplier', 'manufacturer')
// Relations will be handled in query scopes a little further down. ->withCount('users as consumables_users_count');
$allowed_columns =
[
'id',
'name',
'order_number',
'min_amt',
'purchase_date',
'purchase_cost',
'company',
'category',
'model_number',
'item_no',
'qty',
'image',
'notes',
];
$consumables = Consumable::select('consumables.*')
->with('company', 'location', 'category', 'users', 'manufacturer');
if ($request->filled('search')) { if ($request->filled('search')) {
$consumables = $consumables->TextSearch(e($request->input('search'))); $consumables = $consumables->TextSearch(e($request->input('search')));
@ -88,15 +71,9 @@ class ConsumablesController extends Controller
// Make sure the offset and limit are actually integers and do not exceed system limits // Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $consumables->count()) ? $consumables->count() : app('api_offset_value'); $offset = ($request->input('offset') > $consumables->count()) ? $consumables->count() : app('api_offset_value');
$limit = app('api_limit_value'); $limit = app('api_limit_value');
$allowed_columns = ['id', 'name', 'order_number', 'min_amt', 'purchase_date', 'purchase_cost', 'company', 'category', 'model_number', 'item_no', 'manufacturer', 'location', 'qty', 'image'];
$order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort_override = $request->input('sort'); switch ($request->input('sort')) {
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'created_at';
switch ($sort_override) {
case 'category': case 'category':
$consumables = $consumables->OrderCategory($order); $consumables = $consumables->OrderCategory($order);
break; break;
@ -110,10 +87,30 @@ class ConsumablesController extends Controller
$consumables = $consumables->OrderCompany($order); $consumables = $consumables->OrderCompany($order);
break; break;
case 'supplier': case 'supplier':
$components = $consumables->OrderSupplier($order); $consumables = $consumables->OrderSupplier($order);
break; break;
default: default:
$consumables = $consumables->orderBy($column_sort, $order); // This array is what determines which fields should be allowed to be sorted on ON the table itself.
// These must match a column on the consumables table directly.
$allowed_columns = [
'id',
'name',
'order_number',
'min_amt',
'purchase_date',
'purchase_cost',
'company',
'category',
'model_number',
'item_no',
'manufacturer',
'location',
'qty',
'image'
];
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
$consumables = $consumables->orderBy($sort, $order);
break; break;
} }
@ -129,9 +126,8 @@ class ConsumablesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(StoreConsumableRequest $request) : JsonResponse
{ {
$this->authorize('create', Consumable::class); $this->authorize('create', Consumable::class);
$consumable = new Consumable; $consumable = new Consumable;
@ -150,9 +146,8 @@ class ConsumablesController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', Consumable::class); $this->authorize('view', Consumable::class);
$consumable = Consumable::with('users')->findOrFail($id); $consumable = Consumable::with('users')->findOrFail($id);
@ -167,9 +162,8 @@ class ConsumablesController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(StoreConsumableRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Consumable::class); $this->authorize('update', Consumable::class);
$consumable = Consumable::findOrFail($id); $consumable = Consumable::findOrFail($id);
@ -189,9 +183,8 @@ class ConsumablesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Consumable::class); $this->authorize('delete', Consumable::class);
$consumable = Consumable::findOrFail($id); $consumable = Consumable::findOrFail($id);
@ -208,9 +201,8 @@ class ConsumablesController extends Controller
* @see \App\Http\Controllers\Consumables\ConsumablesController::getView() method that returns the form. * @see \App\Http\Controllers\Consumables\ConsumablesController::getView() method that returns the form.
* @since [v1.0] * @since [v1.0]
* @param int $consumableId * @param int $consumableId
* @return array
*/ */
public function getDataView($consumableId) public function getDataView($consumableId) : array
{ {
$consumable = Consumable::with(['consumableAssignments'=> function ($query) { $consumable = Consumable::with(['consumableAssignments'=> function ($query) {
$query->orderBy($query->getModel()->getTable().'.created_at', 'DESC'); $query->orderBy($query->getModel()->getTable().'.created_at', 'DESC');
@ -249,9 +241,8 @@ class ConsumablesController extends Controller
* @author [A. Gutierrez] [<andres@baller.tv>] * @author [A. Gutierrez] [<andres@baller.tv>]
* @param int $id * @param int $id
* @since [v4.9.5] * @since [v4.9.5]
* @return JsonResponse
*/ */
public function checkout(Request $request, $id) public function checkout(Request $request, $id) : JsonResponse
{ {
// Check if the consumable exists // Check if the consumable exists
if (!$consumable = Consumable::with('users')->find($id)) { if (!$consumable = Consumable::with('users')->find($id)) {
@ -263,14 +254,11 @@ class ConsumablesController extends Controller
// Make sure there is at least one available to checkout // Make sure there is at least one available to checkout
if ($consumable->numRemaining() <= 0) { if ($consumable->numRemaining() <= 0) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/consumables/message.checkout.unavailable'))); return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/consumables/message.checkout.unavailable')));
\Log::debug('No enough remaining');
} }
// Make sure there is a valid category // Make sure there is a valid category
if (!$consumable->category){ if (!$consumable->category){
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.invalid_item_category_single', ['type' => trans('general.consumable')]))); return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.invalid_item_category_single', ['type' => trans('general.consumable')])));
return redirect()->route('consumables.index')->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.consumable')]));
} }
@ -278,7 +266,6 @@ class ConsumablesController extends Controller
if (!$user = User::find($request->input('assigned_to'))) { if (!$user = User::find($request->input('assigned_to'))) {
// Return error message // Return error message
return response()->json(Helper::formatStandardApiResponse('error', null, 'No user found')); return response()->json(Helper::formatStandardApiResponse('error', null, 'No user found'));
\Log::debug('No valid user');
} }
// Update the consumable data // Update the consumable data
@ -293,15 +280,7 @@ class ConsumablesController extends Controller
] ]
); );
// Log checkout event event(new CheckoutableCheckedOut($consumable, $user, auth()->user(), $request->input('note')));
$logaction = $consumable->logCheckout($request->input('note'), $user);
$data['log_id'] = $logaction->id;
$data['eula'] = $consumable->getEula();
$data['first_name'] = $user->first_name;
$data['item_name'] = $consumable->name;
$data['checkout_date'] = $logaction->created_at;
$data['note'] = $logaction->note;
$data['require_acceptance'] = $consumable->requireAcceptance();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/consumables/message.checkout.success'))); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/consumables/message.checkout.success')));
@ -312,7 +291,7 @@ class ConsumablesController extends Controller
* *
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$consumables = Consumable::select([ $consumables = Consumable::select([
'consumables.id', 'consumables.id',

View file

@ -8,7 +8,8 @@ use App\Http\Transformers\CustomFieldsTransformer;
use App\Models\CustomField; use App\Models\CustomField;
use App\Models\CustomFieldset; use App\Models\CustomFieldset;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Http\JsonResponse;
class CustomFieldsController extends Controller class CustomFieldsController extends Controller
{ {
@ -20,7 +21,7 @@ class CustomFieldsController extends Controller
* @since [v3.0] * @since [v3.0]
* @return array * @return array
*/ */
public function index() public function index() : array
{ {
$this->authorize('index', CustomField::class); $this->authorize('index', CustomField::class);
$fields = CustomField::get(); $fields = CustomField::get();
@ -33,9 +34,8 @@ class CustomFieldsController extends Controller
* @author [V. Cordes] [<volker@fdatek.de>] * @author [V. Cordes] [<volker@fdatek.de>]
* @param int $id * @param int $id
* @since [v4.1.10] * @since [v4.1.10]
* @return View
*/ */
public function show($id) public function show($id) : JsonResponse | array
{ {
$this->authorize('view', CustomField::class); $this->authorize('view', CustomField::class);
if ($field = CustomField::find($id)) { if ($field = CustomField::find($id)) {
@ -52,9 +52,8 @@ class CustomFieldsController extends Controller
* @since [v4.1.10] * @since [v4.1.10]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : JsonResponse
{ {
$this->authorize('update', CustomField::class); $this->authorize('update', CustomField::class);
$field = CustomField::findOrFail($id); $field = CustomField::findOrFail($id);
@ -86,9 +85,8 @@ class CustomFieldsController extends Controller
* @author [V. Cordes] [<volker@fdatek.de>] * @author [V. Cordes] [<volker@fdatek.de>]
* @since [v4.1.10] * @since [v4.1.10]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
$field = new CustomField; $field = new CustomField;
@ -136,7 +134,7 @@ class CustomFieldsController extends Controller
return $fieldset->fields()->sync($fields); return $fieldset->fields()->sync($fields);
} }
public function associate(Request $request, $field_id) public function associate(Request $request, $field_id) : JsonResponse
{ {
$this->authorize('update', CustomFieldset::class); $this->authorize('update', CustomFieldset::class);
@ -155,10 +153,9 @@ class CustomFieldsController extends Controller
return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.update.success'))); return response()->json(Helper::formatStandardApiResponse('success', $fieldset, trans('admin/custom_fields/message.fieldset.update.success')));
} }
public function disassociate(Request $request, $field_id) public function disassociate(Request $request, $field_id) : JsonResponse
{ {
$this->authorize('update', CustomFieldset::class); $this->authorize('update', CustomFieldset::class);
$field = CustomField::findOrFail($field_id); $field = CustomField::findOrFail($field_id);
$fieldset_id = $request->input('fieldset_id'); $fieldset_id = $request->input('fieldset_id');
@ -179,9 +176,8 @@ class CustomFieldsController extends Controller
* *
* @author [Brady Wetherington] [<uberbrady@gmail.com>] * @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @since [v1.8] * @since [v1.8]
* @return Redirect
*/ */
public function destroy($field_id) public function destroy($field_id) : JsonResponse
{ {
$field = CustomField::findOrFail($field_id); $field = CustomField::findOrFail($field_id);

View file

@ -9,8 +9,7 @@ use App\Http\Transformers\CustomFieldsTransformer;
use App\Models\CustomFieldset; use App\Models\CustomFieldset;
use App\Models\CustomField; use App\Models\CustomField;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Redirect; use Illuminate\Http\JsonResponse;
use View;
/** /**
* This controller handles all actions related to Custom Asset Fieldsets for * This controller handles all actions related to Custom Asset Fieldsets for
@ -30,9 +29,8 @@ class CustomFieldsetsController extends Controller
* @author [Josh Gibson] * @author [Josh Gibson]
* @param int $id * @param int $id
* @since [v1.8] * @since [v1.8]
* @return View
*/ */
public function index() public function index() : array
{ {
$this->authorize('index', CustomField::class); $this->authorize('index', CustomField::class);
$fieldsets = CustomFieldset::withCount('fields as fields_count', 'models as models_count')->get(); $fieldsets = CustomFieldset::withCount('fields as fields_count', 'models as models_count')->get();
@ -46,9 +44,8 @@ class CustomFieldsetsController extends Controller
* @author [Josh Gibson] * @author [Josh Gibson]
* @param int $id * @param int $id
* @since [v1.8] * @since [v1.8]
* @return View
*/ */
public function show($id) public function show($id) : JsonResponse | array
{ {
$this->authorize('view', CustomField::class); $this->authorize('view', CustomField::class);
if ($fieldset = CustomFieldset::find($id)) { if ($fieldset = CustomFieldset::find($id)) {
@ -65,9 +62,8 @@ class CustomFieldsetsController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : JsonResponse
{ {
$this->authorize('update', CustomField::class); $this->authorize('update', CustomField::class);
$fieldset = CustomFieldset::findOrFail($id); $fieldset = CustomFieldset::findOrFail($id);
@ -86,9 +82,8 @@ class CustomFieldsetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
$this->authorize('create', CustomField::class); $this->authorize('create', CustomField::class);
$fieldset = new CustomFieldset; $fieldset = new CustomFieldset;
@ -118,9 +113,8 @@ class CustomFieldsetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return Redirect
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', CustomField::class); $this->authorize('delete', CustomField::class);
$fieldset = CustomFieldset::findOrFail($id); $fieldset = CustomFieldset::findOrFail($id);
@ -147,7 +141,7 @@ class CustomFieldsetsController extends Controller
* @param $fieldsetId * @param $fieldsetId
* @return string JSON * @return string JSON
*/ */
public function fields($id) public function fields($id) : array
{ {
$this->authorize('view', CustomField::class); $this->authorize('view', CustomField::class);
$set = CustomFieldset::findOrFail($id); $set = CustomFieldset::findOrFail($id);
@ -164,14 +158,11 @@ class CustomFieldsetsController extends Controller
* @param $fieldsetId * @param $fieldsetId
* @return string JSON * @return string JSON
*/ */
public function fieldsWithDefaultValues($fieldsetId, $modelId) public function fieldsWithDefaultValues($fieldsetId, $modelId) : array
{ {
$this->authorize('view', CustomField::class); $this->authorize('view', CustomField::class);
$set = CustomFieldset::findOrFail($fieldsetId); $set = CustomFieldset::findOrFail($fieldsetId);
$fields = $set->fields; $fields = $set->fields;
return (new CustomFieldsTransformer)->transformCustomFieldsWithDefaultValues($fields, $modelId, $fields->count()); return (new CustomFieldsTransformer)->transformCustomFieldsWithDefaultValues($fields, $modelId, $fields->count());
} }
} }

View file

@ -6,12 +6,11 @@ use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Transformers\DepartmentsTransformer; use App\Http\Transformers\DepartmentsTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Company;
use App\Models\Department; use App\Models\Department;
use Auth;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Http\JsonResponse;
class DepartmentsController extends Controller class DepartmentsController extends Controller
{ {
@ -20,9 +19,8 @@ class DepartmentsController extends Controller
* *
* @author [Godfrey Martinez] [<snipe@snipe.net>] * @author [Godfrey Martinez] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Department::class); $this->authorize('view', Department::class);
$allowed_columns = ['id', 'name', 'image', 'users_count']; $allowed_columns = ['id', 'name', 'image', 'users_count'];
@ -91,16 +89,15 @@ class DepartmentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : JsonResponse
{ {
$this->authorize('create', Department::class); $this->authorize('create', Department::class);
$department = new Department; $department = new Department;
$department->fill($request->all()); $department->fill($request->all());
$department = $request->handleImages($department); $department = $request->handleImages($department);
$department->user_id = Auth::user()->id; $department->user_id = auth()->id();
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null); $department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
if ($department->save()) { if ($department->save()) {
@ -116,13 +113,11 @@ class DepartmentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', Department::class); $this->authorize('view', Department::class);
$department = Department::findOrFail($id); $department = Department::findOrFail($id);
return (new DepartmentsTransformer)->transformDepartment($department); return (new DepartmentsTransformer)->transformDepartment($department);
} }
@ -133,9 +128,8 @@ class DepartmentsController extends Controller
* @since [v5.0] * @since [v5.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Department::class); $this->authorize('update', Department::class);
$department = Department::findOrFail($id); $department = Department::findOrFail($id);
@ -156,9 +150,8 @@ class DepartmentsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $locationId * @param int $locationId
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\RedirectResponse
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$department = Department::findOrFail($id); $department = Department::findOrFail($id);
@ -180,7 +173,7 @@ class DepartmentsController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$this->authorize('view.selectlists'); $this->authorize('view.selectlists');

View file

@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Http\Transformers\DepreciationsTransformer; use App\Http\Transformers\DepreciationsTransformer;
use App\Models\Depreciation; use App\Models\Depreciation;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class DepreciationsController extends Controller class DepreciationsController extends Controller
{ {
@ -15,14 +16,13 @@ class DepreciationsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Depreciation::class); $this->authorize('view', Depreciation::class);
$allowed_columns = ['id','name','months','depreciation_min','created_at']; $allowed_columns = ['id','name','months','depreciation_min', 'depreciation_type','created_at'];
$depreciations = Depreciation::select('id','name','months','depreciation_min','user_id','created_at','updated_at'); $depreciations = Depreciation::select('id','name','months','depreciation_min','depreciation_type','user_id','created_at','updated_at');
if ($request->filled('search')) { if ($request->filled('search')) {
$depreciations = $depreciations->TextSearch($request->input('search')); $depreciations = $depreciations->TextSearch($request->input('search'));
@ -48,9 +48,8 @@ class DepreciationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
$this->authorize('create', Depreciation::class); $this->authorize('create', Depreciation::class);
$depreciation = new Depreciation; $depreciation = new Depreciation;
@ -69,9 +68,8 @@ class DepreciationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : JsonResponse | array
{ {
$this->authorize('view', Depreciation::class); $this->authorize('view', Depreciation::class);
$depreciation = Depreciation::findOrFail($id); $depreciation = Depreciation::findOrFail($id);
@ -86,9 +84,8 @@ class DepreciationsController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : JsonResponse
{ {
$this->authorize('update', Depreciation::class); $this->authorize('update', Depreciation::class);
$depreciation = Depreciation::findOrFail($id); $depreciation = Depreciation::findOrFail($id);
@ -107,9 +104,8 @@ class DepreciationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Depreciation::class); $this->authorize('delete', Depreciation::class);
$depreciation = Depreciation::withCount('models as models_count')->findOrFail($id); $depreciation = Depreciation::withCount('models as models_count')->findOrFail($id);

View file

@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Http\Transformers\GroupsTransformer; use App\Http\Transformers\GroupsTransformer;
use App\Models\Group; use App\Models\Group;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class GroupsController extends Controller class GroupsController extends Controller
@ -16,16 +17,15 @@ class GroupsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('superadmin'); $this->authorize('superadmin');
$this->authorize('view', Group::class); $this->authorize('view', Group::class);
$allowed_columns = ['id', 'name', 'created_at', 'users_count']; $allowed_columns = ['id', 'name', 'created_at', 'users_count'];
$groups = Group::select('id', 'name', 'permissions', 'created_at', 'updated_at')->withCount('users as users_count'); $groups = Group::select('id', 'name', 'permissions', 'created_at', 'updated_at', 'created_by')->with('admin')->withCount('users as users_count');
if ($request->filled('search')) { if ($request->filled('search')) {
$groups = $groups->TextSearch($request->input('search')); $groups = $groups->TextSearch($request->input('search'));
@ -55,18 +55,21 @@ class GroupsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
$this->authorize('superadmin'); $this->authorize('superadmin');
$group = new Group; $group = new Group;
// Get all the available permissions
$permissions = config('permissions');
$groupPermissions = Helper::selectedPermissionsArray($permissions, $permissions);
$group->name = $request->input('name'); $group->name = $request->input('name');
$group->permissions = json_encode($request->input('permissions')); // Todo - some JSON validation stuff here $group->created_by = auth()->id();
$group->permissions = json_encode($request->input('permissions', $groupPermissions));
if ($group->save()) { if ($group->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $group, trans('admin/groups/message.create.success'))); return response()->json(Helper::formatStandardApiResponse('success', (new GroupsTransformer)->transformGroup($group), trans('admin/groups/message.success.create')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, $group->getErrors())); return response()->json(Helper::formatStandardApiResponse('error', null, $group->getErrors()));
@ -78,13 +81,11 @@ class GroupsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('superadmin'); $this->authorize('superadmin');
$group = Group::findOrFail($id); $group = Group::findOrFail($id);
return (new GroupsTransformer)->transformGroup($group); return (new GroupsTransformer)->transformGroup($group);
} }
@ -95,9 +96,8 @@ class GroupsController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : JsonResponse
{ {
$this->authorize('superadmin'); $this->authorize('superadmin');
$group = Group::findOrFail($id); $group = Group::findOrFail($id);
@ -106,7 +106,7 @@ class GroupsController extends Controller
$group->permissions = $request->input('permissions'); // Todo - some JSON validation stuff here $group->permissions = $request->input('permissions'); // Todo - some JSON validation stuff here
if ($group->save()) { if ($group->save()) {
return response()->json(Helper::formatStandardApiResponse('success', $group, trans('admin/groups/message.update.success'))); return response()->json(Helper::formatStandardApiResponse('success', (new GroupsTransformer)->transformGroup($group), trans('admin/groups/message.success.update')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, $group->getErrors())); return response()->json(Helper::formatStandardApiResponse('error', null, $group->getErrors()));
@ -118,9 +118,8 @@ class GroupsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('superadmin'); $this->authorize('superadmin');
$group = Group::findOrFail($id); $group = Group::findOrFail($id);

View file

@ -9,22 +9,23 @@ use App\Http\Transformers\ImportsTransformer;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Company; use App\Models\Company;
use App\Models\Import; use App\Models\Import;
use Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Database\Eloquent\JsonEncodingException; use Illuminate\Database\Eloquent\JsonEncodingException;
use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use League\Csv\Reader; use League\Csv\Reader;
use Symfony\Component\HttpFoundation\File\Exception\FileException; use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\JsonResponse;
class ImportController extends Controller class ImportController extends Controller
{ {
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *
* @return \Illuminate\Http\Response
*/ */
public function index() public function index() : JsonResponse | array
{ {
$this->authorize('import'); $this->authorize('import');
$imports = Import::latest()->get(); $imports = Import::latest()->get();
@ -36,9 +37,8 @@ class ImportController extends Controller
* Process and store a CSV upload file. * Process and store a CSV upload file.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/ */
public function store() public function store() : JsonResponse
{ {
$this->authorize('import'); $this->authorize('import');
if (! config('app.lock_passwords')) { if (! config('app.lock_passwords')) {
@ -151,18 +151,17 @@ class ImportController extends Controller
* Processes the specified Import. * Processes the specified Import.
* *
* @param int $import_id * @param int $import_id
* @return \Illuminate\Http\Response
*/ */
public function process(ItemImportRequest $request, $import_id) public function process(ItemImportRequest $request, $import_id) : JsonResponse
{ {
$this->authorize('import'); $this->authorize('import');
// Run a backup immediately before processing // Run a backup immediately before processing
if ($request->get('run-backup')) { if ($request->get('run-backup')) {
\Log::debug('Backup manually requested via importer'); Log::debug('Backup manually requested via importer');
Artisan::call('snipeit:backup', ['--filename' => 'pre-import-backup-'.date('Y-m-d-H:i:s')]); Artisan::call('snipeit:backup', ['--filename' => 'pre-import-backup-'.date('Y-m-d-H:i:s')]);
} else { } else {
\Log::debug('NO BACKUP requested via importer'); Log::debug('NO BACKUP requested via importer');
} }
$import = Import::find($import_id); $import = Import::find($import_id);
@ -211,9 +210,8 @@ class ImportController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $import_id * @param int $import_id
* @return \Illuminate\Http\Response
*/ */
public function destroy($import_id) public function destroy($import_id) : JsonResponse
{ {
$this->authorize('create', Asset::class); $this->authorize('create', Asset::class);
@ -230,6 +228,8 @@ class ImportController extends Controller
return response()->json(Helper::formatStandardApiResponse('warning', null, trans('admin/hardware/message.import.file_not_deleted_warning'))); return response()->json(Helper::formatStandardApiResponse('warning', null, trans('admin/hardware/message.import.file_not_deleted_warning')));
} }
} }
return response()->json(Helper::formatStandardApiResponse('warning', null, trans('admin/hardware/message.import.file_not_deleted_warning')));
} }
} }

View file

@ -8,7 +8,7 @@ use App\Http\Transformers\LabelsTransformer;
use App\Models\Labels\Label; use App\Models\Labels\Label;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\ItemNotFoundException; use Illuminate\Support\ItemNotFoundException;
use Auth; use Illuminate\Http\JsonResponse;
class LabelsController extends Controller class LabelsController extends Controller
{ {
@ -16,9 +16,8 @@ class LabelsController extends Controller
* Returns JSON listing of all labels. * Returns JSON listing of all labels.
* *
* @author Grant Le Roux <grant.leroux+snipe-it@gmail.com> * @author Grant Le Roux <grant.leroux+snipe-it@gmail.com>
* @return JsonResponse
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Label::class); $this->authorize('view', Label::class);
@ -50,9 +49,8 @@ class LabelsController extends Controller
* *
* @author Grant Le Roux <grant.leroux+snipe-it@gmail.com> * @author Grant Le Roux <grant.leroux+snipe-it@gmail.com>
* @param string $labelName * @param string $labelName
* @return JsonResponse
*/ */
public function show(string $labelName) public function show(string $labelName) : JsonResponse | array
{ {
$labelName = str_replace('/', '\\', $labelName); $labelName = str_replace('/', '\\', $labelName);
try { try {

View file

@ -9,7 +9,7 @@ use App\Models\Asset;
use App\Models\License; use App\Models\License;
use App\Models\LicenseSeat; use App\Models\LicenseSeat;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class LicenseSeatsController extends Controller class LicenseSeatsController extends Controller
@ -19,11 +19,10 @@ class LicenseSeatsController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $licenseId * @param int $licenseId
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request, $licenseId) public function index(Request $request, $licenseId) : JsonResponse | array
{ {
//
if ($license = License::find($licenseId)) { if ($license = License::find($licenseId)) {
$this->authorize('view', $license); $this->authorize('view', $license);
@ -64,11 +63,10 @@ class LicenseSeatsController extends Controller
* *
* @param int $licenseId * @param int $licenseId
* @param int $seatId * @param int $seatId
* @return \Illuminate\Http\Response
*/ */
public function show($licenseId, $seatId) public function show($licenseId, $seatId) : JsonResponse | array
{ {
//
$this->authorize('view', License::class); $this->authorize('view', License::class);
// sanity checks: // sanity checks:
// 1. does the license seat exist? // 1. does the license seat exist?
@ -89,19 +87,18 @@ class LicenseSeatsController extends Controller
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $licenseId * @param int $licenseId
* @param int $seatId * @param int $seatId
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $licenseId, $seatId) public function update(Request $request, $licenseId, $seatId) : JsonResponse | array
{ {
$this->authorize('checkout', License::class); $this->authorize('checkout', License::class);
// sanity checks:
// 1. does the license seat exist?
if (! $licenseSeat = LicenseSeat::find($seatId)) { if (! $licenseSeat = LicenseSeat::find($seatId)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat not found')); return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat not found'));
} }
// 2. does the seat belong to the specified license?
if (! $license = $licenseSeat->license()->first() || $license->id != intval($licenseId)) { $license = $licenseSeat->license()->first();
if (!$license || $license->id != intval($licenseId)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat does not belong to the specified license')); return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat does not belong to the specified license'));
} }
@ -110,7 +107,7 @@ class LicenseSeatsController extends Controller
// attempt to update the license seat // attempt to update the license seat
$licenseSeat->fill($request->all()); $licenseSeat->fill($request->all());
$licenseSeat->user_id = Auth::user()->id; $licenseSeat->user_id = auth()->id();
// check if this update is a checkin operation // check if this update is a checkin operation
// 1. are relevant fields touched at all? // 1. are relevant fields touched at all?

View file

@ -4,14 +4,12 @@ namespace App\Http\Controllers\Api;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Transformers\LicenseSeatsTransformer;
use App\Http\Transformers\LicensesTransformer; use App\Http\Transformers\LicensesTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Company;
use App\Models\License; use App\Models\License;
use App\Models\LicenseSeat;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Http\JsonResponse;
class LicensesController extends Controller class LicensesController extends Controller
{ {
@ -21,13 +19,12 @@ class LicensesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* *
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', License::class); $this->authorize('view', License::class);
$licenses = License::with('company', 'manufacturer', 'supplier','category')->withCount('freeSeats as free_seats_count'); $licenses = License::with('company', 'manufacturer', 'supplier','category', 'adminuser')->withCount('freeSeats as free_seats_count');
if ($request->filled('company_id')) { if ($request->filled('company_id')) {
$licenses->where('company_id', '=', $request->input('company_id')); $licenses->where('company_id', '=', $request->input('company_id'));
@ -73,6 +70,9 @@ class LicensesController extends Controller
$licenses->where('depreciation_id', '=', $request->input('depreciation_id')); $licenses->where('depreciation_id', '=', $request->input('depreciation_id'));
} }
if ($request->filled('user_id')) {
$licenses->where('user_id', '=', $request->input('user_id'));
}
if (($request->filled('maintained')) && ($request->input('maintained')=='true')) { if (($request->filled('maintained')) && ($request->input('maintained')=='true')) {
$licenses->where('maintained','=',1); $licenses->where('maintained','=',1);
@ -116,6 +116,9 @@ class LicensesController extends Controller
case 'company': case 'company':
$licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order); $licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
break; break;
case 'created_by':
$licenses = $licenses->OrderCreatedBy($order);
break;
default: default:
$allowed_columns = $allowed_columns =
[ [
@ -136,6 +139,7 @@ class LicensesController extends Controller
'seats', 'seats',
'termination_date', 'termination_date',
'depreciation_id', 'depreciation_id',
'min_amt',
]; ];
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at'; $sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
$licenses = $licenses->orderBy($sort, $order); $licenses = $licenses->orderBy($sort, $order);
@ -155,11 +159,9 @@ class LicensesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
//
$this->authorize('create', License::class); $this->authorize('create', License::class);
$license = new License; $license = new License;
$license->fill($request->all()); $license->fill($request->all());
@ -176,9 +178,8 @@ class LicensesController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : JsonResponse | array
{ {
$this->authorize('view', License::class); $this->authorize('view', License::class);
$license = License::withCount('freeSeats')->findOrFail($id); $license = License::withCount('freeSeats')->findOrFail($id);
@ -194,9 +195,8 @@ class LicensesController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : JsonResponse | array
{ {
// //
$this->authorize('update', License::class); $this->authorize('update', License::class);
@ -217,9 +217,8 @@ class LicensesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
// //
$license = License::findOrFail($id); $license = License::findOrFail($id);
@ -247,7 +246,7 @@ class LicensesController extends Controller
* *
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$licenses = License::select([ $licenses = License::select([
'licenses.id', 'licenses.id',

View file

@ -5,12 +5,15 @@ namespace App\Http\Controllers\Api;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Transformers\AssetsTransformer;
use App\Http\Transformers\LocationsTransformer; use App\Http\Transformers\LocationsTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Asset;
use App\Models\Location; use App\Models\Location;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Http\JsonResponse;
class LocationsController extends Controller class LocationsController extends Controller
{ {
@ -21,13 +24,31 @@ class LocationsController extends Controller
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Location::class); $this->authorize('view', Location::class);
$allowed_columns = [ $allowed_columns = [
'id', 'name', 'address', 'address2', 'city', 'state', 'country', 'zip', 'created_at', 'id',
'updated_at', 'manager_id', 'image', 'name',
'assigned_assets_count', 'users_count', 'assets_count','assigned_assets_count', 'assets_count', 'rtd_assets_count', 'currency', 'ldap_ou', ]; 'address',
'address2',
'city',
'state',
'country',
'zip',
'created_at',
'updated_at',
'manager_id',
'image',
'assigned_assets_count',
'users_count',
'assets_count',
'assigned_assets_count',
'assets_count',
'rtd_assets_count',
'currency',
'ldap_ou',
];
$locations = Location::with('parent', 'manager', 'children')->select([ $locations = Location::with('parent', 'manager', 'children')->select([
'locations.id', 'locations.id',
@ -50,6 +71,7 @@ class LocationsController extends Controller
])->withCount('assignedAssets as assigned_assets_count') ])->withCount('assignedAssets as assigned_assets_count')
->withCount('assets as assets_count') ->withCount('assets as assets_count')
->withCount('rtd_assets as rtd_assets_count') ->withCount('rtd_assets as rtd_assets_count')
->withCount('children as children_count')
->withCount('users as users_count'); ->withCount('users as users_count');
if ($request->filled('search')) { if ($request->filled('search')) {
@ -80,6 +102,10 @@ class LocationsController extends Controller
$locations->where('locations.country', '=', $request->input('country')); $locations->where('locations.country', '=', $request->input('country'));
} }
if ($request->filled('manager_id')) {
$locations->where('locations.manager_id', '=', $request->input('manager_id'));
}
// Make sure the offset and limit are actually integers and do not exceed system limits // Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $locations->count()) ? $locations->count() : app('api_offset_value'); $offset = ($request->input('offset') > $locations->count()) ? $locations->count() : app('api_offset_value');
$limit = app('api_limit_value'); $limit = app('api_limit_value');
@ -115,9 +141,8 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : JsonResponse
{ {
$this->authorize('create', Location::class); $this->authorize('create', Location::class);
$location = new Location; $location = new Location;
@ -137,9 +162,8 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : JsonResponse | array
{ {
$this->authorize('view', Location::class); $this->authorize('view', Location::class);
$location = Location::with('parent', 'manager', 'children') $location = Location::with('parent', 'manager', 'children')
@ -176,9 +200,8 @@ class LocationsController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @param int $id * @param int $id
* @return \Illuminate\Http\JsonResponse
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Location::class); $this->authorize('update', Location::class);
$location = Location::findOrFail($id); $location = Location::findOrFail($id);
@ -201,21 +224,36 @@ class LocationsController extends Controller
return response()->json(Helper::formatStandardApiResponse('error', null, $location->getErrors())); return response()->json(Helper::formatStandardApiResponse('error', null, $location->getErrors()));
} }
public function assets(Request $request, Location $location) : JsonResponse | array
{
$this->authorize('view', Asset::class);
$this->authorize('view', $location);
$assets = Asset::where('assigned_to', '=', $location->id)->where('assigned_type', '=', Location::class)->with('model', 'model.category', 'assetstatus', 'location', 'company', 'defaultLoc');
$assets = $assets->get();
return (new AssetsTransformer)->transformAssets($assets, $assets->count(), $request);
}
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Location::class); $this->authorize('delete', Location::class);
$location = Location::findOrFail($id); $location = Location::withCount('assignedAssets as assigned_assets_count')
->withCount('assets as assets_count')
->withCount('rtd_assets as rtd_assets_count')
->withCount('children as children_count')
->withCount('users as users_count')
->withCount('accessories as accessories_count')
->findOrFail($id);
if (! $location->isDeletable()) { if (! $location->isDeletable()) {
return response() return response()
->json(Helper::formatStandardApiResponse('error', null, trans('admin/companies/message.assoc_users'))); ->json(Helper::formatStandardApiResponse('error', null, trans('admin/locations/message.assoc_users')));
} }
$this->authorize('delete', $location); $this->authorize('delete', $location);
$location->delete(); $location->delete();
@ -251,7 +289,7 @@ class LocationsController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
// If a user is in the process of editing their profile, as determined by the referrer, // If a user is in the process of editing their profile, as determined by the referrer,
// then we check that they have permission to edit their own location. // then we check that they have permission to edit their own location.
@ -296,7 +334,6 @@ class LocationsController extends Controller
$paginated_results = new LengthAwarePaginator($locations_formatted->forPage($page, 500), $locations_formatted->count(), 500, $page, []); $paginated_results = new LengthAwarePaginator($locations_formatted->forPage($page, 500), $locations_formatted->count(), 500, $page, []);
//return [];
return (new SelectlistTransformer)->transformSelectlist($paginated_results); return (new SelectlistTransformer)->transformSelectlist($paginated_results);
} }
} }

View file

@ -6,10 +6,12 @@ use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Transformers\ManufacturersTransformer; use App\Http\Transformers\ManufacturersTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Models\Actionlog;
use App\Models\Manufacturer; use App\Models\Manufacturer;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Http\JsonResponse;
class ManufacturersController extends Controller class ManufacturersController extends Controller
{ {
@ -20,7 +22,7 @@ class ManufacturersController extends Controller
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', Manufacturer::class); $this->authorize('view', Manufacturer::class);
$allowed_columns = ['id', 'name', 'url', 'support_url', 'support_email', 'warranty_lookup_url', 'support_phone', 'created_at', 'updated_at', 'image', 'assets_count', 'consumables_count', 'components_count', 'licenses_count']; $allowed_columns = ['id', 'name', 'url', 'support_url', 'support_email', 'warranty_lookup_url', 'support_phone', 'created_at', 'updated_at', 'image', 'assets_count', 'consumables_count', 'components_count', 'licenses_count'];
@ -81,9 +83,8 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : JsonResponse
{ {
$this->authorize('create', Manufacturer::class); $this->authorize('create', Manufacturer::class);
$manufacturer = new Manufacturer; $manufacturer = new Manufacturer;
@ -103,9 +104,8 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : JsonResponse | array
{ {
$this->authorize('view', Manufacturer::class); $this->authorize('view', Manufacturer::class);
$manufacturer = Manufacturer::withCount('assets as assets_count')->withCount('licenses as licenses_count')->withCount('consumables as consumables_count')->withCount('accessories as accessories_count')->findOrFail($id); $manufacturer = Manufacturer::withCount('assets as assets_count')->withCount('licenses as licenses_count')->withCount('consumables as consumables_count')->withCount('accessories as accessories_count')->findOrFail($id);
@ -120,9 +120,8 @@ class ManufacturersController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Manufacturer::class); $this->authorize('update', Manufacturer::class);
$manufacturer = Manufacturer::findOrFail($id); $manufacturer = Manufacturer::findOrFail($id);
@ -142,9 +141,8 @@ class ManufacturersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Manufacturer::class); $this->authorize('delete', Manufacturer::class);
$manufacturer = Manufacturer::findOrFail($id); $manufacturer = Manufacturer::findOrFail($id);
@ -159,6 +157,43 @@ class ManufacturersController extends Controller
} }
/**
* Restore a given Manufacturer (mark as un-deleted)
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.3.4]
* @param int $id
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function restore($id) : JsonResponse
{
$this->authorize('delete', Manufacturer::class);
if ($manufacturer = Manufacturer::withTrashed()->find($id)) {
if ($manufacturer->deleted_at == '') {
return response()->json(Helper::formatStandardApiResponse('error', trans('general.not_deleted', ['item_type' => trans('general.manufacturer')])), 200);
}
if ($manufacturer->restore()) {
$logaction = new Actionlog();
$logaction->item_type = Manufacturer::class;
$logaction->item_id = $manufacturer->id;
$logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id();
$logaction->logaction('restore');
return response()->json(Helper::formatStandardApiResponse('success', trans('admin/manufacturers/message.restore.success')), 200);
}
// Check validation to make sure we're not restoring an item with the same unique attributes as a non-deleted one
return response()->json(Helper::formatStandardApiResponse('error', trans('general.could_not_restore', ['item_type' => trans('general.manufacturer'), 'error' => $manufacturer->getErrors()->first()])), 200);
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/manufacturers/message.does_not_exist')));
}
/** /**
* Gets a paginated collection for the select2 menus * Gets a paginated collection for the select2 menus
* *
@ -166,7 +201,7 @@ class ManufacturersController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$this->authorize('view.selectlists'); $this->authorize('view.selectlists');

View file

@ -7,6 +7,8 @@ use App\Http\Controllers\Controller;
use App\Http\Transformers\PredefinedKitsTransformer; use App\Http\Transformers\PredefinedKitsTransformer;
use App\Models\PredefinedKit; use App\Models\PredefinedKit;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Http\Transformers\SelectlistTransformer;
/** /**
* @author [D. Minaev.] [<dmitriy.minaev.v@gmail.com>] * @author [D. Minaev.] [<dmitriy.minaev.v@gmail.com>]
@ -18,7 +20,7 @@ class PredefinedKitsController extends Controller
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('view', PredefinedKit::class); $this->authorize('view', PredefinedKit::class);
$allowed_columns = ['id', 'name']; $allowed_columns = ['id', 'name'];
@ -47,9 +49,8 @@ class PredefinedKitsController extends Controller
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
$this->authorize('create', PredefinedKit::class); $this->authorize('create', PredefinedKit::class);
$kit = new PredefinedKit; $kit = new PredefinedKit;
@ -66,9 +67,8 @@ class PredefinedKitsController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', PredefinedKit::class); $this->authorize('view', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($id); $kit = PredefinedKit::findOrFail($id);
@ -81,9 +81,8 @@ class PredefinedKitsController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id kit id * @param int $id kit id
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($id); $kit = PredefinedKit::findOrFail($id);
@ -100,9 +99,8 @@ class PredefinedKitsController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', PredefinedKit::class); $this->authorize('delete', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($id); $kit = PredefinedKit::findOrFail($id);
@ -123,7 +121,7 @@ class PredefinedKitsController extends Controller
* *
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$kits = PredefinedKit::select([ $kits = PredefinedKit::select([
'id', 'id',
@ -145,7 +143,7 @@ class PredefinedKitsController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function indexLicenses($kit_id) public function indexLicenses($kit_id) : array
{ {
$this->authorize('view', PredefinedKit::class); $this->authorize('view', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -160,7 +158,7 @@ class PredefinedKitsController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function storeLicense(Request $request, $kit_id) public function storeLicense(Request $request, $kit_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
@ -186,9 +184,8 @@ class PredefinedKitsController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function updateLicense(Request $request, $kit_id, $license_id) public function updateLicense(Request $request, $kit_id, $license_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -205,9 +202,8 @@ class PredefinedKitsController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function detachLicense($kit_id, $license_id) public function detachLicense($kit_id, $license_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -221,9 +217,8 @@ class PredefinedKitsController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function indexModels($kit_id) public function indexModels($kit_id) : array
{ {
$this->authorize('view', PredefinedKit::class); $this->authorize('view', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -236,9 +231,8 @@ class PredefinedKitsController extends Controller
* Store the specified resource. * Store the specified resource.
* *
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function storeModel(Request $request, $kit_id) public function storeModel(Request $request, $kit_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
@ -252,7 +246,7 @@ class PredefinedKitsController extends Controller
$relation = $kit->models(); $relation = $kit->models();
if ($relation->find($model_id)) { if ($relation->find($model_id)) {
return response()->json(Helper::formatStandardApiResponse('error', null, ['model' => 'Model already attached to kit'])); return response()->json(Helper::formatStandardApiResponse('error', null, ['model' => trans('admin/kits/general.model_already_attached')]));
} }
$relation->attach($model_id, ['quantity' => $quantity]); $relation->attach($model_id, ['quantity' => $quantity]);
@ -264,9 +258,8 @@ class PredefinedKitsController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function updateModel(Request $request, $kit_id, $model_id) public function updateModel(Request $request, $kit_id, $model_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -283,9 +276,8 @@ class PredefinedKitsController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function detachModel($kit_id, $model_id) public function detachModel($kit_id, $model_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -299,9 +291,8 @@ class PredefinedKitsController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function indexConsumables($kit_id) public function indexConsumables($kit_id) : array
{ {
$this->authorize('view', PredefinedKit::class); $this->authorize('view', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -314,9 +305,8 @@ class PredefinedKitsController extends Controller
* Store the specified resource. * Store the specified resource.
* *
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function storeConsumable(Request $request, $kit_id) public function storeConsumable(Request $request, $kit_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
@ -342,9 +332,8 @@ class PredefinedKitsController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function updateConsumable(Request $request, $kit_id, $consumable_id) public function updateConsumable(Request $request, $kit_id, $consumable_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -361,9 +350,8 @@ class PredefinedKitsController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function detachConsumable($kit_id, $consumable_id) public function detachConsumable($kit_id, $consumable_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -377,9 +365,8 @@ class PredefinedKitsController extends Controller
* Display the specified resource. * Display the specified resource.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function indexAccessories($kit_id) public function indexAccessories($kit_id) : array
{ {
$this->authorize('view', PredefinedKit::class); $this->authorize('view', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -392,9 +379,8 @@ class PredefinedKitsController extends Controller
* Store the specified resource. * Store the specified resource.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function storeAccessory(Request $request, $kit_id) public function storeAccessory(Request $request, $kit_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
@ -420,9 +406,8 @@ class PredefinedKitsController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function updateAccessory(Request $request, $kit_id, $accessory_id) public function updateAccessory(Request $request, $kit_id, $accessory_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);
@ -439,9 +424,8 @@ class PredefinedKitsController extends Controller
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $kit_id * @param int $kit_id
* @return \Illuminate\Http\Response
*/ */
public function detachAccessory($kit_id, $accessory_id) public function detachAccessory($kit_id, $accessory_id) : JsonResponse
{ {
$this->authorize('update', PredefinedKit::class); $this->authorize('update', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($kit_id); $kit = PredefinedKit::findOrFail($kit_id);

View file

@ -6,13 +6,13 @@ use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\CheckoutRequest; use App\Models\CheckoutRequest;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Laravel\Passport\TokenRepository; use Laravel\Passport\TokenRepository;
use Illuminate\Contracts\Validation\Factory as ValidationFactory; use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use App\Models\CustomField; use App\Models\CustomField;
use DB; use Illuminate\Support\Facades\DB;
use Illuminate\Http\JsonResponse;
class ProfileController extends Controller class ProfileController extends Controller
{ {
@ -42,12 +42,10 @@ class ProfileController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.3.0] * @since [v4.3.0]
*
* @return array
*/ */
public function requestedAssets() public function requestedAssets() : array
{ {
$checkoutRequests = CheckoutRequest::where('user_id', '=', Auth::user()->id)->get(); $checkoutRequests = CheckoutRequest::where('user_id', '=', auth()->id())->get();
$results = array(); $results = array();
$show_field = array(); $show_field = array();
@ -95,10 +93,9 @@ class ProfileController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.0.5] * @since [v6.0.5]
*
* @return \Illuminate\Http\Response
*/ */
public function createApiToken(Request $request) { public function createApiToken(Request $request) : JsonResponse
{
if (!Gate::allows('self.api')) { if (!Gate::allows('self.api')) {
abort(403); abort(403);
@ -106,14 +103,14 @@ class ProfileController extends Controller
$accessTokenName = $request->input('name', 'Auth Token'); $accessTokenName = $request->input('name', 'Auth Token');
if ($accessToken = Auth::user()->createToken($accessTokenName)->accessToken) { if ($accessToken = auth()->user()->createToken($accessTokenName)->accessToken) {
// Get the ID so we can return that with the payload // Get the ID so we can return that with the payload
$token = DB::table('oauth_access_tokens')->where('user_id', '=', Auth::user()->id)->where('name','=',$accessTokenName)->orderBy('created_at', 'desc')->first(); $token = DB::table('oauth_access_tokens')->where('user_id', '=', auth()->id())->where('name','=',$accessTokenName)->orderBy('created_at', 'desc')->first();
$accessTokenData['id'] = $token->id; $accessTokenData['id'] = $token->id;
$accessTokenData['token'] = $accessToken; $accessTokenData['token'] = $accessToken;
$accessTokenData['name'] = $accessTokenName; $accessTokenData['name'] = $accessTokenName;
return response()->json(Helper::formatStandardApiResponse('success', $accessTokenData, 'Personal access token '.$accessTokenName.' created successfully')); return response()->json(Helper::formatStandardApiResponse('success', $accessTokenData, trans('account/general.personal_api_keys_success', ['key' => $accessTokenName])));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, 'Token could not be created.')); return response()->json(Helper::formatStandardApiResponse('error', null, 'Token could not be created.'));
@ -125,17 +122,16 @@ class ProfileController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.0.5] * @since [v6.0.5]
*
* @return \Illuminate\Http\Response
*/ */
public function deleteApiToken($tokenId) { public function deleteApiToken($tokenId) : Response
{
if (!Gate::allows('self.api')) { if (!Gate::allows('self.api')) {
abort(403); abort(403);
} }
$token = $this->tokenRepository->findForUser( $token = $this->tokenRepository->findForUser(
$tokenId, Auth::user()->getAuthIdentifier() $tokenId, auth()->user()->getAuthIdentifier()
); );
if (is_null($token)) { if (is_null($token)) {
@ -154,16 +150,15 @@ class ProfileController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.0.5] * @since [v6.0.5]
*
* @return \Illuminate\Http\Response
*/ */
public function showApiTokens(Request $request) { public function showApiTokens() : JsonResponse
{
if (!Gate::allows('self.api')) { if (!Gate::allows('self.api')) {
abort(403); abort(403);
} }
$tokens = $this->tokenRepository->forUser(Auth::user()->getAuthIdentifier()); $tokens = $this->tokenRepository->forUser(auth()->user()->getAuthIdentifier());
$token_values = $tokens->load('client')->filter(function ($token) { $token_values = $tokens->load('client')->filter(function ($token) {
return $token->client->personal_access_client && ! $token->revoked; return $token->client->personal_access_client && ! $token->revoked;
})->values(); })->values();

View file

@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Http\Transformers\ActionlogsTransformer; use App\Http\Transformers\ActionlogsTransformer;
use App\Models\Actionlog; use App\Models\Actionlog;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class ReportsController extends Controller class ReportsController extends Controller
{ {
@ -14,9 +15,8 @@ class ReportsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return View
*/ */
public function index(Request $request) public function index(Request $request) : JsonResponse | array
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
@ -32,14 +32,34 @@ class ReportsController extends Controller
} }
if (($request->filled('item_type')) && ($request->filled('item_id'))) { if (($request->filled('item_type')) && ($request->filled('item_id'))) {
$actionlogs = $actionlogs->where('item_id', '=', $request->input('item_id')) $actionlogs = $actionlogs->where(function($query) use ($request)
->where('item_type', '=', 'App\\Models\\'.ucwords($request->input('item_type'))); {
$query->where('item_id', '=', $request->input('item_id'))
->where('item_type', '=', 'App\\Models\\'.ucwords($request->input('item_type')))
->orWhere(function($query) use ($request)
{
$query->where('target_id', '=', $request->input('item_id'))
->where('target_type', '=', 'App\\Models\\'.ucwords($request->input('item_type')));
});
});
} }
if ($request->filled('action_type')) { if ($request->filled('action_type')) {
$actionlogs = $actionlogs->where('action_type', '=', $request->input('action_type'))->orderBy('created_at', 'desc'); $actionlogs = $actionlogs->where('action_type', '=', $request->input('action_type'))->orderBy('created_at', 'desc');
} }
if ($request->filled('user_id')) {
$actionlogs = $actionlogs->where('user_id', '=', $request->input('user_id'));
}
if ($request->filled('action_source')) {
$actionlogs = $actionlogs->where('action_source', '=', $request->input('action_source'))->orderBy('created_at', 'desc');
}
if ($request->filled('remote_ip')) {
$actionlogs = $actionlogs->where('remote_ip', '=', $request->input('remote_ip'))->orderBy('created_at', 'desc');
}
if ($request->filled('uploads')) { if ($request->filled('uploads')) {
$actionlogs = $actionlogs->whereNotNull('filename')->orderBy('created_at', 'desc'); $actionlogs = $actionlogs->whereNotNull('filename')->orderBy('created_at', 'desc');
} }
@ -52,18 +72,30 @@ class ReportsController extends Controller
'accept_signature', 'accept_signature',
'action_type', 'action_type',
'note', 'note',
'remote_ip',
'user_agent',
'action_source',
]; ];
$total = $actionlogs->count();
// Make sure the offset and limit are actually integers and do not exceed system limits // Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $actionlogs->count()) ? $actionlogs->count() : app('api_offset_value'); $offset = ($request->input('offset') > $total) ? $total : app('api_offset_value');
$limit = app('api_limit_value'); $limit = app('api_limit_value');
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
$order = ($request->input('order') == 'asc') ? 'asc' : 'desc'; $order = ($request->input('order') == 'asc') ? 'asc' : 'desc';
$total = $actionlogs->count();
$actionlogs = $actionlogs->orderBy($sort, $order)->skip($offset)->take($limit)->get(); switch ($request->input('sort')) {
case 'admin':
$actionlogs->OrderAdmin($order);
break;
default:
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
$actionlogs = $actionlogs->orderBy($sort, $order);
break;
}
$actionlogs = $actionlogs->skip($offset)->take($limit)->get();
return response()->json((new ActionlogsTransformer)->transformActionlogs($actionlogs, $total), 200, ['Content-Type' => 'application/json;charset=utf8'], JSON_UNESCAPED_UNICODE); return response()->json((new ActionlogsTransformer)->transformActionlogs($actionlogs, $total), 200, ['Content-Type' => 'application/json;charset=utf8'], JSON_UNESCAPED_UNICODE);
} }

View file

@ -9,42 +9,38 @@ use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Ldap; use App\Models\Ldap;
use App\Models\Setting; use App\Models\Setting;
use Mail;
use App\Notifications\SlackTest;
use App\Notifications\MailTest; use App\Notifications\MailTest;
use GuzzleHttp\Client;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use App\Http\Requests\SlackSettingsRequest;
use App\Http\Transformers\LoginAttemptsTransformer; use App\Http\Transformers\LoginAttemptsTransformer;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class SettingsController extends Controller class SettingsController extends Controller
{ {
public function ldaptest() public function ldaptest() : JsonResponse
{ {
$settings = Setting::getSettings(); $settings = Setting::getSettings();
if ($settings->ldap_enabled!='1') { if ($settings->ldap_enabled!='1') {
\Log::debug('LDAP is not enabled cannot test.'); Log::debug('LDAP is not enabled cannot test.');
return response()->json(['message' => 'LDAP is not enabled, cannot test.'], 400); return response()->json(['message' => 'LDAP is not enabled, cannot test.'], 400);
} }
\Log::debug('Preparing to test LDAP connection'); Log::debug('Preparing to test LDAP connection');
$message = []; //where we collect together test messages $message = []; //where we collect together test messages
try { try {
$connection = Ldap::connectToLdap(); $connection = Ldap::connectToLdap();
try { try {
$message['bind'] = ['message' => 'Successfully bound to LDAP server.']; $message['bind'] = ['message' => 'Successfully bound to LDAP server.'];
\Log::debug('attempting to bind to LDAP for LDAP test'); Log::debug('attempting to bind to LDAP for LDAP test');
Ldap::bindAdminToLdap($connection); Ldap::bindAdminToLdap($connection);
$message['login'] = [ $message['login'] = [
'message' => 'Successfully connected to LDAP server.', 'message' => 'Successfully connected to LDAP server.',
@ -75,24 +71,24 @@ class SettingsController extends Controller
return response()->json($message, 200); return response()->json($message, 200);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('Bind failed'); Log::debug('Bind failed');
\Log::debug("Exception was: ".$e->getMessage()); Log::debug("Exception was: ".$e->getMessage());
return response()->json(['message' => $e->getMessage()], 400); return response()->json(['message' => $e->getMessage()], 400);
//return response()->json(['message' => $e->getMessage()], 500); //return response()->json(['message' => $e->getMessage()], 500);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('Connection failed but we cannot debug it any further on our end.'); Log::debug('Connection failed but we cannot debug it any further on our end.');
return response()->json(['message' => $e->getMessage()], 500); return response()->json(['message' => $e->getMessage()], 500);
} }
} }
public function ldaptestlogin(Request $request) public function ldaptestlogin(Request $request) : JsonResponse
{ {
if (Setting::getSettings()->ldap_enabled != '1') { if (Setting::getSettings()->ldap_enabled != '1') {
\Log::debug('LDAP is not enabled. Cannot test.'); Log::debug('LDAP is not enabled. Cannot test.');
return response()->json(['message' => 'LDAP is not enabled, cannot test.'], 400); return response()->json(['message' => 'LDAP is not enabled, cannot test.'], 400);
} }
@ -104,39 +100,39 @@ class SettingsController extends Controller
$validator = Validator::make($request->all(), $rules); $validator = Validator::make($request->all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
\Log::debug('LDAP Validation test failed.'); Log::debug('LDAP Validation test failed.');
$validation_errors = implode(' ',$validator->errors()->all()); $validation_errors = implode(' ',$validator->errors()->all());
return response()->json(['message' => $validator->errors()->all()], 400); return response()->json(['message' => $validator->errors()->all()], 400);
} }
\Log::debug('Preparing to test LDAP login'); Log::debug('Preparing to test LDAP login');
try { try {
$connection = Ldap::connectToLdap(); $connection = Ldap::connectToLdap();
try { try {
Ldap::bindAdminToLdap($connection); Ldap::bindAdminToLdap($connection);
\Log::debug('Attempting to bind to LDAP for LDAP test'); Log::debug('Attempting to bind to LDAP for LDAP test');
try { try {
$ldap_user = Ldap::findAndBindUserLdap($request->input('ldaptest_user'), $request->input('ldaptest_password')); $ldap_user = Ldap::findAndBindUserLdap($request->input('ldaptest_user'), $request->input('ldaptest_password'));
if ($ldap_user) { if ($ldap_user) {
\Log::debug('It worked! '. $request->input('ldaptest_user').' successfully binded to LDAP.'); Log::debug('It worked! '. $request->input('ldaptest_user').' successfully binded to LDAP.');
return response()->json(['message' => 'It worked! '. $request->input('ldaptest_user').' successfully binded to LDAP.'], 200); return response()->json(['message' => 'It worked! '. $request->input('ldaptest_user').' successfully binded to LDAP.'], 200);
} }
return response()->json(['message' => 'Login Failed. '. $request->input('ldaptest_user').' did not successfully bind to LDAP.'], 400); return response()->json(['message' => 'Login Failed. '. $request->input('ldaptest_user').' did not successfully bind to LDAP.'], 400);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('LDAP login failed'); Log::debug('LDAP login failed');
return response()->json(['message' => $e->getMessage()], 400); return response()->json(['message' => $e->getMessage()], 400);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('Bind failed'); Log::debug('Bind failed');
return response()->json(['message' => $e->getMessage()], 400); return response()->json(['message' => $e->getMessage()], 400);
//return response()->json(['message' => $e->getMessage()], 500); //return response()->json(['message' => $e->getMessage()], 500);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('Connection failed'); Log::debug('Connection failed');
return response()->json(['message' => $e->getMessage()], 500); return response()->json(['message' => $e->getMessage()], 500);
} }
@ -148,9 +144,8 @@ class SettingsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @return Redirect
*/ */
public function ajaxTestEmail() public function ajaxTestEmail() : JsonResponse
{ {
if (!config('app.lock_passwords')) { if (!config('app.lock_passwords')) {
try { try {
@ -170,9 +165,8 @@ class SettingsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v5.0.0] * @since [v5.0.0]
* @return Response
*/ */
public function purgeBarcodes() public function purgeBarcodes() : JsonResponse
{ {
$file_count = 0; $file_count = 0;
$files = Storage::disk('public')->files('barcodes'); $files = Storage::disk('public')->files('barcodes');
@ -181,19 +175,19 @@ class SettingsController extends Controller
$file_parts = explode('.', $file); $file_parts = explode('.', $file);
$extension = end($file_parts); $extension = end($file_parts);
\Log::debug($extension); Log::debug($extension);
// Only generated barcodes would have a .png file extension // Only generated barcodes would have a .png file extension
if ($extension == 'png') { if ($extension == 'png') {
\Log::debug('Deleting: '.$file); Log::debug('Deleting: '.$file);
try { try {
Storage::disk('public')->delete($file); Storage::disk('public')->delete($file);
\Log::debug('Deleting: '.$file); Log::debug('Deleting: '.$file);
$file_count++; $file_count++;
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
} }
} }
} }
@ -211,9 +205,8 @@ class SettingsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v5.0.0] * @since [v5.0.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return array
*/ */
public function showLoginAttempts(Request $request) public function showLoginAttempts(Request $request) : array
{ {
$allowed_columns = ['id', 'username', 'remote_ip', 'user_agent', 'successful', 'created_at']; $allowed_columns = ['id', 'username', 'remote_ip', 'user_agent', 'successful', 'created_at'];
@ -229,7 +222,13 @@ class SettingsController extends Controller
} }
public function listBackups() { /**
* Lists backup files
*
* @author [A. Gianotto]
*/
public function listBackups() : array
{
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$path = 'app/backups'; $path = 'app/backups';
$backup_files = Storage::files($path); $backup_files = Storage::files($path);
@ -249,12 +248,12 @@ class SettingsController extends Controller
'filesize' => Setting::fileSizeConvert(Storage::size($backup_files[$f])), 'filesize' => Setting::fileSizeConvert(Storage::size($backup_files[$f])),
'modified_value' => $file_timestamp, 'modified_value' => $file_timestamp,
'modified_display' => date($settings->date_display_format.' '.$settings->time_display_format, $file_timestamp), 'modified_display' => date($settings->date_display_format.' '.$settings->time_display_format, $file_timestamp),
'backup_url' => config('app.url').'/settings/backups/download/'.basename($backup_files[$f]),
]; ];
$count++; $count++;
} }
} }
} }
@ -264,15 +263,56 @@ class SettingsController extends Controller
} }
public function downloadBackup($file) { /**
* Downloads a backup file.
* We use response()->download() here instead of Storage::download() because Storage::download()
* exhausts memory on larger files.
*
* @author [A. Gianotto]
*/
public function downloadBackup($file) : JsonResponse | BinaryFileResponse
{
$path = 'app/backups'; $path = storage_path('app/backups');
if (Storage::exists($path.'/'.$file)) {
if (Storage::exists('app/backups/'.$file)) {
$headers = ['ContentType' => 'application/zip']; $headers = ['ContentType' => 'application/zip'];
return Storage::download($path.'/'.$file, $file, $headers); return response()->download($path.'/'.$file, $file, $headers);
} else { } else {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found'))); return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')), 404);
} }
} }
/**
* Determines and downloads the latest backup
*
* @author [A. Gianotto]
* @since [v6.3.1]
*/
public function downloadLatestBackup() : JsonResponse | BinaryFileResponse
{
$fileData = collect();
foreach (Storage::files('app/backups') as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) == 'zip') {
$fileData->push([
'file' => $file,
'date' => Storage::lastModified($file)
]);
}
}
$newest = $fileData->sortByDesc('date')->first();
if (Storage::exists($newest['file'])) {
$headers = ['ContentType' => 'application/zip'];
return response()->download(storage_path($newest['file']), basename($newest['file']), $headers);
} else {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')), 404);
}
}
} }

View file

@ -8,10 +8,11 @@ use App\Http\Transformers\AssetsTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Http\Transformers\StatuslabelsTransformer; use App\Http\Transformers\StatuslabelsTransformer;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Setting;
use App\Models\Statuslabel; use App\Models\Statuslabel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Transformers\PieChartTransformer; use App\Http\Transformers\PieChartTransformer;
use Illuminate\Support\Arr; use Illuminate\Http\JsonResponse;
class StatuslabelsController extends Controller class StatuslabelsController extends Controller
{ {
@ -20,9 +21,8 @@ class StatuslabelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request) : array
{ {
$this->authorize('view', Statuslabel::class); $this->authorize('view', Statuslabel::class);
$allowed_columns = ['id', 'name', 'created_at', 'assets_count', 'color', 'notes', 'default_label']; $allowed_columns = ['id', 'name', 'created_at', 'assets_count', 'color', 'notes', 'default_label'];
@ -72,9 +72,8 @@ class StatuslabelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(Request $request) public function store(Request $request) : JsonResponse
{ {
$this->authorize('create', Statuslabel::class); $this->authorize('create', Statuslabel::class);
$request->except('deployable', 'pending', 'archived'); $request->except('deployable', 'pending', 'archived');
@ -108,9 +107,8 @@ class StatuslabelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', Statuslabel::class); $this->authorize('view', Statuslabel::class);
$statuslabel = Statuslabel::findOrFail($id); $statuslabel = Statuslabel::findOrFail($id);
@ -126,9 +124,8 @@ class StatuslabelsController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(Request $request, $id) public function update(Request $request, $id) : JsonResponse
{ {
$this->authorize('update', Statuslabel::class); $this->authorize('update', Statuslabel::class);
$statuslabel = Statuslabel::findOrFail($id); $statuslabel = Statuslabel::findOrFail($id);
@ -163,9 +160,8 @@ class StatuslabelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Statuslabel::class); $this->authorize('delete', Statuslabel::class);
$statuslabel = Statuslabel::findOrFail($id); $statuslabel = Statuslabel::findOrFail($id);
@ -188,13 +184,18 @@ class StatuslabelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @return array
*/ */
public function getAssetCountByStatuslabel() public function getAssetCountByStatuslabel() : array
{ {
$this->authorize('view', Statuslabel::class); $this->authorize('view', Statuslabel::class);
if (Setting::getSettings()->show_archived_in_list == 0 ) {
$statuslabels = Statuslabel::withCount('assets')->where('archived','0')->get();
} else {
$statuslabels = Statuslabel::withCount('assets')->get(); $statuslabels = Statuslabel::withCount('assets')->get();
$total = Array(); }
$total = [];
foreach ($statuslabels as $statuslabel) { foreach ($statuslabels as $statuslabel) {
@ -215,9 +216,8 @@ class StatuslabelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.0.11] * @since [v6.0.11]
* @return array
*/ */
public function getAssetCountByMetaStatus() public function getAssetCountByMetaStatus() : array
{ {
$this->authorize('view', Statuslabel::class); $this->authorize('view', Statuslabel::class);
@ -245,9 +245,8 @@ class StatuslabelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function assets(Request $request, $id) public function assets(Request $request, $id) : array
{ {
$this->authorize('view', Statuslabel::class); $this->authorize('view', Statuslabel::class);
$this->authorize('index', Asset::class); $this->authorize('index', Asset::class);
@ -281,9 +280,8 @@ class StatuslabelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @return bool
*/ */
public function checkIfDeployable($id) public function checkIfDeployable($id) : string
{ {
$statuslabel = Statuslabel::findOrFail($id); $statuslabel = Statuslabel::findOrFail($id);
if ($statuslabel->getStatuslabelType() == 'deployable') { if ($statuslabel->getStatuslabelType() == 'deployable') {
@ -300,7 +298,7 @@ class StatuslabelsController extends Controller
* @since [v6.1.1] * @since [v6.1.1]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$this->authorize('view.selectlists'); $this->authorize('view.selectlists');

View file

@ -10,6 +10,7 @@ use App\Models\Supplier;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Http\JsonResponse;
class SuppliersController extends Controller class SuppliersController extends Controller
{ {
@ -20,7 +21,7 @@ class SuppliersController extends Controller
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index(Request $request) public function index(Request $request): array
{ {
$this->authorize('view', Supplier::class); $this->authorize('view', Supplier::class);
$allowed_columns = [' $allowed_columns = ['
@ -114,9 +115,8 @@ class SuppliersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @return \Illuminate\Http\Response
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : JsonResponse
{ {
$this->authorize('create', Supplier::class); $this->authorize('create', Supplier::class);
$supplier = new Supplier; $supplier = new Supplier;
@ -136,9 +136,8 @@ class SuppliersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : array
{ {
$this->authorize('view', Supplier::class); $this->authorize('view', Supplier::class);
$supplier = Supplier::findOrFail($id); $supplier = Supplier::findOrFail($id);
@ -154,9 +153,8 @@ class SuppliersController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \App\Http\Requests\ImageUploadRequest $request * @param \App\Http\Requests\ImageUploadRequest $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(ImageUploadRequest $request, $id) public function update(ImageUploadRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', Supplier::class); $this->authorize('update', Supplier::class);
$supplier = Supplier::findOrFail($id); $supplier = Supplier::findOrFail($id);
@ -176,9 +174,8 @@ class SuppliersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy($id) : JsonResponse
{ {
$this->authorize('delete', Supplier::class); $this->authorize('delete', Supplier::class);
$supplier = Supplier::with('asset_maintenances', 'assets', 'licenses')->withCount('asset_maintenances as asset_maintenances_count', 'assets as assets_count', 'licenses as licenses_count')->findOrFail($id); $supplier = Supplier::with('asset_maintenances', 'assets', 'licenses')->withCount('asset_maintenances as asset_maintenances_count', 'assets as assets_count', 'licenses as licenses_count')->findOrFail($id);
@ -209,7 +206,7 @@ class SuppliersController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$this->authorize('view.selectlists'); $this->authorize('view.selectlists');

View file

@ -11,16 +11,20 @@ use App\Http\Transformers\ConsumablesTransformer;
use App\Http\Transformers\LicensesTransformer; use App\Http\Transformers\LicensesTransformer;
use App\Http\Transformers\SelectlistTransformer; use App\Http\Transformers\SelectlistTransformer;
use App\Http\Transformers\UsersTransformer; use App\Http\Transformers\UsersTransformer;
use App\Models\Actionlog;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Company; use App\Models\Accessory;
use App\Models\Consumable;
use App\Models\License; use App\Models\License;
use App\Models\User; use App\Models\User;
use App\Notifications\CurrentInventory; use App\Notifications\CurrentInventory;
use Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Log;
use App\Http\Requests\DeleteUserRequest;
use Illuminate\Http\JsonResponse;
class UsersController extends Controller class UsersController extends Controller
{ {
@ -30,9 +34,9 @@ class UsersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* *
* @return \Illuminate\Http\Response * @return array
*/ */
public function index(Request $request) public function index(Request $request) : array
{ {
$this->authorize('view', User::class); $this->authorize('view', User::class);
@ -72,11 +76,16 @@ class UsersController extends Controller
'users.end_date', 'users.end_date',
'users.vip', 'users.vip',
'users.autoassign_licenses', 'users.autoassign_licenses',
'users.website',
])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables', 'createdBy',) ])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables', 'createdBy', 'managesUsers', 'managedLocations')
->withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count'); ->withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'managesUsers as manages_users_count', 'managedLocations as manages_locations_count');
if ($request->filled('search') != '') {
$users = $users->TextSearch($request->input('search'));
}
if ($request->filled('activated')) { if ($request->filled('activated')) {
$users = $users->where('users.activated', '=', $request->input('activated')); $users = $users->where('users.activated', '=', $request->input('activated'));
} }
@ -121,6 +130,10 @@ class UsersController extends Controller
$users = $users->where('users.country', '=', $request->input('country')); $users = $users->where('users.country', '=', $request->input('country'));
} }
if ($request->filled('website')) {
$users = $users->where('users.website', '=', $request->input('website'));
}
if ($request->filled('zip')) { if ($request->filled('zip')) {
$users = $users->where('users.zip', '=', $request->input('zip')); $users = $users->where('users.zip', '=', $request->input('zip'));
} }
@ -181,21 +194,27 @@ class UsersController extends Controller
$users->has('accessories', '=', $request->input('accessories_count')); $users->has('accessories', '=', $request->input('accessories_count'));
} }
if ($request->filled('manages_users_count')) {
$users->has('manages_users_count', '=', $request->input('manages_users_count'));
}
if ($request->filled('manages_locations_count')) {
$users->has('manages_locations_count', '=', $request->input('manages_locations_count'));
}
if ($request->filled('autoassign_licenses')) { if ($request->filled('autoassign_licenses')) {
$users->where('autoassign_licenses', '=', $request->input('autoassign_licenses')); $users->where('autoassign_licenses', '=', $request->input('autoassign_licenses'));
} }
if ($request->filled('search')) {
$users = $users->TextSearch($request->input('search')); if (($request->filled('deleted')) && ($request->input('deleted') == 'true')) {
$users = $users->onlyTrashed();
} elseif (($request->filled('all')) && ($request->input('all') == 'true')) {
$users = $users->withTrashed();
} }
$order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $order = $request->input('order') === 'asc' ? 'asc' : 'desc';
// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $users->count()) ? $users->count() : app('api_offset_value');
$limit = app('api_limit_value');
switch ($request->input('sort')) { switch ($request->input('sort')) {
case 'manager': case 'manager':
$users = $users->OrderManager($order); $users = $users->OrderManager($order);
@ -229,10 +248,6 @@ class UsersController extends Controller
'jobtitle', 'jobtitle',
'username', 'username',
'employee_num', 'employee_num',
'assets',
'accessories',
'consumables',
'licenses',
'groups', 'groups',
'activated', 'activated',
'created_at', 'created_at',
@ -243,6 +258,8 @@ class UsersController extends Controller
'licenses_count', 'licenses_count',
'consumables_count', 'consumables_count',
'accessories_count', 'accessories_count',
'manages_users_count',
'manages_locations_count',
'phone', 'phone',
'address', 'address',
'city', 'city',
@ -258,20 +275,19 @@ class UsersController extends Controller
'start_date', 'start_date',
'end_date', 'end_date',
'autoassign_licenses', 'autoassign_licenses',
'website',
]; ];
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'first_name';
$users = $users->orderBy($sort, $order); $users = $users->orderBy($sort, $order);
break; break;
} }
if (($request->filled('deleted')) && ($request->input('deleted') == 'true')) {
$users = $users->onlyTrashed();
} elseif (($request->filled('all')) && ($request->input('all') == 'true')) {
$users = $users->withTrashed();
}
$users = Company::scopeCompanyables($users);
// Make sure the offset and limit are actually integers and do not exceed system limits
$offset = ($request->input('offset') > $users->count()) ? $users->count() : app('api_offset_value');
$limit = app('api_limit_value');
$total = $users->count(); $total = $users->count();
$users = $users->skip($offset)->take($limit)->get(); $users = $users->skip($offset)->take($limit)->get();
@ -286,7 +302,7 @@ class UsersController extends Controller
* @since [v4.0.16] * @since [v4.0.16]
* @see \App\Http\Transformers\SelectlistTransformer * @see \App\Http\Transformers\SelectlistTransformer
*/ */
public function selectlist(Request $request) public function selectlist(Request $request) : array
{ {
$users = User::select( $users = User::select(
[ [
@ -301,8 +317,6 @@ class UsersController extends Controller
] ]
)->where('show_in_list', '=', '1'); )->where('show_in_list', '=', '1');
$users = Company::scopeCompanyables($users);
if ($request->filled('search')) { if ($request->filled('search')) {
$users = $users->where(function ($query) use ($request) { $users = $users->where(function ($query) use ($request) {
$query->SimpleNameSearch($request->get('search')) $query->SimpleNameSearch($request->get('search'))
@ -344,20 +358,20 @@ class UsersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function store(SaveUserRequest $request) public function store(SaveUserRequest $request) : JsonResponse
{ {
$this->authorize('create', User::class); $this->authorize('create', User::class);
$user = new User; $user = new User;
$user->fill($request->all()); $user->fill($request->all());
$user->created_by = auth()->id();
if ($request->has('permissions')) { if ($request->has('permissions')) {
$permissions_array = $request->input('permissions'); $permissions_array = $request->input('permissions');
// Strip out the superuser permission if the API user isn't a superadmin // Strip out the superuser permission if the API user isn't a superadmin
if (! Auth::user()->isSuperUser()) { if (! auth()->user()->isSuperUser()) {
unset($permissions_array['superuser']); unset($permissions_array['superuser']);
} }
$user->permissions = $permissions_array; $user->permissions = $permissions_array;
@ -390,16 +404,20 @@ class UsersController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function show($id) public function show($id) : JsonResponse | array
{ {
$this->authorize('view', User::class); $this->authorize('view', User::class);
$user = User::withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count')->findOrFail($id);
if ($user = User::withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'managesUsers as manages_users_count', 'managedLocations as manages_locations_count')->find($id)) {
$this->authorize('view', $user);
return (new UsersTransformer)->transformUser($user); return (new UsersTransformer)->transformUser($user);
} }
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))));
}
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.
@ -408,19 +426,19 @@ class UsersController extends Controller
* @since [v4.0] * @since [v4.0]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function update(SaveUserRequest $request, $id) public function update(SaveUserRequest $request, $id) : JsonResponse
{ {
$this->authorize('update', User::class); $this->authorize('update', User::class);
$user = User::findOrFail($id); if ($user = User::find($id)) {
$this->authorize('update', $user);
/** /**
* This is a janky hack to prevent people from changing admin demo user data on the public demo. * This is a janky hack to prevent people from changing admin demo user data on the public demo.
*
* The $ids 1 and 2 are special since they are seeded as superadmins in the demo seeder. * The $ids 1 and 2 are special since they are seeded as superadmins in the demo seeder.
*
* Thanks, jerks. You are why we can't have nice things. - snipe * Thanks, jerks. You are why we can't have nice things. - snipe
* *
*/ */
@ -447,15 +465,15 @@ class UsersController extends Controller
if ($request->has('permissions')) { if ($request->has('permissions')) {
$permissions_array = $request->input('permissions'); $permissions_array = $request->input('permissions');
// Strip out the superuser permission if the API user isn't a superadmin // Strip out the individual superuser permission if the API user isn't a superadmin
if (! Auth::user()->isSuperUser()) { if (!auth()->user()->isSuperUser()) {
unset($permissions_array['superuser']); unset($permissions_array['superuser']);
} }
$user->permissions = $permissions_array; $user->permissions = $permissions_array;
} }
// Update the location of any assets checked out to this user // Update the location of any assets checked out to this user
Asset::where('assigned_type', User::class) Asset::where('assigned_type', User::class)
->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]); ->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]);
@ -465,27 +483,22 @@ class UsersController extends Controller
if ($user->save()) { if ($user->save()) {
// Sync group memberships: // Check if the request has groups passed and has a value, AND that the user us a superuser
// This was changed in Snipe-IT v4.6.x to 4.7, since we upgraded to Laravel 5.5 if (($request->has('groups')) && (auth()->user()->isSuperUser())) {
// which changes the behavior of has vs filled.
// The $request->has method will now return true even if the input value is an empty string or null.
// A new $request->filled method has was added that provides the previous behavior of the has method.
// Check if the request has groups passed and has a value $validator = Validator::make($request->only('groups'), [
if ($request->filled('groups')) {
$validator = Validator::make($request->all(), [
'groups.*' => 'integer|exists:permission_groups,id', 'groups.*' => 'integer|exists:permission_groups,id',
]); ]);
if ($validator->fails()){ if ($validator->fails()) {
return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors())); return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
}
$user->groups()->sync($request->input('groups'));
// The groups field has been passed but it is null, so we should blank it out
} elseif ($request->has('groups')) {
$user->groups()->sync([]);
} }
// Sync the groups since the user is a superuser and the groups pass validation
$user->groups()->sync($request->input('groups'));
}
return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.update'))); return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.update')));
} }
@ -493,44 +506,33 @@ class UsersController extends Controller
return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors())); return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors()));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))));
}
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.0] * @since [v4.0]
* @param int $id * @param int $id
* @return \Illuminate\Http\Response
*/ */
public function destroy($id) public function destroy(DeleteUserRequest $request, $id) : JsonResponse
{ {
$this->authorize('delete', User::class); $this->authorize('delete', User::class);
$user = User::findOrFail($id);
if ($user = User::withTrashed()->find($id)) {
$this->authorize('delete', $user); $this->authorize('delete', $user);
if (($user->assets) && ($user->assets->count() > 0)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.error.delete_has_assets')));
}
if (($user->licenses) && ($user->licenses->count() > 0)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'This user still has '.$user->licenses->count().' license(s) associated with them and cannot be deleted.'));
}
if (($user->accessories) && ($user->accessories->count() > 0)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'This user still has '.$user->accessories->count().' accessories associated with them.'));
}
if (($user->managedLocations()) && ($user->managedLocations()->count() > 0)) {
return response()->json(Helper::formatStandardApiResponse('error', null, 'This user still has '.$user->managedLocations()->count().' locations that they manage.'));
}
if ($user->delete()) { if ($user->delete()) {
// Remove the user's avatar if they have one // Remove the user's avatar if they have one
if (Storage::disk('public')->exists('avatars/'.$user->avatar)) { if (Storage::disk('public')->exists('avatars/' . $user->avatar)) {
try { try {
Storage::disk('public')->delete('avatars/'.$user->avatar); Storage::disk('public')->delete('avatars/' . $user->avatar);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug($e); Log::debug($e);
} }
} }
@ -538,6 +540,11 @@ class UsersController extends Controller
} }
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.error.delete'))); return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.error.delete')));
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found')));
} }
/** /**
@ -546,17 +553,43 @@ class UsersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @param $userId * @param $userId
* @return string JSON
*/ */
public function assets(Request $request, $id) public function assets(Request $request, $id) : JsonResponse | array
{ {
$this->authorize('view', User::class); $this->authorize('view', User::class);
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
$assets = Asset::where('assigned_to', '=', $id)->where('assigned_type', '=', User::class)->with('model')->get();
if ($user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($id)) {
$this->authorize('view', $user);
$assets = Asset::where('assigned_to', '=', $id)->where('assigned_type', '=', User::class)->with('model');
// Filter on category ID
if ($request->filled('category_id')) {
$assets = $assets->InCategory($request->input('category_id'));
}
// Filter on model ID
if ($request->filled('model_id')) {
$model_ids = $request->input('model_id');
if (!is_array($model_ids)) {
$model_ids = array($model_ids);
}
$assets = $assets->InModelList($model_ids);
}
$assets = $assets->get();
return (new AssetsTransformer)->transformAssets($assets, $assets->count(), $request); return (new AssetsTransformer)->transformAssets($assets, $assets->count(), $request);
} }
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))));
}
/** /**
* Notify a specific user via email with all of their assigned assets. * Notify a specific user via email with all of their assigned assets.
* *
@ -564,34 +597,41 @@ class UsersController extends Controller
* @since [v6.0.13] * @since [v6.0.13]
* @param Request $request * @param Request $request
* @param $id * @param $id
* @return string JSON
*/ */
public function emailAssetList(Request $request, $id) public function emailAssetList(Request $request, $id) : JsonResponse
{ {
$user = User::findOrFail($id); $this->authorize('update', User::class);
if ($user = User::find($id)) {
$this->authorize('update', $user);
if (empty($user->email)) { if (empty($user->email)) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.inventorynotification.error'))); return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.inventorynotification.error')));
} }
$user->notify((new CurrentInventory($user))); $user->notify((new CurrentInventory($user)));
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/users/message.inventorynotification.success'))); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/users/message.inventorynotification.success')));
} }
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))));
}
/** /**
* Return JSON containing a list of consumables assigned to a user. * Return JSON containing a list of consumables assigned to a user.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @param $userId * @param $userId
* @return string JSON
*/ */
public function consumables(Request $request, $id) public function consumables(Request $request, $id) : array
{ {
$this->authorize('view', User::class); $this->authorize('view', User::class);
$this->authorize('view', Consumable::class); $this->authorize('view', Consumable::class);
$user = User::findOrFail($id); $user = User::findOrFail($id);
$this->authorize('view', $user);
$consumables = $user->consumables; $consumables = $user->consumables;
return (new ConsumablesTransformer)->transformConsumables($consumables, $consumables->count(), $request); return (new ConsumablesTransformer)->transformConsumables($consumables, $consumables->count(), $request);
} }
@ -602,12 +642,12 @@ class UsersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.6.14] * @since [v4.6.14]
* @param $userId * @param $userId
* @return string JSON
*/ */
public function accessories($id) public function accessories($id) : array
{ {
$this->authorize('view', User::class); $this->authorize('view', User::class);
$user = User::findOrFail($id); $user = User::findOrFail($id);
$this->authorize('view', $user);
$this->authorize('view', Accessory::class); $this->authorize('view', Accessory::class);
$accessories = $user->accessories; $accessories = $user->accessories;
@ -620,14 +660,14 @@ class UsersController extends Controller
* @author [N. Mathar] [<snipe@snipe.net>] * @author [N. Mathar] [<snipe@snipe.net>]
* @since [v5.0] * @since [v5.0]
* @param $userId * @param $userId
* @return string JSON
*/ */
public function licenses($id) public function licenses($id) : JsonResponse | array
{ {
$this->authorize('view', User::class); $this->authorize('view', User::class);
$this->authorize('view', License::class); $this->authorize('view', License::class);
if ($user = User::where('id', $id)->withTrashed()->first()) { if ($user = User::where('id', $id)->withTrashed()->first()) {
$this->authorize('update', $user);
$licenses = $user->licenses()->get(); $licenses = $user->licenses()->get();
return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count()); return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count());
} }
@ -642,18 +682,28 @@ class UsersController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @param $userId * @param $userId
* @return string JSON
*/ */
public function postTwoFactorReset(Request $request) public function postTwoFactorReset(Request $request) : JsonResponse
{ {
$this->authorize('update', User::class); $this->authorize('update', User::class);
if ($request->filled('id')) { if ($request->filled('id')) {
try { try {
$user = User::find($request->get('id')); $user = User::find($request->get('id'));
$this->authorize('update', $user);
$user->two_factor_secret = null; $user->two_factor_secret = null;
$user->two_factor_enrolled = 0; $user->two_factor_enrolled = 0;
$user->save(); $user->saveQuietly();
// Log the reset
$logaction = new Actionlog();
$logaction->target_type = User::class;
$logaction->target_id = $user->id;
$logaction->item_type = User::class;
$logaction->item_id = $user->id;
$logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id();
$logaction->logaction('2FA reset');
return response()->json(['message' => trans('admin/settings/general.two_factor_reset_success')], 200); return response()->json(['message' => trans('admin/settings/general.two_factor_reset_success')], 200);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -671,9 +721,8 @@ class UsersController extends Controller
* @author [Juan Font] [<juanfontalonso@gmail.com>] * @author [Juan Font] [<juanfontalonso@gmail.com>]
* @since [v4.4.2] * @since [v4.4.2]
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/ */
public function getCurrentUserInfo(Request $request) public function getCurrentUserInfo(Request $request) : array
{ {
return (new UsersTransformer)->transformUser($request->user()); return (new UsersTransformer)->transformUser($request->user());
} }
@ -684,21 +733,34 @@ class UsersController extends Controller
* @author [E. Taylor] [<dev@evantaylor.name>] * @author [E. Taylor] [<dev@evantaylor.name>]
* @param int $userId * @param int $userId
* @since [v6.0.0] * @since [v6.0.0]
* @return JsonResponse
*/ */
public function restore($userId = null) public function restore($userId) : JsonResponse
{ {
// Get asset information $this->authorize('delete', User::class);
$user = User::withTrashed()->find($userId);
$this->authorize('delete', $user);
if (isset($user->id)) {
// Restore the user
User::withTrashed()->where('id', $userId)->restore();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/users/message.success.restored'))); if ($user = User::withTrashed()->find($userId)) {
$this->authorize('delete', $user);
if ($user->deleted_at == '') {
return response()->json(Helper::formatStandardApiResponse('error', trans('general.not_deleted', ['item_type' => trans('general.user')])), 200);
} }
$id = $userId; if ($user->restore()) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))), 200);
$logaction = new Actionlog();
$logaction->item_type = User::class;
$logaction->item_id = $user->id;
$logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id();
$logaction->logaction('restore');
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/users/message.success.restored')), 200);
}
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found')), 200);
} }
} }

View file

@ -2,17 +2,14 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Helpers\Helper;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetMaintenance; use App\Models\AssetMaintenance;
use App\Models\Company; use App\Models\Company;
use Auth; use Illuminate\Support\Facades\Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Slack; use \Illuminate\Contracts\View\View;
use Str; use \Illuminate\Http\RedirectResponse;
use TCPDF;
use View;
/** /**
* This controller handles all actions related to Asset Maintenance for * This controller handles all actions related to Asset Maintenance for
@ -29,9 +26,8 @@ class AssetMaintenancesController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return View
*/ */
private static function getInsufficientPermissionsRedirect() private static function getInsufficientPermissionsRedirect(): RedirectResponse
{ {
return redirect()->route('maintenances.index') return redirect()->route('maintenances.index')
->with('error', trans('general.insufficient_permissions')); ->with('error', trans('general.insufficient_permissions'));
@ -46,9 +42,8 @@ class AssetMaintenancesController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return View
*/ */
public function index() public function index() : View
{ {
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
return view('asset_maintenances/index'); return view('asset_maintenances/index');
@ -63,7 +58,7 @@ class AssetMaintenancesController extends Controller
* @since [v1.8] * @since [v1.8]
* @return mixed * @return mixed
*/ */
public function create() public function create() : View
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
$asset = null; $asset = null;
@ -92,9 +87,8 @@ class AssetMaintenancesController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return mixed
*/ */
public function store(Request $request) public function store(Request $request) : RedirectResponse
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
// create a new model instance // create a new model instance
@ -144,42 +138,26 @@ class AssetMaintenancesController extends Controller
* @param int $assetMaintenanceId * @param int $assetMaintenanceId
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return mixed
*/ */
public function edit($assetMaintenanceId = null) public function edit($assetMaintenanceId = null) : View | RedirectResponse
{ {
$this->authorize('update', Asset::class);
// Check if the asset maintenance exists
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
// Check if the asset maintenance exists // Check if the asset maintenance exists
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) { if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
// Redirect to the improvement management page // Redirect to the asset maintenance management page
return redirect()->route('maintenances.index') return redirect()->route('maintenances.index')->with('error', trans('admin/asset_maintenances/message.not_found'));
->with('error', trans('admin/asset_maintenances/message.not_found')); } elseif ((!$assetMaintenance->asset) || ($assetMaintenance->asset->deleted_at!='')) {
} elseif (! $assetMaintenance->asset) { // Redirect to the asset maintenance management page
return redirect()->route('maintenances.index') return redirect()->route('maintenances.index')->with('error', 'asset does not exist');
->with('error', 'The asset associated with this maintenance does not exist.');
} elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) { } elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
return static::getInsufficientPermissionsRedirect(); return static::getInsufficientPermissionsRedirect();
} }
if ($assetMaintenance->completion_date == '0000-00-00') {
$assetMaintenance->completion_date = null;
}
if ($assetMaintenance->start_date == '0000-00-00') {
$assetMaintenance->start_date = null;
}
if ($assetMaintenance->cost == '0.00') {
$assetMaintenance->cost = null;
}
// Prepare Improvement Type List // Prepare Improvement Type List
$assetMaintenanceType = [ $assetMaintenanceType = ['' => 'Select an improvement type'] + AssetMaintenance::getImprovementOptions();
'' => 'Select an improvement type',
] + AssetMaintenance::getImprovementOptions();
// Get Supplier List
// Render the view
return view('asset_maintenances/edit') return view('asset_maintenances/edit')
->with('selectedAsset', null) ->with('selectedAsset', null)
->with('assetMaintenanceType', $assetMaintenanceType) ->with('assetMaintenanceType', $assetMaintenanceType)
@ -193,18 +171,19 @@ class AssetMaintenancesController extends Controller
* @author Vincent Sposato <vincent.sposato@gmail.com> * @author Vincent Sposato <vincent.sposato@gmail.com>
* @param Request $request * @param Request $request
* @param int $assetMaintenanceId * @param int $assetMaintenanceId
* @return mixed
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
*/ */
public function update(Request $request, $assetMaintenanceId = null) public function update(Request $request, $assetMaintenanceId = null) : View | RedirectResponse
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
// Check if the asset maintenance exists // Check if the asset maintenance exists
if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) { if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
// Redirect to the asset maintenance management page // Redirect to the asset maintenance management page
return redirect()->route('maintenances.index') return redirect()->route('maintenances.index')->with('error', trans('admin/asset_maintenances/message.not_found'));
->with('error', trans('admin/asset_maintenances/message.not_found')); } elseif ((!$assetMaintenance->asset) || ($assetMaintenance->asset->deleted_at!='')) {
// Redirect to the asset maintenance management page
return redirect()->route('maintenances.index')->with('error', 'asset does not exist');
} elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) { } elseif (! Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
return static::getInsufficientPermissionsRedirect(); return static::getInsufficientPermissionsRedirect();
} }
@ -263,9 +242,8 @@ class AssetMaintenancesController extends Controller
* @param int $assetMaintenanceId * @param int $assetMaintenanceId
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return mixed
*/ */
public function destroy($assetMaintenanceId) public function destroy($assetMaintenanceId) : RedirectResponse
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
// Check if the asset maintenance exists // Check if the asset maintenance exists
@ -292,9 +270,8 @@ class AssetMaintenancesController extends Controller
* @param int $assetMaintenanceId * @param int $assetMaintenanceId
* @version v1.0 * @version v1.0
* @since [v1.8] * @since [v1.8]
* @return View
*/ */
public function show($assetMaintenanceId) public function show($assetMaintenanceId) : View | RedirectResponse
{ {
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);

View file

@ -4,16 +4,21 @@ namespace App\Http\Controllers;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Http\Requests\StoreAssetModelRequest;
use App\Models\Actionlog;
use App\Models\AssetModel; use App\Models\AssetModel;
use App\Models\CustomField;
use App\Models\SnipeModel;
use App\Models\User;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Redirect; use Illuminate\Http\Request;
use Request; use Illuminate\Support\Facades\Storage;
use Storage; use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpFoundation\JsonResponse; use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
/** /**
* This class controls all actions related to asset models for * This class controls all actions related to asset models for
@ -30,10 +35,8 @@ class AssetModelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function index() public function index() : View
{ {
$this->authorize('index', AssetModel::class); $this->authorize('index', AssetModel::class);
@ -45,10 +48,8 @@ class AssetModelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function create() public function create() : View
{ {
$this->authorize('create', AssetModel::class); $this->authorize('create', AssetModel::class);
@ -63,16 +64,12 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param ImageUploadRequest $request * @param ImageUploadRequest $request
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(ImageUploadRequest $request) public function store(StoreAssetModelRequest $request) : RedirectResponse
{ {
$this->authorize('create', AssetModel::class); $this->authorize('create', AssetModel::class);
// Create a new asset model
$model = new AssetModel; $model = new AssetModel;
// Save the model data
$model->eol = $request->input('eol'); $model->eol = $request->input('eol');
$model->depreciation_id = $request->input('depreciation_id'); $model->depreciation_id = $request->input('depreciation_id');
$model->name = $request->input('name'); $model->name = $request->input('name');
@ -82,15 +79,14 @@ class AssetModelsController extends Controller
$model->category_id = $request->input('category_id'); $model->category_id = $request->input('category_id');
$model->notes = $request->input('notes'); $model->notes = $request->input('notes');
$model->user_id = Auth::id(); $model->user_id = Auth::id();
$model->requestable = Request::has('requestable'); $model->requestable = $request->has('requestable');
if ($request->input('fieldset_id') != '') { if ($request->input('fieldset_id') != '') {
$model->fieldset_id = e($request->input('fieldset_id')); $model->fieldset_id = $request->input('fieldset_id');
} }
$model = $request->handleImages($model); $model = $request->handleImages($model);
// Was it created?
if ($model->save()) { if ($model->save()) {
if ($this->shouldAddDefaultValues($request->input())) { if ($this->shouldAddDefaultValues($request->input())) {
if (!$this->assignCustomFieldsDefaultValues($model, $request->input('default_values'))){ if (!$this->assignCustomFieldsDefaultValues($model, $request->input('default_values'))){
@ -98,7 +94,6 @@ class AssetModelsController extends Controller
} }
} }
// Redirect to the new model page
return redirect()->route('models.index')->with('success', trans('admin/models/message.create.success')); return redirect()->route('models.index')->with('success', trans('admin/models/message.create.success'));
} }
@ -111,18 +106,14 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param int $modelId * @param int $modelId
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($modelId = null) public function edit($modelId = null) : View | RedirectResponse
{ {
$this->authorize('update', AssetModel::class); $this->authorize('update', AssetModel::class);
if ($item = AssetModel::find($modelId)) { if ($item = AssetModel::find($modelId)) {
$category_type = 'asset'; $category_type = 'asset';
$view = View::make('models/edit', compact('item', 'category_type')); return view('models/edit', compact('item', 'category_type'))->with('depreciation_list', Helper::depreciationList());
$view->with('depreciation_list', Helper::depreciationList());
return $view;
} }
return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist')); return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist'));
@ -137,15 +128,14 @@ class AssetModelsController extends Controller
* @since [v1.0] * @since [v1.0]
* @param ImageUploadRequest $request * @param ImageUploadRequest $request
* @param int $modelId * @param int $modelId
* @return Redirect * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update(ImageUploadRequest $request, $modelId = null) public function update(StoreAssetModelRequest $request, $modelId) : RedirectResponse
{ {
$this->authorize('update', AssetModel::class); $this->authorize('update', AssetModel::class);
// Check if the model exists
if (is_null($model = AssetModel::find($modelId))) { if (is_null($model = AssetModel::find($modelId))) {
// Redirect to the models management page
return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist')); return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist'));
} }
@ -163,9 +153,6 @@ class AssetModelsController extends Controller
$this->removeCustomFieldsDefaultValues($model); $this->removeCustomFieldsDefaultValues($model);
if ($request->input('fieldset_id') == '') {
$model->fieldset_id = null;
} else {
$model->fieldset_id = $request->input('fieldset_id'); $model->fieldset_id = $request->input('fieldset_id');
if ($this->shouldAddDefaultValues($request->input())) { if ($this->shouldAddDefaultValues($request->input())) {
@ -173,9 +160,6 @@ class AssetModelsController extends Controller
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.fieldset_default_value.error')); return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.fieldset_default_value.error'));
} }
} }
}
if ($model->save()) { if ($model->save()) {
if ($model->wasChanged('eol')) { if ($model->wasChanged('eol')) {
@ -201,15 +185,13 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param int $modelId * @param int $modelId
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($modelId) public function destroy($modelId) : RedirectResponse
{ {
$this->authorize('delete', AssetModel::class); $this->authorize('delete', AssetModel::class);
// Check if the model exists // Check if the model exists
if (is_null($model = AssetModel::find($modelId))) { if (is_null($model = AssetModel::find($modelId))) {
return redirect()->route('models.index')->with('error', trans('admin/models/message.not_found')); return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist'));
} }
if ($model->assets()->count() > 0) { if ($model->assets()->count() > 0) {
@ -221,7 +203,7 @@ class AssetModelsController extends Controller
try { try {
Storage::disk('public')->delete('models/'.$model->image); Storage::disk('public')->delete('models/'.$model->image);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::info($e); Log::info($e);
} }
} }
@ -237,22 +219,40 @@ class AssetModelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param int $modelId * @param int $id
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function getRestore($modelId = null) public function getRestore($id) : RedirectResponse
{ {
$this->authorize('create', AssetModel::class); $this->authorize('create', AssetModel::class);
// Get user information
$model = AssetModel::withTrashed()->find($modelId);
if (isset($model->id)) { if ($model = AssetModel::withTrashed()->find($id)) {
$model->restore();
if ($model->deleted_at == '') {
return redirect()->back()->with('error', trans('general.not_deleted', ['item_type' => trans('general.asset_model')]));
}
if ($model->restore()) {
$logaction = new Actionlog();
$logaction->item_type = User::class;
$logaction->item_id = $model->id;
$logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id();
$logaction->logaction('restore');
// Redirect them to the deleted page if there are more, otherwise the section index
$deleted_models = AssetModel::onlyTrashed()->count();
if ($deleted_models > 0) {
return redirect()->back()->with('success', trans('admin/models/message.restore.success'));
}
return redirect()->route('models.index')->with('success', trans('admin/models/message.restore.success')); return redirect()->route('models.index')->with('success', trans('admin/models/message.restore.success'));
} }
return redirect()->back()->with('error', trans('admin/models/message.not_found'));
// Check validation
return redirect()->back()->with('error', trans('general.could_not_restore', ['item_type' => trans('general.asset_model'), 'error' => $model->getErrors()->first()]));
}
return redirect()->back()->with('error', trans('admin/models/message.does_not_exist'));
} }
@ -263,10 +263,8 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param int $modelId * @param int $modelId
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($modelId = null) public function show($modelId = null) : View | RedirectResponse
{ {
$this->authorize('view', AssetModel::class); $this->authorize('view', AssetModel::class);
$model = AssetModel::withTrashed()->find($modelId); $model = AssetModel::withTrashed()->find($modelId);
@ -284,9 +282,8 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param int $modelId * @param int $modelId
* @return View
*/ */
public function getClone($modelId = null) public function getClone($modelId = null) : View | RedirectResponse
{ {
$this->authorize('create', AssetModel::class); $this->authorize('create', AssetModel::class);
// Check if the model exists // Check if the model exists
@ -312,9 +309,8 @@ class AssetModelsController extends Controller
* @author [B. Wetherington] [<uberbrady@gmail.com>] * @author [B. Wetherington] [<uberbrady@gmail.com>]
* @since [v2.0] * @since [v2.0]
* @param int $modelId * @param int $modelId
* @return View
*/ */
public function getCustomFields($modelId) public function getCustomFields($modelId) : View
{ {
return view('models.custom_fields_form')->with('model', AssetModel::find($modelId)); return view('models.custom_fields_form')->with('model', AssetModel::find($modelId));
} }
@ -326,9 +322,8 @@ class AssetModelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.7] * @since [v1.7]
* @return \Illuminate\Contracts\View\View
*/ */
public function postBulkEdit(Request $request) public function postBulkEdit(Request $request) : View | RedirectResponse
{ {
$models_raw_array = $request->input('ids'); $models_raw_array = $request->input('ids');
@ -370,9 +365,8 @@ class AssetModelsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.7] * @since [v1.7]
* @return \Illuminate\Contracts\View\View
*/ */
public function postBulkEditSave(Request $request) public function postBulkEditSave(Request $request) : RedirectResponse
{ {
$models_raw_array = $request->input('ids'); $models_raw_array = $request->input('ids');
$update_array = []; $update_array = [];
@ -410,9 +404,8 @@ class AssetModelsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param int $modelId * @param int $modelId
* @return Redirect
*/ */
public function postBulkDelete(Request $request) public function postBulkDelete(Request $request) : RedirectResponse
{ {
$models_raw_array = $request->input('ids'); $models_raw_array = $request->input('ids');
@ -423,7 +416,6 @@ class AssetModelsController extends Controller
$del_count = 0; $del_count = 0;
foreach ($models as $model) { foreach ($models as $model) {
\Log::debug($model->id);
if ($model->assets_count > 0) { if ($model->assets_count > 0) {
$del_error_count++; $del_error_count++;
@ -433,8 +425,6 @@ class AssetModelsController extends Controller
} }
} }
\Log::debug($del_count);
\Log::debug($del_error_count);
if ($del_error_count == 0) { if ($del_error_count == 0) {
return redirect()->route('models.index') return redirect()->route('models.index')
@ -454,9 +444,8 @@ class AssetModelsController extends Controller
* any default values were entered into the form. * any default values were entered into the form.
* *
* @param array $input * @param array $input
* @return bool
*/ */
private function shouldAddDefaultValues(array $input) private function shouldAddDefaultValues(array $input) : bool
{ {
return ! empty($input['add_default_values']) return ! empty($input['add_default_values'])
&& ! empty($input['default_values']) && ! empty($input['default_values'])
@ -468,28 +457,27 @@ class AssetModelsController extends Controller
* *
* @param AssetModel $model * @param AssetModel $model
* @param array $defaultValues * @param array $defaultValues
* @return void
*/ */
private function assignCustomFieldsDefaultValues(AssetModel $model, array $defaultValues) private function assignCustomFieldsDefaultValues(AssetModel|SnipeModel $model, array $defaultValues): bool
{ {
$data = array(); $data = array();
foreach ($defaultValues as $customFieldId => $defaultValue) { foreach ($defaultValues as $customFieldId => $defaultValue) {
$customField = \App\Models\CustomField::find($customFieldId); $customField = CustomField::find($customFieldId);
$data[$customField->db_column] = $defaultValue; $data[$customField->db_column] = $defaultValue;
} }
$fieldsets = $model->fieldset->validation_rules(); $allRules = $model->fieldset->validation_rules();
$rules = array(); $rules = array();
foreach ($fieldsets as $fieldset => $validation){ foreach ($allRules as $field => $validation) {
// If the field is marked as required, eliminate the rule so it doesn't interfere with the default values // If the field is marked as required, eliminate the rule so it doesn't interfere with the default values
// (we are at model level, the rule still applies when creating a new asset using this model) // (we are at model level, the rule still applies when creating a new asset using this model)
$index = array_search('required', $validation); $index = array_search('required', $validation);
if ($index !== false){ if ($index !== false){
$validation[$index] = 'nullable'; $validation[$index] = 'nullable';
} }
$rules[$fieldset] = $validation; $rules[$field] = $validation;
} }
$validator = Validator::make($data, $rules); $validator = Validator::make($data, $rules);
@ -511,9 +499,8 @@ class AssetModelsController extends Controller
/** /**
* Removes all default values * Removes all default values
* *
* @return void
*/ */
private function removeCustomFieldsDefaultValues(AssetModel $model) private function removeCustomFieldsDefaultValues(AssetModel|SnipeModel $model): void
{ {
$model->defaultValues()->detach(); $model->defaultValues()->detach();
} }

View file

@ -3,26 +3,28 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Helpers\StorageHelper; use App\Helpers\StorageHelper;
use App\Http\Requests\AssetFileRequest; use App\Http\Requests\UploadFileRequest;
use App\Models\Actionlog; use App\Models\Actionlog;
use App\Models\AssetModel; use App\Models\AssetModel;
use Illuminate\Support\Facades\Response; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use enshrined\svgSanitize\Sanitizer; use \Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class AssetModelsFilesController extends Controller class AssetModelsFilesController extends Controller
{ {
/** /**
* Upload a file to the server. * Upload a file to the server.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @param UploadFileRequest $request
* @param AssetFileRequest $request
* @param int $modelId * @param int $modelId
* @return Redirect * @return \Illuminate\Http\RedirectResponse
* @since [v1.0]
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*@since [v1.0]
* @author [A. Gianotto] [<snipe@snipe.net>]
*/ */
public function store(AssetFileRequest $request, $modelId = null) public function store(UploadFileRequest $request, $modelId = null) : RedirectResponse
{ {
if (! $model = AssetModel::find($modelId)) { if (! $model = AssetModel::find($modelId)) {
return redirect()->route('models.index')->with('error', trans('admin/hardware/message.does_not_exist')); return redirect()->route('models.index')->with('error', trans('admin/hardware/message.does_not_exist'));
@ -37,29 +39,9 @@ class AssetModelsFilesController extends Controller
foreach ($request->file('file') as $file) { foreach ($request->file('file') as $file) {
$extension = $file->getClientOriginalExtension(); $file_name = $request->handleFile('private_uploads/assetmodels/','model-'.$model->id,$file);
$file_name = 'model-'.$model->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension;
// Check for SVG and sanitize it $model->logUpload($file_name, $request->get('notes'));
if ($extension=='svg') {
\Log::debug('This is an SVG');
$sanitizer = new Sanitizer();
$dirtySVG = file_get_contents($file->getRealPath());
$cleanSVG = $sanitizer->sanitize($dirtySVG);
try {
Storage::put('private_uploads/assetmodels/'.$file_name, $cleanSVG);
} catch (\Exception $e) {
\Log::debug('Upload no workie :( ');
\Log::debug($e);
}
} else {
Storage::put('private_uploads/assetmodels/'.$file_name, file_get_contents($file));
}
$model->logUpload($file_name, e($request->get('notes')));
} }
return redirect()->back()->with('success', trans('general.file_upload_success')); return redirect()->back()->with('success', trans('general.file_upload_success'));
@ -75,10 +57,8 @@ class AssetModelsFilesController extends Controller
* @param int $modelId * @param int $modelId
* @param int $fileId * @param int $fileId
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($modelId = null, $fileId = null) public function show($modelId = null, $fileId = null) : StreamedResponse | Response | RedirectResponse | BinaryFileResponse
{ {
$model = AssetModel::find($modelId); $model = AssetModel::find($modelId);
// the asset is valid // the asset is valid
@ -91,8 +71,6 @@ class AssetModelsFilesController extends Controller
} }
$file = 'private_uploads/assetmodels/'.$log->filename; $file = 'private_uploads/assetmodels/'.$log->filename;
\Log::debug('Checking for '.$file);
if (! Storage::exists($file)) { if (! Storage::exists($file)) {
return response('File '.$file.' not found on server', 404) return response('File '.$file.' not found on server', 404)
@ -124,10 +102,8 @@ class AssetModelsFilesController extends Controller
* @param int $modelId * @param int $modelId
* @param int $fileId * @param int $fileId
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($modelId = null, $fileId = null) public function destroy($modelId = null, $fileId = null) : RedirectResponse
{ {
$model = AssetModel::find($modelId); $model = AssetModel::find($modelId);
$this->authorize('update', $model); $this->authorize('update', $model);

View file

@ -6,26 +6,28 @@ use App\Events\CheckoutableCheckedIn;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\AssetCheckinRequest; use App\Http\Requests\AssetCheckinRequest;
use App\Http\Traits\MigratesLegacyAssetLocations;
use App\Models\Asset; use App\Models\Asset;
use App\Models\CheckoutAcceptance; use App\Models\CheckoutAcceptance;
use App\Models\LicenseSeat;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect; use \Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\View; use \Illuminate\Http\RedirectResponse;
class AssetCheckinController extends Controller class AssetCheckinController extends Controller
{ {
use MigratesLegacyAssetLocations;
/** /**
* Returns a view that presents a form to check an asset back into inventory. * Returns a view that presents a form to check an asset back into inventory.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @param string $backto * @param string $backto
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
* @since [v1.0] * @since [v1.0]
*/ */
public function create($assetId, $backto = null) public function create($assetId, $backto = null) : View | RedirectResponse
{ {
// Check if the asset exists // Check if the asset exists
if (is_null($asset = Asset::find($assetId))) { if (is_null($asset = Asset::find($assetId))) {
@ -35,7 +37,17 @@ class AssetCheckinController extends Controller
$this->authorize('checkin', $asset); $this->authorize('checkin', $asset);
return view('hardware/checkin', compact('asset'))->with('statusLabel_list', Helper::statusLabelList())->with('backto', $backto); // This asset is already checked in, redirect
if (is_null($asset->assignedTo)) {
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in'));
}
if (!$asset->model) {
return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
}
return view('hardware/checkin', compact('asset'))->with('statusLabel_list', Helper::statusLabelList())->with('backto', $backto)->with('table_name', 'Assets');
} }
/** /**
@ -45,11 +57,9 @@ class AssetCheckinController extends Controller
* @param AssetCheckinRequest $request * @param AssetCheckinRequest $request
* @param int $assetId * @param int $assetId
* @param null $backto * @param null $backto
* @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
* @since [v1.0] * @since [v1.0]
*/ */
public function store(AssetCheckinRequest $request, $assetId = null, $backto = null) public function store(AssetCheckinRequest $request, $assetId = null, $backto = null) : RedirectResponse
{ {
// Check if the asset exists // Check if the asset exists
if (is_null($asset = Asset::find($assetId))) { if (is_null($asset = Asset::find($assetId))) {
@ -60,6 +70,11 @@ class AssetCheckinController extends Controller
if (is_null($target = $asset->assignedTo)) { if (is_null($target = $asset->assignedTo)) {
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in'));
} }
if (!$asset->model) {
return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
}
$this->authorize('checkin', $asset); $this->authorize('checkin', $asset);
if ($asset->assignedType() == Asset::USER) { if ($asset->assignedType() == Asset::USER) {
@ -67,11 +82,8 @@ class AssetCheckinController extends Controller
} }
$asset->expected_checkin = null; $asset->expected_checkin = null;
$asset->last_checkout = null;
$asset->last_checkin = now(); $asset->last_checkin = now();
$asset->assigned_to = null;
$asset->assignedTo()->disassociate($asset); $asset->assignedTo()->disassociate($asset);
$asset->assigned_type = null;
$asset->accepted = null; $asset->accepted = null;
$asset->name = $request->get('name'); $asset->name = $request->get('name');
@ -79,29 +91,12 @@ class AssetCheckinController extends Controller
$asset->status_id = e($request->get('status_id')); $asset->status_id = e($request->get('status_id'));
} }
// This is just meant to correct legacy issues where some user data would have 0 $this->migrateLegacyLocations($asset);
// as a location ID, which isn't valid. Later versions of Snipe-IT have stricter validation
// rules, so it's necessary to fix this for long-time users. It's kinda gross, but will help
// people (and their data) in the long run
if ($asset->rtd_location_id == '0') {
\Log::debug('Manually override the RTD location IDs');
\Log::debug('Original RTD Location ID: '.$asset->rtd_location_id);
$asset->rtd_location_id = '';
\Log::debug('New RTD Location ID: '.$asset->rtd_location_id);
}
if ($asset->location_id == '0') {
\Log::debug('Manually override the location IDs');
\Log::debug('Original Location ID: '.$asset->location_id);
$asset->location_id = '';
\Log::debug('New Location ID: '.$asset->location_id);
}
$asset->location_id = $asset->rtd_location_id; $asset->location_id = $asset->rtd_location_id;
if ($request->filled('location_id')) { if ($request->filled('location_id')) {
\Log::debug('NEW Location ID: '.$request->get('location_id')); Log::debug('NEW Location ID: '.$request->get('location_id'));
$asset->location_id = $request->get('location_id'); $asset->location_id = $request->get('location_id');
if ($request->get('update_default_location') == 0){ if ($request->get('update_default_location') == 0){
@ -117,12 +112,9 @@ class AssetCheckinController extends Controller
$checkin_at = $request->get('checkin_at'); $checkin_at = $request->get('checkin_at');
} }
if(!empty($asset->licenseseats->all())){ $asset->licenseseats->each(function (LicenseSeat $seat) {
foreach ($asset->licenseseats as $seat){ $seat->update(['assigned_to' => null]);
$seat->assigned_to = null; });
$seat->save();
}
}
// Get all pending Acceptances for this asset and delete them // Get all pending Acceptances for this asset and delete them
$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable', $acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',
@ -134,15 +126,12 @@ class AssetCheckinController extends Controller
$acceptance->delete(); $acceptance->delete();
}); });
// Was the asset updated? session()->put('redirect_option', $request->get('redirect_option'));
if ($asset->save()) { if ($asset->save()) {
event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at, $originalValues));
if ((isset($user)) && ($backto == 'user')) { event(new CheckoutableCheckedIn($asset, $target, auth()->user(), $request->input('note'), $checkin_at, $originalValues));
return redirect()->route('users.show', $user->id)->with('success', trans('admin/hardware/message.checkin.success')); return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))->with('success', trans('admin/hardware/message.checkin.success'));
}
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkin.success'));
} }
// Redirect to the asset management page with error // Redirect to the asset management page with error
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.error').$asset->getErrors()); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.error').$asset->getErrors());

View file

@ -9,7 +9,9 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\AssetCheckoutRequest; use App\Http\Requests\AssetCheckoutRequest;
use App\Models\Asset; use App\Models\Asset;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Session;
use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
class AssetCheckoutController extends Controller class AssetCheckoutController extends Controller
{ {
@ -22,9 +24,9 @@ class AssetCheckoutController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v1.0] * @since [v1.0]
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function create($assetId) public function create($assetId) : View | RedirectResponse
{ {
// Check if the asset exists // Check if the asset exists
if (is_null($asset = Asset::with('company')->find(e($assetId)))) { if (is_null($asset = Asset::with('company')->find(e($assetId)))) {
@ -33,11 +35,17 @@ class AssetCheckoutController extends Controller
$this->authorize('checkout', $asset); $this->authorize('checkout', $asset);
if (!$asset->model) {
return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
}
if ($asset->availableForCheckout()) { if ($asset->availableForCheckout()) {
return view('hardware/checkout', compact('asset')) return view('hardware/checkout', compact('asset'))
->with('statusLabel_list', Helper::deployableStatusLabelList()); ->with('statusLabel_list', Helper::deployableStatusLabelList())
->with('table_name', 'Assets');
} }
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));
} }
@ -46,11 +54,9 @@ class AssetCheckoutController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param AssetCheckoutRequest $request * @param AssetCheckoutRequest $request
* @param int $assetId
* @return Redirect
* @since [v1.0] * @since [v1.0]
*/ */
public function store(AssetCheckoutRequest $request, $assetId) public function store(AssetCheckoutRequest $request, $assetId) : RedirectResponse
{ {
try { try {
// Check if the asset exists // Check if the asset exists
@ -60,9 +66,14 @@ class AssetCheckoutController extends Controller
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));
} }
$this->authorize('checkout', $asset); $this->authorize('checkout', $asset);
$admin = Auth::user();
$target = $this->determineCheckoutTarget($asset); if (!$asset->model) {
return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
}
$admin = auth()->user();
$target = $this->determineCheckoutTarget();
$asset = $this->updateAssetLocation($asset, $target); $asset = $this->updateAssetLocation($asset, $target);
@ -98,10 +109,12 @@ class AssetCheckoutController extends Controller
} }
} }
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $request->get('name'))) { session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
}
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))
->with('success', trans('admin/hardware/message.checkout.success'));
}
// Redirect to the asset management page with error // Redirect to the asset management page with error
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error').$asset->getErrors()); return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error').$asset->getErrors());
} catch (ModelNotFoundException $e) { } catch (ModelNotFoundException $e) {

View file

@ -4,26 +4,29 @@ namespace App\Http\Controllers\Assets;
use App\Helpers\StorageHelper; use App\Helpers\StorageHelper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\AssetFileRequest; use App\Http\Requests\UploadFileRequest;
use App\Models\Actionlog; use App\Models\Actionlog;
use App\Models\Asset; use App\Models\Asset;
use Illuminate\Support\Facades\Response; use \Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use enshrined\svgSanitize\Sanitizer; use \Illuminate\Contracts\View\View;
use \Illuminate\Http\RedirectResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class AssetFilesController extends Controller class AssetFilesController extends Controller
{ {
/** /**
* Upload a file to the server. * Upload a file to the server.
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @param UploadFileRequest $request
* @param AssetFileRequest $request
* @param int $assetId * @param int $assetId
* @return Redirect * @return \Illuminate\Http\RedirectResponse
* @since [v1.0]
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*@since [v1.0]
* @author [A. Gianotto] [<snipe@snipe.net>]
*/ */
public function store(AssetFileRequest $request, $assetId = null) public function store(UploadFileRequest $request, $assetId = null) : RedirectResponse
{ {
if (! $asset = Asset::find($assetId)) { if (! $asset = Asset::find($assetId)) {
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
@ -37,30 +40,9 @@ class AssetFilesController extends Controller
} }
foreach ($request->file('file') as $file) { foreach ($request->file('file') as $file) {
$file_name = $request->handleFile('private_uploads/assets/','hardware-'.$asset->id, $file);
$extension = $file->getClientOriginalExtension(); $asset->logUpload($file_name, $request->get('notes'));
$file_name = 'hardware-'.$asset->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension;
// Check for SVG and sanitize it
if ($extension=='svg') {
\Log::debug('This is an SVG');
$sanitizer = new Sanitizer();
$dirtySVG = file_get_contents($file->getRealPath());
$cleanSVG = $sanitizer->sanitize($dirtySVG);
try {
Storage::put('private_uploads/assets/'.$file_name, $cleanSVG);
} catch (\Exception $e) {
\Log::debug('Upload no workie :( ');
\Log::debug($e);
}
} else {
Storage::put('private_uploads/assets/'.$file_name, file_get_contents($file));
}
$asset->logUpload($file_name, e($request->get('notes')));
} }
return redirect()->back()->with('success', trans('admin/hardware/message.upload.success')); return redirect()->back()->with('success', trans('admin/hardware/message.upload.success'));
@ -76,10 +58,8 @@ class AssetFilesController extends Controller
* @param int $assetId * @param int $assetId
* @param int $fileId * @param int $fileId
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function show($assetId = null, $fileId = null) public function show($assetId = null, $fileId = null) : View | RedirectResponse | Response | StreamedResponse | BinaryFileResponse
{ {
$asset = Asset::find($assetId); $asset = Asset::find($assetId);
// the asset is valid // the asset is valid
@ -92,7 +72,6 @@ class AssetFilesController extends Controller
} }
$file = 'private_uploads/assets/'.$log->filename; $file = 'private_uploads/assets/'.$log->filename;
\Log::debug('Checking for '.$file);
if ($log->action_type == 'audit') { if ($log->action_type == 'audit') {
$file = 'private_uploads/audits/'.$log->filename; $file = 'private_uploads/audits/'.$log->filename;
@ -128,10 +107,8 @@ class AssetFilesController extends Controller
* @param int $assetId * @param int $assetId
* @param int $fileId * @param int $fileId
* @since [v1.0] * @since [v1.0]
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function destroy($assetId = null, $fileId = null) public function destroy($assetId = null, $fileId = null) : RedirectResponse
{ {
$asset = Asset::find($assetId); $asset = Asset::find($assetId);
$this->authorize('update', $asset); $this->authorize('update', $asset);
@ -154,7 +131,6 @@ class AssetFilesController extends Controller
->with('success', trans('admin/hardware/message.deletefile.success')); ->with('success', trans('admin/hardware/message.deletefile.success'));
} }
// Redirect to the hardware management page
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
} }
} }

View file

@ -6,6 +6,7 @@ use App\Helpers\Helper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\ImageUploadRequest; use App\Http\Requests\ImageUploadRequest;
use App\Models\Actionlog; use App\Models\Actionlog;
use App\Http\Requests\UploadFileRequest;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetModel; use App\Models\AssetModel;
@ -19,14 +20,16 @@ use Illuminate\Support\Facades\Auth;
use App\View\Label; use App\View\Label;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use League\Csv\Reader; use League\Csv\Reader;
use Illuminate\Support\Facades\Redirect; use Illuminate\Http\Response;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
/** /**
* This class controls all actions related to assets for * This class controls all actions related to assets for
@ -54,10 +57,8 @@ class AssetsController extends Controller
* @see AssetController::getDatatable() method that generates the JSON response * @see AssetController::getDatatable() method that generates the JSON response
* @since [v1.0] * @since [v1.0]
* @param Request $request * @param Request $request
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function index(Request $request) public function index(Request $request) : View
{ {
$this->authorize('index', Asset::class); $this->authorize('index', Asset::class);
$company = Company::find($request->input('company_id')); $company = Company::find($request->input('company_id'));
@ -71,13 +72,12 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @param Request $request * @param Request $request
* @return View
* @internal param int $model_id * @internal param int $model_id
*/ */
public function create(Request $request) public function create(Request $request) : View
{ {
$this->authorize('create', Asset::class); $this->authorize('create', Asset::class);
$view = View::make('hardware/edit') $view = view('hardware/edit')
->with('statuslabel_list', Helper::statusLabelList()) ->with('statuslabel_list', Helper::statusLabelList())
->with('item', new Asset) ->with('item', new Asset)
->with('statuslabel_types', Helper::statusTypeList()); ->with('statuslabel_types', Helper::statusTypeList());
@ -95,12 +95,15 @@ class AssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return Redirect
*/ */
public function store(ImageUploadRequest $request) public function store(ImageUploadRequest $request) : RedirectResponse
{ {
$this->authorize(Asset::class); $this->authorize(Asset::class);
// There are a lot more rules to add here but prevents
// errors around `asset_tags` not being present below.
$this->validate($request, ['asset_tags' => ['required', 'array']]);
// Handle asset tags - there could be one, or potentially many. // Handle asset tags - there could be one, or potentially many.
// This is only necessary on create, not update, since bulk editing is handled // This is only necessary on create, not update, since bulk editing is handled
// differently // differently
@ -130,9 +133,6 @@ class AssetsController extends Controller
$asset->order_number = $request->input('order_number'); $asset->order_number = $request->input('order_number');
$asset->notes = $request->input('notes'); $asset->notes = $request->input('notes');
$asset->user_id = Auth::id(); $asset->user_id = Auth::id();
$asset->archived = '0';
$asset->physical = '1';
$asset->depreciate = '0';
$asset->status_id = request('status_id'); $asset->status_id = request('status_id');
$asset->warranty_months = request('warranty_months', null); $asset->warranty_months = request('warranty_months', null);
$asset->purchase_cost = request('purchase_cost'); $asset->purchase_cost = request('purchase_cost');
@ -148,7 +148,8 @@ class AssetsController extends Controller
$asset->next_audit_date = Carbon::now()->addMonths($settings->audit_interval)->toDateString(); $asset->next_audit_date = Carbon::now()->addMonths($settings->audit_interval)->toDateString();
} }
if ($asset->assigned_to == '') { // Set location_id to rtd_location_id ONLY if the asset isn't being checked out
if (!request('assigned_user') && !request('assigned_asset') && !request('assigned_location')) {
$asset->location_id = $request->input('rtd_location_id', null); $asset->location_id = $request->input('rtd_location_id', null);
} }
@ -195,7 +196,7 @@ class AssetsController extends Controller
} }
if (isset($target)) { if (isset($target)) {
$asset->checkOut($target, Auth::user(), date('Y-m-d H:i:s'), $request->input('expected_checkin', null), 'Checked out on asset creation', $request->get('name'), $location); $asset->checkOut($target, auth()->user(), date('Y-m-d H:i:s'), $request->input('expected_checkin', null), 'Checked out on asset creation', $request->get('name'), $location);
} }
$success = true; $success = true;
@ -203,9 +204,13 @@ class AssetsController extends Controller
} }
} }
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
if ($success) { if ($success) {
return redirect()->route('hardware.index')
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', $asset->id), 'id', 'tag' => $asset->asset_tag])); return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', ['hardware' => $asset->id]), 'id', 'tag' => e($asset->asset_tag)]));
} }
@ -213,11 +218,6 @@ class AssetsController extends Controller
return redirect()->back()->withInput()->withErrors($asset->getErrors()); return redirect()->back()->withInput()->withErrors($asset->getErrors());
} }
public function getOptionCookie(Request $request){
$value = $request->cookie('optional_info');
echo $value;
return $value;
}
/** /**
* Returns a view that presents a form to edit an existing asset. * Returns a view that presents a form to edit an existing asset.
@ -225,9 +225,9 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v1.0] * @since [v1.0]
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function edit($assetId = null) public function edit($assetId = null) : View | RedirectResponse
{ {
if (! $item = Asset::find($assetId)) { if (! $item = Asset::find($assetId)) {
// Redirect to the asset management page with error // Redirect to the asset management page with error
@ -248,9 +248,9 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v1.0] * @since [v1.0]
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function show($assetId = null) public function show($assetId = null) : View | RedirectResponse
{ {
$asset = Asset::withTrashed()->find($assetId); $asset = Asset::withTrashed()->find($assetId);
$this->authorize('view', $asset); $this->authorize('view', $asset);
@ -288,12 +288,12 @@ class AssetsController extends Controller
* Validate and process asset edit form. * Validate and process asset edit form.
* *
* @param int $assetId * @param int $assetId
* @return \Illuminate\Http\RedirectResponse|Redirect * @since [v1.0]
*@since [v1.0]
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
*/ */
public function update(ImageUploadRequest $request, $assetId = null) public function update(ImageUploadRequest $request, $assetId = null) : RedirectResponse
{ {
// Check if the asset exists // Check if the asset exists
if (! $asset = Asset::find($assetId)) { if (! $asset = Asset::find($assetId)) {
// Redirect to the asset management page with error // Redirect to the asset management page with error
@ -305,6 +305,7 @@ class AssetsController extends Controller
$asset->warranty_months = $request->input('warranty_months', null); $asset->warranty_months = $request->input('warranty_months', null);
$asset->purchase_cost = $request->input('purchase_cost', null); $asset->purchase_cost = $request->input('purchase_cost', null);
$asset->purchase_date = $request->input('purchase_date', null); $asset->purchase_date = $request->input('purchase_date', null);
$asset->next_audit_date = $request->input('next_audit_date', null);
if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && ($asset->model->eol > 0)) { if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && ($asset->model->eol > 0)) {
$asset->purchase_date = $request->input('purchase_date', null); $asset->purchase_date = $request->input('purchase_date', null);
$asset->asset_eol_date = Carbon::parse($request->input('purchase_date'))->addMonths($asset->model->eol)->format('Y-m-d'); $asset->asset_eol_date = Carbon::parse($request->input('purchase_date'))->addMonths($asset->model->eol)->format('Y-m-d');
@ -335,7 +336,7 @@ class AssetsController extends Controller
$status = Statuslabel::find($asset->status_id); $status = Statuslabel::find($asset->status_id);
if($status->archived){ if ($status && $status->archived) {
$asset->assigned_to = null; $asset->assigned_to = null;
} }
@ -354,16 +355,27 @@ class AssetsController extends Controller
} }
// Update the asset data // Update the asset data
$asset_tag = $request->input('asset_tags');
$serial = $request->input('serials'); $serial = $request->input('serials');
$asset->name = $request->input('name'); $asset->serial = $request->input('serials');
if (is_array($request->input('serials'))) {
$asset->serial = $serial[1]; $asset->serial = $serial[1];
}
$asset->name = $request->input('name');
$asset->company_id = Company::getIdForCurrentUser($request->input('company_id')); $asset->company_id = Company::getIdForCurrentUser($request->input('company_id'));
$asset->model_id = $request->input('model_id'); $asset->model_id = $request->input('model_id');
$asset->order_number = $request->input('order_number'); $asset->order_number = $request->input('order_number');
$asset->asset_tag = $asset_tag[1];
$asset_tags = $request->input('asset_tags');
$asset->asset_tag = $request->input('asset_tags');
if (is_array($request->input('asset_tags'))) {
$asset->asset_tag = $asset_tags[1];
}
$asset->notes = $request->input('notes'); $asset->notes = $request->input('notes');
$asset->physical = '1';
$asset = $request->handleImages($asset); $asset = $request->handleImages($asset);
@ -374,6 +386,7 @@ class AssetsController extends Controller
$model = AssetModel::find($request->get('model_id')); $model = AssetModel::find($request->get('model_id'));
if (($model) && ($model->fieldset)) { if (($model) && ($model->fieldset)) {
foreach ($model->fieldset->fields as $field) { foreach ($model->fieldset->fields as $field) {
if ($field->field_encrypted == '1') { if ($field->field_encrypted == '1') {
if (Gate::allows('admin')) { if (Gate::allows('admin')) {
if (is_array($request->input($field->db_column))) { if (is_array($request->input($field->db_column))) {
@ -392,9 +405,10 @@ class AssetsController extends Controller
} }
} }
session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
if ($asset->save()) { if ($asset->save()) {
return redirect()->route('hardware.show', $assetId) return redirect()->to(Helper::getRedirectOption($request, $assetId, 'Assets'))
->with('success', trans('admin/hardware/message.update.success')); ->with('success', trans('admin/hardware/message.update.success'));
} }
@ -407,9 +421,8 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v1.0] * @since [v1.0]
* @return Redirect
*/ */
public function destroy($assetId) public function destroy($assetId) : RedirectResponse
{ {
// Check if the asset exists // Check if the asset exists
if (is_null($asset = Asset::find($assetId))) { if (is_null($asset = Asset::find($assetId))) {
@ -441,9 +454,8 @@ class AssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @return Redirect
*/ */
public function getAssetBySerial(Request $request) public function getAssetBySerial(Request $request) : RedirectResponse
{ {
$topsearch = ($request->get('topsearch')=="true"); $topsearch = ($request->get('topsearch')=="true");
@ -459,16 +471,23 @@ class AssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.0] * @since [v3.0]
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function getAssetByTag(Request $request, $tag=null) public function getAssetByTag(Request $request, $tag=null) : RedirectResponse
{ {
$tag = $tag ? $tag : $request->get('assetTag'); $tag = $tag ? $tag : $request->get('assetTag');
$topsearch = ($request->get('topsearch') == 'true'); $topsearch = ($request->get('topsearch') == 'true');
if (! $asset = Asset::where('asset_tag', '=', $tag)->first()) { // Search for an exact and unique asset tag match
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); $assets = Asset::where('asset_tag', '=', $tag);
// If not a unique result, redirect to the index view
if ($assets->count() != 1) {
return redirect()->route('hardware.index')
->with('search', $tag)
->with('warning', trans('admin/hardware/message.does_not_exist_var', [ 'asset_tag' => $tag ]));
} }
$asset = $assets->first();
$this->authorize('view', $asset); $this->authorize('view', $asset);
return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch); return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch);
@ -481,9 +500,8 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v1.0] * @since [v1.0]
* @return Response
*/ */
public function getQrCode($assetId = null) public function getQrCode($assetId = null) : Response | BinaryFileResponse | string | bool
{ {
$settings = Setting::getSettings(); $settings = Setting::getSettings();
@ -510,6 +528,7 @@ class AssetsController extends Controller
return 'That asset is invalid'; return 'That asset is invalid';
} }
return false;
} }
/** /**
@ -523,7 +542,7 @@ class AssetsController extends Controller
public function getBarCode($assetId = null) public function getBarCode($assetId = null)
{ {
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$asset = Asset::find($assetId); if ($asset = Asset::withTrashed()->find($assetId)) {
$barcode_file = public_path().'/uploads/barcodes/'.str_slug($settings->alt_barcode).'-'.str_slug($asset->asset_tag).'.png'; $barcode_file = public_path().'/uploads/barcodes/'.str_slug($settings->alt_barcode).'-'.str_slug($asset->asset_tag).'.png';
if (isset($asset->id, $asset->asset_tag)) { if (isset($asset->id, $asset->asset_tag)) {
@ -549,13 +568,15 @@ class AssetsController extends Controller
} }
} }
} }
return null;
}
/** /**
* Return a label for an individual asset. * Return a label for an individual asset.
* *
* @author [L. Swartzendruber] [<logan.swartzendruber@gmail.com> * @author [L. Swartzendruber] [<logan.swartzendruber@gmail.com>
* @param int $assetId * @param int $assetId
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function getLabel($assetId = null) public function getLabel($assetId = null)
{ {
@ -579,28 +600,22 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v1.0] * @since [v1.0]
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function getClone($assetId = null) public function getClone(Asset $asset)
{ {
// Check if the asset exists $this->authorize('create', $asset);
if (is_null($asset_to_clone = Asset::find($assetId))) { $cloned = clone $asset;
// Redirect to the asset management page $cloned->id = null;
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); $cloned->asset_tag = '';
} $cloned->serial = '';
$cloned->assigned_to = '';
$this->authorize('create', $asset_to_clone); $cloned->deleted_at = '';
$asset = clone $asset_to_clone;
$asset->id = null;
$asset->asset_tag = '';
$asset->serial = '';
$asset->assigned_to = '';
return view('hardware/edit') return view('hardware/edit')
->with('statuslabel_list', Helper::statusLabelList()) ->with('statuslabel_list', Helper::statusLabelList())
->with('statuslabel_types', Helper::statusTypeList()) ->with('statuslabel_types', Helper::statusTypeList())
->with('item', $asset); ->with('item', $cloned);
} }
/** /**
@ -608,7 +623,7 @@ class AssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0] * @since [v1.0]
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function getImportHistory() public function getImportHistory()
{ {
@ -630,7 +645,7 @@ class AssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v3.3] * @since [v3.3]
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function postImportHistory(Request $request) public function postImportHistory(Request $request)
{ {
@ -724,8 +739,8 @@ class AssetsController extends Controller
Actionlog::firstOrCreate([ Actionlog::firstOrCreate([
'item_id' => $asset->id, 'item_id' => $asset->id,
'item_type' => Asset::class, 'item_type' => Asset::class,
'user_id' => Auth::user()->id, 'user_id' => auth()->id(),
'note' => 'Checkout imported by '.Auth::user()->present()->fullName().' from history importer', 'note' => 'Checkout imported by '.auth()->user()->present()->fullName().' from history importer',
'target_id' => $item[$asset_tag][$batch_counter]['user_id'], 'target_id' => $item[$asset_tag][$batch_counter]['user_id'],
'target_type' => User::class, 'target_type' => User::class,
'created_at' => $item[$asset_tag][$batch_counter]['checkout_date'], 'created_at' => $item[$asset_tag][$batch_counter]['checkout_date'],
@ -736,11 +751,11 @@ class AssetsController extends Controller
if ($isCheckinHeaderExplicit) { if ($isCheckinHeaderExplicit) {
//if checkin date header exists, assume that empty or future date is still checked out // if checkin date header exists, assume that empty or future date is still checked out
//if checkin is before todays date, assume it's checked in and do not assign user ID, if checkin date is in the future or blank, this is the expected checkin date, items is checked out // if checkin is before today's date, assume it's checked in and do not assign user ID, if checkin date is in the future or blank, this is the expected checkin date, items are checked out
if ((strtotime($checkin_date) > strtotime(Carbon::now())) || (empty($checkin_date)) if ((strtotime($checkin_date) > strtotime(Carbon::now())) || (empty($checkin_date)))
) { {
//only do this if item is checked out //only do this if item is checked out
$asset->assigned_to = $user->id; $asset->assigned_to = $user->id;
$asset->assigned_type = User::class; $asset->assigned_type = User::class;
@ -752,8 +767,8 @@ class AssetsController extends Controller
Actionlog::firstOrCreate([ Actionlog::firstOrCreate([
'item_id' => $item[$asset_tag][$batch_counter]['asset_id'], 'item_id' => $item[$asset_tag][$batch_counter]['asset_id'],
'item_type' => Asset::class, 'item_type' => Asset::class,
'user_id' => Auth::user()->id, 'user_id' => auth()->id(),
'note' => 'Checkin imported by '.Auth::user()->present()->fullName().' from history importer', 'note' => 'Checkin imported by '.auth()->user()->present()->fullName().' from history importer',
'target_id' => null, 'target_id' => null,
'created_at' => $checkin_date, 'created_at' => $checkin_date,
'action_type' => 'checkin', 'action_type' => 'checkin',
@ -790,27 +805,30 @@ class AssetsController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId * @param int $assetId
* @since [v1.0] * @since [v1.0]
* @return View * @return \Illuminate\Contracts\View\View
*/ */
public function getRestore($assetId = null) public function getRestore($assetId = null)
{ {
// Get asset information if ($asset = Asset::withTrashed()->find($assetId)) {
$asset = Asset::withTrashed()->find($assetId);
$this->authorize('delete', $asset); $this->authorize('delete', $asset);
if (isset($asset->id)) {
// Restore the asset
Asset::withTrashed()->where('id', $assetId)->restore();
$logaction = new Actionlog(); if ($asset->deleted_at == '') {
$logaction->item_type = Asset::class; return redirect()->back()->with('error', trans('general.not_deleted', ['item_type' => trans('general.asset')]));
$logaction->item_id = $asset->id; }
$logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = Auth::user()->id;
$logaction->logaction('restored');
if ($asset->restore()) {
// Redirect them to the deleted page if there are more, otherwise the section index
$deleted_assets = Asset::onlyTrashed()->count();
if ($deleted_assets > 0) {
return redirect()->back()->with('success', trans('admin/hardware/message.restore.success'));
}
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.restore.success')); return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.restore.success'));
} }
// Check validation to make sure we're not restoring an asset with the same asset tag (or unique attribute) as an existing asset
return redirect()->back()->with('error', trans('general.could_not_restore', ['item_type' => trans('general.asset'), 'error' => $asset->getErrors()->first()]));
}
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
} }
@ -826,7 +844,7 @@ class AssetsController extends Controller
{ {
$this->authorize('checkin', Asset::class); $this->authorize('checkin', Asset::class);
return view('hardware/quickscan-checkin'); return view('hardware/quickscan-checkin')->with('statusLabel_list', Helper::statusLabelList());
} }
public function audit($id) public function audit($id)
@ -846,15 +864,15 @@ class AssetsController extends Controller
return view('hardware/audit-due'); return view('hardware/audit-due');
} }
public function overdueForAudit() public function dueForCheckin()
{ {
$this->authorize('audit', Asset::class); $this->authorize('checkin', Asset::class);
return view('hardware/audit-overdue'); return view('hardware/checkin-due');
} }
public function auditStore(Request $request, $id) public function auditStore(UploadFileRequest $request, $id)
{ {
$this->authorize('audit', Asset::class); $this->authorize('audit', Asset::class);
@ -871,7 +889,21 @@ class AssetsController extends Controller
$asset = Asset::findOrFail($id); $asset = Asset::findOrFail($id);
// We don't want to log this as a normal update, so let's bypass that /**
* Even though we do a save() further down, we don't want to log this as a "normal" asset update,
* which would trigger the Asset Observer and would log an asset *update* log entry (because the
* de-normed fields like next_audit_date on the asset itself will change on save()) *in addition* to
* the audit log entry we're creating through this controller.
*
* To prevent this double-logging (one for update and one for audit), we skip the observer and bypass
* that de-normed update log entry by using unsetEventDispatcher(), BUT invoking unsetEventDispatcher()
* will bypass normal model-level validation that's usually handled at the observer )
*
* We handle validation on the save() by checking if the asset is valid via the ->isValid() method,
* which manually invokes Watson Validating to make sure the asset's model is valid.
*
* @see \App\Observers\AssetObserver::updating()
*/
$asset->unsetEventDispatcher(); $asset->unsetEventDispatcher();
$asset->next_audit_date = $request->input('next_audit_date'); $asset->next_audit_date = $request->input('next_audit_date');
@ -880,29 +912,27 @@ class AssetsController extends Controller
// Check to see if they checked the box to update the physical location, // Check to see if they checked the box to update the physical location,
// not just note it in the audit notes // not just note it in the audit notes
if ($request->input('update_location') == '1') { if ($request->input('update_location') == '1') {
Log::debug('update location in audit');
$asset->location_id = $request->input('location_id'); $asset->location_id = $request->input('location_id');
} }
if ($asset->save()) { /**
$file_name = ''; * Invoke Watson Validating to check the asset itself and check to make sure it saved correctly.
// Upload an image, if attached * We have to invoke this manually because of the unsetEventDispatcher() above.)
if ($request->hasFile('image')) { */
$path = 'private_uploads/audits'; if ($asset->isValid() && $asset->save()) {
if (! Storage::exists($path)) {
Storage::makeDirectory($path, 775);
}
$upload = $image = $request->file('image');
$ext = $image->getClientOriginalExtension();
$file_name = 'audit-'.str_random(18).'.'.$ext;
Storage::putFileAs($path, $upload, $file_name);
}
$file_name = null;
// Create the image (if one was chosen.)
if ($request->hasFile('image')) {
$file_name = $request->handleFile('private_uploads/audits/', 'audit-'.$asset->id, $request->file('image'));
}
$asset->logAudit($request->input('note'), $request->input('location_id'), $file_name); $asset->logAudit($request->input('note'), $request->input('location_id'), $file_name);
return redirect()->route('assets.audit.due')->with('success', trans('admin/hardware/message.audit.success')); return redirect()->route('assets.audit.due')->with('success', trans('admin/hardware/message.audit.success'));
} }
return redirect()->back()->withInput()->withErrors($asset->getErrors());
} }
public function getRequestedIndex($user_id = null) public function getRequestedIndex($user_id = null)

View file

@ -2,19 +2,24 @@
namespace App\Http\Controllers\Assets; namespace App\Http\Controllers\Assets;
use App\Models\Actionlog;
use App\Helpers\Helper; use App\Helpers\Helper;
use App\Http\Controllers\CheckInOutRequest; use App\Http\Controllers\CheckInOutRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Statuslabel;
use App\Models\Setting; use App\Models\Setting;
use App\View\Label; use App\View\Label;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;
use App\Http\Requests\AssetCheckoutRequest; use App\Http\Requests\AssetCheckoutRequest;
use App\Models\CustomField; use App\Models\CustomField;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class BulkAssetsController extends Controller class BulkAssetsController extends Controller
{ {
@ -23,58 +28,104 @@ class BulkAssetsController extends Controller
/** /**
* Display the bulk edit page. * Display the bulk edit page.
* *
* This method is super weird because it's kinda of like a controller within a controller.
* It's main function is to determine what the bulk action in, and then return a view with
* the information that view needs, be it bulk delete, bulk edit, restore, etc.
*
* This is something that made sense at the time, but sort of doesn't make sense now. A JS front-end to determine form
* action would make a lot more sense here and make things a lot more clear.
*
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @return View
* @internal param int $assetId * @internal param int $assetId
* @since [v2.0] * @since [v2.0]
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit(Request $request) public function edit(Request $request) : View | RedirectResponse
{ {
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
/**
* No asset IDs were passed
*/
if (! $request->filled('ids')) { if (! $request->filled('ids')) {
return redirect()->back()->with('error', trans('admin/hardware/message.update.no_assets_selected')); return redirect()->back()->with('error', trans('admin/hardware/message.update.no_assets_selected'));
} }
$asset_ids = $request->input('ids');
// Figure out where we need to send the user after the update is complete, and store that in the session // Figure out where we need to send the user after the update is complete, and store that in the session
$bulk_back_url = request()->headers->get('referer'); $bulk_back_url = request()->headers->get('referer');
session(['bulk_back_url' => $bulk_back_url]); session(['bulk_back_url' => $bulk_back_url]);
$asset_ids = array_values(array_unique($request->input('ids'))); $allowed_columns = [
'id',
'name',
'asset_tag',
'serial',
'model_number',
'last_checkout',
'notes',
'expected_checkin',
'order_number',
'image',
'assigned_to',
'created_at',
'updated_at',
'purchase_date',
'purchase_cost',
'last_audit_date',
'next_audit_date',
'warranty_months',
'checkout_counter',
'checkin_counter',
'requests_counter',
'byod',
'asset_eol_date',
];
//custom fields logic
$asset_custom_field = Asset::with(['model.fieldset.fields', 'model'])->whereIn('id', $asset_ids)->whereHas('model', function ($query) {
return $query->where('fieldset_id', '!=', null);
})->get();
$models = $asset_custom_field->unique('model_id'); /**
* Make sure the column is allowed, and if it's a custom field, make sure we strip the custom_fields. prefix
*/
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort_override = str_replace('custom_fields.', '', $request->input('sort'));
// This handles all of the pivot sorting below (versus the assets.* fields in the allowed_columns array)
$column_sort = in_array($sort_override, $allowed_columns) ? $sort_override : 'assets.id';
$assets = Asset::with('assignedTo', 'location', 'model')
->whereIn('assets.id', $asset_ids)
->withTrashed();
$assets = $assets->get();
if ($assets->isEmpty()) {
Log::debug('No assets were found for the provided IDs', ['ids' => $asset_ids]);
return redirect()->back()->with('error', trans('admin/hardware/message.update.assets_do_not_exist_or_are_invalid'));
}
$models = $assets->unique('model_id');
$modelNames = []; $modelNames = [];
foreach($models as $model) { foreach($models as $model) {
$modelNames[] = $model->model->name; $modelNames[] = $model->model->name;
} }
if ($request->filled('bulk_actions')) { if ($request->filled('bulk_actions')) {
switch ($request->input('bulk_actions')) { switch ($request->input('bulk_actions')) {
case 'labels': case 'labels':
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
$assets_found = Asset::find($asset_ids);
if ($assets_found->isEmpty()){
return redirect()->back();
}
return (new Label) return (new Label)
->with('assets', $assets_found) ->with('assets', $assets)
->with('settings', Setting::getSettings()) ->with('settings', Setting::getSettings())
->with('bulkedit', true) ->with('bulkedit', true)
->with('count', 0); ->with('count', 0);
case 'delete': case 'delete':
$this->authorize('delete', Asset::class); $this->authorize('delete', Asset::class);
$assets = Asset::with('assignedTo', 'location')->find($asset_ids); $assets->each(function ($assets) {
$assets->each(function ($asset) { $this->authorize('delete', $assets);
$this->authorize('delete', $asset);
}); });
return view('hardware/bulk-delete')->with('assets', $assets); return view('hardware/bulk-delete')->with('assets', $assets);
@ -85,11 +136,11 @@ class BulkAssetsController extends Controller
$assets->each(function ($asset) { $assets->each(function ($asset) {
$this->authorize('delete', $asset); $this->authorize('delete', $asset);
}); });
return view('hardware/bulk-restore')->with('assets', $assets); return view('hardware/bulk-restore')->with('assets', $assets);
case 'edit': case 'edit':
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
return view('hardware/bulk') return view('hardware/bulk')
->with('assets', $asset_ids) ->with('assets', $asset_ids)
->with('statuslabel_list', Helper::statusLabelList()) ->with('statuslabel_list', Helper::statusLabelList())
@ -98,6 +149,41 @@ class BulkAssetsController extends Controller
} }
} }
switch ($sort_override) {
case 'model':
$assets->OrderModels($order);
break;
case 'model_number':
$assets->OrderModelNumber($order);
break;
case 'category':
$assets->OrderCategory($order);
break;
case 'manufacturer':
$assets->OrderManufacturer($order);
break;
case 'company':
$assets->OrderCompany($order);
break;
case 'location':
$assets->OrderLocation($order);
case 'rtd_location':
$assets->OrderRtdLocation($order);
break;
case 'status_label':
$assets->OrderStatus($order);
break;
case 'supplier':
$assets->OrderSupplier($order);
break;
case 'assigned_to':
$assets->OrderAssigned($order);
break;
default:
$assets->orderBy($column_sort, $order);
break;
}
return redirect()->back()->with('error', 'No action selected'); return redirect()->back()->with('error', 'No action selected');
} }
@ -105,11 +191,10 @@ class BulkAssetsController extends Controller
* Save bulk edits * Save bulk edits
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @return Redirect
* @internal param array $assets * @internal param array $assets
* @since [v2.0] * @since [v2.0]
*/ */
public function update(Request $request) public function update(Request $request) : RedirectResponse
{ {
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
$has_errors = 0; $has_errors = 0;
@ -117,26 +202,33 @@ class BulkAssetsController extends Controller
// Get the back url from the session and then destroy the session // Get the back url from the session and then destroy the session
$bulk_back_url = route('hardware.index'); $bulk_back_url = route('hardware.index');
if ($request->session()->has('bulk_back_url')) { if ($request->session()->has('bulk_back_url')) {
$bulk_back_url = $request->session()->pull('bulk_back_url'); $bulk_back_url = $request->session()->pull('bulk_back_url');
} }
$custom_field_columns = CustomField::all()->pluck('db_column')->toArray(); $custom_field_columns = CustomField::all()->pluck('db_column')->toArray();
if (Session::exists('ids')) {
$assets = Session::get('ids'); if (! $request->filled('ids') || count($request->input('ids')) == 0) {
} elseif (! $request->filled('ids') || count($request->input('ids')) <= 0) {
return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.no_assets_selected')); return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.no_assets_selected'));
} }
$assets = array_keys($request->input('ids'));
if ($request->anyFilled($custom_field_columns)) { $assets = Asset::whereIn('id', $request->input('ids'))->get();
$custom_fields_present = true;
} else {
$custom_fields_present = false;
} /**
if (($request->filled('purchase_date')) * If ANY of these are filled, prepare to update the values on the assets.
*
* Additional checks will be needed for some of them to make sure the values
* make sense (for example, changing the status ID to something incompatible with
* its checkout status.
*/
if (($request->filled('name'))
|| ($request->filled('purchase_date'))
|| ($request->filled('expected_checkin')) || ($request->filled('expected_checkin'))
|| ($request->filled('purchase_cost')) || ($request->filled('purchase_cost'))
|| ($request->filled('supplier_id')) || ($request->filled('supplier_id'))
@ -148,21 +240,30 @@ class BulkAssetsController extends Controller
|| ($request->filled('status_id')) || ($request->filled('status_id'))
|| ($request->filled('model_id')) || ($request->filled('model_id'))
|| ($request->filled('next_audit_date')) || ($request->filled('next_audit_date'))
|| ($request->filled('null_name'))
|| ($request->filled('null_purchase_date')) || ($request->filled('null_purchase_date'))
|| ($request->filled('null_expected_checkin_date')) || ($request->filled('null_expected_checkin_date'))
|| ($request->filled('null_next_audit_date')) || ($request->filled('null_next_audit_date'))
|| ($request->anyFilled($custom_field_columns)) || ($request->anyFilled($custom_field_columns))
) { ) {
foreach ($assets as $assetId) { // Let's loop through those assets and build an update array
foreach ($assets as $asset) {
$this->update_array = []; $this->update_array = [];
$this->conditionallyAddItem('purchase_date') /**
* Leave out model_id and status here because we do math on that later. We have to do some
* extra validation and checks on those two.
*
* It's tempting to make these match the request check above, but some of these values require
* extra work to make sure the data makes sense.
*/
$this->conditionallyAddItem('name')
->conditionallyAddItem('purchase_date')
->conditionallyAddItem('expected_checkin') ->conditionallyAddItem('expected_checkin')
->conditionallyAddItem('order_number') ->conditionallyAddItem('order_number')
->conditionallyAddItem('requestable') ->conditionallyAddItem('requestable')
->conditionallyAddItem('status_id')
->conditionallyAddItem('supplier_id') ->conditionallyAddItem('supplier_id')
->conditionallyAddItem('warranty_months') ->conditionallyAddItem('warranty_months')
->conditionallyAddItem('next_audit_date'); ->conditionallyAddItem('next_audit_date');
@ -170,6 +271,14 @@ class BulkAssetsController extends Controller
$this->conditionallyAddItem($custom_field_column); $this->conditionallyAddItem($custom_field_column);
} }
/**
* Blank out fields that were requested to be blanked out via checkbox
*/
if ($request->input('null_name')=='1') {
$this->update_array['name'] = null;
}
if ($request->input('null_purchase_date')=='1') { if ($request->input('null_purchase_date')=='1') {
$this->update_array['purchase_date'] = null; $this->update_array['purchase_date'] = null;
} }
@ -186,7 +295,6 @@ class BulkAssetsController extends Controller
$this->update_array['purchase_cost'] = $request->input('purchase_cost'); $this->update_array['purchase_cost'] = $request->input('purchase_cost');
} }
if ($request->filled('company_id')) { if ($request->filled('company_id')) {
$this->update_array['company_id'] = $request->input('company_id'); $this->update_array['company_id'] = $request->input('company_id');
if ($request->input('company_id') == 'clear') { if ($request->input('company_id') == 'clear') {
@ -194,48 +302,93 @@ class BulkAssetsController extends Controller
} }
} }
/**
* We're trying to change the model ID - we need to do some extra checks here to make sure
* the custom field values work for the custom fieldset rules around this asset. Uniqueness
* and requiredness across the fieldset is particularly important, since those are
* fieldset-specific attributes.
*/
if ($request->filled('model_id')) {
$this->update_array['model_id'] = AssetModel::find($request->input('model_id'))->id;
}
/**
* We're trying to change the status ID - we need to do some extra checks here to
* make sure the status label type is one that makes sense for the state of the asset,
* for example, we shouldn't be able to make an asset archived if it's currently assigned
* to someone/something.
*/
if ($request->filled('status_id')) {
$updated_status = Statuslabel::find($request->input('status_id'));
// We cannot assign a non-deployable status type if the asset is already assigned.
// This could probably be added to a form request.
// If the asset isn't assigned, we don't care what the status is.
// Otherwise we need to make sure the status type is still a deployable one.
if (
($asset->assigned_to == '')
|| ($updated_status->deployable == '1') && ($asset->assetstatus->deployable == '1')
) {
$this->update_array['status_id'] = $updated_status->id;
}
}
/**
* We're changing the location ID - figure out which location we should apply
* this change to:
*
* 0 - RTD location only
* 1 - location ID and RTD location ID
* 2 - location ID only
*
* Note: this is kinda dumb and we should just use human-readable values IMHO. - snipe
*/
if ($request->filled('rtd_location_id')) { if ($request->filled('rtd_location_id')) {
if (($request->filled('update_real_loc')) && (($request->input('update_real_loc')) == '0')) { if (($request->filled('update_real_loc')) && (($request->input('update_real_loc')) == '0')) {
$this->update_array['rtd_location_id'] = $request->input('rtd_location_id'); $this->update_array['rtd_location_id'] = $request->input('rtd_location_id');
} }
if (($request->filled('update_real_loc')) && (($request->input('update_real_loc')) == '1')) { if (($request->filled('update_real_loc')) && (($request->input('update_real_loc')) == '1')) {
$this->update_array['location_id'] = $request->input('rtd_location_id'); $this->update_array['location_id'] = $request->input('rtd_location_id');
$this->update_array['rtd_location_id'] = $request->input('rtd_location_id'); $this->update_array['rtd_location_id'] = $request->input('rtd_location_id');
} }
if (($request->filled('update_real_loc')) && (($request->input('update_real_loc')) == '2')) { if (($request->filled('update_real_loc')) && (($request->input('update_real_loc')) == '2')) {
$this->update_array['location_id'] = $request->input('rtd_location_id'); $this->update_array['location_id'] = $request->input('rtd_location_id');
} }
} }
/**
* ------------------------------------------------------------------------------
* ANYTHING that happens past this foreach
* WILL NOT BE logged in the edit log_meta data
* ------------------------------------------------------------------------------
*/
$changed = []; $changed = [];
$asset = Asset::find($assetId);
foreach ($this->update_array as $key => $value) { foreach ($this->update_array as $key => $value) {
if ($this->update_array[$key] != $asset->{$key}) { if ($this->update_array[$key] != $asset->{$key}) {
$changed[$key]['old'] = $asset->{$key}; $changed[$key]['old'] = $asset->{$key};
$changed[$key]['new'] = $this->update_array[$key]; $changed[$key]['new'] = $this->update_array[$key];
} }
} }
if ($custom_fields_present) { /**
* Start all the custom fields shenanigans
*/
$model = $asset->model()->first(); // Does the model have a fieldset?
if ($asset->model->fieldset) {
foreach ($asset->model->fieldset->fields as $field) {
// Use the rules of the new model fieldsets if the model changed if ((array_key_exists($field->db_column, $this->update_array)) && ($field->field_encrypted == '1')) {
if ($request->filled('model_id')) { if (Gate::allows('admin')) {
$this->update_array['model_id'] = $request->input('model_id');
$model = \App\Models\AssetModel::find($request->input('model_id'));
}
// Make sure this model is valid
$assetCustomFields = ($model) ? $model->fieldset : null;
if ($assetCustomFields && $assetCustomFields->fields) {
foreach ($assetCustomFields->fields as $field) {
if ((array_key_exists($field->db_column, $this->update_array)) && ($field->field_encrypted=='1')) {
$decrypted_old = Helper::gracefulDecrypt($field, $asset->{$field->db_column}); $decrypted_old = Helper::gracefulDecrypt($field, $asset->{$field->db_column});
/* /*
@ -246,7 +399,7 @@ class BulkAssetsController extends Controller
* but it wasn't. * but it wasn't.
*/ */
if ($decrypted_old != $this->update_array[$field->db_column]) { if ($decrypted_old != $this->update_array[$field->db_column]) {
$asset->{$field->db_column} = \Crypt::encrypt($this->update_array[$field->db_column]); $asset->{$field->db_column} = Crypt::encrypt($this->update_array[$field->db_column]);
} else { } else {
/* /*
* Remove the encrypted custom field from the update_array, since nothing changed * Remove the encrypted custom field from the update_array, since nothing changed
@ -258,9 +411,9 @@ class BulkAssetsController extends Controller
/* /*
* These custom fields aren't encrypted, just carry on as usual * These custom fields aren't encrypted, just carry on as usual
*/ */
}
} else { } else {
if ((array_key_exists($field->db_column, $this->update_array)) && ($asset->{$field->db_column} != $this->update_array[$field->db_column])) { if ((array_key_exists($field->db_column, $this->update_array)) && ($asset->{$field->db_column} != $this->update_array[$field->db_column])) {
// Check if this is an array, and if so, flatten it // Check if this is an array, and if so, flatten it
@ -273,9 +426,7 @@ class BulkAssetsController extends Controller
} }
} // endforeach } // endforeach
} // end custom field check }
} // end custom fields handler
// Check if it passes validation, and then try to save // Check if it passes validation, and then try to save
@ -312,9 +463,8 @@ class BulkAssetsController extends Controller
/** /**
* Adds parameter to update array for an item if it exists in request * Adds parameter to update array for an item if it exists in request
* @param string $field field name * @param string $field field name
* @return BulkAssetsController Model for Chaining
*/ */
protected function conditionallyAddItem($field) protected function conditionallyAddItem($field) : BulkAssetsController
{ {
if (request()->filled($field)) { if (request()->filled($field)) {
$this->update_array[$field] = request()->input($field); $this->update_array[$field] = request()->input($field);
@ -328,12 +478,10 @@ class BulkAssetsController extends Controller
* *
* @author [A. Gianotto] [<snipe@snipe.net>] * @author [A. Gianotto] [<snipe@snipe.net>]
* @param Request $request * @param Request $request
* @return View
* @throws \Illuminate\Auth\Access\AuthorizationException
* @internal param array $assets * @internal param array $assets
* @since [v2.0] * @since [v2.0]
*/ */
public function destroy(Request $request) public function destroy(Request $request) : RedirectResponse
{ {
$this->authorize('delete', Asset::class); $this->authorize('delete', Asset::class);
@ -345,12 +493,7 @@ class BulkAssetsController extends Controller
if ($request->filled('ids')) { if ($request->filled('ids')) {
$assets = Asset::find($request->get('ids')); $assets = Asset::find($request->get('ids'));
foreach ($assets as $asset) { foreach ($assets as $asset) {
$update_array['deleted_at'] = date('Y-m-d H:i:s'); $asset->delete();
$update_array['assigned_to'] = null;
DB::table('assets')
->where('id', $asset->id)
->update($update_array);
} // endforeach } // endforeach
return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success')); return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success'));
@ -362,27 +505,23 @@ class BulkAssetsController extends Controller
/** /**
* Show Bulk Checkout Page * Show Bulk Checkout Page
* @return View View to checkout multiple assets
*/ */
public function showCheckout() public function showCheckout() : View
{ {
$this->authorize('checkout', Asset::class); $this->authorize('checkout', Asset::class);
// Filter out assets that are not deployable.
return view('hardware/bulk-checkout'); return view('hardware/bulk-checkout');
} }
/** /**
* Process Multiple Checkout Request * Process Multiple Checkout Request
* @return View
*/ */
public function storeCheckout(AssetCheckoutRequest $request) public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse | ModelNotFoundException
{ {
$this->authorize('checkout', Asset::class); $this->authorize('checkout', Asset::class);
try { try {
$admin = Auth::user(); $admin = auth()->user();
$target = $this->determineCheckoutTarget(); $target = $this->determineCheckoutTarget();
@ -441,9 +580,11 @@ class BulkAssetsController extends Controller
} }
} }
public function restore(Request $request) { public function restore(Request $request) : RedirectResponse
{
$this->authorize('update', Asset::class); $this->authorize('update', Asset::class);
$assetIds = $request->get('ids'); $assetIds = $request->get('ids');
if (empty($assetIds)) { if (empty($assetIds)) {
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.restore.nothing_updated')); return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.restore.nothing_updated'));
} else { } else {

View file

@ -5,7 +5,7 @@ namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class ForgotPasswordController extends Controller class ForgotPasswordController extends Controller
{ {
/* /*
@ -79,16 +79,16 @@ class ForgotPasswordController extends Controller
) )
); );
} catch(\Exception $e) { } catch(\Exception $e) {
\Log::info('Password reset attempt: User '.$request->input('username').'failed with exception: '.$e ); Log::info('Password reset attempt: User '.$request->input('username').'failed with exception: '.$e );
} }
// Prevent timing attack to enumerate users. // Prevent timing attack to enumerate users.
usleep(500000 + random_int(0, 1500000)); usleep(500000 + random_int(0, 1500000));
if ($response === \Password::RESET_LINK_SENT) { if ($response === \Password::RESET_LINK_SENT) {
\Log::info('Password reset attempt: User '.$request->input('username').' WAS found, password reset sent'); Log::info('Password reset attempt: User '.$request->input('username').' WAS found, password reset sent');
} else { } else {
\Log::info('Password reset attempt: User matching username '.$request->input('username').' NOT FOUND or user is inactive'); Log::info('Password reset attempt: User matching username '.$request->input('username').' NOT FOUND or user is inactive');
} }
/** /**

View file

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\SamlNonce;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User; use App\Models\User;
use App\Models\Ldap; use App\Models\Ldap;
@ -15,7 +16,7 @@ use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Log; use Illuminate\Support\Facades\Log;
use Redirect; use Redirect;
/** /**
@ -56,7 +57,6 @@ class LoginController extends Controller
parent::__construct(); parent::__construct();
$this->middleware('guest', ['except' => ['logout', 'postTwoFactorAuth', 'getTwoFactorAuth', 'getTwoFactorEnroll']]); $this->middleware('guest', ['except' => ['logout', 'postTwoFactorAuth', 'getTwoFactorAuth', 'getTwoFactorEnroll']]);
Session::put('backUrl', \URL::previous()); Session::put('backUrl', \URL::previous());
// $this->ldap = $ldap;
$this->saml = $saml; $this->saml = $saml;
} }
@ -82,7 +82,6 @@ class LoginController extends Controller
} }
if (Setting::getSettings()->login_common_disabled == '1') { if (Setting::getSettings()->login_common_disabled == '1') {
\Log::debug('login_common_disabled is set to 1 - return a 403');
return view('errors.403'); return view('errors.403');
} }
@ -111,24 +110,35 @@ class LoginController extends Controller
try { try {
$user = $saml->samlLogin($samlData); $user = $saml->samlLogin($samlData);
$notValidAfter = new \Carbon\Carbon(@$samlData['assertionNotOnOrAfter']);
if(\Carbon::now()->greaterThanOrEqualTo($notValidAfter)) {
abort(400,"Expired SAML Assertion");
}
if(SamlNonce::where('nonce', @$samlData['nonce'])->count() > 0) {
abort(400,"Assertion has already been used");
}
Log::debug("okay, fine, this is a new nonce then. Good for you.");
if (!is_null($user)) { if (!is_null($user)) {
Auth::login($user); Auth::login($user);
} else { } else {
$username = $saml->getUsername(); $username = $saml->getUsername();
\Log::debug("SAML user '$username' could not be found in database."); Log::debug("SAML user '$username' could not be found in database.");
$request->session()->flash('error', trans('auth/message.signin.error')); $request->session()->flash('error', trans('auth/message.signin.error'));
$saml->clearData(); $saml->clearData();
} }
if ($user = Auth::user()) { if ($user = auth()->user()) {
$user->last_login = \Carbon::now(); $user->last_login = \Carbon::now();
$user->save(); $user->saveQuietly();
} }
$s = new SamlNonce();
$s->nonce = @$samlData['nonce'];
$s->not_valid_after = $notValidAfter;
$s->save();
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('There was an error authenticating the SAML user: '.$e->getMessage()); Log::debug('There was an error authenticating the SAML user: '.$e->getMessage());
throw new \Exception($e->getMessage()); throw $e;
} }
// Fallthrough with better logging // Fallthrough with better logging
@ -136,7 +146,7 @@ class LoginController extends Controller
// Better logging // Better logging
if (empty($samlData)) { if (empty($samlData)) {
\Log::debug("SAML page requested, but samlData seems empty."); Log::debug("SAML page requested, but samlData seems empty.");
} }
} }
@ -199,7 +209,7 @@ class LoginController extends Controller
$user->email = $ldap_attr['email']; $user->email = $ldap_attr['email'];
$user->first_name = $ldap_attr['firstname']; $user->first_name = $ldap_attr['firstname'];
$user->last_name = $ldap_attr['lastname']; //FIXME (or TODO?) - do we need to map additional fields that we now support? E.g. country, phone, etc. $user->last_name = $ldap_attr['lastname']; //FIXME (or TODO?) - do we need to map additional fields that we now support? E.g. country, phone, etc.
$user->save(); $user->saveQuietly();
} // End if(!user) } // End if(!user)
return $user; return $user;
} }
@ -251,19 +261,19 @@ class LoginController extends Controller
/** /**
* Account sign in form processing. * Account sign in form processing.
* *
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function login(Request $request) public function login(Request $request)
{ {
//If the environment is set to ALWAYS require SAML, return access denied //If the environment is set to ALWAYS require SAML, return access denied
if (config('app.require_saml')) { if (config('app.require_saml')) {
\Log::debug('require SAML is enabled in the .env - return a 403'); Log::debug('require SAML is enabled in the .env - return a 403');
return view('errors.403'); return view('errors.403');
} }
if (Setting::getSettings()->login_common_disabled == '1') { if (Setting::getSettings()->login_common_disabled == '1') {
\Log::debug('login_common_disabled is set to 1 - return a 403'); Log::debug('login_common_disabled is set to 1 - return a 403');
return view('errors.403'); return view('errors.403');
} }
@ -316,10 +326,10 @@ class LoginController extends Controller
} }
} }
if ($user = Auth::user()) { if ($user = auth()->user()) {
$user->last_login = \Carbon::now(); $user->last_login = \Carbon::now();
$user->activated = 1; $user->activated = 1;
$user->save(); $user->saveQuietly();
} }
// Redirect to the users page // Redirect to the users page
return redirect()->intended()->with('success', trans('auth/message.signin.success')); return redirect()->intended()->with('success', trans('auth/message.signin.success'));
@ -329,7 +339,7 @@ class LoginController extends Controller
/** /**
* Two factor enrollment page * Two factor enrollment page
* *
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function getTwoFactorEnroll() public function getTwoFactorEnroll()
{ {
@ -340,7 +350,7 @@ class LoginController extends Controller
} }
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$user = Auth::user(); $user = auth()->user();
// We wouldn't normally see this page if 2FA isn't enforced via the // We wouldn't normally see this page if 2FA isn't enforced via the
// \App\Http\Middleware\CheckForTwoFactor middleware AND if a device isn't enrolled, // \App\Http\Middleware\CheckForTwoFactor middleware AND if a device isn't enrolled,
@ -371,7 +381,7 @@ class LoginController extends Controller
[-2, -2, -2, -2] [-2, -2, -2, -2]
); );
$user->save(); // make sure to save *AFTER* displaying the barcode, or else we might save a two_factor_secret that we never actually displayed to the user if the barcode fails $user->saveQuietly(); // make sure to save *AFTER* displaying the barcode, or else we might save a two_factor_secret that we never actually displayed to the user if the barcode fails
return view('auth.two_factor_enroll')->with('barcode_obj', $barcode_obj); return view('auth.two_factor_enroll')->with('barcode_obj', $barcode_obj);
} }
@ -379,7 +389,7 @@ class LoginController extends Controller
/** /**
* Two factor code form page * Two factor code form page
* *
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function getTwoFactorAuth() public function getTwoFactorAuth()
{ {
@ -388,7 +398,7 @@ class LoginController extends Controller
return redirect()->route('login')->with('error', trans('auth/general.login_prompt')); return redirect()->route('login')->with('error', trans('auth/general.login_prompt'));
} }
$user = Auth::user(); $user = auth()->user();
// Check whether there is a device enrolled. // Check whether there is a device enrolled.
// This *should* be handled via the \App\Http\Middleware\CheckForTwoFactor middleware // This *should* be handled via the \App\Http\Middleware\CheckForTwoFactor middleware
@ -405,7 +415,7 @@ class LoginController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function postTwoFactorAuth(Request $request) public function postTwoFactorAuth(Request $request)
{ {
@ -417,19 +427,15 @@ class LoginController extends Controller
return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.code_required')); return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.code_required'));
} }
if (! $request->has('two_factor_secret')) { // TODO this seems almost the same as above? $user = auth()->user();
return redirect()->route('two-factor')->with('error', 'Two-factor code is required.');
}
$user = Auth::user();
$secret = $request->input('two_factor_secret'); $secret = $request->input('two_factor_secret');
if (Google2FA::verifyKey($user->two_factor_secret, $secret)) { if (Google2FA::verifyKey($user->two_factor_secret, $secret)) {
$user->two_factor_enrolled = 1; $user->two_factor_enrolled = 1;
$user->save(); $user->saveQuietly();
$request->session()->put('2fa_authed', $user->id); $request->session()->put('2fa_authed', $user->id);
return redirect()->route('home')->with('success', 'You are logged in!'); return redirect()->route('home')->with('success', trans('auth/message.signin.success'));
} }
return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.invalid_code')); return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.invalid_code'));
@ -441,7 +447,7 @@ class LoginController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Redirect * @return Illuminate\Http\RedirectResponse
*/ */
public function logout(Request $request) public function logout(Request $request)
{ {
@ -502,8 +508,8 @@ class LoginController extends Controller
protected function validator(array $data) protected function validator(array $data)
{ {
return Validator::make($data, [ return Validator::make($data, [
'username' => 'required', 'username' => 'required|not_array',
'password' => 'required', 'password' => 'required|not_array',
]); ]);
} }
@ -527,7 +533,7 @@ class LoginController extends Controller
$minutes = round($seconds / 60); $minutes = round($seconds / 60);
$message = \Lang::get('auth/message.throttle', ['minutes' => $minutes]); $message = trans('auth/message.throttle', ['minutes' => $minutes]);
return redirect()->back() return redirect()->back()
->withInput($request->only($this->username(), 'remember')) ->withInput($request->only($this->username(), 'remember'))

View file

@ -7,7 +7,7 @@ use App\Models\Setting;
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Auth\ResetsPasswords; use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class ResetPasswordController extends Controller class ResetPasswordController extends Controller
{ {
@ -66,7 +66,7 @@ class ResetPasswordController extends Controller
$credentials = $request->only('email', 'token'); $credentials = $request->only('email', 'token');
if (is_null($this->broker()->getUser($credentials))) { if (is_null($this->broker()->getUser($credentials))) {
\Log::debug('Password reset form FAILED - this token is not valid.'); Log::debug('Password reset form FAILED - this token is not valid.');
return redirect()->route('password.request')->with('error', trans('passwords.token')); return redirect()->route('password.request')->with('error', trans('passwords.token'));
} }
@ -87,12 +87,12 @@ class ResetPasswordController extends Controller
'password.not_in' => trans('validation.disallow_same_pwd_as_user_fields'), 'password.not_in' => trans('validation.disallow_same_pwd_as_user_fields'),
]; ];
$request->validate($this->rules(), $request->all(), $this->validationErrorMessages()); $request->validate($this->rules());
\Log::debug('Checking if '.$request->input('username').' exists'); Log::debug('Checking if '.$request->input('username').' exists');
// Check to see if the user even exists - we'll treat the response the same to prevent user sniffing // Check to see if the user even exists - we'll treat the response the same to prevent user sniffing
if ($user = User::where('username', '=', $request->input('username'))->where('activated', '1')->whereNotNull('email')->first()) { if ($user = User::where('username', '=', $request->input('username'))->where('activated', '1')->whereNotNull('email')->first()) {
\Log::debug($user->username.' exists'); Log::debug($user->username.' exists');
// handle the password validation rules set by the admin settings // handle the password validation rules set by the admin settings
@ -112,17 +112,17 @@ class ResetPasswordController extends Controller
// Check if the password reset above actually worked // Check if the password reset above actually worked
if ($response == \Password::PASSWORD_RESET) { if ($response == \Password::PASSWORD_RESET) {
\Log::debug('Password reset for '.$user->username.' worked'); Log::debug('Password reset for '.$user->username.' worked');
return redirect()->guest('login')->with('success', trans('passwords.reset')); return redirect()->guest('login')->with('success', trans('passwords.reset'));
} }
\Log::debug('Password reset for '.$user->username.' FAILED - this user exists but the token is not valid'); Log::debug('Password reset for '.$user->username.' FAILED - this user exists but the token is not valid');
return redirect()->back()->withInput($request->only('email'))->with('success', trans('passwords.reset')); return redirect()->back()->withInput($request->only('email'))->with('success', trans('passwords.reset'));
} }
\Log::debug('Password reset for '.$request->input('username').' FAILED - user does not exist or does not have an email address - but make it look like it succeeded'); Log::debug('Password reset for '.$request->input('username').' FAILED - user does not exist or does not have an email address - but make it look like it succeeded');
return redirect()->guest('login')->with('success', trans('passwords.reset')); return redirect()->guest('login')->with('success', trans('passwords.reset'));
} }

View file

@ -5,7 +5,7 @@ namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Services\Saml; use App\Services\Saml;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Log; use Illuminate\Support\Facades\Log;
/** /**
* This controller provides the endpoint for SAML communication and metadata. * This controller provides the endpoint for SAML communication and metadata.
@ -51,7 +51,7 @@ class SamlController extends Controller
$metadata = $this->saml->getSPMetadata(); $metadata = $this->saml->getSPMetadata();
if (empty($metadata)) { if (empty($metadata)) {
\Log::debug('SAML metadata is empty - return a 403'); Log::debug('SAML metadata is empty - return a 403');
return response()->view('errors.403', [], 403); return response()->view('errors.403', [], 403);
} }
@ -71,7 +71,7 @@ class SamlController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function login(Request $request) public function login(Request $request)
{ {
@ -93,18 +93,24 @@ class SamlController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function acs(Request $request) public function acs(Request $request)
{ {
$saml = $this->saml; $saml = $this->saml;
$auth = $saml->getAuth(); $auth = $saml->getAuth();
$saml_exception = false;
try {
$auth->processResponse(); $auth->processResponse();
} catch (\Exception $e) {
Log::warning("Exception caught in SAML login: " . $e->getMessage());
$saml_exception = true;
}
$errors = $auth->getErrors(); $errors = $auth->getErrors();
if (! empty($errors)) { if (!empty($errors) || $saml_exception) {
Log::error('There was an error with SAML ACS: '.implode(', ', $errors)); Log::warning('There was an error with SAML ACS: ' . implode(', ', $errors));
Log::error('Reason: '.$auth->getLastErrorReason()); Log::warning('Reason: ' . $auth->getLastErrorReason());
return redirect()->route('login')->with('error', trans('auth/message.signin.error')); return redirect()->route('login')->with('error', trans('auth/message.signin.error'));
} }
@ -126,18 +132,24 @@ class SamlController extends Controller
* *
* @param Request $request * @param Request $request
* *
* @return Redirect * @return \Illuminate\Http\RedirectResponse
*/ */
public function sls(Request $request) public function sls(Request $request)
{ {
$auth = $this->saml->getAuth(); $auth = $this->saml->getAuth();
$retrieveParametersFromServer = $this->saml->getSetting('retrieveParametersFromServer', false); $retrieveParametersFromServer = $this->saml->getSetting('retrieveParametersFromServer', false);
$saml_exception = false;
try {
$sloUrl = $auth->processSLO(true, null, $retrieveParametersFromServer, null, true); $sloUrl = $auth->processSLO(true, null, $retrieveParametersFromServer, null, true);
} catch (\Exception $e) {
Log::warning("Exception caught in SAML single-logout: " . $e->getMessage());
$saml_exception = true;
}
$errors = $auth->getErrors(); $errors = $auth->getErrors();
if (! empty($errors)) { if (!empty($errors) || $saml_exception) {
Log::error('There was an error with SAML SLS: '.implode(', ', $errors)); Log::warning('There was an error with SAML SLS: ' . implode(', ', $errors));
Log::error('Reason: '.$auth->getLastErrorReason()); Log::warning('Reason: ' . $auth->getLastErrorReason());
return view('errors.403'); return view('errors.403');
} }

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