<?php
error_reporting(0);
ini_set("display_errors", 0 );
header('Content-Type: text/html; charset=utf-8');
include("../configuracao.php");//confirma no banco de dados
include("../inclusos/funcoes.php");
include("../seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página
?>
<!doctype html>
<html ng-app="myApp">
<head>
<title>RELATÓRIO DE TAREFAS</title>

<link rel="stylesheet" href="inclusos/styles.css">
<link href="inclusos/css_precopratico.css" rel="stylesheet" type="text/css">
<style type="text/css">
@media print {
  #naoimprimir {
    visibility: hidden;
  }
  #printable, #printable * {
    visibility: visible;
  }
}
        </style> 
<script src="https://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></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({	
			minHeight: 300,		
            width: '80%',
            height: '50%',
            autoScale: true,
            transitionIn: 'fade',
            transitionOut: 'fade',			
			afterClose  :function () {
			window.location.reload();
			},
			
			helpers   : {
			  overlay : { closeClick: false }
			},
			keys : {
			  close : null
			}			

			});
			
			/*
			 *  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;
		}
	body {
	background-color: #F2F2F2;
}
    </style>         



</head>
<body>
<?php

//SELECIONA E BUSCA

$busca = $_GET['busca'];
$datainicio = $_GET['datainicio'];
$datafim = $_GET['datafim'];
$status_orcamento = $_GET['status_orcamento'];
$idcliente = $_GET['idcliente'];

$cor_fundo = "#FFFFFF";			  
  

		$seleciona_vendas = Seleciona("tarefas", "WHERE idsolicitante='".$_SESSION['usuarioID']."'", "ORDER BY dataprazo DESC");
		
		//APENAS BUSCA
		if($busca != "" and $datainicio != "" and $datafim != "" and $status_orcamento == "" and $idcliente == ""){
			$seleciona_vendas = Seleciona("tarefas", "WHERE idsolicitante='".$_SESSION['usuarioID']."' AND tarefa LIKE '%".$busca."%'", "ORDER BY dataprazo DESC");
		}
		
		//APENAS STATUS
		if($busca == "" and $datainicio != "" and $datafim != "" and $status_orcamento != "" and $idcliente == ""){
			$seleciona_vendas = Seleciona("tarefas", "WHERE idsolicitante='".$_SESSION['usuarioID']."' AND status='$status_orcamento' AND dataprazo BETWEEN ('$datainicio') AND ('$datafim')", "ORDER BY dataprazo DESC");
		}		
		
		//APENAS CLIENTE
		if($busca == "" and $datainicio != "" and $datafim != "" and $status_orcamento == "" and $idcliente != ""){
			$seleciona_vendas = Seleciona("tarefas", "WHERE idsolicitante='".$_SESSION['usuarioID']."' AND idcliente='$idcliente' AND dataprazo BETWEEN ('$datainicio') AND ('$datafim')", "ORDER BY dataprazo DESC");
		}				
		
		//APENAS DATA INICIO E DATA FIM
		if($busca == "" and $datainicio != "" and $datafim != "" and $status_orcamento == "" and $idcliente == ""){
			$seleciona_vendas = Seleciona("tarefas", "WHERE idsolicitante='".$_SESSION['usuarioID']."' AND dataprazo BETWEEN ('$datainicio') AND ('$datafim')", "ORDER BY dataprazo DESC");
		}				


$TotalVendas = mysql_num_rows($seleciona_vendas);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="50" colspan="4" align="left" valign="middle">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="naoimprimir"  >
      <tr>
        <td width="80" height="40" class="TituloPagina" style="padding-left: 5px;"><a href="index.php"><img src="img/logobranco.fw.png" width="200" height="46" id="printable"></a></td>
        <td align="right">
          
          <form method="get" action="relatorio_atividades.php" enctype="multipart/form-data">
            <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" >
              <tr>
                <td align="center"><strong>DATA</strong></td>
                <td align="left"><input name="datainicio" type="date" class="InputBranco" id="datainicio" value="<?php echo $_GET['datainicio'];?>" placeholder="Data Inicio" style="width: 100%; height: 30px; background-color: #D3D3D3;" required /></td>
                <td align="left"><input name="datafim" type="date" class="InputBranco" id="datafim" value="<?php echo $_GET['datafim'];?>" placeholder="Data Fim" style="width: 100%; height: 30px; background-color: #D3D3D3;" required /></td>
                <td align="center"><strong>CLIENTE</strong></td>
                <td align="center"><span style="color: #676767;  font-size: 12px;">
                  <select name="idcliente" size="1" id="idcliente" class="form-campos" style="width:100%; height: 30px;">
                    <option value="">Selecione um Cliente</option>
                    <?php
						$SelecionaProfissionais = Seleciona("clientes", "WHERE CodCli='".$_GET['idcliente']."'", "ORDER BY Fantasia ASC") or die(mysql_error());
							while($linha_profissionais=mysql_fetch_array($SelecionaProfissionais)){
								$id_profissional = $linha_profissionais['CodCli'];					  
					  ?>
                    <option value="<?php echo $linha_profissionais['CodCli'];?>" <?php if($_GET['idcliente'] == $id_profissional){ echo "Selected";}?>><?php echo $linha_profissionais['Fantasia'];?></option>
                    <?php
                      }
					  ?>
                    </select>
                  </span></td>
                <td align="center"><strong>STATUS</strong></td>
                <td align="left">
                <select name="status" size="1" required class="form-campos" id="status" style="width:100%; height: 30px;">
                <option value="">Selecione o Status</option>
                <option value="Finalizado" <?php if($status == "Finalizado"){ echo "selected";}?>>Finalizado</option>
                <option value="Andamento" <?php if($status == "Andamento"){ echo "selected";}?>>Andamento</option>
                <option value="Cancelado" <?php if($status == "Cancelado"){ echo "selected";}?>>Cancelado</option>
                </select>                
                </td>
                <td align="center"><strong>BUSCA</strong></td>
                <td width="370" align="right"><table width="100%" border="0" align="right" cellpadding="0" cellspacing="0" class="BoxMenuBranco">
                  
                  <tr>
                    <td width="148" align="left" bgcolor="#FFFFFF"><input name="busca" type="text" class="InputBranco" id="busca" placeholder="Titulo" style="width: 100%; height: 30px; background-color: #D3D3D3;" /></td>
                    <td width="28" align="center" bgcolor="#FFFFFF"><input type="image" src="img/icone_buscar.gif" /></td>
                    </tr>
                  
                  </table>
                  
                  </td>
                </tr>
              </table>
            </form>
        </td>
        </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td colspan="4" align="center" valign="top">
    <table width="100%" border="0" align="center" cellpadding="4" cellspacing="0" id="printable">
      <tr class="TextoCinzaEscuro">
        <td align="left" bgcolor="#A6A6A6"><strong>DATA</strong></td>
        <td height="30" align="left" bgcolor="#A6A6A6"><strong>CLIENTE</strong></td>
        <td align="left" bgcolor="#A6A6A6"><strong>TAREFA</strong></td>
        <td align="left" bgcolor="#A6A6A6"><strong>DATA INICIO</strong></td>
        <?php if($_GET['ocultar_bruto'] != "sim"){?>
        <td align="left" bgcolor="#A6A6A6"><strong>DATA FIM</strong></td>
        <?php }?>
        <?php if($_GET['ocultar_venda'] != "sim"){?>        
        <td align="left" bgcolor="#A6A6A6"><strong>PRIORIDADE</strong></td>
        <td align="left" bgcolor="#A6A6A6">OBS.</td>
        <td align="left" bgcolor="#A6A6A6"><strong>STATUS</strong></td>
        <?php }?>        
        <td align="left" bgcolor="#A6A6A6">&nbsp;</td>
        </tr>
      <?php			  
			while($linha=mysql_fetch_array($seleciona_vendas)){
				$id_cliente = $linha['idcliente'];
				
				//SELECIONA NOME CATEGORIA
				
			 	$SelecionaCliente = Seleciona("clientes", "WHERE CodCli='$id_cliente'", "");	
				while($clientes=mysql_fetch_array($SelecionaCliente)){
					$NomeCliente = $clientes['Fantasia'];
				}			
			if($cor_fundo == "#FFFFFF"){
				$cor_fundo = "#E4E4E4";
			}else{
				$cor_fundo = "#FFFFFF";
			}

		?>
      <tr class="TextoCinzaPequeno" bgcolor="<?php echo $cor_fundo;?>" onmouseover="javascript:this.style.backgroundColor='#CCCCCC'" onmouseout="javascript:this.style.backgroundColor='<?php echo $cor_fundo;?>'">
        <td align="left" style="font-size:10px; font-weight:bold;">
<?php echo InverteDataNovoSeparador($linha['data'], "-", "/");?>
        </td>
        <td height="30" align="left"><?php echo $NomeCliente;?></td>
        <td align="left"><?php echo $linha['tarefa'];?></td>
        <td align="left"><?php echo InverteDataNovoSeparador($linha['dataentrada'], "-", "/");?></td>
          
        <td align="left"><?php echo InverteDataNovoSeparador($linha['dataprazo'], "-", "/");?></td>


        <td align="left"><strong><?php echo $linha['prioridade'];?></strong></td>
        <td align="left"><?php echo $linha['assunto'];?></td>
        <td align="left"><?php echo $linha['status'];?></td>
        <td align="right"><a href="manutencao_tarefa_lytebox_final.php?idtarefa=<?php echo $linha['idtarefa'];?>" class="fancybox fancybox.iframe" ><img src="img/icone_detalhe.gif" width="22" height="24" border="0" /></a></td>
        </tr>
        <?php }?>
    </table>
    </td>
  </tr>
  <tr>
    <td colspan="5" align="center" valign="middle">
</td>
  </tr>
</table>
</body>
</html>