PageRenderTime 44ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/application/views/admin/reports.php

https://github.com/yamamoto123/Ushahidi_Web
PHP | 246 lines | 205 code | 16 blank | 25 comment | 19 complexity | a6ec183e035beafdce9dd462c77b6911 MD5 | raw file
  1. <?php
  2. /**
  3. * Reports view page.
  4. *
  5. * PHP version 5
  6. * LICENSE: This source file is subject to LGPL license
  7. * that is available through the world-wide-web at the following URI:
  8. * http://www.gnu.org/copyleft/lesser.html
  9. * @author Ushahidi Team <team@ushahidi.com>
  10. * @package Ushahidi - http://source.ushahididev.com
  11. * @module API Controller
  12. * @copyright Ushahidi - http://www.ushahidi.com
  13. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
  14. */
  15. ?>
  16. <div class="bg">
  17. <h2>
  18. <?php admin::reports_subtabs("view"); ?>
  19. </h2>
  20. <!-- tabs -->
  21. <div class="tabs">
  22. <!-- tabset -->
  23. <ul class="tabset">
  24. <li>
  25. <a href="?status=0" <?php if ($status != 'a' AND $status !='v') echo "class=\"active\""; ?>><?php echo Kohana::lang('ui_main.show_all');?></a>
  26. </li>
  27. <li><a href="?status=a" <?php if ($status == 'a') echo "class=\"active\""; ?>><?php echo Kohana::lang('ui_main.awaiting_approval');?></a></li>
  28. <li><a href="?status=v" <?php if ($status == 'v') echo "class=\"active\""; ?>><?php echo Kohana::lang('ui_main.awaiting_verification');?></a></li>
  29. </ul>
  30. <!-- tab -->
  31. <div class="tab">
  32. <ul>
  33. <li><a href="#" onclick="reportAction('a','<?php echo strtoupper(Kohana::lang('ui_main.approve')); ?>', '');">
  34. <?php echo Kohana::lang('ui_main.approve');?></a>
  35. </li>
  36. <li><a href="#" onclick="reportAction('u','<?php echo strtoupper(Kohana::lang('ui_main.disapprove')); ?>', '');">
  37. <?php echo Kohana::lang('ui_main.disapprove');?></a>
  38. </li>
  39. <li><a href="#" onclick="reportAction('v','<?php echo strtoupper(Kohana::lang('ui_admin.verify_unverify')); ?>', '');">
  40. <?php echo Kohana::lang('ui_admin.verify_unverify');?></a>
  41. </li>
  42. <li><a href="#" onclick="reportAction('d','<?php echo strtoupper(Kohana::lang('ui_main.delete')); ?>', '');">
  43. <?php echo Kohana::lang('ui_main.delete');?></a>
  44. </li>
  45. </ul>
  46. </div>
  47. </div>
  48. <?php if ($form_error): ?>
  49. <!-- red-box -->
  50. <div class="red-box">
  51. <h3><?php echo Kohana::lang('ui_main.error');?></h3>
  52. <ul><?php echo Kohana::lang('ui_main.select_one');?></ul>
  53. </div>
  54. <?php endif; ?>
  55. <?php if ($form_saved): ?>
  56. <!-- green-box -->
  57. <div class="green-box" id="submitStatus">
  58. <h3><?php echo Kohana::lang('ui_main.reports');?> <?php echo $form_action; ?> <a href="#" id="hideMessage" class="hide">hide this message</a></h3>
  59. </div>
  60. <?php endif; ?>
  61. <!-- report-table -->
  62. <?php print form::open(NULL, array('id' => 'reportMain', 'name' => 'reportMain')); ?>
  63. <input type="hidden" name="action" id="action" value="">
  64. <input type="hidden" name="incident_id[]" id="incident_single" value="">
  65. <div class="table-holder">
  66. <table class="table">
  67. <thead>
  68. <tr>
  69. <th class="col-1"><input id="checkallincidents" type="checkbox" class="check-box" onclick="CheckAll( this.id, 'incident_id[]' )" /></th>
  70. <th class="col-2"><?php echo Kohana::lang('ui_main.report_details');?></th>
  71. <th class="col-3"><?php echo Kohana::lang('ui_main.date');?></th>
  72. <th class="col-4"><?php echo Kohana::lang('ui_main.actions');?></th>
  73. </tr>
  74. </thead>
  75. <tfoot>
  76. <tr class="foot">
  77. <td colspan="4">
  78. <?php echo $pagination; ?>
  79. </td>
  80. </tr>
  81. </tfoot>
  82. <tbody>
  83. <?php if ($total_items == 0): ?>
  84. <tr>
  85. <td colspan="4" class="col">
  86. <h3><?php echo Kohana::lang('ui_main.no_results');?></h3>
  87. </td>
  88. </tr>
  89. <?php endif; ?>
  90. <?php
  91. foreach ($incidents as $incident)
  92. {
  93. $incident_id = $incident->incident_id;
  94. $incident_title = strip_tags($incident->incident_title);
  95. $incident_description = text::limit_chars(strip_tags($incident->incident_description), 150, "...", true);
  96. $incident_date = $incident->incident_date;
  97. $incident_date = date('Y-m-d', strtotime($incident->incident_date));
  98. // Mode of submission... WEB/SMS/EMAIL?
  99. $incident_mode = $incident->incident_mode;
  100. // Get the incident ORM
  101. $incident_orm = ORM::factory('incident', $incident_id);
  102. // Get the person submitting the report
  103. $incident_person = $incident_orm->incident_person;
  104. //XXX incident_Mode will be discontinued in favour of $service_id
  105. if ($incident_mode == 1) // Submitted via WEB
  106. {
  107. $submit_mode = "WEB";
  108. // Who submitted the report?
  109. if ($incident_person->loaded)
  110. {
  111. // Report was submitted by a visitor
  112. $submit_by = $incident_person->person_first . " " . $incident_person->person_last;
  113. }
  114. else
  115. {
  116. if ($incident_orm->user_id) // Report Was Submitted By Administrator
  117. {
  118. $submit_by = $incident_orm->user->name;
  119. }
  120. else
  121. {
  122. $submit_by = 'Unknown';
  123. }
  124. }
  125. }
  126. elseif ($incident_mode == 2) // Submitted via SMS
  127. {
  128. $submit_mode = "SMS";
  129. $submit_by = $incident_orm->message->message_from;
  130. }
  131. elseif ($incident_mode == 3) // Submitted via Email
  132. {
  133. $submit_mode = "EMAIL";
  134. $submit_by = $incident_orm->message->message_from;
  135. }
  136. elseif ($incident_mode == 4) // Submitted via Twitter
  137. {
  138. $submit_mode = "TWITTER";
  139. $submit_by = $incident_orm->message->message_from;
  140. }
  141. // Get the country name
  142. $country_name = ($incident->country_id != 0)
  143. ? $countries[$incident->country_id]
  144. : $countries[Kohana::config('settings.default_country')];
  145. // Retrieve Incident Categories
  146. $incident_category = "";
  147. foreach($incident_orm->incident_category as $category)
  148. {
  149. $incident_category .= "<a href=\"#\">" . $category->category->category_title . "</a>&nbsp;&nbsp;";
  150. }
  151. // Incident Status
  152. $incident_approved = $incident->incident_active;
  153. $incident_verified = $incident->incident_verified;
  154. // Get Edit Log
  155. $edit_count = $incident_orm->verify->count();
  156. $edit_css = ($edit_count == 0) ? "post-edit-log-gray" : "post-edit-log-blue";
  157. $edit_log = "<div class=\"".$edit_css."\">"
  158. . "<a href=\"javascript:showLog('edit_log_".$incident_id."')\">".Kohana::lang('ui_admin.edit_log').":</a> (".$edit_count.")</div>"
  159. . "<div id=\"edit_log_".$incident_id."\" class=\"post-edit-log\"><ul>";
  160. foreach ($incident_orm->verify as $verify)
  161. {
  162. $edit_log .= "<li>".Kohana::lang('ui_admin.edited_by')." ".$verify->user->name." : ".$verify->verified_date."</li>";
  163. }
  164. $edit_log .= "</ul></div>";
  165. // Get Any Translations
  166. $i = 1;
  167. $incident_translation = "<div class=\"post-trans-new\">"
  168. . "<a href=\"" . url::base() . 'admin/reports/translate/?iid='.$incident_id."\">"
  169. . strtoupper(Kohana::lang('ui_main.add_translation')).":</a></div>";
  170. foreach ($incident_orm->incident_lang as $translation)
  171. {
  172. $incident_translation .= "<div class=\"post-trans\">"
  173. . Kohana::lang('ui_main.translation'). $i . ": "
  174. . "<a href=\"" . url::base() . 'admin/reports/translate/'. $translation->id .'/?iid=' . $incident_id . "\">"
  175. . text::limit_chars($translation->incident_title, 150, "...", TRUE)
  176. . "</a>"
  177. . "</div>";
  178. }
  179. ?>
  180. <tr>
  181. <td class="col-1">
  182. <input name="incident_id[]" id="incident" value="<?php echo $incident_id; ?>" type="checkbox" class="check-box"/>
  183. </td>
  184. <td class="col-2">
  185. <div class="post">
  186. <h4>
  187. <a href="<?php echo url::site() . 'admin/reports/edit/' . $incident_id; ?>" class="more">
  188. <?php echo $incident_title; ?>
  189. </a>
  190. </h4>
  191. <p><?php echo $incident_description; ?>...
  192. <a href="<?php echo url::base() . 'admin/reports/edit/' . $incident_id; ?>" class="more">
  193. <?php echo Kohana::lang('ui_main.more');?>
  194. </a>
  195. </p>
  196. </div>
  197. <ul class="info">
  198. <li class="none-separator"><?php echo Kohana::lang('ui_main.location');?>:
  199. <strong><?php echo $incident->location_name; ?></strong>, <strong><?php echo $country_name; ?></strong>
  200. </li>
  201. <li><?php echo Kohana::lang('ui_main.submitted_by');?>
  202. <strong><?php echo $submit_by; ?></strong> via <strong><?php echo $submit_mode; ?></strong>
  203. </li>
  204. </ul>
  205. <ul class="links">
  206. <li class="none-separator"><?php echo Kohana::lang('ui_main.categories');?>:<?php echo $incident_category; ?></li>
  207. </ul>
  208. <?php
  209. echo $edit_log;
  210. // Action::report_extra_admin - Add items to the report list in admin
  211. Event::run('ushahidi_action.report_extra_admin', $incident);
  212. ?>
  213. </td>
  214. <td class="col-3"><?php echo $incident_date; ?></td>
  215. <td class="col-4">
  216. <ul>
  217. <li class="none-separator"><a href="#"<?php if ($incident_approved) echo " class=\"status_yes\"" ?> onclick="reportAction('a','APPROVE', '<?php echo $incident_id; ?>');"><?php echo Kohana::lang('ui_main.approve');?></a></li>
  218. <li><a href="#"<?php if ($incident_verified) echo " class=\"status_yes\"" ?> onclick="reportAction('v','VERIFY', '<?php echo $incident_id; ?>');"><?php echo Kohana::lang('ui_main.verify');?></a></li>
  219. <li><a href="#" class="del" onclick="reportAction('d','DELETE', '<?php echo $incident_id; ?>');"><?php echo Kohana::lang('ui_main.delete');?></a></li>
  220. </ul>
  221. </td>
  222. </tr>
  223. <?php
  224. }
  225. ?>
  226. </tbody>
  227. </table>
  228. </div>
  229. <?php print form::close(); ?>
  230. </div>