<?php


function WIEVTABLE_KONTAKTY( $params = array() ) {

	SE_Layout::menu();

	$zasobName = 'ADMIN_USERS';

	$zasobObj = null;
	$db = DB::getDB();
	$sql = "select z.`ID`, z.`DESC`, z.`OPIS`
			, zp.`ID` as P__ID, zp.`DESC` as P__DESC, zp.`TYPE` as P__TYPE
		from `CRM_LISTA_ZASOBOW` as z
			left join `CRM_LISTA_ZASOBOW` as zp on(zp.`ID`=z.`PARENT_ID`)
		where z.`DESC`='{$zasobName}'
			and z.`TYPE`='TABELA'
	";
	$res = $db->query($sql);
	if ($res) {
		$zasobObj = $db->fetch($res);
	}

	if (!$zasobObj) {
		echo "Zasob Kontakty nie został odnaleziony";
		return;
	}

	//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">zasobObj (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($zasobObj);echo'</pre>';

	$userAcl = User::getAcl();
	$userAcl->fetchGroups();
	//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;display:none;">$userAcl (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($userAcl);echo'</pre>';

	if (!$userAcl->hasTableAcl($zasobObj->ID)) {
		die("Brak uprawnień do tabeli ID={$zasobObj->ID}");
	}

	$tblAcl = $userAcl->getTableAcl($zasobObj->ID);
	//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">tblAcl (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($tblAcl);echo'</pre>';

	$forceTblAclInit = ('1' == V::get('_force', '', $_GET));
	$tblAcl->init($forceTblAclInit);

	Lib::loadClass('TableAjax');

	$tbl = new TableAjax($tblAcl);
	$tbl->addRowFunction('edit');
	//$tbl->addRowFunction('hist');
	//$tbl->addRowFunction('files');
	//$tbl->addRowFunction('cp');
	$tbl->addRowFunction('ocena', '<a href="procesy5.php?task=USER_OCENA&_user_id={0}" class="icon-print" title="Ocena pracownika"></a>');
	echo $tbl->render();
}
