Guest User

Untitled

a guest
Feb 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. <?php
  2.  
  3. static public function getPedidosPorPeriodo($data1, $data2) {
  4. try {
  5. $sql = "SELECT * FROM cpedido where ped_status != 'PEDIDO RECUSADO' and ped_dataHora between ? and ?";
  6. $statement_sql = Conexao::getConnection()->prepare($sql);
  7. $statement_sql->bindValue(1, $data1);
  8. $statement_sql->bindValue(2, $data2);
  9. $statement_sql->execute();
  10. return $statement_sql->fetchAll(PDO::FETCH_ASSOC);
  11. } catch (PDOException $exc) {
  12. echo $exc->getMessage();
  13. }
  14. }
  15.  
  16. static public function getPedidosPorCliente($cli_codigo) {
  17. try {
  18. $sql = "SELECT * FROM cpedido where ped_status != 'PEDIDO RECUSADO' and cli_codigo = ?";
  19. $statement_sql = Conexao::getConnection()->prepare($sql);
  20. $statement_sql->bindValue(1, $cli_codigo);
  21. $statement_sql->execute();
  22. return $statement_sql->fetchAll(PDO::FETCH_ASSOC);
  23. } catch (PDOException $exc) {
  24. echo $exc->getMessage();
  25. }
  26. }
  27.  
  28. static public function getStatusPedido($ped_chave) {
  29. try {
  30. $sql = "select ped_status from cpedido where ped_chave = ?";
  31. $statement_sql = Conexao::getConnection()->prepare($sql);
  32. $statement_sql->bindValue(1, $ped_chave);
  33. $statement_sql->execute();
  34. return $statement_sql->fetch(PDO::FETCH_ASSOC);
  35. } catch (PDOException $exc) {
  36. echo $exc->getMessage();
  37. }
  38. }
  39.  
  40. static public function getCPedido($ped_chave) {
  41. try {
  42. $sql = "select * from cpedido where ped_chave = ?";
  43. $statement_sql = Conexao::getConnection()->prepare($sql);
  44. $statement_sql->bindValue(1, $ped_chave);
  45. $statement_sql->execute();
  46. return $statement_sql->fetch(PDO::FETCH_ASSOC);
  47. } catch (PDOException $exc) {
  48. echo $exc->getMessage();
  49. }
  50. }
  51.  
  52. static public function getAllPedidos($status) {
  53. try {
  54. $sql = "select * from cpedido where ped_status = ? AND DATE_FORMAT(ped_dataHora, '%Y-%m-%d') = CURDATE() ";
  55. $statement_sql = Conexao::getConnection()->prepare($sql);
  56. $statement_sql->bindValue(1, $status);
  57. $statement_sql->execute();
  58. return $statement_sql->fetchAll(PDO::FETCH_ASSOC);
  59. } catch (PDOException $exc) {
  60. echo $exc->getMessage();
  61. }
  62. }
  63.  
  64. static public function getItemPedido($pedchave, $prdcodigo) {
  65. try {
  66. $sql = "select * from dpedido where pedchave = ? and prdcodigo = ?";
  67. $statement_sql = Conexao::getConnection()->prepare($sql);
  68. $statement_sql->bindValue(1, $pedchave);
  69. $statement_sql->bindValue(2, $prdcodigo);
  70. $statement_sql->execute();
  71. return $statement_sql->fetch(PDO::FETCH_ASSOC);
  72. } catch (PDOException $exc) {
  73. echo $exc->getMessage();
  74. }
  75. }
  76.  
  77. static public function getProdutoPedido($pedchave) {
  78. try {
  79. $sql = "select * from dpedido where pedchave = ? and tipo ='PRODUTO' order by prdcodigo asc";
  80. $statement_sql = Conexao::getConnection()->prepare($sql);
  81. $statement_sql->bindValue(1, $pedchave);
  82. $statement_sql->execute();
  83. return $statement_sql->fetchAll(PDO::FETCH_ASSOC);
  84. } catch (PDOException $exc) {
  85. echo $exc->getMessage();
  86. }
  87. }
  88.  
  89. static public function getAdicionalPedido($pedchave) {
  90. try {
  91. $sql = "select * from dpedido where pedchave = ? and tipo ='ADICIONAL'";
  92. $statement_sql = Conexao::getConnection()->prepare($sql);
  93. $statement_sql->bindValue(1, $pedchave);
  94. $statement_sql->execute();
  95. return $statement_sql->fetchAll(PDO::FETCH_ASSOC);
  96. } catch (PDOException $exc) {
  97. echo $exc->getMessage();
  98. }
  99. }
  100.  
  101. static public function getItemsPedido($pedchave) {
  102. try {
  103. $sql = "select * from dpedido where pedchave = ?";
  104. $statement_sql = Conexao::getConnection()->prepare($sql);
  105. $statement_sql->bindValue(1, $pedchave);
  106. $statement_sql->execute();
  107. return $statement_sql->fetchAll(PDO::FETCH_ASSOC);
  108. } catch (PDOException $exc) {
  109. echo $exc->getMessage();
  110. }
  111. }
  112.  
  113. static public function getProdutosMaisVendidos($data1, $data2) {
  114. try {
  115. $sql = "select sum(i.quantidade) as qtd,
  116. i.prdcodigo as cod,
  117. pr.prd_descricao as descr
  118. from cpedido p
  119. inner join dpedido i on p.ped_chave = i.pedchave
  120. inner join produtos pr on pr.prd_codigo = i.prdcodigo
  121. where p.ped_status != 'PEDIDO RECUSADO' and p.ped_dataHora between ? and ? group by i.prdcodigo order by qtd desc";
  122. $statement_sql = Conexao::getConnection()->prepare($sql);
  123. $statement_sql->bindValue(1, $data1);
  124. $statement_sql->bindValue(2, $data2);
  125. $statement_sql->execute();
  126. return $statement_sql->fetchAll(PDO::FETCH_ASSOC);
  127. } catch (PDOException $exc) {
  128. echo $exc->getMessage();
  129. }
  130. }
Add Comment
Please, Sign In to add comment