Free Exam Time Printing PaperCut Script
The PaperCut script request…
Recently, we were asked for a PaperCut script that made print jobs sent to a particular printer free of charge during exam time. This is fairly standard practice (at least here, in the UK), exam time means extra user accounts (individual exam accounts) and free printing, oh and stress… lots and lots of stress.
We thought a simple way to achieve this would be to apply a 100% discount to jobs submitted to the queue based on a date range and give the user a little note to let them know how much they’d not been charged. As always, we put on our thinking caps, grabbed some roast ox crisps and came up with the following script.
The solution…
To begin with, we need to declare our variables and work out what our date range is for the Exams.
var day = inputs.job.date.getDate(); var month = inputs.job.date.getMonth(); if ((day >= 19 && month == 5) || (day <= 23 && month == 5)) {
So in the above example, we will be looking for any jobs submitted between the 19th and 23rd of June, (Yes June is 5, we start counting with January = 0, remember developers invented this system and they work in mysterious ways).
Then we must declare the cost and saving variables.
var newCost = inputs.job.cost * 0.00; var saving = inputs.job.cost - newCost;
Once we have done this, we need to add the actions to set the new job cost and define the message we will send to the user.
actions.job.setCost(newCost); actions.job.addComment("100% Exam time discount applied.");
Finally, we’d like to send the message to the user via the PaperCut client tool.
actions.client.sendMessage("You saved " + inputs.utils.formatCost(saving) + " printing your exam related job.");
The full script is below, feel free to tweak as needed. That, as they say, is a wrap, and as always if you need any further help with the above, or indeed any other scripts you may be working on then please, do drop us a line.
Get in touch today | sales@selectec.com
function printJobHook(inputs, actions) { if (!inputs.job.isAnalysisComplete) { return; } var day = inputs.job.date.getDate(); var month = inputs.job.date.getMonth(); if ((day >= 19 && month == 5) || (day <= 23 && month == 5)) { var newCost = inputs.job.cost * 0.00; var saving = inputs.job.cost - newCost; actions.job.setCost(newCost); actions.job.addComment("100% Exam time discount applied."); actions.client.sendMessage("You saved " + inputs.utils.formatCost(saving) + " printing your exam related job."); } }