<?php
session_start();
///Construtoras listar
include "../phpconfig/config.php";
include "../phpconfig/valida_login.php";
include "../phpconfig/funcoes.php";
include "../includes/topo.php";

$id = $_GET['id'];

$query = mysql_query("SELECT * FROM imagens WHERE id_emp ='$id'  ORDER BY ordem ASC");
$query2 = mysql_query("SELECT * FROM empresas WHERE id ='$id'");

$emp = mysql_fetch_assoc($query2);

$cidade = $emp['id_cidade'];

$num = mysql_num_rows($query);

?>
<script type="text/javascript" src="jquery.uploadifive.min.js" ></script>
<link rel="stylesheet" type="text/css" href="uploadifive.css">

<!--script src="jquery-ui-1.8.22.custom.min.js"></script-->
	
<script type="text/javascript">
  // When the document is ready set up our sortable with it's inherant function(s)
  $(document).ready(function() {
    $("#test-list").sortable({
      handle : '.handle',
      update : function () {
      var order = $('#test-list').sortable('serialize');
      $("#info").load("process-sortable.php?"+order);  
   

      }
    });
}); 

    <?php $timestamp = time();?>
    $(function() {
      $('#file_upload').uploadifive({
        'auto'             : false,
        'checkScript'      : 'check-exists.php',
        'formData'         : {
         'timestamp' : '<?php echo $timestamp;?>',
         'token'     : '<?php echo md5(sti("salt") . $timestamp);?>',
         'id_up'     : '<?php echo $id; ?>'
                             },
        'queueID'          : 'queue',
        'uploadScript'     : 'uploadifive.php',
        'onUploadComplete' : function(file, data) { console.log(data); }
      });
    });
  </script>
        
        <ul class="breadcrumb">
          <li><a href="<?php echo sti('cms');  ?>">Home</a></li>
          <li class="active">Galeria </li>
          <li class="active"><?php echo $num; ?> - <?php echo $emp['empresa']; ?></span></li>
        </ul>
        <p id='info'></p>
        <table class="table table-bordered"  >

        <thead>
          <tr>
            <th  colspan='8'> 


                 <form>
                  
                  <input id="file_upload" class="btn btn-success" name="file_upload" type="file" multiple="true">
                  <a class="btn btn-success" style="position: relative; top: 8px;" href="javascript:$('#file_upload').uploadifive('upload')">UPLOAD</a>
                  <a class="btn btn-warning" style="position: relative; top: 8px;" href="">ATUALIZAR</a>
                  <div id="queue"></div>
                </form>
              
            </th>

          </tr>
          <tr>

            <th>Mover</th>
            <th>ID</th>
            <th>Imagem</th>
            <th>Legenda</th>

            <th>Ações</th>
          </tr>
        </thead>
        <tbody id='test-list'>
          
          
          <?php  

          while($lin = mysql_fetch_assoc($query)){  ?>
          <tr id="listItem_<?php echo $lin['id']; ?>">
            <td> <div class="box_img handle" style="cursor:move;display:block">
          <div class="mover"><i class='glyphicon glyphicon-move'></i></div></td>
            <td><?php echo $lin['id'];  ?></td>
            <td><img width='160' src="<?php echo  sti('up')."/galerias/".'thumb1-'.$lin['nome'];  ?>" /></td>
            <td><?php echo $lin['alt'];  ?></td>
           

            <td>
              <a href="edit.php?id=<?php echo $lin['id']; ?>&proj=<?php echo $id;  ?>" class="btn btn-default" ><i class="glyphicon glyphicon-pencil"></i></a>
              <a href="del.php?id=<?php echo $lin['id']; ?>&proj=<?php echo $id;  ?>" title="Deseja deletar esta imagem?"  class="btn btn-default del" ><i class="glyphicon glyphicon-trash"></i></a>
            
            
            </td>
          </tr>
     
          <?php  } if($num==0){echo "<tr><td  colspan='8'>Não há cadastro de imagens</td></tr>";} ?>

        
                  <tr>
            <th  colspan='8'> 

              
                 <form>

                  <a class="btn btn-warning" style="position: relative; top: 8px;" href="../empresas/listar.php?c=<?php echo $cidade; ?>">VOLTAR</a>

                </form>
              
            </th>

          </tr>
        </tbody>
      </table>


<!--div class="pagination">
  <ul  >
    <li><a href="#">Prev</a></li>
    <li><a href="#">1</a></li>
    <li><a href="#">2</a></li>
    <li><a href="#">3</a></li>
    <li><a href="#">4</a></li>
    <li><a href="#">Next</a></li>
  </ul>
</div-->

<?php include "../includes/rodape.php"; ?>
