Guest User

Untitled

a guest
Apr 11th, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.65 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include_once("../PHP/conexao.php");
  4. $filtro = isset($_GET['filtro'])?$_GET['filtro']:"";
  5. $sql = "select * from clientes where nome like '%$filtro%' order by nome";
  6. $consulta = mysqli_query ($conexao, $sql);
  7. $registros = mysqli_num_rows($consulta);
  8.  
  9. ?>
  10. <!doctype html>
  11. <html lang="pt-br">
  12. <head>
  13. <meta charset="utf-8">
  14. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  15. <meta name="description" content="">
  16. <meta name="Pedro Henrique" content="">
  17. <!--
  18. Criado por Pedro Henrique
  19. +5563992852430
  20. pedrolivertwd@gmail.com
  21. -->
  22. <title>Procurar Cliente</title>
  23. <link rel="shortcut icon" href="../IMG/store.png" type="image/x-icon" />
  24.  
  25. <!-- Bootstrap core CSS -->
  26. <link href="../css/bootstrap.css" rel="stylesheet">
  27. <!-- Custom styles for this template -->
  28. <link href="../css/cover.css" rel="stylesheet">
  29. <link href="../css/style.css" rel="stylesheet">
  30. <link href="../css/all-animation.css" rel="stylesheet">
  31. <link href="../css/personalized-pro-cli.css" rel="stylesheet">
  32.  
  33. </head>
  34. <body style="height: auto">
  35. <div style="margin-bottom: 360px" class="div-form flip-top"><br>
  36. <div class="form-group">
  37. <form method="get">
  38. <main role="main" class="inner cover">
  39. Pesquisar Cliente: <input type="text" name="filtro" class="form-control inp" autofocus>
  40.  
  41. <input type="submit" name="pesq" value="Pesquisar" class="btn-s bt btn btn-outline-success">
  42. <input onclick="window.location='procurar-cliente.php'" type="reset" value="Limpar" class="btn-s btn btn-outline-danger">
  43. </main><br>
  44. <a onmouseover="myFunction()" href="index.php"><img class="voltar" src="../IMG/icon-voltar.png"></a>
  45. <a onmouseover="myFunction2()" href="cadastrar-cliente.php"><img class="cadastro" src="../IMG/icons-form.png"></a>
  46. <br><br>
  47. <?php
  48.  
  49. if(isset($_SESSION['msgD'])){
  50. echo $_SESSION['msgD'];
  51. unset($_SESSION['msgD']);
  52. }
  53.  
  54. if(isset($_SESSION['msgE'])){
  55. echo $_SESSION['msgE'];
  56. unset($_SESSION['msgE']);
  57. }
  58. ?>
  59. <script src="../js/bootstrap.js"></script>
  60. <script src="../js/jquery-3.1.1.min.js"></script>
  61. </form>
  62.  
  63. <div id="snackbar">Voltar Para Página Inicial</div>
  64. <div id="snackbar1">Página de Cadastro</div>
  65. <script>
  66. function myFunction() {
  67. var x = document.getElementById("snackbar");
  68. x.className = "show";
  69. setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
  70. }
  71. function myFunction2() {
  72. var y = document.getElementById("snackbar1");
  73. y.className = "show";
  74. setTimeout(function(){ y.className = y.className.replace("show", ""); }, 3000);
  75. }
  76.  
  77. </script>
  78.  
  79. <?php
  80. if ($filtro > NULL){
  81. print "Resultado da pesquisa com a palavra <strong>$filtro.</strong> <br><br>";}
  82. if ($registros > 0){
  83. echo "<br>";
  84. echo "$registros clientes encontrados.";}
  85. else { print "Não foram encontrados dados de clientes.";}
  86. print"<br><br>";
  87. while($exibirRegistros = mysqli_fetch_array($consulta)){
  88. $codigo = $exibirRegistros[0];
  89. $nome = $exibirRegistros[1];
  90. $cpf = $exibirRegistros[2];
  91. $telefone = $exibirRegistros[3];
  92. $endereco = $exibirRegistros[4];
  93. $cidade = $exibirRegistros[5];
  94. $data_da_compra = $exibirRegistros[6];
  95. $valor_da_compra = $exibirRegistros[7];
  96. $parcelamento = $exibirRegistros[8];
  97. $data_de_vencimento = $exibirRegistros[9];
  98.  
  99. echo '<div class="pd-left">';
  100. echo '<ul class="all-animation double-acordeon">';
  101. echo '<li>';
  102. echo "<input type='checkbox' name='_double_acordeon[]' id='double-acordeon$codigo'>";
  103. echo "<label for=double-acordeon$codigo><strong>Cliente:</strong> $nome";
  104. echo '<div>';
  105. echo "<article>";
  106. echo"<strong>ID:</strong> $codigo <br>";
  107. print"<strong>Nome:</strong> $nome <br>";
  108. print"<strong>CPF:</strong> $cpf <br>";
  109. print"<strong>Telefone:</strong> $telefone <br> ";
  110. print"<strong>Endereço:</strong> $endereco <br> ";
  111. print"<strong>Cidade:</strong> $cidade <br> ";
  112. print"<strong>Data da Compra:</strong> $data_da_compra <br> ";
  113. print"<strong>Valor da Compra:</strong> $valor_da_compra <br> ";
  114. print"<strong>Parcelamento:</strong> $parcelamento <br> ";
  115. print"<strong>Data de Vencimento:</strong> $data_de_vencimento <br> ";
  116.  
  117. echo"<br>";
  118. echo "<a class='btn btn-outline-danger ' style='padding-top:15px;' data-toggle='modal' data-target='#apagarMODAL'>Excluir</a>";
  119.  
  120.  
  121.  
  122.  
  123. // echo "<a class='btn btn-outline-danger ' style='padding-top:15px;' href='../PHP/deletar.php?codigo={$exibirRegistros['codigo']}'>Excluir</a>";
  124. echo "<a style='color:transparente: cursor:pointer'>-</a>";
  125. echo "<a class='btn btn-outline-primary ' style='padding-top:15px;' href='editar.php?codigo={$exibirRegistros['codigo']}'>Editar</a>";
  126.  
  127. echo "<br><br>";
  128. echo "</article>";
  129. echo '</div>';
  130. echo ' </label>';
  131. echo ' </li>';
  132. echo '</ul>';
  133. echo '</div>';
  134. }
  135. ?>
  136.  
  137.  
  138.  
  139. <!-- Modal APAGAR -->
  140. <div class="modal fade" id="apagarMODAL" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  141. <div class="modal-dialog modal-dialog-centered" role="document">
  142. <div class="modal-content">
  143. <div class="modal-header">
  144. <h5 class="modal-title text-cor" id="exampleModalLongTitle">Deseja Apagar?</h5>
  145. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  146. <span aria-hidden="true">&times;</span>
  147. </button>
  148. </div>
  149.  
  150. <div class="modal-footer">
  151. <button type="button" class="btn btn-outline-danger" data-dismiss="modal">Não</button>
  152.  
  153. <?php
  154. include_once("../PHP/conexao.php");
  155. $sql = "select * from clientes";/*faz mostrar todos no bd*/
  156. $consulta = mysqli_query ($conexao, $sql);
  157. $registros = mysqli_num_rows($consulta);
  158. $exibirRegistros = mysqli_fetch_array($consulta);
  159. $codigo = $exibirRegistros[0];
  160.  
  161. echo "<a href='../PHP/deletar.php?codigo={$exibirRegistros['codigo']}' class='btn btn-outline-success ' style='padding-top:15px;'>Sim</a>";
  162.  
  163.  
  164. ?>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169.  
  170. </div>
  171. </div>
  172. <!-- Importante -->
  173. <script src="../js/jquery-3.1.1.min.js"></script>
  174. <script src="../js/bootstrap.js"></script>
  175.  
  176. </body>
  177. </html>
  178.  
  179. <?php
  180. session_start();
  181. //include_once("conexao.php");
  182. $hostname = "localhost";
  183. $user = "root";
  184. $password = "";
  185. $database = "db_keima_keima";
  186. $dbc = mysqli_connect($hostname, $user, $password, $database)or die('não foi possivel acessar Banco de Dados');
  187. $codigo = $_GET['codigo'];
  188. $sql = "DELETE FROM clientes WHERE codigo=$codigo";
  189. $apagar = mysqli_query ($dbc, $sql)or die('não foi possivel acessar Banco de Dados');
  190. //header("Location: ../view/procurar-cliente.php");
  191.  
  192. if ($apagar == true){
  193. if ($total = mysqli_affected_rows($dbc)){
  194. //echo 'excluído: '.$total;
  195. $_SESSION['msgD'] = "<div class='alert alert-success'> Cliente Removido Com Sucesso!
  196. <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>";
  197. header("Location: ../view/procurar-cliente.php");
  198.  
  199. }
  200. else {
  201. // echo 'Nenhum registro excluído';
  202. $_SESSION['msgD'] = "<div class='alert alert-danger'> Erro ao Apagar o Cliente! :(
  203. <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>";
  204. header("Location: ../view/procurar-cliente.php");
  205. }}
Add Comment
Please, Sign In to add comment