<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * 商品情報新規登録完了
 *
 * @package     Admin.Itemmanage.Item.Done
 * @author      H.Watanabe <hiroshi.watanabe@netnee.jp>
 * @access      public
 */
class Admin_Itemmanage_Item_Done
{
    var $itembasic;

    var $upduser;
    var $actionnm;
    var $title;
    var $pagename;

    //基本情報
    var $itemnm;
    var $itemnmkana;
    var $makercd;
    var $labelcd;
    var $seriescd;
    var $iteminfo;
    var $comment;
    var $genre;
    var $itemdivcd;
    var $eirinrating;
    var $examgroupcd;
    var $examno;
    var $rankingrate;
    var $releasedate;


    //構成情報
    var $jancd;
    var $isbncd;
    var $makeritemcd;
    var $salestartdate;
    var $makerprice;
    var $orderclosedate;
    var $saleformcd;
    var $rectime;
    var $mediacd;
    var $struct_comment;
    var $variationnm;

    var $itemexp;
    
    // ダウンロード販売フラグ
    var $download;

    var $basic_option01;
    var $basic_option02;
    var $basic_option03;
    var $basic_option04;
    var $basic_option05;
    var $basic_option06;
    var $basic_option07;
    var $basic_option08;
    var $basic_option09;
    var $basic_option10;

    var $struct_option01;
    var $struct_option02;
    var $struct_option03;
    var $struct_option04;
    var $struct_option05;
    var $struct_option06;
    var $struct_option07;
    var $struct_option08;
    var $struct_option09;
    var $struct_option10;

    var $basic_option;
    var $struct_option;

    var $use_tags;
    var $actionChain;

    /**
     * execute
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Change_Item_Doneが実行されました", "Admin_Itemmanage_Item_Done#execute");


        if (preg_match_all("@(?:</?([^>]*?)>)@im",$this->itemexp, $match)) {
            //$log->debug(print_r($match[0],true), "");
            $errorList =& $this->actionChain->getCurErrorList();

            $use_tags = str_replace(",", "|", $this->use_tags);
            foreach ($match[0] as $val) {
                if (!preg_match("@(?:</?[".$use_tags."]++(([\s]+[^>]*?)*)>)@im",$val)) {
                    $log->debug("@(?:</?[".$use_tags."]++(([\s]+[^>]*?)*)>)@im  : ". $val, "");
                    $errorList->add("error", "使用できないHTMLタグが入力されています。");
                    $errorList->add("error", "「".$this->use_tags."」が使用できます。");
                    return 'input';
                }
            }
        }

        //基本情報
        if (!empty($this->releasedate)) {
            $this->releasedate = str_replace("/", "-", $this->releasedate);
        }
        if (!empty($this->salestartdate)) {
            $this->salestartdate = str_replace("/", "-", $this->salestartdate);
        }
        if (!empty($this->orderclosedate)) {
            $this->orderclosedate = str_replace("/", "-", $this->orderclosedate);
        }
        
        $result = $this->itembasic->insert(
                    $this->itemnm,
                    $this->itemnmkana,
                    $this->makercd,
                    $this->itemexp,
                    $this->basic_option01,
                    $this->basic_option02,
                    $this->basic_option03,
                    $this->basic_option04,
                    $this->basic_option05,
                    $this->basic_option06,
                    $this->basic_option07,
                    $this->basic_option08,
                    $this->basic_option09,
                    $this->basic_option10,
                    $this->upduser,
                    $this->releasedate,
                    $this->rankingrate,
                    $this->comment,
                    $this->genre,
                    
                    $this->variationnm,
                    $this->makeritemcd,
                    $this->jancd,
                    $this->salestartdate,
                    $this->orderclosedate,
                    $this->makerprice,
                    $this->struct_comment,
                    $this->struct_option01,
                    $this->struct_option02,
                    $this->struct_option03,
                    $this->struct_option04,
                    $this->struct_option05,
                    $this->struct_option06,
                    $this->struct_option07,
                    $this->struct_option08,
                    $this->struct_option09,
                    $this->struct_option10,
                    $this->download
                    );

        if (!$result) return "error";

        return 'success';
    }


}
?>
