Ejemplo n.º 1
0
    db_delete('organizations', $_GET['delete_id']);
    url_drop('delete_id,action');
}
echo drawTop();
if (url_id()) {
    //form
    $f = new form('organizations', @$_GET['id']);
    $f->set_field(array('type' => 'text', 'name' => 'title' . langExt(), 'label' => getString('title')));
    langUnsetFields($f, 'title');
    langTranslateCheckbox($f);
    echo $f->draw();
} else {
    //modules list
    $t = new table('organizations', drawHeader());
    $t->set_column('draggy', 'd', ' ');
    $t->set_column('title', 'l', getString('title'));
    $t->set_column('delete', 'd', ' ');
    $result = db_table('SELECT id, title' . langExt() . ' title FROM organizations WHERE is_active = 1 ORDER BY precedence');
    foreach ($result as &$r) {
        $r['draggy'] = draw_img('/images/icons/move.png');
        $r['title'] = draw_link('organizations.php?id=' . $r['id'], $r['title']);
        $r['delete'] = drawColumnDelete($r['id']);
    }
    echo $t->draw($result, 'No organizations');
    //add new
    $f = new form('organizations');
    $f->set_field(array('type' => 'text', 'name' => 'title' . langExt(), 'label' => getString('title')));
    langUnsetFields($f, 'title');
    echo $f->draw(false, false);
}
echo drawBottom();
Ejemplo n.º 2
0
function drawStaffList($where, $errmsg = false, $options = false, $listtitle = false, $searchterms = false)
{
    global $page, $_josh;
    if (!$errmsg) {
        $errmsg = getString('results_empty');
    }
    //only show delete for admins on pages that aren't the chagnes page
    $showDelete = $page['is_admin'] && $page['id'] != 35;
    $t = new table('staff', drawHeader($options, $listtitle));
    $t->set_column('pic', 'c', ' ', 50);
    $t->set_column('name', 'l', getString('name') . (getOption('staff_showoffice') ? ' / ' . getString('location') : ''));
    $t->set_column('title', 'l', getString('staff_title') . ' / ' . (getOption('staff_showdept') ? getString('department') : getString('organization')), 222);
    $t->set_column('phone', 'l', getString('telephone'));
    if ($showDelete) {
        $t->set_column('del', 'c', ' ', 16);
    }
    $result = db_table('SELECT DISTINCT
							u.id, 
							u.lastname,
							ISNULL(u.nickname, u.firstname) firstname, 
							u.bio, 
							u.phone,
							c.title' . langExt() . ' organization,
							u.organization_id,
							o.name office, 
							o.isMain,
							u.title, 
							d.departmentName department
						FROM users u
						LEFT JOIN users_to_channels u2c ON u.id = u2c.user_id
						LEFT JOIN departments d	ON d.departmentID = u.departmentID 
						LEFT JOIN organizations c ON u.organization_id = c.id
						LEFT JOIN offices o ON o.id = u.officeID
						' . getChannelsWhere('users', 'u', 'user_id') . ' AND ' . $where . '
						ORDER BY u.lastname, ISNULL(u.nickname, u.firstname)');
    foreach ($result as &$r) {
        $link = '/staff/view.php?id=' . $r['id'];
        $r['pic'] = draw_img(file_dynamic('users', 'image_small', $r['id'], 'jpg'), $link);
        $r['name'] = draw_link($link, $r['lastname'] . ', ' . $r['firstname']);
        if (getOption('staff_showoffice')) {
            $r['name'] .= '<br/>' . $r['office'];
        }
        if (getOption('staff_showdept')) {
            $r['title'] .= '<br/>' . $r['department'];
        } else {
            $r['title'] .= '<br/>' . draw_link('organizations.php?id=' . $r['organization_id'], format_string($r['organization']));
        }
        if ($showDelete) {
            $r['del'] = drawColumnDelete($r['id']);
        }
    }
    return $t->draw($result, $errmsg);
}