<%@
LANGUAGE=VBScript%>
<% Response.Buffer = TRUE %>
--------
RESULTS.ASP
Displays
the results in a table from SEARCH.ASP.
--------
-->
<!--
#include file = "../public.asp" -->
<%
Dim
adoCon, sid
Set adoCon = CreateCon
sid = GetSid
%>
<html>
<head>
<title>Help Desk - Résultats</title>
<link rel="stylesheet" type="text/css"
href="../../../../../format.css">
</head>
<body bgcolor="<% = Cfg(adoCon, "BGColor")
%>" text="<% = Cfg(adoCon, "TextColor")
%>"
link="<% = Cfg(adoCon, "LinkColor") %>"
vlink="<% = Cfg(adoCon, "VLinkColor") %>"
alink="<% = Cfg(adoCon, "ALinkColor") %>">
<%
' Check if user has permissions for this page
Call CheckRep(adoCon, sid)
' Get the search fields from the form.
Dim uid, id, rep, category, department, description, solution,
priority, order,p, numero_page
p=0
tour = Request.form("form_p")
Dim status()
For p = 0 to tour
Redim Preserve status(p+1)
status(p) = Request.Form("status" & p)
'response.write("status :"&status(p))
Next
p_type=0
tour_type = Request.form("form_p_type")
Dim Rtype()
For p_type = 0 to tour_type
Redim Preserve Rtype(p_type+1)
Rtype(p_type) = Request.Form("type" & p_type)
'response.write("type :"&Rtype(p_type))
Next
choix_date = Request.form("choix_date")
uid = Trim(Request.Form("uid"))
rep = Cint(Request.Form("rep"))
category = Cint(Request.Form("category"))
department = Cint(Request.Form("department"))
description = Trim(Request.Form("description"))
solution = Trim(Request.Form("solution"))
titre = Trim(Request.Form("form_titre"))
priority = Cint(Request.Form("priority"))
applications = Cint(Request.Form("applications"))
order = Cint(Request.Form("order"))
ligne = Cint(Request.Form("ligne_form"))
operateur_logique = Cint(Request.Form("form_logique"))
numero_page = Cint(Request.Form("numero_page_form"))
'response.write("numero : "&numero_page)
id = Trim(Request.Form("id"))
If IsNumeric(id) Then
id = Cint(id)
Else
id = 0
End If
' Convert to valid characters
description = Replace(description,"'","''")
solution = Replace(solution,"'","''")
titre = Replace(titre,"'","''")
uid = Replace(uid,"'","''")
' recuperer les mots cles du champ description
if description <> "" then
myarray = Split(description)
NbTabIndice_description=UBound(myarray)
end if
if
solution <> "" then
myarraySolu = Split(solution)
NbTabIndice_solution=UBound(myarraySolu)
end if
if
titre <> "" then
myarrayTitre = Split(titre)
NbTabIndice_titre=UBound(myarraytitre)
end if
' Create the query string. Only get 100 results. String is in
two
' parts, listStr (here) and whereStr (below).
'Dim listStr, whereStr
'listStr = "SELECT p.id, p.title, p.start_date, p.uid,
p.uemail, p.applications, p.type_prob, p.category, r.uid AS
ruid, s.sname " & _
'"FROM (ANO_problems AS p " & _
'"INNER JOIN ANO_tblUsers AS r ON p.rep = r.sid) "
& _
'"INNER JOIN ANO_status AS s ON p.status = s.status_id
" & _
'"WHERE "
Dim listStr, whereStr
listStr = "SELECT p.id, p.title, p.start_date, p.prob_uid,
p.uemail, r.uid ruid, s.sname, ANO_applications.appliname, ANO_categories.cname,
ANO_type.typename FROM ANO_applications, ANO_type, ANO_categories,
ANO_problems p, ANO_tblUsers r, ANO_status s WHERE (p.rep =
r.sid) AND (p.status = s.status_id) AND (p.applications = ANO_applications.appli_id)
AND (p.category = ANO_categories.category_id) AND (p.type_prob
= ANO_type.type_id) AND "
' Convert the start and end dates to valid ODBC dates
Dim start_date, end_date
If Len(Request.Form("start_date")) > 0 Then
start_date = Request.Form("start_date")
Else
start_date = Request.Form("s_month") & "/"
& Request.Form("s_day") & "/" &
Request.Form("s_year")
start_date = start_date & " 00:00:00"
End If
If Len(Request.Form("end_date")) > 0 Then
end_date = Request.Form("end_date")
Else
end_date = Request.Form("e_month") & "/"
& Request.Form("e_day") & "/" &
Request.Form("e_year")
end_date = end_date & " 23:59:59"
End If
'
pour que la id soit independant de la date
If id <> 0 Then
start_date = "01/01/2000"
end_date = "12/31/2050"
end if
' pour que la recherche ne tiennent pas compte de la date
If choix_date = "date_invalide" Then
start_date = "01/01/2000"
end_date = "12/31/2050"
end if
'response.write("start_date:
"&start_date)
'response.write("end_date:
"&end_date)
' If a field was filled in on the search form, add it to the
where string.
' Insert the dates to search between.
If (Application("DBType") = 3) OR (Application("DBType")
= 4) Then
whereStr = "p.start_date >'" & start_date &
"' AND p.start_date<'" & end_date & "'"
Else
whereStr = "p.start_date >'" & start_date &
"' AND p.start_date<'" & end_date & "'"
End If
If Len(uid) > 0 Then
whereStr = whereStr & " AND UPPER(p.prob_uid) LIKE
UPPER('" & uid & "')"
End If
If id <> 0 Then
whereStr = whereStr & " AND p.id=" & id
End If
If rep <> 0 Then
whereStr = whereStr & " AND p.rep=" & rep
End If
If category <> 0 Then
whereStr = whereStr & " AND p.category=" &
category
End If
If department <> 0 Then
whereStr = whereStr & " AND p.department=" &
department
End If
Dim
m
m=0
For p=0 to tour
if status(p)>0 and m=0 then
whereStr = whereStr & "AND("
m=m+1
end if
NEXT
dim
n
n=0
For p=0 to tour
If status(p) <> 0 Then
If status(p) > 0 Then
whereStr = whereStr & "p.status= "& status(p)&"
OR "
Else
whereStr = whereStr & " AND p.status<>"
& Cfg(adoCon, "CloseStatus")
End If
End if
NEXT
if Mid (whereStr , Len(whereStr)-2,3) = "OR " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -3)
end if
Dim q
q=0
for p=0 to tour
if status(p)>0 and q= 0 then
whereStr = whereStr & ")"
q=q+1
end if
next
Dim
m_type
m_type=0
For p_type=0 to tour_type
if Rtype(p_type)>0 and m_type=0 then
whereStr = whereStr & "AND("
m_type=m_type+1
end if
NEXT
dim
n_type
n_type=0
For p_type=0 to tour_type
If Rtype(p_type) <> 0 Then
If Rtype(p_type) > 0 Then
whereStr = whereStr & "p.type_prob= "& Rtype(p_type)&"
OR "
Else
whereStr = whereStr & " AND p.type_prob<>"
& Cfg(adoCon, "CloseStatus")
End If
End if
NEXT
if Mid (whereStr , Len(whereStr)-2,3) = "OR " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -3)
end if
Dim q_type
q_type=0
for p_type=0 to tour_type
if Rtype(p_type)>0 and q_type= 0 then
whereStr = whereStr & ")"
q_type=q_type+1
end if
next
If priority <> 0 Then
whereStr = whereStr & " AND p.priority=" &
priority
End If
If applications <> 0 Then
whereStr = whereStr & " AND p.applications=" &
applications
End If
If description <> "" Then
Dim m_description, p_description
p_description = 0
m_description=0
For p_description=0 to NbTabIndice_description
if myarray(p_description)<>"" and m_description=0
then
whereStr = whereStr & "AND("
m_description=m_description+1
end if
NEXT
For
p_description=0 to NbTabIndice_description
if operateur_logique = 1 then
whereStr = whereStr & "p.description LIKE '%"&
myarray(p_description)&"%' AND "
else
whereStr = whereStr & "p.description LIKE '%"&
myarray(p_description)&"%' OR "
end if
NEXT
if operateur_logique = 1 then
if Mid (whereStr , Len(whereStr)-3,4) = "AND " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -4)
end if
else
if Mid (whereStr , Len(whereStr)-2,3) = "OR " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -3)
end if
end if
Dim q_description
q_description=0
for p_description=0 to NbTabIndice_description
if myarray(p_description) <> "" and q_description=
0 then
whereStr = whereStr & ")"
q_description=q_description+1
end if
next
End If
If solution <> "" Then
Dim m_solution, p_solution
p_solution = 0
m_solution=0
For p_solution=0 to NbTabIndice_solution
if myarraySolu(p_solution)<>"" and m_solution=0
then
whereStr = whereStr & "AND("
m_solution=m_solution+1
end if
NEXT
For
p_solution=0 to NbTabIndice_solution
if operateur_logique = 1 then
whereStr = whereStr & "p.solution LIKE '%"&
myarraySolu(p_solution)&"%' AND "
else
whereStr = whereStr & "p.solution LIKE '%"&
myarraySolu(p_solution)&"%' OR "
end if
NEXT
if operateur_logique = 1 then
if Mid (whereStr , Len(whereStr)-3,4) = "AND " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -4)
end if
else
if Mid (whereStr , Len(whereStr)-2,3) = "OR " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -3)
end if
end if
Dim q_solution
q_solution=0
for p_solution=0 to NbTabIndice_solution
if myarraySolu(p_solution) <> "" and q_solution=
0 then
whereStr = whereStr & ")"
q_solution=q_solution+1
end if
next
End If
If titre <> "" Then
Dim m_titre, p_titre
p_titre = 0
m_titre=0
For p_titre=0 to NbTabIndice_titre
if myarrayTitre(p_titre)<>"" and m_titre=0 then
whereStr = whereStr & "AND("
m_titre=m_titre+1
end if
NEXT
For
p_titre=0 to NbTabIndice_titre
if operateur_logique = 1 then
whereStr = whereStr & "UPPER(p.title) LIKE UPPER('%"&
myarrayTitre(p_titre)&"%') AND "
else
whereStr = whereStr & "UPPER(p.title) LIKE UPPER('%"&
myarrayTitre(p_titre)&"%') OR "
end if
NEXT
if operateur_logique = 1 then
if Mid (whereStr , Len(whereStr)-3,4) = "AND " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -4)
end if
else
if Mid (whereStr , Len(whereStr)-2,3) = "OR " then
whereStr = Mid (whereStr , 1 , Len(whereStr) -3)
end if
end if
Dim q_titre
q_titre=0
for p_titre=0 to NbTabIndice_titre
if myarrayTitre(p_titre) <> "" and q_titre=
0 then
whereStr = whereStr & ")"
q_titre=q_titre+1
end if
next
End If
Select Case order
Case 1 whereStr = whereStr & " ORDER BY p.id ASC"
Case 2 whereStr = whereStr & " ORDER BY p.uid ASC"
Case 3 whereStr = whereStr & " ORDER BY r.uid ASC"
Case 4 whereStr = whereStr & " ORDER BY p.status ASC"
End Select
' Concatenate the two strings together.
listStr = listStr & whereStr
'response.write(listStr)
' Query the database
Set listRes = SQLQuery(adoCon, listStr)
' If results are retuned, display them. Only 10 results
' per page.
If Not listRes.EOF Then
Dim Counter, numToDisplay, startNum
Counter = 1
If Len(Request.Form("num")) > 0 Then
numToDisplay = CInt(Request.Form("num"))
Else
numToDisplay = ligne
End if
If Len(Request.Form("start")) > 0 Then
start = CInt(Request.Form("start"))
Else
start = 1
End if
' Get a total number of problems returned
cntStr
= "SELECT count(*) as compteur FROM ANO_applications, ANO_type,
ANO_categories, ANO_problems p, ANO_tblUsers r, ANO_status s
WHERE (p.rep = r.sid) AND (p.status = s.status_id) AND (p.applications
= ANO_applications.appli_id) AND (p.category = ANO_categories.category_id)
AND (p.type_prob = ANO_type.type_id) AND "
cntStr = cntStr & whereStr
'response.write (cntStr)
Set cntRes = SQLQuery(adoCon, cntStr)
total = cntRes("compteur")
nomb_page = (total / ligne)
if nomb_page < 1 then _
nomb_page = Cint (nomb_page) _
else _
nomb_page = Cint(nomb_page+1) _
end if
%>
<center>
<a href="default.asp">Retour au Menu</a> | <a
href="new.asp">Créer une nouvelle fiche</a>
| <a href="view.asp">Consulter vos
fiches</a> | <a href="search.asp">Nouvelle
recherche</a>
<table style="width:100 %;" border="0"
cellspacing="3" cellpadding="5" width="620">
<tr>
<td colspan="9" valign="center" align="center"
bgcolor="<% = Cfg(adoCon, "Color1") %>">
<b>Resultats de la recherche</b></font></b>
<b><font face="Verdana, Arial, Helvetica, sans-serif"
size="2" color="#FF0000">
<%Response.Write(" (Total:" & total &
")")
cntRes.Close
%>
</font></b><font face="Verdana, Arial, Helvetica,
sans-serif" size="2" color="#FF0000"></font>
<% if nomb_page > 0 then %>
<font size="2" face="Verdana, Arial, Helvetica,
sans-serif"><b>page :</b></font>
<b> <font color="#006699"> <font color="#009966">
<font face="Verdana, Arial, Helvetica, sans-serif">
<font size="2">
<% response.write(numero_page)%>
</font></font></font></font></b>/<b><font
color="#FF0000" face="Verdana, Arial, Helvetica,
sans-serif" size="2">
<% response.write(nomb_page) %>
<%end if %>
</font></b> </td>
</tr>
<tr
align="left" bgcolor="<% = Cfg(adoCon, "Color2")
%>">
<td style="width:1 %;"nowrap><b><u>ID</u></b></td>
<td style="width:3 %;" nowrap><b><u>Applications</u></b></td>
<td style="width:3 %;" nowrap><b><u>Catégories</u></b></td>
<td style="width:3 %;" nowrap><b><u>Type</u></b></td>
<td><b><u>Titre</u></b></td>
<td style="width:3 %;"nowrap><b><u>Utilisateur</u></b></td>
<td style="width:3 %;"nowrap><b><u>Attribué
à</u></b></td>
<td style="width:3 %;"nowrap><b><u>Date
Enr</u></b></td>
<td style="width:3 %;"nowrap><b><u>Status</u></b></td>
</tr>
<%
Do While Not (listRes.EOF) AND (Counter <= (numToDisplay
+ start - 1))
If Counter >= start Then
%>
<% mystring = listRes("typename") %>
<% myarray = Split(mystring, "Q") %>
<%
if listRes("typename") = "EVOLUTION" then
myarray = Split(mystring, "L")%>
<% if listRes("typename") = "NON BLOQUANT"
then myarray(0) = "NBLO" %>
<tr
align="left" valign="center" bgcolor="<%
= Cfg(adoCon, "Color2") %>">
<td style="width:3 %;"nowrap><% = listRes("id")
%></td>
<td style="width:3 %;" nowrap><% = listRes("appliname")
%></td>
<td style="width:3 %;" nowrap><% = listRes("cname")
%></td>
<td style="width:3 %;" nowrap><% =myarray(0)
%></td>
<td style="width:60 %;"><A style="width:60
%;" HREF="details.asp?id=<% = listRes("id")
%>"><% = listRes("title") %></A></td>
<td nowrap><A HREF="mailto:<% = listRes("uemail")
%>?Subject=HELPDESK: Problem <% = listRes("id")
%>"><% = listRes("prob_uid") %></A></td>
<td style="width:3 %;"nowrap><% = listRes("ruid")
%></td>
<td align="center" style="width:3 %;"nowrap><%
= listRes("start_date") %></td>
<td style="width:3 %;"nowrap><% = listRes("sname")
%></td>
</tr>
<%
End If
Counter = Counter + 1
listRes.MoveNext
Loop
Response.Write("</table></center>")
' Calculate prev/next page links
Dim startP, StartN
startP = start - numToDisplay
If startP < 1 Then
startP = 1
End if
startN = start + numToDisplay
%>
<CENTER>
<% If start > 1 Then %>
<form method="POST" action="results.asp">
<input type="hidden" name="start" value="<%
= startP %>">
<input type="hidden" name="num" value="<%
= numToDisplay %>">
<input type="hidden" name="uid" value="<%
= uid %>">
<input type="hidden" name="id" value="<%
= id %>">
<input type="hidden" name="rep" value="<%
= rep %>">
<input type="hidden" name="category"
value="<% = category %>">
<input type="hidden" name="department"
value="<% = department %>">
<input type="hidden" name="start_date"
value="<% = start_date %>">
<input type="hidden" name="end_date"
value="<% = end_date %>">
<input type="hidden" name="description"
value="<% = description %>">
<input type="hidden" name="solution"
value="<% = solution %>">
<input type="hidden" name="form_titre"
value="<% = titre %>">
<input type="hidden" name="applications"
value="<% = applications %>">
<%for p=0 to tour%>
<%if status(p)>0 then%>
<input type="hidden" name="<%response.write("status"&p)%>"
value="<% = status(p) %>">
<%end if%>
<%next%>
<%for p_type=0 to tour_type%>
<%if Rtype(p_type)>0 then%>
<input type="hidden" name="<%response.write("type"&p_type)%>"
value="<% = Rtype(p_type) %>">
<%end if%>
<%next%>
<input type="hidden" name="priority"
value="<% = priority %>">
<input type="hidden" name="order" value="<%
= order %>">
<input type="hidden" name="form_p" value="<%
= tour %>">
<input type="hidden" name="form_p_type"
value="<% = tour_type %>">
<input type="hidden" name="ligne_form"
value="<% = ligne %>">
<% numero_page = numero_page-1 %>
<input type="hidden" name="numero_page_form"
value="<% = numero_page %>">
<input type="submit" value="Précédent">
</form>
<%numero_page = numero_page+1%>
<% End If
If Not (listRes.EOF) Then
%>
<form method="POST" action="results.asp">
<input type="hidden" name="start" value="<%
= startN %>">
<input type="hidden" name="num" value="<%
= numToDisplay %>">
<input type="hidden" name="uid" value="<%
= uid %>">
<input type="hidden" name="id" value="<%
= id %>">
<input type="hidden" name="rep" value="<%
= rep %>">
<input type="hidden" name="category"
value="<% = category %>">
<input type="hidden" name="department"
value="<% = department %>">
<input type="hidden" name="start_date"
value="<% = start_date %>">
<input type="hidden" name="end_date"
value="<% = end_date %>">
<input type="hidden" name="description"
value="<% = description %>">
<input type="hidden" name="solution"
value="<% = solution %>">
<input type="hidden" name="form_titre"
value="<% = titre %>">
<input type="hidden" name="applications"
value="<% = applications %>">
<%for p=0 to tour%>
<%if status(p)>0 then%>
<input type="hidden" name="<%response.write("status"&p)%>"
value="<% = status(p) %>">
<%end if%>
<%next%>
<%for p_type=0 to tour_type%>
<%if Rtype(p_type)>0 then %>
<input type="hidden" name="<%response.write("type"&p_type)%>"
value="<% = Rtype(p_type) %>">
<%end if%>
<%next%>
<input type="hidden" name="priority"
value="<% = priority %>">
<input type="hidden" name="order" value="<%
= order %>">
<input type="hidden" name="form_p" value="<%
= tour %>">
<input type="hidden" name="form_p_type"
value="<% = tour_type %>">
<input type="hidden" name="ligne_form"
value="<% = ligne %>">
<input
type="hidden" name="numero_page_form" value="<%
= (numero_page+1) %>">
<input type="submit" value="Suivant">
</form>
<% End If %>
</center>
<div align="center"><br>
<%
' If no results returned:
Else
%>
<a href="default.asp">Retour au Menu</a> | <a
href="new.asp">Créer
une nouvelle fiche</a> | <a href="view.asp">Consulter
vos fiches</a> | <a href="search.asp">Nouvelle
recherche</a> </div>
<table border="0" cellspacing="3" cellpadding="5"
width="600">
<tr>
<td colspan="6" valign="center" align="center"
bgcolor="<% = Cfg(adoCon, "Color1") %>">
<font size="+2"><b>Resultat de la recherche</b></font>
</td>
</tr>
<tr align="center" bgcolor="<% = Cfg(adoCon,
"Color2") %>">
<td nowrap><b><u>Identifiant</u></b></td>
<td><b><u>Titre</u></b></td>
<td nowrap><b><u>Utilisateur</u></b></td>
<td nowrap><b><u>Attribué à</u></b></td>
<td nowrap><b><u>Date d'enregistrement</u></b></td>
<td nowrap><b><u>Statut</u></b></td>
</tr>
<tr align="center" bgcolor="<% = Cfg(adoCon,
"Color2") %>">
<td colspan="6"> <font size="+1">Pas
de résultat.</font> </td>
</tr>
</table>
<% End If
' Close results
listRes.Close
set listRes = nothing
Call DisplayFooter(adoCon, sid)
adoCon.Close
set adoCon = nothing
%>
</body>
</html>
|