<?php
/*
 * shopping/calendar/Delete.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-02-12
 * 
 */
require_once( dirname(dirname(__FILE__))
.DIRECTORY_SEPARATOR.'PackageConfig.class.php' );
class shopping_calendar_Delete extends system_login_ModuleBase {
	function shopping_calendar_Delete(){
		array_push($this->require_module_array,'database2.Connect');
	}
	function execute( & $request ) {
		$dbo			= $request->getAttribute( 'dbo' );
		$scheduleNumber	= $request->getParam('schedule_number','post');
		// 妥当性検査
		if( strlen($scheduleNumber) == 0 ) {
			$request->addLocaledError('shopping.error.calendar.noselected',SPIDER_LOG_LEVEL_ERROR,array());
		} else if( preg_match('/^[0-9]{1,6}$/',$scheduleNumber)==0 ) {
			$request->addLocaledError('shopping.error.calendar.noselected',SPIDER_LOG_LEVEL_ERROR,array());
		}
		// 問題ないなら削除
		if( $request->isError() ) {
		} else {
			$sql	= 'DELETE FROM '.TABLE_NAME_SHOPPING_CALENDAR.' WHERE schedule_number='.$scheduleNumber;
			if( $dbo->query($sql) ) {
			} else {
				$request->addLocaledError('database2.error.common',SPIDER_LOG_LEVEL_FATAL,array($sql));
			}
		}
	}
}
?>