Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function form($c){
- $year = $_POST['year'];
- $month = $_POST['month'];
- $nazwisko = $_POST['nazwisko'];
- if (isUser()){
- $add_where = "where left(kod,3)=".$_SESSION['user'];
- }
- $q = "select distinct year(data) from grafik order by data desc";
- $q_res = mysql_query($q,$c);
- $rows = mysql_num_rows($q_res);
- $q2 = "select distinct month(data) from grafik order by data desc";
- $q2_res = mysql_query($q2,$c);
- $rows2 = mysql_num_rows($q2_res);
- $q3 = "select distinct nazwisko from grafik $add_where order by nazwisko";
- $q3_res = mysql_query($q3,$c);
- $rows3 = mysql_num_rows($q3_res);
- echo "<form action='grafik.php' method='post'><table width=100%>";
- echo "<tr class='headrow'><th colspan=9>GRAFIK PRACOWNIKÓW</th></tr>";
- 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>";
- echo "<tr><td align=right>Pracownik:</td><td><select name='nazwisko'>";
- echo "<option value=''>wszystkie</option>";
- for($i=0; $i<$rows3; $i++) {
- $nazwiska = mysql_fetch_row($q3_res);
- $sel = '';
- if ($nazwisko==$nazwiska[0]){$sel = 'selected';}
- echo "<option value=$nazwiska[0] $sel>$nazwiska[0]</option>";
- }
- echo "</select></td>";
- echo "<td align=right>Miesiąc:</td><td><select name='month'>";
- //echo "<option value=''>wszystkie</option>";
- for($i=0; $i<$rows2; $i++) {
- $months = mysql_fetch_row($q2_res);
- $checked = '';
- if ($month==$months[0]) {$checked='selected';}
- echo "<option value=$months[0] $checked>$months[0]</option>";
- }
- echo "</select></td>";
- echo "<td align=right>Rok:</td><td><select name='year'>";
- //echo "<option value=''>wszystkie</option>";
- for($i=0; $i<$rows; $i++) {
- $years = mysql_fetch_row($q_res);
- $checked = '';
- if ($year==$years[0]) {$checked='selected';}
- echo "<option value=$years[0] $checked>$years[0]</option>";
- }
- echo "</select></td>";
- echo "<td><input type='submit' value='Wybierz'></td>";
- echo "<tr><td></td></tr>";
- echo "</tr></table></form>";
- }
- function grafiks($c){
- $year = $_POST['year'];
- $month = $_POST['month'];
- $nazwisko = $_POST['nazwisko'];
- if (!empty($year)){
- $where1 = "and year(data)='$year'";
- }
- if (!empty($month)){
- $where2 = " and month(data)='$month'";
- }
- if (!empty($nazwisko)){
- $where3 = " and nazwisko='$nazwisko'";
- }
- if (isUser()){
- $where4 = " and left(kod,3)=".$_SESSION['user'];
- }
- $q = "select kod,nazwisko,imie,data,w1_godzod,w1_godzdo,typdnia,w1_strefa,opis,concat
- ((left(w1_godzdo,INSTR(w1_godzdo, ':')-1)*60 + right(w1_godzdo,INSTR(w1_godzdo, ':')-1)) -
- (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";
- $q_res = mysql_query($q,$c);
- $rows = mysql_num_rows($q_res);
- $q2 = "select sum(concat
- ((left(w1_godzdo,INSTR(w1_godzdo, ':')-1)*60 + right(w1_godzdo,INSTR(w1_godzdo, ':')-1)) -
- (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 ";
- $q2_res = mysql_query($q2,$c);
- $rows2 = mysql_num_rows($q2_res);
- echo "<table>";
- 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> </td></tr>";
- for($i=0; $i<$rows; $i++) {
- $rowstyle = 'lightrow';
- if ($i%2==0) $rowstyle='darkrow';
- $wiersz = mysql_fetch_row($q_res);
- echo "<tr class='$rowstyle'>
- <td>".($i+1)."</td>
- <td >$wiersz[1]</td>
- <td >$wiersz[2]</td>
- <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[3]</td>
- <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[4]</td>
- <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[5]</td>
- <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[9]</td>
- <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[6]</td>
- <td style='color:".($wiersz[6]=='P'?'black':'green')."'>$wiersz[8]</td>
- <td><a href='grafik.php?pracownik=$wiersz[1]&dzien=$wiersz[3]&pracimie=$wiersz[2]'>Edytuj</a></td>
- </tr>";
- }
- $wiersz2 = mysql_fetch_row($q2_res);
- 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> </td></tr>";
- echo "</table>";
- }
Advertisement
Add Comment
Please, Sign In to add comment