<?php
session_start();
if(strpos(strtolower($_SERVER['REQUEST_URI']), 'phpsessid') !== false)
{
  session_destroy();
  session_regenerate_id();
  session_start();
                              
}
include "../phpconfig/config.php";
include "../phpconfig/valida_login.php";

include "../includes/topo.php"; 

$id = $_GET['id'];


$sql = mysql_query("SELECT * FROM tipos WHERE id='$id'");

$lin = mysql_fetch_assoc($sql);

?>
        <ul class="breadcrumb">
          <li><a href="<?php echo sti('adm');  ?>">Home</a> </li>
          <li>Editar categoria
          <li class="active"><?php echo $lin['nome']; ?> </li>
        </ul>

 <form class="form-horizontal" method="post" action="edita.php" id='depform'  enctype="multipart/form-data">
  <input type="hidden" name="id" value="<?php echo $id ?>">
        <fieldset>
           <div class="control-group">
            <label class="control-label" >Título</label>
            <div class="controls">
             <input type="text" name="titulo" value="<?php echo $lin['nome']; ?>">
            </div>
          </div>

           <div class="control-group">
            <label class="control-label" >Dias e Horário</label>
            <div class="controls">

              <?php

                $semana = array();

                if(!empty($lin['semana']))   $semana= unserialize($lin['semana']);
              
              ?>

            <input type="checkbox" name="semana[]" value="7" <?php if(in_array('7', $semana) != FALSE){ echo "checked = 'checked'"; } ?>> - Domingo       <br />
            <input type="checkbox" name="semana[]" value="1" <?php if(in_array('1', $semana) != FALSE){ echo "checked = 'checked'"; } ?>> - Segunda-feira <br />
            <input type="checkbox" name="semana[]" value="2" <?php if(in_array('2', $semana) != FALSE){ echo "checked = 'checked'"; } ?>> - Terça-feira   <br />
            <input type="checkbox" name="semana[]" value="3" <?php if(in_array('3', $semana) != FALSE){ echo "checked = 'checked'"; } ?>> - Quarta-feira  <br />
            <input type="checkbox" name="semana[]" value="4" <?php if(in_array('4', $semana) != FALSE){ echo "checked = 'checked'"; } ?>> - Quinta-feira  <br />
            <input type="checkbox" name="semana[]" value="5" <?php if(in_array('5', $semana) != FALSE){ echo "checked = 'checked'"; } ?>> - Sexta-feira   <br />
            <input type="checkbox" name="semana[]" value="6" <?php if(in_array('6', $semana) != FALSE){ echo "checked = 'checked'"; } ?>> - Sábado        <br />
 
            </div>     
            <br />       
            <div class="controls">
             Início <input type="text" name="hora1" value="<?php echo $lin['hora1']; ?>">
             Fim <input type="text" name="hora2" value="<?php echo $lin['hora2']; ?>">
            </div>
          </div>

                  <div class="control-group">
                    <?php if($_SESSION['nivel']==1){   ?>
            <label class="control-label"  for="depp">Deletar</label><div class="controls">
              <a href="del.php?id=<?php echo $lin['id'];  ?>" onclick="return confirma('Deseja deletar esta categoria?');" class="btn btn-danger pull-right" ><span class="glyphicon glyphicon-trash"></span></a>
         </div><?php } ?>
         </div>

          <div class="form-actions">
            <input  type="submit" class="btn btn-primary" value='Salvar' />
            <a class="btn btn-warning pull-right" href="index.php">Voltar</a>
          </div>
        </fieldset>
      </form>
<?php include "../includes/rodape.php"; ?>
