public function doAction($arrParam)
 {
     $this->doInitParam($arrParam);
     if ($this->isParamError()) {
         return false;
     }
     // メンバー情報を取得
     $this->memberData = $this->getMemberData($arrParam['access_token']);
     // アップロードファイル情報の初期化
     $objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
     $this->lfInitFile($objUpFile);
     $objUpFile->setHiddenFileList($_POST);
     // ファイルを一時ディレクトリにアップロード
     $arrImgKey = array('main_large_image');
     for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
         $arrImgKey[] = 'sub_large_image' . $cnt;
     }
     foreach ($arrImgKey as $val) {
         $this->arrErr[$val] = $objUpFile->makeTempFile($val, IMAGE_RENAME);
         if ($this->arrErr[$val] == '') {
             // 縮小画像作成
             $this->lfSetScaleImage($objUpFile, $val);
         }
     }
     // DBへデータ登録
     $product_id = $this->lfRegistProduct($objUpFile, $arrParam);
     // 件数カウントバッチ実行
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objDb = new SC_Helper_DB_Ex();
     $objDb->sfCountCategory($objQuery);
     $objDb->sfCountMaker($objQuery);
     // 一時ファイルを本番ディレクトリに移動する
     $this->lfSaveUploadFiles($objUpFile, $product_id);
     $arrData[] = array('result_id' => 1, 'product_id' => $product_id, 'error_msg' => '');
     $this->setResponse('Item', $arrData);
     $this->setResponse('StatusCode', '0');
     return true;
 }
 /**
  * Page のアクション.
  *
  * @return void
  */
 function action()
 {
     $objDb = new SC_Helper_DB_Ex();
     $objFormParam = new SC_FormParam_Ex();
     $objProduct = new SC_Product_Ex();
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     // パラメーター情報の初期化
     $this->lfInitParam($objFormParam);
     $objFormParam->setParam($_POST);
     $this->arrHidden = $objFormParam->getSearchArray();
     $this->arrForm = $objFormParam->getFormParamList();
     switch ($this->getMode()) {
         case 'delete':
             // 商品、子テーブル(商品規格)、会員お気に入り商品の削除
             $this->doDelete('product_id = ?', array($objFormParam->getValue('product_id')));
             // 件数カウントバッチ実行
             $objDb->sfCountCategory($objQuery);
             $objDb->sfCountMaker($objQuery);
             // 削除後に検索結果を表示するため breakしない
             // 検索パラメーター生成後に処理実行するため breakしない
         // 削除後に検索結果を表示するため breakしない
         // 検索パラメーター生成後に処理実行するため breakしない
         case 'csv':
         case 'delete_all':
         case 'search':
             $objFormParam->convParam();
             $objFormParam->trimParam();
             $this->arrErr = $this->lfCheckError($objFormParam);
             $arrParam = $objFormParam->getHashArray();
             if (count($this->arrErr) == 0) {
                 $where = 'del_flg = 0';
                 $arrWhereVal = array();
                 foreach ($arrParam as $key => $val) {
                     if ($val == '') {
                         continue;
                     }
                     $this->buildQuery($key, $where, $arrWhereVal, $objFormParam, $objDb);
                 }
                 $order = 'update_date DESC';
                 /* -----------------------------------------------
                  * 処理を実行
                  * ----------------------------------------------- */
                 switch ($this->getMode()) {
                     // CSVを送信する。
                     case 'csv':
                         $objCSV = new SC_Helper_CSV_Ex();
                         // CSVを送信する。正常終了の場合、終了。
                         $objCSV->sfDownloadCsv(1, $where, $arrWhereVal, $order, true);
                         SC_Response_Ex::actionExit();
                         // 全件削除(ADMIN_MODE)
                     // 全件削除(ADMIN_MODE)
                     case 'delete_all':
                         $this->doDelete($where, $arrWhereVal);
                         break;
                         // 検索実行
                     // 検索実行
                     default:
                         // 行数の取得
                         $this->tpl_linemax = $this->getNumberOfLines($where, $arrWhereVal);
                         // ページ送りの処理
                         $page_max = SC_Utils_Ex::sfGetSearchPageMax($objFormParam->getValue('search_page_max'));
                         // ページ送りの取得
                         $objNavi = new SC_PageNavi_Ex($this->arrHidden['search_pageno'], $this->tpl_linemax, $page_max, 'fnNaviSearchPage', NAVI_PMAX);
                         $this->arrPagenavi = $objNavi->arrPagenavi;
                         // 検索結果の取得
                         $this->arrProducts = $this->findProducts($where, $arrWhereVal, $page_max, $objNavi->start_row, $order, $objProduct);
                         // 各商品ごとのカテゴリIDを取得
                         if (count($this->arrProducts) > 0) {
                             foreach ($this->arrProducts as $key => $val) {
                                 $this->arrProducts[$key]['categories'] = $objDb->sfGetCategoryId($val['product_id'], 0, true);
                                 $objDb->g_category_on = false;
                             }
                         }
                 }
             }
             break;
     }
     // カテゴリの読込
     list($this->arrCatKey, $this->arrCatVal) = $objDb->sfGetLevelCatList(false);
     $this->arrCatList = $this->lfGetIDName($this->arrCatKey, $this->arrCatVal);
 }
Ejemplo n.º 3
0
 function changeProductStatus(LC_Page $objPage)
 {
     $objQuery = SC_Query_Ex::getSingletonInstance();
     $objQuery->begin();
     $n = array();
     $n2 = array("auto_display_status" => 0);
     $objSql = new SC_SelectSql_Ex();
     $objSql->setWhere("auto_display_status = 1");
     $objSql->setWhere("del_flg             = 0");
     $s = "auto_display_end_date";
     $e = "auto_display_start_date";
     // 公開日による状態変更
     // {$s} > NOW() 公開開始前
     // {$e} < NOW() 公開終了後
     // その他       公開中
     $objQuery->update("dtb_products", $n, $objSql->getWhere(), $n, array("status" => "CASE WHEN {$s} > NOW() THEN 2 WHEN {$e} < NOW() THEN 2 ELSE 1 END", "auto_display_status" => "CASE WHEN {$e} < NOW() THEN 0 ELSE 1 END"));
     $objSql->setWhere("{$e} < NOW() ");
     $objQuery->update("dtb_products", $n, $objSql->getWhere(), $n2);
     $objQuery->commit();
     if (GC_Utils_Ex::isFrontFunction()) {
         // 商品数量を再計算
         $objDb = new SC_Helper_DB_Ex();
         $objDb->sfCountCategory($objQuery);
         $objDb->sfCountMaker($objQuery);
     }
 }
 /**
  * Page のアクション.
  *
  * @return void
  */
 function action()
 {
     $objFormParam = new SC_FormParam_Ex();
     // アップロードファイル情報の初期化
     $objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
     $this->lfInitFile($objUpFile);
     $objUpFile->setHiddenFileList($_POST);
     // ダウンロード販売ファイル情報の初期化
     $objDownFile = new SC_UploadFile_Ex(DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR);
     $this->lfInitDownFile($objDownFile);
     $objDownFile->setHiddenFileList($_POST);
     // 検索パラメーター引き継ぎ
     $this->arrSearchHidden = $this->lfGetSearchParam($_POST);
     $mode = $this->getMode();
     switch ($mode) {
         case 'pre_edit':
         case 'copy':
             // パラメーター初期化(商品ID)
             $this->lfInitFormParam_PreEdit($objFormParam, $_POST);
             // エラーチェック
             $this->arrErr = $objFormParam->checkError();
             if (count($this->arrErr) > 0) {
                 trigger_error('', E_USER_ERROR);
             }
             // 商品ID取得
             $product_id = $objFormParam->getValue('product_id');
             // 商品データ取得
             $arrForm = $this->lfGetFormParam_PreEdit($objUpFile, $objDownFile, $product_id);
             // 複製の場合は、ダウンロード商品情報部分はコピーしない
             if ($mode == 'copy') {
                 // ダウンロード商品ファイル名をunset
                 $arrForm['down_filename'] = '';
                 // $objDownFile->setDBDownFile()でsetされたダウンロードファイル名をunset
                 unset($objDownFile->save_file[0]);
             }
             // ページ表示用パラメーター設定
             $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
             // 商品複製の場合、画像ファイルコピー
             if ($mode == 'copy') {
                 $this->arrForm['copy_product_id'] = $this->arrForm['product_id'];
                 $this->arrForm['product_id'] = '';
                 // 画像ファイルのコピー
                 $this->lfCopyProductImageFiles($objUpFile);
             }
             // ページonload時のJavaScript設定
             $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage();
             break;
         case 'edit':
             // パラメーター初期化, 取得
             $this->lfInitFormParam($objFormParam, $_POST);
             $arrForm = $objFormParam->getHashArray();
             // エラーチェック
             $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm);
             if (count($this->arrErr) == 0) {
                 // 確認画面表示設定
                 $this->tpl_mainpage = 'products/confirm.tpl';
                 $this->arrCatList = $this->lfGetCategoryList_Edit();
                 $this->arrForm = $this->lfSetViewParam_ConfirmPage($objUpFile, $objDownFile, $arrForm);
             } else {
                 // 入力画面表示設定
                 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
                 // ページonload時のJavaScript設定
                 $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage();
             }
             break;
         case 'complete':
             // パラメーター初期化, 取得
             $this->lfInitFormParam($objFormParam, $_POST);
             $arrForm = $this->lfGetFormParam_Complete($objFormParam);
             // エラーチェック
             $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm);
             if (count($this->arrErr) == 0) {
                 // DBへデータ登録
                 $product_id = $this->lfRegistProduct($objUpFile, $objDownFile, $arrForm);
                 // 件数カウントバッチ実行
                 $objQuery =& SC_Query_Ex::getSingletonInstance();
                 $objDb = new SC_Helper_DB_Ex();
                 $objDb->sfCountCategory($objQuery);
                 $objDb->sfCountMaker($objQuery);
                 // ダウンロード商品の複製時に、ダウンロード商品用ファイルを
                 // 変更すると、複製元のファイルが削除されるのを回避。
                 if (!empty($arrForm['copy_product_id'])) {
                     $objDownFile->save_file = array();
                 }
                 // 一時ファイルを本番ディレクトリに移動する
                 $this->lfSaveUploadFiles($objUpFile, $objDownFile, $product_id);
                 $this->tpl_mainpage = 'products/complete.tpl';
                 $this->arrForm['product_id'] = $product_id;
             } else {
                 // 入力画面表示設定
                 $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
                 // ページonload時のJavaScript設定
                 $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage();
             }
             break;
             // 画像のアップロード
         // 画像のアップロード
         case 'upload_image':
         case 'delete_image':
             // パラメーター初期化
             $this->lfInitFormParam_UploadImage($objFormParam);
             $this->lfInitFormParam($objFormParam, $_POST);
             $arrForm = $objFormParam->getHashArray();
             switch ($mode) {
                 case 'upload_image':
                     // ファイルを一時ディレクトリにアップロード
                     $this->arrErr[$arrForm['image_key']] = $objUpFile->makeTempFile($arrForm['image_key'], IMAGE_RENAME);
                     if ($this->arrErr[$arrForm['image_key']] == '') {
                         // 縮小画像作成
                         $this->lfSetScaleImage($objUpFile, $arrForm['image_key']);
                     }
                     break;
                 case 'delete_image':
                     // ファイル削除
                     $this->lfDeleteTempFile($objUpFile, $arrForm['image_key']);
                     break;
                 default:
                     break;
             }
             // 入力画面表示設定
             $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
             // ページonload時のJavaScript設定
             $anchor_hash = $this->getAnchorHash($arrForm['image_key']);
             $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash);
             break;
             // ダウンロード商品ファイルアップロード
         // ダウンロード商品ファイルアップロード
         case 'upload_down':
         case 'delete_down':
             // パラメーター初期化
             $this->lfInitFormParam_UploadDown($objFormParam);
             $this->lfInitFormParam($objFormParam, $_POST);
             $arrForm = $objFormParam->getHashArray();
             switch ($mode) {
                 case 'upload_down':
                     // ファイルを一時ディレクトリにアップロード
                     $this->arrErr[$arrForm['down_key']] = $objDownFile->makeTempDownFile();
                     break;
                 case 'delete_down':
                     // ファイル削除
                     $objDownFile->deleteFile($arrForm['down_key']);
                     break;
                 default:
                     break;
             }
             // 入力画面表示設定
             $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
             // ページonload時のJavaScript設定
             $anchor_hash = $this->getAnchorHash($arrForm['down_key']);
             $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash);
             break;
             // 関連商品選択
         // 関連商品選択
         case 'recommend_select':
             // パラメーター初期化
             $this->lfInitFormParam_RecommendSelect($objFormParam);
             $this->lfInitFormParam($objFormParam, $_POST);
             $arrForm = $objFormParam->getHashArray();
             // 入力画面表示設定
             $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
             // 選択された関連商品IDがすでに登録している関連商品と重複していないかチェック
             $this->lfCheckError_RecommendSelect($this->arrForm, $this->arrErr);
             // ページonload時のJavaScript設定
             $anchor_hash = $this->getAnchorHash($this->arrForm['anchor_key']);
             $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash);
             break;
             // 確認ページからの戻り
         // 確認ページからの戻り
         case 'confirm_return':
             // パラメーター初期化
             $this->lfInitFormParam($objFormParam, $_POST);
             $arrForm = $objFormParam->getHashArray();
             // 入力画面表示設定
             $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
             // ページonload時のJavaScript設定
             $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage();
             break;
         default:
             // 入力画面表示設定
             $arrForm = array();
             $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm);
             // ページonload時のJavaScript設定
             $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage();
             break;
     }
     // 関連商品の読み込み
     $this->arrRecommend = $this->lfGetRecommendProducts($this->arrForm);
 }