Guest User

Untitled

a guest
Apr 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. .filter('daterangeentrevistado', function () {
  2. return function (conversations, start_date, end_date) {
  3. var result = [];
  4.  
  5. //console.log(conversations, start_date, end_date);
  6. // date filters
  7. var start_date = start_date ? new Date(start_date.substring(start_date.length - 4, start_date.length) + "/" + start_date.substring(start_date.length - 7, start_date.length - 5) + "/" + start_date.substring(0, start_date.length == 10 ? 2 : 1)).getTime() : new Date("01/01/1900");
  8. var end_date = end_date ? new Date(end_date.substring(end_date.length - 4, end_date.length) + "/" + end_date.substring(end_date.length - 7, end_date.length - 5) + "/" + end_date.substring(0, end_date.length == 10 ? 2 : 1)).getTime() : new Date().getTime();
  9.  
  10. //console.log(conversations, start_date, end_date);
  11. // if the conversations are loaded
  12. if (conversations && conversations.length > 0) {
  13. $.each(conversations, function (index, conversation) {
  14. //alert(conversation.datanascimento);
  15. //result.push(conversation);
  16. if (conversation.datanascimento) {
  17. var conversationDate = new Date(conversation.datanascimento.substring(conversation.datanascimento.length - 4, conversation.datanascimento.length) + "/" + conversation.datanascimento.substring(conversation.datanascimento.length - 7, conversation.datanascimento.length - 5) + "/" + conversation.datanascimento.substring(0, conversation.datanascimento.length == 10 ? 2 : 1)).getTime();
  18. //console.log('conversationDate',conversation.datanascimento, conversation.datanascimento.length, conversation.datanascimento.substring(conversation.datanascimento.length-4,conversation.datanascimento.length), conversation.datanascimento.substring(conversation.datanascimento.length-7,conversation.datanascimento.length-5) , conversation.datanascimento.substring(0,conversation.datanascimento.length==10?2:1), conversationDate, conversationDate >= start_date, conversationDate <= end_date);
  19. if (conversationDate >= start_date && conversationDate <= end_date) {
  20. //console.log('conversation', conversation);
  21. result.push(conversation);
  22. }
  23. }
  24. });
  25.  
  26. return result;
  27. }
  28. };
  29. });
  30.  
  31. <tr ng-repeat="entrevistado in results = (entrevistados.data | filter:query | daterangeentrevistado: datanascimentoInicio:datanascimentoFim)" id="filtros">
  32. <td><input type="checkbox" ng-model="entrevistado.selecionado" id="checkbox"> {{ entrevistado.rg }}</td>
  33. <td>{{ entrevistado.nome }}</td>
  34. <td>{{ entrevistado.telefone }}</td>
  35. <td>
  36. <div class="btn-group">
  37. <button class="btn btn-warning" ng-click="editData(entrevistado.rg)">
  38. <span class="glyphicon glyphicon-pencil"></span>
  39. </button>
  40. <button class="btn btn-danger" ng-click="removeData(entrevistado.id)">
  41. <span class="glyphicon glyphicon-remove"></span>
  42. </button>
  43. </div>
  44. </td>
  45. </tr>
Add Comment
Please, Sign In to add comment