<?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     [[package名]]
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Seller_Itemexhibit_Deliprint
{
    var $no;
    var $sell = 1;

    var $auth;
    var $c_order;
    var $c_member;

    var $results;

    var $sumprice;
    var $orderno;
    var $orderdate;
    var $lastnm;
    var $firstnm;
    var $sendpostalcd;
    var $prefnm;
    var $sendaddr1;
    var $sendaddr2;
    var $sendtelno1;
    var $addressee;
    var $deposit_updcnt;
    var $deposit_state;
    var $deposit_statename;
    var $mail;
    var $depositdiv;
    var $depositdivname;
    var $forwardstate;
    var $stockstate;
    var $takkyubin;
    var $enquiryno;
    var $brief;
    var $printdate;

    var $sellernm;

    var $cardcompany = array(1 => "VISA", 
                             2 => "MASTER",
                             3 => "NICOS",
                             4 => "JCB",
                             5 => "アメックス");

    var $nomember_name;
    var $note;

    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        //購入者情報取得
        $membercd = $this->auth->getAuthData("membercd");
        $this->results   = $this->c_order->OrderdetailMail($this->no,"typediv",$membercd);

        $memberdata = $this->c_member->getMemberData($membercd);
        $this->sellernm = $memberdata["nicknm"];

        if (empty($this->sellernm) || empty($this->results)) {
            die("error");
            exit;
        }

        foreach($this->results as $key => $value){
            $type[]=$this->results[$key]["typediv"];
            $fwtype[]=$this->results[$key]["forwardstate"];
            $price[] = $this->results[$key]["price"];
        }
       
        foreach($type as $key => $value){
            if(($value == 1 || $value==2 || $value==3 || $value==10 || $value==11) &&
               ($fwtype[$key]!=8 && $fwtype[$key]!=9)){
                $salesprice[] = $price[$key];
            }
            else{
                $otherprice[] = $price[$key];
            }
        }

        $this->sumprice = array_sum($salesprice);

        $this->orderno   = $this->results[0]["orderno"];
        $this->orderdate = $this->results[0]["orderdate"];

        $this->nomember_name     = $this->results[0]["sendbuyer"];

        $this->lastnm    = $this->results[0]["lastnm"];
        $this->firstnm   = $this->results[0]["firstnm"];
        $this->sendpostalcd = $this->results[0]["sendpostalcd"];
        $this->prefnm       = $this->results[0]["prefnm"];
        $this->sendaddr1    = $this->results[0]["sendaddr1"];
        $this->sendaddr2    = $this->results[0]["sendaddr2"];
        $this->sendtelno1   = $this->results[0]["sendtelno1"];
        $this->addressee    = $this->results[0]["addressee"];
        $this->deposit_updcnt     = $this->results[0]["deposit_updcnt"];
        $this->deposit_state      = $this->results[0]["depositstate"];
        $this->deposit_statename  = $this->results[0]["depostate"];
        $this->mail           = (!empty($this->results[0]["mailaddr"])) ?
                                $this->results[0]["mailaddr"] : $this->results[0]["sendmailaddr"];
        $this->depositdiv     = $this->results[0]["depositdiv"];
        $this->depositdivname = $this->results[0]["depositdivname"];
        $this->forwardstate   = $this->results[0]["forwardstate"];
        foreach ($this->results as $v) {
            if ($this->forwardstate > $v["forwardstate"] && $v["typediv"]==1) {
                $this->forwardstate   = $v["forwardstate"];
            }
        }
        $this->stockstate     = $this->results[0]["stockstate"];
        $this->takkyubin      = $this->results[0]["takkyubin"];
        $this->enquiryno      = $this->results[0]["enquiryno"];
        $this->brief          = "";
        if ($this->depositdiv==1) {
            $this->brief = $this->cardcompany[$this->results[0]["cardcompany"]];
        } elseif ($this->depositdiv==4) {
            $this->brief = $this->results[0]["kouzanumberkey"];
        }
       
        $year = (int)date("Y")-1988;
        $this->printdate = "平成". $year ."年". 
                           date("m") ."月".
                           date("d") ."日";

        $this->note          = $this->results[0]["note"];
        return 'success';
    }
}
?>
