";
echo "raport z LMSa HELPDESK.
";
echo "
";
#podlaczenie do bazy danych
$sql = mysql_connect('localhost', 'nazwa_bazy_LMS', 'twoje_haslo_do_bazy_lms');
#echo "
";
#echo $sql;
#echo mysql_error();
#wybor bazy danych
$db = mysql_select_db('nazwa_bazy_LMS');
#echo "
";
#koniec zapytania
$zapytanie = "SET names latin2";
$odp2 = mysql_query($zapytanie);
#zapytanie 2
$zapytanie = "SELECT `id`,`queueid`,`requestor`,`customerid`,`subject`,`state`,`cause`,`owner`, `createtime`, `resolvetime` FROM `rttickets` WHERE `createtime` > 1293840925 AND `createtime` < 1301616925";
#$zapytanie = "SELECT * FROM `rttickets` WHERE 1";
$odp2 = mysql_query($zapytanie);
#to zwraca wszystkie rekordy po kolei
while($row2 = mysql_fetch_array($odp2, MYSQL_BOTH)) {
$ownerid = $row2[5];
$zid = $row2[0];
$subject = $row2[4];
if ($row2[5]==0){
$state = "nowy";
}elseif ($row2[5]==1){
$state = "otwarty";
}elseif ($row2[5]==2){
$state = "rozwiazany";
}elseif ($row2[5]==3){
$state = "martwy";
}
# $state = $row2[5];
if ($row2[6]==0){
$cause = "nieznana";
}elseif ($row2[6]==1){
$cause = "po str. klienta";
}elseif ($row2[6]==2){
$cause = "po str. firmy";
}
# $cause = $row2[6];
$customerid = $row2[3];
$createtime=date('d-m-Y H:i:s',$row2[8]);
$uptimes=$row2[9]-$row2[8];
$uptimed=date('z H:i:s',$uptimes);
# echo $customerid;
#echo "lala";
#wyciagam dane o powiazaniu grupy z klientem
$zapytanie3 = "SELECT `lastname`,`name`,`address`,`zip`,`city` FROM `customers` WHERE `id` = ".$customerid;
$odp3 = mysql_query($zapytanie3);
# echo "odp".$odp3;
#dostajemy dane ludka
while($row3 = mysql_fetch_array($odp3,MYSQL_BOTH)){
$lastname = $row3[0];
$name = $row3[1];
$address = $row3[2];
$zip = $row3[3];
$city = $row3[4];
}
#wyciagam dane zgloszenia z rtmessages
$zapytanie = "SELECT `body`, `createtime` FROM `rtmessages` WHERE `ticketid` = ".$zid;
$odp4 = mysql_query($zapytanie);
$body="";
while($row4 = mysql_fetch_array($odp4,MYSQL_BOTH)){
$body = $body." Data wpisu : ".date('d-m-Y H:i:s',$row4[1])." Tre�� wpisu : ".$row4[0]."
";
# $body = mysql_result($odp4,0,0);
}
#wyciagam notatki z rtnotes
$zapytanie = "SELECT `body`,`createtime` FROM `rtnotes` WHERE `ticketid` = ".$zid;
$odp5 = mysql_query($zapytanie);
$bodyn="";
while($row5 = mysql_fetch_array($odp5,MYSQL_BOTH)){
$bodyn = $bodyn." Data wpisu : ".date('d-m-Y H:i:s',$row5[1])." Tre�� wpisu : ".$row5[0]."
";
# echo "bodyn";
}
echo "---------------------------------------------------------------------------------------------------------------------------------
";
echo $zid." ".$subject." ".$lastname." ".$name." ".$zip." ".$city."
Data zg�oszenia : ".$createtime."
Czas usuni�cia (dni, godziny): ".$uptimed."
".$body." ".$bodyn."
Stan zg�oszenia : ".$state."
Przyczyna : ".$cause."
";
}
mysql_close($sql);
echo "
";
echo "Raport SUKCES.
";
$SMARTY->display('footer.html');
?>