CMS  Version 3.9
custom_report_list_view.inc
Go to the documentation of this file.
1 <?php
7 Fakoli::usingFeature("paged_list");
8 
10 {
11  var $title;
12  var $reports;
13  var $list;
14  var $id; // report url
16 
17  function __construct($title, $id, $constraints, $pageSize)
18  {
19  $this->title = $title;
20 
21  // blank title means throw-away record presaved on generate page
22  $this->reports = Query::create(CustomReport, "WHERE title != '' AND $constraints")->execute();
23 
24  $this->id = $id;
25  $this->list = new PagedList($this->reports, "{$id}_list", array($this, formatReport));
26  $this->list->pageSize = $pageSize;
27  $this->list->emptyList = "<em>No reports found.</em>";
28  }
29 
31  {
32  global $user;
33 
34  $out = "<div class='report_title'>";
35  if ($report->shared)
36  {
37  $out .= "<i class='fa-fw fas fa-share'></i>&nbsp;";
38  }
39 
40  $out .= "{$report->title}</div><div class='report_description'>{$report->description}</div>";
41 
42  $out .= "<a class='button' href='custom_report_results?report_id={$report->report_id}'><i class='fa-fw far fa-file-alt'></i> Run Report</a>";
43 
44  if (checkRole("admin,data") || $report->user_id == $user->user_id)
45  {
46  $out .= "&nbsp;&nbsp;&nbsp;<a class='button' href='custom_report?report_id={$report->report_id}&edit=1'><i class='fa-fw fas fa-pencil-alt'></i> Edit</a>";
47  }
48 
49  if (checkRole("admin,data"))
50  {
51  if ($report->shared)
52  {
53  $out .= "&nbsp;&nbsp;&nbsp;<a class='button' href='#' onclick='ReportManager.unshareReport({$report->report_id}); return false;'><i class='fa-fw far fa-share reverse'></i> Unshare</a>";
54  }
55  else
56  {
57  $out .= "&nbsp;&nbsp;&nbsp;<a class='button' href='#' onclick='ReportManager.shareReport({$report->report_id}); return false;'><i class='fa-fw far fa-share'></i> Share</a>";
58  }
59 
60  $out .= "&nbsp;&nbsp;&nbsp;<a class='button' href='#' onclick='ReportManager.deleteReport({$report->report_id}); return false;'><i class='fa-fw far fa-trash-alt'></i> Delete</a>";
61  }
62  return $out;
63  }
64 
65  function writeScript()
66  {
67  return $this->list->writeScript();
68  }
69 
70  function drawView()
71  {
72  echo "<div id='$this->id' class='custom_report_list_panel'>";
73  echo "<h3>$this->title</h3>";
74  echo "<div class='report_list'>";
75  $this->list->drawList();
76  echo "</div></div>";
77  }
78 }?>
$out
Definition: page.inc:66
$bookmark title
__construct($title, $id, $constraints, $pageSize)
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
global $user
$report
Definition: save_report.inc:38