PageRenderTime 153ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/pos/is4c/fannie/reports/hourlySales.php

https://github.com/maxolasersquad/FLOSS-POS
PHP | 116 lines | 112 code | 4 blank | 0 comment | 4 complexity | 40a3a872443285e5a338cb3f900c3cd4 MD5 | raw file
Possible License(s): GPL-2.0
  1. <html>
  2. <?php
  3. if(isset($_POST['submit'])){
  4. foreach ($_POST AS $key => $value) {
  5. $$key = $value;
  6. }
  7. }else{
  8. foreach ($_GET AS $key => $value) {
  9. $$key = $value;
  10. }
  11. }
  12. if($date0 != '') {
  13. $date1 = $date0;
  14. $date2 = $date0;
  15. $date0a = $date0 . " 00:00:00";
  16. $day = date("l",$date0a);
  17. $title = $day."s Hourly Sales For ".$date0;
  18. } else {
  19. $title = $day."s Hourly Sales For ".$date1." thru ".$date2;
  20. }
  21. echo "<HEAD>";
  22. echo "<link href='../style.css' rel='stylesheet'' type='text/css' />";
  23. echo "<title>".$title."</title>";
  24. echo "</HEAD>";
  25. echo "<BODY>";
  26. $date1a = $date1 . " 00:00:00";
  27. $date2a = $date2 . " 23:59:59";
  28. $db = mysql_connect("localhost","root");
  29. mysql_select_db("is4c_log",$db);
  30. $num1 = 0;
  31. $num2 = 0;
  32. $query1="SELECT date_format(datetime,'%H') AS hour,ROUND(sum(total),2) as Sales
  33. FROM dtransactions
  34. WHERE date_format(datetime,'%W') = '$day'
  35. AND datetime > '$date1a'
  36. AND datetime < '$date2a'
  37. AND department <= 13
  38. AND department <> 0
  39. AND trans_status <> 'X'
  40. AND emp_no <> 9999
  41. GROUP BY hour
  42. ORDER BY hour";
  43. $query2="SELECT ROUND(sum(total),2) as TotalSales
  44. FROM dtransactions
  45. WHERE datetime > '$date1a'
  46. AND datetime < '$date2a'
  47. AND date_format(datetime,'%W') = '$day'
  48. AND trans_status <> 'X'
  49. AND department <= 13
  50. AND department <> 0
  51. AND emp_no <> 9999";
  52. $transCountQ = "SELECT date_format(datetime,'%H') AS hour,COUNT(total) as transactionCount
  53. FROM dtransactions
  54. WHERE date_format(datetime,'%W') = '$day'
  55. AND datetime > '$date1a'
  56. AND datetime < '$date2a'
  57. AND trans_status <> 'X'
  58. AND emp_no <> 9999
  59. AND upc = 'DISCOUNT'
  60. GROUP BY hour
  61. ORDER BY hour";
  62. $result1 = mysql_query($query1);
  63. $result2 = mysql_query($query2);
  64. $result3 = mysql_query($transCountQ);
  65. $num1 = mysql_num_rows($result1);
  66. $num2 = mysql_num_rows($result3);
  67. $row2 = mysql_fetch_row($result2);
  68. echo "<center><h2>";
  69. echo $title;
  70. echo "</h2>";
  71. echo "<table>";
  72. echo "<tr align='center'><td><b>Hour</b></td><td><b>Sales</b></td><td>&nbsp</td><td><b>Pct.</b></td><td><b>Count</b></tr>";
  73. while(($row1 = mysql_fetch_row($result1)) && ($row3 = mysql_fetch_row($result3))){
  74. $sales = $row1[1];
  75. $gross = $row2[0];
  76. $count = $row3[1];
  77. $portSales = $sales/$gross;
  78. $twoperSales = $portSales * 200;
  79. $percentage = money_format('%i',100 * $portSales);
  80. echo "<tr><td align='center'>".$row1[0]."</td><td align='right'>".$row1[1]."</td>";
  81. echo "<td><img src=../image.php?size=$twoperSales></td>";
  82. echo "<td align='right'>".$percentage." %</td>";
  83. echo "<td align='right'>".$count."</td></tr>";
  84. }
  85. echo "<tr><td>&nbsp</td></tr><tr><td><b>Gross Total:</b></td>";
  86. echo "<td><p><b>".$gross."</b></p></td></tr>";
  87. echo "</table></center>";
  88. //
  89. // PHP INPUT DEBUG SCRIPT -- very helpful!
  90. //
  91. /*
  92. function debug_p($var, $title)
  93. {
  94. print "<p>$title</p><pre>";
  95. print_r($var);
  96. print "</pre>";
  97. }
  98. debug_p($_REQUEST, "all the data coming in");
  99. */
  100. echo "</BODY>";
  101. ?>
  102. </html>