<?php
function _get_date($date){
	return strftime(DATE_FORMAT_LONG,strtotime($date));
}
function _get_import_link($value){
	$number = yes_get_import_number_from_imports_id($value);
	return yes_draw_href_text($number,xtc_href_link(FILENAME_IMPORTS,'action=overview&id='.$value),'imports','','');
}
function _get_size_string($value){
	$bracket_pos1 = strpos($value,'{');
	$size_string = substr($value,0,$bracket_pos1);
	$value = substr($value,strlen($size_string),strlen($value));
	$bracket_pos2 = strpos($value,'}');
	$special = substr($value,1,($bracket_pos2-1) );
	$special = split('\|',$special);
	switch($special[0]){
		case 'special':
			$size_string = $size_string.'<br /><span class="main" style="color:#FFFFFF;background-color:#FF0000;"><img src="images/icons/warning.gif" border="0" />&nbsp;'.$special[1].'</span>';
			break;
	}
	return $size_string;
}
$ship_collies_smarty = new yesSmarty;

$class_id = xtc_db_input($_GET['id']);

$query_raw = sprintf("SELECT i.imports_id,concat(ishc.quantity,' x ',ishc.collie_content) as content,concat(ishc.height,'x',ishc.width,'x',ishc.depth,'{',ishc.format,'|',ishc.format_text,'}') as size,i.date_added FROM %s i LEFT JOIN %s ish USING(imports_id) LEFT JOIN %s ishc USING(import_ships_id) WHERE ish.orderer_ships_id='%s' AND ish.status=0 ORDER BY i.date_added DESC",TABLE_IMPORTS,TABLE_IMPORT_SHIPS,TABLE_IMPORT_SHIP_COLLIES,$class_id );
$pager = new ADODB_Pager($conn,$query_raw);
$pager->index_field = 'imports_id';
//$pager->hide_columns(array('history_id'));
$pager->set_in_div('snippet_imports');
$pager->gridHelper = array(
	'imports_id'=>'_get_import_link',
	'size'=>'_get_size_string',
	'date_added'=>'_get_date'
);

$pager->get_row_selector = 'iID';
$pager->gridHeader = array(ENTRY_IMPORT_NUMBER,ENTRY_CONTENT,ENTRY_SIZE,TEXT_DATE_CREATED);

// KEINE AJAX BOX
$pager->pager_tab_file = false;
// KEINE JAVASCRIPT ROW-ACTION
$pager->javascript_row_click_action = false;

$pager->Render($rows_per_page=MAX_DISPLAY_SEARCH_RESULTS_ADMIN);

$selected_item = $pager->selected_row;

$grid_smarty = new yesSmarty;
$grid_smarty->assign('grid',$pager->getGrid());
$grid = $grid_smarty->fetch(DIR_FS_ADMIN.'templates/pager_grid.tpl');
$ship_collies_smarty->assign('HEADER',$pager->getHeader());

$grid_smarty->assign('grid',$pager->getGrid());

$grid = $grid_smarty->fetch(DIR_FS_ADMIN.'templates/pager_grid.tpl');

$ship_collies_smarty->assign('GRID',$grid);
$ship_collies_smarty->assign('FOOTER',$pager->getFooter());

header('Content-Type: text/html; charset=iso-8859-1');
echo $ship_collies_smarty->fetch(DIR_FS_ADMIN.'templates/pager.tpl');
