<?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-02-12
 * 
 */
require_once( dirname(dirname(__FILE__))
.DIRECTORY_SEPARATOR.'PackageConfig.class.php');
class shopping_promotion_Load extends system_login_ModuleBase {
	function shopping_promotion_Load() {
	}
	function execute( & $request ) {
		
		$dbo					= $request->getAttribute( 'dbo' );
		$promotionNumber		= stripslashes( $_GET['shppn'] );
		$promotionId			= stripslashes( $_GET['shppi'] );
		$shoppingProductObject	= spider_Controller::createObject('shopping_DaoShoppingPromotion');
		$loginUserObject		= $this->getLoginUserObject( $request );
		
		if ( strlen(trim($promotionNumber)) == 0 && strlen(trim($promotionId)) == 0 ) {
			$request->addLocaledError('system.error.common.data.requireselect',SPIDER_LOG_LEVEL_FATAL,array(''));
		} else if( strlen(trim($promotionNumber)) > 0 && preg_match('/^[0-9]+$/',$promotionNumber) > 0 ){
			if ( !$dbo->loadByNumber( $shoppingProductObject, $promotionNumber, true ) ) {
				$request->addLocaledError('system.error.common.data.invalidselect',SPIDER_LOG_LEVEL_FATAL,array(''));
			}
		} else if( strlen(trim($promotionId)) > 0 && preg_match('/^[0-9a-zA-Z]+$/',$promotionId) > 0 ){
			if ( !$dbo->loadById( $shoppingProductObject, $promotionId, true ) ) {
				$request->addLocaledError('system.error.common.data.invalidselect',SPIDER_LOG_LEVEL_FATAL,array(''));
			}
		}
		$request->setAttribute('shopping.promotion.promotion_object',			$shoppingProductObject);
	}
}
?>