<? session_start();

include("../funcoes.inc");
include("config.php");
include("conexao_sinsweb.php");
// Quantidade de agendamentos
  $sql=("	select count(codigo) as qte_agendamentos from agendamento where trabalhador_nome <>'' ");
  $query=mysql_query($sql)
  or die (header("Location:erro.php?txtmensagem="."ERRO NA LEITURA DOS AGENDAMENTOS"));
  $num_rows = mysql_num_rows($query);
  if($num_rows>=1)
  {
	$qte_agendamentos=mysql_result($query,$i,"qte_agendamentos"); 
  }
  
// Quantidade que não enquadra
  $sql=("	select count(codigo) as qte_nao_enquadra from nao_enquadra");
  $query=mysql_query($sql)
  or die (header("Location:erro.php?txtmensagem="."ERRO NA LEITURA DO NAO ENQUADRA"));
  $num_rows = mysql_num_rows($query);
  if($num_rows>=1)
  {
	$qte_nao_enquadra=mysql_result($query,$i,"qte_nao_enquadra"); 
  }
  
// Quantidade agendamentos cancelados
  $sql=("	select count(codigo) as qte_cancelamentos from agendamento where cod_cancelamento <> 0 and trabalhador_nome <>'' ");
  $query=mysql_query($sql)
  or die (header("Location:erro.php?txtmensagem="."ERRO NA LEITURA DOS CANCELAMENTOS"));
  $num_rows = mysql_num_rows($query);
  if($num_rows>=1)
  {
	$qte_cancelamentos=mysql_result($query,$i,"qte_cancelamentos"); 
  }
  $qte_confirmada=$qte_agendamentos-$qte_cancelamentos;
  
?>


<html>
<style type="text/css">
@import url(../css/fourthcoffee.css);
.style1 {	font-family: Verdana;
	font-size: 8.5pt;
	color: black;
}
</style>
<head>
<link rel="stylesheet" type="text/css" href="../css/anylinkcssmenu.css" />

<script type="text/javascript" src="../js/anylinkcssmenu.js">

/***********************************************
* AnyLink CSS Menu script v2.0- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Project Page at http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm for full source code
***********************************************/

</script>

<script type="text/javascript">

//anylinkcssmenu.init("menu_anchors_class") ////Pass in the CSS class of anchor links (that contain a sub menu)
anylinkcssmenu.init("anchorclass")
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administração</title>
</head>

<body>
<table class=MsoNormalTable border=0 cellpadding=0 width="51%"
 style='width:98.0%;mso-cellspacing:1.5pt;mso-padding-alt:0cm 0cm 0cm 0cm'>
  <tr style='mso-yfti-irow:5'>
    <td width="52%" style='padding:0cm 0cm 0cm 0cm'><strong><span class="style1">Agendamento de Homologa&ccedil;&atilde;o Online [<? echo date('d/m/Y H:i'); ?>]</span></strong></td>
    <td width="48%" style='padding:0cm 0cm 0cm 0cm'>&nbsp;</td>
  </tr>
  <tr style='mso-yfti-irow:5'>
    <td colspan="2" style='padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><span style='font-size:7.5pt;font-family:Verdana;
  color:#333333'> <img width=1 height=5
  src="../../imagens/image002.gif" v:shapes="_x0000_i1033">
      <o:p></o:p>
    </span></p></td>
  </tr>
  <tr style='mso-yfti-irow:6'>
    <td colspan="2" style='background:#A8B7BF;padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><span style='font-size:7.5pt;font-family:Verdana;
  color:#333333'> <img width=1 height=1
  src="../../imagens/image003.gif" v:shapes="_x0000_i1034">
      <o:p></o:p>
    </span></p></td>
  </tr>
  <tr style='mso-yfti-irow:7'>
    <td colspan="2" style='padding:0cm 0cm 0cm 0cm'><p class=MsoNormal align=right style='text-align:right'><span
  style='font-size:8.5pt;font-family:Verdana;color:black'> <img width=1 height=5
  src="../../imagens/image002.gif" v:shapes="_x0000_i1035">
      <o:p></o:p>
    </span></p></td>
  </tr>
  <tr style='mso-yfti-irow:8;mso-yfti-lastrow:yes'>
    <td colspan="2" style='padding:0cm 0cm 0cm 0cm'><h2>Resumo agendamento</h2></td>
  </tr>
  <tr style='mso-yfti-irow:8;mso-yfti-lastrow:yes'>
    <td colspan="2" style='padding:0cm 0cm 0cm 0cm'><h2><strong>Total: <? echo $qte_agendamentos; ?><br>
    Canceladas: <? echo $qte_cancelamentos; ?></span><br>
    Confirmadas: <? echo $qte_confirmada; ?></span><br>
    Tentativas-N&atilde;o enquadram: <? echo $qte_nao_enquadra; ?><br>
    </strong></h2></td>
  </tr>
  <tr style='mso-yfti-irow:5'>
    <td colspan="2" style='padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><span style='font-size:7.5pt;font-family:Verdana;
  color:#333333'> <img width=1 height=5
  src="../../imagens/image002.gif" v:shapes="_x0000_i1033">
      <o:p></o:p>
    </span></p></td>
  </tr>
  <tr style='mso-yfti-irow:6'>
    <td colspan="2" style='background:#A8B7BF;padding:0cm 0cm 0cm 0cm'><p class=MsoNormal><span style='font-size:7.5pt;font-family:Verdana;
  color:#333333'> <img width=1 height=1
  src="../../imagens/image003.gif" v:shapes="_x0000_i1034">
      <o:p></o:p>
    </span></p></td>
  </tr>
  <tr>
    <td colspan="2"></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="35%"><p class="product_orderinfo"><a href="#" class="anchorclass" rel="submenu1"><span class="style1">ADMINISTRAR</span></a></p></td>
    <td width="65%">
	<?
  $sql=("	
		SELECT substring(data_hora from 1 for 10) as dia_marcado,
			count(data_hora) as qte_dia, 
			100 - ((count(data_hora) * 100) / 58) as disponivel
		FROM agendamento 
		WHERE trabalhador_nome <>''
		GROUP BY substring(data_hora from 1 for 10)
  ");
  $query=mysql_query($sql)
  or die (header("Location:erro.php?txtmensagem="."ERRO NO LEVANTAMENTO DE DISPONIBILIDADE"));

    {
echo "<table width='50%' border='1' cellpadding='0' cellspacing='0' bordercolor='#000000'>";
echo "<tr bgcolor='#FFFF00'>
<td align='center'>Data Agenda</td>
<td align='center'>Qte agendada</td>
<td align='center'>Disponivel</td>
</tr>";

/*Enquanto houver dados na tabela para serem mostrados será executado tudo que esta dentro do while */

while($escrever=mysql_fetch_array($query)){
/*Escreve cada linha da tabela*/
?>

<tr>
<td align='center'><? $data_agenda=strtotime($escrever[dia_marcado]); $data_agenda=date("d/m/Y",$data_agenda); echo $data_agenda;?></td>
<td align='center'><? echo $escrever[qte_dia];?></td>
<td align='center'><? echo $escrever[disponivel].'%';?></td>
</tr>
<p>
  <?

}/*Fim do while*/

echo "</table>"; /*fecha a tabela apos termino de impressão das linhas*/


}
?>
</td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>

<p>&nbsp;</p>

                                                    
<div id="submenu1" class="anylinkcss">
<ul>
<li><a href="empresa.php">	Protocolo por empresa</a></li>
<li><a href="#">	Relatório de agendamento</a></li>
<li><a href="#">		Inserir horários na agenda</a></li>
</ul>
</div>







</body>
  
</html>