<?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 Admin_Ordermanage_Forwarding_Detail_Form
{
  
  var $pagename;
/*
  var $order_date_start;
  var $order_date_end;
  var $order_time_start;
  var $order_time_end;
  var $orderno_start;
  var $orderno_end;
  var $ordermember;
  var $mailaddr;
  var $state;
  var $display;
*/
  var $from;
  var $order;
  var $results;
  var $res;
  
  var $odno;
  var $orderno;
  var $orderdate;
  var $lastnm;
  var $firstnm;
  var $sendpostalcd;
  var $pref;
  var $sendaddr1;
  var $sendaddr2;
  var $sendtelno1;
  var $addressee;
  var $deposit_updcnt;
  var $deposit_state;
  var $mail;
  var $depositdiv;
  var $depositdivname;
  var $forwardstate;
  var $stockstate;
  var $takkyubin;

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

  //From 予約一覧画面の為に
  var $untrans;
  var $disp_day;
  var $disp_select;
  
    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
      
        $log =& LogFactory::getLog();
        $log->debug("Admin_Ordermanage_Order_Detail_Formが実行されました", "Ordermanage_Order_Detail_Form#execute");
        
        $this->results   = $this->order->Orderdetailview();
        

       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->lastnm    = $this->results[0]["lastnm"];
        $this->firstnm   = $this->results[0]["firstnm"];
        $this->sendbuyername   = $this->results[0]["sendbuyer"];
        $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->brief          = "";
        if ($this->depositdiv==1) {
            $this->brief = $this->cardcompany[$this->results[0]["cardcompany"]];
        } elseif ($this->depositdiv==4) {
            $this->brief = $this->results[0]["kouzanumberkey"];
        }
        
        if($this->untrans=="untrans") $this->pagename = "予約一覧(未発送管理)";
        
        
        return 'success';
    }
    
}
?>
