<?php
error_reporting(E_WARNING);

require_once("funcoes.php");
require_once("valida.php");
$_SESSION['editprod'] = $_GET['edit'];
$_SESSION['tabela'] = "tb_prod_fotos";
$_SESSION['campo'] = "cod_prod";
$_SESSION['pasta'] = "produtos/secundarias/";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php require_once("topo.php"); ?>  
<title><?php 
    global $insertcod;
    if($insertcod <> ""){
    $edit   =   $insertcod;
    } else {
        $edit   =   $_GET['edit'];
    }
    $selectprod2    =   "SELECT * FROM tb_produto WHERE cod = $edit";
    $queryprod2 =   mysql_query($selectprod2);
    $sqlprod2   =   mysql_fetch_array($queryprod2);
    
    
echo $sqlprod2['nome'] ?> / Editar Produto / Painel de Administra&ccedil;&atilde;o</title>

<link rel="stylesheet" href="css/query-ui.css" />
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script src="../ckeditor/_samples/sample.js" type="text/javascript"></script>
<script type="text/javascript">

function ExecutaAcao(valor){
   document.editar.action = valor; 
   document.editar.submit();
}

</script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Generic page styles -->

<!-- blueimp Gallery styles -->
<link rel="stylesheet" href="//blueimp.github.io/Gallery/css/blueimp-gallery.min.css">
<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
<link rel="stylesheet" href="css/jquery.fileupload.css">
<link rel="stylesheet" href="css/jquery.fileupload-ui.css">
<!-- CSS adjustments for browsers with JavaScript disabled -->
<noscript><link rel="stylesheet" href="css/jquery.fileupload-noscript.css"></noscript>
<noscript><link rel="stylesheet" href="css/jquery.fileupload-ui-noscript.css"></noscript>
</head>
<body>
<div id="conteudo">

    <?php
    


    $selectprod =   "SELECT * FROM tb_produto WHERE cod = $edit";
    $queryprod  =   mysql_query($selectprod);
    $sqlprod    =   mysql_fetch_array($queryprod);
    
    ?>

    <div id="top_conteudo"> 
    <form name="editar" action="gerenciar_produtos.php?pag=1" method="post" enctype="multipart/form-data">
        <p> Editando Produto - <?php echo $sqlprod['nome'] ?> </p>
            <div class="criar_produto">
                <input type="button" name="editar_produto" value="Salvar" onClick="ExecutaAcao('gerenciar_produtos.php?pag=1');" />

            </div>
            
            <div class="criar_produto" style="margin:0 10px; text-align:center">
                <input type="button" name="editar_produto" value="Salvar e Continuar" onClick="ExecutaAcao('editar_produto.php?edit=<?php echo $sqlprod['cod'] ?>');" />
            </div>
        </div> 
        <div id="cadastros">
        
                <div id="tabs"> 
                    <ul>
                        <li><a href="#geral"><span>Geral</span></a></li>
                        <li><a href="#imagem"><span>Imagem</span></a></li>
                        <li><a href="#mais-fotos"><span>Fotos</span></a></li>
                        <li><a href="#categorias"><span>Categorias</span></a></li>
                        <li><a href="#seo"><span>SEO</span></a></li>
                        <li><a href="#caracteristica"><span>Características</span></a>
                        <li><a href="#opcoes-cores"><span>Opções de Cores</span></a></li>
                        <li><a href="#opcoes-tamanhos"><span>Opções de Tamanho</span></a></li>
                        <li><a href="#etiquetas"><span>Etiquetas</span></a></li>
                        <li><a href="#relacionados"><span>Relacionados</span></a></li>
                    </ul>
        <div id="geral">
            <table>


                <tr>
                    <input type="hidden" name="editar_produto" value="true" />

                    <input type="hidden" name="cod" value="<?php echo $sqlprod['cod']; ?>" />
                    <td>Nome: </td>
                    <td><input type="text" name="nome" value="<?php echo $sqlprod['nome']; ?>" /></td>
                </tr>
                
                <tr>
                    <td>Sku: </td>
                    <td><input type="text" name="sku" value="<?php echo $sqlprod['sku']; ?>" /></td>
                </tr>

                <tr>
                    <td>Valor: </td>
                    <td><input type="text" name="valor" value="<?php echo $sqlprod['preco']; ?>" placeholder="Ex: 1999 (apenas numeros inteiros)" /></td>
                </tr>

                <tr>
                    <td>Valor promocional: </td>
                    <td><input type="text" name="valor_promocional" value="<?php echo $sqlprod['preco_promocional']; ?>" placeholder="Ex: 999 (apenas numeros inteiros)" /></td>
                </tr>
                
                <tr>
                    <td>Descrição Curta: </td>
                    <td><textarea name="descricao"><?php echo $sqlprod['descricao_curta']; ?></textarea></td>
                    <td></td>
                </tr>

                <tr>
                    <td>Descrição Completa: </td>
                    <td><textarea name="descricao_completa" placeholder="" class="ckeditor" cols="80" id="editor"><?php echo $sqlprod['descricao_completa']; ?></textarea></td>
                    <td></td>
                </tr>


                <tr>
                    <td>Busca interna: </td>
                    <td><textarea name="busca_interna" placeholder=""><?php echo $sqlprod['busca_interna']; ?></textarea></td>
                    <td></td>
                </tr>

                <tr>
                    <td>Situação: </td>
                    <td>
                        <select name="status">
                            <option value="<?php echo $sqlprod['status'] ?>" selected="selected"><?php if($sqlprod['status'] == 1) { echo "Habilitado"; } else { echo "Desabilitado"; } ?></option>
                            <?php if($sqlprod['status'] == 1) { ?> <option value="2">Desabilitado</option> <?php } else { ?> <option value="1">Habilitado</option><?php } ?>
                            
                        </select>
                    </td>
                </tr>
    
                
             </table>          
        
        </div> 
        <div id="imagem">
		<table>
        
            <tr>
                <td>Imagem principal: </td>
            <?php 
                
                if(isset($_GET['del_imagem_prod1'])){
                               
                    $coddelprod =   $_GET['del_imagem_prod1'];
                    $updateprod =   "UPDATE tb_produto SET imagem_principal = '' WHERE cod = $coddelprod";
                    $deletar_foto   =   "../images/produtos/principal/".$sqlprod['imagem_principal'];
                    $deletar_foto2  =   "../images/produtos/principal/miniatura/".$sqlprod['imagem_principal'];
                    if($queryprod   =   mysql_query($updateprod)){
                    
                    if(unlink($deletar_foto) and unlink($deletar_foto2)){
                              
                              echo "Imagem excluida";
                              
                             } else {
                                 
                                 echo "Erro ao excluir";
                                 
                             } } }
                         
                if($sqlprod['imagem_principal'] == "" or $_GET['del_imagem_prod1']){?>
                
                    <td><input type="file" name="foto" value="" /></td>
                
                <?php } else { ?> 
                
                    <td><img src="../images/produtos/principal/miniatura/<?php echo $sqlprod['imagem_principal'] ?>" style="max-width:50px; max-height:50px;" /> <a href="?edit=<?php echo $sqlprod['cod'] ?>&del_imagem_prod1=<?php echo $sqlprod['cod'] ?>#imagem" style="font-size:10px; text-decoration:none;">Excluir</a><input type="file" name="foto" value="" /><input type="hidden" name="foto3" value="<?php echo $sqlprod['imagem_principal'] ?>" /></td>
                    
                
                <?php } ?>
            </tr>

         </table>
            
           </div>
        
         <div id="seo">
         
        		<table>
                
                	<tr>
                    	<td>Title</td>
                        <td><input type="text" onkeyup="limitaInput(this.value)" id="title" name="titulo_seo" value="<?php echo $sqlprod['titulo_seo']; ?>" /><span style="font-size:10px; color:#666;" >caracteres restantes:</span> <span id="contador3" style="font-size:10px; color:#666;">90</span></td>
                    </tr>
                
                    <tr>
                        <td>Meta Description: </td>
                        <td><textarea onkeyup="limitaTextarea(this.value)" id="descricao_seo" name="descricao_seo"><?php echo $sqlprod['descricao_seo']; ?></textarea><span style="font-size:10px; color:#666;" >caracteres restantes:</span> <span id="contador" style="font-size:10px; color:#666;">155</span></td>
                        <td></td>
                    </tr>
                    
                    <tr>
                    	<td>URL Amigável</td>
                        <td><input type="text" name="url_seo" value="<?php echo $sqlprod['url_seo']; ?>" /></td>
                    </tr>
                
                </table>        
        
        </div>

        <div id="categorias">
            
           <?php


            function categoryTree($filiacao = 0){
                global $edit;

                global $db;
                //$query = $db->query("SELECT * FROM tb_categoria WHERE filiacao = $filiacao ORDER BY ordem ASC");

                $selectcat = mysql_query("SELECT c.cod AS codcategoria, c.nome AS nomecategoria, cp.cod_prod AS codigocatproduto, c.filiacao FROM tb_prod_cat cp  RIGHT JOIN tb_produto p ON (p.cod = cp.cod_prod AND p.cod = $edit) RIGHT JOIN tb_categoria c ON (c.cod = cp.cod_cat) WHERE c.filiacao = $filiacao ORDER BY c.ordem ASC");

               
                if(mysql_num_rows($selectcat) > 0){
                    echo "<ul style='list-style:none;'>";
                    while($row = mysql_fetch_assoc($selectcat)){
                        if($filiacao > 0){
                            $i3 = 20;
                        } else {
                            $i3 = 0;
                        }
                        echo '<label><li style="margin-left:'.$i3.'px; margin-bottom:10px; font-size:12px;"><input '; if($row['codigocatproduto'] == $edit) { echo 'checked="checked"'; } echo ' style="margin:5px 5px 0 5px;" type="checkbox" name="categoria[]" value='.$row['codcategoria'].' />'.$row['nomecategoria'].'</li></label>';
                        categoryTree($row['codcategoria']);
                    }
                    echo "</ul>";
                    
                }
            }


           ?>

            <?php categoryTree(); ?>


         </div>

        <div id="caracteristica">
         
                <table>
                
                    <tr>
                        <td>Material: </td>
                        <td><input type="text" name="material" value="<?php echo $sqlprod['material'] ?>" /></td>
                    </tr>

                    <tr>
                        <td>Garantia: </td>
                        <td><input type="text" name="garantia" value="<?php echo $sqlprod['garantia'] ?>" /></td>
                    </tr>

                    <tr>
                        <td>Prazo de produção: </td>
                        <td><input type="text" name="prazo" value="<?php echo $sqlprod['prazo'] ?>" /></td>
                    </tr>

                    <tr>
                        <td>Fabricante: </td>
                        <td><input type="text" name="fabricante" value="<?php echo $sqlprod['fabricante'] ?>" /></td>
                    </tr>

                    <tr>
                        <td>Instruções: </td>
                        <td><textarea name="instrucoes"><?php echo $sqlprod['instrucoes'] ?></textarea></td>
                    </tr>
                
                </table>        
        
        </div>  

         <div id="opcoes-tamanhos">
       
            <table>

                <tr>
                    <th style="width:150px">Nome do campo</th>
                    <th style="width:150px">Comprimento</th>
                    <th style="width:150px">Altura</th>
                    <th style="width:150px">Largura</th>
                    <th style="width:80px">Peso</th>
                </tr>
                
                <?php
                
                
                $selecttamanho2 =   "SELECT p.cod AS codproduto, tp.nomenclatura, tp.largurat, tp.alturat, tp.profundidadet, tp.peso, tp.preco, tp.cod_produto AS codtamproduto, tp.principal FROM tb_tam_prod tp RIGHT JOIN tb_produto p ON (p.cod = tp.cod_produto AND p.cod = $edit) WHERE tp.cod_produto = $edit ORDER BY tp.cod ASC";
                $querytamanho2  =   mysql_query($selecttamanho2);
                echo mysql_error();
                while($sqltamanho2  =   mysql_fetch_array($querytamanho2)){
                
                 ?>
                
                 <tr>
                    <td><input type="text" name="nomenclatura[]" style="width:150px" placeholder="Nome do campo" value="<?php echo $sqltamanho2['nomenclatura'] ?>"></td>
                    <td><input type="text" name="largura2[]" style="width:150px" value="<?php echo $sqltamanho2['largurat'] ?>" /></td>
                    <td><input type="text" name="altura2[]" style="width:150px" value="<?php echo $sqltamanho2['alturat'] ?>" /></td>
                    <td><input type="text" name="profundidade2[]" style="width:150px" value="<?php echo $sqltamanho2['profundidadet'] ?>" /></td>
                    <td><input type="text" name="peso[]" style="width:80px" value="<?php echo $sqltamanho2['peso'] ?>" /></td>                   
                </tr>

             
                <?php } ?>

                <tr>
                    <td><input type="text" name="nomenclatura[]" style="width:150px" placeholder="Nome do campo"></td>
                    <td><input type="text" name="largura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="altura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="profundidade2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="peso[]" style="width:80px" value="" /></td>
                </tr>

                <tr>
                    <td><input type="text" name="nomenclatura[]" style="width:150px" placeholder="Nome do campo"></td>
                    <td><input type="text" name="largura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="altura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="profundidade2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="peso[]" style="width:80px" value="" /></td>

                </tr>

                <tr>
                    <td><input type="text" name="nomenclatura[]" style="width:150px" placeholder="Nome do campo"></td>
                    <td><input type="text" name="largura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="altura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="profundidade2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="peso[]" style="width:80px" value="" /></td>
                </tr>

                <tr>
                    <td><input type="text" name="nomenclatura[]" style="width:150px" placeholder="Nome do campo"></td>
                    <td><input type="text" name="largura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="altura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="profundidade2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="peso[]" style="width:80px" value="" /></td>
                </tr>

                <tr>
                    <td><input type="text" name="nomenclatura[]" style="width:150px" placeholder="Nome do campo"></td>
                    <td><input type="text" name="largura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="altura2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="profundidade2[]" style="width:150px" value="" /></td>
                    <td><input type="text" name="peso[]" style="width:80px" value="" /></td>
                </tr>
                
             </table>
            
         </div>
     
         <div id="opcoes-cores">
            <table>

                <tr>
                    <th>Cor</th>
                </tr>
                
                
                <?php
                
                
                $selectcor2 =   "SELECT p.cod AS codproduto,c.nome AS nomecor, c.hexadecimal, cp.preco, c.cod AS codigocor, cp.cod_prod AS codcorproduto FROM tb_cor_prod cp RIGHT JOIN tb_produto p ON (p.cod = cp.cod_prod AND p.cod = $edit) RIGHT JOIN tb_cor c ON (c.cod = cp.cod_cor) ORDER BY c.nome ASC";
                $querycor2  =   mysql_query($selectcor2);
                echo mysql_error();
                while($sqlcor2  =   mysql_fetch_array($querycor2)){
                
                 ?>
                 <tr>

                <td><label><input type="checkbox" <?php if($sqlcor2['codcorproduto'] == $edit){ ?> checked="checked" <?php } ?> name="opcoescor[]" value="<?php echo $sqlcor2['codigocor'];?>" style="float: left;" /><div style="background: <?php echo $sqlcor2['hexadecimal'];?>; padding:10px; color: #fff; text-shadow: 1px 1px #000;margin-bottom: 10px;"><?php echo $sqlcor2['nomecor'];?></div></label></td>
                </tr>
                <?php } ?>
                
                
             </table>
            
         </div>

         <div id="etiquetas">
            <table>

                <tr>
                    <th>Etiquetas</th>
                </tr>
                
                <?php
                
                
                $selectcor2 =   "SELECT p.cod AS codproduto,e.nome AS nomeetiqueta, e.cod AS codigoetiqueta, pe.cod_prod AS codetiproduto FROM tb_prod_etiqueta pe RIGHT JOIN tb_produto p ON (p.cod = pe.cod_prod AND p.cod = $edit) RIGHT JOIN tb_etiquetas e ON (e.cod = pe.cod_etiqueta) ORDER BY e.nome ASC";
                $querycor2  =   mysql_query($selectcor2);
                echo mysql_error();
                while($sqlcor2  =   mysql_fetch_array($querycor2)){
                
                 ?>
                 <tr>

                <td><label><input type="checkbox" <?php if($sqlcor2['codetiproduto'] == $edit){ ?> checked="checked" <?php } ?> name="opcoesetiquetas[]" value="<?php echo $sqlcor2['codigoetiqueta'];?>" style="float: left;" /><?php echo $sqlcor2['nomeetiqueta'];?></label></td>
                </tr>
                <?php } ?>
                
                
             </table>
            
         </div>

         <div id="relacionados">
           <table>
            <tr>
            <th style="width:20px"><input class="checkcampo" type="checkbox" name="checkcampo" /></th>
            <th style="width:430px">Nome<br /><input type="text" class="camporel"></th>
            <th style="width:130px">SKU<br /><input type="text" class="camporel"></th>
            <th style="width:130px">Preço</th>
            <th style="width:130px">Status</th>
            </tr>   

             <?php

             $sql           =   "SELECT p.cod AS codproduto, p.sku, p.nome, p.status, p.preco, pr.cod_prod, pr.cod_prod_relacionado
FROM tb_produto p
LEFT JOIN tb_prod_relacionados pr ON (p.cod = pr.cod_prod_relacionado AND pr.cod_prod = $edit)
WHERE p.cod <> $edit AND status = 1
ORDER BY p.cod DESC";

                $query          =   mysql_query($sql) or die();
                while($sql = mysql_fetch_assoc($query)){ ?>
                <tr>
                    <td><input type="checkbox" class="inputrel" name="relacionados[]" <?php if($sql['cod_prod'] == $edit){ echo "checked='checked'"; } ?> value="<?php echo $sql['codproduto'];?>" style="float: left;" /></td>
                    <td style="text-align:left;"><?php echo $sql['nome'] ?> </td>
                    <td><?php echo $sql['sku'] ?> </td>
                    <td><?php echo $sql['preco'] ?> </td>
                    <td style="width:130px"><?php if($sql['status'] == 1){ echo "<img src='images/liberado.png' />"; } else { echo "<img src='images/bloqueado.png' />";  } ?> </td>
                </tr>
             
                <?php } ?>
                
             </table>
            
         </div>
        
        </form>

        <div id="mais-fotos">
            <form id="fileupload" action="//jquery-file-upload.appspot.com/" method="POST" enctype="multipart/form-data">
        <!-- Redirect browsers with JavaScript disabled to the origin page -->
        <noscript><input type="hidden" name="redirect" value="https://blueimp.github.io/jQuery-File-Upload/"></noscript>
        <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
        <div class="row fileupload-buttonbar">
            <div class="col-lg-7">
                <!-- The fileinput-button span is used to style the file input field as button -->
                <span class="btn btn-success fileinput-button">
                    <i class="glyphicon glyphicon-plus"></i>
                    <span>Add files...</span>
                    <input type="file" name="files[]" multiple>
                </span>
                <button type="submit" class="btn btn-primary start">
                    <i class="glyphicon glyphicon-upload"></i>
                    <span>Start upload</span>
                </button>
                <button type="reset" class="btn btn-warning cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel upload</span>
                </button>
                <button type="button" class="btn btn-danger delete">
                    <i class="glyphicon glyphicon-trash"></i>
                    <span>Delete</span>
                </button>
                <input type="checkbox" class="toggle">
                <!-- The global file processing state -->
                <span class="fileupload-process"></span>
            </div>
            <!-- The global progress state -->
            <div class="col-lg-5 fileupload-progress fade">
                <!-- The global progress bar -->
                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                    <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                </div>
                <!-- The extended global progress state -->
                <div class="progress-extended">&nbsp;</div>
            </div>
        </div>
        <!-- The table listing the files available for upload/download -->
        <table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
    </form>
               </div>
<!-- The blueimp Gallery widget -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
    <div class="slides"></div>
    <h3 class="title"></h3>
    <a class="prev">‹</a>
    <a class="next">›</a>
    <a class="close">×</a>
    <a class="play-pause"></a>
    <ol class="indicator"></ol>
</div>
        </div>
       
        <script>
        $( "#tabs" ).tabs();
        </script>
        </table>
  
    </div>
    </div>
    </div>
    </div>

<script type="text/javascript">




    function limitaTextarea(valor) {
    quantidade = 155;
    total = valor.length;

    if(total <= quantidade) {
        resto = quantidade- total;
        document.getElementById('contador').innerHTML = resto;
    } else {
        document.getElementById('descricao_seo').value = valor.substr(0, quantidade);
    }
}

    function limitaTextarea2(valor) {
    quantidade = 199;
    total = valor.length;

    if(total <= quantidade) {
        resto = quantidade- total;
        document.getElementById('contador2').innerHTML = resto;
    } else {
        document.getElementById('keywords_seo').value = valor.substr(0, quantidade);
    }
}

function limitaInput(valor) {
    quantidade = 90;
    total = valor.length;

    if(total <= quantidade) {
        resto = quantidade- total;
        document.getElementById('contador3').innerHTML = resto;
    } else {
        document.getElementById('title').value = valor.substr(0, quantidade);
    }
}
</script>

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>


<script>
    CKEDITOR.replace( 'editor', {
    filebrowserBrowseUrl: 'ckfinder/ckfinder.html',
    filebrowserUploadUrl: 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
} );
</script>



    <script>
    $(function(){
        $("#relacionados input").keyup(function(){     
            var index = $(this).parent().index();
            var nth = "#relacionados td:nth-child("+(index+1).toString()+")";
            var valor = $(this).val().toUpperCase();
            $('.checkcampo').prop('checked', false);
            $("#relacionados tbody tr").show();
            $(nth).each(function(){
                if($(this).text().toUpperCase().indexOf(valor) < 0){
                    $(this).parent().hide();
                }
            });
        });

    
   

     $('.checkcampo').click(function() {
            current = $(this);
            if (current.is(':checked')) {
                var index = $(this).parent().index();
                var nth = "#relacionados td:nth-child("+(index+1)+") input";
                var valor = $(this).val().toUpperCase();
                $('.camporel').val("");
                 $("#relacionados tbody tr").show();
                $(nth).each(function(){
                    if(!$(this).is(':checked')){
                        $(this).parent().parent().hide();
                    }
                });
            } else {
                $("#relacionados tbody tr").show();
            }
        });
      });
    </script>


<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-upload fade">
        <td>
            <span class="preview"></span>
        </td>
        <td>
            <p class="name">{%=file.name%}</p>
            <strong class="error text-danger"></strong>
        </td>
        <td>
            <p class="size">Processing...</p>
            <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
        </td>
        <td>
            {% if (!i && !o.options.autoUpload) { %}
                <button class="btn btn-primary start" disabled>
                    <i class="glyphicon glyphicon-upload"></i>
                    <span>Start</span>
                </button>
            {% } %}
            {% if (!i) { %}
                <button class="btn btn-warning cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel</span>
                </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-download fade">
        <td>
            <span class="preview">
                {% if (file.thumbnailUrl) { %}
                    <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
                {% } %}
            </span>
        </td>
        <td>
            <p class="name">
                {% if (file.url) { %}
                    <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
                {% } else { %}
                    <span>{%=file.name%}</span>
                {% } %}
            </p>
            {% if (file.error) { %}
                <div><span class="label label-danger">Error</span> {%=file.error%}</div>
            {% } %}
        </td>
        <td>
            <span class="size">{%=o.formatFileSize(file.size)%}</span>
        </td>
        <td>
            {% if (file.deleteUrl) { %}
                <button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                    <i class="glyphicon glyphicon-trash"></i>
                    <span>Delete</span>
                </button>
                <input type="checkbox" name="delete" value="1" class="toggle">
            {% } else { %}
                <button class="btn btn-warning cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel</span>
                </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="js/vendor/jquery.ui.widget.js"></script>
<!-- The Templates plugin is included to render the upload/download listings -->
<script src="//blueimp.github.io/JavaScript-Templates/js/tmpl.min.js"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="//blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="//blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js"></script>
<!-- Bootstrap JS is not required, but included for the responsive demo navigation -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<!-- blueimp Gallery script -->
<script src="//blueimp.github.io/Gallery/js/jquery.blueimp-gallery.min.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="js/jquery.fileupload.js"></script>
<!-- The File Upload processing plugin -->
<script src="js/jquery.fileupload-process.js"></script>
<!-- The File Upload image preview & resize plugin -->
<script src="js/jquery.fileupload-image.js"></script>
<!-- The File Upload audio preview plugin -->
<script src="js/jquery.fileupload-audio.js"></script>
<!-- The File Upload video preview plugin -->
<script src="js/jquery.fileupload-video.js"></script>
<!-- The File Upload validation plugin -->
<script src="js/jquery.fileupload-validate.js"></script>
<!-- The File Upload user interface plugin -->
<script src="js/jquery.fileupload-ui.js"></script>
<!-- The main application script -->
<script src="js/main.js"></script>
<script src="js/jquery.custom.js"></script>
<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE 8 and IE 9 -->
<!--[if (gte IE 8)&(lt IE 10)]>
<script src="js/cors/jquery.xdr-transport.js"></script>
<![endif]-->

</body>
</html>