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


require_once 'Pager.php';

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

/**
 * [[機能説明]]
 *
 * @package     [[package名]]
 * @author      Your Name <mail@example.com>
 * @access      public
 */
class Admin_Moneymanage_Payment_list
{

    var $moneyview;       //テーブル操作
    var $results;
    var $res;
    var $title;
    var $pagename;
    var $links;
    var $from;
    
    var $list;
    
    //search 受渡し素材
    var $deposit_date_start;
    var $deposit_date_end;
    var $orderno_start;
    var $orderno_end;
    var $sellermember;
    var $state;
    var $display;
    var $sort;
    
    //金額
    var $saleprice;
    
    // 入力パラメータ
    var $cnt;         // 総登録件数
    var $pageID;      // ページ番号
    
    var $pagedata;
    var $cont;
    
    var $Pager_perPage;
    var $Pager_delta;
    var $Pager_append;
    var $Pager_clearIfVoid;
    var $Pager_urlVar;
    var $Pager_useSessions;
    var $Pager_closeSession;
    var $Pager_mode;
    var $Pager_prevImg;
    var $Pager_nextImg;
    var $Pager_altPage;
    var $Pager_altPrev;
    var $Pager_altNext;
    var $Pager_altFirst;
    var $Pager_altLast;
    var $Pager_firstPagePre;
    var $Pager_firstPageText;
    var $Pager_firstPagePost;
    var $Pager_lastPagePre;
    var $Pager_lastPageText;
    var $Pager_lastPagePost;
    var $Pager_separator;
    var $Pager_spacesBeforeSeparator;
    var $Pager_spacesAfterSeparator;

    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Moneymanage_Payment_listが実行されました", "Admin_Moneymanage_Payment_list#execute");

        $to = $this->display; 
        
        //orderno↓
        $this->res = $this->moneyview->PaymentList();
        
        // Pager設定
        $pageparams = array(
            //'itemData'      => $this->results,
            'totalItems'    => $this->res["recordcount"],
            'perPage'       => $to,                       // １ページの行数
            'delta'         => $this->Pager_delta,       // 表示ページから、前後に表示するページ数
            'append'        => $this->Pager_append,
            'clearIfVoid'   => $this->Pager_clearIfVoid,
            'urlVar'        => $this->Pager_urlVar,
            'useSessions'   => $this->Pager_useSessions,
            'closeSession'  => $this->Pager_closeSession,
            'mode'          => $this->Pager_mode,
            'prevImg'       => $this->Pager_prevImg,
            'nextImg'       => $this->Pager_nextImg,
            'altPage'       => $this->Pager_altPage,
            'altPrev'       => $this->Pager_altPrev,
            'altNext'       => $this->Pager_altNext,
            'altFirst'      => $this->Pager_altFirst,
            'altLast'       => $this->Pager_altLast,
            'firstPagePre'  => $this->Pager_firstPagePre,
            'firstPageText' => $this->Pager_firstPageText,
            'firstPagePost' => $this->Pager_firstPagePost,
            'lastPagePre'   => $this->Pager_lastPagePre,
            'lastPageText'  => $this->Pager_lastPageText,
            'lastPagePost'  => $this->Pager_lastPagePost,
            'separator'     => $this->Pager_separator, 
            'spacesBeforeSeparator' => $this->Pager_spacesBeforeSeparator,
            'spacesAfterSeparator'  => $this->Pager_spacesAfterSeparator
            );

            // Pager出力
            $pager = & Pager::factory($pageparams);
            $this->pagedata = $pager->getPageData();
            $this->links = $pager->getLinks();
            
          $this->cont = $this->res["recordcount"];
          unset($this->res["recordcount"]);
        
          
           foreach($this->res as $key => $value){
            $odno[] = $value["orderno"];
       }

        //売上金額詳細行取得
        $this->results = $this->moneyview->PaymentListSalePrc($odno);
          
          
       //売上行の合計
          foreach($this->results as $key => $value){
               if($value["typediv"]==1){
                   $salesprice[$value["orderno"]][] = $value["price"];
               }else{
                   $otherprice[$value["orderno"]][] = $value["price"];
               }

           }
           foreach($salesprice as $key => $value){
                   $price[$key][] =array_sum($value);
           }
           $this->saleprice = $price;
           
        foreach($this->res as $key => $value){
          foreach($this->saleprice as $k => $v){
                       if($k == $this->res[$key]["orderno"]){
                          $this->list[$key]["depositdate"]=$this->res[$key]["depositdate"];
                          $this->list[$key]["lastnm"]=$this->res[$key]["lastnm"];
                          $this->list[$key]["firstnm"]=$this->res[$key]["firstnm"];
                          $this->list[$key]["payfix"]=number_format($this->saleprice[$k][0]
                                               +$this->res[$key]["price2"]
                                               +$this->res[$key]["price3"]
                                               -$this->res[$key]["price4"]
                                               -$this->res[$key]["price5"]
                                               -$this->res[$key]["price7"]);
                          $this->list[$key]["orderno"]=$this->res[$key]["orderno"];
                          $this->list[$key]["sellerpaydate"]=$this->res[$key]["sellerpaydate"];
                          $this->list[$key]["uriage"]=number_format($this->saleprice[$k][0]);
                          $this->list[$key]["souryou"]=number_format($this->res[$key]["price2"]);
                          $this->list[$key]["takkyuu"]=number_format($this->res[$key]["price3"]);
                          $this->list[$key]["seiyakuprc"]=number_format($this->res[$key]["price4"]);
                          $this->list[$key]["riyouprc"]=number_format($this->res[$key]["price5"]);
                          $this->list[$key]["henkin"]=number_format($this->res[$key]["price7"]);
                          $this->list[$key]["updcnt"]=$this->res[$key]["updcnt"];
                       }
                 }
       }       
       
        return 'success';
    }
    
        function getLink()
    {
        return $this->links;
    }
    

}
?>
