/**
  * 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)
 {
     switch ($csv_id) {
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
             return parent::sfDownloadCsv($csv_id, $where, $arrVal, $order, $is_download);
     }
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     // CSV出力タイトル行の作成
     $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE));
     if (count($arrOutput) <= 0) {
         SC_Utils_Ex::sfDispError("");
         return false;
         // 失敗終了
     }
     $arrOutputCols = $arrOutput['col'];
     $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true);
     switch ($csv_id) {
         case 6:
             // キャラクター
             $from = 'cp_dtb_character';
             break;
         case 7:
             // 端末
             $from = 'cp_dtb_device';
             break;
     }
     $objQuery->setOrder($order);
     $sql = $objQuery->getSql($cols, $from, $where);
     return $this->sfDownloadCsvFromSql($sql, $arrVal, $this->arrSubnavi[$csv_id], $arrOutput['disp_name'], $is_download);
 }
Example #2
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 =& SC_Query_Ex::getSingletonInstance();
     // CSV出力タイトル行の作成
     $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE));
     if (count($arrOutput) <= 0) {
         return false;
     }
     // 失敗終了
     $arrOutputCols = $arrOutput['col'];
     $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true);
     // 商品の場合
     if ($csv_id == 1) {
         // この WHERE 句を足さないと無効な規格も出力される。現行仕様と合わせる為追加。
         $inner_where = 'dtb_products_class.del_flg = 0';
         $from = SC_Product_Ex::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);
 }
Example #3
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 mixed $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string
  */
 function sfDownloadCsv($csv_id, $where = '', $arrVal = array(), $order = '', $is_download = false)
 {
     // 実行時間を制限しない
     @set_time_limit(0);
     // CSV出力タイトル行の作成
     $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE));
     if (count($arrOutput) <= 0) {
         return false;
     }
     // 失敗終了
     $arrOutputCols = $arrOutput['col'];
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setOrder($order);
     $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true);
     // TODO: 固有処理 なんかエレガントな処理にしたい
     if ($csv_id == '1') {
         //商品の場合
         $objProduct = new SC_Product_Ex();
         // このWhereを足さないと無効な規格も出力される。現行仕様と合わせる為追加。
         $inner_where = 'dtb_products_class.del_flg = 0';
         $sql = $objQuery->getSql($cols, $objProduct->prdclsSQL($inner_where), $where);
     } else {
         if ($csv_id == '2') {
             // 会員の場合
             $sql = 'SELECT ' . $cols . ' FROM dtb_customer ' . $where;
         } else {
             if ($csv_id == '3') {
                 // 注文の場合
                 $sql = 'SELECT ' . $cols . ' FROM dtb_order ' . $where;
             } else {
                 if ($csv_id == '4') {
                     // レビューの場合
                     $sql = 'SELECT ' . $cols . ' FROM dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id ' . $where;
                 } else {
                     if ($csv_id == '5') {
                         // カテゴリの場合
                         $sql = 'SELECT ' . $cols . ' FROM dtb_category ' . $where;
                     }
                 }
             }
         }
     }
     // 固有処理ここまで
     return $this->sfDownloadCsvFromSql($sql, $arrVal, $this->arrSubnavi[$csv_id], $arrOutput['disp_name'], $is_download);
 }
 /**
  * テーブルを検索する.
  *
  * 引数に部分一致するテーブル名を配列で返す.
  *
  * @deprecated SC_Query::listTables() を使用してください
  * @param  string $expression 検索文字列
  * @return array  テーブル名の配列
  */
 public function findTableNames($expression = '')
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $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 = SC_Utils_Ex::sfSwapArray($arrColList, false);
     return $arrColList[0];
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_AdminView();
     $objDbFactory = SC_DB_DBFactory_Ex::getInstance();
     $objCSV = new SC_Helper_CSV_Ex();
     $this->arrSubnavi = $objCSV->arrSubnavi;
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (!isset($_POST['sql_id'])) {
         $_POST['sql_id'] = "";
     }
     if (!isset($_GET['sql_id'])) {
         $_GET['sql_id'] = "";
     }
     if (!isset($_POST['selectTable'])) {
         $_POST['selectTable'] = "";
     }
     // SQL_IDの取得
     if ($_POST['sql_id'] != "") {
         $sql_id = $_POST['sql_id'];
     } elseif ($_GET['sql_id'] != "") {
         $sql_id = $_GET['sql_id'];
     } else {
         $sql_id = "";
     }
     $mode = $_POST['mode'];
     switch ($_POST['mode']) {
         // データの登録
         case "confirm":
             // エラーチェック
             $this->arrErr = $this->lfCheckError($_POST);
             if (count($this->arrErr) <= 0) {
                 // データの更新
                 $sql_id = $this->lfUpdData($sql_id, $_POST);
                 // 完了メッセージ表示
                 $this->tpl_onload = "alert('登録が完了しました。');";
             }
             break;
             // 確認画面
         // 確認画面
         case "preview":
             // SQL文表示
             $sql = "SELECT \n" . $_POST['csv_sql'];
             // FIXME
             $this->sql = $sql;
             // エラー表示
             $objErrMsg = $this->lfCheckSQL($_POST);
             if ($objErrMsg != "") {
                 $errMsg = $objErrMsg->message . "\n" . $objErrMsg->userinfo;
             }
             $this->sqlerr = isset($errMsg) ? $errMsg : "";
             $this->objView = $objView;
             // 画面の表示
             $objView->assignobj($this);
             $objView->display('contents/csv_sql_view.tpl');
             exit;
             break;
             // 新規作成
         // 新規作成
         case "new_page":
             $this->sendRedirect($this->getLocation("./csv_sql.php"));
             exit;
             break;
             // データ削除
         // データ削除
         case "delete":
             $this->lfDelData($sql_id);
             $this->sendRedirect($this->getLocation("./csv_sql.php"));
             exit;
             break;
         case "csv_output":
             // CSV出力データ取得
             $arrCsvData = $this->lfGetSqlList(" WHERE sql_id = ?", array($_POST['csv_output_id']));
             $objQuery = new SC_Query();
             $arrCsvOutputData = $objQuery->getall("SELECT " . $arrCsvData[0]['csv_sql']);
             if (count($arrCsvOutputData) > 0) {
                 $arrKey = array_keys(SC_Utils_Ex::sfSwapArray($arrCsvOutputData));
                 $i = 0;
                 $header = "";
                 foreach ($arrKey as $data) {
                     if ($i != 0) {
                         $header .= ", ";
                     }
                     $header .= $data;
                     $i++;
                 }
                 $header .= "\r\n";
                 $data = SC_Utils_Ex::getCSVData($arrCsvOutputData, $arrKey);
                 // CSV出力
                 SC_Utils_Ex::sfCSVDownload($header . $data);
                 exit;
                 break;
             } else {
                 $this->tpl_onload = "alert('出力データがありません。');";
                 $sql_id = "";
                 $_POST = "";
             }
             break;
     }
     // mode が confirm 以外のときは完了メッセージは出力しない
     if ($mode != "confirm" and $mode != "csv_output") {
         $this->tpl_onload = "";
     }
     // 登録済みSQL一覧取得
     $arrSqlList = $this->lfGetSqlList();
     // 編集用SQLデータの取得
     if ($sql_id != "") {
         $arrSqlData = $this->lfGetSqlList(" WHERE sql_id = ?", array($sql_id));
     }
     // テーブル一覧を取得する
     $arrTableList = $this->lfGetTableList();
     $arrTableList = SC_Utils_Ex::sfSwapArray($arrTableList);
     // 現在選択されているテーブルを取得する
     if ($_POST['selectTable'] == "") {
         $selectTable = $arrTableList['table_name'][0];
     } else {
         $selectTable = $_POST['selectTable'];
     }
     // カラム一覧を取得する
     $arrColList = $this->lfGetColumnList($selectTable);
     $arrColList = SC_Utils_Ex::sfSwapArray($arrColList);
     // 表示させる内容を編集
     foreach ($arrTableList['description'] as $key => $val) {
         $arrTableList['description'][$key] = $arrTableList['table_name'][$key] . ":" . $arrTableList['description'][$key];
     }
     foreach ($arrColList['description'] as $key => $val) {
         $arrColList['description'][$key] = $arrColList['column_name'][$key] . ":" . $arrColList['description'][$key];
     }
     $arrDiff = array_diff($objDbFactory->sfGetColumnList($selectTable), $arrColList["column_name"]);
     $arrColList["column_name"] = array_merge($arrColList["column_name"], $arrDiff);
     $arrColList["description"] = array_merge($arrColList["description"], $arrDiff);
     // テンプレートに出力するデータをセット
     $this->arrSqlList = $arrSqlList;
     // SQL一覧
     $this->arrTableList = SC_Utils_Ex::sfarrCombine($arrTableList['table_name'], $arrTableList['description']);
     // テーブル一覧
     $this->arrColList = SC_Utils_Ex::sfarrCombine($arrColList['column_name'], $arrColList['description']);
     // カラム一覧
     $this->selectTable = $selectTable;
     // 選択されているテーブル
     $this->sql_id = $sql_id;
     // 選択されているSQL
     // POSTされたデータをセットする
     if (isset($_POST['sql_name']) && isset($_POST['csv_sql'])) {
         $arrSqlData[0]['sql_name'] = isset($_POST['sql_name']) ? $_POST['sql_name'] : "";
         $arrSqlData[0]['csv_sql'] = isset($_POST['csv_sql']) ? $_POST['csv_sql'] : "";
     }
     $this->arrSqlData = $arrSqlData[0];
     // 選択されているSQLデータ
     // 画面の表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * 入力内容のチェックを行う.
  *
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return array エラーメッセージの配列
  */
 function lfCheckError(&$objFormParam)
 {
     $objProduct = new SC_Product_Ex();
     $arrErr = $objFormParam->checkError();
     if (!SC_Utils_Ex::isBlank($objErr->arrErr)) {
         return $arrErr;
     }
     $arrValues = $objFormParam->getHashArray();
     // 商品の種類数
     $max = count($arrValues['quantity']);
     $subtotal = 0;
     $totalpoint = 0;
     $totaltax = 0;
     for ($i = 0; $i < $max; $i++) {
         // 小計の計算
         $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i]) * $arrValues['quantity'][$i];
         // 小計の計算
         $totaltax += SC_Helper_DB_Ex::sfTax($arrValues['price'][$i]) * $arrValues['quantity'][$i];
         // 加算ポイントの計算
         $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i];
         // 在庫数のチェック
         $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]);
         // 編集前の値と比較するため受注詳細を取得
         $objPurchase = new SC_Helper_Purchase_Ex();
         $arrOrderDetail = SC_Utils_Ex::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 = SC_Utils_Ex::isBlank($class_name1) ? 'なし' : $class_name1;
             $class_name2 = $arrValues['classcategory_name2'][$i];
             $class_name2 = SC_Utils_Ex::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'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_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);
     return $arrErr;
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     //---- 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     $objView = new SC_AdminView();
     $objQuery = new SC_Query();
     $objFormParam = new SC_FormParam();
     $objCSV = new SC_Helper_CSV_Ex();
     // パラメータ情報の初期化
     $this->lfInitParam($objFormParam);
     // フォームの値をセット
     $objFormParam->setParam($_POST);
     // 編集処理の場合は状態を保持
     $this->is_update = isset($_POST['is_update']) ? $_POST['is_update'] : "";
     // フォームの値をテンプレートへ渡す
     $this->arrForm = $objFormParam->getHashArray();
     $campaign_id = isset($_POST['campaign_id']) ? $_POST['campaign_id'] : "";
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         // 新規登録/編集登録
         case 'regist':
             // エラーチェック
             $this->arrErr = $this->lfErrorCheck($campaign_id, $objQuery, $objFormParam);
             if (count($this->arrErr) <= 0) {
                 // 登録
                 $this->lfRegistCampaign($campaign_id, $objQuery, $objFormParam);
                 // キャンペーンTOPへリダイレクト
                 $this->sendRedirect($this->getLocation(URL_CAMPAIGN_TOP));
                 exit;
             }
             break;
             // 編集押下時
         // 編集押下時
         case 'update':
             // キャンペーン情報を取得
             $this->arrForm = $this->lfGetCampaign($campaign_id, $objQuery);
             $this->is_update = true;
             break;
             // 削除押下時
         // 削除押下時
         case 'delete':
             // 削除
             $this->lfDeleteCampaign($campaign_id, $objQuery);
             // キャンペーンTOPへリダイレクト
             $this->sendRedirect($this->getLocation(URL_CAMPAIGN_TOP));
             exit;
             break;
             // CSV出力
         // CSV出力
         case 'csv':
             // オプションの指定
             $option = "ORDER BY create_date DESC";
             // CSV出力タイトル行の作成
             $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(4, " WHERE csv_id = 4 AND status = 1"));
             if (count($arrCsvOutput) <= 0) {
                 break;
             }
             $arrCsvOutputCols = $arrCsvOutput['col'];
             $arrCsvOutputTitle = $arrCsvOutput['disp_name'];
             $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle);
             $data = $objCSV->lfGetCSV("dtb_campaign_order", "campaign_id = ?", $option, array($campaign_id), $arrCsvOutputCols);
             // CSVを送信する。
             SC_Utils_Ex::sfCSVDownload($head . $data);
             exit;
             break;
         default:
             break;
     }
     // キャンペーン一覧取得
     $this->arrCampaign = $this->lfGetCampaignList($objQuery);
     $this->campaign_id = $campaign_id;
     // キャンペーン期間用
     $objDate = new SC_Date();
     $this->arrYear = $objDate->getYear(min(date('Y'), $this->arrForm['start_year']));
     $this->arrMonth = $objDate->getMonth();
     $this->arrDay = $objDate->getDay();
     $this->arrHour = $objDate->getHour();
     $this->arrMinutes = $objDate->getMinutes();
     //---- ページ表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * 規格編集画面を表示する
  *
  * @param integer $product_id 商品ID
  * @param bool $existsValue
  * @param bool $usepostValue
  */
 function doPreEdit(&$objFormParam)
 {
     $product_id = $objFormParam->getValue('product_id');
     $objProduct = new SC_Product_Ex();
     $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');
     $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 (SC_Utils_Ex::isBlank($arrValues['del_flg']) || $arrValues['del_flg'] === '1') {
                 $arrValues['del_flg'] = '1';
             } else {
                 $arrValues['del_flg'] = '0';
             }
             $arrMergeProductsClass[] = $arrValues;
         }
     }
     // 登録済みのデータで上書き
     $objFormParam->setParam(SC_Utils_Ex::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);
 }
 /**
  * CSVカラム設定の読み込み
  *
  * @param integer $csv_id CSV ID
  * @param integer $csv_status_flg 読み込む対象のフラグ CSV_COLUMN_STATUS_FLG_ENABLE or ''
  * @return array SwapArrayしたカラム設定
  */
 function lfGetCSVColumn($csv_id, $csv_status_flg = '', $order = 'rank, no')
 {
     $objCSV = new SC_Helper_CSV_Ex();
     if (SC_Utils_Ex::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 = SC_Utils_Ex::sfSwapArray($arrData);
     } else {
         $arrData = array();
     }
     return $arrData;
 }
Example #10
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $conn = new SC_DBConn();
     $objView = new SC_AdminView();
     $objDb = new SC_Helper_DB_Ex();
     $objSess = new SC_Session();
     // パラメータ管理クラス
     $this->objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam();
     $this->objFormParam->setParam($_POST);
     $this->objFormParam->splitParamCheckBoxes('search_order_sex');
     $this->objFormParam->splitParamCheckBoxes('search_payment_id');
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         if (ereg("^search_", $key)) {
             switch ($key) {
                 case 'search_order_sex':
                 case 'search_payment_id':
                     $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
                     break;
                 default:
                     $this->arrHidden[$key] = $val;
                     break;
             }
         }
     }
     // ページ送り用
     $this->arrHidden['search_pageno'] = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (!isset($arrRet)) {
         $arrRet = array();
     }
     if ($_POST['mode'] == 'delete') {
         if (SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
             $objQuery = new SC_Query();
             $where = "order_id = ?";
             $sqlval['del_flg'] = '1';
             $objQuery->update("dtb_order", $sqlval, $where, array($_POST['order_id']));
         }
     }
     switch ($_POST['mode']) {
         case 'delete':
         case 'csv':
         case 'pdf':
         case 'delete_all':
         case 'search':
             // 入力値の変換
             $this->objFormParam->convParam();
             $this->arrErr = $this->lfCheckError($arrRet);
             $arrRet = $this->objFormParam->getHashArray();
             // 入力なし
             if (count($this->arrErr) == 0) {
                 $where = "del_flg = 0";
                 foreach ($arrRet as $key => $val) {
                     if ($val == "") {
                         continue;
                     }
                     $val = SC_Utils_Ex::sfManualEscape($val);
                     switch ($key) {
                         case 'search_order_name':
                             if (DB_TYPE == "pgsql") {
                                 $where .= " AND order_name01||order_name02 ILIKE ?";
                             } elseif (DB_TYPE == "mysql") {
                                 $where .= " AND concat(order_name01,order_name02) ILIKE ?";
                             }
                             $nonsp_val = mb_ereg_replace("[  ]+", "", $val);
                             $arrval[] = "%{$nonsp_val}%";
                             break;
                         case 'search_order_kana':
                             if (DB_TYPE == "pgsql") {
                                 $where .= " AND order_kana01||order_kana02 ILIKE ?";
                             } elseif (DB_TYPE == "mysql") {
                                 $where .= " AND concat(order_kana01,order_kana02) ILIKE ?";
                             }
                             $nonsp_val = mb_ereg_replace("[  ]+", "", $val);
                             $arrval[] = "%{$nonsp_val}%";
                             break;
                         case 'search_order_id1':
                             $where .= " AND order_id >= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_order_id2':
                             $where .= " AND order_id <= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_order_sex':
                             $tmp_where = "";
                             foreach ($val as $element) {
                                 if ($element != "") {
                                     if ($tmp_where == "") {
                                         $tmp_where .= " AND (order_sex = ?";
                                     } else {
                                         $tmp_where .= " OR order_sex = ?";
                                     }
                                     $arrval[] = $element;
                                 }
                             }
                             if ($tmp_where != "") {
                                 $tmp_where .= ")";
                                 $where .= " {$tmp_where} ";
                             }
                             break;
                         case 'search_order_tel':
                             if (DB_TYPE == "pgsql") {
                                 $where .= " AND (order_tel01 || order_tel02 || order_tel03) LIKE ?";
                             } elseif (DB_TYPE == "mysql") {
                                 $where .= " AND concat(order_tel01,order_tel02,order_tel03) LIKE ?";
                             }
                             $nonmark_val = ereg_replace("[()-]+", "", $val);
                             $arrval[] = "%{$nonmark_val}%";
                             break;
                         case 'search_order_email':
                             $where .= " AND order_email ILIKE ?";
                             $arrval[] = "%{$val}%";
                             break;
                         case 'search_payment_id':
                             $tmp_where = "";
                             foreach ($val as $element) {
                                 if ($element != "") {
                                     if ($tmp_where == "") {
                                         $tmp_where .= " AND (payment_id = ?";
                                     } else {
                                         $tmp_where .= " OR payment_id = ?";
                                     }
                                     $arrval[] = $element;
                                 }
                             }
                             if ($tmp_where != "") {
                                 $tmp_where .= ")";
                                 $where .= " {$tmp_where} ";
                             }
                             break;
                         case 'search_total1':
                             $where .= " AND total >= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_total2':
                             $where .= " AND total <= ?";
                             $arrval[] = $val;
                             break;
                         case 'search_sorderyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sorderyear'], $_POST['search_sordermonth'], $_POST['search_sorderday']);
                             $where .= " AND create_date >= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_eorderyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eorderyear'], $_POST['search_eordermonth'], $_POST['search_eorderday'], true);
                             $where .= " AND create_date <= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_supdateyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_supdateyear'], $_POST['search_supdatemonth'], $_POST['search_supdateday']);
                             $where .= " AND update_date >= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_eupdateyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_eupdateyear'], $_POST['search_eupdatemonth'], $_POST['search_eupdateday'], true);
                             $where .= " AND update_date <= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_sbirthyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_sbirthyear'], $_POST['search_sbirthmonth'], $_POST['search_sbirthday']);
                             $where .= " AND order_birth >= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_ebirthyear':
                             $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_ebirthyear'], $_POST['search_ebirthmonth'], $_POST['search_ebirthday'], true);
                             $where .= " AND order_birth <= ?";
                             $arrval[] = $date;
                             break;
                         case 'search_order_status':
                             $where .= " AND status = ?";
                             $arrval[] = $val;
                             break;
                         default:
                             if (!isset($arrval)) {
                                 $arrval = array();
                             }
                             break;
                     }
                 }
                 $order = "update_date DESC";
                 switch ($_POST['mode']) {
                     case 'csv':
                         require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
                         $objCSV = new SC_Helper_CSV_Ex();
                         // オプションの指定
                         $option = "ORDER BY {$order}";
                         // CSV出力タイトル行の作成
                         $arrCsvOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(3, " WHERE csv_id = 3 AND status = 1"));
                         if (count($arrCsvOutput) <= 0) {
                             break;
                         }
                         $arrCsvOutputCols = $arrCsvOutput['col'];
                         $arrCsvOutputTitle = $arrCsvOutput['disp_name'];
                         $head = SC_Utils_Ex::sfGetCSVList($arrCsvOutputTitle);
                         $data = $objCSV->lfGetCSV("dtb_order", $where, $option, $arrval, $arrCsvOutputCols);
                         // CSVを送信する。
                         SC_Utils_Ex::sfCSVDownload($head . $data);
                         exit;
                         break;
                     case 'pdf':
                         $objFpdf = new SC_Fpdf(1, '納品書');
                         $objFpdf->setData($arrRet);
                         $objFpdf->createPdf();
                         break;
                     case 'delete_all':
                         // 検索結果をすべて削除
                         $sqlval['del_flg'] = 1;
                         $objQuery = new SC_Query();
                         $objQuery->update("dtb_order", $sqlval, $where, $arrval);
                         break;
                     default:
                         // 読み込む列とテーブルの指定
                         $col = "*";
                         $from = "dtb_order";
                         $objQuery = new SC_Query();
                         // 行数の取得
                         $linemax = $objQuery->count($from, $where, $arrval);
                         $this->tpl_linemax = $linemax;
                         // 何件が該当しました。表示用
                         // ページ送りの処理
                         if (is_numeric($_POST['search_page_max'])) {
                             $page_max = $_POST['search_page_max'];
                         } else {
                             $page_max = SEARCH_PMAX;
                         }
                         // ページ送りの取得
                         $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX);
                         $startno = $objNavi->start_row;
                         $this->arrPagenavi = $objNavi->arrPagenavi;
                         // 取得範囲の指定(開始行番号、行数のセット)
                         $objQuery->setlimitoffset($page_max, $startno);
                         // 表示順序
                         $objQuery->setorder($order);
                         // 検索結果の取得
                         $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
                 }
             }
             break;
         default:
             break;
     }
     $objDate = new SC_Date();
     // 登録・更新日検索用
     $objDate->setStartYear(RELEASE_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrRegistYear = $objDate->getYear();
     // 生年月日検索用
     $objDate->setStartYear(BIRTH_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrBirthYear = $objDate->getYear();
     // 月日の設定
     $this->arrMonth = $objDate->getMonth();
     $this->arrDay = $objDate->getDay();
     // 入力値の取得
     $this->arrForm = $this->objFormParam->getFormParamList();
     // 支払い方法の取得
     $arrRet = $objDb->sfGetPayment();
     $this->arrPayment = SC_Utils_Ex::sfArrKeyValue($arrRet, 'payment_id', 'payment_method');
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_AdminView();
     $objDb = new SC_Helper_DB_Ex();
     $objDate = new SC_Date();
     // 登録・更新検索開始年
     $objDate->setStartYear(RELEASE_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrStartYear = $objDate->getYear();
     $this->arrStartMonth = $objDate->getMonth();
     $this->arrStartDay = $objDate->getDay();
     // 登録・更新検索終了年
     $objDate->setStartYear(RELEASE_YEAR);
     $objDate->setEndYear(DATE("Y"));
     $this->arrEndYear = $objDate->getYear();
     $this->arrEndMonth = $objDate->getMonth();
     $this->arrEndDay = $objDate->getDay();
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     //キャンペーンの編集時
     if (isset($_POST['campaign_id']) && SC_Utils_Ex::sfIsInt($_POST['campaign_id']) && $_POST['mode'] == "camp_search") {
         $objQuery = new SC_Query();
         $search_data = $objQuery->get("dtb_campaign", "search_condition", "campaign_id = ? ", array($_POST['campaign_id']));
         $arrSearch = unserialize($search_data);
         foreach ($arrSearch as $key => $val) {
             $_POST[$key] = $val;
         }
     }
     // POST値の引き継ぎ
     $this->arrForm = $_POST;
     // 検索ワードの引き継ぎ
     foreach ($_POST as $key => $val) {
         if (ereg("^search_", $key) || ereg("^campaign_", $key)) {
             switch ($key) {
                 case 'search_product_flag':
                 case 'search_status':
                     $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
                     if (!is_array($val)) {
                         $this->arrForm[$key] = split("-", $val);
                     }
                     break;
                 default:
                     $this->arrHidden[$key] = $val;
                     break;
             }
         }
     }
     // ページ送り用
     $this->arrHidden['search_pageno'] = isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
     // 商品削除
     if ($_POST['mode'] == "delete") {
         if ($_POST['category_id'] != "") {
             // ランク付きレコードの削除
             $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['category_id']);
             $objDb->sfDeleteRankRecord("dtb_products", "product_id", $_POST['product_id'], $where);
         } else {
             $objDb->sfDeleteRankRecord("dtb_products", "product_id", $_POST['product_id']);
         }
         // 子テーブル(商品規格)の削除
         $objQuery = new SC_Query();
         $objQuery->delete("dtb_products_class", "product_id = ?", array($_POST['product_id']));
         // 件数カウントバッチ実行
         $objDb->sfCategory_Count($objQuery);
     }
     if ($_POST['mode'] == "search" || $_POST['mode'] == "csv" || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all" || $_POST['mode'] == "camp_search") {
         // 入力文字の強制変換
         $this->lfConvertParam();
         // エラーチェック
         $this->arrErr = $this->lfCheckError();
         $where = "del_flg = 0";
         $view_where = "del_flg = 0";
         // 入力エラーなし
         if (count($this->arrErr) == 0) {
             $arrval = array();
             foreach ($this->arrForm as $key => $val) {
                 $val = SC_Utils_Ex::sfManualEscape($val);
                 if ($val == "") {
                     continue;
                 }
                 switch ($key) {
                     case 'search_product_id':
                         // 商品ID
                         $where .= " AND product_id = ?";
                         $view_where .= " AND product_id = ?";
                         $arrval[] = $val;
                         break;
                     case 'search_product_class_name':
                         //規格名称
                         $where_in = " (SELECT classcategory_id FROM dtb_classcategory WHERE class_id IN (SELECT class_id FROM dtb_class WHERE name LIKE ?)) ";
                         $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE classcategory_id1 IN " . $where_in;
                         $where .= " OR classcategory_id2 IN" . $where_in . ")";
                         $view_where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE classcategory_id1 IN " . $where_in;
                         $view_where .= " OR classcategory_id2 IN" . $where_in . ")";
                         $arrval[] = "%{$val}%";
                         $arrval[] = "%{$val}%";
                         $view_where = $where;
                         break;
                     case 'search_name':
                         // 商品名
                         $where .= " AND name ILIKE ?";
                         $view_where .= " AND name ILIKE ?";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_category_id':
                         // カテゴリー
                         list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val);
                         if ($tmp_where != "") {
                             $where .= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
                             $view_where .= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
                             $arrval = array_merge((array) $arrval, (array) $tmp_arrval);
                         }
                         break;
                     case 'search_product_code':
                         // 商品コード
                         $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)";
                         $view_where .= " AND EXISTS (SELECT product_id FROM dtb_products_class as cls WHERE cls.product_code ILIKE ? AND dtb_products.product_id = cls.product_id GROUP BY cls.product_id )";
                         $arrval[] = "%{$val}%";
                         break;
                     case 'search_startyear':
                         // 登録更新日(FROM)
                         $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
                         $where .= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth'] . "/" . $_POST['search_startday'] . "'";
                         $view_where .= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth'] . "/" . $_POST['search_startday'] . "'";
                         break;
                     case 'search_endyear':
                         // 登録更新日(TO)
                         $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
                         $date = date('Y/m/d', strtotime($date) + 86400);
                         $where .= " AND update_date < date('" . $date . "')";
                         $view_where .= " AND update_date < date('" . $date . "')";
                         break;
                     case 'search_product_flag':
                         //種別
                         global $arrSTATUS;
                         $search_product_flag = SC_Utils_Ex::sfSearchCheckBoxes($val);
                         if ($search_product_flag != "") {
                             $where .= " AND product_flag LIKE ?";
                             $view_where .= " AND product_flag LIKE ?";
                             $arrval[] = $search_product_flag;
                         }
                         break;
                     case 'search_status':
                         // ステータス
                         $tmp_where = "";
                         foreach ($val as $element) {
                             if ($element != "") {
                                 if ($tmp_where == "") {
                                     $tmp_where .= "AND (status = ? ";
                                 } else {
                                     $tmp_where .= "OR status = ? ";
                                 }
                                 $arrval[] = $element;
                             }
                         }
                         if ($tmp_where != "") {
                             $tmp_where .= ")";
                             $where .= " {$tmp_where}";
                             $view_where .= " {$tmp_where}";
                         }
                         break;
                     default:
                         break;
                 }
             }
             $order = "update_date DESC, product_id DESC";
             $objQuery = new SC_Query();
             switch ($_POST['mode']) {
                 case 'csv':
                     require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
                     $objCSV = new SC_Helper_CSV_Ex();
                     // オプションの指定
                     $option = "ORDER BY {$order}";
                     // CSV出力タイトル行の作成
                     $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(1, " WHERE csv_id = 1 AND status = 1"));
                     if (count($arrOutput) <= 0) {
                         break;
                     }
                     $arrOutputCols = $arrOutput['col'];
                     $arrOutputTitle = $arrOutput['disp_name'];
                     $head = SC_Utils_Ex::sfGetCSVList($arrOutputTitle);
                     $data = $objCSV->lfGetProductsCSV($where, $option, $arrval, $arrOutputCols);
                     // CSVを送信する。
                     SC_Utils_Ex::sfCSVDownload($head . $data);
                     exit;
                     break;
                 case 'delete_all':
                     // 検索結果の取得
                     $col = "product_id";
                     $from = "vw_products_nonclass AS noncls ";
                     $arrProducts = $objQuery->select($col, $from, $where, $arrval);
                     // 検索結果をすべて削除
                     $sqlval['del_flg'] = 1;
                     $where = "product_id = ?";
                     if (count($arrProducts) > 0) {
                         foreach ($arrProducts as $key => $val) {
                             $objQuery->update("dtb_products", $sqlval, $where, array($arrProducts[$key]["product_id"]));
                         }
                     }
                     break;
                 default:
                     // 読み込む列とテーブルの指定
                     $col = "product_id, name, category_id, main_list_image, status, product_code, price01, price02, stock, stock_unlimited";
                     $from = "vw_products_nonclass AS noncls ";
                     // 行数の取得
                     $linemax = $objQuery->count("dtb_products", $view_where, $arrval);
                     $this->tpl_linemax = $linemax;
                     // 何件が該当しました。表示用
                     // ページ送りの処理
                     if (is_numeric($_POST['search_page_max'])) {
                         $page_max = $_POST['search_page_max'];
                     } else {
                         $page_max = SEARCH_PMAX;
                     }
                     // ページ送りの取得
                     $objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX);
                     $startno = $objNavi->start_row;
                     $this->arrPagenavi = $objNavi->arrPagenavi;
                     //キャンペーン商品検索時は、全結果の商品IDを変数に格納する
                     if (isset($_POST['search_mode']) && $_POST['search_mode'] == 'campaign') {
                         $arrRet = $objQuery->select($col, $from, $where, $arrval);
                         if (count($arrRet) > 0) {
                             $arrRet = sfSwapArray($arrRet);
                             $pid = implode("-", $arrRet['product_id']);
                             $this->arrHidden['campaign_product_id'] = $pid;
                         }
                     }
                     // 取得範囲の指定(開始行番号、行数のセット)
                     //                    if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno);
                     $objQuery->setlimitoffset($page_max, $startno);
                     // 表示順序
                     $objQuery->setorder($order);
                     // 検索結果の取得
                     $this->arrProducts = $objQuery->select($col, $from, $where, $arrval);
                     // 各商品ごとのカテゴリIDを取得
                     if (count($this->arrProducts) > 0) {
                         foreach ($this->arrProducts as $key => $val) {
                             $this->arrProducts[$key]["categories"] = $objDb->sfGetCategoryId($val["product_id"]);
                             $objDb->g_category_on = false;
                         }
                     }
             }
         }
     }
     // カテゴリの読込
     list($this->arrCatKey, $this->arrCatVal) = $objDb->sfGetLevelCatList(false);
     $this->arrCatList = $this->lfGetIDName($this->arrCatKey, $this->arrCatVal);
     // 画面の表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 function Lfgetcolumnlist($table_name)
 {
     $objQuery = new SC_Query();
     if (DB_TYPE == "pgsql") {
         $sql = "SELECT\n                    a.attname, t.typname, a.attnotnull, d.adsrc as defval, a.atttypmod, a.attnum as fldnum, e.description\n                FROM\n                    pg_class c,\n                    pg_type t,\n                    pg_attribute a left join pg_attrdef d on (a.attrelid=d.adrelid and a.attnum=d.adnum)\n                                   left join pg_description e on (a.attrelid=e.objoid and a.attnum=e.objsubid)\n                WHERE (c.relname=?) AND (c.oid=a.attrelid) AND (a.atttypid=t.oid) AND a.attnum > 0\n                ORDER BY fldnum";
         $arrColList = $objQuery->getAll($sql, array($table_name));
         $arrColList = SC_Utils_Ex::sfSwapArray($arrColList);
         $arrRet['col_def'] = $arrColList['defval'];
         $arrRet['col_name'] = $arrColList['attname'];
     } else {
         if (DB_TYPE == "mysql") {
             $sql = "SHOW COLUMNS FROM {$table_name}";
             $arrColList = $objQuery->getAll($sql);
             $arrColList = SC_Utils_Ex::sfSwapArray($arrColList);
             $arrRet['col_def'] = $arrColList['Extra'];
             $arrRet['col_name'] = $arrColList['Field'];
         }
     }
     return $arrRet;
 }
Example #13
0
 function lfGetOrderData($order_id)
 {
     if (SC_Utils_Ex::sfIsInt($order_id)) {
         // DBから受注情報を読み込む
         $objQuery = new SC_Query_Ex();
         $where = "order_id = ?";
         $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
         $this->arrDisp = $arrRet[0];
         list($point) = SC_Helper_Customer_Ex::sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
         $this->arrDisp['point'] = $point;
         // 受注詳細データの取得
         $arrRet = $this->lfGetOrderDetail($order_id);
         $arrRet = SC_Utils_Ex::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"] = "お支払い";
     }
 }
 function lfGetOrderData($order_id)
 {
     if (SC_Utils_Ex::sfIsInt($order_id)) {
         // DBから受注情報を読み込む
         $objQuery = new SC_Query();
         $objDb = new SC_Helper_DB_Ex();
         $where = "order_id = ?";
         $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
         $this->objFormParam->setParam($arrRet[0]);
         list($point, $total_point) = $objDb->sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
         $this->objFormParam->setValue('total_point', $total_point);
         $this->objFormParam->setValue('point', $point);
         $this->arrForm = $arrRet[0];
         // 受注詳細データの取得
         $arrRet = $this->lfGetOrderDetail($order_id);
         $arrRet = SC_Utils_Ex::sfSwapArray($arrRet);
         $this->arrForm = array_merge($this->arrForm, $arrRet);
         $this->objFormParam->setParam($arrRet);
         // その他支払い情報を表示
         if ($this->arrForm["memo02"] != "") {
             $this->arrForm["payment_info"] = unserialize($this->arrForm["memo02"]);
         }
         if ($this->arrForm["memo01"] == PAYMENT_CREDIT_ID) {
             $this->arrForm["payment_type"] = "クレジット決済";
         } elseif ($this->arrForm["memo01"] == PAYMENT_CONVENIENCE_ID) {
             $this->arrForm["payment_type"] = "コンビニ決済";
         } else {
             $this->arrForm["payment_type"] = "お支払い";
         }
         //受注データを表示用配列に代入(各EC-CUBEバージョンと決済モジュールとのデータ連携保全のため)
         $this->arrDisp = $this->arrForm;
     }
 }
 /**
  * 入力内容のチェックを行う.
  *
  * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return array        エラーメッセージの配列
  */
 public function lfCheckError(&$objFormParam)
 {
     $objProduct = new SC_Product_Ex();
     $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];
         $objError = new SC_CheckError_Ex(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'];
     $objError = new SC_CheckError_Ex(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 += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i];
         // 小計の計算
         $totaltax += SC_Utils_Ex::sfTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i];
         // 加算ポイントの計算
         $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i];
         // 在庫数のチェック
         $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]);
         // 編集前の値と比較するため受注詳細を取得
         $objPurchase = new SC_Helper_Purchase_Ex();
         $arrOrderDetail = SC_Utils_Ex::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 = SC_Utils_Ex::isBlank($class_name1) ? 'なし' : $class_name1;
             $class_name2 = $arrValues['classcategory_name2'][$i];
             $class_name2 = SC_Utils_Ex::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'] = SC_Helper_DB_Ex::sfGetAddPoint($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;
 }
 function lfGetOrderData($order_id)
 {
     if (SC_Utils_Ex::sfIsInt($order_id)) {
         // DBから受注情報を読み込む
         $objQuery =& SC_Query_Ex::getSingletonInstance();
         $where = 'order_id = ?';
         $arrRet = $objQuery->select('*', 'dtb_order', $where, array($order_id));
         $this->arrDisp = $arrRet[0];
         list($point) = SC_Helper_Customer_Ex::sfGetCustomerPoint($order_id, $arrRet[0]['use_point'], $arrRet[0]['add_point']);
         $this->arrDisp['point'] = $point;
         // 受注詳細データの取得
         $arrRet = $this->lfGetOrderDetail($order_id);
         $arrRet = SC_Utils_Ex::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'] = 'お支払い';
     }
 }
 /**
  * lfGetProductKeys.
  *
  * @param array $arrProduct 商品データ配列
  * @return array $arrProductKeys 商品情報のkey配列を返す
  */
 function lfGetProductKeys($arrProduct)
 {
     $arrProductKeys = array();
     $arrProduct = SC_Utils_Ex::sfSwapArray($arrProduct);
     if (is_array($arrProduct)) {
         $arrProductKeys = array_keys($arrProduct);
     }
     return $arrProductKeys;
 }
Example #18
0
 /**
  * 配列の縦横を入れ替えて返す
  *
  * @param array $arrKey 対象のキー
  * @return array 縦横を入れ替えた配列
  */
 function getSwapArray($arrKey = array())
 {
     $arrTmp = $this->getHashArray($arrKey);
     return SC_Utils_Ex::sfSwapArray($arrTmp);
 }
 private function lfGetOrderData($order_id)
 {
     if (SC_Utils_Ex::sfIsInt($order_id)) {
         // DBから受注情報を読み込む
         $objPurchase = new SC_Helper_Purchase_Ex();
         $this->arrDisp = $objPurchase->getOrder($order_id);
         list($point) = SC_Helper_Customer_Ex::sfGetCustomerPoint($order_id, $this->arrDisp['use_point'], $this->arrDisp['add_point']);
         $this->arrDisp['point'] = $point;
         // 受注詳細データの取得
         $arrRet = $objPurchase->getOrderDetail($order_id);
         $arrRet = SC_Utils_Ex::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'] = 'お支払い';
     }
 }
 /**
  * テーブルを検索する.
  *
  * 引数に部分一致するテーブル名を配列で返す.
  *
  * @deprecated SC_Query::listTables() を使用してください
  * @param string $expression 検索文字列
  * @return array テーブル名の配列
  */
 function findTableNames($expression = "")
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $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 = SC_Utils_Ex::sfSwapArray($arrColList, false);
     return $arrColList[0];
 }
 /**
  * テーブルを検索する.
  *
  * 引数に部分一致するテーブル名を配列で返す.
  *
  * @param string $expression 検索文字列
  * @return array テーブル名の配列
  */
 function findTableNames($expression = '')
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $sql = 'SHOW TABLES LIKE ' . $objQuery->quote('%' . $expression . '%');
     $arrColList = $objQuery->getAll($sql);
     $arrColList = SC_Utils_Ex::sfSwapArray($arrColList, false);
     return $arrColList[0];
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_AdminView();
     $objSess = new SC_Session();
     $objCSV = new SC_Helper_CSV_Ex();
     $this->arrSubnavi = $objCSV->arrSubnavi;
     $this->tpl_subno_csv = $objCSV->arrSubnavi[1];
     $this->arrSubnaviName = $objCSV->arrSubnaviName;
     // 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     $arrOutput = array();
     $arrChoice = array();
     $get_tpl_subno_csv = isset($_GET['tpl_subno_csv']) ? $_GET['tpl_subno_csv'] : "";
     // GETで値が送られている場合にはその値を元に画面表示を切り替える
     if ($get_tpl_subno_csv != "") {
         // 送られてきた値が配列に登録されていなければTOPを表示
         if (in_array($get_tpl_subno_csv, $this->arrSubnavi)) {
             $subno_csv = $get_tpl_subno_csv;
         } else {
             $subno_csv = $this->arrSubnavi[1];
         }
     } else {
         // GETで値がなければPOSTの値を使用する
         if (isset($_POST['tpl_subno_csv']) && $_POST['tpl_subno_csv'] != "") {
             $subno_csv = $_POST['tpl_subno_csv'];
         } else {
             $subno_csv = $this->arrSubnavi[1];
         }
     }
     // subnoの番号を取得
     $subno_id = array_keys($this->arrSubnavi, $subno_csv);
     $subno_id = $subno_id[0];
     // データの登録
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if ($_POST["mode"] == "confirm") {
         // エラーチェック
         $this->arrErr = $this->lfCheckError($_POST['output_list']);
         if (count($this->arrErr) <= 0) {
             // データの更新
             $this->lfUpdCsvOutput($subno_id, $_POST['output_list']);
             // 画面のリロード
             $this->reload(array("tpl_subno_csv" => $subno_csv));
         }
     }
     // 出力項目の取得
     $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_csv, "WHERE csv_id = ? AND status = 1", array($subno_id)));
     $arrOutput = SC_Utils_Ex::sfarrCombine($arrOutput['col'], $arrOutput['disp_name']);
     // 非出力項目の取得
     $arrChoice = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_csv, "WHERE csv_id = ? AND status = 2", array($subno_id)));
     if (!isset($arrChoice['col'])) {
         $arrChoice['col'] = array();
     }
     if (!isset($arrChoice['disp_name'])) {
         $arrChoice['disp_name'] = array();
     }
     $arrChoice = SC_Utils_Ex::sfarrCombine($arrChoice['col'], $arrChoice['disp_name']);
     $this->arrOutput = $arrOutput;
     $this->arrChoice = $arrChoice;
     $this->SubnaviName = $this->arrSubnaviName[$subno_id];
     $this->tpl_subno_csv = $subno_csv;
     // 画面の表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $conn = new SC_DBConn();
     $objView = new SC_AdminView();
     $objSess = new SC_Session();
     $objDb = new SC_Helper_DB_Ex();
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     // パラメータ管理クラス
     $this->objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam();
     // POST値の取得
     $this->objFormParam->setParam($_POST);
     // 通常時は親カテゴリを0に設定する。
     $this->arrForm['parent_category_id'] = isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : "";
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         case 'edit':
             $this->objFormParam->convParam();
             $arrRet = $this->objFormParam->getHashArray();
             $this->arrErr = $this->lfCheckError($arrRet);
             if (count($this->arrErr) == 0) {
                 if ($_POST['category_id'] == "") {
                     $objQuery = new SC_Query();
                     $count = $objQuery->count("dtb_category");
                     if ($count < CATEGORY_MAX) {
                         $this->lfInsertCat($_POST['parent_category_id']);
                     } else {
                         print "カテゴリの登録最大数を超えました。";
                     }
                 } else {
                     $this->lfUpdateCat($_POST['category_id']);
                 }
             } else {
                 $this->arrForm = array_merge($this->arrForm, $this->objFormParam->getHashArray());
                 $this->arrForm['category_id'] = $_POST['category_id'];
             }
             break;
         case 'pre_edit':
             // 編集項目のカテゴリ名をDBより取得する。
             $oquery = new SC_Query();
             $where = "category_id = ?";
             $cat_name = $oquery->get("dtb_category", "category_name", $where, array($_POST['category_id']));
             $description = $oquery->get("dtb_category", "description", $where, array($_POST['category_id']));
             // 入力項目にカテゴリ名を入力する。
             $this->arrForm['category_name'] = $cat_name;
             $this->arrForm['description'] = $description;
             // POSTデータを引き継ぐ
             $this->arrForm['category_id'] = $_POST['category_id'];
             break;
         case 'delete':
             $objQuery = new SC_Query();
             // 子カテゴリのチェック
             $where = "parent_category_id = ? AND del_flg = 0";
             $count = $objQuery->count("dtb_category", $where, array($_POST['category_id']));
             if ($count != 0) {
                 $this->arrErr['category_name'] = "※ 子カテゴリが存在するため削除できません。<br>";
             }
             // 登録商品のチェック
             $table = "dtb_product_categories AS T1 LEFT JOIN dtb_products AS T2 ON T1.product_id = T2.product_id";
             $where = "T1.category_id = ? AND T2.del_flg = 0";
             $count = $objQuery->count($table, $where, array($_POST['category_id']));
             if ($count != 0) {
                 $this->arrErr['category_name'] = "※ カテゴリ内に商品が存在するため削除できません。<br>";
             }
             if (!isset($this->arrErr['category_name'])) {
                 // ランク付きレコードの削除(※処理負荷を考慮してレコードごと削除する。)
                 $objDb->sfDeleteRankRecord("dtb_category", "category_id", $_POST['category_id'], "", true);
             }
             break;
         case 'up':
             $objQuery = new SC_Query();
             $objQuery->begin();
             $up_id = $this->lfGetUpRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
             if ($up_id != "") {
                 // 上のグループのrankから減算する数
                 $my_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
                 // 自分のグループのrankに加算する数
                 $up_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id);
                 if ($my_count > 0 && $up_count > 0) {
                     // 自分のグループに加算
                     $this->lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $up_count);
                     // 上のグループから減算
                     $this->lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id, $my_count);
                 }
             }
             $objQuery->commit();
             break;
         case 'down':
             $objQuery = new SC_Query();
             $objQuery->begin();
             $down_id = $this->lfGetDownRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
             if ($down_id != "") {
                 // 下のグループのrankに加算する数
                 $my_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']);
                 // 自分のグループのrankから減算する数
                 $down_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id);
                 if ($my_count > 0 && $down_count > 0) {
                     // 自分のグループから減算
                     $this->lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id, $my_count);
                     // 下のグループに加算
                     $this->lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $down_count);
                 }
             }
             $objQuery->commit();
             break;
         case 'tree':
             break;
         case 'csv':
             require_once CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php";
             $objCSV = new SC_Helper_CSV_Ex();
             // オプションの指定
             $option = "ORDER BY rank DESC";
             // CSV出力タイトル行の作成
             $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput(5, " WHERE csv_id = 5 AND status = 1"));
             if (count($arrOutput) <= 0) {
                 break;
             }
             $arrOutputCols = $arrOutput['col'];
             $arrOutputTitle = $arrOutput['disp_name'];
             $head = SC_Utils_Ex::sfGetCSVList($arrOutputTitle);
             $where = "del_flg = 0";
             $data = $objCSV->lfGetCategoryCSV($where, $option, $arrval, $arrOutputCols);
             // CSVを送信する。
             SC_Utils_Ex::sfCSVDownload($head . $data, 'category');
             exit;
             break;
         default:
             $this->arrForm['parent_category_id'] = 0;
             break;
     }
     $this->arrList = $this->lfGetCat($this->arrForm['parent_category_id']);
     $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']);
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
 function lfGetOrderData($order_id)
 {
     //注文番号が数字であれば
     if (SC_Utils_Ex::sfIsInt($order_id)) {
         // DBから受注情報を読み込む
         $objQuery = new SC_Query();
         $col = "order_id, create_date, payment_id, subtotal, tax, use_point, add_point, discount, ";
         $col .= "deliv_fee, charge, payment_total, deliv_name01, deliv_name02, deliv_kana01, deliv_kana02, ";
         $col .= "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_time_id, deliv_date ";
         $from = "dtb_order";
         $where = "order_id = ?";
         $arrRet = $objQuery->select($col, $from, $where, array($order_id));
         $arrOrder = $arrRet[0];
         // 受注詳細データの取得
         $arrRet = $this->lfGetOrderDetail($order_id);
         $arrOrderDetail = SC_Utils_Ex::sfSwapArray($arrRet);
         $arrData = array_merge($arrOrder, $arrOrderDetail);
     }
     return $arrData;
 }
 /**
  * テーブルを検索する.
  *
  * 引数に部分一致するテーブル名を配列で返す.
  *
  * @deprecated SC_Query::listTables() を使用してください
  * @param string $expression 検索文字列
  * @return array テーブル名の配列
  */
 function findTableNames($expression = "")
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $sql = 'SELECT name FROM sysobjects WHERE xtype = \'u\' AND name LIKE \'mtb_%\' order by name';
     $arrColList = $objQuery->getAll($sql);
     $arrColList = SC_Utils_Ex::sfSwapArray($arrColList, false);
     $arrList = array();
     foreach ($arrColList[0] as $val) {
         $arrList[$val] = $val;
     }
     return $arrList;
 }
 /**
  * 受注データを取得して, SC_FormParam へ設定する.
  *
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param integer $order_id 取得元の受注ID
  * @return void
  */
 function setOrderToFormParam(&$objFormParam, $order_id)
 {
     $objPurchase = new SC_Helper_Purchase_Ex();
     // 受注詳細を設定
     $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false);
     $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail));
     $arrShippingsTmp = $objPurchase->getShippings($order_id);
     $arrShippings = array();
     foreach ($arrShippingsTmp as $row) {
         // お届け日の処理
         if (!SC_Utils_Ex::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->setValue('shipping_quantity', count($arrShippings));
     $objFormParam->setParam(SC_Utils_Ex::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);
     $objFormParam->setParam($arrOrder);
     // ポイントを設定
     list($db_point, $rollback_point) = SC_Helper_DB_Ex::sfGetRollbackPoint($order_id, $arrOrder['use_point'], $arrOrder['add_point'], $arrOrder['status']);
     $objFormParam->setValue('total_point', $db_point);
     $objFormParam->setValue('point', $rollback_point);
     if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) {
         $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($objFormParam->getValue('customer_id'));
         $objFormParam->setValue('customer_point', $arrCustomer['point']);
     }
 }
 /**
  * 入力内容のチェックを行う.
  *
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return array エラーメッセージの配列
  */
 function lfCheckError(&$objFormParam)
 {
     $objProduct = new SC_Product_Ex();
     $arrErr = $objFormParam->checkError();
     if (!SC_Utils_Ex::isBlank($objErr->arrErr)) {
         return $arrErr;
     }
     $arrValues = $objFormParam->getHashArray();
     // 商品の種類数
     $max = count($arrValues['quantity']);
     $subtotal = 0;
     $totalpoint = 0;
     $totaltax = 0;
     for ($i = 0; $i < $max; $i++) {
         // 小計の計算
         $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i]) * $arrValues['quantity'][$i];
         // 小計の計算
         $totaltax += SC_Helper_DB_Ex::sfTax($arrValues['price'][$i]) * $arrValues['quantity'][$i];
         // 加算ポイントの計算
         $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i];
         // 在庫数のチェック
         $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]);
         // 編集前の値と比較するため受注詳細を取得
         $objPurchase = new SC_Helper_Purchase_Ex();
         $arrOrderDetail = SC_Utils_Ex::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 = SC_Utils_Ex::isBlank($class_name1) ? t('c_None_01') : $class_name1;
             $class_name2 = $arrValues['classcategory_name2'][$i];
             $class_name2 = SC_Utils_Ex::isBlank($class_name2) ? t('c_None_01') : $class_name2;
             $arrErr['quantity'][$i] .= t('c_There is an inventory shortage for T_ARG1/(T_ARG2)/(T_ARG3). Up to T_ARG4 can be set for the quantity.<br />_1', array('T_ARG1' => $arrValues['product_name'][$i], 'T_ARG2' => $class_name1, 'T_ARG3' => $class_name2, 'T_ARG4' => $arrOrderDetail['quantity'][$i] + $arrProduct['stock']));
         }
     }
     // 消費税
     $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'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']);
     // 最終保持ポイント
     $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point'];
     if ($arrValues['total'] < 0) {
         $arrErr['total'] = t('c_Adjust so that the total amount is not a negative number.<br />_01');
     }
     if ($arrValues['payment_total'] < 0) {
         $arrErr['payment_total'] = t('c_Adjust so that a negative number is not displayed for the payment total.<br />_01');
     }
     if ($arrValues['total_point'] < 0) {
         $arrErr['use_point'] = t('c_Adjust the final number of points registered so that it does not become a negative number.<br />_01');
     }
     $objFormParam->setParam($arrValues);
     return $arrErr;
 }