<?php
/*
 * shopping/order/download/Form.class.php
 * 
 * CopyRight(C) 2010 Shopformer Development Team. All Right Reserved
 * URL: http://sourceforge.jp/projects/shopformer/
 * 
 * 
 * Mail: m_nakashima@users.sourceforge.jp
 * Auther: Masanori Nakashima
 * Last Update: 2010-06-18
 */
require_once(dirname(dirname(dirname(__FILE__)))
.DIRECTORY_SEPARATOR.'PackageConfig.class.php' );
class shopping_order_download_Form extends system_login_ModuleBase {
	function shopping_order_download_Form(){
	}
	function execute( & $request ) {
		$dbo 				= $request->getAttribute( 'dbo' );
		$sessionHashName	= 'shopping.order.download.columnSelectedArray';
		
		// セッション登録済みのカラム定義を確認
		$columnSelectedArray	= $request->getSession($sessionHashName);
		if( !is_array($columnSelectedArray) ) {
			$columnSelectedArray	= array_keys($GLOBALS['SHOPPING_ORDER_CSV_DEFINITION']);
			array_push($columnSelectedArray,'item_all');
		}
		// ダウンロードする対象クエリの確認
		$totalCount		= 0;
		$queryHash	= $request->getSession(SHOPPING_SESSION_NAME_ORDER_SEARCH_LAST_QUERY, SPIDER_SESSION_SCOPE_GLOBAL);
		if( !is_array($queryHash) ) {
			$request->addLocaledError('system.error.common.session.timeout',SPIDER_LOG_LEVEL_FATAL,array());
		} else if( strlen($queryHash['countQuery']) == 0 || strlen($queryHash['loadQuery']) == 0 ) {
			$request->addLocaledError('system.error.common.session.timeout',SPIDER_LOG_LEVEL_FATAL,array());
		} else {
			$totalCount	= $dbo->queryOne($queryHash['countQuery']);
			if ( $totalCount === false ) {
				$request->addLocaledError('database2.error.common',SPIDER_LOG_LEVEL_FATAL,array($queryHash['countQuery']));
			}
		}
		$request->setAttribute('shopping.order.download.culumnSelectedArray', $columnSelectedArray );
		$request->setAttribute('shopping.order.download.totalCount', $totalCount );

	}
}
?>