Jump to content

jjulien

Members
  • Posts

    5
  • Joined

  • Last visited

Reputation

5 Neutral

About jjulien

  1. Hi PaperCutterAI, That worked with some tweaking. There was a missing closed parenthesis and I changed the remaining "group" to "user" and it was able to cancel the job after reaching the monthly group limit. Now, I need to test either sending a denied email or popup notification. Thanks, Judy
  2. [h=2]PaperCut Script Monthly Group Color Limit[/h] I want to limit the number of monthly color printing for a specific group. I edited the daily color limit script but I'd like to make sure it's correct before testing. My concern is the !inputs.user.isInGroup() group code. I want the 200 monthly limit to apply to the group and not to the individual. So, if the group color count hits 200 then no one in the group can no longer print. I'd also like to know if I have the monthly code correct as well. Thanks! /* * Monthly color page limit * * Sometimes, a high price tag just isn't enough to discourage users from * printing in color. This recipe imposes a fixed limit on the number of color * pages a user can print per month. * * Imposing a color page quota is a better solution than separate balances for * color and black & white. Separate balances are more confusing (two accounts * to manage) and also can lead to waste. The user may for example run out of * black and white credit, and therefore be forced to print in color wasting * resources. This method (an overlayed color quota) solves these issues. */ function printJobHook(inputs, actions) { // Modify this value to change the daily color page limit. var MAX_COLOR_PAGES_PER_MONTH = 200; if (!inputs.job.isAnalysisComplete) { return; } if (!inputs.job.isColor) { // Not color so no need to check and apply any limits. return; } if (!inputs.user.isInGroup == "GroupName") { // return; } var currentColorCount = inputs.user.getNumberProperty("color-per-month"); if (currentColorCount == null) currentColorCount = 0; var currentMonthIndex = inputs.job.date.getMonth(); var monthLastSeen = inputs.group.getProperty("color-month-last-seen"); if (monthLastSeen == null || monthLastSeen != currentMonthIndex) { // It's a new month. Reset the current count value to zero. currentColorCount = 0; } currentColorCount += inputs.job.totalColorPages; if (currentColorCount > MAX_COLOR_PAGES_PER_MONTH) { var deniedMessage = "This print job has been denied. You have exceeded" + " your monthly limit of " + MAX_COLOR_PAGES_PER_MONTH + " color pages per month. Please print in grayscale."; actions.client.sendMessage(deniedMessage); actions.job.cancelAndLog("This job was denied because you have exceeded" + " the monthly color quota."); return; } // If we're here, then it's OK for the job to proceed. // Save the current monthly count actions.group.onCompletionSaveProperty("color-month-last-seen", currentMonthIndex); // Note: Set is used for simplicity (see "Rate limit by department" // for use of increment). actions.group.onCompletionSaveProperty("color-per-month", currentColorCount); }
  3. I want to limit the number of monthly color printing for a specific group. I edited the daily color limit script but I'd like to make sure it's correct before testing. My concern is the !inputs.user.isInGroup() group code. I want the 200 monthly limit to apply to the group and not to the individual. So, if the group color count hits 200 then no one in the group can no longer print. I'd also like to know if I have the monthly code correct as well. Thanks! /* * Monthly color page limit * * Sometimes, a high price tag just isn't enough to discourage users from * printing in color. This recipe imposes a fixed limit on the number of color * pages a user can print per month. * * Imposing a color page quota is a better solution than separate balances for * color and black & white. Separate balances are more confusing (two accounts * to manage) and also can lead to waste. The user may for example run out of * black and white credit, and therefore be forced to print in color wasting * resources. This method (an overlayed color quota) solves these issues. */ function printJobHook(inputs, actions) { // Modify this value to change the daily color page limit. var MAX_COLOR_PAGES_PER_MONTH = 200; if (!inputs.job.isAnalysisComplete) { return; } if (!inputs.job.isColor) { // Not color so no need to check and apply any limits. return; } if (!inputs.user.isInGroup == "GroupName") { // return; } var currentColorCount = inputs.user.getNumberProperty("color-per-month"); if (currentColorCount == null) currentColorCount = 0; var currentMonthIndex = inputs.job.date.getMonth(); var monthLastSeen = inputs.group.getProperty("color-month-last-seen"); if (monthLastSeen == null || monthLastSeen != currentMonthIndex) { // It's a new month. Reset the current count value to zero. currentColorCount = 0; } currentColorCount += inputs.job.totalColorPages; if (currentColorCount > MAX_COLOR_PAGES_PER_MONTH) { var deniedMessage = "This print job has been denied. You have exceeded" + " your monthly limit of " + MAX_COLOR_PAGES_PER_MONTH + " color pages per month. Please print in grayscale."; actions.client.sendMessage(deniedMessage); actions.job.cancelAndLog("This job was denied because you have exceeded" + " the monthly color quota."); return; } // If we're here, then it's OK for the job to proceed. // Save the current monthly count actions.group.onCompletionSaveProperty("color-month-last-seen", currentMonthIndex); // Note: Set is used for simplicity (see "Rate limit by department" // for use of increment). actions.group.onCompletionSaveProperty("color-per-month", currentColorCount); }​
  4. Thank you! This worked and I was able to add a snippet so that it sends them an email.
  5. I am trying to modify the daily color page limit script but I only want to restrict if for one person. What code can I use so that it targets a specific username? Here's the current script: /* * Daily color page limit * * Sometimes, a high price tag just isn't enough to discourage users from * printing in color. This recipe imposes a fixed limit on the number of color * pages a user can print per day. * * Imposing a color page quota is a better solution than separate balances for * color and black & white. Separate balances are more confusing (two accounts * to manage) and also can lead to waste. The user may for example run out of * black and white credit, and therefore be forced to print in color wasting * resources. This method (an overlayed color quota) solves these issues. */ function printJobHook(inputs, actions) { // Modify this value to change the daily color page limit. var MAX_COLOR_PAGES_PER_DAY = 20; if (!inputs.job.isAnalysisComplete) { return; } if (!inputs.job.isColor) { // Not color so no need to check and apply any limits. return; } var currentColorCount = inputs.user.getNumberProperty("color-per-day"); if (currentColorCount == null) currentColorCount = 0; var currentDayIndex = inputs.job.date.toDateString(); var dayLastSeen = inputs.user.getProperty("color-day-last-seen"); if (dayLastSeen == null || dayLastSeen != currentDayIndex) { // It's a new day. Reset the current count value to zero. currentColorCount = 0; } currentColorCount += inputs.job.totalColorPages; if (currentColorCount > MAX_COLOR_PAGES_PER_DAY) { var deniedMessage = "This print job has been denied. You have exceeded" + " your daily limit of " + MAX_COLOR_PAGES_PER_DAY + " color pages per day. Please print in grayscale."; actions.client.sendMessage(deniedMessage); actions.job.cancelAndLog("This job was denied because you have exceeded" + " the daily color quota."); return; } // If we're here, then it's OK for the job to proceed. // Save the current daily count actions.user.onCompletionSaveProperty("color-day-last-seen", currentDayIndex); // Note: Set is used for simplicity (see "Rate limit by department" // for use of increment). actions.user.onCompletionSaveProperty("color-per-day", currentColorCount); }
×
×
  • Create New...