<?php
/**
 * admin_list_view.php - DIsplay list view for admin features.
 *
 * @author $Author: dtong $
 * @version $Id: admin_list_view.php,v 1.6 2011/04/27 05:46:27 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
*/
require_once(APPPATH . 'libraries/mapping/display_list.php');
osa_load_lang('admin');

$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($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;
$formname = 'adminform';

if (!isset($display->filter_key_1)) {
	$display->filter_key_1 = '';
}
if (!isset($display->filter_key_2)) {
	$display->filter_key_2 = '';
}

$display->print_page_links()
?>
<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>
		<?php if (isset($not_show_search_box) && $not_show_search_box) { ?>
			<td colspan="2"><nobr><?php echo lang('admin_list_listitem'); ?></nobr>
		<?php } else {?>
			<td class="admin_list_filter"><nobr><?php echo lang('admin_list_listitem'); ?></nobr></td><td>
		<?php } ?>
		<?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;'";
							$jscript_search = "onClick='search_filter(\"$search\", \"$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>
<?php
	if ( isset($display->notice) && !empty($display->notice) ) {
		echo "<div style='margin-top:-15px;text-align:right;width:96%;font-style:italic;font-size:10px'>$display->notice</div>";
	}
   $display->cssclass_titlerow = 'table_head_col';
   $display->cssclass_datarow1 = 'table_body_row';
   $display->cssclass_datarow2 = 'table_body_row_none';
   //Need to tell which view to load on a full page refresh
   $display->view_file = 'tablelist/admin_list_view';
   //Loads the displaylist for the table generation
   //$this->load->view('mapping/display_list_view');
   $display->load_tableview();
?>
<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>
<?php $display->print_page_links()?>
<br /><br />