Guest User

Untitled

a guest
Jan 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. // Codice.php
  2.  
  3. public function getCodiceBySiae($codiceSiae) {
  4. $result = $this
  5. ->getRequestsModel()
  6. ->getConnection()
  7. ->createQueryBuilder()
  8. ->select('*')
  9. ->from('z_requests_tbl', 'richieste')
  10. ->join('richieste', 'z_codici_tbl', 'codici', 'richieste.request_FK_codice_id_da < codici.codice_id AND richieste.request_FK_codice_id_a > codici.codice_id')
  11. ->where('richieste.request_siae_da <' . $codiceSiae . 'AND richieste.request_siae_a >' . $codiceSiae)
  12. ->execute()
  13. ->fetch();
  14. return $result;
  15. }
  16.  
  17. public function getCodiceByBruciatura($codiceBruciatura) {
  18. $result = $this
  19. ->getCodiceModel()
  20. ->getConnection()
  21. ->createQueryBuilder()
  22. ->select('*')
  23. ->from('z_codici_tbl', 'codici')
  24. ->join('codici', 'z_requests_tbl', 'richieste', 'richieste.request_FK_codice_id_da < codici.codice_id AND richieste.request_FK_codice_id_a > codici.codice_id')
  25. ->where('richieste.codice_prodotto_VERIFICAREEEEEE = "' . $codiceBruciatura . '"')
  26. return $result;
  27. }
  28.  
  29. // Index.php
  30. public function execute($oldAction = null)
  31. {
  32.  
  33. $filtersCommand = __Request::get('filters_command');
  34. $searchValue = __Request::get('filterSearch');
  35. $proxyCode = org_glizy_ObjectFactory::createObject('it_zanichelli_my_libs_models_proxy_Codice');
  36. $codeId = 0;
  37. $scenario = 'codice_non_trovato';
  38.  
  39. if ($filtersCommand == 'SEARCH') {
  40. // validare input a seconda dei 3 scenari
  41. if (is_numeric($searchValue)) {
  42. $result = $proxyCode->getCodiceBySiae($searchValue);
  43. $this->redirectToShowPage($result['codice_id']);
  44. } else if ($this->isValidEmail($searchValue)) {
  45. // 'user_email';
  46. } else if (isset($searchValue)) {
  47. $result = $proxyCode->getCodiceByBruciatura($searchValue);
  48. $this->redirectToShowPage($result['codice_id']);
  49. } else {
  50. // resta sulla pagina e servi 'codice non trovato'
  51. }
  52. } else {
  53. // resta sulla pagina e servi 'codice non trovato'
  54. }
  55. }
  56.  
  57. public function isValidEmail($email)
  58. {
  59. return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
  60. }
  61.  
  62. public function redirectToShowPage($codeId)
  63. {
  64. $this->changePage('linkWithActionAndValue', [
  65. 'pageId' => $this->pageId,
  66. 'action' => 'show',
  67. 'id' => $codeId,
  68. ]);
  69. }
Add Comment
Please, Sign In to add comment