operator.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?
  2. //we want to print certain job and pay for it
  3. if($_REQUEST['job']!='' && !strcmp(trim($_REQUEST['do']),'allow') && $_REQUEST['price']!='') {
  4. print_job($ssh_con, $_REQUEST['job'],$_REQUEST['price'], $userid);
  5. }
  6. //we want to deny some job
  7. else if($_REQUEST['job']!='' && !strcmp(trim($_REQUEST['do']),'deny')){
  8. cancel_job($ssh_con, $_REQUEST['job']);
  9. }
  10. //just show the queue of jobs
  11. $output = show_queue($ssh_con);
  12. ?>
  13. <center><table width="690px" cellpadding="0px" cellspacing="0px">
  14. <tr height="30px" align="center" bgcolor="#000000">
  15. <td><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>document title</b></font><font color="#ff8000">]</font></td>
  16. <td width="80px" align="left"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>User</b></font><font color="#ff8000">]</font></td>
  17. <td width="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>pages</b></font><font color="#ff8000">]</font></td>
  18. <td width="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>price</b></font><font color="#ff8000">]</font></td>
  19. <td width="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>print</b></font><font color="#ff8000">]</font></td>
  20. <td width="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>cancel</b></font><font color="#ff8000">]</font></td>
  21. </tr>
  22. <?
  23. $err = $output[0];
  24. $output = $output[1];
  25. if($err!=0){?>
  26. <tr bgcolor="#000000"><td colspan=6><font face="helvetica" color="#ffffff">
  27. <?if($err == 1){ echo "Invalid task specification";}
  28. else if($err == 2){ echo "No jobs";}
  29. else if($err == 15){ echo "Connection to cups failed";} ?>
  30. </font></td></tr>
  31. <?}else{
  32. foreach($output as $string){?>
  33. <tr bgcolor="#000000">
  34. <?list($id, $author, $hostname, $title, $pages) = split("\t", $string, 5);?>
  35. <!-- title of the document -->
  36. <td><font face="helvetica"color="#ffffff"><?echo $title;?></font></td>
  37. <!-- author of the document -->
  38. <td><font face="helvetica"color="#ffffff"><?echo $author;?></font></td>
  39. <!-- number of pages in document -->
  40. <td align="center"><font face="helvetica"color="#ffffff"><? $pages = count_pages($ssh_con, $id); echo $pages;?></font></td>
  41. <!--price for job -->
  42. <td align="center">
  43. <? /* check if user is an operator. For operators the priceis different */
  44. exec(UMS_UTILS_PATH . $UMS_UTILS['group'] . " check " . $MANAGING_GROUPS[0] . " " . $author, $output, $err);
  45. if($err == 0) {$price_for_job = $pages* $price_operator;} /* if this is an operator*/
  46. else $price_for_job = $pages* $price; /* if this is an ordinary user */
  47. $user_bill = check_bill(get_uid_by_username($author));?>
  48. <font color=<?if($user_bill < $price_for_job)echo "#ff0000"; else echo "#33CC00"; ?>>
  49. <?echo echo_price($price_for_job);?></font>
  50. </td>
  51. <!-- button which allows print -->
  52. <td align="center"><form method="POST" action=<?echo $_SERVER['PHP_SELF'];?> >
  53. <input type="hidden" name="userid" value=<?echo $userid?>>
  54. <input type="hidden" name="job" value=<?echo $id?>>
  55. <input type="hidden" name="do" value="allow">
  56. <? if($user_bill >= $price_for_job){?> <input type="hidden" name="price" value=<?echo $price_for_job?>> <?}?>
  57. <input type="submit" name="operator_as_operator_x" value="ok" <?if($user_bill < $price_for_job) echo "disabled";?>>
  58. </form>
  59. </td>
  60. <!-- button which denies print -->
  61. <td align="center"><form method="POST" action=<?echo $_SERVER['PHP_SELF'];?> >
  62. <input type="hidden" name="userid" value=<?echo $userid?>>
  63. <input type="hidden" name="job" value=<?echo $id?>>
  64. <input type="hidden" name="do" value="deny">
  65. <input type="submit" name="operator_as_operator_x" value="cancel">
  66. </form>
  67. </td>
  68. </tr>
  69. <?} //foreach?>
  70. <?} //else if ?>