PageRenderTime 48ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/simplegroups/views/simplegroups/reports_js.php

https://github.com/fayazv/Taarifa_Web
PHP | 146 lines | 77 code | 33 blank | 36 comment | 6 complexity | dd93359cc29cc9dcbe577c70197731f9 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-3.0, BSD-3-Clause, LGPL-2.1
  1. /**
  2. * Main reports js file.
  3. *
  4. * Handles javascript stuff related to reports function.
  5. *
  6. * PHP version 5
  7. * LICENSE: This source file is subject to LGPL license
  8. * that is available through the world-wide-web at the following URI:
  9. * http://www.gnu.org/copyleft/lesser.html
  10. * @author Ushahidi Team <team@ushahidi.com>
  11. * @package Ushahidi - http://source.ushahididev.com
  12. * @module API Controller
  13. * @copyright Ushahidi - http://www.ushahidi.com
  14. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
  15. */
  16. <?php require SYSPATH.'../application/views/admin/form_utils_js.php' ?>
  17. var currentPage = "1";
  18. var currentStatus = "O";
  19. var currentStatus = "O";
  20. // Ajax Submission
  21. function reportAction ( action, confirmAction, incident_id, ui_id )
  22. {
  23. var statusMessage;
  24. if( !isChecked( "incident" ) && incident_id=='' )
  25. {
  26. alert('Please select at least one report.');
  27. }
  28. else
  29. {
  30. var answer = confirm('Are You Sure You Want To ' + confirmAction + ' items?')
  31. if (answer){
  32. // Set Submit Type
  33. $("#action").attr("value", action);
  34. if (incident_id != '')
  35. {
  36. // Submit Form For Single Item
  37. $("#incident_single").attr("value", incident_id);
  38. }
  39. else
  40. {
  41. //we're acting on lots of stuff at once.
  42. // Set Hidden form item to 000 so that it doesn't return server side error for blank value
  43. $("#incident_single").attr("value", "000");
  44. }
  45. //get the category id that we want to use
  46. var cat_id = encodeURIComponent($("#cat_filter").val());
  47. //turn on the wating image
  48. $('<img id="reportAction_wait" src="<?php echo url::base(); ?>media/img/loading_g.gif"/>').insertAfter($("#"+ui_id));
  49. $.post("<?php echo url::base() ?>admin/simplegroups/reports/get_table?c="+cat_id+"&page="+currentPage+"&status="+currentStatus,
  50. $("#reportMain").serialize(),
  51. function(data){
  52. var parent = $('#table_holder').parent();
  53. $('#table_holder').remove();
  54. parent.append('<div class="table-holder" id="table_holder">'+data+'</div>');
  55. $("#reportAction_wait").remove();
  56. });
  57. }
  58. }
  59. return false;
  60. }//end method
  61. function showLog(id)
  62. {
  63. $('#' + id).toggle(400);
  64. }
  65. //called when the user changes what category to filter by
  66. function changeCategoryFilter()
  67. {
  68. //start at the first page
  69. currentPage = "1";
  70. //turn on the wating image
  71. $('#filter_wait').html('<img src="<?php echo url::base(); ?>media/img/loading_g.gif"/>');
  72. updateTable('#filter_wait');
  73. return false;
  74. }
  75. /*
  76. * This sets the page we're looking at
  77. */
  78. function pagination(page)
  79. {
  80. currentPage = page;
  81. $('<img id="page_wait" src="<?php echo url::base(); ?>media/img/loading_g.gif"/>').insertAfter($("#pagination_"+page));
  82. updateTable('#pagination_'+page);
  83. }
  84. /*
  85. * Sets the status of messages that we're looking at
  86. */
  87. function changeStatus(status)
  88. {
  89. currentStatus = status;
  90. //remove the selected class from all the tabs
  91. var kids = $(".tabset").find('a');
  92. kids.removeClass("active");
  93. $("#status_filter_"+status).addClass("active");
  94. //turn on the wating image
  95. $('<img id="tab_wait" src="<?php echo url::base(); ?>media/img/loading_g.gif"/>').insertAfter($("#status_filter_a"+status));
  96. updateTable('#tab_wait');
  97. }
  98. //Updates the table
  99. function updateTable(waitingID)
  100. {
  101. //get the category id that we want to use
  102. var cat_id = encodeURIComponent($("#cat_filter").val());
  103. //get the HTML for the next set of kid admin areas
  104. $.get("<?php echo url::base() ?>admin/simplegroups/reports/get_table?c="+cat_id+"&page="+currentPage+"&status="+currentStatus,
  105. function(data){
  106. var parent = $('#table_holder').parent();
  107. $('#table_holder').remove();
  108. parent.append('<div class="table-holder" id="table_holder">'+data+'</div>');
  109. $(waitingID).html('');
  110. }
  111. );
  112. return false;
  113. }