PageRenderTime 62ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/equilibrium.php

https://github.com/obenauer/equilibrium
PHP | 1845 lines | 1626 code | 103 blank | 116 comment | 246 complexity | 51067564049f7c319f68ead5793eb38f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. // Copyright 2008, St. Jude Children's Research Hospital.
  3. // Written by Dr. John Obenauer, john.obenauer@stjude.org.
  4. // This file is part of Equilibrium. Equilibrium is free software:
  5. // you can redistribute it and/or modify it under the terms of the
  6. // GNU General Public License as published by the Free Software
  7. // Foundation, either version 2 of the License, or (at your option)
  8. // any later version.
  9. // Equilibrium is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License
  14. // along with Equilibrium. If not, see <http://www.gnu.org/licenses/>.
  15. function build_todolist($staff, $status, $todostatus, $priority, $calmode,
  16. $project, $duty, $pageflag, $dragonly, $page, $maxresults) {
  17. global $displayed_user;
  18. //global $page;
  19. //global $maxresults;
  20. global $heading_color;
  21. global $background_color;
  22. // Only allow authorized people to sort or mark off to-do items
  23. if (($_SESSION['SESSION_ADMIN'] == "Y")
  24. || ($staff == $_SESSION['SESSION_USERID'])) {
  25. $edit_priv = "Y";
  26. } else {
  27. $edit_priv = "N";
  28. }
  29. if ($staff == 0) {
  30. $staffclause = "";
  31. } else {
  32. $staffclause = "and t.staff_assigned = \"$staff\" ";
  33. }
  34. if ($priority == "All") {
  35. $priorityclause = "";
  36. } else {
  37. $priorityclause = "and t.priority = \"$priority\" ";
  38. }
  39. if (($project == 0) && ($duty == 0)) {
  40. // Query conditions for To Do page
  41. if ($status == "All") {
  42. $statusclause = "";
  43. } else if ($status == "Open") {
  44. $statusclause = "and ((p.status in ('Pending', 'Active', 'Suspended') " .
  45. "or t.project_id = 0) " .
  46. "and (d.status = \"Active\" or t.duty_id = 0)) ";
  47. } else {
  48. $statusclause = "and ((p.status = \"$status\" " .
  49. "or t.project_id = 0) " .
  50. "and (d.status = \"Active\" or t.duty_id = 0)) ";
  51. }
  52. if ($todostatus == "Pending") {
  53. if ($calmode) {
  54. $orderclause = "order by u.last_name, u.first_name, " .
  55. "schedulenull asc, t.schedule_date, t.order_number asc ";
  56. } else {
  57. $orderclause = "order by u.last_name, u.first_name, " .
  58. "t.order_number asc ";
  59. }
  60. } else {
  61. $orderclause = "order by u.last_name, u.first_name, t.completed_date desc, " .
  62. "t.completed_time desc ";
  63. }
  64. } else if ($project == 0) {
  65. // Query conditions for Duties page
  66. $statusclause = "and t.duty_id = \"$duty\" ";
  67. $staffclause = "";
  68. if ($todostatus == "Pending") {
  69. $orderclause = "order by t.priority, t.duty_order asc ";
  70. } else {
  71. $orderclause = "order by t.completed_date desc, t.completed_time desc ";
  72. }
  73. } else {
  74. // Query conditions for Projects page
  75. $statusclause = "and t.project_id = \"$project\" ";
  76. $staffclause = "";
  77. if ($todostatus == "Pending") {
  78. $orderclause = "order by t.priority, t.project_order asc ";
  79. } else {
  80. $orderclause = "order by t.completed_date desc, t.completed_time desc ";
  81. }
  82. }
  83. if ($todostatus == "Completed") {
  84. $todoflag = "Y";
  85. $dateheading = "Completed";
  86. $checkimage = "checkmark.png";
  87. $checkother = "checkbox.png";
  88. $marktext = "Undo Completion";
  89. } else {
  90. $todoflag = "N";
  91. $dateheading = "Schedule";
  92. $checkimage = "checkbox.png";
  93. $checkother = "checkmark.png";
  94. $marktext = "Mark Completed";
  95. }
  96. // Get staff list for reassigning
  97. $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
  98. $query = "select user_id, first_name, last_name " .
  99. "from users where staff_flag = \"Y\" " .
  100. "order by last_name asc, first_name asc ";
  101. $get_staff = $conn->query($query);
  102. $stafflist = array();
  103. $staffnames = array();
  104. $nstaff = 0;
  105. while ($row = $get_staff->fetch_array(MYSQLI_ASSOC)) {
  106. $stafflist[$nstaff] = $row['user_id'];
  107. $staffnames[$nstaff] = $row['first_name'] . " " . $row['last_name'];
  108. $nstaff++;
  109. }
  110. $get_staff->free_result();
  111. $conn->close();
  112. // Create JavaScript array of staff names
  113. printf("<script language='JavaScript'>\n");
  114. printf("var stafflist = new Array(%d);\n", $nstaff);
  115. printf("var staffnames = new Array(%d);\n", $nstaff);
  116. for ($i = 0; $i < $nstaff; $i++) {
  117. printf("stafflist[$i] = '$stafflist[$i]';\n");
  118. printf("staffnames[$i] = '$staffnames[$i]';\n");
  119. }
  120. printf("</script>\n");
  121. // Get open projects for this staff member
  122. $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
  123. $query = "select t.project_id, t.title from projects as t " .
  124. "where t.status in ('Pending', 'Active', 'Suspended') " .
  125. $staffclause .
  126. "order by t.date_entered desc ";
  127. //printf("query = $query<br>\n");
  128. $get_projects = $conn->query($query);
  129. $project_ids = array();
  130. $projects = array();
  131. $nprojects = 0;
  132. while ($row = $get_projects->fetch_array(MYSQLI_ASSOC)) {
  133. if (strlen($row['title']) > 40) {
  134. $project_title = substr($row['title'], 0, 37) . "...";
  135. } else {
  136. $project_title = $row['title'];
  137. }
  138. $project_ids[$nprojects] = $row['project_id'];
  139. $projects[$nprojects] = $project_title;
  140. $nprojects++;
  141. }
  142. $get_projects->free_result();
  143. $conn->close();
  144. // Get active duties for this staff member
  145. $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
  146. $query = "select t.duty_id, t.title from duties as t " .
  147. "where t.status = 'Active' " .
  148. $staffclause .
  149. "order by t.date_entered desc ";
  150. $get_duties = $conn->query($query);
  151. $duty_ids = array();
  152. $duties = array();
  153. $nduties = 0;
  154. while ($row = $get_duties->fetch_array(MYSQLI_ASSOC)) {
  155. if (strlen($row['title']) > 40) {
  156. $duty_title = substr($row['title'], 0, 37) . "...";
  157. } else {
  158. $duty_title = $row['title'];
  159. }
  160. $duty_ids[$nduties] = $row['duty_id'];
  161. $duties[$nduties] = $duty_title;
  162. $nduties++;
  163. }
  164. $get_duties->free_result();
  165. $conn->close();
  166. // Choose dates to display in schedule options
  167. $weekend = 0;
  168. $dates = array();
  169. if ($weekend) {
  170. // Show all dates for next two weeks
  171. for ($i = 0; $i <= 14; $i++) {
  172. $day = mktime(0, 0, 0, date("m"), date("d") + $i, date("Y"));
  173. $dates[$i] = date("Y", $day) . "-" . date("m", $day) . "-" .
  174. date("d", $day);
  175. }
  176. } else {
  177. // Show only weekdays for next two weeks
  178. $count = 0;
  179. for ($i = 0; $i <= 14; $i++) {
  180. $day = mktime(0, 0, 0, date("m"), date("d") + $i, date("Y"));
  181. $dayofweek = date('l', $day);
  182. if (($dayofweek != "Saturday") && ($dayofweek != "Sunday")) {
  183. $dates[$count] = date("Y", $day) . "-" . date("m", $day) . "-" .
  184. date("d", $day);
  185. $count++;
  186. }
  187. }
  188. }
  189. // Put relevant to-do's in order
  190. $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
  191. //$query = "select t.todo_id, t.schedule_date is null as schedulenull " .
  192. // "from todos as t left join users as u on t.staff_assigned = u.user_id " .
  193. // "left join projects as p on t.project_id = p.project_id " .
  194. // "left join duties as d on t.duty_id = d.duty_id " .
  195. // "where t.completed = \"$todoflag\" " .
  196. // $staffclause .
  197. // $statusclause .
  198. // $priorityclause .
  199. // $orderclause;
  200. //$todo_order = $conn->query($query);
  201. //$count = 1;
  202. //if ($project) {
  203. // $order_var = "project_order";
  204. //} else if ($duty) {
  205. // $order_var = "duty_order";
  206. //} else {
  207. // $order_var = "order_number";
  208. //}
  209. //while ($row = $todo_order->fetch_array(MYSQLI_ASSOC)) {
  210. // $set_order = $conn->query("update todos set $order_var = \"$count\" " .
  211. // "where todo_id = \"" . $row['todo_id'] . "\" ");
  212. // $count++;
  213. //}
  214. //$todo_order->free_result();
  215. // Define visibility clause
  216. if ($_SESSION['SESSION_USERID'] != $staff) {
  217. $visclause = "and t.visibility = 'Public' ";
  218. } else {
  219. $visclause = "";
  220. }
  221. // Get to-do items and display them
  222. $query = "select t.todo_id, t.completed, t.schedule_date, t.completed_date, " .
  223. "t.priority, t.visibility, u.first_name, u.last_name, u.user_id, " .
  224. "u2.user_id as project_owner, u3.user_id as duty_owner, " .
  225. "p.project_id, p.icon_id as project_icon, p.title as project_title, " .
  226. "d.duty_id, d.icon_id as duty_icon, d.title as duty_title, t.description, " .
  227. "(t.schedule_date is null or t.schedule_date = '0000-00-00') as schedulenull " .
  228. "from todos as t left join users as u on t.staff_assigned = u.user_id " .
  229. "left join projects as p on t.project_id = p.project_id " .
  230. "left join users as u2 on p.staff_assigned = u2.user_id " .
  231. "left join duties as d on t.duty_id = d.duty_id " .
  232. "left join users as u3 on d.staff_assigned = u3.user_id " .
  233. "where t.completed = \"$todoflag\" " .
  234. $staffclause .
  235. $statusclause .
  236. $visclause .
  237. $priorityclause .
  238. $orderclause;
  239. //printf("query = $query limit " . (($page - 1) * $maxresults) . ", $maxresults <br>\n");
  240. $list_full = $conn->query($query);
  241. if ($pageflag) {
  242. $list_page = $conn->query($query . "limit " . (($page - 1) * $maxresults) .
  243. ", $maxresults ");
  244. } else {
  245. $list_page = $list_full;
  246. }
  247. $list = "<div id='$todostatus" . "_todoblock'>\n";
  248. //printf("query = $query limit %d, %d<br>\n", (($page - 1) * $maxresults), $maxresults);
  249. //$list .= "query = $query<br>\n";
  250. //$list .= "projectclause = $projectclause<br>\n";
  251. if ($list_full->num_rows) {
  252. // Show "Pending" or "Completed" label for individual projects and duties
  253. if (($project) || ($duty)) {
  254. $list .= "<b>$todostatus</b><br>\n";
  255. }
  256. // Show page numbers for results
  257. if ($pageflag) {
  258. $page_url = "todolist.php?staff=$staff&status=$status&todostatus=$todostatus" .
  259. "&priority=$priority&calmode=$calmode";
  260. $list .= page_results($list_full->num_rows, $page, $maxresults, $page_url);
  261. //$list .= "BUILD_TODOLIST PAGEFLAG=$pageflag<BR>\n";
  262. }
  263. // Start div for to do list
  264. $list .= "<div id='$todostatus" . "_todolist' class='sortable_list'>\n";
  265. //$list .= "<div id='todolist' onmouseup='update_list(\"todolist\", " .
  266. // "\"common.php?cmd=updatelist&staff=$staff&status=$status" .
  267. // "&todostatus=$todostatus&edit_priv=$edit_priv&project=$project&duty=$duty&pageflag=$pageflag\");'>\n";
  268. $lastscheduledate = "";
  269. while ($row = $list_page->fetch_array(MYSQLI_ASSOC)) {
  270. // If schedule date is present, convert it to Unix time
  271. $pastscheduledate = 0;
  272. if (($row['schedule_date'] == "0000-00-00") ||
  273. ($row['schedule_date'] == "NULL") ||
  274. ($row['schedule_date'] == NULL)) {
  275. $row['schedule_date'] = "";
  276. }
  277. if ($row['schedule_date']) {
  278. $parts = explode("-", $row['schedule_date']);
  279. $calday = mktime(0, 0, 0, $parts[1], $parts[2], $parts[0]);
  280. $schedule_column = $row['schedule_date'];
  281. // Check if scheduled date is before current day
  282. $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
  283. if ($calday < $today) {
  284. $pastscheduledate = 1;
  285. }
  286. } else {
  287. $schedule_column = "";
  288. }
  289. // If all staff members selected, show their initials
  290. if ($staff == 0) {
  291. $initials = substr($row['first_name'], 0, 1) .
  292. substr($row['last_name'], 0, 1) . " ";
  293. } else {
  294. $initials = "";
  295. }
  296. // Identify to-do owner
  297. if ($row['user_id']) {
  298. $todo_owner = $row['user_id'];
  299. } else {
  300. $todo_owner = 0;
  301. }
  302. // Identify project owner
  303. if ($row['project_owner']) {
  304. $project_owner = $row['project_owner'];
  305. } else {
  306. $project_owner = 0;
  307. }
  308. // Identify duty owner
  309. if ($row['duty_owner']) {
  310. $duty_owner = $row['duty_owner'];
  311. } else {
  312. $duty_owner = 0;
  313. }
  314. // Check whether this is a private or public to-do item
  315. if ($row['visibility'] == 'Private') {
  316. $bgcolor = "style='background-color: $heading_color'";
  317. } else {
  318. $bgcolor = "";
  319. }
  320. // Draw lines between to-do's with different schedule dates
  321. // (in Calendar Mode)
  322. if ($calmode) {
  323. if (($lastscheduledate == "") && ($pastscheduledate)) {
  324. $list .= "<div id='A" . $row['todo_id'] . "'>";
  325. $list .= "<font color='blue' size='-1'><b>" .
  326. "Overdue</b></font><br clear=left></div>\n";
  327. } else if (($row['schedule_date'] != $lastscheduledate)
  328. && (!$pastscheduledate)) {
  329. $list .= "<div id='A" . $row['todo_id'] . "'>";
  330. if ($row['schedule_date']) {
  331. $list .= "<font color='blue' size='-1'><b>" .
  332. short_date($row['schedule_date']) .
  333. "</b></font><br clear=left></div>\n";
  334. } else {
  335. $list .= "<font color='blue' size='-1'><b>" .
  336. "Unscheduled</b></font><br clear=left></div>\n";
  337. }
  338. }
  339. $lastscheduledate = $row['schedule_date'];
  340. }
  341. $list .= "<div class='todo_item' id='" . $row['todo_id']. "' style='background-color: " . $background_color . "'>\n";
  342. $list .= "<table style='font-size: 14px'><tr valign='top'>\n";
  343. // Mark to-do completed, or undo it
  344. if ($dragonly == 0) {
  345. if ($edit_priv == "Y") {
  346. //$list .= "<td style=\"width:30px\">\n";
  347. $list .= "<td>\n";
  348. $list .= "<img id='check_image_" . $row['todo_id'] .
  349. "' src=\"images/$checkimage\" title='$marktext' ";
  350. if (($project) || ($duty)) {
  351. $list .= "onclick='{ $(\"check_image_" . $row['todo_id'] .
  352. "\").src=\"images/$checkother\"; modify_two_lists(\"" .
  353. $row['todo_id'] . "\", \"togglecomplete\", \"$staff\", " .
  354. "\"$status\", \"$priority\", \"$calmode\", " .
  355. "\"$project\", \"$duty\", \"$pageflag\", " .
  356. "\"$dragonly\", \"$page\", \"$maxresults\");}'>\n";
  357. } else {
  358. $list .= "onclick='{ $(\"check_image_" . $row['todo_id'] .
  359. "\").src=\"images/$checkother\"; modify_todo(\"" .
  360. $row['todo_id'] . "\", \"togglecomplete\", \"$staff\", " .
  361. "\"$status\", \"$todostatus\", \"$priority\", \"$calmode\", " .
  362. "\"$project\", \"$duty\", " .
  363. "\"$pageflag\", \"$dragonly\", \"$page\", \"$maxresults\"" .
  364. ");}'>\n";
  365. }
  366. $list .= "</td>\n";
  367. } else {
  368. //$list .= "<td style=\"width:30px\">\n";
  369. $list .= "<td>\n";
  370. $list .= "<img id='check_image_" . $row['todo_id'] .
  371. "' src=\"images/$checkimage\" ";
  372. $list .= "title='$marktext'>\n";
  373. $list .= "</td>\n";
  374. }
  375. }
  376. // Show staff initials if "All" staff is selected
  377. $list .= "<td><font color='blue'>$initials</font>\n";
  378. // Show project icon (if any), unless only one project is being viewed
  379. if (!$project) {
  380. if (($row['project_id']) && ($row['project_id'] != "NULL")) {
  381. $list .= "<a href='projects.php?action=view&project=" .
  382. $row['project_id'] . "'><img src=\"icons18/icon_" .
  383. $row['project_icon'] . ".png\" title='" .
  384. $row['project_title'] . "' border='0'></a>\n";
  385. }
  386. }
  387. // Show duty icon (if any), unless only one duty is being viewed
  388. if (!$duty) {
  389. if (($row['duty_id']) && ($row['duty_id'] != "NULL")) {
  390. $list .= "<a href='duties.php?action=view&duty=" .
  391. $row['duty_id'] . "'><img src=\"icons18/icon_" .
  392. $row['duty_icon'] . ".png\" title='" .
  393. $row['duty_title'] . "' border='0'></a>\n";
  394. }
  395. }
  396. // Show to-do item description
  397. $list .= "<span class='draghandle' onclick='modify_todo(\"$todostatus" .
  398. "_todolist\", \"updatelist\", \"$staff\", \"$status\", \"$todostatus\", " .
  399. "\"$priority\", \"$calmode\", \"$project\", \"$duty\", \"$pageflag\", " .
  400. "\"$dragonly\", \"$page\", " .
  401. "\"$maxresults\");' $bgcolor>" . $row['description'] . "</span>\n";
  402. // Show to-do owner if different from project owner
  403. if ($project && $project_owner && $todo_owner) {
  404. if ($project_owner != $todo_owner) {
  405. $todoname = $staffnames[array_search($todo_owner, $stafflist, true)];
  406. } else {
  407. $todoname = "";
  408. }
  409. }
  410. if ($duty) {
  411. if ($duty_owner != $todo_owner) {
  412. $todoname = $staffnames[array_search($todo_owner, $stafflist, true)];
  413. } else {
  414. $todoname = "";
  415. }
  416. }
  417. if ($dragonly) {
  418. //$list .= "</td></tr></table></div>\n";
  419. $list .= "</td></tr></table>\n";
  420. } else if ($todostatus == "Completed") {
  421. if ($todoname) {
  422. $list .= " (<b>$todoname</b>, " . short_date($row['completed_date']) . ")\n";
  423. } else {
  424. $list .= " (" . short_date($row['completed_date']) . ")\n";
  425. }
  426. $list .= "</tr></table>\n";
  427. } else {
  428. if ($calmode) {
  429. if ($pastscheduledate) {
  430. if ($todoname && $schedule_column) {
  431. $list .= " (<b>$todoname</b>, " . short_date($schedule_column) . ")\n";
  432. } else if ($schedule_column) {
  433. $list .= " (" . short_date($schedule_column) . ")\n";
  434. } else if ($todoname) {
  435. $list .= " (<b>$todoname</b>)\n";
  436. }
  437. } else {
  438. if ($todoname) {
  439. $list .= " (<b>$todoname</b>)\n";
  440. }
  441. }
  442. } else {
  443. if ($todoname && $schedule_column) {
  444. $list .= " (<b>$todoname</b>, " . short_date($schedule_column) . ")\n";
  445. } else if ($schedule_column) {
  446. $list .= " (" . short_date($schedule_column) . ")\n";
  447. } else if ($todoname) {
  448. $list .= " (<b>$todoname</b>)\n";
  449. }
  450. }
  451. // Priority icon
  452. if ($row['priority'] == 'High') {
  453. $list .= "&nbsp; &nbsp; <img src='images/plus.png' height='16' " .
  454. "title='Priority' onclick='modify_todo(\"" . $row['todo_id'] .
  455. "\", \"togglepriority\", \"$staff\", \"$status\", " .
  456. "\"$todostatus\", \"$priority\", \"$calmode\", " .
  457. "\"$project\", \"$duty\", " .
  458. "\"$pageflag\", \"$dragonly\", \"$page\", " .
  459. "\"$maxresults\");'>";
  460. } else {
  461. $list .= "&nbsp; <img src='images/minus.png' height='16' " .
  462. "title='Priority' onclick='modify_todo(\"" . $row['todo_id'] .
  463. "\", \"togglepriority\", \"$staff\", \"$status\", " .
  464. "\"$todostatus\", \"$priority\", \"$calmode\", " .
  465. "\"$project\", \"$duty\", " .
  466. "\"$pageflag\", \"$dragonly\", \"$page\", " .
  467. "\"$maxresults\");'>";
  468. }
  469. // Edit icon
  470. $list .= "&nbsp; <img src='images/edit.png' height='16' " .
  471. "title='Edit' " .
  472. "onclick='show_item(\"edit_" . $row['todo_id'] . "\");'>";
  473. // Delete icon
  474. $list .= "&nbsp; <img src='images/delete.png' height='16' " .
  475. "title='Delete' " .
  476. "onclick='show_item(\"confirm_" . $row['todo_id'] . "\");'>";
  477. $list .= "</td>";
  478. $list .= "</tr></table>\n";
  479. //$list .= "</div>\n";
  480. // Div for edit box
  481. $list .= "<div style='display: none' id='edit_" . $row['todo_id'] . "' >" .
  482. "<center>Edit: <input type='text' " .
  483. " id='txtEditItem_" .
  484. $row['todo_id'] .
  485. "' size='100' maxlength='255' value=\"" . $row['description'] ."\" " .
  486. ">\n<br>";
  487. // Project/duty selection
  488. if ($row['project_id']) {
  489. $pstyle = "style='font-weight: bold' ";
  490. $dstyle = "style='font-weight: normal' ";
  491. $selectname = "name = 'projectchange_" . $row['todo_id'] .
  492. "' ";
  493. } else if ($row['duty_id']) {
  494. $pstyle = "style='font-weight: normal' ";
  495. $dstyle = "style='font-weight: bold' ";
  496. $selectname = "name = 'dutychange_" . $row['todo_id'] .
  497. "' ";
  498. } else {
  499. $pstyle = "style='font-weight: bold' ";
  500. $dstyle = "style='font-weight: normal' ";
  501. $selectname = "name = 'projectchange_" . $row['todo_id'] .
  502. "' ";
  503. }
  504. $list .= "<font id='projectlabel_" . $row['todo_id'] . "' onclick='pdflag_" . $row['todo_id'] . " = \"Project\"; populate_projects( $(\"pdlist_" . $row['todo_id'] . "\"), $(\"projectlabel_" . $row['todo_id'] . "\"), $(\"dutylabel_" . $row['todo_id'] . "\"), project_ids, projects, \"" .
  505. $row['project_id'] . "\");' $pstyle>";
  506. $list .= "Project</font> / ";
  507. $list .= "<font id='dutylabel_" . $row['todo_id'] . "' onclick='pdflag_" . $row['todo_id'] . " = \"Duty\"; populate_duties( $(\"pdlist_" . $row['todo_id'] . "\"), $(\"projectlabel_" . $row['todo_id'] . "\"), $(\"dutylabel_" . $row['todo_id'] . "\"), duty_ids, duties, \"" .
  508. $row['duty_id'] . "\");' $dstyle>Duty</font>: \n";
  509. $list .= "<select id='pdlist_" . $row['todo_id'] . "' size='1' onChange=\"if (pdflag_" . $row['todo_id'] . " == 'Project') {duty = 0; project = project_ids[$('pdlist_" . $row['todo_id'] . "').selectedIndex - 1];} else {project = 0; duty = duty_ids[$('pdlist_" . $row['todo_id'] . "').selectedIndex - 1];}\" $selectname>\n";
  510. if ($row['project_id']) {
  511. $list .= "<option value='P0'></option>\n";
  512. for ($i = 0; $i < $nprojects; $i++) {
  513. if ($row['project_id'] == $project_ids[$i]) {
  514. $list .= "<option value='P" . $project_ids[$i] .
  515. "' selected>" . $projects[$i] . "</option>\n";
  516. } else {
  517. $list .= "<option value='P" . $project_ids[$i] .
  518. "'>" . $projects[$i] . "</option>\n";
  519. }
  520. }
  521. } else if ($row['duty_id']) {
  522. $list .= "<option value='D0'></option>\n";
  523. for ($i = 0; $i < $nduties; $i++) {
  524. if ($row['duty_id'] == $duty_ids[$i]) {
  525. $list .= "<option value='D" . $duty_ids[$i] .
  526. "' selected>" . $duties[$i] . "</option>\n";
  527. } else {
  528. $list .= "<option value='D" . $duty_ids[$i] .
  529. "'>" . $duties[$i] . "</option>\n";
  530. }
  531. }
  532. } else {
  533. $list .= "<option value='P0'></option>\n";
  534. for ($i = 0; $i < $nprojects; $i++) {
  535. if ($row['project_id'] == $project_ids[$i]) {
  536. $list .= "<option value='P" . $project_ids[$i] .
  537. "' selected>" . $projects[$i] . "</option>\n";
  538. } else {
  539. $list .= "<option value='P" . $project_ids[$i] .
  540. "'>" . $projects[$i] . "</option>\n";
  541. }
  542. }
  543. }
  544. $list .= "</select> &nbsp; \n";
  545. // Staff assigned selection
  546. $list .= "Staff assigned: ";
  547. $list .= "<select id='staff_assigned_" . $row['todo_id'] .
  548. "' name='staff_assigned_" . $row['todo_id'] .
  549. "'>\n";
  550. for ($i = 0; $i < $nstaff; $i++) {
  551. if ($stafflist[$i] == $todo_owner) {
  552. $list .= "<option value='" . $stafflist[$i].
  553. "' selected>" . $staffnames[$i] . "</option>\n";
  554. } else {
  555. $list .= "<option value='" . $stafflist[$i].
  556. "'>" . $staffnames[$i] . "</option>\n";
  557. }
  558. }
  559. $list .= "</select><br>\n";
  560. // Visibility selection
  561. $list .= "Visibility: ";
  562. $list .= "<select id='visibility_" . $row['todo_id'] .
  563. "' name='visibility_" . $row['todo_id'] .
  564. "'>\n";
  565. if ($row['visibility'] == 'Public') {
  566. $list .= "<option value='Public' selected>Public</option>\n";
  567. } else {
  568. $list .= "<option value='Public'>Public</option>\n";
  569. }
  570. if ($row['visibility'] == 'Private') {
  571. $list .= "<option value='Private' selected>Private</option>\n";
  572. } else {
  573. $list .= "<option value='Private'>Private</option>\n";
  574. }
  575. $list .= "</select>\n";
  576. // Schedule date selection
  577. $list .= "Schedule: ";
  578. $list .= "<select id='schedule_" . $row['todo_id'] .
  579. "' name='schedule_" . $row['todo_id'] .
  580. "'>\n";
  581. if ($pastscheduledate) {
  582. $list .= "<option value='$schedule_column' selected " .
  583. "style='background-color: $heading_color'>" .
  584. short_date($schedule_column) . "</option>\n";
  585. }
  586. if ($schedule_column == "") {
  587. $list .= "<option value='NULL' selected></option>\n";
  588. } else {
  589. $list .= "<option value='NULL'></option>\n";
  590. }
  591. for ($i = 0; $i < count($dates); $i++) {
  592. if ($schedule_column == $dates[$i]) {
  593. $list .= "<option value='$dates[$i]' selected>" .
  594. short_date($dates[$i]) . "</option>\n";
  595. } else {
  596. $list .= "<option value='$dates[$i]'>" .
  597. short_date($dates[$i]) . "</option>\n";
  598. }
  599. }
  600. $list .= "</select><br>\n";
  601. // Update and cancel icons
  602. $list .= "<input type='button' value='Update' " .
  603. "onclick='{modify_todo(\"" . $row['todo_id'] .
  604. "\", \"edititem\", \"$staff\", \"$status\", \"$todostatus\", " .
  605. "\"$priority\", \"$calmode\", \"$project\", \"$duty\", \"$pageflag\", " .
  606. "\"$dragonly\", \"$page\", \"$maxresults\");}'> &nbsp; &nbsp; " .
  607. "<input type='button' value='Cancel' onclick='hide_item(\"edit_" .
  608. $row['todo_id'] . "\");'></center></div>\n";
  609. // Set variable for project/duty flag
  610. printf("<script type='text/javascript'>\n");
  611. if ($row['project_id']) {
  612. printf("var pdflag_" . $row['todo_id'] . " = \"Project\";\n");
  613. } else if ($row['duty_id']) {
  614. printf("var pdflag_" . $row['todo_id'] . " = \"Duty\";\n");
  615. } else {
  616. printf("var pdflag_" . $row['todo_id'] . " = \"Project\";\n");
  617. }
  618. printf("</script>\n");
  619. // Div to confirm deletion
  620. $list .= "<div class='confirm' id='confirm_" . $row['todo_id'] .
  621. "' ><font color='red'>" .
  622. "<center>Are you sure you want to delete this item?</font><br>" .
  623. "<input type='button' value='Confirm Deletion' " .
  624. "onclick='{Element.hide(\$(\"confirm_" . $row['todo_id'] .
  625. "\").id); modify_todo(\"" . $row['todo_id'] .
  626. "\", \"deleteitem\", \"$staff\", \"$status\", \"$todostatus\", " .
  627. "\"$priority\", \"$calmode\", \"$project\", \"$duty\", \"$pageflag\", " .
  628. "\"$dragonly\", \"$page\", \"$maxresults\");" .
  629. "}'> &nbsp; &nbsp; " .
  630. "<input type='button' value='Cancel' onclick='hide_item(\"confirm_" .
  631. $row['todo_id'] . "\");'></center></div>\n";
  632. // End the div for this to-do item (containing edit and delete divs)
  633. $list .= "</div>\n";
  634. }
  635. }
  636. // End the div for all to-do items
  637. $list .= "</div>\n";
  638. } else {
  639. if ($project) {
  640. $list .= "<b>No " . strtolower($todostatus) . " to-do items found " .
  641. "for this project.</b><br>\n";
  642. } else if ($duty) {
  643. $list .= "<b>No " . strtolower($todostatus) . " to-do items found " .
  644. "for this duty.</b><br>\n";
  645. } else {
  646. if ($displayed_user == "All") {
  647. if ($status == "All") {
  648. $list .= "<b>No " . strtolower($todostatus) . " to-do items found " .
  649. "in database.</b><br>\n";
  650. } else {
  651. $list .= "<b>No " . strtolower($todostatus) . " to-do items for " .
  652. strtolower($status) . " projects found in database.</b><br>\n";
  653. }
  654. } else {
  655. if ($status == "All") {
  656. $list .= "<b>No " . strtolower($todostatus) . " to-do items found " .
  657. "for $displayed_user.</b><br>\n";
  658. } else {
  659. $list .= "<b>No " . strtolower($todostatus) . " to-do items for " .
  660. strtolower($status) . " projects found for " .
  661. "$displayed_user.</b><br>\n";
  662. }
  663. }
  664. }
  665. }
  666. // End the "to do block" div
  667. $list .= "</div>\n";
  668. // Close the database connection
  669. $list_full->free_result();
  670. if ($pageflag) {
  671. $list_page->free_result();
  672. }
  673. $conn->close();
  674. // Make list sortable
  675. if (($todostatus == "Pending") && ($_SESSION['SESSION_USERID'] == $staff)) {
  676. $list .= "<script type='text/javascript'>\n";
  677. $list .= "Sortable.create('$todostatus" . "_todolist', {tag:'div', handle:'draghandle'});\n";
  678. $list .= "</script>\n";
  679. }
  680. return $list;
  681. }
  682. function build_two_lists($staff, $status, $priority, $calmode, $project, $duty,
  683. $pageflag, $dragonly, $page, $maxresults) {
  684. $two_lists = build_todolist($staff, $status, "Pending", $priority, $calmode,
  685. $project, $duty, '0', '0', $page, $maxresults);
  686. $two_lists .= "<br>\n";
  687. $two_lists .= build_todolist($staff, $status, "Completed", $priority, $calmode,
  688. $project, $duty, '0', '0', $page, $maxresults);
  689. return $two_lists;
  690. }
  691. function build_commentlist($staff, $project, $duty, $fromdate, $todate,
  692. $pageflag, $page, $maxresults) {
  693. global $displayed_user;
  694. //global $page;
  695. //global $maxresults;
  696. global $heading_color;
  697. global $background_color;
  698. // Only the assigned staff or administrators can edit this project, unless it's not assigned
  699. if (($_SESSION['SESSION_ADMIN'] == "Y") || ($staff == $_SESSION['SESSION_USERID'])) {
  700. $edit_priv = "Y";
  701. } else {
  702. $edit_priv = "N";
  703. }
  704. if ($staff == 0) {
  705. $staffclause = "";
  706. } else {
  707. $staffclause = "where c.submitter_id = \"$staff\" ";
  708. }
  709. // Define visibility clause
  710. if ($_SESSION['SESSION_USERID'] != $staff) {
  711. $visclause = "and c.visibility = 'Public' ";
  712. } else {
  713. $visclause = "";
  714. }
  715. // Define date clause
  716. if ($project) {
  717. $dateclause = "";
  718. $pdclause = "and c.project_id = \"$project\" ";
  719. } else if ($duty) {
  720. $dateclause = "";
  721. $pdclause = "and c.duty_id = \"$duty\" ";
  722. } else {
  723. $dateclause = "and c.submit_date >= \"$fromdate\" " .
  724. "and c.submit_date <= \"$todate\" ";
  725. $pdclause = "";
  726. }
  727. // Fill Javascript arrays with open projects and active duties
  728. fill_pdlist_arrays($staff, $projects, $project_ids, $duties, $duty_ids);
  729. // Get to-do items for active projects and display them
  730. $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
  731. $query = "select c.comment_id, c.comment_text, c.submit_date, " .
  732. "u.user_id, u.first_name, u.last_name, c.visibility, " .
  733. "p.project_id, p.icon_id as project_icon, p.title as project_title, " .
  734. "d.duty_id, d.icon_id as duty_icon, d.title as duty_title " .
  735. "from comments as c left join users as u on c.submitter_id = u.user_id " .
  736. "left join projects as p on c.project_id = p.project_id " .
  737. "left join duties as d on c.duty_id = d.duty_id " .
  738. $staffclause . $visclause . $dateclause . $pdclause .
  739. "order by c.submit_time desc ";
  740. //printf("query = $query<br>\n");
  741. $list_full = $conn->query($query);
  742. if ($pageflag) {
  743. $list_page = $conn->query($query . "limit " . (($page - 1) * $maxresults) .
  744. ", $maxresults ");
  745. } else {
  746. $list_page = $list_full;
  747. }
  748. $list = "<div id='commentblock'>\n";
  749. //$list .= "fromdate = $fromdate, todate = $todate<br>\n";
  750. if ($list_page->num_rows) {
  751. // Show page numbers for results
  752. if ($pageflag) {
  753. $page_url = "logbook.php?staff=$staff&fromdate=$fromdate&todate=$todate";
  754. $list .= page_results($list_full->num_rows, $page, $maxresults, $page_url);
  755. }
  756. while ($row = $list_page->fetch_array(MYSQLI_ASSOC)) {
  757. // If all staff members selected, show their initials
  758. if ($staff == 0) {
  759. $initials = substr($row['first_name'], 0, 1) .
  760. substr($row['last_name'], 0, 1) . " ";
  761. } else {
  762. $initials = "";
  763. }
  764. $list .= "<div id='comment_" . $row['comment_id'] . "'>";
  765. // Check whether this is a private or public to-do item
  766. if ($row['visibility'] == 'Private') {
  767. $bgcolor = "$heading_color";
  768. } else {
  769. $bgcolor = "white";
  770. }
  771. // Date submitted
  772. $list .= "<table><tr valign='top'><td>" . short_date($row['submit_date']) . "</td>\n";
  773. $list .= "<td bgcolor='$bgcolor' style='{border: 1px solid $heading_color; padding-left: 5px; padding-right: 5px;}'><font color='blue'>$initials</font>";
  774. // Show project icon (if any), unless only one project is being viewed
  775. if (!$project) {
  776. if (($row['project_id']) && ($row['project_id'] != "NULL")) {
  777. $list .= "<a href='projects.php?action=view&project=" .
  778. $row['project_id'] . "'><img src=\"icons18/icon_" .
  779. $row['project_icon'] . ".png\" title='" .
  780. $row['project_title'] . "' border='0'></a>\n";
  781. }
  782. }
  783. // Show duty icon (if any), unless only one duty is being viewed
  784. if (!$duty) {
  785. if (($row['duty_id']) && ($row['duty_id'] != "NULL")) {
  786. $list .= "<a href='duties.php?action=view&duty=" .
  787. $row['duty_id'] . "'><img src=\"icons18/icon_" .
  788. $row['duty_icon'] . ".png\" title='" .
  789. $row['duty_title'] . "' border='0'></a>\n";
  790. }
  791. }
  792. // Comment text
  793. $comment_text = str_replace("\'", "'", $row['comment_text']);
  794. $comment_text = str_replace('\"', '"', $comment_text);
  795. $comment_text = str_replace("%", "%%", $comment_text);
  796. $list .= $comment_text . "</td>\n";
  797. // Don't show edit or delete icons if user does not have edit_priv
  798. if ($edit_priv == "Y") {
  799. // "Edit" icon
  800. $list .= "<td><img src='images/edit.png' height='16' style='{position:relative; padding-left:20px;}' " .
  801. "onclick='show_item(\"editcomment_" . $row['comment_id'] . "\");'></td>";
  802. // "Delete" icon
  803. $list .= "<td style='background-color:" . $background_color . "'><img src='images/delete.png' height='16' onclick='show_item(\"confirmcomment_" . $row['comment_id'] . "\");'>" .
  804. "</td></tr></table>\n";
  805. // Div for edit box
  806. $list .= "<div style='display: none' id='editcomment_" .
  807. $row['comment_id'] . "'><center>Edit: <textarea id='txtEditEntry_" .
  808. $row['comment_id'] .
  809. "' rows='4' cols='120' class='description'>" .$comment_text .
  810. "</textarea>\n<br>";
  811. // Project/duty selection
  812. $list .= make_pdlist($staff, $row['comment_id'], $row['project_id'],
  813. $projects, $project_ids, $row['duty_id'], $duties, $duty_ids, 0);
  814. // Visibility selection
  815. $list .= "Visibility: ";
  816. $list .= "<select id='viscomment_" . $row['comment_id'] .
  817. "' name='viscomment_" . $row['comment_id'] .
  818. "'>\n";
  819. if ($row['visibility'] == 'Public') {
  820. $list .= "<option value='Public' selected>Public</option>\n";
  821. } else {
  822. $list .= "<option value='Public'>Public</option>\n";
  823. }
  824. if ($row['visibility'] == 'Private') {
  825. $list .= "<option value='Private' selected>Private</option>\n";
  826. } else {
  827. $list .= "<option value='Private'>Private</option>\n";
  828. }
  829. $list .= "</select><br>\n";
  830. // Update and cancel icons
  831. $list .= "<input type='button' value='Update' " .
  832. "onclick='{modify_comment(\"" . $row['comment_id'] .
  833. "\", \"editcomment\", \"$staff\", \"$project\", \"$duty\", " .
  834. "\"$fromdate\", \"$todate\", \"$pageflag\", \"$page\", \"$maxresults\");}'> &nbsp; &nbsp; " .
  835. "<input type='button' value='Cancel' onclick='hide_item(\"editcomment_" .
  836. $row['comment_id'] . "\");'></center><br></div>\n";
  837. // Set variable for project/duty flag
  838. printf("<script type='text/javascript'>\n");
  839. if ($row['project_id']) {
  840. printf("var pdflag_" . $row['comment_id'] . " = \"Project\";\n");
  841. } else if ($row['duty_id']) {
  842. printf("var pdflag_" . $row['comment_id'] . " = \"Duty\";\n");
  843. } else {
  844. printf("var pdflag_" . $row['comment_id'] . " = \"Project\";\n");
  845. }
  846. printf("</script>\n");
  847. // Div to confirm deletion
  848. $list .= "<div class='confirm' id='confirmcomment_" . $row['comment_id'] .
  849. "' ><font color='red'>" .
  850. "<center>Are you sure you want to delete this comment?</font><br>" .
  851. "<input type='button' value='Confirm Deletion' " .
  852. "onclick='{modify_comment(\"" . $row['comment_id'] .
  853. "\", \"deletecomment\", \"$staff\", \"$project\", \"$duty\", " .
  854. "\"$fromdate\", \"$todate\", \"$pageflag\", \"$page\", \"$maxresults\");" .
  855. "}'> &nbsp; &nbsp; " .
  856. "<input type='button' value='Cancel' onclick='hide_item(\"confirmcomment_" .
  857. $row['comment_id'] . "\");'></center><br></div>\n";
  858. $list .= "</div>\n";
  859. } else {
  860. // Don't show "Edit" icon
  861. $list .= "<td></td>";
  862. // Don't show "Delete" icon
  863. $list .= "<td></td></tr></table>\n";
  864. $list .= "</div>\n";
  865. }
  866. }
  867. // End comment block div
  868. $list .= "</div>\n";
  869. } else {
  870. if ($project) {
  871. $list .= "<b>No comments entered for this project.</b><br>\n";
  872. } else if ($duty) {
  873. $list .= "<b>No comments entered for this duty.</b><br>\n";
  874. } else {
  875. if ($displayed_user == "All") {
  876. $list .= "<b>No comments entered during this date range.</b><br>\n";
  877. } else {
  878. $list .= "<b>No comments entered by $displayed_user in this date range.</b><br>\n";
  879. }
  880. }
  881. }
  882. // Close the database connection
  883. $list_full->free_result();
  884. if ($pageflag) {
  885. $list_page->free_result();
  886. }
  887. $conn->close();
  888. return $list;
  889. }
  890. function show_project_comments($project, $edit_priv) {
  891. global $background_color;
  892. global $heading_color;
  893. $myList = "";
  894. $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
  895. or die ("Cannot connect to database. " . mysql_error() . "\n<br>");
  896. mysql_select_db(DB_DATABASE);
  897. $get_comments = mysql_query("select comment_id, comment_text, submit_date, " .
  898. "submit_time from comments where project_id = \"$project\" " .
  899. "order by submit_time desc ");
  900. if (mysql_num_rows($get_comments) == 0) {
  901. $myList .= "No comments entered for this project.<br>\n";
  902. }
  903. // Don't show edit or delete icons if user does not have edit_priv
  904. if ($edit_priv == "Y") {
  905. while ($row = mysql_fetch_array($get_comments, MYSQL_ASSOC))
  906. {
  907. $myList .= "<div id='comment_" . $row['comment_id'] . "'>";
  908. // Date submitted
  909. $myList .= "<table><tr valign='top'><td>" . short_date($row['submit_date
  910. ']) . "</td>\n";
  911. // Comment text
  912. $myList .= "<td bgcolor='white' style='{border: 1px solid $heading_color
  913. ; padding-left: 5px; padding-right: 5px;}'>"
  914. . $row['comment_text'] . "</td>\n";
  915. // "Edit" icon
  916. $myList .= "<td><img src='images/pencil.gif' style='{position:relative;
  917. padding-left:20px;}' " .
  918. "onclick='show_editbox(\"editcomment_" . $row['comment_id'] . "\");'
  919. ></td>";
  920. // "Delete" icon
  921. $myList .= "<td style='background-color:" . $background_color . "'><img src='images/trash.gif' onclick='show_confirm(\"confirmcomment_" . $row['comment_id'] . "\");'>" .
  922. "</td></tr></table>\n";
  923. // Div for edit box
  924. $myList .= "<div class='editbox' id='editcomment_" . $row['comment_id'] . "' style='background-color: white;'>" .
  925. "<center><font color='red'>Edit:</font><br>\n<textarea id='txtEditComment_" .
  926. $row['comment_id'] .
  927. "' rows='3' cols='100'>\n" .
  928. //"onkeydown='handleKeyEditComment(event, $project, " . $row['comment_id'] . ")'>\n" .
  929. $row['comment_text'] . "</textarea><br>" .
  930. "<img src='images/update_icon.png' " .
  931. "onclick='{var editcomm = $(\"comment_" . $row['comment_id'] . "\"); Element.hide(editcomm); " .
  932. "process_comments(" . $row['comment_id'] . ", \"editComment\", \"" . $project . "\");}'> &nbsp; &nbsp; " .
  933. //"process_comments(editcomm.id, \"editComment\", \"" . $project . "\");}'> &nbsp; &nbsp; " .
  934. "<img src='images/cancel_icon.png' onclick='hide_editbox(\"editcomment_" . $row['comment_id'] . "\");'></center></div>\n";
  935. // Div to confirm deletion
  936. $myList .= "<div class='confirm' id='confirmcomment_" . $row['comment_id'] . "' style='background-color: white;'><font color='red'>" .
  937. "<center>Are you sure you want to delete this item?</font><br>" .
  938. "<img src='images/confirm_delete_icon.png' " .
  939. "onclick='{var remcomm = $(\"comment_" . $row['comment_id'] . "\"); Element.hide(remcomm); " .
  940. "process_comments(" . $row['comment_id'] . ", \"delComment\", \"" .
  941. $project . "\");}'> &nbsp; &nbsp; " .
  942. "<img src='images/cancel_icon.png' onclick='hide_confirm(\"confirmcomment_" . $row['comment_id'] . "\");'></center></div>";
  943. $myList .= "</div>\n";
  944. }
  945. } else {
  946. while ($row = mysql_fetch_array($get_comments, MYSQL_ASSOC))
  947. {
  948. $myList .= "<div id='comment_" . $row['comment_id'] . "' style='background-color: white'>";
  949. // Date submitted
  950. $myList .= "<table><tr valign='top'><td>" . short_date($row['submit_date']) . "</td>\n";
  951. // Comment text
  952. $myList .= "<td bgcolor='white' style='border: 1px solid $heading_color;'>"
  953. . $row['comment_text'] . "</td>\n";
  954. // Don't show "Edit" icon
  955. $myList .= "<td></td>";
  956. // Don't show "Delete" icon
  957. $myList .= "<td></td></tr></table>\n";
  958. $myList .= "</div>\n";
  959. }
  960. }
  961. mysql_free_result($get_comments);
  962. mysql_close($conn);
  963. return $myList;
  964. }
  965. function ugly_date($formatted_date) {
  966. if ($formatted_date) {
  967. $parts = explode(" ", $formatted_date);
  968. $months = array("January", "February", "March", "April", "May", "June", "July",
  969. "August", "September", "October", "November", "December");
  970. $monthnum = array_search($parts[0], $months) + 1;
  971. if (strlen($monthnum) < 2) {
  972. $monthnum = "0" . $monthnum;
  973. }
  974. $daynum = substr($parts[1], 0, strlen($parts[1]) - 1);
  975. if (strlen($daynum) < 2) {
  976. $daynum = "0" . $daynum;
  977. }
  978. $year = $parts[2];
  979. $newformat = $year . "-" . $monthnum . "-" . $daynum;
  980. return $newformat;
  981. } else {
  982. return $formatted_date;
  983. }
  984. }
  985. function pretty_date($formatted_date) {
  986. if ($formatted_date) {
  987. if ($formatted_date == "0000-00-00") {
  988. return "";
  989. }
  990. $parts = explode("-", $formatted_date);
  991. $months = array("January", "February", "March", "April", "May", "June", "July",
  992. "August", "September", "October", "November", "December");
  993. $monthname = $months[$parts[1] - 1];
  994. $daynum = $parts[2];
  995. if (substr($daynum, 0, 1) == "0") {
  996. $daynum = substr($daynum, 1);
  997. }
  998. $year = $parts[0];
  999. $newformat = "$monthname $daynum, $year";
  1000. return $newformat;
  1001. } else {
  1002. return $formatted_date;
  1003. }
  1004. }
  1005. function short_date($formatted_date) {
  1006. if ($formatted_date) {
  1007. if ($formatted_date == "0000-00-00") {
  1008. ret

Large files files are truncated, but you can click here to view the full file