By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

frustrating question

P: 22
I have searched high and low and am stumped on this. The below code is a checklist form for work. there are 2 shifts 7 days a week and it displays the checklist items for each shift. something i did not plan on was a bi-weekly task. (dumb oversight, I know) Can anyone point me in the right direction to add an item that would only occur every 2 weeks. thanks in advance

Expand|Select|Wrap|Line Numbers
  1. <?
  2. include_once('./sql_connect.php');
  3. include_once('./links.php');
  4. echo $links;
  5. $current_day = date("l");
  6. $current_time = date("His");
  7. $current_date = date("Y-m-d ");
  8. $tomorrow_day = date("d")+1;
  9. $tomorrow = date("Y-m-$tomorrow_day");
  10. $yesterday_day = date("d")-1;
  11. $yesterday = date("Y-m-$yesterday_day");
  12.  
  13.  
  14. if ($current_time > '060000' and $current_time <= '180000')
  15. {
  16. $start_time = $current_date . " 06:00:00";
  17. $end_time = $current_date . " 18:00:00";
  18. $Shift = "Day";
  19.  
  20. //get todays checklist
  21. $sql = ("SELECT * FROM CheckList WHERE Item NOT IN (SELECT Item FROM CheckDone WHERE
  22.  (TimeofEvent BETWEEN '$start_time' AND '$end_time')) 
  23. AND ($current_day='1' AND Shift='$Shift') ORDER BY Time ASC");
  24.  
  25.  
  26. } elseif ($current_time >= '000000' && $current_time <= '060000') {
  27.  
  28. $start_time = $current_date . " 18:00:00";
  29. $end_time = $current_date . " 06:00:00";
  30. $today_start_time = $current_date . " 00:00:00";
  31. $today_end_time = $current_date . " 05:59:59";
  32. $yesterday_start_time = $yesterday . " 18:00:00";
  33. $yesterday_end_time = $yesterday . " 23:59:59";
  34. $Shift = "Evening";
  35. $start_today = "00:00";
  36. $end_today = "05:59";
  37. $start_yesterday = "18:01";
  38. $end_yesterday = "23:59";
  39.  
  40. // get yesterday evening and sort by time first
  41. $sql = ("SELECT * FROM CheckList WHERE Item NOT IN (SELECT Item FROM CheckDone WHERE 
  42. (TimeofEvent BETWEEN '$yesterday_start_time' AND '$yesterday_end_time')
  43. OR (TimeofEvent BETWEEN '$today_start_time' AND '$today_end_time')) 
  44. AND ($current_day='1' AND Shift='$Shift') AND (Time BETWEEN '$start_yesterday' AND '$end_yesterday')
  45. ORDER BY Time ASC");
  46.  
  47. $print_sql = "SELECT * FROM CheckList WHERE Item NOT IN (SELECT Item FROM CheckDone WHERE 
  48. (TimeofEvent BETWEEN '$yesterday_start_time' AND '$yesterday_end_time')
  49. OR (TimeofEvent BETWEEN '$today_start_time' AND '$today_end_time')) 
  50. AND ($current_day='1' AND Shift='$Shift') AND (Time BETWEEN '$start_yesterday' AND '$end_yesterday')
  51. ORDER BY Time ASC";
  52.  
  53. /*
  54. // get yesterday evening and sort by time first
  55. $sql = ("SELECT * FROM CheckList WHERE Item NOT IN (SELECT Item FROM CheckDone 
  56. WHERE (TimeofEvent BETWEEN '$today_start_time' AND '$today_end_time')) 
  57. AND ($current_day='1' AND Shift='$Shift') AND (Time BETWEEN '$start_today' AND '$end_today') 
  58. ORDER BY Time ASC");
  59. */
  60.  
  61.  
  62. //get todays checklist items
  63. $sql1 = ("SELECT * FROM CheckList WHERE Item NOT IN (SELECT Item FROM CheckDone WHERE 
  64. (TimeofEvent BETWEEN '$yesterday_start_time' AND '$yesterday_end_time')
  65. OR (TimeofEvent BETWEEN '$today_start_time' AND '$today_end_time')) 
  66. AND ($current_day='1' AND Shift='$Shift') AND (Time BETWEEN '$start_today' AND '$end_today') 
  67. ORDER BY Time ASC");
  68.  
  69. $result1 = mysql_query($sql1);
  70. $check_result1 = mysql_num_rows($result1);
  71.  
  72. } else {
  73. $start_time = $current_date . " 18:00:00";
  74. $end_time = $current_date . " 06:00:00";
  75. $today_start_time = $current_date . " 18:01:00";
  76. $today_end_time = $current_date . " 23:59:59";
  77. $tomorrow_start_time = $yesterday . " 00:00:00";
  78. $tomorrow_end_time = $yesterday . " 05:59:59";
  79. $start_tomorrow = "00:01";
  80. $end_tomorrow = "05:59";
  81. $Shift = "Evening";
  82.  
  83. //select todays items
  84. $sql = ("SELECT * FROM CheckList WHERE Item NOT IN (SELECT Item FROM CheckDone 
  85. WHERE (TimeofEvent BETWEEN '$today_start_time' AND '$today_end_time')) 
  86. AND ($current_day='1' AND Shift='$Shift') AND Time BETWEEN '$today_start_time' AND '$today_end_time' 
  87. ORDER BY Time ASC");
  88.  
  89. $midnight = "<font color=red>At midnight, you will get the checklist items for midnight-6am.</font> <br />";
  90.  
  91.  
  92. }
  93.  
  94.  
  95.  
  96.  
  97. $result = mysql_query($sql);
  98.  
  99. $check_result = mysql_num_rows($result);
  100.  
  101.  
  102. if(!$result) {
  103. echo "Error! \nresult";
  104. }
  105.  
  106.  
  107. $Shift_Head = $Shift . " Shift " . $current_day . " " . $current_date .  "<br />";
  108. $Print_Form = "<form method='POST' action='checkdone.php'>
  109.  $SubmittedBy_List
  110. <input type='submit' value='submit'><br />";
  111.  
  112.  
  113.  
  114. While (list($Item, $Event) = mysql_fetch_row($result))
  115. {
  116. $CheckItems = $CheckItems. "<input type='checkbox' name='Item[]' value='$Item'> " . $Event . "\n" . "<br />\n";
  117. }
  118.  
  119.  
  120. if($check_result1 > 0) {
  121. While (list($Item, $Event) = mysql_fetch_row($result1))
  122. {
  123. $CheckItems = $CheckItems. "<input type='checkbox' name='Item[]' value='$Item'> " . $Event . "\n" . "<br />\n";
  124. //yesterday night first
  125. if(!$result1) {
  126. echo "Error! \n  result1";
  127. }
  128.  
  129. }
  130. }
  131.  
  132.  
  133. $CheckItems = $CheckItems. "</form>";
  134.  
  135. /// print content
  136.  
  137. echo "<div id='content'>"
  138. .$Shift_Head
  139. .$Print_Form
  140. .$midnight
  141. .$CheckItems
  142.  
  143. ."</div>";
  144.  
  145.  
  146.  
  147. ?>
  148. </body>
  149. </html>
  150.  
Aug 20 '08 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
have you any idea yet, how to distinguish between weekly and bi-weekly tasks? Then you could use (odd/even) week numbers to differentiate.
Aug 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.