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

/**
 * 棚番 ID 入力・変更完了
 *
 * @package     Admin.Itemmanage.Rackid.Done
 * @author      netnee <mail@example.com>
 * @access      public
 */
class Admin_Itemmanage_Rackid_Done
{
    var $title;
    var $ins_title;
    var $upd_title;
    var $pagename;
    var $upduser;
    
    var $stock;
    
    var $jansearch;
    var $stocktitlecd;
    var $defaultid;
    
    var $st_orderno;
    var $itemc;
    var $structc;
    var $stockc;
    var $rackid;
    var $es_updcnt;
    
    var $queue = 0;
    var $affected = 0;
    var $errors = array();
    
    var $cd;
    var $structcd;
    var $stockcd;
    
    var $div;
    var $itemdiv;
    var $jancode;
    var $hinban;
    var $itemtitle;
    var $release_date_start;
    var $release_date_end;
    var $publish_date_start;
    var $publish_date_end;
    var $maker_capital;
    var $maker_name;
    var $media;
    var $cast;
    var $situation;
    var $photo_situation;
    var $publish_situation;
    var $sort;
    var $genre_select;
    
    /**
     * execute
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Rackid_Doneが実行されました", "Admin_Itemmanage_Rackid_Done#execute");
        
        
        if (!empty($this->stocktitlecd)){
            $this->title = $this->upd_title;
        } else {
            $this->title = $this->ins_title;
        }
        
        
        
        $res = array();
        
        if (is_array($this->itemc) && is_array($this->structc) && is_array($this->stockc)){
            $this->queue = count($this->itemc);
            
            foreach($this->itemc as $key => $val){
                if (is_numeric($this->itemc[$key]) && is_numeric($this->structc[$key]) && is_numeric($this->stockc[$key]) && !empty($this->rackid[$key])){
                    $tmp = $this->stock->rackidUpdate($this->itemc[$key],
                                                        $this->structc[$key],
                                                        $this->stockc[$key],
                                                        $this->rackid[$key],
                                                        $this->upduser,
                                                        $this->es_updcnt[$key]);
                    $res[] = array("st_orderno" => $this->st_orderno[$key],
                                    "errcd"     => $tmp["errcd"],
                                    "errmsg"    => $tmp["errmsg"]);
                    $this->defaultid = $this->rackid[$key];
                } else {
                    $this->queue--;
                }
            }
        }
        
        foreach($res as $val){
            if ($val["errcd"] < 0){
                $this->errors[] = $val;
            } else {
                $this->affected++;
            }
        }
        
        
        return 'success';
    }
}
?>
