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");}
    Delete jobs with a large number of pages.
    if ($this->pageCount>500) {$this->delete();}

  • Actions based on the size of the job
    Move large jobs to a dedicated queue.
    if ($this->dataSize>1000000) {$this->moveToQueue("LargeJobs");}
    Delete oversize jobs.
    if ($this->dataSize>5000000) {$this->delete();}

  • Actions based on paper format
    Move jobs with the a3 paper format to a dedicate queue.
    if ($this->paper===6) {$this->moveToQueue("LargePaperFormat");}

  • 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");}
    Change the owner of the job.
    if ($this->owner->name==="eliot.kate")
    {$this->owner=MyQ()->getUserByUserName("simon.kate");}

  • Actions based on the duplex property
    Move duplex jobs to a duplex queue.
    if ($this->duplex) {$this->moveToQueue("Duplex");}
    Move simplex jobs to a simplex queue.
    if ($this->duplex===false) {$this->moveToQueue("Simplex");}

  • Actions based on the color property
    Move color jobs to a color queue.
    if ($this->color) {$this->moveToQueue("Color");}

  • 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");}
    Delete jobs sent from Facebook.
    if (strpos($this->name,'Facebook')!==false) {$this->delete();}

  • Actions based on the rights to a queue
    Move jobs of users who are not alowed to print to one queue to a different queue
    if ($this->owner->canPrintToQueue(Color)===false)
    {$this->moveToQueue(Monochrome);}

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

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

  • Sending custom log messages to MyQ
    Send a log info message to MyQ Log
    MyQ()->logInfo("This message appears in the MyQ log.");

  • Complex actions

    • If number of pages multiplied by number of copies exceed 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.");
      }

    • Send color jobs to a dedicated queue; if the job owner does not have rights to this queue, delete the job and inform the user
      // if the job is color, perform the next action
      if ($this->color) {
      // if the owner has rights to the queue, move the job to the Color queue
      if ($this->owner->canPrintToQueue("Color")) {
      $this->moveToQueue("Color"); }
      // if they don't have rights to the queue, delete the job and inform the user
      else {
      $this->owner->sendNotification("error","Job refused", "Color printing denied");
      $this->delete(); }}