Jump to content

Papercut Scripting - Help Required


Recommended Posts

Posted

Hi All,

 

We are in need of a script that we can apply to certain printers that will do the following:

 

When a user prints it will popup an window to say that they have exceeded their quota and to request more balance press the "Request Balance" button below which will email the support team and we can action a top-up balance. The email needs to contain the the username and the number of pages they tries to print, colour of mono type job, just so we can work out how much to top-up by.

 

Any Help would be great thanks :-)

Posted (edited)

Hiya,

 

Try something like this

 

function printJobHook(inputs, actions) {

 if (!inputs.job.isAnalysisComplete) { return; }

 var EMAIL = "[email protected]";
 var SUBJECT = "Print Credit Request";
 var MESSAGE = "You have exceeded your balance, Would you like some more credit?";
 
 // If job cost is more than users balance
 if (inputs.job.cost > inputs.user.balance) {
 
   // Show the prompt
   var response = actions.client.promptYesNo(MESSAGE);
 
   // If they press yes
   if (response == "YES") {
     // Send an email
     // $USERNAME is trying to print XX colour pages and XX grayscale pages. The total job cost is XX but the user only has XX available.
     actions.utils.sendEmail(EMAIL, SUBJECT, inputs.job.username + " is trying to print " + inputs.job.totalColorPages + " colour pages and " + inputs.job.totalGrayscalePages + " grayscale pages. The total job cost is " + inputs.job.cost + " but the user only has " + inputs.user.balance + " available." );
   }
 
   // Always cancel the job if they don't have enough credit
   actions.job.cancel();
 }

}

Edited by Big_Ted
added code
Posted
Will give it try but but will actions.client only work with the pop up client? Looking for more generic html rendered page if poss so it will work on most platforms....

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...