<?php
/*
 * shopping/product/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_product_download_Form extends system_login_ModuleBase {
	
	function shopping_product_download_Form(){
	}
	function execute( & $request ) {

		$dbo 				= $request->getAttribute( 'dbo' );
		$sessionHashName	= 'shopping.product.download.columnSelectedArray';
		
		// セッション登録済みのカラム定義を確認
		$columnSelectedArray	= $request->getSession($sessionHashName);
		if( !is_array($columnSelectedArray) ) {
			$columnSelectedArray	= array_keys($GLOBALS['SHOPPING_PRODUCT_CSV_DEFINITION']);
			$columnSelectedArray	= array_merge($columnSelectedArray,array_keys($GLOBALS['SHOPPING_PRODUCT_UNIT_CSV_DEFINITION']));
		}
		// ダウンロードする対象クエリの確認
		$totalCount		= 0;
		$queryHash	= $request->getSession(SHOPPING_SESSION_NAME_PRODUCT_SEARCH_LAST_QUERY, SPIDER_SESSION_SCOPE_GLOBAL);
		if( !is_array($queryHash) ) {
			$request->addLocaledError('system.error.common.session.timeout',SPIDER_LOG_LEVEL_ERROR,array());
		} else if( strlen($queryHash['countQuery']) == 0 || strlen($queryHash['loadQuery']) == 0 ) {
			$request->addLocaledError('system.error.common.session.timeout',SPIDER_LOG_LEVEL_ERROR,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.product.download.culumnSelectedArray', $columnSelectedArray );
		$request->setAttribute('shopping.product.download.totalCount', $totalCount );
	}
}
?>