In this section you can find examples covering a variety of job management options. These examples should give you an idea about how to use the PHP scripting in MyQ. You can also substitute the properties and methods in the examples to use them as building blocks of more complex scripts.

Actions based on the number of pages
Move jobs with a higher number of color pages to a monochrome queue.

if ($this->colorCount>20) {
 $this->moveToQueue("ForceMonochrome");
 }
PHP

Delete jobs with a large number of pages.

if ($this->pageCount>500) {
 $this->delete();
 }
PHP

Actions based on the size of the job
Move large jobs to a dedicated queue.

if ($this->dataSize>1000000) {
 $this->moveToQueue("LargeJobs");
 }
PHP

Delete oversized jobs.

if ($this->dataSize>5000000) {
 $this->delete();
 }
PHP

Actions based on paper format
Move jobs with the A3 paper format to a dedicated queue.

if ($this->paper===6) {
 $this->moveToQueue("LargePaperFormat");
 }
PHP

Actions based on the job owner
Move jobs of a certain owner to a dedicated queue.

if ($this->owner->name==="eliot.kate") {
 $this->moveToQueue("EliotKate");
 }
PHP

Change the owner of the job.

if ($this->owner->name==="eliot.kate") {
 $this->owner=MyQ()->getUserByUserName("simon.kate");
 }
PHP

Actions based on the duplex property
Move duplex jobs to a duplex queue.

if ($this->duplex) {
 $this->moveToQueue("Duplex");
 }
PHP

Move simplex jobs to a simplex queue.

if ($this->duplex===false) {
 $this->moveToQueue("Simplex");
 }
PHP

Actions based on the color property
Move color jobs to a color queue.

if ($this->color) {
 $this->moveToQueue("Color");
 }
PHP

Actions based on the job name or the source application
Move jobs printed in MS Word to a dedicated queue.

if (strpos($this->name,"Microsoft Word")!==false) {
 $this->moveToQueue("MSWord");
 }
PHP

Delete jobs sent from Facebook.

if (strpos($this->name,'Facebook')!==false) {
 $this->delete();
 }
PHP

Actions based on the rights to a queue
Move jobs of users who are not allowed to print to one queue to a different queue

if ($this->owner->canPrintToQueue(Color)===false) {
 $this->moveToQueue(Monochrome);
 }
PHP

Actions based on group membership
Move jobs sent by members of a group to a dedicated queue

if ($this->owner->hasGroup(Clerks)) {
 $this->moveToQueue(Clerks);
 }
PHP

Actions based on the PDL of the job
Move all jobs sent in a certain PDL to a dedicated queue

if ($this->lang===0) {
 $this->moveToQueue(UnknownPDL);
 }
PHP

Sending custom log messages to MyQ
Send a log info message to MyQ Log

MyQ()->logInfo("This message appears in the MyQ log.");
PHP

Complex actions

If the number of pages multiplied by the number of copies exceeds a certain number, delete the job and inform the user

// get the number of pages and the number of copies
$pages_number = $this->pageCount; $copies_number = $this->copies;
// if total (pagescopies) exceeds 500, delete the job and notify its owner
if ( $pages_number $copies_number>500) {
 $this->delete(); $this->owner->sendNotification("error","Job refused", "Cannot
 print jobs exceeding 500 pages.");
}
PHP

Move the job to a queue, if allowed

if ($this->color) {
  if ($this->owner->canPrintToQueue("JPS2")) {
     $this->moveToQueue("JPS2");
  } else {
     $this->owner->sendEmail("Job error", "Color printing denied");
     $this->delete();
  }
}
PHP

Move the job to the first available personal queue

// get all user's queues sorted by priority
$personalQueues = $this->owner->personalQueues;
 
// loop them
foreach ($personalQueues as $q) {
    // skip queue if no printer is available
    if ($q->isAnyPrinterAvailable() === false) {
        continue;
    }
 
    // queue printer is available, move job to queue
    $this->moveToQueue($q->name);
    // job is moved, stop the loop
    break;
}
PHP