<?php
require_once(DIR_WS_CLASSES.'imports.php');
// Imports PAGING
function _get_imports_id($value){
	$data = split('\|',$value);
	$id = $data[1];
	$number = $data[0];

	$imports = new imports;
	$import = $imports->get_import($id);
	if($import->data->gassed == 0){
		return $number;
	}
	return xtc_image('images/icons/warning.gif',TEXT_GASSED).'&nbsp;'.$number;
}

function _get_documents_present($value){
	if($value == 1)
		return YES;
	return NO;
}
function _get_import_ships_id($id){
	global $YES_USER_PERMISSIONS;
	if($YES_USER_PERMISSIONS['exports_edit'] == 1){
		return xtc_draw_checkbox_field('id[]',$id,false).$id;
	}else{
		return $id;
	}
}

function _convert_html($text){
	return html_entity_decode($text);
}

$imports_smarty = new yesSmarty;

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

$query_raw = sprintf("SELECT ish.import_ships_id,CONCAT(i.import_number,'|',i.imports_id) AS number,ish.orderer_name,i.shipper_name,i.transport_agent_name,i.date_added FROM %s i LEFT JOIN %s ish USING(imports_id) WHERE ish.orderer_ships_id='%s' AND ish.status=0 ORDER BY i.date_added DESC",TABLE_IMPORTS,TABLE_IMPORT_SHIPS,$class_id );
$pager = new ADODB_Pager($conn,$query_raw);
$pager->pager_grid_formid = 'imports'; // WIRD BENOETIGT FUER ALLE MARKIEREN
$pager->index_field = 'imports_id';
//$pager->hide_columns(array('history_id'));
$pager->set_in_div('snippet_imports');

$pager->get_row_selector = 'iID';
$pager->gridHeader = array(ENTRY_ID,ENTRY_IMPORT_NUMBER,ENTRY_DOCUMENTS_PRESENT_SHORT,ENTRY_ORDERER,ENTRY_SHIPPER,ENTRY_TRANSPORT_AGENT,TEXT_DATE_CREATED);
$pager->gridHelper = array(
	'number'=>'_get_imports_id',
	'import_ships_id'=>'_get_import_ships_id',
	'date_added'=>'xtc_date_long'
);

// 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');
$imports_smarty->assign('HEADER',$pager->getHeader());

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

if($YES_USER_PERMISSIONS['exports_edit'] == 1){
	$list_actions_array = array(
		0=>array('id'=>'','text'=>TEXT_SELECT),
		1=>array('id'=>'export','text'=>ENTRY_EXPORT_IMPORT)
	);
	$list_actions = xtc_draw_pull_down_menu('list_action',$list_actions_array,'','onchange="pager_list_action(this.form,this.value,\'\');" class="dbforminput"');
	$grid_smarty->assign('list_actions',$list_actions);
	// fuer alle markieren brauchen wir den checkbox-namen
	$grid_smarty->assign('multiselect_field','id[]');
}

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

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

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