Skip to content

Commit

Permalink
Merge branch 'feat/report_module_bootstrap' into feat/FinishNewDesign…
Browse files Browse the repository at this point in the history
…sMigration
  • Loading branch information
MaddyUnderStars committed Nov 8, 2024
2 parents ce5a641 + ccdd5d8 commit 8c87bf2
Show file tree
Hide file tree
Showing 16 changed files with 386 additions and 207 deletions.
24 changes: 17 additions & 7 deletions system/modules/report/actions/addmembers.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php

use Html\Form\InputField\Hidden;
use Html\Form\Select;

// provide form by which to add members to a report
function addmembers_GET(Web &$w)
{
Expand All @@ -11,19 +15,25 @@ function addmembers_GET(Web &$w)
$currentReportMembers = ReportService::getInstance($w)->getReportMembers($p["id"]);
$currentMembers = [];

for ($i = 0; $i <= count($currentReportMembers) - 1; $i++) {
for ($i = 0; $i <= count($currentReportMembers) - 1; $i++)
{
$currentMembers[] = AuthService::getInstance($w)->getUser($currentReportMembers[$i]->user_id);
}

$members = array_diff($possibleMembers, $currentMembers);

// build form
$addUserForm = array(
array("", "hidden", "report_id", $p['id']),
array("Add Member", "select", "member", null, $members),
array("With Role", "select", "role", "", ReportService::getInstance($w)->getReportPermissions()),
);
$addUserForm = [
"Add Member" => [
[new Hidden([
"id|name" => "report_id",
"value" => $p["id"]
])],
[new Select(["id|name" => "member", "label" => "Member", "options" => $members])],
[new Select(["id|name" => "role", "label" => "Role", "options" => ReportService::getInstance($w)->getReportPermissions()])]
]
];

$w->setLayout(null);
$w->ctx("addmembers", Html::form($addUserForm, $w->localUrl("/report/updatemembers/"), "POST", " Submit "));
$w->ctx("addmembers", HtmlBootstrap5::multiColForm($addUserForm, $w->localUrl("/report/updatemembers/"), "POST", " Submit "));
}
2 changes: 1 addition & 1 deletion system/modules/report/actions/connections/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function edit_GET(Web $w) {
)
);

$w->out(Html::multiColForm($form, "/report-connections/edit/{$report_connection->id}"));
$w->out(HtmlBootstrap5::multiColForm($form, "/report-connections/edit/{$report_connection->id}"));
}

function edit_POST(Web $w) {
Expand Down
35 changes: 21 additions & 14 deletions system/modules/report/actions/connections/index.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
<?php

function index_ALL(Web $w) {
function index_ALL(Web $w)
{
$connections = ReportService::getInstance($w)->getConnections();
$table_header = array("Driver", "Host", "Database", "Port", "Username", "Actions");
$table_body = array();

$table_header = ["Driver", "Host", "Database", "Port", "Username", "Actions"];
$table_body = [];
if (!empty($connections)) {
foreach($connections as $conn) {
foreach ($connections as $conn) {
$conn->decrypt();
$table_body[] = array(
$conn->db_driver, $conn->db_host, $conn->db_database, $conn->db_port, $conn->s_db_user,
Html::box("/report-connections/test/{$conn->id}", "Test Connection", true) .
Html::box("/report-connections/edit/{$conn->id}", "Edit", true) .
Html::b("/report-connections/delete/{$conn->id}", "Delete", "Are you sure you want to remove this connection?")
);
$table_body[] = [
$conn->db_driver,
$conn->db_host,
$conn->db_database,
$conn->db_port,
$conn->s_db_user,
HtmlBootstrap5::buttonGroup(
Html::box("/report-connections/test/{$conn->id}", "Test Connection", true) .
Html::box("/report-connections/edit/{$conn->id}", "Edit", true) .
Html::b("/report-connections/delete/{$conn->id}", "Delete", "Are you sure you want to remove this connection?", null, false, "btn-danger")
)
];
}
}
$w->ctx("connections_table", Html::table($table_body, null, "tablesorter", $table_header));
}

$w->ctx("connections_table", HtmlBootstrap5::table($table_body, null, "tablesorter", $table_header));
}
16 changes: 11 additions & 5 deletions system/modules/report/actions/createfeed.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

use Html\Form\Select;
function createfeed_GET(Web &$w)
{
ReportService::getInstance($w)->navigation($w, "Create a Feed");
Expand All @@ -15,11 +17,15 @@ function createfeed_GET(Web &$w)
}
}

$f = Html::form([
["Create a Feed from a Report", "section"],
["Select Report", "select", "rid", null, $myrep],
["Feed Title", "text", "title"],
["Description", "textarea", "description", null, "40", "6"],
$f = HtmlBootstrap5::multiColForm([
"Create a Feed from a Report" => [
[new Select(["id|name" => "rid", "label" => "Select Report", "options" => $myrep])]
]

// ["Create a Feed from a Report", "section"],
// ["Select Report", "select", "rid", null, $myrep],
// ["Feed Title", "text", "title"],
// ["Description", "textarea", "description", null, "40", "6"],
], $w->localUrl("/report/createfeed"), "POST", "Save");

$w->ctx("createfeed", $f);
Expand Down
78 changes: 59 additions & 19 deletions system/modules/report/actions/createreport.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php

use Html\Cmfive\QuillEditor;
use Html\Form\InputField;
use Html\Form\Select;
use Html\Form\Textarea;
//////////////////////////////////////////////////
// CREATE REPORT //
//////////////////////////////////////////////////
Expand All @@ -9,25 +14,60 @@ function createreport_ALL(Web &$w)

// build form to create a report. display to users by role is controlled by the template
// using lookup with type ReportCategory for category listing
$f = Html::form(array(
array("Create a New Report", "section"),
array("Title", "text", "title", Request::string('title')),
array("Module", "select", "module", Request::string('module'), ReportService::getInstance($w)->getModules()),
// array("Category","select","category", Request::string('category'), lookupForSelect($w, "ReportCategory")),
array("Description", "textarea", "description", Request::string('description'), "110", "2"),
array("Code", "textarea", "report_code", Request::string('report_code'), "110", "22", false),
array("Connection", "select", "report_connection_id", Request::int('report_connection_id'), ReportService::getInstance($w)->getConnections())
), $w->localUrl("/report/savereport"), "POST", "Save Report");

$t = Html::form(array(
array("Special Parameters", "section"),
array("User", "static", "user", "{{current_user_id}}"),
array("Roles", "static", "roles", "{{roles}}"),
array("Site URL", "static", "webroot", "{{webroot}}"),
array("View Database", "section"),
array("Tables", "select", "dbtables", null, ReportService::getInstance($w)->getAllDBTables()),
array(" ", "static", "dbfields", "<span id=dbfields></span>")
));
$f = HtmlBootstrap5::multiColForm([
"Create a new Report" => [
[new InputField([
"id|name" => "title",
"label" => "Title",
"value" => Request::string("title"),
])],

[new Select([
"id|name" => "module",
"label" => "Module",
"value" => Request::string("module"),
"options" => ReportService::getInstance($w)->getModules(),
])],

// [new Select([
// "id|name" => "category",
// "label" => "Category",
// "value" => Request::string("module"),
// "options" => lookupForSelect($w, "ReportCategory"),
// ])]

[new QuillEditor([
"id|name" => "description",
"label" => "Description",
"value" => Request::string("description"),
])],

[new Textarea([
"id|name" => "report_code",
"label" => "Code",
"value" => Request::string("report_code"),
"rows" => 22,
"cols" => 110
])],

[new Select([
"id|name" => "report_connection_id",
"label" => "Connect",
"value" => Request::int("report_connection_id"),
"options" => ReportService::getInstance($w)->getConnections(),
])]
]
], $w->localUrl("/report/savereport"), "POST", "Save Report");

// $t = Html::form(array(
// array("Special Parameters", "section"),
// array("User", "static", "user", "{{current_user_id}}"),
// array("Roles", "static", "roles", "{{roles}}"),
// array("Site URL", "static", "webroot", "{{webroot}}"),
// array("View Database", "section"),
// array("Tables", "select", "dbtables", null, ReportService::getInstance($w)->getAllDBTables()),
// array(" ", "static", "dbfields", "<span id=dbfields></span>")
// ));

// display form
$w->ctx("createreport", $f);
Expand Down
26 changes: 18 additions & 8 deletions system/modules/report/actions/edit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

use Html\Cmfive\QuillEditor;
use Html\Form\InputField;
use Html\Form\Textarea;

function edit_GET(Web &$w)
{
$p = $w->pathMatch("id");
Expand Down Expand Up @@ -71,7 +75,11 @@ function edit_GET(Web &$w)
'options' => !empty($category_config_for_select[$report->module]) ? $category_config_for_select[$report->module] : []
]))->setLabel('Category')
],
[["Description", "textarea", "description", $report->description, "110", "2"]],
[new QuillEditor([
"id|name" => "description",
"label" => "Description",
"value" => $report->description,
])],
[["Connection", "select", "report_connection_id", $report->report_connection_id, ReportService::getInstance($w)->getConnections()]],
]
];
Expand All @@ -84,11 +92,13 @@ function edit_GET(Web &$w)

if (!empty($report)) {
$sqlform = [
["", "hidden", "title", $report->title],
["", "hidden", "module", $report->module],
["", "hidden", "description", $report->description],
["Code", "textarea", "report_code", $report->report_code, "110", "82", "codemirror"],
["", "hidden", "report_connection_id", $report->report_connection_id, ReportService::getInstance($w)->getConnections()],
"SQL Editor" => [
[new InputField\Hidden(["id|name" => "title", "value" => $report->title])],
[new InputField\Hidden(["id|name" => "module", "value" => $report->module])],
[new InputField\Hidden(["id|name" => "description", "value" => $report->description])],
[new InputField\Hidden(["id|name" => "report_connection_id", "value" => $report->report_connection_id])],
[new Textarea(["id|name" => "report_code", "value" => $report->report_code, "rows" => 10])],
]
];
}

Expand All @@ -110,8 +120,8 @@ function edit_GET(Web &$w)
$w->ctx("duplicate_button", Html::b($w->localUrl("/report/duplicate/{$report->id}"), "Duplicate"));
}

$w->ctx("report_form", Html::multiColForm($form, $w->localUrl("/report/edit/{$report->id}"), "POST", "Save Report"));
$w->ctx("sql_form", !empty($sqlform) ? Html::form($sqlform, $w->localUrl("/report/edit/{$report->id}"), "POST", "Save Report") : "");
$w->ctx("report_form", HtmlBootstrap5::multiColForm($form, $w->localUrl("/report/edit/{$report->id}"), "POST", "Save Report"));
$w->ctx("sql_form", !empty($sqlform) ? HtmlBootstrap5::multiColForm($sqlform, $w->localUrl("/report/edit/{$report->id}"), "POST", "Save Report") : "");

if (!empty($report->id)) {
// ============= Members tab ===================
Expand Down
70 changes: 48 additions & 22 deletions system/modules/report/actions/editmember.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
<?php

use Html\Form\InputField\Checkbox;
use Html\Form\InputField\Hidden;
use Html\Form\Select;

// edit a member
function editmember_GET(Web &$w) {
$p = $w->pathMatch("repid","userid");
// get member details for edit
$member = ReportService::getInstance($w)->getReportMember($p['repid'], $p['userid']);
function editmember_GET(Web &$w)
{
$p = $w->pathMatch("repid", "userid");
// get member details for edit
$member = ReportService::getInstance($w)->getReportMember($p['repid'], $p['userid']);

// build editable form for a member allowing change of membership type
$f = Html::form(array(
array("Member Details","section"),
array("","hidden", "report_id",$p['repid']),
array("Name","static", "name", ReportService::getInstance($w)->getUserById($member->user_id)),
array("Role","select","role",$member->role,ReportService::getInstance($w)->getReportPermissions()),
array("Is email recipient", "checkbox", "is_email_recipient", $member->is_email_recipient)
),$w->localUrl("/report/editmember/".$p['userid']),"POST"," Update ");
// build editable form for a member allowing change of membership type
$f = HtmlBootstrap5::multiColForm([
"Edit Member" => [
[new Hidden([
"id|name" => "report_id",
"value" => $p["id"]
])],
[
(new Select([
"id|name" => "member",
"label" => "Member",
"options" => [ReportService::getInstance($w)->getUserById($member->user_id)],
"disabled" => true,
]))
->setSelectedOption(ReportService::getInstance($w)->getUserById($member->user_id))
],
[
(new Select([
"id|name" => "role",
"label" => "Role",
"options" => ReportService::getInstance($w)->getReportPermissions()
]))
->setSelectedOption($member->role)
],
[new Checkbox(["id|name" => "is_email_recipient", "label" => "Is email recipient", "value" => $member->is_email_recipient])]
]
], $w->localUrl("/report/editmember/" . $p['userid']), "POST", " Update ");

// display form
$w->setLayout(null);
$w->ctx("editmember",$f);
// display form
$w->setLayout(null);
$w->ctx("editmember", $f);
}

function editmember_POST(Web &$w) {
$p = $w->pathMatch("id");
$member = ReportService::getInstance($w)->getReportMember($_POST['report_id'], $p['id']);
function editmember_POST(Web &$w)
{
$p = $w->pathMatch("id");
$member = ReportService::getInstance($w)->getReportMember($_POST['report_id'], $p['id']);

$member->fill($_POST);
$member->is_email_recipient = intval(!empty($_POST['is_email_recipient']));
$member->update();
$member->fill($_POST);
$member->is_email_recipient = intval(!empty($_POST['is_email_recipient']));
$member->update();

$w->msg("Member updated","/report/edit/".$_POST['report_id']."#members");
$w->msg("Member updated", "/report/edit/" . $_POST['report_id'] . "#members");
}
2 changes: 2 additions & 0 deletions system/modules/report/actions/exereport.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// criteria/parameter form is submited and report is executed
function exereport_ALL(Web &$w)
{
$w->ctx("layout-size", "large");

ReportService::getInstance($w)->navigation($w, "Generate Report");
$p = $w->pathMatch("id");

Expand Down
Loading

0 comments on commit 8c87bf2

Please sign in to comment.