﻿<!-- #include file="security.asp" -->

<%

		Set rs = Conn.Execute("SELECT ClientCompanyShort FROM CLIENTS  ORDER BY ClientCompanyShort ASC ")
		while not rs.EOF
		ArrayClientsToGrafic=ArrayClientsToGrafic&"'"&rs("ClientCompanyShort")&"',"
		rs.movenext
		wend
		
	'	sSql = "UPDATE LAB SET"
	'	sSql = sSql & " [LABDATEEND]='17/03/2018 17:07:47'"
	'	sSql = sSql & " WHERE LABWORKCOD=446 "
	'	Conn.Execute(sSql)


Function Grafic3Month()

		for mes=0 to 9
		data = dateAdd("m",-9+mes,date())
'response.Write fuelMonth&"<---"
			Set rs = Conn.Execute("SELECT SUM(LABPRICE) AS TotalMonthLab FROM LAB WHERE MONTH(LABDATEWORK)="&month(data)&" AND YEAR(LABDATEWORK)="&year(data)&"")
			if rs("TotalMonthLab")="" or isnull(rs("TotalMonthLab")) then totalMonthLab=" 0 €" else totalMonthLab=replace(formatCurrency(rs("TotalMonthLab")),",",".")
			response.Write "['"&MonthName(month(data),true)&" ',"
			
			Set rs = Conn.Execute("SELECT ClientCompanyShort FROM CLIENTS ORDER BY ClientCompanyShort ASC ")
			while not rs.EOF
			
				Set rs1 = Conn.Execute("SELECT LABID FROM LAB WHERE LABCOMPANY='"&rs("ClientCompanyShort")&"' AND MONTH(LABDATEWORK)="&month(data)&" AND YEAR(LABDATEWORK)="&year(data)&"")
				if rs1.EOF and rs1.BOF then
				 response.Write " 0,"
				else
					Set rs1 = Conn.Execute("SELECT SUM(LABPRICE) AS TotalMonthClient FROM LAB WHERE LABCOMPANY='"&rs("ClientCompanyShort")&"' AND MONTH(LABDATEWORK)="&month(data)&" AND YEAR(LABDATEWORK)="&year(data)&"")
					if rs1("TotalMonthClient")="" then response.Write " 0," else response.Write replace(rs1("TotalMonthClient"),",",".")&", "
				end if
				
			rs.movenext
			wend
			response.Write "'"&totalMonthLab&"'],"
		next
		
End function
	
	
		
		sSql="SELECT  LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE LABWORKCOD=545  GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND"
		Set rs = Conn.Execute(sSql)
		
			while not rs.eof
			response.write rs("LABWORKCOD")&" - "&rs("LABWORKCOD")
			response.write "<br>next<br>"
			
			rs.movenext
			wend

		
		
		
			
		

Function TableLabWorks()

	sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE LABDATEEND IS NULL OR LABDATESTART>#"&month(dateadd("m",-1,date))&"/"&month(dateadd("m",-1,date))&"/"&year(dateadd("m",-1,date))&"# GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND"

	if request.Form("date")<>"" then
		sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE MONTH(LABDATESTART)="&month(request.Form("date"))&" AND YEAR(LABDATESTART)="&year(request.Form("date"))&" GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND "
	end if
	
	if request.Form("QUICK")<>"" then
		sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE LABPATIENT LIKE '%"&replace(request.Form("QUICK")," ","%")&"%' or LABMEDIC LIKE '%"&replace(request.Form("QUICK")," ","%")&"%' GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND "
	end if
	
		Set rs = Conn.Execute(sSql)
	
		response.Write"<div style=""float:left;width:60px; margin-left:10px;"" class=""text"">EMPRESA</div>"
		response.Write"<div style=""float:left;width:165px;"" class=""text"">PACIENTE</div>"
		response.Write"<div style=""float:left;width:145px;"" class=""text"">MEDICO</div>"
		'response.Write"<div style=""float:left;width:230px;"" class=""text"">TIPO DE TRABALHO</div>"
		response.Write"<div style=""float:left;width:55px; margin-right:20px; TEXT-ALIGN:RIGHT; "" class=""text"">PREÇO</div>"
		response.Write"<div style=""float:left;width:50px;"" class=""text"">ENT</div>"
		response.Write"<div style=""float:left;width:50px;"" class=""text"">SAI</div>"
		response.Write"<div style=""float:left;width:100%;height:1px;background-color:#ccc;""></div>"
	
	while not rs.eof
	
	if rs("LABDATEEND")<>"" then
		backgroundColor="green"
	else
		backgroundColor="gray"
		if date-cDate(rs("LABDATEUPDATE"))>5 then backgroundColor="yellow"
		if date-cDate(rs("LABDATEUPDATE"))>8 then backgroundColor="red"
	end if
	
	response.Write"<a onclick=""mysticky"&rs("LABWORKCOD")&".showhidenote('show');return false"" href=""#"">"
	response.Write"<div id=""Line-TableFuelMonthInformationWorker"">"
		response.Write"<div style=""float:left;width:5px;height:20px; BACKGROUND-COLOR:"&backgroundColor&";"">&nbsp;</div>"
		response.Write"<div style=""float:left;width:60px;height:20px; margin-left:5px;"" class=""text"">"&rs("LABCOMPANY")&"</div>"
		response.Write"<div style=""float:left;width:165px;"" class=""text"">"&rs("LABPATIENT")&"</div>"
		response.Write"<div style=""float:left;width:145px;"" class=""text"">"&rs("LABMEDIC")&" &nbsp;</div>"
		sSql = "SELECT SUM(LABPRICE) AS WorkPriceTotal FROM LAB WHERE LABWORKCOD="&rs("LABWORKCOD")&" "
		Set rs1 = Conn.Execute(sSql) 
		response.Write"<div style=""float:left;width:55px; text-align:right; margin-right:20px;"" class=""text"">"&formatCurrency(rs1("WorkPriceTotal"))&"</div>"
		response.Write"<div style=""float:left;width:50px;"" class=""text"">"&day(rs("LABDATESTART"))&"/"&month(rs("LABDATESTART"))&"</div>"
		if rs("LABDATEEND")<>"" then response.Write"<div style=""float:left;width:50px;"" class=""text"">"&day(rs("LABDATEEND"))&"/"&month(rs("LABDATEEND"))&" </div>"
		response.Write"<div style=""float:left;width:100%;height:1px;background-color:#ccc;""></div>"
		response.Write"</div>"
	rs.movenext
	wend


End Function

		
Function StickyNoteJavaWorks()
	sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE LABDATEEND IS NULL OR LABDATESTART>#5/8/2017# GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND DESC"

	if request.Form("date")<>"" then
		sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE MONTH(LABDATESTART)="&month(request.Form("date"))&" AND YEAR(LABDATESTART)="&year(request.Form("date"))&" GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND "
	end if
	
	if request.Form("QUICK")<>"" then
		sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE LABPATIENT LIKE '%"&replace(request.Form("QUICK")," ","%")&"%' or LABMEDIC LIKE '%"&replace(request.Form("QUICK")," ","%")&"%' GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND "
	end if
	
		Set rs = Conn.Execute(sSql)
	
	while not rs.eof
		response.Write"var mysticky"&rs("LABWORKCOD")&"=new stickynote({ "
		response.Write"content:{divid:'stickynote"&rs("LABWORKCOD")&"', source:'inline'}, "
		response.Write"hidebox:0, "
		if ""&request.Form("CODWORK")&""=""&rs("LABWORKCOD")&"" or ""&request.Form("deleteWorkCod")&""=""&rs("LABWORKCOD")&"" then
		response.Write"showfrequency:'always' "
		else
		response.Write"showfrequency:'never' "
		end if
		response.Write"}); "
	rs.movenext
	wend
End function
		
Function StickyNoteWindowsWorks()

	sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE LABDATEEND IS NULL OR LABDATESTART>#5/8/2017# GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND DESC"

	if request.Form("date")<>"" then
		sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE MONTH(LABDATESTART)="&month(request.Form("date"))&" AND YEAR(LABDATESTART)="&year(request.Form("date"))&" GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND "
	end if
	
	if request.Form("QUICK")<>"" then
		sSql="SELECT LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND FROM LAB WHERE LABPATIENT LIKE '%"&replace(request.Form("QUICK")," ","%")&"%' or LABMEDIC LIKE '%"&replace(request.Form("QUICK")," ","%")&"%' GROUP BY LABWORKCOD, LABCOMPANY, LABPATIENT, LABMEDIC, LABDATESTART, LABDATEUPDATE, LABDATEEND ORDER BY LABDATEEND "
	end if
	
		Set rs = Conn.Execute(sSql)
	
	while not rs.eof
	
		response.Write"<div id=""stickynote"&rs("LABWORKCOD")&""" class=""stickynote"" >"
			response.Write"<div style=""float:right;margin-top:5px;width:20px;"">"
			response.Write"<a href=""#"" onClick=""mysticky"&rs("LABWORKCOD")&".showhidenote('hide');return false""><img src=""images/icon-close.png"" border=""0"" /></a>"
			response.Write"</div>"
			response.Write"<div style=""float:left;width:100%;height:1px;margin-bottom:10px;background-color:#CCC;""> </div>"
			
			Set rs1 = Conn.Execute("SELECT ClientCompany, ClientLocal FROM CLIENTS WHERE ClientCompanyShort='"&rs("LABCOMPANY")&"' ") 
			response.Write"<div style=""float:left;margin-left:10px; width:95%; font-size:16px;"" class=""text"">"
			response.Write "<img src=""images/icon-company.png"" style=""float:left;margin-right:5px;""> Clinica  "&rs1("ClientCompany")&"  "&rs1("ClientLocal")
			response.Write"</div>"
			
			response.Write"<div style=""float:left;margin-left:10px; width:95%; margin-top:5px; font-size:16px;"" class=""text"">"
			response.Write "<img src=""images/icon-user.png"" style=""float:left;margin-right:5px;""> "&rs("LABPATIENT")
			response.Write"</div>"

			response.Write"<div style=""float:left;margin-left:10px; width:95%; margin-top:5px; font-size:16px;"" class=""text"">"
			response.Write "<img src=""images/icon-user.png"" style=""float:left;margin-right:5px;""> "&rs("LABMEDIC")
			response.Write"</div>"

			response.Write"<div style=""float:left;margin-left:10px; width:95%; margin-top:5px; font-size:16px;"" class=""text"">"
			response.Write "<img src=""images/icon-calendar-small.png"" style=""float:left;margin-right:5px;""> "&rs("LABDATESTART")
			response.Write"</div>"

			TotalWorks=0
			sSql = "SELECT * FROM LAB WHERE LABWORKCOD="&rs("LABWORKCOD")&" "
			Set rs1 = Conn.Execute(sSql) 
			while not rs1.eof
			dateWork=day(rs1("LABDATEWORK"))&"/"&month(rs1("LABDATEWORK"))&"/"&year(rs1("LABDATEWORK"))
			response.Write"<div style=""float:left;margin-left:20px; width:90%; margin-top:5px; font-size:16px;"" class=""text"">"
				response.Write"<div style=""float:left;min-width:270px;"">"
				response.Write "<div style=""float:left;border-radius: 50%;width: 10px; height: 10px; background-color:#007b7b; margin-top:3px; margin-right:5px;""></div>"&rs1("LABWORK")
				response.Write"</div>"
				response.Write"<div style=""float:left;width:70px;text-align:right; "">"&formatCurrency(rs1("LABPRICE"))&" </div>"
				response.Write"<div style=""float:left;width:100px;text-align:right;"">"&dateWork&"</div>"
				
				response.Write "<div style=""float:left;width:30px;margin-left:10px; font-size:14px;""> "
					response.Write "<form name=""formDelete"&rs1("LABID")&""" method=""post"" action=""main.asp?pag="&request.QueryString("pag")&""">"
					if rs1("LABPRICE")<>"0" then response.Write "<input type=""image"" src=""images/icon-delete.png"" />"
					response.Write"<input name=""deleteWorkCod"" type=""number""  type=""hidden"" value="""&rs("LABWORKCOD")&""" hidden=""hidden"" />"
					response.Write"<input name=""deleteWorkId"" type=""number"" type=""hidden""  value="""&rs1("LABID")&"""  hidden /> "
					response.Write "</form>"
				
				response.Write "</div>"

			response.Write"</div>"
			
				
			TotalWorks=TotalWorks+rs1("LABPRICE")
			rs1.movenext
			wend
			
			response.Write"<div style=""float:left;margin-left:20px; width:90%; margin-top:5px; font-size:16px;"" class=""text"">"
				response.Write"<div style=""float:left;min-width:270px;""><span style=""margin-left:15px;"">Total: </span></div>"
				response.Write""
				response.Write"<div style=""float:left;width:70px;text-align:right; "">"&formatCurrency(TotalWorks)&" </div>"
			response.Write"</div>"
			
			response.Write"<div id=""line"" style=""width:100%;margin:0px;""></div>"
			
			response.Write "<form name=""formWork"&rs("LABWORKCOD")&""" method=""post"" action=""main.asp?pag="&request.QueryString("pag")&""">"
			response.Write"<div style=""float:left;margin-left:20px; width:90%;height:70px; margin-top:20px; font-size:16px;"" class=""text"">"
				response.Write"<div style=""float:left;min-width:270px;color:#007b7b;"">Adicionar Trabalho</div>"
				response.Write"<div style=""float:left;width:70px;color:#007b7b;"" class>&nbsp;</div>"
				response.Write"<div style=""float:left;width:100px;"" class>&nbsp;</div>"
				response.Write"<div style=""float:left;min-width:270px;"">"
				response.Write"<select name=""WORK""  style=""width:97%; font-size:16px;"" class=""text"">"
				Set rs1 = Conn.Execute("SELECT * FROM TabWorks ")
				while not rs1.EOF 
				response.Write"<option>"&rs1("WorkDesc")&"</option>"
				rs1.MoveNext
				wend
				response.Write"</select>"
				response.Write"<BR>"
				response.Write"<input type=""date"" name=""DATEWORK"" style=""width:270px;font-size:16px;""  class=""text""  required />"
				
				response.Write"</div>"
				response.Write"<div style=""float:left;width:70px;"" class> &nbsp;</div>" '<input type=""text"" name=""PRICE"" class=""text"" style=""width:57px; font-size:16px;"" >€

				response.Write "<input type=""submit"" style=""margin-left:25px; border:0px;width:90px;height:28px;border:0px;background-color:#007b7b;color:#FFF"" value=""INSERIR"" />"
				
        response.Write "<input type=""number"" name=""CODWORK"" value="""&rs("LABWORKCOD")&""" hidden=""hidden"" />"
				response.Write rs("LABWORKCOD")
			response.Write"</div>"
			response.Write"</form>"
			
			
			response.Write"<div style=""float:left;margin-left:20px; width:90%;height:70px; margin-top:20px; font-size:16px;"" class=""text"">"
				response.Write"<div style=""float:left;min-width:270px;color:#007b7b;"">Data Conclusão</div>"
			response.Write "<form name=""formWork"&rs("LABWORKCOD")&""" method=""post"" action=""main.asp?pag="&request.QueryString("pag")&""">"
			
				response.Write "<input type=""date"" name=""DATEWORKEND"" style=""width:270px;font-size:16px;""  class=""text""  required />"
				response.Write "<input type=""submit"" style=""margin-left:25px; border:0px;width:90px;height:28px;border:0px;background-color:#007b7b;color:#FFF"" value=""INSERIR"" />"
				response.Write "<input type=""number"" name=""CODWORKEND"" value="""&rs("LABWORKCOD")&""" hidden=""hidden"" />"
			response.Write"</div>"
			response.Write"</form>"
			
			

			response.Write"</div>"
	rs.movenext
	wend

End function


if request.Form("INSERT")<>"" then

	Set rs = Conn.Execute("SELECT * FROM CLIENTS WHERE ClientID="&request.Form("COMPANY")&" ")
	Company=rs("ClientCompanyShort")
	CompanyLocal=rs("ClientLocal")
	
	Set rs = Conn.Execute("SELECT LABWORKCOD FROM LAB ORDER BY LABWORKCOD DESC")
	WorkCod=rs("LABWORKCOD")+1


			sSql = "INSERT INTO LAB ( LABUSER, LABWORKCOD, LABCOMPANY, LABLOCAL, LABPATIENT,LABMEDIC, LABPRICE, LABDATESTART, LABDATEUPDATE)"
			sSql = sSql & " VALUES ('"&session("NAME")
			sSql = sSql & "', "&WorkCod
			sSql = sSql & ", '"&Company
			sSql = sSql & "', '"&CompanyLocal
			sSql = sSql & "', '"&request.Form("NAME")
			sSql = sSql & "', '"&request.Form("MEDIC")
			sSql = sSql & "', 0"
			sSql = sSql & ", '"&request.Form("DATESTART")
			sSql = sSql & "', '"&now()
			sSql = sSql & "')"
			Conn.Execute(sSql)
End if

if request.Form("CODWORK")<>"" then

	Set rs = Conn.Execute("SELECT * FROM LAB WHERE LABWORKCOD="&request.Form("CODWORK")&" ")
							
	ClientCompany=rs("LABCOMPANY")
	ClientLocal=rs("LABLOCAL")
	ClientName=rs("LABPATIENT")
	ClientMedic=rs("LABMEDIC")
	ClientStart=rs("LABDATESTART")
	
	if ClientCompany="CSB" then
		Set rs = Conn.Execute("SELECT * FROM TabWorks WHERE WorkDesc='"&request.Form("WORK")&"' ")
		ClientWorkPrice=rs("WorkPriceCSB")
		ClientWorkPriceWorker=rs("WorkPriceCSBJarbas")
	else
		Set rs = Conn.Execute("SELECT * FROM TabWorks WHERE WorkDesc='"&request.Form("WORK")&"' ")
		ClientWorkPrice=rs("WorkPrice")
		ClientWorkPriceWorker=rs("WorkPriceJarbas")
	end if
	
	Set rs = Conn.Execute("SELECT COUNT(*) As CONTA FROM LAB WHERE LABWORKCOD="&request.Form("CODWORK")&" AND LABWORK IS NULL ")
							'response.write rs("CONTA")&"<br>"

		if rs("CONTA")<>"0" Then
				sSql = "UPDATE LAB SET"
				sSql = sSql & " [LABUSER] = '"&SESSION("NAME")
				sSql = sSql & "', [LABWORK] = '"&request.Form("WORK")
				sSql = sSql & "', [LABPRICE]="&replace(ClientWorkPrice,",", ".")
				sSql = sSql & ", [LABPRICEWORKER]="&replace(ClientWorkPriceWorker,",", ".")
				sSql = sSql & ", [LABDATEWORK]='"&now()
				sSql = sSql & "', [LABDATEUPDATE]='"&now()&"'"
				sSql = sSql & " WHERE LABWORKCOD="&request.Form("CODWORK")&""
				Conn.Execute(sSql)
				'response.write sSql&"<br>"
				

		else
				sSql = "INSERT INTO LAB ( LABUSER, LABWORKCOD, LABCOMPANY, LABLOCAL, LABPATIENT, LABMEDIC, LABWORK, LABPRICE, LABPRICEWORKER, LABDATEWORK, LABDATESTART, LABDATEUPDATE)"
				sSql = sSql & " VALUES ('" &SESSION("NAME")
				sSql = sSql & "', "&request.Form("CODWORK")
				sSql = sSql & ", '"&ClientCompany
				sSql = sSql & "', '"&ClientLocal
				sSql = sSql & "', '"&ClientName
				sSql = sSql & "', '"&ClientMedic
				sSql = sSql & "', '"&request.Form("WORK")
				sSql = sSql & "', "&replace(ClientWorkPrice,",", ".")
				sSql = sSql & ", "&replace(ClientWorkPriceWorker,",", ".")
				sSql = sSql & ", '"&now()
				sSql = sSql & "', '"&ClientStart
				sSql = sSql & "', '"&now()
				sSql = sSql & "')"
				Conn.Execute(sSql)
				'response.write sSql&"<br>"
				
				sSql = "UPDATE LAB SET"
				sSql = sSql & "[LABDATEUPDATE]='"&now()&"'"
				sSql = sSql & " WHERE LABWORKCOD="&request.Form("CODWORK")&" "
				Conn.Execute(sSql)
				'response.write sSql&"<br>"
				
		end if
End if
if request.Form("deleteWorkId")<>"" then

	Set rs = Conn.Execute("SELECT COUNT(*) As CONTA FROM LAB WHERE LABWORKCOD="&request.Form("deleteWorkCod")&" ")

	If rs("CONTA")="1" Then
		sSql = "UPDATE LAB SET"
		sSql = sSql & " [LABWORK]=NULL"
		sSql = sSql & ", [LABPRICE]=0"
		sSql = sSql & ", [LABDATEWORK]=NULL"
		sSql = sSql & ", [LABDATEUPDATE]='"&now()&"'"
		sSql = sSql & " WHERE LABWORKCOD="&request.Form("deleteWorkCod")&""
		Conn.Execute(sSql)
	else
		Set rs = Conn.Execute("DELETE FROM LAB WHERE LABID="&request.Form("deleteWorkId")&" ")
	end if

	
end if


if request.Form("CODWORKEND")<>"" then

		sSql = "UPDATE LAB SET"
		sSql = sSql & " [LABDATEEND]='"&request.Form("DATEWORKEND")&"'"
		sSql = sSql & " WHERE LABWORKCOD="&request.Form("CODWORKEND")&""
		Conn.Execute(sSql)

end if







Function TabCompanys()

		Set rs = Conn.Execute("SELECT * FROM CLIENTS ")
		while not rs.EOF 
		response.Write"<option value="""&rs("ClientID")&""">"&rs("ClientCompany")&" "&rs("ClientLocal")&"</option>"
		rs.MoveNext
		wend

End function

Function TabProsthesis()

		Set rs = Conn.Execute("SELECT * FROM TabProstheses ")
		while not rs.EOF 
		response.Write"<option>"&rs("ProsthesesDesc")&"</option>"
		rs.MoveNext
		wend

End function





'response.write "work ->"&request.Form("WORK")&"<br>"

'response.write request.Form("COMPANY")&"<br>"
'response.write request.Form("NAME")&"<br>"
'response.write request.Form("JAW")&" "&request.Form("PROSTHESIS")&"<br>"


%>


<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="css/styles.css">
        
        
<!--popup -->

<style type="text/css">

.stickynote{
position:absolute;
visibility:hidden;
width: 580px;
border: 1px solid #666;
background-color:#FFF;
box-shadow: 3px 3px 8px #818181;
-webkit-box-shadow: 3px 3px 8px #818181;
-moz-box-shadow: 3px 3px 8px #818181;
}

</style>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

<script src="js/stickynote.js">

/***********************************************
* Sticky Note Script (c) Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

</script>

<script>

<%=StickyNoteJavaWorks()%>

var mystickyAddWork=new stickynote({
	content:{divid:'stickynoteAddWork', source:'inline'},
	hidebox:0,
	showfrequency:'never'  //<--no comma following last setting!
})

</script>
        
        
        
        
        
        
        
        
        
        
        
        
        
		<script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
        google.load("visualization", "1", {packages:["corechart"]});
        google.setOnLoadCallback(drawChart);
        function drawChart() {

 var data = google.visualization.arrayToDataTable([
        ['Genre', <%=ArrayClientsToGrafic%> { role: 'annotation' } ],
        <%=Grafic3Month()%>
      ]);

      var options = {
        width: 800,
        height: 300,
        legend: { position: 'top', maxLines: 4 },
        bar: { groupWidth: '60%' },
        isStacked: true,
      };

        var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
        
        
                
        
        

<div id="body-center">

        

   <div id="chart_div" style="width:800px; height:300px;"></div>
    
    
    
    <a onclick="mystickyAddWork.showhidenote('show');return false" href="#" style=" text-decoration:none; "> &nbsp;
    <div style="float:right;width:200px;height:30px;background-color:#007b7b;color:#FFF; text-align:center; padding-top:7px;">Adicionar Trabalho</div>
    </a>
    
    
    <div style="float:left;width:100%; margin-top:15px; margin-bottom:30px;">
		<%=TableLabWorks()%>
    </div>
    
               
    
    

		

</div>



<!-- STCKYNOTES-->
<%=StickyNoteWindowsWorks()%>

		<div id="stickynoteAddWork" class="stickynote" style="width:370px;" >
			<div style="float:right;margin-top:5px;width:20px;">
			<a href="#" onClick="mystickyAddWork.showhidenote('hide');return false"><img src="images/icon-close.png" border="0" /></a>
			</div>
			<div style="float:left;width:100%;height:1px;margin-bottom:15px;background-color:#CCC;"> </div>
			
			<form name="formWorkAdd" method="post" action="main.asp?pag=<%=request.QueryString("pag")%>">
            
            <div style="float:left;width:100%; font-size:14px;" class="text">
                <div style="float:left;width:230px; margin-left:38px;">Empresa</div>
            </div>

			<div style="float:left;margin-left:10px; width:95%; font-size:16px;" class="text">
			<img src="images/icon-company.png" style="float:left;margin-right:5px;">
            <select name="company" style="font-size:16px; width:310px;" class="text">
            <option></option>
            <%=TabCompanys()%>
            </select>
			</div>

            <div style="float:left;width:100%; margin-top:10px; font-size:14px;" class="text">
                <div style="float:left;width:230px; margin-left:38px;">Paciente</div>
            </div>

			<div style="float:left;margin-left:10px; width:95%; font-size:16px;" class="text">
			<img src="images/icon-user.png" style="float:left;margin-right:5px;"> <input type="text" name="NAME" style="width:310px;font-size:16px;"  class="text"  required />
			</div>
            
            <div style="float:left;width:100%; margin-top:10px; font-size:14px;" class="text">
                <div style="float:left;width:230px; margin-left:38px;">Médico</div>
            </div>

			<div style="float:left;margin-left:10px; width:95%; font-size:16px;" class="text">
			<img src="images/icon-user.png" style="float:left;margin-right:5px;"> <input type="text" name="MEDIC" style="width:310px;font-size:16px;"  class="text"  required />
			</div>
						
            
            
			<div style="float:left;margin-left:10px; margin-top:10px; width:95%; font-size:16px;" class="text">
			<img src="images/icon-calendar-small.png" style="float:left;margin-right:5px;"> <input type="date" name="DATESTART" style="/* [disabled]width:310px; */ font-size: 16px;"  class="text"  required />
			</div>
            
			<input type="submit" style="margin-left:38px;margin-top:20px; border:0px;width:90px;height:28px;border:0px;background-color:#007b7b;color:#FFF" value="INSERIR" />
            <input name="insert" type="hidden"  value="ok"  hidden />
			
			<div style="float:left; width:100%; height:30px;" class="text"> </div>

			</div>

