Guest User

Untitled

a guest
Feb 4th, 2022
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. function form($c){
  2. $year = $_POST['year'];
  3. $month = $_POST['month'];
  4. $nazwisko = $_POST['nazwisko'];
  5.  
  6.  
  7. if (isUser()){
  8. $add_where = "where left(kod,3)=".$_SESSION['user'];
  9. }
  10.  
  11. $q = "select distinct year(data) from grafik order by data desc";
  12. $q_res = mysql_query($q,$c);
  13. $rows = mysql_num_rows($q_res);
  14.  
  15. $q2 = "select distinct month(data) from grafik order by data desc";
  16. $q2_res = mysql_query($q2,$c);
  17. $rows2 = mysql_num_rows($q2_res);
  18.  
  19. $q3 = "select distinct nazwisko from grafik $add_where order by nazwisko";
  20. $q3_res = mysql_query($q3,$c);
  21. $rows3 = mysql_num_rows($q3_res);
  22.  
  23.  
  24. echo "<form action='grafik.php' method='post'><table width=100%>";
  25.  
  26. echo "<tr class='headrow'><th colspan=9>GRAFIK PRACOWNIKÓW</th></tr>";
  27. echo "<tr> <td colspan=9 align='center' style='background-color:#FFFFFF; padding:0;'><img src='/images/grafik.jpg' alt='' border=0 width=312 height=265></center></td></tr>";
  28.  
  29. echo "<tr><td align=right>Pracownik:</td><td><select name='nazwisko'>";
  30. echo "<option value=''>wszystkie</option>";
  31. for($i=0; $i<$rows3; $i++) {
  32. $nazwiska = mysql_fetch_row($q3_res);
  33. $sel = '';
  34. if ($nazwisko==$nazwiska[0]){$sel = 'selected';}
  35. echo "<option value=$nazwiska[0] $sel>$nazwiska[0]</option>";
  36. }
  37. echo "</select></td>";
  38.  
  39.  
  40. echo "<td align=right>Miesiąc:</td><td><select name='month'>";
  41. //echo "<option value=''>wszystkie</option>";
  42. for($i=0; $i<$rows2; $i++) {
  43. $months = mysql_fetch_row($q2_res);
  44. $checked = '';
  45. if ($month==$months[0]) {$checked='selected';}
  46. echo "<option value=$months[0] $checked>$months[0]</option>";
  47. }
  48. echo "</select></td>";
  49.  
  50.  
  51.  
  52. echo "<td align=right>Rok:</td><td><select name='year'>";
  53. //echo "<option value=''>wszystkie</option>";
  54. for($i=0; $i<$rows; $i++) {
  55. $years = mysql_fetch_row($q_res);
  56. $checked = '';
  57. if ($year==$years[0]) {$checked='selected';}
  58. echo "<option value=$years[0] $checked>$years[0]</option>";
  59. }
  60. echo "</select></td>";
  61.  
  62.  
  63. echo "<td><input type='submit' value='Wybierz'></td>";
  64. echo "<tr><td></td></tr>";
  65. echo "</tr></table></form>";
  66. }
  67.  
  68.  
  69.  
  70.  
  71.  
  72. function grafiks($c){
  73. $year = $_POST['year'];
  74. $month = $_POST['month'];
  75. $nazwisko = $_POST['nazwisko'];
  76.  
  77.  
  78. if (!empty($year)){
  79. $where1 = "and year(data)='$year'";
  80. }
  81. if (!empty($month)){
  82. $where2 = " and month(data)='$month'";
  83. }
  84. if (!empty($nazwisko)){
  85. $where3 = " and nazwisko='$nazwisko'";
  86. }
  87. if (isUser()){
  88. $where4 = " and left(kod,3)=".$_SESSION['user'];
  89. }
  90.  
  91. $q = "select kod,nazwisko,imie,data,w1_godzod,w1_godzdo,typdnia,w1_strefa,opis,concat
  92. ((left(w1_godzdo,INSTR(w1_godzdo, ':')-1)*60 + right(w1_godzdo,INSTR(w1_godzdo, ':')-1)) -
  93. (left(w1_godzod,INSTR(w1_godzod, ':')-1)*60 + right(w1_godzod,INSTR(w1_godzod, ':')-1)))/60 as suma_dnia from grafik where typdnia<>'' $where1 $where2 $where3 $where4 order by kod,data";
  94. $q_res = mysql_query($q,$c);
  95. $rows = mysql_num_rows($q_res);
  96.  
  97.  
  98. $q2 = "select sum(concat
  99. ((left(w1_godzdo,INSTR(w1_godzdo, ':')-1)*60 + right(w1_godzdo,INSTR(w1_godzdo, ':')-1)) -
  100. (left(w1_godzod,INSTR(w1_godzod, ':')-1)*60 + right(w1_godzod,INSTR(w1_godzod, ':')-1))))/60 as suma_dnia from grafik where typdnia<>'' $where1 $where2 $where3 $where4 ";
  101. $q2_res = mysql_query($q2,$c);
  102. $rows2 = mysql_num_rows($q2_res);
  103.  
  104.  
  105.  
  106. echo "<table>";
  107. echo "<tr class='headrow'><td>L.P.</td><td>Nazwisko</td><td>Imie</td><td>Data</td><td>OD</td><td>DO</td><td>Godzin</td><td>Kod</td><td>TypDnia</td><td>&nbsp;</td></tr>";
  108.  
  109. for($i=0; $i<$rows; $i++) {
  110. $rowstyle = 'lightrow';
  111. if ($i%2==0) $rowstyle='darkrow';
  112. $wiersz = mysql_fetch_row($q_res);
  113. echo "<tr class='$rowstyle'>
  114. <td>".($i+1)."</td>
  115. <td >$wiersz[1]</td>
  116. <td >$wiersz[2]</td>
  117. <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[3]</td>
  118. <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[4]</td>
  119. <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[5]</td>
  120. <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[9]</td>
  121. <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[6]</td>
  122.  
  123. <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[8]</td>
  124. <td><a href='grafik.php?pracownik=$wiersz[1]&dzien=$wiersz[3]&pracimie=$wiersz[2]'>Edytuj</a></td>
  125. </tr>";
  126. }
  127. $wiersz2 = mysql_fetch_row($q2_res);
  128.  
  129. echo "<tr class='headrow'><td></td><td>Suma godzin</td><td>$wiersz2[0]</td> <td></td><td></td><td></td><td></td><td></td><td></td><td>&nbsp;</td></tr>";
  130.  
  131. echo "</table>";
  132.  
  133.  
  134.  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment