Пример #1
0
 /**
  * CSVファイルを送信する
  *
  * @param  integer $csv_id      CSVフォーマットID
  * @param  string  $where       WHERE条件文
  * @param  array   $arrVal      プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。
  * @param  string  $order       ORDER文
  * @param  boolean $is_download true:ダウンロード用出力までさせる false:CSVの内容を返す(旧方式、メモリを食います。)
  * @return boolean|string   $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string
  */
 public function sfDownloadCsv($csv_id, $where = '', $arrVal = array(), $order = '', $is_download = false)
 {
     $objQuery = Application::alias('eccube.query');
     // CSV出力タイトル行の作成
     $arrOutput = Utils::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE));
     if (count($arrOutput) <= 0) {
         return false;
     }
     // 失敗終了
     $arrOutputCols = $arrOutput['col'];
     $cols = Utils::sfGetCommaList($arrOutputCols, true);
     // 商品の場合
     if ($csv_id == 1) {
         // この WHERE 句を足さないと無効な規格も出力される。現行仕様と合わせる為追加。
         $inner_where = 'dtb_products_class.del_flg = 0';
         $from = Application::alias('eccube.product')->prdclsSQL($inner_where);
         // 会員の場合
     } elseif ($csv_id == 2) {
         $from = 'dtb_customer';
         // 注文の場合
     } elseif ($csv_id == 3) {
         $from = 'dtb_order';
         // レビューの場合
     } elseif ($csv_id == 4) {
         $from = 'dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id';
         // カテゴリの場合
     } elseif ($csv_id == 5) {
         $from = 'dtb_category';
     }
     $objQuery->setOrder($order);
     $sql = $objQuery->getSql($cols, $from, $where);
     return $this->sfDownloadCsvFromSql($sql, $arrVal, $this->arrSubnavi[$csv_id], $arrOutput['disp_name'], $is_download);
 }
Пример #2
0
 /**
  * 受注データを取得して, FormParam へ設定する.
  *
  * @param  FormParam $objFormParam FormParam インスタンス
  * @param  integer      $order_id     取得元の受注ID
  * @return void
  */
 public function setOrderToFormParam(&$objFormParam, $order_id)
 {
     /* @var $objPurchase PurchaseHelper */
     $objPurchase = Application::alias('eccube.helper.purchase');
     // 受注詳細を設定
     $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false);
     $objFormParam->setParam(Utils::sfSwapArray($arrOrderDetail));
     $arrShippingsTmp = $objPurchase->getShippings($order_id);
     $arrShippings = array();
     foreach ($arrShippingsTmp as $row) {
         // お届け日の処理
         if (!Utils::isBlank($row['shipping_date'])) {
             $ts = strtotime($row['shipping_date']);
             $row['shipping_date_year'] = date('Y', $ts);
             $row['shipping_date_month'] = date('n', $ts);
             $row['shipping_date_day'] = date('j', $ts);
         }
         $arrShippings[$row['shipping_id']] = $row;
     }
     $objFormParam->setParam(Utils::sfSwapArray($arrShippings));
     /*
      * 配送商品を設定
      *
      * $arrShipmentItem['shipment_(key)'][$shipping_id][$item_index] = 値
      * $arrProductQuantity[$shipping_id] = 配送先ごとの配送商品数量
      */
     $arrProductQuantity = array();
     $arrShipmentItem = array();
     foreach ($arrShippings as $shipping_id => $arrShipping) {
         $arrProductQuantity[$shipping_id] = count($arrShipping['shipment_item']);
         foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) {
             foreach ($arrItem as $item_key => $item_val) {
                 $arrShipmentItem['shipment_' . $item_key][$shipping_id][$item_index] = $item_val;
             }
         }
     }
     $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity);
     $objFormParam->setParam($arrShipmentItem);
     /*
      * 受注情報を設定
      * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値
      * が渡ってくるため, $arrOrder で上書きする.
      */
     $arrOrder = $objPurchase->getOrder($order_id);
     // 生年月日の処理
     if (!Utils::isBlank($arrOrder['order_birth'])) {
         $order_birth = substr($arrOrder['order_birth'], 0, 10);
         $arrOrderBirth = explode("-", $order_birth);
         $arrOrder['order_birth_year'] = intval($arrOrderBirth[0]);
         $arrOrder['order_birth_month'] = intval($arrOrderBirth[1]);
         $arrOrder['order_birth_day'] = intval($arrOrderBirth[2]);
     }
     $objFormParam->setParam($arrOrder);
     // ポイントを設定
     list($db_point, $rollback_point) = Application::alias('eccube.helper.db')->getRollbackPoint($order_id, $arrOrder['use_point'], $arrOrder['add_point'], $arrOrder['status']);
     $objFormParam->setValue('total_point', $db_point);
     $objFormParam->setValue('point', $rollback_point);
     if (!Utils::isBlank($objFormParam->getValue('customer_id'))) {
         $arrCustomer = Application::alias('eccube.helper.customer')->sfGetCustomerDataFromId($objFormParam->getValue('customer_id'));
         $objFormParam->setValue('customer_point', $arrCustomer['point']);
     }
 }
Пример #3
0
 /**
  * 配列の縦横を入れ替えて返す
  *
  * @param  array $arrKey 対象のキー
  * @return array 縦横を入れ替えた配列
  */
 public function getSwapArray($arrKey = array())
 {
     $arrTmp = $this->getHashArray($arrKey);
     return Utils::sfSwapArray($arrTmp);
 }
Пример #4
0
 /**
  * 入力内容のチェックを行う.
  *
  * @param  FormParam $objFormParam FormParam インスタンス
  * @return array        エラーメッセージの配列
  */
 public function lfCheckError(&$objFormParam)
 {
     /* @var $objProduct Product */
     $objProduct = Application::alias('eccube.product');
     $arrValues = $objFormParam->getHashArray();
     $arrErr = array();
     $arrErrTemp = $objFormParam->checkError();
     $arrErrDate = array();
     foreach ($arrValues['shipping_date_year'] as $key_index => $year) {
         $month = $arrValues['shipping_date_month'][$key_index];
         $day = $arrValues['shipping_date_day'][$key_index];
         /* @var $objError CheckError */
         $objError = Application::alias('eccube.check_error', array('shipping_date_year' => $year, 'shipping_date_month' => $month, 'shipping_date_day' => $day));
         $objError->doFunc(array('お届け日', 'shipping_date_year', 'shipping_date_month', 'shipping_date_day'), array('CHECK_DATE'));
         $arrErrDate['shipping_date_year'][$key_index] = $objError->arrErr['shipping_date_year'];
     }
     $arrErrTemp = array_merge($arrErrTemp, $arrErrDate);
     // 複数項目チェック
     $year = $arrValues['order_birth_year'];
     $month = $arrValues['order_birth_month'];
     $day = $arrValues['order_birth_day'];
     /* @var $objError CheckError */
     $objError = Application::alias('eccube.check_error', array('order_birth_year' => $year, 'order_birth_month' => $month, 'order_birth_day' => $day));
     $objError->doFunc(array('生年月日', 'order_birth_year', 'order_birth_month', 'order_birth_day'), array('CHECK_BIRTHDAY'));
     $arrErrTemp['order_birth_year'] = $objError->arrErr['order_birth_year'];
     // 商品の種類数
     $max = count($arrValues['quantity']);
     $subtotal = 0;
     $totalpoint = 0;
     $totaltax = 0;
     for ($i = 0; $i < $max; $i++) {
         // 小計の計算
         $subtotal += Application::alias('eccube.helper.db')->calcIncTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i];
         // 小計の計算
         $totaltax += Utils::sfTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i];
         // 加算ポイントの計算
         $totalpoint += Utils::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i];
         // 在庫数のチェック
         $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]);
         // 編集前の値と比較するため受注詳細を取得
         /* @var $objPurchase PurchaseHelper */
         $objPurchase = Application::alias('eccube.helper.purchase');
         $arrOrderDetail = Utils::sfSwapArray($objPurchase->getOrderDetail($objFormParam->getValue('order_id'), false));
         if ($arrProduct['stock_unlimited'] != '1' && $arrProduct['stock'] < $arrValues['quantity'][$i] - $arrOrderDetail['quantity'][$i]) {
             $class_name1 = $arrValues['classcategory_name1'][$i];
             $class_name1 = Utils::isBlank($class_name1) ? 'なし' : $class_name1;
             $class_name2 = $arrValues['classcategory_name2'][$i];
             $class_name2 = Utils::isBlank($class_name2) ? 'なし' : $class_name2;
             $arrErr['quantity'][$i] .= $arrValues['product_name'][$i] . '/(' . $class_name1 . ')/(' . $class_name2 . ') の在庫が不足しています。 設定できる数量は「' . ($arrOrderDetail['quantity'][$i] + $arrProduct['stock']) . '」までです。<br />';
         }
     }
     // 消費税
     $arrValues['tax'] = $totaltax;
     // 小計
     $arrValues['subtotal'] = $subtotal;
     // 合計
     $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge'];
     // お支払い合計
     $arrValues['payment_total'] = $arrValues['total'] - $arrValues['use_point'] * POINT_VALUE;
     // 加算ポイント
     $arrValues['add_point'] = Application::alias('eccube.helper.db')->getAddPoint($totalpoint, $arrValues['use_point']) + $arrValues['birth_point'];
     // 最終保持ポイント
     $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point'];
     if ($arrValues['total'] < 0) {
         $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />';
     }
     if ($arrValues['payment_total'] < 0) {
         $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />';
     }
     if ($arrValues['total_point'] < 0) {
         $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />';
     }
     $objFormParam->setParam($arrValues);
     $arrErr = array_merge($arrErr, $arrErrTemp);
     return $arrErr;
 }
Пример #5
0
 /**
  * テーブルを検索する.
  *
  * 引数に部分一致するテーブル名を配列で返す.
  *
  * @deprecated Query::listTables() を使用してください
  * @param  string $expression 検索文字列
  * @return array  テーブル名の配列
  */
 public function findTableNames($expression = '')
 {
     $objQuery = Application::alias('eccube.query');
     $sql = '   SELECT c.relname AS name, ' . '     CASE c.relkind ' . "     WHEN 'r' THEN 'table' " . "     WHEN 'v' THEN 'view' END AS type " . '     FROM pg_catalog.pg_class c ' . 'LEFT JOIN pg_catalog.pg_namespace n ' . '       ON n.oid = c.relnamespace ' . "    WHERE c.relkind IN ('r','v') " . "      AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " . '      AND pg_catalog.pg_table_is_visible(c.oid) ' . '      AND c.relname LIKE ?' . ' ORDER BY 1,2;';
     $arrColList = $objQuery->getAll($sql, array('%' . $expression . '%'));
     $arrColList = Utils::sfSwapArray($arrColList, false);
     return $arrColList[0];
 }
Пример #6
0
 /**
  * CSVカラム設定の読み込み
  *
  * @param  integer $csv_id         CSV ID
  * @param  integer $csv_status_flg 読み込む対象のフラグ CSV_COLUMN_STATUS_FLG_ENABLE or ''
  * @return integer   SwapArrayしたカラム設定
  */
 public function lfGetCSVColumn($csv_id, $csv_status_flg = '', $order = 'rank, no')
 {
     /* @var $objCSV CsvHelper */
     $objCSV = Application::alias('eccube.helper.csv');
     if (Utils::sfIsInt($csv_id)) {
         if ($csv_status_flg != '') {
             $arrData = $objCSV->sfGetCsvOutput($csv_id, 'status = ?', array($csv_status_flg), $order);
         } else {
             $arrData = $objCSV->sfGetCsvOutput($csv_id, '', array(), $order);
         }
         $arrData = Utils::sfSwapArray($arrData);
     } else {
         $arrData = array();
     }
     return $arrData;
 }
Пример #7
0
 private function lfGetOrderData($order_id)
 {
     if (Utils::sfIsInt($order_id)) {
         // DBから受注情報を読み込む
         /* @var $objPurchase PurchaseHelper */
         $objPurchase = Application::alias('eccube.helper.purchase');
         $this->arrDisp = $objPurchase->getOrder($order_id);
         list($point) = Application::alias('eccube.helper.customer')->sfGetCustomerPoint($order_id, $this->arrDisp['use_point'], $this->arrDisp['add_point']);
         $this->arrDisp['point'] = $point;
         // 受注詳細データの取得
         $arrRet = $objPurchase->getOrderDetail($order_id);
         $arrRet = Utils::sfSwapArray($arrRet);
         $this->arrDisp = array_merge($this->arrDisp, $arrRet);
         // その他支払い情報を表示
         if ($this->arrDisp['memo02'] != '') {
             $this->arrDisp['payment_info'] = unserialize($this->arrDisp['memo02']);
         }
         $this->arrDisp['payment_type'] = 'お支払い';
     }
 }
Пример #8
0
 /**
  * テーブルを検索する.
  *
  * 引数に部分一致するテーブル名を配列で返す.
  *
  * @param  string $expression 検索文字列
  * @return array  テーブル名の配列
  */
 public function findTableNames($expression = '')
 {
     $objQuery = Application::alias('eccube.query');
     $sql = 'SHOW TABLES LIKE ' . $objQuery->quote('%' . $expression . '%');
     $arrColList = $objQuery->getAll($sql);
     $arrColList = Utils::sfSwapArray($arrColList, false);
     return $arrColList[0];
 }
Пример #9
0
 /**
  * 規格編集画面を表示する
  *
  * @param FormParam $objFormParam
  */
 public function doPreEdit(&$objFormParam)
 {
     $product_id = $objFormParam->getValue('product_id');
     /* @var $objProduct Product */
     $objProduct = Application::alias('eccube.product');
     $existsProductsClass = $objProduct->getProductsClassFullByProductId($product_id);
     // 規格のデフォルト値(全ての組み合わせ)を取得し, フォームに反映
     $class_id1 = $existsProductsClass[0]['class_id1'];
     $class_id2 = $existsProductsClass[0]['class_id2'];
     $objFormParam->setValue('class_id1', $class_id1);
     $objFormParam->setValue('class_id2', $class_id2);
     $this->doDisp($objFormParam);
     /*
      * 登録済みのデータで, フォームの値を上書きする.
      *
      * 登録済みデータと, フォームの値は, 配列の形式が違うため,
      * 同じ形式の配列を生成し, マージしてフォームの値を上書きする
      */
     $arrKeys = array('classcategory_id1', 'classcategory_id2', 'product_code', 'classcategory_name1', 'classcategory_name2', 'stock', 'stock_unlimited', 'price01', 'price02', 'product_type_id', 'down_filename', 'down_realfilename', 'upload_index', 'tax_rate');
     $arrFormValues = $objFormParam->getSwapArray($arrKeys);
     // フォームの規格1, 規格2をキーにした配列を生成
     $arrClassCatKey = array();
     foreach ($arrFormValues as $formValue) {
         $arrClassCatKey[$formValue['classcategory_id1']][$formValue['classcategory_id2']] = $formValue;
     }
     // 登録済みデータをマージ
     foreach ($existsProductsClass as $existsValue) {
         $arrClassCatKey[$existsValue['classcategory_id1']][$existsValue['classcategory_id2']] = $existsValue;
     }
     // 規格のデフォルト値に del_flg をつけてマージ後の1次元配列を生成
     $arrMergeProductsClass = array();
     foreach ($arrClassCatKey as $arrC1) {
         foreach ($arrC1 as $arrValues) {
             $arrValues['del_flg'] = (string) $arrValues['del_flg'];
             if (Utils::isBlank($arrValues['del_flg']) || $arrValues['del_flg'] === '1') {
                 $arrValues['del_flg'] = '1';
             } else {
                 $arrValues['del_flg'] = '0';
             }
             // 消費税率を設定
             if (OPTION_PRODUCT_TAX_RULE) {
                 $arrRet = TaxRuleHelper::getTaxRule($arrValues['product_id'], $arrValues['product_class_id']);
                 $arrValues['tax_rate'] = $arrRet['tax_rate'];
             }
             $arrMergeProductsClass[] = $arrValues;
         }
     }
     // 登録済みのデータで上書き
     $objFormParam->setParam(Utils::sfSwapArray($arrMergeProductsClass));
     // $arrMergeProductsClass で product_id が配列になってしまうため数値で上書き
     $objFormParam->setValue('product_id', $product_id);
     // check を設定
     $arrChecks = array();
     $index = 0;
     foreach ($objFormParam->getValue('del_flg') as $key => $val) {
         if ($val === '0') {
             $arrChecks[$index] = 1;
         }
         $index++;
     }
     $objFormParam->setValue('check', $arrChecks);
     // class_id1, class_id2 を取得値で上書き
     $objFormParam->setValue('class_id1', $class_id1);
     $objFormParam->setValue('class_id2', $class_id2);
 }