<?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: */

require_once 'Pager.php';

/**
 * [[機能説明]]
 *
 * @package     Admin.Itemmanage.Preitem.Accept
 * @author      H.Watanabe <hiroshi.watanabe@netnee.jp>
 * @access      public
 */
class Admin_Itemmanage_Preitem_Accept
{
    // components
    var $actionChain;
    var $tmaker;
    var $view;
    var $m_name;
    var $castnm;
    var $media_list;
    var $tname;
    var $genreview;
    var $genre_search;
    var $db_preitem;
    var $auth;
    var $l_mail;
    var $memberview;
    
    var $title;
    var $pagename;

    // param
    var $preitemcd;
    //-- param 
    var $result;
    
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Itemmanage_Preitem_Acceptが実行されました", "Admin_Itemmanage_Preitem_Accept#execute");
        
        $errorList =& $this->actionChain->getCurErrorList();
        
        $this->result = $this->db_preitem->getOnePreItem($this->preitemcd);
        if(count($this->result)>0) {
            $accept = $this->db_preitem->accept($this->preitemcd);
            if($accept) {
                $this->sendMail();
            }
        }

        return 'success';
    }
    
    function sendMail()
    {
        $membercd = $this->result['sellercd'];
        $memberdata = $this->memberview->getMemberData($membercd);
        
        $mailaddress = $memberdata["mailaddr"];
        $from        = MAIL_FROM;

        $params = array(
            "username"  => $memberdata["lastnm"]." ". $memberdata["firstnm"],
            "itemname"  => $this->result["itemnm"] ." ". $this->result["variationnm"],
            "itemcd"    => $this->db_preitem->getitemcd(),
            "url"   => _DOMAIN_NAME . dirname($_SERVER["REQUEST_URI"]),
        );

        return $this->l_mail->sendFromTemplate("preitem_accept", $mailaddress, $from, $params);
    }

}
?>
