user.php 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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,$userid);
  12. ?>
  13. <center><table width="690px" border="0px" cellspacing="0px" cellpadding="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="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>pages</b></font><font color="#ff8000">]</font></td>
  17. <td width="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>price</b></font><font color="#ff8000">]</font></td>
  18. <td width="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>print</b></font><font color="#ff8000">]</font></td>
  19. <td width="70px"><font color="#ff8000">[</font><font face="helvetica"color="#ffffff"><b>cancel</b></font><font color="#ff8000">]</font></td>
  20. </tr>
  21. <?
  22. $err = $output[0];
  23. $output = $output[1];
  24. if($err!=0){?>
  25. <tr bgcolor="#000000"><td colspan=5><font face="helvetica" color="#ffffff">
  26. <?if($err == 1){ echo "Invalid task specification";}
  27. else if($err == 2){ echo "No jobs";}
  28. else if($err == 15){ echo "Connection to cups failed";} ?>
  29. </font></td></tr>
  30. <?}else{
  31. foreach($output as $string){?>
  32. <tr bgcolor="000000">
  33. <?list($id, $author, $hostname, $title, $pages) = split("\t", $string, 5);?>
  34. <!-- title of the document -->
  35. <td><font face="helvetica"color="#ffffff"><?echo $title;?></font></td>
  36. <!-- number of pages in document -->
  37. <td align="center"><font face="helvetica"color="#ffffff"><? $pages = count_pages($ssh_con, $id); echo $pages;?></font></td>
  38. <!--price for job -->
  39. <td align="center"><? $price_for_job = $pages* $price;
  40. $user_bill = check_bill($userid);?>
  41. <font color=<?if($user_bill < $price_for_job)echo "#ff0000"; else echo "#33CC00"; ?>>
  42. <?echo echo_price($price_for_job);?></font>
  43. </td>
  44. <!-- button which allows print -->
  45. <td align="center"><form method="POST" action=<?echo $_SERVER['PHP_SELF'];?> >
  46. <input type="hidden" name="userid" value=<?echo $userid?>>
  47. <input type="hidden" name="job" value=<?echo $id?>>
  48. <input type="hidden" name="do" value="allow">
  49. <? if($user_bill >= $price_for_job){?> <input type="hidden" name="price" value=<?echo $price_for_job?>> <?}?>
  50. <input type="submit" name="<?if($_REQUEST['operator_as_user_x']!='') echo "operator_as_user_x"?>" value="ok" <?if($user_bill < $price_for_job) echo "disabled";?> >
  51. </form>
  52. </td>
  53. <!-- button which denies print -->
  54. <td align="center"><form method="POST" action=<?echo $_SERVER['PHP_SELF'];?> >
  55. <input type="hidden" name="userid" value=<?echo $userid?>>
  56. <input type="hidden" name="job" value=<?echo $id?>>
  57. <input type="hidden" name="do" value="deny">
  58. <input type="submit" name="<?if($_REQUEST['operator_as_user_x']!='') echo "operator_as_user_x"?>" value="cancel">
  59. <!-- <input type="image" src="images/delete.gif" name="allow"> -->
  60. </form>
  61. </td>
  62. </tr>
  63. <?} //foreach?>
  64. <?} //else if ?>