Source for file Invoices.inc

Documentation is available at Invoices.inc

  1. <?php
  2. // Team Template code runs within a Team_Display member function environement
  3. if (!isset($teamCompUnix)) $teamCompUnix="";
  4. if (isset($_POST["selectedCompUnix"])) $teamCompUnix=$_POST["selectedCompUnix"];
  5. if ($teamCompUnix=="" && isset($extras["CompUnix"]))
  6. $teamCompUnix=$extras["CompUnix"];
  7.  
  8.  
  9. if (!preg_match('|^[A-Za-z][-_A-Za-z0-9]*$|',$teamCompUnix))
  10. $teamCompUnix="";
  11.  
  12. if ($teamCompUnix!="")
  13. {
  14. $_SESSION["teamCompUnix"]=$teamCompUnix;
  15. $compDB = new CompDB($teamCompUnix, $this->db->getDBUser(),
  16. $this->db->getDBPass());
  17. $details = $this->db->getTeamDetails($teamID);
  18. $orgID = $compDB->checkForCentralAffiliation($details["Name"],
  19. $details["Short"]);
  20. $compStatus=$compDB->getStatus();
  21. }
  22.  
  23.  
  24. if ($teamCompUnix!="" && isset($_POST["submit"]))
  25. {
  26. foreach($_POST as $label=>$value)
  27. {
  28. if ($label=="affil") continue;
  29. if ($label=="submit") continue;
  30. $id = substr($label,strrpos($label,'-')+1,strlen($label));
  31. $update=(substr($value,0,3)!="not"?"TRUE":"FALSE");
  32. if ($update=="TRUE")
  33. $orgString=", orgid=$orgID ";
  34. else
  35. $orgString="";
  36. $query = "UPDATE people_paying SET org_pays=$update{$orgString} WHERE peopleid=$id;";
  37. $compDB->query($query);
  38. touch("{$GLOBALS["CIB_VAR_PATH"]}/$teamCompUnix.updated");
  39. }
  40. }
  41.  
  42. if ($teamCompUnix!="")
  43. {
  44. $invoice=$compDB->produceRegistrantArray($orgID);
  45. $formattedInvoice=$this->formatInvoice($invoice,$details,$compStatus,
  46. $teamCompUnix,$compDB);
  47. $table=$formattedInvoice;
  48. }
  49.  
  50.  
  51. if ($teamCompUnix=="")
  52. {
  53. $comps = $this->db->getUpcomingComps($teamID,'2 weeks');
  54. $needTable=FALSE;
  55. foreach($comps as $aComp)
  56. {
  57. if (!isset($aComp["OrgID"])) continue;
  58. if ($aComp["NumAttending"]>0)
  59. $needTable=TRUE;
  60. if ($needTable) break;
  61. }
  62. if ($needTable)
  63. {
  64. $table =<<<END_TABLE
  65. <p>Your team has members attending the following competitions. The current
  66. registration total is shown next to the competition name. You can click
  67. on the competition name to see the current invoice. From the details page for a given
  68. competition you can remove people from the team invoice or "adopt" non-team
  69. members who are partering with your members, if needed.</p>
  70. <table>
  71. <tr><th>Date</th><th>Competition</th><th>Outstanding</th><th>Paid</th><th>Waived</th><th>Reg. Total</th></tr>
  72.  
  73. END_TABLE; foreach($comps as $aCompUnix=>$aComp)
  74. {
  75. $compDB = new CompDB($aCompUnix, $this->db->getDBUser(),
  76. $this->db->getDBPass());
  77. if (!isset($aComp["OrgID"])) continue;
  78. $compOrgID=$aComp["OrgID"];
  79. $totalDue = $compDB->getTotalOwed($compOrgID);
  80. if (abs($totalDue)<0.5) continue;
  81. $totalWaived = $compDB->getTotalWaived($compOrgID);
  82. $totalPaid = $compDB->getTotalPaid($compOrgID);
  83. $outstanding=$totalDue-$totalWaived-$totalPaid;
  84. $total_s = number_format($totalDue,2);
  85. $paid_s = number_format($totalPaid,2);
  86. $waived_s = number_format($totalWaived,2);
  87. $outstanding_s = number_format($outstanding,2);
  88. $link="{$GLOBALS["CIB_BASE_URL"]}team/admin/$teamID/Invoices/$aCompUnix";
  89. $table .= <<<END_ROW
  90. <tr><td>{$aComp["Date"]}</td><td><a href="$link">{$aComp["Name"]}</a></td><td>\$$outstanding_s</td><td>\$$paid_s</td><td>\$$waived_s</td><td>\$$total_s</td></tr>
  91.  
  92. END_ROW; }
  93. $table .= "</table>";
  94. }
  95. else
  96. {
  97. $table="<p>You have no members competing at upcoming competitions.</p>";
  98. }
  99. }
  100. $body.=<<<END_BODY
  101. <div class="team-tab">
  102. $table
  103. </div>
  104. END_BODY?>

Documentation generated on Tue, 25 Apr 2006 13:03:55 -0400 by phpDocumentor 1.3.0RC3