<?php require_once('topo.php');?>
<?php require_once('lateral.php');?>
      <!-- Right side column. Contains the navbar and content of the page -->
      <div class="content-wrapper" style="<?php if($_GET['Box'] != ""){ echo "margin-left: 0px;"; }?>">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Pacotes
            <small>listagem de pacotes</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="index.php?Box=<?php echo $_GET['Box'];?>"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="listar_pacotes.php?Box=<?php echo $_GET['Box'];?>">Pacotes</a></li>
            <li class="active">Listagem</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12"><!-- /.box -->

              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Listagem de Pacotes</h3>
                  
                  <button type="button" class="btn <?php if($_GET['Filtro'] == "Ativo"){ echo "btn-success"; }else{ echo "btn-primary";}?>" style=" float:right;" onclick="location.href='listar_pacotes.php?Filtro=Ativo&Box=<?php echo $_GET['Box'];?>';">Pacotes Ativos</button>
                  <button type="button" class="btn <?php if($_GET['Filtro'] == "Esgotados"){ echo "btn-success"; }else{ echo "btn-primary";}?>" style=" float:right;" onclick="location.href='listar_pacotes.php?Filtro=Esgotados&Box=<?php echo $_GET['Box'];?>';">Pacotes Esgotados</button>
                  <button type="button" class="btn <?php if($_GET['Filtro'] == ""){ echo "btn-success"; }else{ echo "btn-primary";}?>" style=" float:right;" onclick="location.href='listar_pacotes.php?Box=<?php echo $_GET['Box'];?>';">Todos os Pacotes</button>
                  
                  <button type="button" class="btn btn-primary" style=" float:right;" onclick="location.href='manutencao_pacotes.php?Box=<?php echo $_GET['Box'];?>';">Novo Pacote</button>
                  <br>
                  <br>
                <!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th style="cursor:pointer">Cód.</th>
                        <th style="cursor:pointer">Titulo Pacote</th>
                        <th style="cursor:pointer">Saída</th>
                        <th style="cursor:pointer">Data de Saída</th>
                        <th style="cursor:pointer">Data de Retorno</th>
                        <th style="cursor:pointer">Tipo</th>                        
                        <th style="cursor:pointer">Url Amigável</th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
                    $cor_fundo = "#FFFFFF";	
                        
                    if($_GET['Filtro'] == ""){
                        $seleciona = Seleciona("pacotes", "WHERE excluido IS NULL", "ORDER BY idpacote DESC");                    
                    }
                        
                    if($_GET['Filtro'] == "Ativo"){
                        $seleciona = Seleciona("pacotes", "WHERE excluido IS NULL AND esgotado <> 'Sim'", "ORDER BY idpacote DESC");    
                    }
                        
                    if($_GET['Filtro'] == "Esgotado"){
                        $seleciona = Seleciona("pacotes", "WHERE excluido IS NULL AND esgotado='Sim'", "ORDER BY idpacote DESC");    
                    }

                        
                    while($linha=mysql_fetch_array($seleciona)){										
                    
                    if($linha['esgotado'] == "Sim"){
                    $cor_fundo = "#FFCFBF";
                    }
                    
                    $slug = slugify($linha['titulo']);
                    //ALTERAR PACOTE
                    $AlterarPacote = Alterar("pacotes", "slug='$slug'", "idpacote", $linha['idpacote']);
                    ?>
                      <tr bgcolor="<?php echo $cor_fundo;?>"style="cursor:pointer" onclick="location.href='manutencao_pacotes.php?idpacote=<?php echo $linha['idpacote'];?>&Box=<?php echo $_GET['Box'];?>';">
                        <td bgcolor="<?php echo $cor_fundo;?>"><strong><?php echo $linha['idpacote'];?></strong></td>
                        <td bgcolor="<?php echo $cor_fundo;?>"><strong><?php echo $linha['titulo'];?></strong></td>
                        <td bgcolor="<?php echo $cor_fundo;?>"><?php echo $linha['saida'];?></td>
                        <td bgcolor="<?php echo $cor_fundo;?>" data-search='<?php echo InverteDataNovoSeparador($linha['datasaida'], "-", "/");?>' data-order='<?php echo $linha['datasaida'];?>'><strong><?php echo InverteDataNovoSeparador($linha['datasaida'],"-","/");?></strong></td>
                        <td bgcolor="<?php echo $cor_fundo;?>" data-search='<?php echo InverteDataNovoSeparador($linha['dataretorno'], "-", "/");?>' data-order='<?php echo $linha['dataretorno'];?>'><strong><?php echo InverteDataNovoSeparador($linha['dataretorno'],"-","/");?></strong></td>
                        <td bgcolor="<?php echo $cor_fundo;?>"><?php echo $linha['tipo'];?></td>                        
                        <td bgcolor="<?php echo $cor_fundo;?>"><?php echo $slug;?></td>
                          
                      </tr>
                      <?php 
					  $cor_fundo = "";			
                      $slug = "";
					  }?>
                    </tbody>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
<?php require_once('rodape.php');?>