<?php 

	//$orgunitname = mysql_real_escape_string(stripslashes($_GET['orgunitname']));
	
	// -------------------------------------------	
$whereclause = "";
//if ($orgunitname != NULL) $whereclause .= " AND orgunitname LIKE '%$orgunitname%' ";

//if ($whereclause != "") $whereclause = "WHERE " . substr($whereclause, 0, strlen($whereclause)-5);


$params = "";
//if ($orgunitname != NULL) $params .= "orgunitname=$orgunitname&";
	
// ------------------------------------- PAGE ------------------------------ //
$pagesize = 20;
$start =  (int)$_GET['start'];
	
$limitclause = "LIMIT $start, $pagesize";

// --------------------------------------------------------- Build Paging

$eqcount = nr_execute("SELECT COUNT(*) from orgunit WHERE inactive  <> 1 AND isdeleted <> 1 ");
$pagecount = ceil($eqcount / $pagesize);
$pagenum = floor($start/$pagesize) +1;
$starttext = $start+1;
$endtext = min($start + $pagesize, $eqcount);
$pagedescription = "ຫນ້າທີ $pagenum, ສະແດງລາຍການທີ $starttext ຫາ $endtext, ຈາກທັງຫມົດ $eqcount ລາຍການ";		
		
/*-------------------- select the TO FLOW ------------*/
function manager(){
	return mysql_query("select * from orgunit WHERE inactive  <> 1 AND isdeleted <> 1 AND parentunit = 0 ");
}
function section($m_id){
	return mysql_query("select * from orgunit WHERE inactive  <> 1 AND isdeleted <> 1 AND parentunit = $m_id");
}
function unit($sec_id){
	return mysql_query("select * from orgunit WHERE inactive  <> 1 AND isdeleted <> 1 AND parentunit = $sec_id ");
}

