function stageSelect(){
$reshipping = MetaData::createObject("Operation.Reshipping");
$registry = MetaData::createObject("Operation.Operation_Registry");
$country = MetaData::createObject("Reference.Country");
$status = MetaData::createObject("Reference.Delivery_Status");
$state = MetaData::createObject("Reference.State");
$sm = MetaData::createObject("Reference.Shipping_Method");
// cache status ID for optimizing query
if ( !$status->selectBy("code","wait") )
throw new Exception("No status code found: wait");
$sql = new ORM2SQL_Query;
$what = array(
$sql->absf($reshipping,null,"reshipping_id"),
$sql->absf($registry,"base_interseq_id","id"),
$sql->absf($registry,"base_timepos","order_timepos"),
$sql->absf($reshipping,"timepos","timepos"),
$sql->absf($sm,"name","shipping_method"),
$sql->absf($reshipping,"fname","fname"),
$sql->absf($reshipping,"lname","lname"),
$sql->absf($reshipping,"address","address"),
$sql->absf($reshipping,"city","city"),
$sql->absf($reshipping,"zip","zip"),
$sql->absf($reshipping,"phone","phone"),
$sql->absf($reshipping,"comment","comment"),
$sql->absf($country,"name","country"),
$sql->absf($state,"short_name","state"),
);
$from = array(
$sql->leftjoin($reshipping,$registry),
$sm->getTableName(),
$country->getTableName(),
$state->getTableName(),
);
$cond = array(
sprintf("%s IS NOT NULL",$sql->absf($registry,"base_entry")),
sprintf("%s=%d",$sql->absf($reshipping,"status"),$status->getId()),
$sql->eqf($reshipping,"shipping_method",$sm),
$sql->eqf($reshipping,"country",$country),
$sql->eqf($reshipping,"state",$state),
);
$sort = $sql->absf($reshipping,"timepos");
$qtxt = $sql->select($what,$from,$cond,null,null,$sort);
$rs = $reshipping->getConnection()->executeQuery($qtxt);
$this->getBaseController()->setRecordSet($rs);
return true;
}