<?php
/**
 * admin_list_view.php - User Search file. TODO: FILE IS OBSOLETE.
 *
 * @author $Author: dtong $
 * @version $Id: admin_list_view.php,v 1.28 2011/04/05 15:18:44 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
*/
return;

$sortup_url = osa_imagepath() . 'arrow_up.gif';
$sortdown_url = osa_imagepath() . 'arrow_down.gif';
$update_url = base_url().'search/sort/get_nohandle/sort/';

$page = $display->page;
$listitem = $display->listitem;
$selectlistitem = $display->selectlistitem;

$href = base_url();
$refresh = base_url().$page.'/refresh/';
$search = base_url().$page.'/search/';
$filter  = base_url().$page.'/filter/';
$imgreq = 'search.gif';
$img_req = "<img src=". osa_imagepath() . "$imgreq    title='Required field'   alt='Required field'    border='0' >";

$display->reset();
$count = $display->total;
if ( isset($count)==FALSE )  {
	 echo lang('user_error_nodata');
  	 return;
}
//echo "lnkdiv           : $display->lnkdiv <br />";
//echo "screen id(divid) : {$display->divid}_list (session)<br />";
//echo "type             : $display->type <br />";

if (isset($display->selectid))
	$selectid = $display->selectid;
else
	$selectid = 0;

if(is_array($display->strand)==FALSE){
	$display->strand=array();
}
if(is_array($display->standard)==FALSE){
	$display->standard=array();
}

if(is_array($display->data_dep_sch)==FALSE){
	$display->data_dep_sch=array();
}

$formname = 'admin_search_form_'.$display->divid.'_'.$display->type;

if (!isset($display->filter_key_1)) {
	$display->filter_key_1 = '';
}
if (!isset($display->filter_key_2)) {
	$display->filter_key_2 = '';
}
?>
<form method="POST"  name="<?php echo $formname;?>" >
<input type='hidden' value='<?php echo $display->filter_key_1;?>' name='filter_key_1' />
<input type='hidden' value='<?php echo $display->filter_key_2;?>' name='filter_key_2' />
<center>
<div class="admin_list_title"><?php echo $display->pagetitle;?></div>

<table class="admin_list_table"  border="0">
<tr>
<td align="right" colspan=2 >
<?php
	if ($display->refresh!='page_content'){
?>
	<div>
	<input type="submit" value="<?php echo lang('admin_btn_close'); ?>" name="close" <?php osa_btn()?>
		onClick="closeDhtmlWindow('<?php echo $display->refresh; ?>');return false;" />
	</div>
<?php } ?>
</td>
</tr>
<?php if ($listitem!=FALSE) { ?>
	<?php if ( !isset($not_show_filter_selection) || !$not_show_filter_selection) { ?>
	<tr>
		<td class="admin_list_filter"><nobr><?php echo lang('admin_list_listitem'); ?></nobr></td>
		<td>
		<?php
			$jscript_sel = "onChange=\"select_listitem(this,'$refresh', '$formname', '$display->refresh','$display->type');  return false; \"";
		  	//echo form_dropdown("filters", $display->strand, $selectid, "size=1  style=width:40% " . " $jscript_sel ");
			echo form_dropdown("filters", $listitem, $selectlistitem, "size=1  " . "  $jscript_sel");
			//echo form_dropdown("id", $listitem, $selectlistitem, "size=1  " . "  onChange='javascript:select_listitem(this,\"$refresh\")'");
		?>
		</td>
	</tr>
	<?php }?>
<?php
if ($display->menu==lang('admin_menu_strand') ||$display->menu==lang('admin_menu_standard') ||
	 $display->menu==lang('admin_menu_benchmark') || $display->menu==lang('admin_menu_eq') ) {
?>
<tr>
<td class="admin_list_filter"><nobr><?php echo $display->search_dep_sch; ?></nobr></td>
<td>
<?php

	$url = $refresh."$display->enableflag/$display->type/$display->refresh";
	$jscript_sel = "onChange=\"select_listitem(this,'$url', '$formname', '$display->refresh','$display->type');  return false; \"";
	echo form_dropdown("dep_schid", $display->data_dep_sch, $display->dep_schid, "size=1  style=width:30% " . " $jscript_sel ");
	// onChange='javascript:search_filter(\"$search\", \"$filter\", \"admin_search_form\")'");
?>
</td>
</tr>
<?php }
		if ($display->menu==lang('admin_menu_standard') || $display->menu==lang('admin_menu_benchmark') ){ ?>
<tr>
<td class="admin_list_filter"><nobr><?php echo lang('admin_standard_searchestrand').':'; ?></nobr></td>
<td>
<?php
	$url = $refresh."$display->enableflag/$display->type/$display->refresh";
	$jscript_sel = "onChange=\"select_listitem(this,'$url', '$formname', '$display->refresh','$display->type');  return false; \"";
	echo form_dropdown("strandids", $display->strand, $selectid, "size='1'  style='width:40%' " . " $jscript_sel ");
	// onChange='javascript:search_filter(\"$search\", \"$filter\", \"admin_search_form\")'");
?>
</td>
</tr>
<?php } ?>
<?php
if ($display->menu==lang('admin_menu_benchmark') ){
?>
<tr>
<td class="admin_list_filter"><nobr><?php echo lang('admin_standard_searchestandard').':'; ?></nobr></td>
<td>
<?php
	$url = $refresh."$display->enableflag/$display->type/$display->refresh";
	$jscript_sel = "onChange=\"select_listitem(this,'$url', '$formname', '$display->refresh','$display->type');  return false; \"";
	echo form_dropdown("standardid", $display->standard, $display->selectstandardid, "size='1'  style='width:450px' " . " $jscript_sel ");

	//$url = $refresh."FALSE/$display->type/$display->refresh";
	//$jscript_sel = "onChange=\"updateWindow('$url', '$formname', '', '$display->refresh');  return false; \"";
	//echo form_dropdown("standardid", $display->standard, $display->selectstandardid, "size=1  style=width:70% " . " $jscript_sel ");
	//echo form_dropdown("standardid", $display->standard, $display->selectstandardid, "size=1 style=width:70% " . "  onChange='javascript:refresh_page(this,\"$filter\")'");
?>
</td>
</tr>
<?php }
			} // if ($listitem!=FALSE) ?>
	<?php //Search text box. Don't display this if the search title text is empty
		if ( !isset($not_show_search_box) || !$not_show_search_box ) { ?>
	<tr>
		<td class="admin_list_filter"><nobr><span><?php echo $display->search; ?></span></nobr></td>
		<td valign="middle" >
			<table>
			<tr>
				<td>
				<input type=text name=filter value="<?php echo $display->filter;?>" size=40
			 			 onkeydown="if (event.keyCode == 13) { document.getElementById('button_search').focus();  }" />
						<?php
							$jscript_search = "onClick='search_filter(\"$search\", \"$refresh\", \"$formname\", \"$display->refresh\"); return false;'";
						?>
				</td>
				<td>
				<input id="button_search" type="button"
						 value="<?php echo lang('admin_list_button_search'); ?>"
						 name="button_search" <?php osa_btn(); echo $jscript_search; ?> />
				</td>
			</tr>
			</table>
		</td>
	</tr>
	<?php } ?>
	<?php if ( !isset($not_show_item_found) || !$not_show_item_found ) {?>
		<tr>
			<td><nobr>
		 		<?php echo $count; ?> <?php echo lang('admin_list_count'); ?>
			</nobr></td>
		</tr>
	<?php } ?>
</table>

<table class="admin_list_table"  border="1">
<tr class="table_head_col">
<?php

	$tdwidths = array();
	foreach ($display->titles as $key => $title) {

		$width = $display->widths[$key];
		if ( $width != '' )
			$width = "width=\"$width%\"";
		else
			$width='';
		$tdwidths[$key] = $width;

		$url   = $update_url . $display->searchid .'/'.$key.'/'.$display->image_sort.'/'.$display->paging.'/'.$display->current_page;//$display->image_sort;
		//page_content
		if ($display->refresh=='page_content')
		$click = "onClick=\"ajaxGetpage('page_content','$url',false); return false;\"";
		else
		$click = "onClick=\"updateWindow('$url','$display->refresh','', '$display->refresh'); return false;\"";

		$imgsrc  = $sortdown_url;
		if ($display->image_sort == 0)
			$imgsrc  = $sortup_url;
		$colspan = '';
		$img     = '';
		if ($display->default_col==$key){
			$img = "<img src='$imgsrc' class='searchsort_button_image' title='sort' />";
		}
		if (is_array($title)==FALSE)
		    $sort = "<a title='sort' href='$url' $click ><nobr>$title $img</nobr></a>";
		else {
			$sort = "<a title='sort' href='$url' $click ><nobr>$title[0] $img</nobr></a>";
			$colspan = "colspan='".$title['_colspan']."'";
		}

		if ( !$display->sort_columns ) {
			$sort = $title;
		}

		echo "<td $colspan {$width} class=\"map_restitle\">$sort</td>";

	}
	echo "</tr>";

	$colortrack=FALSE;
	$trclass = $trclass1 = 'table_body_row';
	$trclass2 = 'table_body_row_none';
	while ( ($node = $display->next()) !== FALSE)  {
		if ( $display->colortrack ) {
			if (!$colortrack)
				$trclass = $trclass1;
			else
				$trclass = $trclass2;
			$colortrack = !$colortrack;
		}
		echo "<tr class='$trclass'>";
		foreach ($node as $key => $value) {
			echo "<td  class=\"map_resitem\">$value</td>";
		}
		echo '</tr>';
	} //while
?>
</tr>
</table>
<table class="admin_list_table" style="margin-top:10px" border="0">
<tr><td align="right" colspan="2" >
<?php
if ($display->refresh!='page_content'){
?>
	<input type="submit" value="<?php echo lang('admin_btn_close'); ?>" name="close" <?php osa_btn()?>
	onClick="closeDhtmlWindow('<?php echo $display->refresh; ?>'); return false;" />
<?php
}
?>
</td></tr>
</table>
</center>
</form>