<?php
/*
 * shopping/order/step/ConfirmStock.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-10-04
 */
require_once(dirname(dirname(dirname(__FILE__)))
.DIRECTORY_SEPARATOR.'PackageConfig.class.php' );
require_once( dirname(dirname(dirname(__FILE__)))
.DIRECTORY_SEPARATOR.'DaoShoppingOrder.class.php');
class shopping_order_step_ConfirmStock extends system_login_ModuleBase {
	/**
	 * コンストラクタ
	 */
	function shopping_order_step_ConfirmStock() {
		array_push($this->require_module_array,'shopping.LoadConfig');
		array_push($this->require_module_array,'shopping.order.option.LoadList');
		array_push($this->require_module_array,'shopping.order.settlement.LoadList');
		if( isset($_GET['shpoi']) && strlen(trim($_GET['shpoi'])) > 0 ) {
			array_push($this->require_module_array,'shopping.order.CartAdmin');
		} else {
			array_push($this->require_module_array,'shopping.order.Cart');
		}
	}
	/**
	 * executeメソッド
	 */
	function execute( & $request ) {
		// カートオブジェクトの取得
		$shoppingOrderObject	= $request->getAttribute('shopping.order.orderObject');
		// 申し込み時のカート内基本検査
		if( !is_object($shoppingOrderObject) || $shoppingOrderObject->getAllItemCount($request) == 0 ) {
			// 商品選択がなければエラー
			$request->addLocaledError('system.error.common.session.timeout',SPIDER_LOG_LEVEL_ERROR,array());
			return false;
		} else if( !$shoppingOrderObject->canExecuteOrder( $request ) ) {
			// 在庫チェック
		}
		$shoppingOrderObject->optimize();
		$request->setAttribute('shopping.order.orderObject',	$shoppingOrderObject );
	}
}
?>