/**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objSubView = new SC_SiteView();
     $objDb = new SC_Helper_DB_Ex();
     // 選択中のカテゴリIDを判定する
     $arrCategory_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
     // 選択中のカテゴリID
     $this->tpl_category_id = empty($arrCategory_id) ? array(0) : $arrCategory_id;
     $this->lfGetCatTree($this->tpl_category_id, true, $this);
     $objSubView->assignobj($this);
     $objSubView->display($this->tpl_mainpage);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $arrSearch = array();
     // 検索項目表示用
     $objDb = new SC_Helper_DB_Ex();
     // 選択中のカテゴリIDを判定する
     $this->category_id = $objDb->sfGetCategoryId($_GET['product_id'], $_GET['category_id']);
     // カテゴリ検索用選択リスト
     $arrRet = $objDb->sfGetCategoryList('', true, ' ');
     if (is_array($arrRet)) {
         // 文字サイズを制限する
         foreach ($arrRet as $key => $val) {
             $arrRet[$key] = SC_Utils_Ex::sfCutString($val, SEARCH_CATEGORY_LEN, false);
         }
     }
     $this->arrCatList = $arrRet;
     $objSubView = new SC_SiteView();
     $objSubView->assignobj($this);
     $objSubView->display($this->tpl_mainpage);
 }
 /**
  * 選択中のカテゴリIDを取得する.
  *
  * @param  array $arrRequest リクエスト配列
  * @return array $arrCategoryId 選択中のカテゴリID
  */
 public function lfGetSelectedCategoryId($arrRequest)
 {
     // 商品ID取得
     $product_id = '';
     if (isset($arrRequest['product_id']) && $arrRequest['product_id'] != '' && is_numeric($arrRequest['product_id'])) {
         $product_id = $arrRequest['product_id'];
     }
     // カテゴリID取得
     $category_id = '';
     if (isset($arrRequest['category_id']) && $arrRequest['category_id'] != '' && is_numeric($arrRequest['category_id'])) {
         $category_id = $arrRequest['category_id'];
     }
     // 選択中のカテゴリIDを判定する
     $objDb = new SC_Helper_DB_Ex();
     $arrCategoryId = $objDb->sfGetCategoryId($product_id, $category_id);
     if (empty($arrCategoryId)) {
         $arrCategoryId = array(0);
     }
     return $arrCategoryId;
 }
Ejemplo n.º 4
0
 /**
  * カテゴリツリーの取得を複数カテゴリで行う.
  *
  * @param  integer $product_id  商品ID
  * @param  bool    $count_check 登録商品数のチェックを行う場合 true
  * @return array   カテゴリツリーの配列
  */
 public static function sfGetMultiCatTree($product_id, $count_check = false)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $col = '';
     $col .= ' cat.category_id,';
     $col .= ' cat.category_name,';
     $col .= ' cat.parent_category_id,';
     $col .= ' cat.level,';
     $col .= ' cat.rank,';
     $col .= ' cat.creator_id,';
     $col .= ' cat.create_date,';
     $col .= ' cat.update_date,';
     $col .= ' cat.del_flg, ';
     $col .= ' ttl.product_count';
     $from = 'dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id';
     // 登録商品数のチェック
     if ($count_check) {
         $where = 'del_flg = 0 AND product_count > 0';
     } else {
         $where = 'del_flg = 0';
     }
     $objQuery->setOption('ORDER BY rank DESC');
     $arrRet = $objQuery->select($col, $from, $where);
     $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId($product_id);
     $arrCatTree = array();
     foreach ($arrCategory_id as $pkey => $parent_category_id) {
         $arrParentID = SC_Helper_DB_Ex::sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
         foreach ($arrParentID as $pid) {
             foreach ($arrRet as $key => $array) {
                 if ($array['category_id'] == $pid) {
                     $arrCatTree[$pkey][] = $arrRet[$key];
                     break;
                 }
             }
         }
     }
     return $arrCatTree;
 }
 /**
  * 選択中のカテゴリIDを取得する
  *
  * @return array $arrCategoryId 選択中のカテゴリID
  */
 function lfGetSelectedCategoryId($product_id, $category_id)
 {
     // 選択中のカテゴリIDを判定する
     $objDb = new SC_Helper_DB_Ex();
     $arrCategoryId = $objDb->sfGetCategoryId($product_id, $category_id);
     return $arrCategoryId;
 }
 /**
  * カテゴリIDの取得
  *
  * @return integer カテゴリID
  */
 function lfGetCategoryId($category_id)
 {
     // 指定なしの場合、0 を返す
     if (empty($category_id)) {
         return 0;
     }
     // 正当性チェック
     if (!SC_Utils_Ex::sfIsInt($category_id) || SC_Utils_Ex::sfIsZeroFilling($category_id) || !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array) $category_id, 'del_flg = 0')) {
         SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
     }
     // 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。
     $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId('', $category_id);
     if (empty($arrCategory_id)) {
         SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND);
     }
     return $arrCategory_id[0];
 }
 /**
  * 選択されたカテゴリーとその子カテゴリーの情報を取得し、
  * ページオブジェクトに格納する。
  *
  * @param string $category_id カテゴリーID
  * @param boolean $count_check 有効な商品がないカテゴリーを除くかどうか
  * @param object &$objPage ページオブジェクト
  * @return void
  */
 function lfGetCategories($category_id, $count_check = false, &$objPage)
 {
     $objDb = new SC_Helper_DB_Ex();
     // カテゴリーの正しいIDを取得する。
     $arrCategory_id = $objDb->sfGetCategoryId('', $category_id);
     $category_id = $arrCategory_id[0];
     if ($category_id == 0) {
         SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND, "", false, "", true);
     }
     $arrCategory = null;
     // 選択されたカテゴリー
     $arrChildren = array();
     // 子カテゴリー
     $arrAll = $objDb->sfGetCatTree($category_id, $count_check);
     foreach ($arrAll as $category) {
         // 選択されたカテゴリーの場合
         if ($category['category_id'] == $category_id) {
             $arrCategory = $category;
             continue;
         }
         // 関係のないカテゴリーはスキップする。
         if ($category['parent_category_id'] != $category_id) {
             continue;
         }
         // 子カテゴリーの場合は、孫カテゴリーが存在するかどうかを調べる。
         $arrGrandchildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrAll, 'parent_category_id', 'category_id', $category['category_id']);
         $category['has_children'] = count($arrGrandchildrenID) > 0;
         $arrChildren[] = $category;
     }
     if (!isset($arrCategory)) {
         SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND, "", false, "", true);
     }
     // 子カテゴリーの商品数を合計する。
     $children_product_count = 0;
     foreach ($arrChildren as $category) {
         $children_product_count += $category['product_count'];
     }
     // 選択されたカテゴリーに直属の商品がある場合は、子カテゴリーの先頭に追加する。
     if ($arrCategory['product_count'] > $children_product_count) {
         $arrCategory['product_count'] -= $children_product_count;
         // 子カテゴリーの商品数を除く。
         $arrCategory['has_children'] = false;
         // 商品一覧ページに遷移させるため。
         array_unshift($arrChildren, $arrCategory);
     }
     // 結果を格納する。
     $objPage->arrCategory = $arrCategory;
     $objPage->arrChildren = $arrChildren;
 }
Ejemplo n.º 8
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objView = new SC_SiteView();
     $objCustomer = new SC_Customer();
     $objQuery = new SC_Query();
     $objDb = new SC_Helper_DB_Ex();
     // レイアウトデザインを取得
     $helper = new SC_Helper_PageLayout_Ex();
     $helper->sfGetPageLayout($this, false, "products/detail.php");
     // ログイン中のユーザが商品をお気に入りにいれる処理
     if ($objCustomer->isLoginSuccess() === true && strlen($_POST['mode']) > 0 && $_POST['mode'] == "add_favorite" && strlen($_POST['favorite_product_id']) > 0) {
         // 値の正当性チェック
         if (!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) {
             SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
             exit;
         } else {
             $this->arrErr = $this->lfCheckError();
             if (count($this->arrErr) == 0) {
                 $customer_id = $objCustomer->getValue('customer_id');
                 $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']);
             }
         }
     }
     // パラメータ管理クラス
     $this->objFormParam = new SC_FormParam();
     // パラメータ情報の初期化
     $this->lfInitParam();
     // POST値の取得
     $this->objFormParam->setParam($_POST);
     // ファイル管理クラス
     $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
     // ファイル情報の初期化
     $this->lfInitFile();
     // 管理ページからの確認の場合は、非公開の商品も表示する。
     if (isset($_GET['admin']) && $_GET['admin'] == 'on') {
         SC_Utils_Ex::sfIsSuccess(new SC_Session());
         $status = true;
         $where = "del_flg = 0";
     } else {
         $status = false;
         $where = "del_flg = 0 AND status = 1";
     }
     if (isset($_POST['mode']) && $_POST['mode'] != "") {
         $tmp_id = $_POST['product_id'];
     } else {
         $tmp_id = $_GET['product_id'];
     }
     // 値の正当性チェック
     if (!SC_Utils_Ex::sfIsInt($_GET['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) {
         SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
     }
     // ログイン判定
     if ($objCustomer->isLoginSuccess() === true) {
         //お気に入りボタン表示
         $this->tpl_login = true;
         /* 閲覧ログ機能は現在未使用
         
                     $table = "dtb_customer_reading";
                     $where = "customer_id = ? ";
                     $arrval[] = $objCustomer->getValue('customer_id');
                     //顧客の閲覧商品数
                     $rpcnt = $objQuery->count($table, $where, $arrval);
         
                     //閲覧数が設定数以下
                     if ($rpcnt < CUSTOMER_READING_MAX){
                         //閲覧履歴に新規追加
                         lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
                     } else {
                         //閲覧履歴の中で一番古いものを削除して新規追加
                         $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?";
                         $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id")));
                         $where = "customer_id = ? AND update_date = ? ";
                         $arrval = array($objCustomer->getValue("customer_id"), $old);
                         //削除
                         $objQuery->delete($table, $where, $arrval);
                         //追加
                         lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
                     }
                 */
     }
     // 規格選択セレクトボックスの作成
     $this->lfMakeSelect($tmp_id);
     // 商品IDをFORM内に保持する。
     $this->tpl_product_id = $tmp_id;
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     switch ($_POST['mode']) {
         case 'cart':
             // 入力値の変換
             $this->objFormParam->convParam();
             $this->arrErr = $this->lfCheckError();
             if (count($this->arrErr) == 0) {
                 $objCartSess = new SC_CartSession();
                 $classcategory_id1 = $_POST['classcategory_id1'];
                 $classcategory_id2 = $_POST['classcategory_id2'];
                 if (!empty($_POST['gmo_oneclick'])) {
                     $objCartSess->delAllProducts();
                 }
                 // 規格1が設定されていない場合
                 if (!$this->tpl_classcat_find1) {
                     $classcategory_id1 = '0';
                 }
                 // 規格2が設定されていない場合
                 if (!$this->tpl_classcat_find2) {
                     $classcategory_id2 = '0';
                 }
                 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
                 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $this->objFormParam->getValue('quantity'));
                 if (!empty($_POST['gmo_oneclick'])) {
                     $objSiteSess = new SC_SiteSession();
                     $objSiteSess->setRegistFlag();
                     $objCartSess->saveCurrentCart($objSiteSess->getUniqId());
                     $this->sendRedirect($this->getLocation(URL_DIR . 'user_data/gmopg_oneclick_confirm.php', array(), true));
                     exit;
                 }
                 $this->sendRedirect($this->getLocation(URL_CART_TOP));
                 exit;
             }
             break;
         default:
             break;
     }
     $objQuery = new SC_Query();
     // DBから商品情報を取得する。
     $arrRet = $objQuery->select("*, (SELECT count(*) FROM dtb_customer_favorite_products WHERE product_id = alldtl.product_id AND customer_id = ?) AS favorite_count", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($objCustomer->getValue('customer_id'), $tmp_id));
     $this->arrProduct = $arrRet[0];
     // 商品コードの取得
     $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code";
     $arrProductCode = $objQuery->getall($code_sql, array($tmp_id));
     $arrProductCode = SC_Utils_Ex::sfswaparray($arrProductCode);
     $this->arrProductCode = $arrProductCode["product_code"];
     // 購入制限数を取得
     if ($this->arrProduct['sale_unlimited'] == 1 || $this->arrProduct['sale_limit'] > SALE_LIMIT_MAX) {
         $this->tpl_sale_limit = SALE_LIMIT_MAX;
     } else {
         $this->tpl_sale_limit = $this->arrProduct['sale_limit'];
     }
     // サブタイトルを取得
     $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'], '', $status);
     $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
     $this->tpl_subtitle = $arrFirstCat['name'];
     // 関連カテゴリを取得
     $this->arrRelativeCat = $objDb->sfGetMultiCatTree($tmp_id);
     // DBからのデータを引き継ぐ
     $this->objUpFile->setDBFileList($this->arrProduct);
     // ファイル表示用配列を渡す
     $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true);
     // 支払方法の取得
     $this->arrPayment = $this->lfGetPayment();
     // 入力情報を渡す
     $this->arrForm = $this->objFormParam->getFormParamList();
     //レビュー情報の取得
     $this->arrReview = $this->lfGetReviewData($tmp_id);
     // トラックバック情報の取得
     // トラックバック機能の稼働状況チェック
     if (SC_Utils_Ex::sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) {
         $this->arrTrackbackView = "OFF";
     } else {
         $this->arrTrackbackView = "ON";
         $this->arrTrackback = $this->lfGetTrackbackData($tmp_id);
     }
     $this->trackback_url = TRACKBACK_TO_URL . $tmp_id;
     // タイトルに商品名を入れる
     $this->tpl_title = "商品詳細 " . $this->arrProduct["name"];
     //オススメ商品情報表示
     $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id);
     //この商品を買った人はこんな商品も買っています
     $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id);
     $this->lfConvertParam();
     $objView->assignobj($this);
     $objView->display(SITE_FRAME);
 }
Ejemplo n.º 9
0
 /**
  * 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);
 }
Ejemplo n.º 10
0
 /**
  * Page のプロセス(モバイル).
  *
  * FIXME スパゲッティ...
  *
  * @return void
  */
 function mobileProcess()
 {
     $objView = new SC_MobileView();
     $conn = new SC_DBConn();
     $objDb = new SC_Helper_DB_Ex();
     //表示件数の選択
     if (isset($_REQUEST['disp_number']) && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) {
         $this->disp_number = $_REQUEST['disp_number'];
     } else {
         //最小表示件数を選択
         $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX));
     }
     //表示順序の保存
     $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : "";
     // GETのカテゴリIDを元に正しいカテゴリIDを取得する。
     $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']);
     // タイトル編集
     $tpl_subtitle = "";
     $tpl_search_mode = false;
     if (!isset($_GET['mode'])) {
         $_GET['mode'] = "";
     }
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     if (!isset($_GET['name'])) {
         $_GET['name'] = "";
     }
     if (!isset($_REQUEST['orderby'])) {
         $_REQUEST['orderby'] = "";
     }
     if (empty($arrCategory_id)) {
         $arrCategory_id = array("0");
     }
     if ($_GET['mode'] == 'search') {
         $tpl_subtitle = "検索結果";
         $tpl_search_mode = true;
     } elseif (empty($arrCategory_id)) {
         $tpl_subtitle = "全商品";
     } else {
         $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
         $tpl_subtitle = $arrFirstCat['name'];
     }
     $objQuery = new SC_Query();
     $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id);
     // 以下の条件でBEST商品を表示する
     // ・BEST最大数の商品が登録されている。
     // ・カテゴリIDがルートIDである。
     // ・検索モードでない。
     if ($count >= BEST_MIN && $this->lfIsRootCategory($arrCategory_id[0]) && $_GET['mode'] != 'search') {
         // 商品TOPの表示処理
         $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]);
         $this->BEST_ROOP_MAX = ceil((BEST_MAX - 1) / 2);
     } else {
         if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0) {
             // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す
             $arrCategory_id = array("");
         }
         // 商品一覧の表示処理
         $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']);
         // 検索条件を画面に表示
         // カテゴリー検索条件
         if (strlen($_GET['category_id']) == 0) {
             $arrSearch['category'] = "指定なし";
         } else {
             $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($category_id));
             $arrSearch['category'] = $arrCat;
         }
         // 商品名検索条件
         if ($_GET['name'] === "") {
             $arrSearch['name'] = "指定なし";
         } else {
             $arrSearch['name'] = $_GET['name'];
         }
     }
     if ($_POST['mode'] == "cart" && $_POST['product_id'] != "") {
         // 値の正当性チェック
         if (!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {
             SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true);
         } else {
             // 入力値の変換
             $this->arrErr = $this->lfCheckError($_POST['product_id']);
             if (count($this->arrErr) == 0) {
                 $objCartSess = new SC_CartSession();
                 $classcategory_id = "classcategory_id" . $_POST['product_id'];
                 $classcategory_id1 = $_POST[$classcategory_id . '_1'];
                 $classcategory_id2 = $_POST[$classcategory_id . '_2'];
                 $quantity = "quantity" . $_POST['product_id'];
                 // 規格1が設定されていない場合
                 if (!$this->tpl_classcat_find1[$_POST['product_id']]) {
                     $classcategory_id1 = '0';
                 }
                 // 規格2が設定されていない場合
                 if (!$this->tpl_classcat_find2[$_POST['product_id']]) {
                     $classcategory_id2 = '0';
                 }
                 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
                 $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
                 $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id()));
                 exit;
             }
         }
     }
     // ページ送り機能用のURLを作成する。
     $objURL = new Net_URL($_SERVER['PHP_SELF']);
     foreach ($_REQUEST as $key => $value) {
         if ($key == session_name() || $key == 'pageno') {
             continue;
         }
         $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE));
     }
     if ($this->objNavi->now_page > 1) {
         $objURL->addQueryString('pageno', $this->objNavi->now_page - 1);
         $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString();
     }
     if ($this->objNavi->now_page < $this->objNavi->max_page) {
         $objURL->addQueryString('pageno', $this->objNavi->now_page + 1);
         $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString();
     }
     $this->tpl_subtitle = $tpl_subtitle;
     $this->tpl_search_mode = $tpl_search_mode;
     // 支払方法の取得
     $this->arrPayment = $this->lfGetPayment();
     // 入力情報を渡す
     $this->arrForm = $_POST;
     $this->category_id = $arrCategory_id[0];
     $this->arrSearch = $arrSearch;
     $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl";
     $objView->assignobj($this);
     $objView->display(SITE_FRAME);
 }
 function getBreadcrumbByCategoryId($category_id)
 {
     $arrBreadcrumb = array();
     // 正当性チェック
     if (!SC_Utils_Ex::sfIsInt($category_id) || SC_Utils_Ex::sfIsZeroFilling($category_id) || !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array) $category_id, 'del_flg = 0')) {
         $this->current_name = '全商品';
         return array();
     }
     // 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。
     $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId('', $category_id);
     if (empty($arrCategory_id)) {
         $this->current_name = '全商品';
         return array();
     }
     // 商品が属するカテゴリIDを縦に取得
     $objDb = new SC_Helper_DB_Ex();
     $arrCatID = $objDb->sfGetParents("dtb_category", "parent_category_id", "category_id", $arrCategory_id[0]);
     $objQuery = new SC_Query();
     $index_no = 0;
     foreach ($arrCatID as $val) {
         // カテゴリー名称を取得
         $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
         $arrVal = array($val);
         $CatName = $objQuery->getOne($sql, $arrVal);
         if ($val != $category_id) {
             $arrBreadcrumb[$index_no]['category_name'] = $CatName;
             $arrBreadcrumb[$index_no]['category_id'] = $val;
         } else {
             $this->current_name = $CatName;
         }
         $index_no++;
     }
     return $arrBreadcrumb;
 }