<?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_Order_List_Depositdone
{
  
  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 $deposit_updcnt;

  var $from;
  var $deposit;
  
  var $orderno;
  var $orderdate;
  var $upduser;
  
  var $check;

  var $depo_false;
  var $depo_true;
  var $depo_cardfalse;
  var $depo_cardtrue;
  var $cancel_true;
  
  var $ms;
  
    /**
     * [[機能説明]]
     *
     * @access  public
     */
    function execute()
    {
      
        $log =& LogFactory::getLog();
        $log->debug("Admin_Ordermanage_Order_Detail_Formが実行されました", "Ordermanage_Order_Detail_Form#execute");
        
        $today = date("Y-m-d");

        foreach($this->check as $key => $value){ 
          $v = explode("-", $value);

          if ($v[3] == 9) {                 // キャンセル済みは、変更不可
             $cancel_true[] = $v;
          }
          elseif($v[5] >= 22){                  //カード以外で購入の入金済み
             $depo_true[] = $v;
          }
          elseif($v[5] == 21){              //カード購入の入金済み
             $depo_cardtrue[] = $v;
          }
          elseif($v[5] == 11){              //カード購入の予約分の未入金
             $depo_cardfalse[] = $v;
          }
          else{                                  //カード以外で購入の未入金→入金済みにしてＯＫ
             $depo_false[] = $v;
          }
        }
                  
      if(!empty($depo_true))      $this->depo_true  = $depo_true;
      if(!empty($depo_cardtrue))  $this->depo_cardtrue = $depo_cardtrue;
      if(!empty($depo_cardfalse)) $this->depo_cardfalse = $depo_cardfalse;      
      if(!empty($cancel_true))    $this->cancel_true  = $cancel_true;
      
      
      if(empty($depo_false)){
          $this->ms = "depositsate0";
          if(!empty($depo_true)){ 
              $this->ms = "depositsate2";
          }
          if(!empty($cancel_true)){ 
              $this->ms = "cancel";
          }
      }
        
      foreach($depo_false as $key => $value){ 
        $res = $this->deposit->DepositUpdate($depo_false[$key][0], $this->upduser, $today, $depo_false[$key][1]);
      }
        
      if (!$res) return "error"; 
        return 'success';
    }
    
}
?>
