Jump to content

Recommended Posts

Posted

[h=2]PaperCut Script Monthly Group Color Limit[/h]1lg.php?bt=de&bbannerid=0&campaignid=0&zoneid=46&source={obfs:}&loc=https%3A%2F%2Fwww.edugeek.net%2Fforums%2Fnetwork-classroom-management%2F240230-papercut-script-monthly-group-color-limit.html%23post2054811&referer=https%3A%2F%2Fwww.edugeek.net%2Fnewthread.php%3Fdo%3Dnewthread%26f%3D59&cb=9e6959a142

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
)
;

 

}

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...