PageRenderTime 65ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/conference/admin/payment_info.php

https://github.com/azeckoski/az-php-sandbox
PHP | 394 lines | 341 code | 30 blank | 23 comment | 43 complexity | eebd4ddb1d4b3e4c3b048593f934f4d7 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /*
  3. * file: index.php
  4. * Created on Mar 23, 2006 10:39:51 PM by @author aaronz
  5. * Aaron Zeckoski (aaronz@vt.edu) - Virginia Tech (http://www.vt.edu/)
  6. */
  7. ?>
  8. <?php
  9. require_once '../include/tool_vars.php';
  10. $PAGE_NAME = "Payment Information";
  11. $ACTIVE_MENU="REGISTER"; //for managing active links on multiple menus
  12. $Message = "";
  13. // connect to database
  14. require $ACCOUNTS_PATH.'sql/mysqlconnect.php';
  15. // check authentication
  16. require $ACCOUNTS_PATH.'include/check_authentic.php';
  17. // login if not autheticated
  18. //require $ACCOUNTS_PATH.'include/auth_login_redirect.php';
  19. // Make sure user is authorized
  20. $allowed = 0; // assume user is NOT allowed unless otherwise shown
  21. if ( (!$User->checkPerm("admin_conference")) && (!$User->checkPerm("registration_dec2006")) ){
  22. $allowed = 0;
  23. $Message = "Only admins with <b>admin_conference</b> may view this page.<br/>" .
  24. "Try out this one instead: <a href='$TOOL_URL/'>$TOOL_NAME</a>";
  25. } else {
  26. $allowed = 1;
  27. }
  28. // handle activation/deactivation controls
  29. if ($allowed) {
  30. if ($_REQUEST['activate']) {
  31. $sql = "update conferences set activated='Y' where id='".$_REQUEST['activate']."'";
  32. $result = mysql_query($sql) or die("Update query failed ($sql): " . mysql_error());
  33. } else if ($_REQUEST['deactivate']) {
  34. $sql = "update conferences set activated='N' where id='".$_REQUEST['deactivate']."'";
  35. $result = mysql_query($sql) or die("Update query failed ($sql): " . mysql_error());
  36. }
  37. }
  38. // Roles Filter
  39. $filter_roles_default = "show all Roles";
  40. $filter_roles = "";
  41. if ($_REQUEST["filter_roles"] && (!$_REQUEST["clearall"]) ) { $filter_roles = $_REQUEST["filter_roles"]; }
  42. $filter_roles_sql = "";
  43. if ($filter_roles && ($filter_roles != $filter_roles_default)) {
  44. $filter_roles_sql = " and primaryRole='$filter_roles' ";
  45. } else {
  46. $filter_roles = $filter_roles_default;
  47. }
  48. // get the search
  49. $searchtext = "";
  50. if ($_REQUEST["searchtext"]) { $searchtext = $_REQUEST["searchtext"]; }
  51. $sqlsearch = "";
  52. if ($searchtext) {
  53. $sqlsearch = " and (U1.username like '%$searchtext%' or U1.firstname like '%$searchtext%' or " .
  54. "U1.lastname like '%$searchtext%' or U1.email like '%$searchtext%' or U1.institution like '%$searchtext%') ";
  55. }
  56. // sorting
  57. $sortorder = "date_created desc";
  58. if ($_REQUEST["sortorder"]) { $sortorder = $_REQUEST["sortorder"]; }
  59. $sqlsorting = " order by $sortorder ";
  60. // main SQL to fetch all items
  61. $from_sql = " from users U1 join conferences C1 on U1.pk=C1.users_pk where confID='$CONF_ID' " ;
  62. // counting number of items
  63. // **************** NOTE - APPLY THE FILTERS TO THE COUNT AS WELL
  64. $count_sql = "select count(*) " . $from_sql . $sqlsearch;
  65. $result = mysql_query($count_sql) or die('Count query failed: ' . mysql_error());
  66. $row = mysql_fetch_array($result);
  67. $total_items = $row[0];
  68. // pagination control
  69. $num_limit = 25;
  70. if ($_REQUEST["num_limit"] == "All") {
  71. $num_limit = $total_items;
  72. $total_pages = 1;
  73. }
  74. else {
  75. $num_limit = $_REQUEST["num_limit"];
  76. if ($num_limit <= 0) { $num_limit = 1; }
  77. $total_pages = ceil($total_items / $num_limit);
  78. }
  79. $page = 1;
  80. $PAGE = $_REQUEST["page"];
  81. if ($PAGE) { $page = $PAGE; }
  82. $PAGING = $_REQUEST["paging"];
  83. if ($PAGING) {
  84. if ($PAGING == 'first') { $page = 1; }
  85. else if ($PAGING == 'prev') { $page--; }
  86. else if ($PAGING == 'next') { $page++; }
  87. else if ($PAGING == 'last') { $page = $total_pages; }
  88. }
  89. if ($page > $total_pages) { $page = $total_pages; }
  90. if ($page <= 0) { $page = 1; }
  91. $limitvalue = $page * $num_limit - ($num_limit);
  92. // we only want to limit the number of rows if we're not doing an export
  93. if ($_REQUEST["export"]) { $mysql_limit = ""; }
  94. else { $mysql_limit = " LIMIT $limitvalue, $num_limit"; }
  95. $start_item = $limitvalue + 1;
  96. $end_item = $limitvalue + $num_limit;
  97. if ($end_item > $total_items) { $end_item = $total_items; }
  98. // the main fetching query
  99. $sql = "select U1.username, U1.firstname, U1.lastname, U1.email, " .
  100. "U1.primaryRole, U1.institution, U1.institution_pk, U1.address, U1.city, U1.state, U1.zipcode, U1.country, U1.phone, C1.* " .
  101. $from_sql . $sqlsearch . $filter_roles_sql . $sqlsorting . $mysql_limit;
  102. //print "SQL=$sql<br/>";
  103. $result = mysql_query($sql) or die("Fetch query failed ($sql): " . mysql_error());
  104. $items_displayed = mysql_num_rows($result);
  105. // custom CSS file
  106. $CSS_FILE = $ACCOUNTS_URL."/include/accounts.css";
  107. $DATE_FORMAT = "M d, Y h:i a";
  108. // Do the export as requested by the user
  109. if ($_REQUEST["export"] && $allowed) {
  110. $date = date("Ymd-Hi",time());
  111. $filename = "conf_attendees-" . $date . ".csv";
  112. header("Content-type: text/x-csv");
  113. header("Content-disposition: attachment; filename=$filename\n\n");
  114. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  115. header("Expires: 0");
  116. $line = 0;
  117. while ($item = mysql_fetch_assoc($result)) {
  118. $line++;
  119. if ($line == 1) {
  120. echo "\"Conference Attendees Export:\",,\"$CONF_NAME\",\"$CONF_ID\"\n";
  121. print join(',', array_keys($item)) . "\n"; // add header line
  122. }
  123. foreach ($item as $name=>$value) {
  124. $value = str_replace("\"", "\"\"", $value); // fix for double quotes
  125. $item[$name] = '"' . trim($value) . '"'; // put quotes around each item
  126. }
  127. echo join(',', $item) . "\n";
  128. }
  129. echo "\n\"Exported on:\",\"" . date($DATE_FORMAT,time()) . "\"\n";
  130. exit;
  131. } // END EXPORT
  132. // set header links
  133. $EXTRA_LINKS =
  134. "<span class='extralinks'>" .
  135. "<a class='active' href='$CONFADMIN_URL/admin/attendees.php'>Attendee List</a>" .
  136. "<a href='$CONFADMIN_URL/admin/payment_info.php'>Payments</a>" .
  137. "<a href='$CONFADMIN_URL/admin/check_in.php'>Onsite Check-in</a>" .
  138. "</span>";
  139. ?>
  140. <?php // INCLUDE THE HTML HEAD
  141. require $ACCOUNTS_PATH.'include/top_header.php'; ?>
  142. <script type="text/javascript">
  143. <!--
  144. function orderBy(newOrder) {
  145. if (document.adminform.sortorder.value == newOrder) {
  146. document.adminform.sortorder.value = newOrder + " desc";
  147. } else {
  148. document.adminform.sortorder.value = newOrder;
  149. }
  150. document.adminform.submit();
  151. return false;
  152. }
  153. function doConfirm(item, type, action) {
  154. var response = window.confirm("Are you sure you want to "+action+" this "+type+" ("+item+")?");
  155. if (response) {
  156. return true;
  157. }
  158. return false;
  159. }
  160. // -->
  161. </script>
  162. <?php include $ACCOUNTS_PATH.'include/header.php' ?>
  163. <div id="maindata">
  164. <?= $Message ?>
  165. <h2>Under construction --- do not use ---- </h2>
  166. <?php
  167. // Put in footer and stop the rest of the page from loading if not allowed -AZ
  168. if (!$allowed) {
  169. include $ACCOUNTS_PATH.'include/footer.php';
  170. exit;
  171. }
  172. ?>
  173. <form name="adminform" method="post" action="<?= $_SERVER['PHP_SELF'] ?>" style="margin:0px;">
  174. <input type="hidden" name="sortorder" value="<?= $sortorder ?>"/>
  175. <div class="filterarea">
  176. <table border=0 cellspacing=0 cellpadding=0 width="100%">
  177. <tr>
  178. <td>
  179. <strong>Filter:</strong>
  180. </td>
  181. <td>
  182. <select style="font-size:.9em;"name="filter_roles" title="Filter the items by role">
  183. <option value="<?= $filter_roles ?>" selected><?= $filter_roles ?></option>
  184. <option value="Developer/Programmer">Developer/Programmer</option>
  185. <option value="Faculty">Faculty</option>
  186. <option value="Faculty Development">Faculty Development</option>
  187. <option value="Implementor">Implementor</option>
  188. <option value="Instructional Designer">Instructional Designer</option>
  189. <option value="Instructional Technologist">Instructional Technologist</option>
  190. <option value="Librarian">Librarian</option>
  191. <option value="Manager">Manager</option>
  192. <option value="System Administrator">System Administrator</option>
  193. <option value="UI/Interaction Designer">UI/Interaction Designer</option>
  194. <option value="University Administration">University Administration</option>
  195. <option value="User Support">User Support</option>
  196. <option value="show all Roles">show all Roles</option>
  197. </select>
  198. <input class="filter" type="submit" name="filter" value="Filter" title="Apply the current filter settings to the page" />
  199. &nbsp;&nbsp;
  200. </td> <td align="right">
  201. <?php
  202. $count_sql = "SELECT count(*) FROM conferences where activated = 'Y' and confId = '$CONF_ID'";
  203. $count_result = mysql_query($count_sql) or die("Count failed ($count_sql): " . mysql_error());
  204. $row = mysql_fetch_array($count_result);
  205. $total_activated = $row[0];
  206. $count_sql = "SELECT count(*) FROM conferences where date_created > curdate()-INTERVAL 7 DAY and confId = '$CONF_ID'";
  207. $count_result = mysql_query($count_sql) or die("Count failed ($count_sql): " . mysql_error());
  208. $row = mysql_fetch_array($count_result);
  209. $total_week = $row[0];
  210. $count_sql = "SELECT count(*) from conferences C1 join users U1 on U1.pk = C1.users_pk " .
  211. "and institution_pk = '1' where confId = '$CONF_ID'";
  212. $count_result = mysql_query($count_sql) or die("Count failed ($count_sql): " . mysql_error());
  213. $row = mysql_fetch_array($count_result);
  214. $non_members = $row[0];
  215. ?>
  216. <strong>Attendees:</strong>
  217. <label title="number of active registrations\n(i.e. signed up and paid)"><?= $total_activated ?></label>
  218. <span style="font-size:.9em;">
  219. (<label title="total number of registrations\n(including those who have not paid yet)"><?= $total_items ?> total</label>
  220. {<label style="color:red;" title="non-members that have not paid yet"><?= $total_items - $total_activated ?> inactive</label>},
  221. <label title="registrations in the past 7 days"><?= $total_week ?> recent</label>,
  222. <label title="members of Sakai partner institutions"><?= $total_items - $non_members ?> members</label> /
  223. <label style="color:#990099;" title="not members of Sakai partner institutions"><?= $non_members ?> non-members</label>)
  224. </span>
  225. </td>
  226. </tr>
  227. <tr>
  228. <td nowrap="y" style="padding-top:8px;" ><strong >Paging:</strong></td>
  229. <td nowrap="y" style="padding-top:8px;">
  230. <?php if ($_REQUEST["num_limit"] == "All") { ?>
  231. <input type="hidden" name="num_limit" value="All"/>
  232. <span class="keytext">
  233. Displaying all <?= $total_items ?> items
  234. </span>&nbsp;&nbsp;
  235. <strong>Show </strong> <input class="filter" type="submit" name="num_limit" value="25" /> per page
  236. <?php } else { ?>
  237. <input type="hidden" name="page" value="<?= $page ?>" />
  238. <input class="filter" type="submit" name="paging" value="first" title="Go to the first page" />
  239. <input class="filter" type="submit" name="paging" value="prev" title="Go to the previous page" />
  240. <span class="keytext">Page <?= $page ?> of <?= $total_pages ?></span>
  241. <input class="filter" type="submit" name="paging" value="next" title="Go to the next page" />
  242. <input class="filter" type="submit" name="paging" value="last" title="Go to the last page" />
  243. <span class="keytext">&nbsp;-&nbsp;
  244. Displaying <?= $start_item ?> - <?= $end_item ?> of <?= $total_items ?> items (<?= $items_displayed ?> shown)
  245. </span>&nbsp;&nbsp;
  246. <strong>Show </strong> <input class="filter" type="submit" name="num_limit" value="All" />
  247. <?php } ?>
  248. </td>
  249. <td nowrap="y" align="right" style="padding-top:8px;">
  250. <input class="filter" type="submit" name="clearall" value="Clear" title="Reset display to defaults" />
  251. <input class="filter" type="submit" name="export" value="Export" title="Export results based on current filters" />
  252. <input class="filter" type="text" name="searchtext" value="<?= $searchtext ?>"
  253. size="20" title="Enter search text here" />
  254. <script type="text/javascript">document.adminform.searchtext.focus();</script>
  255. <input class="filter" type="submit" name="search" value="Search" title="Search the requirements" />
  256. </td>
  257. </tr>
  258. </table>
  259. </div>
  260. <table border="0" cellspacing="0" width="100%">
  261. <tr class='tableheader'>
  262. <td>&nbsp;&nbsp;&nbsp;</td>
  263. <td><a href="javascript:orderBy('lastname');">Name</a></td>
  264. <td><a href="javascript:orderBy('email');">Email</a></td>
  265. <td><a href="javascript:orderBy('primaryRole');">Primary Role</a></td>
  266. <td><a href="javascript:orderBy('institution');">Institution</a></td>
  267. <td align="center"><a href="javascript:orderBy('date_created');">Date</a></td>
  268. <td align="center">#</td>
  269. </tr>
  270. <?php
  271. //TO DO calculations for members vs non members
  272. //TO DO report on the number of registrations each day (for Joseph's projections')
  273. $line = 0;
  274. $row_num=$total_items;
  275. while($row=mysql_fetch_assoc($result)) {
  276. $line++;
  277. //echo "<pre>",print_r($row),"</pre>";
  278. if (strlen($row["institution"]) > 33) {
  279. $row["institution"] = substr($row["institution"],0,35) . "...";
  280. }
  281. $rowstyle = "";
  282. if ($row["activated"] == 'N') {
  283. $rowstyle = " style = 'color:red;' ";
  284. } else if ($row["institution_pk"] == "1") {
  285. $rowstyle = " style = 'color:#990099;' ";
  286. }
  287. $linestyle = "oddrow";
  288. if ($line % 2 == 0) {
  289. $linestyle = "evenrow";
  290. } else {
  291. $linestyle = "oddrow";
  292. }
  293. ?>
  294. <tr class="<?= $linestyle ?>" <?= $rowstyle ?> >
  295. <td>
  296. <?php if ($row['activated'] == 'Y') { ?>
  297. <a title="Deactivate this user"
  298. onClick="return confirm('Are you sure you want to deactivate this user (<?= $row['username'] ?>)')"
  299. href="<?= $_SERVER['PHP_SELF'] ?>?deactivate=<?= $row['id'] ?>">x</a>
  300. <?php } else { ?>
  301. <a title="Activate this user"
  302. onClick="return confirm('Are you sure you want to activate this user (<?= $row['username'] ?>)')"
  303. href="<?= $_SERVER['PHP_SELF'] ?>?activate=<?= $row['id'] ?>">+</a>
  304. <?php } ?>
  305. </td>
  306. <td class="line"><?= $row["firstname"] ?> <?= $row["lastname"] ?></td>
  307. <td class="line"><?= $row["email"] ?></td>
  308. <td class="line"><?= $row['primaryRole'] ?> </td>
  309. <td class="line"><?= $row["institution"] ?></td>
  310. <td class="line" align="center" nowrap="y" ><?= date($DATE_FORMAT,strtotime($row["date_created"])) ?></td>
  311. <td class="line"><?= $row_num ?></td>
  312. </tr>
  313. <?php
  314. $row_num--;
  315. } ?>
  316. </table>
  317. </form>
  318. <div class="padding50"></div>
  319. <br/>
  320. <div class="definitions">
  321. <div class="defheader">How to use attendees page</div>
  322. <div style="padding:3px;">
  323. The attendees page is primarily for viewing a report of attendees.<br/>
  324. Use the export button to generate a spreadsheet of all attendees.<br/>
  325. <span style="color:red;">Non-member users</span> are color coded and indicate
  326. anyone is not part of a Sakai partner institution.<br/>
  327. <span style="color:#990099;">Inactive users</span> are color coded
  328. and represent anyone who has not paid the registration fee yet.<br/>
  329. To activate a user even if they have not paid, use the <strong>+</strong> link to the left of their name.<br/>
  330. To deactivate a user (basically disables their registration), use the <strong>x</strong> link to the left of their name.<br/>
  331. </div>
  332. </div>
  333. </div>
  334. <?php require $ACCOUNTS_PATH.'include/footer.php'; ?>