andripzf

Untitled

May 3rd, 2014
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. if($geninvoice) {
  2. insert_query("tblinvoiceitems", array
  3. ("userid" => 1, "type" =>"Invoice", "relid" => $invoiceid, "description" => 1, "amount" => 1, "duedate" => "now()", "paymentmethod" => $paymentmethod));
  4. }
  5.  
  6. if($action == "masspay"){
  7. checkContactPermission("invoices");
  8. $ca->setTemplate("masspay");
  9.  
  10. if(!$CONFIG
  11. ['EnableMassPay']) {
  12. header("Location:
  13. clientarea.php");
  14. exit();
  15. }
  16.  
  17. if($all) {
  18. $invoiceids = array();
  19. $result = select_query("tblinvoices", "id",
  20. array("userid" => $client->getID(), "status" =>
  21. "Unpaid", "(select count
  22. (id) from tblinvoiceitems
  23. where
  24. invoiceid=tblinvoices.id
  25. and type='Invoice')" =>
  26. array("sqltype" => "<=",
  27. "value" => 0)), "id",
  28. "DESC");
  29. while($data = mysql_fetch_array($result)) {
  30. $invoiceids[] = $data['id'];
  31. }
  32. } else {
  33.  
  34. if(count($invoiceids) ==
  35. 0) {
  36. header("Location:
  37. clientarea.php");
  38. exit();
  39. }
  40.  
  41. if(count($invoiceids) ==
  42. 1) {
  43. header("Location:
  44. viewinvoice.php?id=".$invoiceids[0]);
  45. exit();
  46. }
  47. foreach($invoiceids as $k
  48. => $v) {
  49. $invoiceids[$k] = (int) $v;
  50. }
  51. }
  52. $xmasspays = array();
  53. $result = select_query("tblinvoiceitems",
  54. "invoiceid,relid", array("tblinvoiceitems.userid"
  55. => $client->getID(),
  56. "tblinvoiceitems.type"
  57. => "Invoice",
  58. "tblinvoices.status" =>
  59. "Unpaid"), "", "", "",
  60. "tblinvoices ON
  61. tblinvoices.id=tblinvoiceitems.invoiceid");
  62. while ($data = mysql_fetch_array($result)) {
  63. $xmasspays[$data[0]][$
  64. data[1]] = 1;
  65. }
  66.  
  67. if(count($xmasspays)) {
  68. $numsel = count($invoiceids);
  69. foreach($xmasspays as $iid => $vals) {
  70. if (count($vals) == $numsel) {
  71. foreach($invoiceids as $z) {
  72. unset($vals[$z]);
  73. }
  74.  
  75. if(!count($vals)) {
  76. redir("id=".$iid,
  77. "viewinvoice.php");
  78. }
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment