Пример #1
0
/**
* Display member and permission infomation
*
* @param <type> $w
*/
function moreInfo_GET(Web &$w)
{
    $option = $w->pathMatch("group_id");
    $w->Admin->navigation($w, $w->Auth->getUser($option['group_id'])->login);
    if ($w->Auth->user()->is_admin || $w->Auth->getRoleForLoginUser($option['group_id'], $w->Auth->user()->id) == "owner") {
        $w->ctx("addMember", Html::box("/admin/groupmember/" . $option['group_id'], "New Member", true));
    }
    $w->ctx("editPermission", Html::b("/admin/permissionedit/" . $option['group_id'], "Edit Permissions"));
    //fill in member table;
    $table = array(array("Name", "Role", "Operations"));
    $groupMembers = $w->Auth->getGroupMembers($option['group_id']);
    if ($groupMembers) {
        foreach ($groupMembers as $groupMember) {
            $line = array();
            $style = $groupMember->role == "owner" ? "<div style=\"color:red;\">" : "<div style=\"color:blue;\">";
            $name = $groupMember->getUser()->is_group == 1 ? $groupMember->getUser()->login : $groupMember->getUser()->getContact()->getFullName();
            $line[] = $style . $name . "</div>";
            $line[] = $style . $groupMember->role . "</div>";
            if ($w->Auth->user()->is_admin || $w->Auth->getRoleForLoginUser($option['group_id'], $w->Auth->user()->id) == "owner") {
                $line[] = Html::a("/admin/memberdelete/" . $option['group_id'] . "/" . $groupMember->id, "Delete", null, null, "Are you sure you want to delete this member?");
            } else {
                $line[] = null;
            }
            $table[] = $line;
        }
    }
    $w->ctx("memberList", Html::table($table, null, "tablesorter", true));
}
Пример #2
0
/**
* Display a list of all groups which are not deleted
*
* @param <type> $w
*/
function groups_GET(Web &$w)
{
    $w->Admin->navigation($w, "Groups");
    $table = array(array("Title", "Parent Groups", "Operations"));
    $groups = $w->Auth->getGroups();
    if ($groups) {
        foreach ($groups as $group) {
            $ancestors = array();
            $line = array();
            $line[] = $w->Auth->user()->is_admin ? Html::box($w->localUrl("/admin/groupedit/" . $group->id), "<u>" . $group->login . "</u>") : $group->login;
            //if it is a sub group from other group;
            $groupUsers = $group->isInGroups();
            if ($groupUsers) {
                foreach ($groupUsers as $groupUser) {
                    $ancestors[] = $groupUser->getGroup()->login;
                }
            }
            $line[] = count($ancestors) > 0 ? "<div style=\"color:green;\">" . implode(", ", $ancestors) . "</div>" : "";
            $operations = Html::b("/admin/moreInfo/" . $group->id, "More Info");
            if ($w->Auth->user()->is_admin) {
                $operations .= Html::b("/admin/groupdelete/" . $group->id, "Delete", "Are you sure you want to delete this group?");
            }
            $line[] = $operations;
            $table[] = $line;
        }
    }
    if ($w->Auth->user()->is_admin) {
        $w->out(Html::box("/admin/groupadd", "New Group", true));
    }
    $w->out(Html::table($table, null, "tablesorter", true));
}
Пример #3
0
function showarchive_ALL(Web $w)
{
    $w->Inbox->navigation($w, "Archive");
    $p = $w->pathMatch('num');
    $num = $p['num'] ? $p['num'] : 1;
    $new_arch = $w->Inbox->getMessages($num - 1, 40, $w->Auth->user()->id, 1, 1);
    $arch = $w->Inbox->getMessages($num - 1, 40, $w->Auth->user()->id, 0, 1);
    $arch_count = $w->Inbox->getArchCount($w->Auth->user()->id);
    $table_header = array("<input style='margin: 0px;' type='checkbox' id='allChk' onclick='selectAll()' />", "Subject", "Date", "Sender");
    $table_data = array();
    if (!empty($new_arch)) {
        foreach ($new_arch as $q) {
            $table_data[] = array("<input style='margin: 0px;' type='checkbox' id='" . $q->id . "' value='" . $q->id . "' class='classChk'/>", Html::a(WEBROOT . "/inbox/view/new/" . $q->id, "<b>" . $q->subject . "</b>"), "<b>" . $q->getDate("dt_created", "d/m/Y H:i") . "</b>", "<b>" . ($q->sender_id ? $q->getSender()->getFullName() : "") . "</b>");
        }
    }
    if (!empty($arch)) {
        foreach ($arch as $q) {
            $table_data[] = array("<input style='margin: 0px;' type='checkbox' id='" . $q->id . "' value='" . $q->id . "' class='classChk'/>", Html::a(WEBROOT . "/inbox/view/read/" . $q->id, $q->subject), "<b>" . $q->getDate("dt_created", "d/m/Y H:i") . "</b>", "<b>" . ($q->sender_id ? $q->getSender()->getFullName() : "") . "</b>");
        }
    }
    $w->ctx("arch_table", Html::table($table_data, null, "tablesorter", $table_header));
    $w->ctx('pgnum', $num);
    $w->ctx("readtotal", $arch_count);
    //    $w->ctx("new_arch", $new_arch);
}
Пример #4
0
/**
 * @hook example_add_row_action(array(<ExampleData> 'data', <String> 'actions')
 * @param Web $w
 */
function index_ALL(Web $w)
{
    // adding data to the template context
    $w->ctx("message", "Example Data List");
    // get the list of data objects
    $listdata = $w->Example->getAllData();
    // prepare table data
    $t[] = array("Title", "Data", "Actions");
    // table header
    if (!empty($listdata)) {
        foreach ($listdata as $d) {
            $row = array();
            $row[] = $d->title;
            $row[] = $d->data;
            // prepare action buttons for each row
            $actions = array();
            if ($d->canEdit($w->Auth->user())) {
                $actions[] = Html::box("/example/edit/" . $d->id, "Edit", true);
            }
            if ($d->canDelete($w->Auth->user())) {
                $actions[] = Html::b("/example/delete/" . $d->id, "Delete", "Really delete?");
            }
            // allow any other module to add actions here
            $actions = $w->callHook("example", "add_row_action", array("data" => $d, "actions" => $actions));
            $row[] = implode(" ", $actions);
            $t[] = $row;
        }
    }
    // create the html table and put into template context
    $w->ctx("table", Html::table($t, "table", "tablesorter", true));
}
Пример #5
0
 /**
  * Displays a table of pages, either for all users or the currently logged in users pages only 
  * based on permissions.
  *
  * Route: admin/pages/manage
  */
 public static function manage()
 {
     // Check if user only has access to their pages
     if (!User::current()->hasPermission('page.manage')) {
         $pages = Page::page()->where('user_id', '=', User::current()->id)->orderBy('title')->all();
     } else {
         $pages = Page::page()->orderBy('title')->all();
     }
     $table = Html::table();
     $header = $table->addHeader();
     $header->addCol('Title');
     $header->addCol('User', array('colspan' => 2));
     if ($pages) {
         MultiArray::load($pages, 'page_id');
         $indentedPages = MultiArray::indent();
         foreach ($indentedPages as $page) {
             $user = User::user()->find($page->user_id);
             $row = $table->addRow();
             $row->addCol(Html::a()->get($page->indent . $page->title, 'admin/page/edit/' . $page->id));
             $row->addCol($user->email);
             $row->addCol(Html::a('Delete', 'admin/page/delete/' . $page->id, array('onclick' => "return confirm('Delete this page? All child pages will be deleted as well.')")), array('class' => 'right'));
         }
     } else {
         $table->addRow()->addCol('<em>No pages</em>', array('colspan' => 2));
     }
     return array('title' => 'Manage Page', 'content' => $table->render());
 }
Пример #6
0
 /**
  * Gets all the log types, checks if their configs are enabled but are not set to write to file
  * and outputs them to the browser in their own tables.
  */
 public static function output()
 {
     foreach (self::$_logs as $type => $logs) {
         if (Config::get(sprintf('log.%s_enabled', $type)) && !Config::get(sprintf('log.%s_to_file', $type))) {
             $table = Html::table(array('border' => '1', 'width' => '100%', 'class' => 'caffeine_' . $type));
             $header = $table->addHeader();
             $header->addCol(strtoupper($type), array('colspan' => 3));
             $titles = $table->addRow();
             $titles->addCol('<strong>Timestamp</strong>');
             $titles->addCol('<strong>Module</strong>');
             $titles->addCol('<strong>Message</strong>');
             if ($logs) {
                 foreach ($logs as $l) {
                     $row = $table->addRow();
                     $row->addCol($l[0]);
                     // Timestamp
                     $row->addCol($l[1]);
                     // Module name
                     $row->addCol($l[2]);
                     // Message
                 }
             } else {
                 $table->addRow()->addCol('<em>No logs.</em>', array('colspan' => 3));
             }
             echo $table->render();
         }
     }
 }
Пример #7
0
function lookup_ALL(Web &$w)
{
    $w->Admin->navigation($w, "Lookup");
    $types = $w->Admin->getLookupTypes();
    $typelist = Html::select("type", $types, $w->request('type'));
    $w->ctx("typelist", $typelist);
    // tab: Lookup List
    $where = array();
    if (NULL == $w->request('reset')) {
        if ($w->request('type') != "") {
            $where['type'] = $w->request('type');
        }
    } else {
        // Reset called, unset vars
        if ($w->request("type") !== null) {
            unset($_REQUEST["type"]);
        }
        var_dump($_REQUEST);
    }
    $lookup = $w->Admin->getAllLookup($where);
    $line[] = array("Type", "Code", "Title", "Actions");
    if ($lookup) {
        foreach ($lookup as $look) {
            $line[] = array($look->type, $look->code, $look->title, Html::box($w->localUrl("/admin/editlookup/" . $look->id . "/" . urlencode($w->request('type'))), " Edit ", true) . "&nbsp;&nbsp;&nbsp;" . Html::b($w->webroot() . "/admin/deletelookup/" . $look->id . "/" . urlencode($w->request('type')), " Delete ", "Are you sure you wish to DELETE this Lookup item?"));
        }
    } else {
        $line[] = array("No Lookup items to list", null, null, null);
    }
    // display list of items, if any
    $w->ctx("listitem", Html::table($line, null, "tablesorter", true));
    // tab: new lookup item
    $types = $w->Admin->getLookupTypes();
    $f = Html::form(array(array("Create a New Entry", "section"), array("Type", "select", "type", null, $types), array("or Add New Type", "text", "ntype"), array("Key", "text", "code"), array("Value", "text", "title")), $w->localUrl("/admin/newlookup/"), "POST", " Save ");
    $w->ctx("newitem", $f);
}
Пример #8
0
function printqueue_GET(Web $w)
{
    $print_folder = FILE_ROOT . "print";
    $path = realpath($print_folder);
    // Check if folder exists
    if ($path === false) {
        // Make print folder (If you specify a full path, use the recursion flag because it seems to crash without it in unix)
        // Other wise you would need to chdir to the parent folder, create and change back to wherever execution currently was at
        mkdir($print_folder, 0777, true);
        $path = realpath($print_folder);
    }
    $exclude = array("THUMBS.db");
    $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
    $table_data = array();
    $table_header = array("Name", "Size", "Date Created", "Actions");
    foreach ($objects as $name => $object) {
        $filename = $object->getFilename();
        // Ignore files starting with '.' and in exclude array
        if ($filename[0] === '.' || in_array($filename, $exclude)) {
            continue;
        }
        $table_data[] = array(Html::a("/uploads/print/" . $filename, $filename), humanReadableBytes($object->getSize()), date("H:i d/m/Y", filectime($name)), Html::box("/admin/printfile?filename=" . urlencode($name), "Print", true) . " " . Html::b("/admin/deleteprintfile?filename=" . urlencode($name), "Delete", "Are you sure you want to remove this file? (This is irreversible)"));
    }
    $w->out(Html::table($table_data, null, "tablesorter", $table_header));
}
Пример #9
0
function viewtaskgrouptypes_ALL(Web $w)
{
    $w->Task->navigation($w, "Manage Task Groups");
    History::add("Manage Task Groups");
    $task_groups = $w->Task->getTaskGroups();
    if ($task_groups) {
        usort($task_groups, array("TaskService", "sortbyGroup"));
    }
    // prepare column headings for display
    $line = array(array("Title", "Type", "Description", "Default Assignee"));
    // if task group exists, display title, group type, description, default assignee and button for specific task group info
    if ($task_groups) {
        foreach ($task_groups as $group) {
            $line[] = array(Html::a(WEBROOT . "/task-group/viewmembergroup/" . $group->id, $group->title), $group->getTypeTitle(), $group->description, $group->getDefaultAssigneeName());
        }
    } else {
        // if no groups for this group type, say as much
        $line[] = array("There are no Task Groups Configured. Please create a New Task Group.", "", "", "", "");
    }
    // display list of task groups in the target task group type
    $w->ctx("dashboard", Html::table($line, null, "tablesorter", true));
    // tab: new task group
    // get generic task group permissions
    $arrassign = $w->Task->getTaskGroupPermissions();
    // unset 'ALL' given all can never assign a task
    unset($arrassign[0]);
    // set Is Task Active dropdown
    $is_active = array(array("Yes", "1"), array("No", "0"));
    $grouptypes = $w->Task->getAllTaskGroupTypes();
    // build form to create a new task group within the target group type
    $f = Html::form(array(array("Task Group Attributes", "section"), array("Task Group Type", "select", "task_group_type", null, $grouptypes), array("Title", "text", "title"), array("Who Can Assign", "select", "can_assign", null, $arrassign), array("Who Can View", "select", "can_view", null, $w->Task->getTaskGroupPermissions()), array("Who Can Create", "select", "can_create", null, $w->Task->getTaskGroupPermissions()), array("Active", "select", "is_active", null, $is_active), array("", "hidden", "is_deleted", "0"), array("Description", "textarea", "description", null, "26", "6"), array("Default Assignee", "select", "default_assignee_id", null, $w->Auth->getUsers())), $w->localUrl("/task-group/createtaskgroup"), "POST", "Save");
    // display form
    $w->ctx("creategroup", $f);
}
Пример #10
0
 /**
  * Displays a form for updating a role name and a table of available permissions that
  * can be checked to add to the role.
  */
 public static function edit($id)
 {
     $role = User::role()->find($id);
     if (isset($_POST['update_role'])) {
         if ($_POST['name'] == $role->name || !User::role()->where('name', 'LIKE', $_POST['name'])->first()) {
             $status = User::role()->where('id', '=', $id)->update(array('name' => $_POST['name']));
             if ($status) {
                 Message::ok('Role updated successfully.');
                 $role->name = $_POST['name'];
                 // Set updated name for form
             } else {
                 Message::info('Nothing changed.');
             }
         } else {
             Message::error('A role with that name is already in use.');
         }
     }
     if (isset($_POST['update_perms'])) {
         User::permission()->where('role_id', '=', $role->id)->delete();
         if (isset($_POST['permissions'])) {
             foreach ($_POST['permissions'] as $permission) {
                 User::permission()->insert(array('role_id' => $id, 'permission' => $permission));
             }
         }
         Message::ok('Permissions updated successfully.');
     }
     $fields[] = array('fields' => array('name' => array('title' => 'Name', 'type' => 'text', 'default_value' => $role->name, 'validate' => array('required')), 'update_role' => array('value' => 'Update Role', 'type' => 'submit')));
     $formHtml = Html::form()->build($fields);
     $table = Html::table();
     $table->addHeader()->addCol('Module Roles', array('colspan' => 2));
     $sortedPermissions = User::getSortedPermissions();
     $setPermissions = User::permission()->where('role_id', '=', $id)->all();
     $tmp = array();
     foreach ($setPermissions as $ap) {
         $tmp[] = $ap->permission;
     }
     $setPermissions = $tmp;
     foreach ($sortedPermissions as $module => $modulePermissions) {
         $nameRow = $table->addRow();
         $nameRow->addCol(sprintf('<strong>%s</strong>', ucfirst($module)), array('colspan' => 2));
         foreach ($modulePermissions as $permission => $desc) {
             $fieldRow = $table->addRow();
             $checked = in_array($permission, $setPermissions) ? ' checked="checked"' : '';
             $fieldRow->addCol('<input type="checkbox" name="permissions[]" value="' . $permission . '"' . $checked . ' />', array('width' => 10));
             $fieldRow->addCol($desc);
         }
     }
     // TODO This is a bit hacky, figure a better way to make tables into forms
     $tableHtml = Html::form()->open(null, 'post', false, array('name' => 'perms', 'id' => 'perms'));
     $tableHtml .= $table->render();
     $tableHtml .= '<div class="buttons">';
     $tableHtml .= '<input type="hidden" name="update_perms" value="true" />';
     $tableHtml .= '<a class="blue btn submitter" href="#">Update Permissions</a>';
     $tableHtml .= '</div>';
     $tableHtml .= Html::form()->close();
     return array(array('title' => 'Edit Role', 'content' => $formHtml), array('title' => 'Edit Role Permissions', 'content' => $tableHtml));
 }
Пример #11
0
function index_GET($w)
{
    $w->Admin->navigation($w, "Templates");
    $templates = $w->Template->findTemplates();
    $table_header = array("Title", "Module", "Category", array("Active?", true), array("Created", true), array("Modified", true), "Actions");
    $table_data = array();
    if (!empty($templates)) {
        foreach ($templates as $t) {
            $table_data[] = array($t->title, $t->module, $t->category, array($t->is_active ? "Active" : "Inactive", true), array(Date("H:i d-m-Y", $t->dt_created), true), array(Date("H:i d-m-Y", $t->dt_modified), true), Html::b("/admin-templates/edit/" . $t->id, "Edit", false));
        }
    }
    $w->ctx("templates_table", Html::table($table_data, null, "tablesorter", $table_header));
}
Пример #12
0
function index_ALL(Web $w)
{
    $connections = $w->Report->getConnections();
    $table_header = array("Driver", "Host", "Database", "Port", "Username", "Actions");
    $table_body = array();
    if (!empty($connections)) {
        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?"));
        }
    }
    $w->ctx("connections_table", Html::table($table_body, null, "tablesorter", $table_header));
}
Пример #13
0
 function render($array)
 {
     if (!is_array($array)) {
         return false;
     }
     $table = '';
     foreach ($array as $name => $value) {
         if (is_array($value)) {
             $table .= Html::tr(Html::td(Html::escape($name)) . Html::td($this->render($value)));
             continue;
         }
         $table .= Html::tr(Html::td($this->html($name)) . Html::td($this->html($value)));
     }
     return Html::table($table);
 }
Пример #14
0
 /**
  * Displays a table of languages to be supported.
  *
  * Route: admin/multilanguage/languages/manage
  */
 public static function manage()
 {
     $table = Html::table();
     $table->addHeader()->addCol('Languages', array('colspan' => 2));
     $langs = Multilanguage::language()->orderBy('name')->all();
     if ($langs) {
         foreach ($langs as $lang) {
             $row = $table->addRow();
             $row->addCol(Html::a()->get($lang->name, 'admin/multilanguage/languages/edit/' . $lang->id));
             $row->addCol(Html::a('Delete', 'admin/multilanguage/languages/delete/' . $lang->id, array('onclick' => "return confirm('Delete this language?')")), array('class' => 'right'));
         }
     } else {
         $table->addRow()->addCol('<em>No languages</em>', array('colspan' => 2));
     }
     return array('title' => 'Manage Languages', 'content' => $table->render());
 }
Пример #15
0
function viewmembergroup_GET(Web $w)
{
    $p = $w->pathMatch("id");
    // tab: Members
    // get all members in a task group given a task group ID
    $member_group = $w->Task->getMemberGroup($p['id']);
    // get the group attributes given a task group ID
    $group = $w->Task->getTaskGroup($p['id']);
    // put the group title into the page heading
    $w->Task->navigation($w, "Task Group - " . $group->title);
    History::add("Task Group: " . $group->title);
    // set columns headings for display of members
    $line[] = array("Member", "Role", "");
    // if their are members, display their full name, role and buttons to edit or delete the member
    if ($member_group) {
        foreach ($member_group as $member) {
            $line[] = array($w->Task->getUserById($member->user_id), $member->role, Html::box(WEBROOT . "/task-group/viewmember/" . $member->id, " Edit ", true) . "&nbsp;&nbsp;" . Html::box(WEBROOT . "/task-group/deletegroupmember/" . $member->id, " Delete ", true));
        }
    } else {
        // if there are no members, say as much
        $line[] = array("Group currently has no members. Please Add New Members.", "", "");
    }
    // enter task group attributes sa query string for buttons providing group specific functions such as delete or add members
    $w->ctx("taskgroup", $group->task_group_type);
    $w->ctx("grpid", $group->id);
    $w->ctx("groupid", $p['id']);
    // display list of group members
    $w->ctx("viewmembers", Html::table($line, null, "tablesorter", true));
    // tab:  Notify
    $notify = $w->Task->getTaskGroupNotify($group->id);
    if ($notify) {
        foreach ($notify as $n) {
            $v[$n->role][$n->type] = $n->value;
        }
    } else {
        $v['guest']['creator'] = 0;
        $v['member']['creator'] = 0;
        $v['member']['assignee'] = 0;
        $v['owner']['creator'] = 0;
        $v['owner']['assignee'] = 0;
        $v['owner']['other'] = 0;
    }
    $notifyForm['Task Group Notifications'] = array(array(array("", "hidden", "task_group_id", $group->id)), array(array("", "static", ""), array("Creator", "static", "creator"), array("Assignee", "static", "assignee"), array("All Others", "static", "others")), array(array("Guest", "static", "guest"), array("", "checkbox", "guest_creator", $v['guest']['creator'])), array(array("Member", "static", "member"), array("", "checkbox", "member_creator", $v['member']['creator']), array("", "checkbox", "member_assignee", $v['member']['assignee'])), array(array("Owner", "static", "owner"), array("", "checkbox", "owner_creator", $v['owner']['creator']), array("", "checkbox", "owner_assignee", $v['owner']['assignee']), array("", "checkbox", "owner_other", $v['owner']['other'])));
    $w->ctx("notifymatrix", Html::multiColForm($notifyForm, $w->localUrl("/task-group/updategroupnotify/"), "POST", " Submit "));
}
Пример #16
0
function read_GET(Web $w)
{
    $w->Inbox->navigation($w, "Read Messages");
    $p = $w->pathMatch('num');
    $num = $p['num'];
    $num ? $num : ($num = 1);
    $read = $w->Inbox->getMessages($num - 1, 40, $w->Auth->user()->id, 0);
    $read_total = $w->Inbox->getReadMessageCount($w->Auth->user()->id);
    $table_header = array("<input style='margin: 0px;' type='checkbox' id='allChk' onclick='selectAll()' />", "Subject", "Date", "Sender");
    $table_data = array();
    foreach ($read as $q => $in) {
        $table_data[] = array("<input style='margin: 0px;' type='checkbox' id='" . $in->id . "' value='" . $in->id . "' class='classChk'/>", Html::a(WEBROOT . "/inbox/view/read/" . $in->id, $in->subject), $in->getDate("dt_created", "d/m/Y H:i"), $in->sender_id ? $in->getSender()->getFullName() : "");
    }
    $w->ctx("read_table", Html::table($table_data, null, "tablesorter", $table_header));
    $w->ctx('pgnum', $num);
    $w->ctx("readtotal", $read_total);
    $w->ctx("read", $read);
}
Пример #17
0
function feed_ALL(Web &$w)
{
    // check for feed key in request
    if (array_key_exists("key", $_REQUEST)) {
        // get feed
        $feed = $w->Report->getFeedInfobyKey($_REQUEST["key"]);
        // if feed, then get respective report details
        if ($feed) {
            $rep = $w->Report->getReportInfo($feed->report_id);
            // if report exists, execute it
            if ($rep) {
                $w->Report->navigation($w, $rep->title);
                // prepare and execute the report
                $tbl = $rep->getReportData();
                // if we have an empty return, say as much
                if (!$tbl) {
                    // return error status?
                } elseif ($tbl[0][0] == "ERROR") {
                    // return error status?
                    $w->ctx("showreport", "error");
                } elseif ($tbl[0][0] == "SUCCESS") {
                    // return error status?
                    $w->ctx("showreport", "success");
                } else {
                    // as a cvs file for download
                    if ($_REQUEST['format'] == "csv") {
                        $w->Report->exportcsv($tbl, $rep->title);
                    } elseif ($_REQUEST['format'] == "pdf") {
                        $w->Report->exportpdf($tbl, $rep->title);
                    } elseif ($_REQUEST['format'] == "xml") {
                        $w->Report->exportxml($tbl, $rep->title);
                    } else {
                        foreach ($tbl as $t) {
                            $crumbs = array_shift($t);
                            $title = array_shift($t);
                            $results .= "<b>" . $title . "</b><p>" . Html::table($t, null, "tablesorter", true);
                        }
                        $w->ctx("showreport", $results);
                    }
                }
            }
        }
    }
}
Пример #18
0
function index_GET(Web &$w)
{
    $w->Inbox->navigation($w, "New Messages");
    // Get current page number
    $p = $w->pathMatch('num');
    $num = !empty($p['num']) ? $p['num'] : 1;
    // Get count of messages and the messages for current page
    $new_total = $w->Inbox->getNewMessageCount();
    $new = $w->Inbox->getMessages($num - 1, 40, $w->Auth->user()->id, 1);
    // Make new message table
    $header = array("<input style='margin: 0px;' type='checkbox' id='allChk' onclick='selectAll()' />", "Subject", "Date", "Sender");
    $data = array();
    foreach ($new as $q => $in) {
        $data[] = array("<input style='margin: 0px;' type='checkbox' id='" . $in->id . "' value='" . $in->id . "' class='classChk'/>", Html::a(WEBROOT . "/inbox/view/new/" . $in->id, "<b>" . $in->subject . "</b>"), $in->getDate("dt_created", "d/m/Y H:i"), $in->sender_id ? $in->getSender()->getFullName() : "");
    }
    $w->ctx('new_table', Html::table($data, null, "tablesorter", $header));
    $w->ctx('pgnum', $num);
    $w->ctx("newtotal", $new_total);
    $w->ctx("new", $new);
}
Пример #19
0
function users_GET(Web &$w)
{
    $w->Admin->navigation($w, "Users");
    $header = array("Login", "First Name", "Last Name", array("Admin", true), array("Active", true), array("Created", true), array("Last Login", true), "Operations");
    //	$result = $w->db->sql("select user.id as id,login,firstname,lastname,is_admin,is_active,user.dt_created as dt_created,dt_lastlogin from user left join contact on user.contact_id = contact.id where user.is_deleted = 0 AND user.is_group = 0")->fetch_all();
    // $result = $w->db->get("user")->select("user.*, contact.*")->leftJoin("contact on user.contact_id = contact.id")->where("user.is_deleted", 0)->where("user.is_group", 0)->fetch_all();
    $users = $w->Admin->getObjects("User", array("is_deleted" => 0, "is_group" => 0));
    $data = array();
    foreach ($users as $user) {
        $contact = $user->getContact();
        $firstName = '';
        $lastName = '';
        if (!empty($contact)) {
            $firstName = $contact->firstname;
            $lastName = $contact->lastname;
        }
        $data[] = array($user->login, $firstName, $lastName, array($user->is_admin ? "X" : "", true), array($user->is_active ? "X" : "", true), array($w->Admin->time2Dt($user->dt_created), true), array($w->Admin->time2Dt($user->dt_lastlogin), true), Html::box($w->localUrl("/admin/useredit/" . $user->id . "/box"), "Edit", true) . Html::b("/admin/permissionedit/" . $user->id, "Permissions") . Html::b($w->localUrl("/admin/userdel/" . $user->id), "Delete", "Are you sure to delete this user?"));
    }
    $w->ctx("table", Html::table($data, null, "tablesorter", $header));
}
Пример #20
0
 /**
  * Displays a table of current users.
  */
 public static function manage()
 {
     $table = Html::table();
     $header = $table->addHeader();
     $header->addCol('Username', array('colspan' => 2));
     $users = User::user()->orderBy('email')->all();
     if ($users) {
         foreach ($users as $user) {
             $row = $table->addRow();
             $row->addCol(Html::a($user->email, 'admin/user/edit/' . $user->id));
             if ($user->is_admin <= 0) {
                 $row->addCol(Html::a('Delete', 'admin/user/delete/' . $user->id), array('class' => 'right', 'onclick' => "return confirm('Delete this user?')"));
             } else {
                 $row->addCol('&nbsp;');
             }
         }
     } else {
         $table->addRow()->addCol('<em>No users</em>', array('colspan' => 2));
     }
     return array('title' => 'Manage Users', 'content' => $table->render());
 }
Пример #21
0
function trash_ALL(Web &$w)
{
    $w->Inbox->navigation($w, 'Bin');
    $p = $w->pathMatch('num');
    $num = $p['num'] ? $p['num'] : 1;
    $read_del = $w->Inbox->getMessages($num - 1, 40, $w->Auth->user()->id, 0, 0, 1);
    //$new_del = $w->Inbox->getMessages(0,100,$w->Auth->user()->id,1,0,1);
    $del_count = $w->Inbox->getDelMessageCount();
    $table_header = array("<input style='margin: 0px;' type='checkbox' id='allChk' onclick='selectAll()' />", "Subject", "Date", "Sender");
    $table_data = array();
    if (!empty($read_del)) {
        foreach ($read_del as $q) {
            $table_data[] = array("<input style='margin: 0px;' type='checkbox' id='" . $q->id . "' value='" . $q->id . "' class='classChk'/>", Html::a(WEBROOT . "/inbox/view/" . $q->id, $q->subject), $q->getDate("dt_created", "d/m/Y H:i"), $q->sender_id ? $q->getSender()->getFullName() : "");
        }
    }
    $w->ctx("del_table", Html::table($table_data, null, "tablesorter", $table_header));
    $w->ctx('del_count', $del_count);
    $w->ctx('pgnum', $num);
    $w->ctx('readdel', $read_del);
    //$w->ctx('newdel',$new_del);
}
Пример #22
0
 static function viewMemberstab(Web &$w, $id)
 {
     // return list of members of given report
     $members = $w->Report->getReportMembers($id);
     // get report details
     $report = $w->Report->getReportInfo($id);
     // set columns headings for display of members
     $line[] = array("Member", "Role", "");
     // if there are members, display their full name, role and button to delete the member
     if ($members) {
         foreach ($members as $member) {
             $line[] = array($w->Report->getUserById($member->user_id), $member->role, Html::box("/report/editmember/" . $report->id . "/" . $member->user_id, " Edit ", true) . "&nbsp;&nbsp;" . Html::box("/report/deletemember/" . $report->id . "/" . $member->user_id, " Delete ", true));
         }
     } else {
         // if there are no members, say as much
         $line[] = array("Group currently has no members. Please Add New Members.", "", "");
     }
     $w->ctx("reportid", $report->id);
     // display list of group members
     $w->ctx("viewmembers", Html::table($line, null, "tablesorter", true));
 }
Пример #23
0
 /**
  * Displays a form for creating a new translation of the current string. Also displays a table
  * of current translations for the current string.
  *
  * Route: admin/multilanguage/strings/manage/:id
  *
  * @param int $id The id of the string to create translations for
  */
 public static function manageContent($id)
 {
     if (!($string = Multilanguage::stringcontent()->find($id))) {
         return ERROR_404;
     }
     if (isset($_POST['create_translation']) && Html::form()->validate()) {
         $tmpId = Multilanguage::string()->insert(array('stringcontent_id' => $string->id, 'language_id' => $_POST['language_id'], 'content' => $_POST['content']));
         if ($tmpId) {
             Message::ok('Translation created successfully.');
             unset($_POST['language_id']);
             // Clear selected language
         } else {
             Message::error('Error creating translation, please try again.');
         }
     }
     $langs = Multilanguage::language()->orderBy('name')->all();
     $sortedLangs = array('' => 'Choose One');
     foreach ($langs as $l) {
         $sortedLangs[$l->id] = $l->name;
     }
     $form[] = array('fields' => array('language_id' => array('title' => 'Language', 'type' => 'select', 'options' => $sortedLangs, 'validate' => array('required')), 'content' => array('title' => 'Translated String', 'type' => strlen($string->content) > 25 ? 'textarea' : 'text', 'validate' => array('required'), 'default_value' => $string->content), 'create_translation' => array('type' => 'submit', 'value' => 'Create Translation')));
     $table = Html::table();
     $header = $table->addHeader();
     $header->addCol('String');
     $header->addCol('Language', array('colspan' => 2));
     $translations = Multilanguage::string()->select('multilanguage_strings.*, multilanguage_languages.name AS language')->leftJoin('multilanguage_languages', 'multilanguage_languages.id', '=', 'multilanguage_strings.language_id')->where('multilanguage_strings.stringcontent_id', '=', $id)->orderBy('multilanguage_languages.name')->all();
     if ($translations) {
         foreach ($translations as $t) {
             $row = $table->addRow();
             $row->addCol(Html::a()->get(String::truncate($t->content, 100, '...'), 'admin/multilanguage/strings/edit/' . $id . '/' . $t->id));
             $row->addCol($t->language);
             $row->addCol(Html::a()->get('Delete', 'admin/multilanguage/strings/delete/' . $id . '/' . $t->id, array('onclick' => "return confirm('Delete this translation?')")), array('class' => 'right'));
         }
     } else {
         $table->addRow()->addCol('<em>No translations.</em>', array('colspan' => 3));
     }
     return array(array('title' => 'Create String Translation', 'content' => Html::form()->build($form)), array('title' => 'Translations', 'content' => $table->render()));
 }
Пример #24
0
function listfeed_ALL(Web &$w)
{
    $w->Report->navigation($w, "Feeds");
    // get all feeds
    $feeds = $w->Report->getFeeds();
    // prepare table headings
    $line = array(array("Feed", "Report", "Description", "Created", ""));
    // if feeds exists and i am suitably authorised, list them
    if ($feeds && ($w->Auth->user()->hasRole("report_editor") || $w->Auth->user()->hasRole("report_admin"))) {
        foreach ($feeds as $feed) {
            // get report data
            $rep = $w->Report->getReportInfo($feed->report_id);
            // display the details
            if ($rep) {
                $line[] = array($feed->title, $rep->title, $feed->description, formatDateTime($feed->dt_created), Html::b(WEBROOT . "/report/editfeed/" . $feed->id, " View ") . Html::b(WEBROOT . "/report/deletefeed/" . $feed->id, " Delete ", "Are you sure you wish to DELETE this feed?"));
            }
        }
    } else {
        // no feeds and/or no access
        $line[] = array("No feeds to list", "", "", "", "");
    }
    // display results
    $w->ctx("feedlist", Html::table($line, null, "tablesorter", true));
}
Пример #25
0
// set task activity heading
$line = array(array("An overview of the activity in Tasks: " . $from . " to " . $to));
if ($tasks) {
    // dont wanna keep displaying same date so set a variable for comparison
    $olddate = "";
    foreach ($tasks as $task) {
        $taskgroup = $w->Task->getTaskGroup($task['task_group_id']);
        $caniview = $taskgroup->getCanIView();
        if ($caniview) {
            // if current task date = previous task date, dont display
            if (formatDate($task['dt_modified']) != $olddate) {
                // if this is not the first record, display emtpy row between date lists
                if ($i > 0) {
                    $line[] = array("&nbsp;");
                }
                // display fancy date
                $line[] = array("<b>" . date("l jS F, Y", strtotime($task['dt_modified'])) . "</b>");
            }
            // display comments. if no group selected, display with link to task list with group preselected
            $thisgroup = $taskgroup != "" ? "" : "<a title=\"View Task Group\" href=\"" . $webroot . "/task/tasklist/?taskgroups=" . $task['task_group_id'] . "\">" . $w->Task->getTaskGroupTitleById($task['task_group_id']) . "</a>:&nbsp;&nbsp;";
            $line[] = array("<dd>" . date("g:i a", strtotime($task['dt_modified'])) . " - " . $thisgroup . "<a title=\"View Task Details\" href=\"" . $webroot . "/task/viewtask/" . $task['id'] . "\"><b>" . $task['title'] . "</b></a>: " . $w->Task->findURL($task['comment']) . " - " . $w->Task->getUserById($task['creator_id']) . "</dd>");
            $olddate = formatDate($task['dt_modified']);
            $i++;
        }
    }
} else {
    // if no tasks found, say as much
    $line[] = array("No Task Activity found for given date span");
}
return Html::table($line, null, "tablesorter", true);
Пример #26
0
function viewtask_GET(Web &$w)
{
    $p = $w->pathMatch("id");
    // declare delete button
    $btndelete = "";
    // get relevant object for viewing a task given input task ID
    $task = $w->Task->getTask($p['id']);
    $w->ctx("task", $task);
    $taskdata = $w->Task->getTaskData($p['id']);
    $group = $w->Task->getTaskGroup($task->task_group_id);
    $w->Task->navigation($w, "View Task: " . $task->title);
    // if task is deleted, say as much and return to task list
    if ($task->is_deleted != 0) {
        $w->msg("This Task has been deleted", "/task/tasklist/");
    } elseif ($task->getCanIView()) {
        History::add("Task: {$task->title}");
        // tab: Task Details
        // if I can assign tasks, provide dropdown of group members else display current assignee.
        // my role in group Vs group can_assign value
        if ($task->getCanIAssign()) {
            $members = $task ? $w->Task->getMembersBeAssigned($task->task_group_id) : $w->Auth->getUsers();
            sort($members);
            $assign = array("Assigned To", "select", "assignee_id", $task->assignee_id, $members);
        } else {
            $assigned = $task->assignee_id == "0" ? "Not Assigned" : $w->Task->getUserById($task->assignee_id);
            $assign = array("Assigned To", "static", "assignee_id", $assigned);
        }
        //		changing type = dymanically loading of relevant form fields ... problem when presenting on single page.
        //		array("Task Type","select","task_type",$task->task_type,$task->getTaskGroupTypes()),
        // check a due date exists
        $dtdue = $task->dt_due == "0000-00-00 00:00:00" || $task->dt_due == "" ? "" : date('d/m/Y', $task->dt_due);
        // Guests can view but not edit
        // See if i am assignee or creator, if yes provide editable form, else provide static display
        $btndelete = "";
        if ($task->getCanIEdit()) {
            $btndelete = Html::b(WEBROOT . "/task/deletetask/" . $task->id, " Delete Task ", "Are you should you with to DELETE this task?");
            // if task is closed and Task Group type says cannot be reopened, display static status
            if ($task->getisTaskClosed() && !$task->getTaskReopen()) {
                $status = array("Status", "static", "status", $task->status);
            } else {
                $status = array("Status", "select", "status", $task->status, $task->getTaskGroupStatus());
            }
            $f = array(array("Task Details", "section"), array("Title", "text", "title", $task->title), array("Created By", "static", "creator", $task->getTaskCreatorName()), array("Task Group", "static", "tg", $task->getTaskGroupTypeTitle()), array("Task Type", "static", "task_type", $task->getTypeTitle()), array("Description", "static", "tdesc", $task->getTypeDescription()), $status, array("Priority", "select", "priority", $task->priority, $task->getTaskGroupPriority()), array("Date Due", "date", "dt_due", $dtdue), array("Description", "textarea", "description", $task->description, "80", "15"), $assign);
        } else {
            $f = array(array("Task Details", "section"), array("Title", "static", "title", $task->title), array("Created By", "static", "creator", $task->getTaskCreatorName()), array("Task Group", "static", "tg", $task->getTaskGroupTypeTitle()), array("Task Type", "static", "task_type", $task->getTypeTitle()), array("Description", "static", "tdesc", $task->getTypeDescription()), array("Status", "static", "status", $task->status), array("Priority", "static", "priority", $task->priority), array("Date Due", "static", "dt_due", $dtdue), array("Description", "static", "description", str_replace("\r\n", "<br>", $task->description)), $assign);
        }
        // got additional form fields for this task type
        $form = $w->Task->getFormFieldsByTask($task->task_type, $group);
        // if there are additional form fields, display them
        if ($form) {
            // string match form fields with task data by key
            // can then push db:value into form field for display
            foreach ($form as $x) {
                if ($x[1] == "section") {
                    array_push($f, $x);
                }
                if ($taskdata) {
                    foreach ($taskdata as $td) {
                        $key = $td->key;
                        $value = $td->value;
                        // Guests can view but not edit
                        // See if i am a guest, if yes provide static display, else provide editable form
                        if (!$task->getCanIEdit()) {
                            $x[1] = "static";
                        }
                        if ($key == $x[2]) {
                            $x[3] = $value;
                            array_push($f, $x);
                        }
                    }
                } else {
                    if ($x[1] != "section") {
                        array_push($f, $x);
                    }
                }
            }
        }
        // create form
        $form = Html::form($f, $w->localUrl("/task/updatetask/" . $task->id), "POST", " Update ");
        // create 'start time log' button
        $buttontimelog = "";
        if ($task->assignee_id == $w->Auth->user()->id) {
            $buttontimelog = new \Html\Button();
            $buttontimelog->href("/task/starttimelog/{$task->id}")->setClass("startTime button small")->text("Start Time Log");
            // $btntimelog = "<button class=\"startTime\" href=\"/task/starttimelog/".$task->id."\"> Start Time Log </button>";
        }
        // display variables
        $w->ctx("btntimelog", !empty($buttontimelog) ? $buttontimelog->__toString() : "");
        $w->ctx("btndelete", $btndelete);
        $w->ctx("viewtask", $form);
        $w->ctx("extradetails", $task->displayExtraDetails());
        // tab: time log
        // provide button to add time entry
        $addtime = "";
        if ($task->assignee_id == $w->Auth->user()->id) {
            $addtime = Html::box(WEBROOT . "/task/addtime/" . $task->id, " Add Time Log entry ", true);
        }
        $w->ctx("addtime", $addtime);
        // get time log for task
        $timelog = $task->getTimeLog();
        // set total period
        $totseconds = 0;
        // set headings
        $line = array(array("Assignee", "Start", "End", "Period (hours)", "Comment", ""));
        // if log exists, display ...
        if ($timelog) {
            // for each entry display, calculate period and display total time on task
            foreach ($timelog as $log) {
                // get time difference, start to end
                $seconds = $log->dt_end - $log->dt_start;
                $period = $w->Task->getFormatPeriod($seconds);
                // if suspect, label button, style period, remove edit button
                if ($log->is_suspect == "1") {
                    $label = " Accept ";
                    $period = "(" . $period . ")";
                    $bedit = "";
                }
                // if accepted, label button, tally period, include edit button
                if ($log->is_suspect == "0") {
                    $label = " Review ";
                    $totseconds += $seconds;
                    $bedit = Html::box($w->localUrl("/task/addtime/" . $task->id . "/" . $log->id), " Edit ", true);
                }
                // ony Task Group owner gets to reject/accept time log entries
                $bsuspect = $w->Task->getIsOwner($task->task_group_id, $_SESSION['user_id']) ? Html::b($w->localUrl("/task/suspecttime/" . $task->id . "/" . $log->id), $label) : "";
                $line[] = array($w->Task->getUserById($log->user_id), $w->Task->getUserById($log->creator_id), formatDateTime($log->dt_start), formatDateTime($log->dt_end), $period, !empty($w->Comment->getComment($log->comment_id)) ? $w->Comment->getComment($log->comment_id)->comment : "", $bedit . Html::b($w->localUrl("/task/deletetime/" . $task->id . "/" . $log->id), " Delete ", "Are you sure you wish to DELETE this Time Log Entry?") . $bsuspect . Html::box($w->localUrl("/task/popComment/" . $task->id . "/" . $log->comment_id), " Comment ", true));
            }
            $line[] = array("", "", "", "<b>Total</b>", "<b>" . $w->Task->getFormatPeriod($totseconds) . "</b>", "");
        } else {
            $line[] = array("No time log entries have been made", "", "", "", "", "");
        }
        // display the task time log
        $w->ctx("timelog", Html::table($line, null, "tablesorter", true));
        // tab: notifications
        // if i am assignee, creator or task group owner, i can get notifications for this task
        if ($task->getCanINotify()) {
            // get User set notifications for this Task
            $notify = $w->Task->getTaskUserNotify($_SESSION['user_id'], $task->id);
            if ($notify) {
                $task_creation = $notify->task_creation;
                $task_details = $notify->task_details;
                $task_comments = $notify->task_comments;
                $time_log = $notify->time_log;
                $task_documents = $notify->task_documents;
            } else {
                // need my role in group
                $me = $w->Task->getMemberGroupById($task->task_group_id, $_SESSION['user_id']);
                // get task creator ID
                $creator_id = $task->getTaskCreatorId();
                // which am i?
                $assignee = $task->assignee_id == $_SESSION['user_id'] ? true : false;
                $creator = $creator_id == $_SESSION['user_id'] ? true : false;
                $owner = $w->Task->getIsOwner($task->task_group_id, $_SESSION['user_id']);
                // get single type given this is specific to a single Task
                if ($assignee) {
                    $type = "assignee";
                } elseif ($creator) {
                    $type = "creator";
                } elseif ($owner) {
                    $type = "other";
                }
                $role = strtolower($me->role);
                if ($type) {
                    // for type, check the User defined notification table
                    $notify = $w->Task->getTaskGroupUserNotifyType($_SESSION['user_id'], $task->task_group_id, $role, $type);
                    // get list of notification flags
                    if ($notify) {
                        if ($notify->value == "1") {
                            $task_creation = $notify->task_creation;
                            $task_details = $notify->task_details;
                            $task_comments = $notify->task_comments;
                            $time_log = $notify->time_log;
                            $task_documents = $notify->task_documents;
                            $task_pages = $notify->task_pages;
                        }
                    }
                }
            }
            // create form. if still no 'notify' all boxes are unchecked
            $f = array(array("For which Task Events should you receive Notification?", "section"));
            $f[] = array("", "hidden", "task_creation", "0");
            $f[] = array("Task Details Update", "checkbox", "task_details", !empty($task_details) ? $task_details : null);
            $f[] = array("Comments Added", "checkbox", "task_comments", !empty($task_comments) ? $task_comments : null);
            $f[] = array("Time Log Entry", "checkbox", "time_log", !empty($time_log) ? $time_log : null);
            $f[] = array("Task Data Updated", "checkbox", "task_data", !empty($task_data) ? $task_data : null);
            $f[] = array("Documents Added", "checkbox", "task_documents", !empty($task_documents) ? $task_documents : null);
            $form = Html::form($f, $w->localUrl("/task/updateusertasknotify/" . $task->id), "POST", "Save");
            // display
            $w->ctx("tasknotify", $form);
        }
    } else {
        // if i cannot view task details, return to task list with error message
        // for display get my role in the group, the group owners, the group title and the minimum membership required to view a task
        $me = $w->Task->getMemberGroupById($task->task_group_id, $_SESSION['user_id']);
        $myrole = !$me ? "Not a Member" : $me->role;
        $owners = $w->Task->getTaskGroupOwners($task->task_group_id);
        // get owners names for display
        $strOwners = "";
        foreach ($owners as $owner) {
            $strOwners .= $w->Task->getUserById($owner->user_id) . ", ";
        }
        $strOwners = rtrim($strOwners, ", ");
        $form = "You must be at least a <b>" . $group->can_view . "</b> of the Task Group: <b>" . strtoupper($group->title) . "</b>, to view tasks in this group.<p>Your current Membership Level: <b>" . $myrole . "</b><p>Please appeal to the group owner(s): <b>" . $strOwners . "</b> for promotion.";
        $w->error($form, "/task/tasklist");
    }
}
Пример #27
0
function edit_GET(Web &$w)
{
    $p = $w->pathMatch("id");
    $w->Report->navigation($w, (!empty($p['id']) ? "Edit" : "Create") . " Report");
    // Get or create report object
    $report = !empty($p['id']) ? $w->Report->getReport($p['id']) : new Report($w);
    if (!empty($p['id']) and empty($report->id)) {
        $w->error("Report not found", "/report");
    }
    if (empty($report)) {
        History::add("Create Report");
    } else {
        History::add("Edit Report: " . $report->title);
    }
    $w->ctx("report", $report);
    // If we're creating this is the table
    $form = array(array((!empty($report->id) ? "Edit" : "Create a New") . " Report", "section"), array("Title", "text", "title", $report->title), array("Module", "select", "module", $report->module, $w->Report->getModules()), array("Description", "textarea", "description", $report->description, "110", "2"), array("Code", "textarea", "report_code", $report->report_code, "110", "22", "codemirror"), array("Connection", "select", "report_connection_id", $report->report_connection_id, $w->Report->getConnections()));
    // DB view table
    $db_table = 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", $db_table);
    if (!empty($report->id)) {
        $btnrun = Html::b("/report/runreport/" . $report->id, "Execute Report");
        $w->ctx("btnrun", $btnrun);
    }
    // Check access rights
    // If user is editing, we need to check multiple things, detailed in the helper function
    if (!empty($report->id)) {
        // Get the report member object for the logged in user
        $member = $w->Report->getReportMember($report->id, $w->Auth->user()->id);
        // Check if user can edit this report
        if (!$w->Report->canUserEditReport($report, $member)) {
            $w->error("You do not have access to this report", "/report");
        }
    } else {
        // If we're creating a report, check that the user has rights
        if ($w->Auth->user()->is_admin == 0 and !$w->Auth->user()->hasAnyRole(array('report_admin', 'report_editor'))) {
            $w->error("You do not have create report permissions", "/report");
        }
    }
    // Access checked and OK, add approval to form only if is report_admin or admin
    if ($w->Auth->user()->is_admin == 1 or $w->Auth->user()->hasRole("report_admin")) {
        $form[0][] = array("Approved", "checkbox", "is_approved", $report->is_approved);
    }
    $w->ctx("report_form", Html::form($form, $w->localUrl("/report/edit/{$report->id}"), "POST", "Save Report"));
    if (!empty($report->id)) {
        // ============= Members tab ===================
        $members = $w->Report->getReportMembers($report->id);
        // set columns headings for display of members
        $line[] = array("Member", "Role", "");
        // if there are members, display their full name, role and button to delete the member
        if ($members) {
            foreach ($members as $member) {
                $line[] = array($w->Report->getUserById($member->user_id), $member->role, Html::box("/report/editmember/" . $report->id . "/" . $member->user_id, " Edit ", true) . Html::box("/report/deletemember/" . $report->id . "/" . $member->user_id, " Delete ", true));
            }
        } else {
            // if there are no members, say as much
            $line[] = array("Group currently has no members. Please Add New Members.", "", "");
        }
        // display list of group members
        $w->ctx("viewmembers", Html::table($line, null, "tablesorter", true));
        // =========== template tab ======================
        $report_templates = $report->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/{$report->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("templates_table", Html::table($table_data, null, "tablesorter", $table_header));
    }
}
Пример #28
0
<?php

echo Html::filter("Filter Tasks", $filter_data, '/' . $redirect, "GET", "Filter", "task_list");
if (!empty($tasks)) {
    $table_header = array("Title", "Created By", "Assigned To", "Group", "Type", "Priority", "Status", "Due");
    $table_data = array();
    // Build table data
    usort($tasks, array("TaskService", "sortTasksbyDue"));
    foreach ($tasks as $task) {
        if ($task->getCanIView()) {
            $table_line = array();
            $table_line[] = Html::a("/task/edit/" . $task->id, $task->title);
            // Append the rest of the data
            $table_line += array(null, $task->getTaskCreatorName(), $w->Task->getUserById($task->assignee_id), $task->getTaskGroupTypeTitle(), $task->getTypeTitle(), $task->priority, $task->status, $task->isTaskLate());
            $table_data[] = $table_line;
        }
    }
    echo Html::table($table_data, null, "tablesorter", $table_header);
} else {
    ?>
    <h3><small>No tasks found.</small></h3>
<?php 
}
Пример #29
0
function edit_GET($w)
{
    $p = $w->pathMatch("id");
    $task = !empty($p["id"]) ? $w->Task->getTask($p["id"]) : new Task($w);
    if (!empty($task->id) && !$task->canView($w->Auth->user())) {
        $w->error("You do not have permission to edit this Task", "/task/tasklist");
    }
    // Get a list of the taskgroups and filter by what can be used
    $taskgroups = array_filter($w->Task->getTaskGroups(), function ($taskgroup) {
        return $taskgroup->getCanICreate();
    });
    $tasktypes = array();
    $priority = array();
    $members = array();
    // Try and prefetch the taskgroup by given id
    $taskgroup = null;
    $taskgroup_id = $w->request("gid");
    if (!empty($taskgroup_id) || !empty($task->task_group_id)) {
        $taskgroup = $w->Task->getTaskGroup(!empty($task->task_group_id) ? $task->task_group_id : $taskgroup_id);
        if (!empty($taskgroup->id)) {
            $tasktypes = $w->Task->getTaskTypes($taskgroup->task_group_type);
            $priority = $w->Task->getTaskPriority($taskgroup->task_group_type);
            $members = $w->Task->getMembersBeAssigned($taskgroup->id);
            sort($members);
        }
    }
    // Create form
    $form = array(!empty($p["id"]) ? "Edit task" : "Create a new task" => array(array(!empty($p["id"]) ? array("Task Group", "text", "-task_group_id_text", $taskgroup->title) : array("Task Group", "autocomplete", "task_group_id", !empty($task->task_group_id) ? $task->task_group_id : $taskgroup_id, $taskgroups), !empty($p["id"]) ? array("Task Type", "select", "-task_type", $task->task_type, $tasktypes) : array("Task Type", "select", "task_type", $task->task_type, $tasktypes)), array(array("Task Title", "text", "title", $task->title), array("Status", "select", "status", $task->status, $task->getTaskGroupStatus())), array(array("Priority", "select", "priority", $task->priority, $priority), array("Date Due", "date", "dt_due", formatDate($task->dt_due)), !empty($taskgroup) && $taskgroup->getCanIAssign() ? array("Assigned To", "select", "assignee_id", $task->assignee_id, $members) : array("Assigned To", "select", "-assignee_id", $task->assignee_id, $members)), array(array("Description", "textarea", "description", $task->description))));
    if (empty($p['id'])) {
        History::add("New Task");
    } else {
        History::add("Task: {$task->title}");
    }
    $w->ctx("task", $task);
    $w->ctx("form", Html::multiColForm($form, $w->localUrl("/task/edit/{$task->id}"), "POST", "Save", "edit_form"));
    //////////////////////////
    // Build time log table //
    //////////////////////////
    $timelog = $task->getTimeLog();
    $total_seconds = 0;
    $table_header = array("Assignee", "Start", "Period (hours)", "Comment", "Actions");
    $table_data = array();
    if (!empty($timelog)) {
        // for each entry display, calculate period and display total time on task
        foreach ($timelog as $log) {
            // get time difference, start to end
            $seconds = $log->dt_end - $log->dt_start;
            $period = $w->Task->getFormatPeriod($seconds);
            $comment = $w->Comment->getComment($log->comment_id);
            $comment = !empty($comment) ? $comment->comment : "";
            $table_row = array($w->Task->getUserById($log->user_id), formatDateTime($log->dt_start), $period, !empty($comment) ? $w->Comment->renderComment($comment) : "");
            // Build list of buttons
            $buttons = '';
            if ($log->is_suspect == "0") {
                $total_seconds += $seconds;
                $buttons .= Html::box($w->localUrl("/task/addtime/" . $task->id . "/" . $log->id), " Edit ", true);
            }
            if ($w->Task->getIsOwner($task->task_group_id, $w->Auth->user()->id)) {
                $buttons .= Html::b($w->localUrl("/task/suspecttime/" . $task->id . "/" . $log->id), empty($log->is_suspect) || $log->is_suspect == "0" ? "Review" : "Accept");
            }
            $buttons .= Html::b($w->localUrl("/task/deletetime/" . $task->id . "/" . $log->id), "Delete", "Are you sure you wish to DELETE this Time Log Entry?");
            $table_row[] = $buttons;
            $table_data[] = $table_row;
        }
        $table_data[] = array("<b>Total</b>", "", "<b>" . $w->Task->getFormatPeriod($total_seconds) . "</b>", "", "");
    }
    // display the task time log
    $w->ctx("timelog", Html::table($table_data, null, "tablesorter", $table_header));
    ///////////////////
    // Notifications //
    ///////////////////
    $notify = null;
    // If I am assignee, creator or task group owner, I can get notifications for this task
    if (!empty($task->id) && $task->getCanINotify()) {
        // get User set notifications for this Task
        $notify = $w->Task->getTaskUserNotify($w->Auth->user()->id, $task->id);
        if (empty($notify)) {
            $logged_in_user_id = $w->Auth->user()->id;
            // Get my role in this task group
            $me = $w->Task->getMemberGroupById($task->task_group_id, $logged_in_user_id);
            $type = "";
            if ($task->assignee_id == $logged_in_user_id) {
                $type = "assignee";
            } else {
                if ($task->getTaskCreatorId() == $logged_in_user_id) {
                    $type = "creator";
                } else {
                    if ($w->Task->getIsOwner($task->task_group_id, $logged_in_user_id)) {
                        $type = "other";
                    }
                }
            }
            if (!empty($type) && !empty($me)) {
                $notify = $w->Task->getTaskGroupUserNotifyType($logged_in_user_id, $task->task_group_id, strtolower($me->role), $type);
            }
        }
        // create form. if still no 'notify' all boxes are unchecked
        $form = array("Notification Events" => array(array(array("", "hidden", "task_creation", "0")), array(array("Task Details Update", "checkbox", "task_details", !empty($notify->task_details) ? $notify->task_details : null), array("Comments Added", "checkbox", "task_comments", !empty($notify->task_comments) ? $notify->task_comments : null)), array(array("Time Log Entry", "checkbox", "time_log", !empty($notify->time_log) ? $notify->time_log : null), array("Task Data Updated", "checkbox", "task_data", !empty($notify->task_data) ? $notify->task_data : null)), array(array("Documents Added", "checkbox", "task_documents", !empty($notify->task_documents) ? $notify->task_documents : null))));
        $w->ctx("tasknotify", Html::multiColForm($form, $w->localUrl("/task/updateusertasknotify/" . $task->id), "POST"));
    }
}
Пример #30
0
function taskweek_ALL(Web &$w)
{
    $w->Task->navigation($w, "");
    // if no group then no group
    $taskgroup = $w->request('taskgroup');
    // if no group member then no group member
    $assignee = $w->request('assignee');
    // if no from date then 7 days ago
    $from = $w->request('dt_from', $w->Task->getLastWeek());
    // if no to date then today
    $to = $w->request('dt_to', date("d/m/Y"));
    // display
    $w->ctx("from", $from);
    $w->ctx("to", $to);
    // get all tasks in my groups answering criteria
    $tasks = $w->Task->getTaskWeek($taskgroup, $assignee, $from, $to);
    // set task activity heading
    $line = array(array("An overview of the activity in Tasks: " . $from . " to " . $to));
    if ($tasks) {
        // dont wanna keep displaying same date so set a variable for comparison
        $olddate = "";
        $i = 0;
        foreach ($tasks as $task) {
            $taskgroup = $w->Task->getTaskGroup($task['task_group_id']);
            $caniview = $taskgroup->getCanIView();
            if ($caniview) {
                // if current task date = previous task date, dont display
                if (formatDate($task['dt_modified']) != $olddate) {
                    // if this is not the first record, display emtpy row between date lists
                    if ($i > 0) {
                        $line[] = array("&nbsp;");
                    }
                    // display fancy date
                    $line[] = array("<b>" . date("l jS F, Y", strtotime($task['dt_modified'])) . "</b>");
                }
                // display comments. if no group selected, display with link to task list with group preselected
                $thisgroup = $taskgroup != "" ? "" : "<a title=\"View Task Group\" href=\"" . WEBROOT . "/task/tasklist/?taskgroups=" . $task['task_group_id'] . "\">" . $w->Task->getTaskGroupTitleById($task['task_group_id']) . "</a>:&nbsp;&nbsp;";
                $line[] = array("<dd>" . date("g:i a", strtotime($task['dt_modified'])) . " - " . $thisgroup . "<a title=\"View Task Details\" href=\"" . WEBROOT . "/task/edit/" . $task['id'] . "\"><b>" . $task['title'] . "</b></a>: " . $w->Task->findURL($task['comment']) . " - " . $w->Task->getUserById($task['creator_id']) . "</dd>");
                $olddate = formatDate($task['dt_modified']);
                $i++;
            }
        }
    } else {
        // if no tasks found, say as much
        $line[] = array("No Task Activity found for given selections.");
    }
    // display
    $lines = Html::table($line, null, "tablesorter", true);
    $w->ctx("taskweek", $lines);
    // get list of groups of which i am a member
    $mygroups = $w->Task->getMemberGroups($_SESSION['user_id']);
    if ($mygroups) {
        foreach ($mygroups as $mygroup) {
            $taskgroup = $w->Task->getTaskGroup($mygroup->task_group_id);
            $caniview = $taskgroup->getCanIView();
            if ($caniview) {
                $group[$mygroup->task_group_id] = array($w->Task->getTaskGroupTitleById($mygroup->task_group_id), $mygroup->task_group_id);
                // for those groups of which i am a member, get list of all members for display in Assignee & Creator dropdowns
                $mymembers = $w->Task->getMembersInGroup($mygroup->task_group_id);
                foreach ($mymembers as $mymem) {
                    $members[$mymem[1]] = array($mymem[0], $mymem[1]);
                }
            }
        }
        sort($members);
    }
    // load the search filters
    $a = Html::select("assignee", $members, $w->request('assignee'));
    $w->ctx("assignee", $a);
    $taskgroups = Html::select("taskgroup", $group, $w->request('taskgroup'));
    $w->ctx("taskgroups", $taskgroups);
}