<?php


echo '<div class="container app-main app-form">' . "\r\n" . '   <div class="app-title mb-2">' . "\r\n" . '      <h1>✉️ Contato</h1>' . "\r\n" . '      <div class="app-title-desc">Tire suas dúvidas.</div>' . "\r\n" . '   </div>' . "\r\n" . '   <form id="form-contact">' . "\r\n" . '      <div class="app-card card mb-2">' . "\r\n" . '         <div class="card-body">' . "\r\n" . '            <div class="mb-2"><label class="form-label">Nome</label><input type="text" name="nome" id="nome"' . "\r\n" . '                  class="form-control text-black" required=""></div>' . "\r\n" . '            <div class="mb-2"><label class="form-label">Email</label><input type="email" maxlength="50"' . "\r\n" . '                  name="email" id="email" class="form-control text-black" required="" value=""></div>' . "\r\n" . '            <div class="mb-2"><label class="form-label">Telefone</label><input onkeyup="formatarTEL(this);" maxlength="15"' . "\r\n" . '                  name="telefone" id="telefone" class="form-control text-black" required="" value=""></div>' . "\r\n" . '            <div class="mb-2">' . "\r\n" . '               <label class="form-label">Campanha</label>' . "\r\n" . '               <select name="campanha" id="campanha" class="form-control text-black" required="">' . "\r\n" . '                  <option>Deseja falar sobre uma campanha?</option>' . "\r\n" . '                  ';
$qry = $conn->query('SELECT * from `product_list` order by id desc');

if (0 < $qry->num_rows) {
	while ($row = $qry->fetch_assoc()) {
		echo '                        <option value="';
		echo $row['name'];
		echo '">' . "\r\n" . '                           ';
		echo $row['name'];
		echo '                        </option>' . "\r\n" . '                     ';
	}

	echo '                  ';
}

echo '               </select>' . "\r\n" . '            </div>' . "\r\n" . '            <div class="mb-2">' . "\r\n" . '               <label class="form-label">Assunto</label>' . "\r\n" . '               <select name="assunto" id="assunto" class="form-control text-black" required="">' . "\r\n" . '                  <option>Outro(s)</option>' . "\r\n" . '                  <option>Problemas com cadastro</option>' . "\r\n" . '                  <option>Problemas com compras</option>' . "\r\n" . '                  <option>Quero ser parceiro</option>' . "\r\n" . '                  <option>Recuperar senha</option>' . "\r\n" . '               </select>' . "\r\n" . '            </div>' . "\r\n" . '            <div class="mb-2"><label class="form-label">Mensagem</label>' . "\r\n" . '               <textarea type="text" minlength="20" name="mensagem" id="mensagem" class="form-control mb-1 text-black" required=""' . "\r\n" . '                  rows="6"></textarea>' . "\r\n" . '               <small class="text-muted font-xss">mínimo de 20 caracteres</small>' . "\r\n" . '            </div>' . "\r\n" . '         </div>' . "\r\n" . '      </div>' . "\r\n" . '      <div class="text-end">' . "\r\n" . '         <button type="submit" class="btn btn-primary btn-wide">Enviar <i class="bi bi-arrow-right"></i></button>' . "\r\n" . '      </div>' . "\r\n" . '   </form>' . "\r\n" . '</div>' . "\r\n" . '<script>' . "\r\n" . '   $(document).ready(function () {' . "\r\n" . '      $(\'#form-contact\').submit(function (e) {' . "\r\n" . '         e.preventDefault();' . "\r\n\r\n" . '         $.ajax({' . "\r\n" . '            url: _base_url_ + "class/Main.php?action=contact_send_email",' . "\r\n" . '            method: \'POST\',' . "\r\n" . '            type: \'POST\',' . "\r\n" . '            data: new FormData($(this)[0]),' . "\r\n" . '            dataType: \'json\',' . "\r\n" . '            cache: false,' . "\r\n" . '            processData: false,' . "\r\n" . '            contentType: false,' . "\r\n" . '            error: err => {' . "\r\n" . '               console.log(err)' . "\r\n" . '               alert(\'An error occurred\')' . "\r\n\r\n" . '            },' . "\r\n" . '            success: function (resp) {' . "\r\n" . '               if (resp.status == \'success\') {' . "\r\n" . '                  alert(\'Email enviado com sucesso.\');' . "\r\n" . '                  location.href = (\'./\')' . "\r\n" . '               } else {' . "\r\n" . '                  alert(\'An error occurred\')' . "\r\n" . '                  console.log(resp)' . "\r\n" . '               }' . "\r\n" . '            }' . "\r\n" . '         })' . "\r\n" . '      })' . "\r\n" . '   })' . "\r\n\r\n" . '</script>';

?>