Snipe is a great open source asset management tool ideal for organisations and educational environments where you want to be able to lend out devices and track maintenance schedules. I’ve posted a few articles about how to configure Snipe already and in this article I’ll look at how to customize the emails that Snipe sends out, particularly the email receipts when someone checks in or out an asset.
In my previous guide I’ve looked at installing Snipe on Ubuntu, so I’ll carry on working on my Ubuntu box. If you are running on Snipe on Windows, or you’ve installed it in a non-default directory, then the following guide should give you a rough idea as to where to look and you’ll need to adjust the locations based on your setup.
[message type=”error” title=”Warning”]Future Snipe updates may overwrite your modified files. Be sure to grab a backup of your changes so that you can easily restore them if you need to. [/message]
The template files
Snipe uses templates heavily so that you can customize a number of its emails and pages. Here’s a rough list of the email templates and their file names. The paths are relative to the Snipe install folder so in our case they all start /var/www/snipeit/.
The header used in every email, /app/views/emails/layouts/default.blade.php
When a user receives or accepts a loan device,/app/views/emails/accept-asset.blade.php
When a user requests a loan device,/app/views/emails/asset-requested.blade.php
When a user checks in a loan device,/app/views/emails/checkin-asset.blade.php
When the loan period of a device is about to expire,/app/views/emails/expiring-assets-report.blade.php
When the loan period of a license is about to expire,/app/views/emails/expiring-licenses-report.blade.php
When the user requests a password change, /app/views/emails/forgot-password.blade.php
When the user registers or activates their account, /app/views/emails/register-activate.blade.php
When an administrator creates an account for a user, /app/views/emails/send-login.blade.php
Editing the templates
I’ll be using Emacs here as my editor in Ubuntu but feel free to use whatever editor you like. One that’s available on every system is vi, but you’ll want to open up this list of handy vi commands if you don’t know it.
- So assuming you’ve logged on to your Ubuntu server, let’s change to that base directory.
- I want to my logo to the header of each email so let’s first make a copy of the default email blade file.
- Next lets open up the default blade file.
- Now you can see the default.blade.php file where you can add elements to the top of your emails. To add an image to the top of your emails you can add the following line just before the @yield line.
- Finally, copy the default blade template file to your Home directory just in case an update overwrites it.
cp /app/views/emails/layouts/default.blade.php ~
- When you next check in or check out an email your email should show you a lovely logo.
cp /app/views/emails/layouts/default.blade.php /app/views/emails/layouts/default.blade.php.bak
sudo emacs /app/views/emails/layouts/default.blade.php
It should look like this