function tableTitle($title)
{
    $sort = getSort();
    $field = strtolower(str_replace(' ', '_', $title));
    $page = getPageNumber();
    $sortDir = getSortDir($field);
    $sortChar = !empty($sort) ? 1 : '';
    return '<a href="?page=' . $page . '&sort=' . $field . '&sortDir=' . $sortDir . '">' . $title . '</a>';
}
 public function listUsers()
 {
     //Variables
     $users = DB::table('user');
     $sort = getSort();
     $search = Input::get('search');
     //Search
     if (!empty($search)) {
         $users = $users->where('first_name', 'LIKE', "%{$search}%")->orWhere('last_name', 'LIKE', "%{$search}%");
     }
     //Sort
     if (!empty($sort)) {
         $users = $users->orderBy($sort, getSortDir());
     }
     //Paginate
     $users = $users->paginate($this->pageSize);
     //Return ViewData
     return view('users', ['sort' => $sort, 'users' => $users, 'pageNum' => getPageNumber(), 'sortDir' => getSortDir(), 'detailsURL' => '/public/user-info/']);
 }
		'left fc-16',
		'',
		),
		
	);
*/
if (isAdmin()) {
    $parent = '';
} elseif (isManager() or isGridManager()) {
    $parent = 'AND needy.user_parent = ' . CUSER;
    /*elseif(isGridManager()) :
    		$children = array();
    		foreach(listData('users', 'user_acctype = 1 AND user_active = 1 AND user_parent = '.CUSER) as $child) $children[] = 'needy.user_parent = '.$child['user_id'];
    		$parent = 'AND (('.implode(' OR ', $children).') OR needy.user_parent_ta = '.CUSER.')';*/
}
getSort('need_id');
$where = 'SELECT need_id, need_name, cat_name, user_fname, user_lname, user_orgname, need_expires, need_desc, need_regdate, a.deleted AS deleted FROM (SELECT need_id, need_name, cat_name, need_type, need_needy, need_expires, need_desc, need_regdate, needs.deleted AS deleted FROM needs LEFT JOIN cats ON needs.need_cat = cats.cat_id WHERE needs.need_type=' . subpage() . ' AND needs.need_full=0) a LEFT JOIN needy ON a.need_needy = needy.user_id WHERE a.need_type=' . subpage() . ' ' . $parent . ' ORDER BY ' . $getsort . $getorder;
/*
	$sortby = array(0 => 'need_id', 1 => 'need_name', 2 => 'cat_name', 3 => 'user_fname', 4 => 'user_lname', 5 => 'user_orgname', 6 => 'need_regdate');*/
formatTable(listData(false, false, pageNum(), $where), $tablefields, $tablehead, $sortby, true, 'nomargin');
pagination(countData(false, false, $where));
$poreikis = array(1 => 'darbo', 2 => 'daikto');
?>

<br><br>
<a href="?p=editneed&type=<?php 
echo subpage();
?>
&subp=<?php 
echo subpage();
?>
<?php

if ($login->isUserLoggedIn() == false) {
    return;
}
if (!isAdmin() and !(isCustom() and haveRight(6))) {
    return;
}
if (isAction('salinti') and getParam()) {
    $row = getRow('pages', 'page_id = ' . getParam());
    $act = $row['deleted'];
    $act = !$act;
    updateFieldWhere('pages', 'deleted', $act, 'page_id = ' . getParam());
    redirect(0, getCurrentLink());
}
$tablefields = array('page_id', 'page_name', 'page_modified', array('converter' => array('page_id', 'getPageEditLink')), array('convArray' => array(array('page_slug', 'page_site'), 'getPageLinks')), array('action' => array('page_id', 'salinti', '<i title="Šalinti/atnaujinti" class="fa fa-times"></i>', false)), 'null');
$tablehead = array('titles' => array('ID', 'Pavadinimas', 'Modifikuotas', '', '', '', ''), 'columns' => array('right fc-60', 'left fc-verylong', 'left fc-150', 'left fc-18', 'left fc-30', 'left fc-16', ''));
getSort('page_id');
$where = 'SELECT * FROM pages WHERE page_type = 0 ORDER BY ' . $getsort . $getorder;
$sortby = array(0 => 'page_id', 1 => 'page_name', 2 => 'page_modified');
formatTable(listData(false, false, pageNum(), $where), $tablefields, $tablehead, $sortby, true, 'nomargin');
pagination(countData(false, false, $where));
?>

<br><br>
<a href="?p=editpage"><i class="fa fa-asterisk"></i> Sukurti puslapį</a>
            $children[] = 'needy.user_parent = ' . $child['user_id'];
        }
        $parent = '((' . implode(' OR ', $children) . ') OR needy.user_parent_ta = ' . CUSER . ')';
        if (countData(false, false, "SELECT * FROM needs INNER JOIN needy ON needs.need_needy = needy.user_id WHERE needs.need_id = " . getParam() . " AND " . $parent) == 0) {
            err('Neturite teisės keisti šio poreikio duomenis', 'red');
            return;
        }
    }
    $row = getRow('needs', 'need_id = ' . getParam());
    $act = $row['need_full'];
    $act = !$act;
    updateFieldWhere('needs', 'need_full', $act, 'need_id = ' . getParam());
    redirect(0, getCurrentLink());
}
$tablefields = array('need_id', 'need_name', 'need_full_desc', 'need_regdate', array('converter' => array('need_id', 'getThingEditLink')), array('action' => array('need_id', 'atkurti', '<i title="Patenkintą poreikį padaryti nepatenkintu ir grąžinti į Poreikių lentelę" class="fa fa-undo"></i>', false)), 'null');
$tablehead = array('titles' => array('ID', 'Pavadinimas', 'Aprašymas', 'Modifikuotas', '', '', ''), 'columns' => array('right fc-60', 'left fc-150', 'left fc-300', 'left fc-dates', 'left fc-16', 'left fc-16', ''));
if (isAdmin()) {
    $parent = '';
} elseif (isManager() or isGridManager()) {
    $parent = 'AND needy.user_parent = ' . CUSER;
    /*elseif(isGridManager()) :
    		$children = array();
    		foreach(listData('users', 'user_acctype = 1 AND user_active = 1 AND user_parent = '.CUSER) as $child) $children[] = 'needy.user_parent = '.$child['user_id'];
    		$parent = 'AND (('.implode(' OR ', $children).') OR needy.user_parent_ta = '.CUSER.')';*/
}
getSort('need_fulldate');
$where = 'SELECT need_fulldate, need_full_desc, need_needy, need_id, need_name, cat_name, user_fname, user_lname, need_regdate, a.deleted AS deleted FROM (SELECT need_fulldate, need_full_desc, need_id, need_name, cat_name, need_type, need_needy, need_regdate, needs.deleted AS deleted FROM needs LEFT JOIN cats ON needs.need_cat = cats.cat_id WHERE needs.need_type=' . subpage() . ' AND needs.need_full=1) a LEFT JOIN needy ON a.need_needy = needy.user_id WHERE a.need_type=' . subpage() . ' ' . $parent . ' ORDER BY ' . $getsort . $getorder;
$sortby = array(0 => 'need_id', 1 => 'need_name', 3 => 'need_regdate');
formatTable(listData(false, false, pageNum(), $where), $tablefields, $tablehead, $sortby, true, 'nomargin');
pagination(countData(false, false, $where));
$poreikis = array(1 => 'darbų', 2 => 'daiktų');
    if (isset($_POST['reason']) or $act == 0) {
        updateFieldWhere('needy', 'deleted', $act, 'user_id = ' . getParam());
        if (isset($_POST['reason']) and ($_POST['reason'] == 1 or $_POST['reason'] == 2 or $_POST['reason'] == 3)) {
            updateFieldWhere('needy', 'delreason', $_POST['reason'], 'user_id = ' . getParam());
        }
        redirect(0, getCurrentLink());
        return;
    }
    ?>
	<form class="simpleform" action="" method="POST">
		Pažymėkite šalinimo priežastį:<br><br>
			<input checked="checked" name="reason" type="radio" value="1" />nebereikalinga parama/pagalba<br>
			<input name="reason" type="radio" value="2" />privatumo problema<br>
			<input name="reason" type="radio" value="3" />pastebėtas sukčiavimas<br>
		<br><input type="submit" value="Siųsti" />
	</form>
	<?php 
    return;
}
$tablefields = array('user_id', array('converter' => array('user_thumb', 'getThumb')), 'user_fname', 'user_lname', 'user_orgname', 'user_phone', array('converter' => array('user_city', 'getCountry')), 'kuratorius', array('converter' => array('user_id', 'getNeedyEditLink')), array('action' => array('user_id', 'salinti', '<i title="Šalinti/atnaujinti" class="fa fa-times"></i>', false)), 'null');
$tablehead = array('titles' => array('ID', '', 'Vardas', 'Pavardė', 'Organizacija', 'Telefonas', 'Savivaldybė', 'Kuratorius', '', '', ''), 'columns' => array('right fc-60', 'left fc-30', 'left fc-75', 'left fc-100', 'left fc-100', 'left fc-90', 'left fc-125', 'left fc-125', 'left fc-16', 'left fc-16', ''));
$children = array();
foreach (listData('users', 'user_acctype = 1 AND user_active = 1 AND user_parent = ' . CUSER) as $child) {
    $children[] = 'needy.user_parent = ' . $child['user_id'];
}
$parent = 'AND ((' . implode(' OR ', $children) . ') OR user_parent_ta = ' . CUSER . ')';
getSort('user_id');
$where = 'SELECT needy.user_id, needy.user_thumb, needy.user_fname, needy.user_lname, needy.user_orgname, needy.user_phone, needy.user_city, needy.deleted, CONCAT(users.user_fname, " ", users.user_lname) as kuratorius FROM needy LEFT JOIN users ON needy.user_parent = users.user_id WHERE user_type=0 ' . $parent . ' ORDER BY ' . $getsort . $getorder;
$sortby = array(0 => 'user_id', 2 => 'user_fname', 3 => 'user_lname', 4 => 'user_orgname', 5 => 'user_phone', 6 => 'user_city', 7 => 'kuratorius');
formatTable(listData(false, false, pageNum(), $where), $tablefields, $tablehead, $sortby, true, 'nomargin');
pagination(countData(false, false, $where));
<?php

if ($login->isUserLoggedIn() == false) {
    return;
}
if (!isAdmin() and !isManager() and !isGridManager()) {
    return;
}
$tablefields = array('obj_type', 'obj_name', 'obj_desc', array('convArray' => array(array('obj_type', 'obj_id'), 'getSearchLink')), 'null');
$tablehead = array('titles' => array('Tipas', 'Rezultatas', 'Kita informacija', '', ''), 'columns' => array('left fc-150', 'left fc-150', 'left fc-300', 'left fc-16', ''));
$term = isset($_GET['srch']) ? $_GET['srch'] : '';
if ($term == '' or strlen($term) < 3) {
    err('Per trumpa paieškos užklausa');
    return;
}
getSort('obj_id');
$where = "\n\tSELECT user_id AS obj_id, 'Vartotojas' AS obj_type, CONCAT(user_fname, ' ', user_lname, ' ', user_orgname) AS obj_name, CONCAT('Paskyros vardas: ', user_name,', el. paštas: ', user_email, ', telefonas: ', user_phone) AS obj_desc FROM users WHERE user_name LIKE ('%{$term}%') OR user_fname LIKE ('%{$term}%') OR user_lname LIKE ('%{$term}%') OR user_orgname LIKE ('%{$term}%') OR user_phone LIKE ('%{$term}%') OR user_email LIKE ('%{$term}%')\n\tUNION\n\tSELECT user_id AS obj_id, 'Stokojantysis' AS obj_type, CONCAT(user_fname, ' ', user_lname, ' ', user_orgname) AS obj_name, CONCAT('El. paštas: ', user_email, ', telefonas: ', user_phone) AS obj_desc FROM needy WHERE user_fname LIKE ('%{$term}%') OR user_lname LIKE ('%{$term}%') OR user_orgname LIKE ('%{$term}%') OR user_phone LIKE ('%{$term}%') OR user_email LIKE ('%{$term}%')\n\tUNION\n\tSELECT need_id AS obj_id, 'Dovanotojas/geradarys' AS obj_type, CONCAT(user_fname, ' ', user_lname) AS obj_name, CONCAT('El. paštas: ', user_email, ', telefonas: ', user_phone) AS obj_desc FROM needs WHERE user_fname LIKE ('%{$term}%') OR user_lname LIKE ('%{$term}%') OR user_phone LIKE ('%{$term}%') OR user_email LIKE ('%{$term}%')\n\tUNION\n\tSELECT need_id AS obj_id, 'Daiktas/darbas' AS obj_type, need_name AS obj_name, need_desc AS obj_desc FROM needs WHERE need_name LIKE ('%{$term}%')\n\t";
$sortby = false;
formatTable(listData(false, false, pageNum(), $where), $tablefields, $tablehead, $sortby, true, 'nomargin');
pagination(countData(false, false, $where));