<%
Session.LCID = 1040
%>
<!--#include file="../admin/con_port.asp"-->
<link href="../stile.css" rel="stylesheet" type="text/css">
<html>
<head>
<title></title>
</head>
<body bgcolor="#CCCCCC">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="600" background="../admin/menu_adm/center.gif"><img src="../admin/menu_adm/blank.gif" width="123" height="25"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="twobord">
<%
call verify()
passo=request.querystring("passo")
id=request.querystring("id")
action="auto_uso_adm.asp?passo=confins"
data_rif=request.querystring("data_rif")
if data_rif="" then data_rif=date()
'if mm="" then mm=minute(time())
'if hh="" then hh=hour(time())
call apricon()
if passo="mod" then
SQLmod="SELECT * FROM auto_uso WHERE id="&id
call aprirSQLx(md,SQLmod)
data=md("data")
ggm=day(data)
mmm=month(data)
aam=year(data)
'ORE USCITA
ora=md("ora")
hh=hour(md("ora"))
mm=minute(md("ora"))
if len(mm)=1 then mm=0&mm
'ORE PREVISTA ENTRATA
hh_prev=hour(md("ora_prev"))
mm_prev=minute(md("ora_prev"))
if len(mm_prev)=1 then mm_prev=0&mm_prev
'ORE PREVISTA EFFETTIVA
hh_eff=hour(md("ora_eff"))
mm_eff=minute(md("ora_eff"))
if len(mm_eff)=1 then mm_eff=0&mm_eff
auto=md("auto")
visitatore=replace(md("visitatore"),"""","'")
motivo=replace(md("motivo"),"""","'")
destinazione=replace(md("destinazione"),"""","'")
km_iniziali=md("km_iniziali")
km_finali=md("km_finali")
carburante=md("carburante")
auto_freeze=md("auto_freeze")
if carburante="si" then
si="checked"
else
no="checked"
end if
action="auto_uso_adm.asp?data_rif="&Dateserial(year(data_rif),month(data_rif),day(data_rif))&"&passo=confmod&id="&id
call chiudirSQLx(md)
else
hh=hour(time())
mm=minute(time())
action="auto_uso_adm.asp?data_rif="&Dateserial(year(data_rif),month(data_rif),day(data_rif))&"&passo=confins"
end if
%>
<form action='<%=action%>' method='post' class='tiny'>
<table align='center' >
<tr>
<td colspan='2'> </td>
</tr>
<tr>
<td colspan='2'><a href='auto_uso_prt.asp' target='_blank'><img src='../images/ric.gif' border='0' class='img'></a></td>
</tr>
<tr>
<td class='normalw' colspan='2'>Inserimento</td>
</tr>
<%if passo="mod" then%>
<tr>
<td class="catform">Data</td>
<td bgcolor="#E8E8E8" class="catform"><input type='text' value='<%=ggm%>' name='ggm' size='2' maxlength='2' > / <input type='text' value='<%=mmm%>' name='mmm' size='2' maxlength='2' > / <input type='text' value='<%=aam%>' name='aam' size='4' maxlength='4' ></td>
</td>
</tr>
<%end if%>
<tr>
<td class="catform">Auto</td>
<td bgcolor="#E8E8E8" class="catform"><Select name='auto'>
<%
if passo="mod" then
response.write("<option value='"&auto_freeze&"'>"&auto_freeze&"</option>")
end if
%>
<option value='0'></option>
<%SQLauto="SELECT id_auto,marca,modello,chiave FROM auto WHERE proprieta='Aziendale' and CHIAVE<>'' ORDER BY chiave"
call aprirSQLx(cr,SQLauto)
do while not cr.eof
response.write("<option value='"&cr("chiave")&" ("&cr("marca")&" "&cr("modello")&")'>"&cr("chiave")&" ("&cr("marca")&" "&cr("modello")&")</option>")
cr.movenext
loop
call chiudirSQLx(cr)
%>
</select></td>
</tr>
<tr>
<td class="catform">Dalle ora Ore</td>
<td bgcolor="#E8E8E8" class="catform"><input type='text' value='<%=hh%>' name='hh' size='2' maxlength='2' >:<input type='text' value='<%=mm%>' name='mm' size='2' maxlength='2' >
</tr>
<tr>
<td class="catform">Alle ora Ore</td>
<td bgcolor="#E8E8E8" class="catform">Orario Previsto <input type='text' value='<%=hh_prev%>' name='hh_prev' size='2' maxlength='2' >:<input type='text' value='<%=mm_prev%>' name='mm_prev' size='2' maxlength='2' ><br>
Orario Effettivo <input type='text' value='<%=hh_eff%>' name='hh_eff' size='2' maxlength='2' >:<input type='text' value='<%=mm_eff%>' name='mm_eff' size='2' maxlength='2' ></td>
</tr>
<tr>
<td class="catform">Nome</td>
<td bgcolor="#E8E8E8"><input type='text' value="<%=visitatore%>" name='visitatore' size='60' ></td>
</tr>
<tr>
<td class="catform">Note</td>
<td bgcolor="#E8E8E8"><input type='text' value="<%=motivo%>" name='motivo' size='60'></td>
</tr>
<tr>
<td class="catform" colspan='2'></td>
</tr>
<tr>
<td class="catform">Destinazione</td>
<td bgcolor="#E8E8E8"><input type='text' value="<%=Destinazione%>" name='Destinazione' size='60'></td>
</tr>
<tr>
<td class="catform">Km iniziali</td>
<td bgcolor="#E8E8E8"><input type='text' value='<%=Km_iniziali%>' name='Km_iniziali'></td>
</tr>
<tr>
<td class="catform">Km finali</td>
<td bgcolor="#E8E8E8"><input type='text' value='<%=Km_finali%>' name='Km_finali'></td>
</tr>
<tr>
<td class="catform">Carburante</td>
<td bgcolor="#E8E8E8"><input type='radio' name='Carburante' value='si' <%=si%>>si<input type='radio' name='Carburante' value='no' <%=no%>>no</td>
</tr>
<tr>
<td colspan='2' class='insert'><input type='submit' value='conferma'> <a href='auto_uso_adm.asp?data_rif=<%=data_rif%>'>Annulla</a></td>
</tr>
</table>
</form>
<%
if passo="confins" then
call aprirs("auto_uso")
rs.addnew
rs("data")=data_rif
if request.form("auto")<>"" then rs("Auto_freeze")=request.form("auto")
if request.form("hh")="" then hhi=00
if request.form("mm")="" then mmi=00
if request.form("hh")<>"" then hhi=request.form("hh")
if request.form("mm")<>"" then mmi=request.form("mm")
rs("ora")=hhi&":"&mmi
if request.form("hh_prev")<>"" and request.form("mm_prev")<>"" then rs("ora_prev")=request.form("hh_prev")&":"&request.form("mm_prev")
if request.form("hh_eff")<>"" and request.form("mm_eff")<>"" then rs("ora_eff")=request.form("hh_eff")&":"&request.form("mm_eff")
rs("visitatore")=set_txt(request.form("visitatore"))
rs("motivo")=set_txt(request.form("motivo"))
rs("destinazione")=set_txt(request.form("destinazione"))
if request.form("km_iniziali")<>"" then rs("km_iniziali")=request.form("km_iniziali")
if request.form("km_finali")<>"" then rs("km_finali")=request.form("km_finali")
rs("carburante")=request.form("carburante")
rs.update
call chiudirs()
response.redirect("auto_uso_adm.asp?data_rif="&Dateserial(year(data_rif),month(data_rif),day(data_rif)))
end if
if passo="confmod" then
auto="'"&request.form("auto")&"'"
if request.form("hh")="" then hhi=00
if request.form("mm")="" then mmi=00
if request.form("hh")<>"" then hhi=request.form("hh")
if request.form("mm")<>"" then mmi=request.form("mm")
ora="ora=#"&hhi&":"&mmi&"#,"
if request.form("hh_prev")<>"" and request.form("mm_prev")<>"" then ora_prev="ora_prev='"&request.form("hh_prev")&":"&request.form("mm_prev")&"',"
if request.form("hh_eff")<>"" and request.form("mm_eff")<>"" then ora_eff="ora_eff='"&request.form("hh_eff")&":"&request.form("mm_eff")&"',"
data=request.form("mmm")&"/"&request.form("ggm")&"/"&request.form("aam")
km_iniziali="km_iniziali=0"
km_finali="km_finali=0"
if request.form("km_iniziali")<>"" then km_iniziali="km_iniziali="&request.form("km_iniziali")
if request.form("km_finali")<>"" then km_finali="km_finali="&request.form("km_finali")
SQLmod="UPDATE auto_uso SET auto_freeze="&auto&","&ora&" "&ora_prev&" "&ora_eff&" data=#"&data&"# , visitatore='"&set_txt(request.form("visitatore"))&"' , motivo='"&set_txt(request.form("motivo"))&"' "
SQLmod=SQLmod & ",destinazione='"&set_txt(request.form("destinazione"))&"' ,"&km_iniziali&" , "&km_finali&",carburante='"&request.form("carburante")&"' WHERE id="&id
response.write(SQLmod)
call apri_cmd(SQLmod)
response.redirect("auto_uso_adm.asp?data_rif="&data)
end if
if passo="del" then
SQLdel="DELETE * FROM auto_uso WHERE id="&id
call apri_cmd(SQLdel)
response.redirect("auto_uso_adm.asp?data_rif="&Dateserial(year(data_rif),month(data_rif),day(data_rif)))
end if
function set_txt(string)
string_out=replace(string,"'","""")
set_txt=string_out
end function
%>
<table class='tiny' width='98%' align='center' border=0>
<tr>
<td colspan='11' align='center'><a href='auto_uso_adm.asp?data_rif=<%=DateAdd("d", -1, data_rif)%>'><img src='../images/lef.gif' border='0'></a><b><%=Giorno(data_rif)%> - <%=day(data_rif)&"/"&month(data_rif)&"/"&year(data_rif)%></b><a href='auto_uso_adm.asp?data_rif=<%=DateAdd("d", 1, data_rif)%>'><img src='../images/rig.gif' border='0'></a></td>
</tr>
<tr class='normalw'>
<td width='1%'>Auto Nr.</td>
<td width='20%'>Nome</td>
<td width='10%'>Note</td>
<td width='9%'>Ora uscita</td>
<td width='9%'>Orario previsto</td>
<td width='9%'>Orario effettivo</td>
<td width='39%'>Destinazione</td>
<td width='9%'>Km iniziali</td>
<td width='9%'>Km finali</td>
<td width='9%'>Carburante</td>
<td width='1%'></td>
</tr>
<%
SQL="SELECT * FROM auto_uso WHERE data=#" & data_rif& "# ORDER BY ora"
call aprirSQLx(rs,SQL)
do while not rs.eof
if not rs.eof then
ora=zero_add (rs("ora"))
ora_prev=zero_add (rs("ora_prev"))
ora_eff=zero_add (rs("ora_eff"))
col=color_line(col)
Sqlcod="SELECT marca,modello,chiave FROM auto WHERE id_auto="&rs("auto")
'response.write Sqlcod
'response.end
call aprirSQLx(co,Sqlcod)
cod_auto=""
if not co.eof then
cod_auto=co("chiave") '' &" "& left(co("modello"),6)
end if
cod_auto= left(rs("Auto_freeze"),3)
call chiudirSQLx(co)
response.write("<tr bgcolor='"&col&"' >")
'response.write("<td>"&rs("data")&"</td>")
response.write("<td>"&cod_auto&"</td>")
response.write("<td>"&replace(rs("visitatore"),"""","'")&"</td>")
response.write("<td>"&replace(rs("motivo"),"""","'")&"</td>")
response.write("<td>"&ora&"</td>")
response.write("<td>"&ora_prev&"</td>")
response.write("<td>"&ora_eff&"</td>")
response.write("<td>"&replace(rs("Destinazione"),"""","'")&"</td>")
response.write("<td>"&rs("km_iniziali")&"</td>")
response.write("<td>"&rs("km_finali")&"</td>")
response.write("<td>"&rs("carburante")&"</td>")
response.write("<td align='center'><a href='auto_uso_adm.asp?data_rif="&Dateserial(year(data_rif),month(data_rif),day(data_rif))&"&passo=mod&id="&rs("id")&"'><img src='../images/img_adm/mod.gif' class='img' width='15'>")
%><a href="javascript:if(confirm('Vuoi Veramente Cancellare il record?')){navigate('auto_uso_adm.asp?data_rif=<%=data_rif%>&passo=del&id=<%=rs("id")%>');}"><img src='../images/img_adm/del.gif' class='img' width='15'></td></a><%
response.write("</tr>")
end if
rs.movenext
loop
call chiudirSQLx(rs)
call chiudicon()
%>
<tr><td> </td></tr>
</table>
</td></tr><tr>
<td colspan="6"><img src="../images/1x1.gif" width="100%" height="1"></td>
</tr></table>
</body>
</html>
<%
function zero_add(tempo)
if len(minute(tempo))=1 then
min_out=0 & minute(tempo)
else
min_out=minute(tempo)
end if
ora_out=hour(tempo)&":"& min_out
if ora_out="0:00" or ora_out=":" then ora_out=""
zero_add = ora_out
end function
function giorno(data)
if weekday(data)=2 then
giornoout="Lunedì"
elseif weekday(data)=3 then
giornoout="Martedì"
elseif weekday(data)=4 then
giornoout="Mercoledì"
elseif weekday(data)=5 then
giornoout="Giovedì"
elseif weekday(data)=6 then
giornoout="Venerdì"
elseif weekday(data)=7 then
giornoout="Sabato"
elseif weekday(data)=1 then
giornoout="Domenica"
end if
giorno= giornoout
end function
%>