sexta-feira, 10 de julho de 2020

DropZone.js - com varias arrays no form e com multiplos uploads - with Form Arrays and Multiple Uploads


<script src="js/dropzone.js"></script>
<link rel="stylesheet" href="css/dropzone.css">

<script>
Dropzone.options.myDropzone=
{
    url: "SUAPAGINA",
    paramName: "arquivo",
    autoProcessQueue: false,
    uploadMultiple: true,
    parallelUploads: 5,
    maxFiles: 5,
    maxFilesize: 3,
    acceptedFiles: 'image/*,application/pdf',
    dictDefaultMessage: 'Arraste os arquivos para cá ou clique aqui',
    dictFileTooBig: 'A imagem não pode ser maior que 3 MBs',
    dictInvalidFileType: 'Apenas arquivos com terminação pdf, png, jpg e gif são aceitos',
    dictCancelUpload: 'Cancelar o UPLOAD',
    dictRemoveFile: '&#10006; Remover',
    dictCancelUploadConfirmation: 'Tem certeza que quer cancelaro UPLOAD?',
    dictMaxFilesExceeded: 'Você pode subir apenas 5 arquivos por vez',
    addRemoveLinks: true,
    init: function()
    {
        dzClosure = this; // Makes sure that 'this' is understood inside the functions below.
        // for Dropzone to process the queue (instead of default form behavior):
       
  // Necessaria função abaixo pois o Dropzone não esta parando em Erros como MaxFileSize e Accepeted File...
   this.on("error", function(file, message, xhr) {
        if (xhr == null) this.removeFile(file); // could choose to not remove file(s) on xhr error
        //alert(message);
        document.getElementById('erro').innerHTML="<p id='cpoErro'>"+message+"</p>";
        exit();
   });   
       
        document.getElementById("submit-all").addEventListener("click", function(e)
        {
            // Make sure that the form isn't actually being sent.
            e.preventDefault();
            e.stopPropagation();
            if (document.getElementById("obra").value=='') document.getElementById('erro').innerHTML="<p id='cpoErro'>Obra é Obrigatório</p>";
            else if (document.getElementById("inputString").value=='') document.getElementById('erro').innerHTML="<p id='cpoErro'>Fornecedores é Obrigatório</p>";
            else if (document.getElementById("inputString_Desc").value=='') document.getElementById('erro').innerHTML="<p id='cpoErro'>Descrição é Obrigatório</p>";
            else {
    if (dzClosure.files.length) dzClosure.processQueue();
    else $('#FormEnvia').submit();
   }
        });
        //send all the form data along with the files:
        this.on("sending", function(file, xhr, formData)
        {
   $('.pagamento').each(function(){
                formData.append("pagamento[]", $(this).val());
            });
            $('.valor').each(function(){
                formData.append("valor[]", $(this).val());
            });
            $('.status').each(function(){
                formData.append("status[]", $(this).val());
            });
            formData.append("total_pagtos", $("#total_pagtos").val());
   formData.append("id_obra", $("#obra").val());
            formData.append("descricao", $("#inputString_Desc").val());
            formData.append("fornecedores", $("#inputString").val());
            formData.append("obs", $("#obs").val());
        });
       
        this.on('success', function( file, resp ){
   document.getElementById('form-sucesso').innerHTML=resp;
  });
 
  this.on("error", function (file, message) {
          document.getElementById('form-sucesso').innerHTML=$(file.previewElement).addClass("dz-error").find('.dz-error-message').text(message.Message);
      });
         }
}
</script>
 <!--========================================================
                            CONTENT
  =========================================================-->
<form method='POST' action='SUAPAGINA' id='FormEnvia' enctype='multipart/form-data'>
 <p id='chamada'>PAGAMENTO</p>
 <div style='text-align:left;padding:12px 0 0 5%;'>
  <table>
   <tr>
    <td>Vencimento</td><td>Valor</td><td>Pago?</td>
   </tr>
   <tr>
    <td><input type='text' name='pagamento[]' placeholder='dd/mm/aaaa' required onkeyup='formataData(this)' maxlength='10' class='pagamento'>
    <td><input type='text' name='valor[]' placeholder='0.00' required class='valor'></td>
    <td><select name='status[]' class='status'><option value='A'>NÃO</option><option value='P'>SIM</option></select></td>
   </tr>
  </table>
 </div>
 <p></p>
 <div id='newRow'></div>
        <button id='addRow' type='button' class='btn btn-info'  onclick="document.getElementById('total_pagtos').value= parseInt(document.getElementById('total_pagtos').value)+1"> [+] Pagamentos</button>
   
    <p></p>
   
    <p id='chamada'>NOTAS FISCAIS</p>
    <p></p>
    <div class='dropzone' id='myDropzone' style='border: 1px solid #808080;border-radius: 4px; box-sizing: border-box;margin-bottom:15px;'>
  <div class='fallback'>
   <input type='file' name='arquivo' multiple>
  </div>
 </div>
   
  <div  style='width:100%;text-align:center;'>
   <input type='hidden' name='foi' value='2' />
   <input type='hidden' name='total_pagtos' id='total_pagtos' value='1' />
   <button type='submit' class='btn2' id='submit-all'>REGISTRAR</button>
   </div>
   <p></p>
  <div id='erro'></div>
</form>
  <script>
 // add row
    $("#addRow").click(function () {
        var html = '';
        html += '<div id="inputFormRow" style="border: 1px solid #808080;border-radius: 4px; box-sizing: border-box;margin-bottom:15px">';
        html += '<div style="text-align:right;">';
        html += '<button id="removeRow" type="button" class="btn btn-danger" onclick="document.getElementById(\'total_pagtos\').value=parseInt(document.getElementById(\'total_pagtos\').value)-1">&#10006;</button>';
        html += '</div>';
        html += '<table><tr><td>Vencimento</td><td>Valor</td><td>Pago?</td></tr>';
        html += '<tr>';
        html += '<td><input type="text" name="pagamento[]" class="pagamento" placeholder="dd/mm/aaaa" autocomplete="off" onkeyup="formataData(this)"  maxlength="10"></td>';
        html += '<td><input type="text" name="valor[]" class="valor" placeholder="0.00" autocomplete="off"></td>';
        html += '<td><select name="status[]" class="status"><option value="A">NÃO</option><option value="P">SIM</option></select></td>';
        html += '</tr>';
        html += '</table><p></p>';
        html += '</div>';

        $('#newRow').append(html);
    });

    // remove row
    $(document).on('click', '#removeRow', function () {
        $(this).closest('#inputFormRow').remove();
    });
 </script>

  

segunda-feira, 14 de outubro de 2019

JavaScript : Sort Table Asc and Desc - Listar dados Asc e Desc

<table id="customers">
    <thead>
    <tr>
        <th >
        </th>
        <th>
        Empresa
       </th>
        <th >
        POL / POD
        </th>     
<th>
        Data<br/>
        Embarque<br/><a onclick="sortByDateDesc()" style="font-size:25px;">&#10563;</a> <a onclick="sortByDate()" style="font-size:25px;">&#10564;</a>
        </th>
        <th >
        Viagem
        </th>
    </tr>
    </thead>
<tbody>
        <tr>
            <td>P1</td>
            <td align=center>LA WEB</td>
            <td align=center>IGI / MAO</td>
            <td align=center>25/12/2019</td>
            <td align=center>BLKR121212</td>
        </tr>
     
        <tr>
            <td>P2</td>
            <td align=center>WEB LA</td>
            <td align=center>MAO / RIG</td>
            <td align=center>01/02/2019</td>
            <td align=center>BLKR121212</td>
        </tr>
     
        <tr>
            <td>P3</td>
            <td align=center>WEBBER MA</td>
            <td align=center>MVD / BUE</td>
            <td align=center>25/10/2019</td>
            <td align=center>BLKR121212</td>
        </tr>
     
        <tr>
            <td>P4</td>
            <td align=center>LAS WEBS</td>
            <td align=center>STS / USH</td>
            <td align=center>30/05/2020</td>
            <td align=center>BLKR121212</td>
        </tr>

</tbody>
</table>
<script>
            function convertDate(d) {
              var p = d.split("/");
              return +(p[2]+p[1]+p[0]);
            }

            function sortByDate() {
              table = document.getElementById("customers");
              //var tbody = document.querySelector("#results tbody");
              // get trs as array for ease of use
              var rows = [].slice.call(table.querySelectorAll("tr"));
             
              rows.sort(function(a,b) {
                return convertDate(a.cells[4].innerHTML) - convertDate(b.cells[4].innerHTML);
              });
             
              rows.forEach(function(v) {
                table.appendChild(v); // note that .appendChild() *moves* elements
              });
            }
            function sortByDateDesc() {
              table = document.getElementById("customers");
              //var tbody = document.querySelector("#results tbody");
              // get trs as array for ease of use
              var rows = [].slice.call(table.querySelectorAll("tr"));
             
              rows.sort(function(a,b) {
                return convertDate(b.cells[4].innerHTML) - convertDate(a.cells[4].innerHTML);
              });
             
              rows.forEach(function(v) {
                table.appendChild(v); // note that .appendChild() *moves* elements
              });
            }
</script>

Obs / PS -> Original code by https://stackoverflow.com/users/615754/nnnnnn

quinta-feira, 19 de setembro de 2019

Check - Uncheck input check box thru image click - Marcar - Desmarcar um botao checkbox clicando na imagem


<?php
for ($x=1;$x<=20;$x++)
        {
           echo "
            <div class='sombra'>
                <a  onclick='if (document.getElementById(\"c$x\").checked == false) document.getElementById(\"c$x\").checked = true; else document.getElementById(\"c$x\").checked = false' style='cursor: pointer;'><img src='images/quizz/min/SUAIMAGEM.jpg'  /></a><br/>
                <input type='checkbox' name='q2[]' value='$var_vai' id='c$x' />  <br/>
                TEXTO
            </div>";
        }
?>

quinta-feira, 4 de julho de 2019

DropZone.js validate and multiple form data - Validar campos com DropZone e envio de variaveis

JQuery - JavaScript and HTML at same page :: send.html

<script>
Dropzone.options.myDropzone=
{
    url: "upload.php",
    paramName: "arquivo", // same name that you use at upload.php
    autoProcessQueue: false,
    uploadMultiple: false,
    parallelUploads: 5,
    maxFiles: 5,
    maxFilesize: 10,
    acceptedFiles: 'image/*',
    addRemoveLinks: true,
    init: function()
    {
        dzClosure = this; // Makes sure that 'this' is understood inside the functions below.

        // for Dropzone to process the queue (instead of default form behavior):
        document.getElementById("submit-all").addEventListener("click", function(e)
        {
            // Make sure that the form isn't actually being sent.
            e.preventDefault();
            e.stopPropagation();
            if (document.getElementById("ambiance").value=='') document.getElementById('resp1').innerHTML="<font color=red size=1 face='Verdana'> &#8673; Champ obligatoire!</font>";
            else dzClosure.processQueue();
        });

        //send all the form data along with the files:
        this.on("sending", function(file, xhr, formData)
        {
            formData.append("quem", $("#quem").val());
            formData.append("id_cliente_poder", $("#id_cliente_poder").val());
        });
      
        this.on('success', function( file, resp ){
            document.getElementById('form-sucesso').innerHTML="<div style='width:100%;height:100%;border-radius: 15px;background-color:rgba(0, 0, 0, 0.01);color:#000000;font-size:18px;text-align:center;'>&#x263a; Archive téléchargé avec succès!</div>";
        });
      
      
    }
}</script>

<div id='form-sucesso' style="border-radius: 15px;">
                <form method="post" action="upload.php" enctype="multipart/form-data" data-form-output="form-output-global" data-form-type="forms">
                <br/>
                        <input type='hidden' name='quem' id='quem' value='i' />
                        <input type='hidden' name='id_cliente_poder' id='id_cliente_poder' value='5' />
                       
                        <div class="cell-sm-10">
                          <div class="form-wrap form-wrap-validation">
                            <label class="form-label" for="ambiance">Ambiance Name</label>
                            <input class="form-input" type="text" id ="ambiance" name="ambiance"  onkeypress="document.getElementById('resp1').innerHTML=''" required  /> <span id="resp1"></span>
                          </div>
                        </div><br/>
                        <div class="dropzone" id="myDropzone">
                        <div class="fallback">
                        <input class="form-input-file" id="form-input-file" type="file" name="arquivo" multiple required />
                        </div>
                        </div>
                        <div class="form-button">
                        <font size='1'>
                            &#8674; Tous les champs sont obligatoires.
                            <br/>
                            &#8674; Le fichier doit avoir un maximum de 10 Mbs
                            <br/>
                            &#8674; Les formats de fichier suivants sont pris en charge: png, jpg, gif et pdf
                        </font><br/>
                    <button class="button button-primary" type="submit" id="submit-all"><span>Envoyer</span></button>
                  </div>
                </form>
                </div>

PHP :: upload.php

<?php

$normalizeChars = array(
    'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A',
    'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I',
    'Ï'=>'I', 'Ñ'=>'N', 'Ń'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U',
    'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a',
    'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i',
    'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ń'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u',
    'ú'=>'u', 'û'=>'u', 'ü'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y', 'ƒ'=>'f',
    'ă'=>'a', 'î'=>'i', 'â'=>'a', 'ș'=>'s', 'ț'=>'t', 'Ă'=>'A', 'Î'=>'I', 'Â'=>'A', 'Ș'=>'S', 'Ț'=>'T',
    '’'=>'', ' '=>'-', "'"=>"", '"'=>'', 'ª'=>'a', 'º'=>'o', '°'=>'o', '/'=>'', '«'=>'', '»'=>'', ','=>'',
    'ê'=>'e', 'à'=>'a', 'é'=>'e', 'ô'=>'o', 'è'=>'e', 'à'=>'a', 'Ê'=>'E', 'À'=>'A', 'É'=>'E', 'O'=>'O', 'E'=>'E', 'A'=>'A',
    'ã'=>'a',
);

$arquivo='';
   
if (isset($_FILES['arquivo']['tmp_name'])) $arquivo = $_FILES['arquivo']['tmp_name'];
if (!empty($arquivo))
{
    $err=0;
    $arquivo_name = strtr($_FILES['arquivo']['name'], $normalizeChars);
    $arquivo_size = $_FILES['arquivo']['size'];
    $arquivo_type = $_FILES['arquivo']['type'];
   
    if ($arquivo_size > 10240000)
    {
        $alert= "<font color=red>Votre archive ne peut pas dépasser 10 MBs</font>";
        $err++;
    }
   
    if ($err==0)
    {
        $id_cliente='';
        if ($_SESSION['poder']==1)
        {
            $id_cliente=$_POST['id_cliente_poder'];
            $quem_vai='3dplan';
        }
        else
        {
            $id_cliente=$_POST['id_cliente_poder'];
            if ($_POST['quem']=='c') $quem_vai='cotation';
            else $quem_vai='envoye';
        }
      
        $caminho="yourfoldergoeshere/$id_cliente/$quem_vai";
        if (!file_exists($caminho))
        {
            if (!mkdir($caminho, 0755, true))
            {
                $error = error_get_last();
                echo $error['message'];
            }
        }
      
        $caminho=$caminho.'/'.$arquivo_name;

        /* Defina aqui o tipo de arquivo suportado */
        $ext = pathinfo($arquivo_name, PATHINFO_EXTENSION);
        $allowed =  array('xlsx', 'xls', 'doc', 'docx', 'pdf', 'png', 'jpg', 'gif', 'jpeg', 'ai', 'cdr', 'zip', 'rar', 'gzip', 'XLSX', 'XLS', 'DOC', 'DOCX', 'PDF', 'PNG', 'JPG', 'GIF', 'JPEG', 'AI', 'CDR', 'ZIP', 'RAR', 'GZIP');
        if (in_array($ext,$allowed))
        {
            move_uploaded_file($arquivo,$caminho);
            $alert = "&#x263a; Archive téléchargé avec succès! <br/>";
        }
        else $alert= "<font color=red>Extension de archive invalide</font><br/>";
    }
}
else $alert= "S'il vous plaît poster un archive";
echo "<br/><br/>".$alert."<br/><br/><br/><br/>";
?>

segunda-feira, 19 de junho de 2017

MySQL check valid e-mail - checagem de email validos na base

Segue REGEX bem simples:

SELECT `email` 
 FROM  `clients`  
WHERE `email` NOT REGEXP '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';
 
 

quarta-feira, 10 de maio de 2017

Form checkbox array PHP and MySQL - Multiple Values - Passa multiplos valores em um form

<?php
// SIMPLES
$go='';
if (isset($_POST['go'])   $go=$_POST['go'];
if (!$go)
{
?>
<form method='post' action='".$_SERVER['PHP_SELF']."'>
<table>
<tr>
                <td><input type='checkbox' name='apagar[]' value='1' /></td>
                <td><input type='checkbox' name='apagar[]' value='2' /></td>
                <td><input type='checkbox' name='apagar[]' value='3' /></td>
                <td><input type='checkbox' name='apagar[]' value='4' /></td>
</tr>
<tr>
                <td colspan=4 align='center'>
                <input type='hidden' name='go' value='S' />
                <input type='submit' name='apagando' value='Apagar Selecionados' />
                </td>
</table>
</form>
<?php
exit;
}
else
{
 $i=0;
    if (isset($_POST['apagando']))
    {
       $apagar = $_POST['apagar'];
       foreach ($apagar as $del=>$value)
       {
            $sql=mysql_query("delete from SUA_TABELA_SQL where id='$value'");
            if ($sql) $i++;
       }
       if ($i>0)
       {
           echo "sucesso";
       }
      else
       {
           echo "nada foi feito";
       }
    }
exit;
}
// PASSAR MULTIPLOS VALORES

echo "
<form data-form-output='orm-output-global' data-form-type='forms' method='post' action='".$_SERVER['PHP_SELF']."'>
    <div>
        <div>
            <label for='forms-mensagem'>Réponse</label><textarea  id='forms-mensagem' name='resposta[][346][]'></textarea>
        </div>
        <div>
            <label for='forms-mensagem'>Réponse</label><textarea  id='forms-mensagem' name='resposta[][374][]'></textarea>
        </div>
        <div>
            <input type='submit' name='Enviar' value='Enviar' />
        </div>
    </div>
</form>";
echo '</div></form>';

if (!empty($_POST['Enviar']))
{
   
    if (!empty($_POST['resposta'])) $resposta = $_POST['resposta'];
    foreach ($resposta as $resp=>$value)
    {
        $resposta2 = $_POST['resposta'][$resp];
        foreach ($resposta2 as $resp2=>$value2)
        {
            //echo "$resp2<br/>";
        }
        $resposta3 = $_POST['resposta'][$resp][$resp2];
        foreach ($resposta3 as $resp3=>$value3)
        {
            //echo "$value3<br/>";
        }
      
        echo "$resp2-->$value3<br/>";
    }
   
   
}



?>

JavaScript Onchange return old value - onchange retornar valor antigo

Meu problema é:

Tenho x numero de Containers e y numero de Pedidos.

Pedidos não pode ser maior que Containers então tenho:

OBS: IE não suporta Number.parseInt() por isso usei apenas parseInt().

<script language="Javascript" type="text/javascript">
function validar_totais(pedido, container)
{
    if (parseInt(pedido)<=parseInt(container))
    {
    //faça algo legal aqui
    var my_condition = true;
    }
    else
    {
        alert ("Quantidade de Pedidos não pode ser maior que a Quantidade de Contêineres.");
        var my_condition = false;
    }
       
        var lastSel = $("#qtd_geral_pedido option:selected");
        $("#qtd_geral_pedido").change(function(){
          if(my_condition)
          {
            lastSel.prop("selected", true);
          }
        });

        $("#qtd_geral_pedido").click(function(){
            lastSel = $("#qtd_geral_pedido option:selected");
        });
}
</script>
<?php
echo "
Containers:
           <select name='quantidade' id='quantidade'>
               <option value='0'>---</option> ";
            for ($i=1;$i<=200;$i++)
               {
                      echo "<option value='$i'>$i</option>\n";
                }
echo "
            </select>
Pedidos:
            <select name='qtd_geral_pedido' id='qtd_geral_pedido'  onchange='validar_totais(document.procurado.qtd_geral_pedido.value, document.procurado.quantidade.value);'>
                   <option value='0'>--</option>";
            for ($i=1;$i<=200;$i++)
               {
                      echo "<option value='$i'>$i</option>\n";
                }
                        echo "
             </select>
        ";
?>


terça-feira, 21 de março de 2017

PHP trocar ENTER - ch(10) ou ch(13) por <br> | change enter tab to <br>


O problema aqui era o envio da nota por e-mail, com str_replace dava alguns paus e como eu uso um disparo de notas vindas de um banco de dados passei a usar a linha abaixo e funcionou perfeitamente.

The problem here was sent an e-mail, I tried str_replace but sometimes it just crash the configuration.

$nota="Especializados em fornecer end-to-end soluções complexas e softwares, a nossa empresa é considerada um parceiro fundamental para todas as empresas e organizações que trabalharam conosco.

Com profissionais qualificados e com vasto conhecimento em desenvolvimento e consultoria. Nossa equipe é composta de Arquitetos de Software, Desenvolvedores de Software, Administradores de Dados, Administradores de Sistema, Web Designers e Gerentes de Projeto. ";

$output = nl2br($nota);


quarta-feira, 14 de dezembro de 2016

Regex against Google Analytics Spam Bots - Regex para tentar frear Spam no Google Analytics


Lembrar de Clicar no ADMINISTRADOR -> Vista de Propriedade -> Visualizar Configurações ->

Filtragem de bots
Excluir todos os hits de bots e indexadores conhecidos

Depois entre em Relatórios -> E crie um Novo Segmento ->

clique em + Adicionar Segmento
clique em + Novo Segmento
Escolha Avançado -> Condições -> Em "Ações do Evento" escolha Titulo da Página e em "Contém" escolha "corresponde à Regex" no meu caso todos os abaixo estavam entrando no seu vc precisa verificar e colar apenas uma parte do nome deles no regex abaixo.

Cada | (pipe) é um Spammer.

\W*((?i)sharebutton|xyz|reddit|lifehacĸer|Secret|motherboard|ilovevitaly|thenextweb(?-i))\W*

Lembrando que não é uma solução definitiva, o correto seria o Google apagá-los automaticamente...

Então de tempos em tempos seu regex vai aumentar, pois vc terá que ficar inserindo os nomes dos novos spammers.

Remember to click the ADMINISTRATOR -> View Property -> View Settings ->

Bottling bots
Delete all hits from known bots and crawlers

Then go to Reports -> And create a new Segment ->

Click + Add Segment
Click + New Segment
Choose Advanced -> Conditions -> In "Event Actions" choose Page Title and in "Contains" choose "corresponds to Regex" in my case all below were entering your you need to check and paste only a part of their name in the Regex below.

Each | (Pipe) is a Spammer.

\W*((?i)sharebutton|xyz|reddit|lifehacĸer|Secret|motherboard|ilovevitaly|thenextweb(?-i))\W*

Remembering that it is not a definitive solution, the correct one would be Google to automatically delete them ...

Then from time to time your regex will increase, because you will have to be entering the names of the new spammers.


quinta-feira, 2 de junho de 2016

HTML 5 - POP UP



<!DOCTYPE html>
<head>
    <title>Creating a modal window with HTML5 &amp; CSS3</title>
   
    <style>
     #openModal {
    position:relative;
    z-index:1;
   
    }
    #popup
{
    position:absolute;
    z-index:2;
    left:300px;
    top:35px;
    display:none;
    width:500px;
   
        padding: 5px 20px 13px 20px;
        border-radius: 10px;
        background: -moz-linear-gradient(#fff, #999);
        background: -webkit-linear-gradient(#fff, #999);
        background: -o-linear-gradient(#fff, #999);
}


    .close {
        background: #606061;
        color: #FFFFFF;
        line-height: 25px;
        position: absolute;
        right: -12px;
        text-align: center;
        top: -10px;
        width: 24px;
        text-decoration: none;
        font-weight: bold;
        -webkit-border-radius: 12px;
        -moz-border-radius: 12px;
        border-radius: 12px;
        -moz-box-shadow: 1px 1px 3px #000;
        -webkit-box-shadow: 1px 1px 3px #000;
        box-shadow: 1px 1px 3px #000;
    }

    .close:hover { background: #00d9ff; }
  
    </style>
   
</head>

<body>

<div id="popup">
        <div>
        <a href="#close" onclick="hide('closer'); hide('popup')" id="closer" title="Close" class="close">X</a>
        <h2>Modal Box</h2>
        <p>This is a sample modal box that can be created using the powers of CSS3.</p>
        <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
    </div>
</div>   

<div id="openModal" class="modalDialog">
   
        <h2>TESTE</h2>
        <p>POP UP CSS3.</p>
        <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>

</div>


<script>
    document.getElementById('popup').style.display = 'block';
   
    function hide(id)
    {
    document.getElementById(id).style.display = "none";
    }
   
    </script>
</body>
</html>

MySQL How to fill a Google Drive Spread Sheet - Como preencher o Planilhas do Google Drive



 // This app is made in JDBC

// Replace the variables in this block with real values.
var address = 'localhost:3306';
var user = 'USER';
var userPwd = 'PWD';
var db = 'DATABASE';

var dbUrl = 'jdbc:mysql://' + address + '/' + db;

//Gets and Sets the Current Spreadsheet as Active
var doc = SpreadsheetApp.getActiveSpreadsheet();
doc.setActiveSheet(doc.getSheetByName('Sheet1')); // nome da sheet
//No meu caso tenho a nome da coluna na linha 1: [E-mail] na coluna A1 e [Contato] na coluna B1
var lastRow = doc.getLastRow();
var lastRow_plus = lastRow + 1; // pula uma linha
var cell = doc.getRange('A'+lastRow_plus); // acha a ultima linha preenchida da coluna A

// Read up to 1000 rows of data from the table and log them.
function readFromTable() {
  var conn = Jdbc.getConnection(dbUrl, user, userPwd);

  var start = new Date();
 
  var stmt = conn.createStatement();
  stmt.setMaxRows(1000);
  var results = stmt.executeQuery('SELECT DISTINCT email, contato FROM `SUA-TABELA` WHERE status_envio=0 order by email');
  var numCols = results.getMetaData().getColumnCount();
  var row = 0;
  while (results.next()) {
    var rowString = '';
    for (var col = 0; col < numCols; col++) {
      cell.offset(row, col).setValue(results.getString(col+1));
    }
    row++;
    Logger.log(rowString);
  }
  var stmt1 = conn.prepareStatement('update SUA-TABELA set status_envio=1');
  stmt1.addBatch();
  var batch = stmt1.executeBatch();
 
  results.close();
  stmt.close();

  var end = new Date();
  Logger.log('Time elapsed: %sms', end - start);
}


Linux bash file returns unexpected token `$'do\r''

open file in vi edit with   vi filename.sh   command; type in vi  :set ff=unix  command; save file with  :wq It will save the file with unix...