function edit_GET(Web $w) { list($lotId, $householdid) = $w->pathMatch("lotId", "householdid"); if (empty($lotId)) { $w->out("no lot id provided"); return; } $lot = $w->Bend->getLotForId($lotId); $household = new BendHousehold($w); if (!empty($householdid)) { $household = $w->Bend->getHouseholdForId($householdid); } $form["Lot"] = array(array(array("Lot Number", "static", "", $lot->lot_number), array("Occupancy", "static", "", $lot->occupancy))); $form["Household"] = array(array(array("Streetnumber", "text", "streetnumber", $household->streetnumber), array("Is CHL", "select", "is_chl", $household->is_chl, lookupForSelect($w, "YesNo")), array("Is Occupied", "select", "is_occupied", $household->is_occupied, lookupForSelect($w, "YesNo")), array("Number of Occupants", "text", "num_occupants", $household->num_occupants))); $w->setLayout(null); $w->out(Html::multiColForm($form, "/bend-household/edit/{$lotId}/{$household->id}", "POST", "Save")); }
function editoccupant_GET(Web $w) { list($householdid, $occupantid) = $w->pathMatch("a", "b"); if (empty($householdid)) { $w->error("Need a household ID"); } $household = $w->Bend->getHouseholdForId($householdid); if (empty($household)) { $w->error("Household not found"); } $oc = new BendHouseholdOccupant($w); $contact = new Contact($w); if (!empty($occupantid)) { $oc = $w->Bend->getHouseholdOccupantForId($occupantid); $contact = $oc->getContact(); } $form["Household"] = array(array(array("Street Number", "static", "", $household->streetnumber), array("Is CHL?", "static", "", $household->is_chl ? "yes" : "no"), array("Is Occupied?", "static", "", $household->is_occupied ? "yes" : "no"))); $form["Occupant"] = array(array(array("Occupant From", "date", "d_start", !empty($oc->d_start) ? formatDate($oc->d_start) : ""), array("Occupant To", "date", "d_end", !empty($oc->d_end) ? formatDate($oc->d_end) : "")), array(array("Pays Electricity?", "select", "pays_electricity", $oc->pays_electricity, lookupForSelect($w, "YesNo")), array("Does Workhours?", "select", "does_workhours", $oc->does_workhours, lookupForSelect($w, "YesNo")))); $form["Occupant Contact"] = array(array(empty($oc->user_id) ? array("Select Existing User", "select", "user_id", null, $w->Auth->getUsers()) : array("User", "static", "", $oc->getFullName())), array(array("First Name", "text", "firstname", $contact->firstname), array("Last Name", "text", "lastname", $contact->lastname), array("Email", "text", "email", $contact->email)), array(array("Home Phone", "text", "homephone", $contact->homephone), array("Work Phone", "text", "workphone", $contact->workphone), array("Mobile Phone", "text", "mobile", $contact->mobile))); $w->ctx("form", Html::multiColForm($form, "/bend-household/editoccupant/{$householdid}/{$occupantid}", "POST", "Save")); }
<?php if ($user) { if ($box) { ?> <h1>Edit User</h1><?php } $contact = $user->getContact(); $form['User Details'][] = array(array("Login", "text", "login", $user->login), array("Admin", "checkbox", "is_admin", $user->is_admin), array("Active", "checkbox", "is_active", $user->is_active)); $form['User Details'][] = array(array("Password", "password", "password"), array("Repeat Password", "password", "password2")); $form['Contact Details'][] = array(array("First Name", "text", "firstname", $contact ? $contact->firstname : ""), array("Last Name", "text", "lastname", $contact ? $contact->lastname : "")); $form['Contact Details'][] = array(array("Title", "select", "title", $contact ? $contact->title : "", lookupForSelect($w, "title")), array("Email", "text", "email", $contact ? $contact->email : "")); $groupUsers = $user->isInGroups(); if ($groupUsers) { foreach ($groupUsers as $groupUser) { $group = $groupUser->getGroup(); $groups[] = " - " . Html::a("/admin/moreInfo/" . $group->id, $group->login); } } else { $groups = array(); } $form['User Groups'][] = array(array("Group Title", "static", "groupName", implode("<br/>", $groups))); print Html::multiColForm($form, $w->localUrl("/admin/useredit/" . $w->ctx("id")), "POST", "Save"); ?> <?php } else { ?> <div class="error">User with ID <?php echo $id; ?>
function viewreport_GET(Web &$w) { $w->Report->navigation($w, "Edit Report"); $p = $w->pathMatch("id"); // tab: view report // if there is a report ID in the URL ... if ($p['id']) { // get member $member = $w->Report->getReportMember($p['id'], $w->session('user_id')); // get the relevant report $rep = $w->Report->getReportInfo($p['id']); // if the report exists check status & role before displaying if ($rep) { // if ($w->Auth->user()->hasRole("report_user") && (!$w->Auth->user()->hasRole("report_editor")) && (!$w->Auth->user()->hasRole("report_admin"))) { if ($member->role != "EDITOR" && !$w->Auth->user()->hasRole("report_admin")) { // redirect the unauthorised $w->msg("Sorry, you are not authorised to edit this Report", "/report/index/"); } elseif ($w->Auth->user()->hasRole("report_admin")) { // build the report for edit WITH an Approval checkbox // using lookup with type ReportCategory for category listing // get list of modules $modules = $w->Report->getModules(); $f = Html::form(array(array("Report Definition", "section"), array("Title", "text", "title", $rep->title), array("Module", "select", "module", $rep->module, $modules), array("Description", "textarea", "description", $rep->description, 110, 2, false), array("Code", "textarea", "report_code", $rep->report_code, 110, 22, false), array("Approved", "checkbox", "is_approved", $rep->is_approved), array("Connection", "select", "report_connection_id", $rep->report_connection_id, $w->Report->getConnections())), $w->localUrl("/report/editreport/" . $rep->id), "POST", " Update Report "); // provide a button by which the report may be tested, ie. executed $btntestreport = Html::b("/report/runreport/" . $rep->id, " Test the Report "); $w->ctx("btntestreport", $btntestreport); // create form providing view of tables and fields $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, $w->Report->getAllDBTables()), array("Fields", "static", "dbfields", "<span id='dbfields'></span>"))); $w->ctx("dbform", $t); } elseif ($member->role == "EDITOR") { // build the report for edit. edited forms again require approval // using lookup with type ReportCategory for category listing // get list of modules $modules = $w->Report->getModules(); $f = Html::form(array(array("Create a New Report", "section"), array("Title", "text", "title", $rep->title), array("Module", "select", "module", $rep->module, $modules), array("Category", "select", "category", $rep->category, lookupForSelect($w, "ReportCategory")), array("Description", "textarea", "description", $rep->description, 100, 2, true), array("Code", "textarea", "report_code", $rep->report_code, 100, 22, false), array("", "hidden", "is_approved", "0")), $w->localUrl("/report/edit/" . $rep->id), "POST", " Update Report "); // create form providing view of tables and fields $t = Html::form(array(array("Special Parameters", "section"), array("Logged in User", "static", "user", "{{current_user_id}}"), array("User Roles", "static", "roles", "{{roles}}"), array("Site URL", "static", "webroot", "{{webroot}}"), array("View Database", "section"), array("Tables", "select", "dbtables", null, $w->Report->getAllDBTables()), array("Fields", "static", "dbfields", "<span id='dbfields'></span>"))); $w->ctx("dbform", $t); } else { // redirect on all other occassions $w->msg($rep->title . ": Report has yet to be approved", "/report/index/"); } // Get list of templates $report_templates = $rep->getTemplates(); // Build table $table_header = array("Title", "Category", "Type", "Actions"); $table_data = array(); if (!empty($report_templates)) { // Add data to table layout foreach ($report_templates as $report_template) { $template = $report_template->getTemplate(); $table_data[] = array($template->title, $template->category, $report_template->type, Html::box("/report-templates/edit/{$rep->id}/{$report_template->id}", "Edit", true) . Html::b("/report-templates/delete/{$report_template->id}", "Delete", "Are you sure you want to delete this Report template entry?")); } } // Render table $w->ctx("report", $rep); $w->ctx("templates_table", Html::table($table_data, null, "tablesorter", $table_header)); } else { $f = "Report does not exist"; } } else { $f = "Report does not exist"; } // return the form for display and edit $w->ctx("viewreport", $f); $btnrun = Html::b("/report/runreport/" . $rep->id, " Execute Report "); $w->ctx("btnrun", $btnrun); // tab: view members // see report.lib.php ReportLib::viewMemberstab($w, $p['id']); }
<?php $form['User Details'][] = array(array("Login", "text", "login"), array("Admin", "checkbox", "is_admin"), array("Active", "checkbox", "is_active")); $form['User Details'][] = array(array("Password", "password", "password"), array("Repeat Password", "password", "password2")); $form['Contact Details'][] = array(array("First Name", "text", "firstname"), array("Last Name", "text", "lastname")); $form['Contact Details'][] = array(array("Title", "select", "title", null, lookupForSelect($w, "title")), array("Email", "text", "email")); $roles = $w->Auth->getAllRoles(); $roles = array_chunk($roles, 4); foreach ($roles as $r) { $row = array(); foreach ($r as $rf) { $row[] = array($rf, "checkbox", "check_" . $rf); } $form['User Roles'][] = $row; } print Html::multiColForm($form, $w->localUrl("/admin/useradd"), "POST", "Save");