<?php
include("seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página
header('Content-Type: text/html; charset=utf-8');

include("configuracao.php");//confirma no banco de dados
include("inclusos/funcoes.php");



//RECEBE PÁGINA
$recebepagina	= $_GET['pagina'];
$pagina			= RecebePagina($recebepagina);
?>
<!doctype html>
<html>
<head>
<title>Agência E Comunicação</title>
<link rel="stylesheet" href="inclusos/styles.css">
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="inclusos/script.js"></script>

<link href="inclusos/css_precopratico.css" rel="stylesheet" type="text/css">
		<script type="text/javascript">
			$(document).ready(function(){
				$("a[rel=modal]").click( function(ev){
					ev.preventDefault();

					var id = $(this).attr("href");

					var alturaTela = $(document).height();
					var larguraTela = $(window).width();
	
					//colocando o fundo preto
					$('#mascara').css({'width':larguraTela,'height':alturaTela});
					$('#mascara').fadeIn(1000);	
					$('#mascara').fadeTo("slow",0.8);

					var left = ($(window).width() /2) - ( $(id).width() / 2 );
					var top = ($(window).height() / 2) - ( $(id).height() / 2 );
					
					$(id).css({'top':top,'left':left});
					$(id).show();	
 				});

 				$("#mascara").click( function(){
 					$(this).hide();
 					$(".window").hide();
 				});

 				$('.fechar').click(function(ev){
 					ev.preventDefault();
 					$("#mascara").hide();
 					$(".window").hide();
 				});
			});
			
			function preLoad() {
			$("#loading").hide();
			}
			
			$(function(){
			$("#loading").show();
			});
			
			//$(document).ready(function () {
			//   $('input').keypress(function (e) {
			//		var code = null;
			//		code = (e.keyCode ? e.keyCode : e.which);                
			//		return (code == 13) ? false : true;
			//   });
			//});		
			
			//EXPANDIR
			jQuery.fn.toggleText = function(a,b) {
			return   this.html(this.html().replace(new RegExp("("+a+"|"+b+")"),function(x){return(x==a)?b:a;}));
			}
			
			$(document).ready(function(){
				$('.tgl').before('<span>Exibir Informações</span>');
				$('.tgl').css('display', 'none')
				$('span', '#box-toggle').click(function() {
					$(this).next().slideToggle('slow')
					.siblings('.tgl:visible').slideToggle('fast');
				
					$(this).toggleText('Exibir','Esconder')
					.siblings('span').next('.tgl:visible').prev()
					.toggleText('Exibir','Esconder')
				});
			})				
		</script>
        
	<!-- Add mousewheel plugin (this is optional) -->
	<script type="text/javascript" src="js/lib/jquery.mousewheel-3.0.6.pack.js"></script>

	<!-- Add fancyBox main JS and CSS files -->
	<script type="text/javascript" src="js/source/jquery.fancybox.js?v=2.1.5"></script>
	<link rel="stylesheet" type="text/css" href="js/source/jquery.fancybox.css?v=2.1.5" media="screen" />

	<!-- Add Button helper (this is optional) -->
	<link rel="stylesheet" type="text/css" href="js/source/helpers/jquery.fancybox-buttons.css?v=1.0.5" />
	<script type="text/javascript" src="js/source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>

	<!-- Add Thumbnail helper (this is optional) -->
	<link rel="stylesheet" type="text/css" href="js/source/helpers/jquery.fancybox-thumbs.css?v=1.0.7" />
	<script type="text/javascript" src="js/source/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>

	<!-- Add Media helper (this is optional) -->
	<script type="text/javascript" src="js/source/helpers/jquery.fancybox-media.js?v=1.0.6"></script>

	<script type="text/javascript">
		$(document).ready(function() {
			/*
			 *  Simple image gallery. Uses default settings
			 */

			$('.fancybox').fancybox({
				afterClose  :function () {
						window.location.reload();
					}
			});
			/*
			 *  Different effects
			 */

			// Change title type, overlay closing speed
			$(".fancybox-effects-a").fancybox({
				helpers: {
					title : {
						type : 'outside'
					},
					overlay : {
						speedOut : 0
					}
				}
			});

			// Disable opening and closing animations, change title type
			$(".fancybox-effects-b").fancybox({
				openEffect  : 'none',
				closeEffect	: 'none',			

				helpers : {
					title : {
						type : 'over'
					}
				}
			});

			// Set custom style, close if clicked, change title type and overlay color
			$(".fancybox-effects-c").fancybox({
				wrapCSS    : 'fancybox-custom',
				closeClick : true,

				openEffect : 'none',

				helpers : {
					title : {
						type : 'inside'
					},
					overlay : {
						css : {
							'background' : 'rgba(238,238,238,0.85)'
						}
					}
				}
			});

			// Remove padding, set opening and closing animations, close if clicked and disable overlay
			$(".fancybox-effects-d").fancybox({
				padding: 0,

				openEffect : 'elastic',
				openSpeed  : 150,

				closeEffect : 'elastic',
				closeSpeed  : 150,

				closeClick : true,

				helpers : {
					overlay : null
				}
			});

			/*
			 *  Button helper. Disable animations, hide close button, change title type and content
			 */

			$('.fancybox-buttons').fancybox({
				openEffect  : 'none',
				closeEffect : 'none',

				prevEffect : 'none',
				nextEffect : 'none',

				closeBtn  : false,

				helpers : {
					title : {
						type : 'inside'
					},
					buttons	: {}
				},

				afterLoad : function() {
					this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
				}
			});


			/*
			 *  Thumbnail helper. Disable animations, hide close button, arrows and slide to next gallery item if clicked
			 */

			$('.fancybox-thumbs').fancybox({
				prevEffect : 'none',
				nextEffect : 'none',

				closeBtn  : false,
				arrows    : false,
				nextClick : true,

				helpers : {
					thumbs : {
						width  : 50,
						height : 50
					}
				}
			});

			/*
			 *  Media helper. Group items, disable animations, hide arrows, enable media and button helpers.
			*/
			$('.fancybox-media')
				.attr('rel', 'media-gallery')
				.fancybox({
					openEffect : 'none',
					closeEffect : 'none',
					prevEffect : 'none',
					nextEffect : 'none',

					arrows : false,
					helpers : {
						media : {},
						buttons : {}
					}
				});

			/*
			 *  Open manually
			 */

			$("#fancybox-manual-a").click(function() {
				$.fancybox.open('1_b.jpg');
			});

			$("#fancybox-manual-b").click(function() {
				$.fancybox.open({
					href : 'iframe.html',
					type : 'iframe',
					padding : 5
				});
			});

			$("#fancybox-manual-c").click(function() {
				$.fancybox.open([
					{
						href : '1_b.jpg',
						title : 'My title'
					}, {
						href : '2_b.jpg',
						title : '2nd title'
					}, {
						href : '3_b.jpg'
					}
				], {
					helpers : {
						thumbs : {
							width: 75,
							height: 50
						}
					}
				});
			});


		});
	</script>
	<style type="text/css">
		.fancybox-custom .fancybox-skin {
			box-shadow: 0 0 50px #222;
		}
		.fancybox-wrap{
			top:80;
		}

	</style> 
        
<?php if($_GET['Imprimir'] == "Sim"){
	echo "<script>window.print();</script>";
}?>
<meta charset="utf-8">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" height="50" colspan="5" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="40"><span class="TituloPagina" style="padding-left: 5px;">ESTÚDIOS DO DIA <?php echo InverteDataNovoSeparador($data_atual, "-", "/");?></span></td>
        <td align="right">&nbsp;</td>
        <td width="80" align="right" style="padding-right: 8px;">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="5" align="center" valign="middle"><table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
      <tr class="TextoCinzaEscuro">
        <td width="5%" bgcolor="#97D6FF"><strong>CÓD. ATEND.</strong></td>
        <td width="5%" bgcolor="#97D6FF"><strong>TIPO</strong></td>
        <td width="20%" height="30" bgcolor="#97D6FF" class="TextoCinzaEscuro"><strong>CLIENTE</strong></td>
        <td width="10%" align="left" bgcolor="#97D6FF"><strong>MODELO</strong></td>
        <td width="10%" align="left" bgcolor="#97D6FF"><strong>HORA INICIO</strong></td>
        <td width="10%" align="left" bgcolor="#97D6FF"><strong>HORA FIM</strong></td>        
        <td width="10%" align="left" bgcolor="#97D6FF"><strong>CRIADOR EM</strong></td>
        <td width="10%" align="left" bgcolor="#97D6FF"><strong>AGENDADO POR</strong></td>
        <td width="2%" align="center" bgcolor="#97D6FF">&nbsp;</td>
      </tr>
              <?php
		if($_GET['idtipo_agenda'] != ""){
		$ids_tipo_agenda = "'" . str_replace(",", "','", $_GET['idtipo_agenda']) . "'";		
		}
		
		$data_atual = $_GET['data_atual'];
			$cor_fundo = "#FFFFFF";		
		if($ids_tipo_agenda == ""){
			 	$seleciona = Seleciona("agenda", "WHERE data='$data_atual' AND excluido IS NULL", "ORDER BY horainicio ASC");	
			echo "1";
		}else{
			$seleciona = Seleciona("agenda", "WHERE data='$data_atual' AND tipo IN ($ids_tipo_agenda) AND excluido IS NULL", "ORDER BY horainicio ASC");
			echo "2";
		}
			while($linha=mysql_fetch_array($seleciona)){
			$idusuario_cadastro = $linha['idusuario_cadastro'];
			if($cor_fundo == "#FFFFFF"){
				$cor_fundo = "#DEF2FF";
			}else{
				$cor_fundo = "#FFFFFF";
			}
			
			if(empty($data_festa) or $data_festa == "0000-00-00"){
				$cor_fundo = "#FFECEC";
			}
if($linha['idcliente'] > 0){			
$selecionar_clientes = Seleciona("clientes", "WHERE idcliente='".$linha['idcliente']."'", "") or die(mysql_error());
while($linha_clientes=mysql_fetch_array($selecionar_clientes)){

$responsavel = "<strong>".utf8_decode($linha_clientes['nome'])."</strong>"; 
$telefone = "Telefone: ".$linha_clientes['telefone'] . " / " . $linha_clientes['telefone2'] . "<br> Celular: " . $linha_clientes['celular'] . " / " . $linha_clientes['celular2'];

}
}
				
$cor_fundo = RetornaCampoGeral("agenda_tipos", $linha['idtipo_agenda'], "idtipo_agenda", "cor");				
				
				
		?>
        <tr class="TextoCinzaPequeno" bgcolor="<?php echo $cor_fundo;?>" onmouseover="javascript:this.style.backgroundColor='#CCCCCC'" onmouseout="javascript:this.style.backgroundColor='<?php echo $cor_fundo;?>'" style="cursor:pointer;">
          <td align="center"><?php echo $linha['idatendimento'];?></td>
          <td width="5%"><?php echo RetornaCampoGeral("agenda_tipos", $linha['idtipo_agenda'], "idtipo_agenda", "titulo");?></td>
          <td width="20%" height="30"><?php echo $responsavel . "<br>" . $telefone;?></td>
          <td width="10%" align="left"><?php echo RetornaCampoGeral("atendimentos_agenciae", $linha['idatendimento'], "idatendimento", "aniversariante");?></td>
          <td width="10%" align="left"><?php echo $linha['horainicio'];?></td> 
          <td width="10%" align="left"><?php echo $linha['horafim'];?></td>                    
          <td width="10%" align="left"><?php echo InverteDataNovoSeparador($linha['datacadastro'], "-", "/");?></td>
          <td width="10%" align="left"><?php echo LoginUsuario($linha['idusuario_cadastro']);?></td>
          <td width="2%" align="right">
	      <a href="manutencao_atendimentos_agenciae.php?idatendimento=<?php echo $linha['idatendimento'];?>" target="_blank">
		  <img src="img/icone_detalhe_novo.png" width="27" height="35" border="0" />
		  </a>	 
		  </td>
          </tr>
        <?php 
		$responsavel = "";
		$telefone = "";
		}?>
    </table></td>
  </tr>
  <tr>
    <td colspan="5" align="center" valign="middle">
</td>
  </tr>
</table>
<table width="100" border="0" align="center" cellpadding="2" cellspacing="0" class="BoxMenuCinza">
  <tr>
    <td height="25" align="center" class="TextoMenuBranco" style="font-weight:normal;"><a href="estudio_agenda.php?data_atual=<?php echo $_GET['data_atual'];?>&idatendimento=<?php echo $_GET['idatendimento'];?>&idcliente=<?php echo $_GET['idcliente'];?>&Imprimir=Sim" style="color:#FFFFFF" target="_blank">Imprimir</a></td>
  </tr>
</table>
<p>&nbsp;</p>
<?php if($_GET['idatendimento'] != "" or $_GET['idcliente'] != ""){ ?>
<table width="200" border="0" align="center" cellpadding="2" cellspacing="0" class="BoxMenuAzul">
  <tr>
    <td height="25" align="center" class="TextoMenuBranco" style="font-weight:normal;"><a href="manutencao_atendimentos_agenciae.php?idatendimento=<?php echo $_GET['idatendimento'];?>&idcliente=<?php echo $_GET['idcliente'];?>&data_escolhida=<?php echo $_GET['data_atual'];?>" style="color:#FFFFFF" target="_top">Selecionar Essa Data</a></td>
  </tr>
</table>
<?php } ?>

<?php if($_GET['idatendimento'] == "" and $_GET['idcliente'] == ""){ ?>
<table width="200" border="0" align="center" cellpadding="2" cellspacing="0" class="BoxMenuAzul">
  <tr>
    <td height="25" align="center" class="TextoMenuBranco" style="font-weight:normal;"><a href="manutencao_atendimentos_agenciae.php?data_escolhida=<?php echo $_GET['data_atual'];?>" style="color:#FFFFFF" target="_parent">Criar Cliente nesta Data</a></td>
  </tr>
</table>
<?php } ?>

<p>&nbsp;</p>
</body>
</html>