예제 #1
0
 public function doAction($arrParam)
 {
     $arrRequest = $this->doInitParam($arrParam);
     if (!$this->isParamError()) {
         $objProduct = new SC_Product_Ex();
         switch ($arrRequest['IdType']) {
             case 'product_code':
                 $search_column = 'product_code';
                 break;
             case 'product_class_id':
                 $arrProduct = $objProduct->getDetailAndProductsClass($arrRequest['ItemId']);
                 break;
             case 'product_id':
             default:
                 $arrProduct = $objProduct->getDetail($arrRequest['ItemId']);
                 break;
         }
         $objProduct->setProductsClassByProductIds(array($arrProduct['product_id']));
         if ($arrProduct['del_flg'] == '0' && $arrProduct['status'] == '1') {
             unset($arrProduct['note']);
             $this->setResponse('product_id', $arrProduct['product_id']);
             $this->setResponse('DetailPageURL', HTTP_URL . 'products/detail.php?product_id=' . $arrProduct['product_id']);
             $this->setResponse('Title', $arrProduct['name']);
             $this->setResponse('ItemAttributes', $arrProduct);
             return true;
         } else {
             $this->addError('ItemLookup.Error', t('c_* The requested information was not found._01'));
         }
     }
     return false;
 }
예제 #2
0
 public function doAction($arrParam)
 {
     $arrRequest = $this->doInitParam($arrParam);
     if (!$this->isParamError()) {
         $masterData = new SC_DB_MasterData_Ex();
         $arrSTATUS = $masterData->getMasterData('mtb_status');
         $arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image');
         $objProduct = new SC_Product_Ex();
         $arrSearchData = array('category_id' => $arrRequest['BrowseNode'], 'maker_name' => $arrRequest['Manufacturer'], 'name' => $arrRequest['Keywords'], 'orderby' => $arrRequest['Sort']);
         $arrSearchCondition = $this->getSearchCondition($arrSearchData);
         $disp_number = 10;
         $objQuery =& SC_Query_Ex::getSingletonInstance();
         $objQuery->setWhere($arrSearchCondition['where_for_count']);
         $objProduct = new SC_Product_Ex();
         $linemax = $objProduct->findProductCount($objQuery, $arrSearchCondition['arrval']);
         $objNavi = new SC_PageNavi_Ex($arrRequest['ItemPage'], $tpl_linemax, $disp_number);
         $arrProducts = $this->getProductsList($arrSearchCondition, $disp_number, $objNavi->start_row, $linemax, $objProduct);
         if (!SC_Utils_Ex::isBlank($arrProducts)) {
             $arrProducts = $this->setStatusDataTo($arrProducts, $arrSTATUS, $arrSTATUS_IMAGE);
             $arrProducts = $objProduct->setPriceTaxTo($arrProducts);
             foreach ($arrProducts as $key => $val) {
                 $arrProducts[$key]['main_list_image'] = SC_Utils_Ex::sfNoImageMainList($val['main_list_image']);
             }
             $arrData = array();
             foreach ($arrProducts as $key => $val) {
                 $arrData[] = array('product_id' => $val['product_id'], 'DetailPageURL' => HTTP_URL . 'products/detail.php?product_id=' . $val['product_id'], 'ItemAttributes' => $val);
             }
             $this->setResponse('Item', $arrData);
             return true;
         } else {
             $this->addError('ItemSearch.Error', '※ 要求された情報は見つかりませんでした。');
         }
     }
     return false;
 }
 /**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 public function lfGetRanking()
 {
     $objRecommend = new SC_Helper_BestProducts_Ex();
     // おすすめ商品取得
     $arrRecommends = $objRecommend->getList(RECOMMEND_NUM);
     $response = array();
     if (count($arrRecommends) > 0) {
         // 商品一覧を取得
         $objQuery =& SC_Query_Ex::getSingletonInstance();
         $objProduct = new SC_Product_Ex();
         // where条件生成&セット
         $arrProductId = array();
         foreach ($arrRecommends as $key => $val) {
             $arrProductId[] = $val['product_id'];
         }
         $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
         // 税込金額を設定する
         SC_Product_Ex::setIncTaxToProducts($arrProducts);
         // おすすめ商品情報にマージ
         foreach ($arrRecommends as $key => $value) {
             if (isset($arrProducts[$value['product_id']])) {
                 $product = $arrProducts[$value['product_id']];
                 if ($product['status'] == 1 && (!NOSTOCK_HIDDEN || ($product['stock_max'] >= 1 || $product['stock_unlimited_max'] == 1))) {
                     $response[] = array_merge($value, $arrProducts[$value['product_id']]);
                 }
             } else {
                 // 削除済み商品は除外
                 unset($arrRecommends[$key]);
             }
         }
     }
     return $response;
 }
 /**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 public function lfGetRanking()
 {
     $arrRecommends = parent::lfGetRanking();
     $detect = new Mobile_Detect();
     $cur_category_id = 0;
     if ($detect->is("AndroidOS")) {
         $cur_category_id = 1;
     } elseif ($detect->is("iOS")) {
         $cur_category_id = 2;
     } else {
         return array();
     }
     $response = array();
     if (count($arrRecommends) > 0) {
         $objProduct = new SC_Product_Ex();
         foreach ($arrRecommends as $value) {
             $product_id = $value['product_id'];
             $category_id = $objProduct->getCategoryIds($product_id);
             if (in_array($cur_category_id, $category_id)) {
                 // nop
                 $response[] = $value;
             }
         }
     }
     return $response;
 }
 /**
  * Page のアクション.
  *
  * @return void
  */
 function action()
 {
     $layout = new SC_Helper_PageLayout_Ex();
     $layout->sfGetPageLayout($this, false, $_SERVER['SCRIPT_NAME'], $this->objDisplay->detectDevice());
     $this->arrBreadcrumb[0][0] = array();
     switch ($this->arrPageLayout['url']) {
         case 'products/list.php':
             $category_id = $_GET['category_id'];
             if ($category_id) {
                 $this->arrBreadcrumb[0] = self::getBreadcrumbByCategoryId(intval($category_id));
             } else {
                 if ($_GET['mode'] == 'search') {
                     $this->current_name = '検索結果';
                 } else {
                     $this->current_name = '全商品';
                 }
             }
             break;
         case 'products/detail.php':
             $product_id = $_GET['product_id'];
             $this->arrBreadcrumb = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id);
             $objProduct = new SC_Product_Ex();
             $arrProduct = $objProduct->getDetail($product_id);
             $this->current_name = $arrProduct['name'];
             break;
         case 'index.php':
             $this->current_name = '';
             break;
         default:
             $this->current_name = $this->arrPageLayout['page_name'];
             break;
     }
     $this->arrData = self::loadData();
 }
 /**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 function lfGetRanking()
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     // おすすめ商品取得
     $col = 'T1.best_id, T1.category_id, T1.rank, T1.product_id, T1.title, T1.comment, T1.create_date, T1.update_date';
     $table = 'dtb_best_products as T1 INNER JOIN dtb_products as T2 ON T1.product_id = T2.product_id';
     $where = 'T1.del_flg = 0 and T2.status = 1';
     $objQuery->setOrder('T1.rank');
     $objQuery->setLimit(RECOMMEND_NUM);
     $arrBestProducts = $objQuery->select($col, $table, $where);
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     if (count($arrBestProducts) > 0) {
         // 商品一覧を取得
         // where条件生成&セット
         $arrProductId = array();
         $where = 'product_id IN (';
         foreach ($arrBestProducts as $key => $val) {
             $arrProductId[] = $val['product_id'];
         }
         // 取得
         $arrProductList = $objProduct->getListByProductIds($objQuery, $arrProductId);
         // おすすめ商品情報にマージ
         foreach ($arrBestProducts as $key => $value) {
             $arrRow =& $arrBestProducts[$key];
             if (isset($arrProductList[$arrRow['product_id']])) {
                 $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]);
             } else {
                 // 削除済み商品は除外
                 unset($arrBestProducts[$key]);
             }
         }
     }
     return $arrBestProducts;
 }
예제 #7
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);
 }
예제 #8
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);
 }
 /**
  * お気に入りを取得する
  *
  * @param mixed $customer_id
  * @param mixed $objPage
  * @access private
  * @return array お気に入り商品一覧
  */
 public function lfGetFavoriteProduct($customer_id, &$objPage)
 {
     if (DB_TYPE != 'sqlsrv') {
         return parent::lfGetFavoriteProduct($customer_id, $objPage);
     }
     $objQuery = SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     $objQuery->setOrder('f.create_date DESC');
     $where = 'f.customer_id = ? and p.status = 1';
     if (NOSTOCK_HIDDEN) {
         $where .= ' AND EXISTS(SELECT * FROM dtb_products_class WHERE product_id = f.product_id AND del_flg = 0 AND (stock >= 1 OR stock_unlimited = 1))';
     }
     $arrProductId = $objQuery->getCol('f.product_id', 'dtb_customer_favorite_products f inner join dtb_products p on f.product_id = p.product_id ', $where, array($customer_id));
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setWhere($this->lfMakeWhere('alldtl.', $arrProductId));
     $linemax = $objProduct->findProductCount($objQuery);
     $objPage->tpl_linemax = $linemax;
     // 何件が該当しました。表示用
     // ページ送りの取得
     $objNavi = new SC_PageNavi_Ex($objPage->tpl_pageno, $linemax, SEARCH_PMAX, 'eccube.movePage', NAVI_PMAX);
     $this->tpl_strnavi = $objNavi->strnavi;
     // 表示文字列
     $startno = $objNavi->start_row;
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     //$objQuery->setLimitOffset(SEARCH_PMAX, $startno);
     // 取得範囲の指定(開始行番号、行数のセット)
     $arrProductId = array_slice($arrProductId, $startno, SEARCH_PMAX);
     $where = $this->lfMakeWhere('', $arrProductId);
     $where .= ' AND del_flg = 0';
     $objQuery->setWhere($where, $arrProductId);
     $arrProducts = $objProduct->lists($objQuery);
     //取得している並び順で並び替え
     $arrProducts2 = array();
     foreach ($arrProducts as $item) {
         $arrProducts2[$item['product_id']] = $item;
     }
     $arrProductsList = array();
     foreach ($arrProductId as $product_id) {
         $arrProductsList[] = $arrProducts2[$product_id];
     }
     // 税込金額を設定する
     SC_Product_Ex::setIncTaxToProducts($arrProductsList);
     return $arrProductsList;
 }
 /**
  * おすすめ商品検索.
  *
  * @return array $arrBestProducts 検索結果配列
  */
 function lfGetRanking()
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     // おすすめ商品取得
     $col = 'best_id, best_id, category_id, rank, product_id, title, comment, create_date, update_date';
     $table = 'dtb_best_products';
     $where = 'del_flg = 0';
     $objQuery->setOrder('rank');
     $objQuery->setLimit(RECOMMEND_NUM);
     $arrBestProducts = $objQuery->select($col, $table, $where);
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     if (count($arrBestProducts) > 0) {
         // 商品一覧を取得
         // where条件生成&セット
         $arrProductId = array();
         $where = 'product_id IN (';
         foreach ($arrBestProducts as $key => $val) {
             $arrProductId[] = $val['product_id'];
         }
         // 取得
         $arrTmp = $objProduct->getListByProductIds($objQuery, $arrProductId);
         foreach ($arrTmp as $key => $arrRow) {
             $arrProductList[$arrRow['product_id']] = $arrRow;
         }
         // おすすめ商品情報にマージ
         foreach (array_keys($arrBestProducts) as $key) {
             $arrRow =& $arrBestProducts[$key];
             if (isset($arrProductList[$arrRow['product_id']])) {
                 $arrRow = array_merge($arrRow, $arrProductList[$arrRow['product_id']]);
             } else {
                 // 削除済み商品は除外
                 unset($arrBestProducts[$key]);
             }
         }
     }
     return $arrBestProducts;
 }
 /**
  * カート内の商品の妥当性をチェックする.
  *
  * エラーが発生した場合は, 商品をカート内から削除又は数量を調整し,
  * エラーメッセージを返す.
  *
  * 1. 商品種別に関連づけられた配送業者の存在チェック
  * 2. 削除/非表示商品のチェック
  * 3. 販売制限数のチェック
  * 4. 在庫数チェック
  *
  * @param  string $productTypeId 商品種別ID
  * @return string エラーが発生した場合はエラーメッセージ
  */
 public function checkProducts($productTypeId)
 {
     $objProduct = new SC_Product_Ex();
     $objDelivery = new SC_Helper_Delivery_Ex();
     $arrDeliv = $objDelivery->getList($productTypeId);
     $tpl_message = '';
     // カート内の情報を取得
     $arrItems = $this->getCartList($productTypeId);
     foreach ($arrItems as &$arrItem) {
         $product =& $arrItem['productsClass'];
         /*
          * 表示/非表示商品のチェック
          */
         if (SC_Utils_Ex::isBlank($product) || $product['status'] != 1) {
             $this->delProduct($arrItem['cart_no'], $productTypeId);
             $tpl_message .= "※ 現時点で販売していない商品が含まれておりました。該当商品をカートから削除しました。\n";
         } else {
             /*
              * 配送業者のチェック
              */
             if (SC_Utils_Ex::isBlank($arrDeliv)) {
                 $tpl_message .= '※「' . $product['name'] . '」はまだ配送の準備ができておりません。';
                 $tpl_message .= '恐れ入りますがお問い合わせページよりお問い合わせください。' . "\n";
                 $this->delProduct($arrItem['cart_no'], $productTypeId);
             }
             /*
              * 販売制限数, 在庫数のチェック
              */
             $limit = $objProduct->getBuyLimit($product);
             if (!is_null($limit) && $arrItem['quantity'] > $limit) {
                 if ($limit > 0) {
                     $this->setProductValue($arrItem['id'], 'quantity', $limit, $productTypeId);
                     $total_inctax = $limit * SC_Helper_TaxRule_Ex::sfCalcIncTax($arrItem['price'], $product['product_id'], $arrItem['id'][0]);
                     $this->setProductValue($arrItem['id'], 'total_inctax', $total_inctax, $productTypeId);
                     $tpl_message .= '※「' . $product['name'] . '」は販売制限(または在庫が不足)しております。';
                     $tpl_message .= "一度に数量{$limit}を超える購入はできません。\n";
                 } else {
                     $this->delProduct($arrItem['cart_no'], $productTypeId);
                     $tpl_message .= '※「' . $product['name'] . "」は売り切れました。\n";
                     continue;
                 }
             }
         }
     }
     return $tpl_message;
 }
 /**
  * 受注商品の追加/更新を行う.
  *
  * 小画面で選択した受注商品をフォームに反映させる.
  *
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @return void
  */
 function doRegisterProduct(&$objFormParam)
 {
     $product_class_id = $objFormParam->getValue('add_product_class_id');
     if (SC_Utils_Ex::isBlank($product_class_id)) {
         $product_class_id = $objFormParam->getValue('edit_product_class_id');
         $changed_no = $objFormParam->getValue('no');
     }
     // FXIME バリデーションを通さず $objFormParam の値で DB 問い合わせしている。(管理機能ため、さほど問題は無いと思うものの…)
     // 商品規格IDが指定されていない場合、例外エラーを発生
     if (strlen($product_class_id) === 0) {
         trigger_error('商品規格指定なし', E_USER_ERROR);
     }
     // 選択済みの商品であれば数量を1増やす
     $exists = false;
     $arrExistsProductClassIds = $objFormParam->getValue('product_class_id');
     foreach ($arrExistsProductClassIds as $key => $value) {
         $exists_product_class_id = $arrExistsProductClassIds[$key];
         if ($exists_product_class_id == $product_class_id) {
             $exists = true;
             $exists_no = $key;
             $arrExistsQuantity = $objFormParam->getValue('quantity');
             $arrExistsQuantity[$key]++;
             $objFormParam->setValue('quantity', $arrExistsQuantity);
         }
     }
     // 新しく商品を追加した場合はフォームに登録
     // 商品を変更した場合は、該当行を変更
     if (!$exists) {
         $objProduct = new SC_Product_Ex();
         $arrProduct = $objProduct->getDetailAndProductsClass($product_class_id);
         // 一致する商品規格がない場合、例外エラーを発生
         if (empty($arrProduct)) {
             trigger_error('商品規格一致なし', E_USER_ERROR);
         }
         $arrProduct['quantity'] = 1;
         $arrProduct['price'] = $arrProduct['price02'];
         $arrProduct['product_name'] = $arrProduct['name'];
         $arrUpdateKeys = array('product_id', 'product_class_id', 'product_type_id', 'point_rate', 'product_code', 'product_name', 'classcategory_name1', 'classcategory_name2', 'quantity', 'price');
         foreach ($arrUpdateKeys as $key) {
             $arrValues = $objFormParam->getValue($key);
             // FIXME getValueで文字列が返る場合があるので配列であるかをチェック
             if (!is_array($arrValues)) {
                 $arrValues = array();
             }
             if (isset($changed_no)) {
                 $arrValues[$changed_no] = $arrProduct[$key];
             } else {
                 $added_no = 0;
                 if (is_array($arrExistsProductClassIds)) {
                     $added_no = count($arrExistsProductClassIds);
                 }
                 $arrValues[$added_no] = $arrProduct[$key];
             }
             $objFormParam->setValue($key, $arrValues);
         }
     } elseif (isset($changed_no) && $exists_no != $changed_no) {
         // 変更したが、選択済みの商品だった場合は、変更対象行を削除。
         $this->doDeleteProduct($changed_no, $objFormParam);
     }
 }
 /**
  *
  * @param SC_Product_Ex $objProduct
  */
 public function lfGetProductsList($searchCondition, $disp_number, $startno, &$objProduct)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objDb = new SC_Helper_DB_Ex();
     $arrOrderVal = array();
     // 表示順序
     switch ($this->orderby) {
         // ダウンロード順
         case 'download':
             $status = ORDER_PRE_END;
             $objProduct->setProductsOrder('count(*)', "(SELECT B.* FROM dtb_order A INNER JOIN dtb_order_detail B USING(order_id) WHERE A.del_flg = 0 AND A.status = {$status})", 'ASC');
             break;
             // 販売価格が安い順
         // 販売価格が安い順
         case 'price':
             $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC');
             break;
             // 新着順
         // 新着順
         case 'date':
             if ($objDb->sfColumnExists('dtb_products', 'auto_display_start_date')) {
                 $objProduct->setProductsOrder('auto_display_start_date', 'dtb_products', 'DESC');
             } else {
                 $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC');
             }
             break;
         default:
             // FIXME 指定した カラムが損z内下場合はそのカラムをキーとする。
             if ($objDb->sfColumnExists('dtb_products', 'auto_display_start_date') && strlen($this->orderby) == 0) {
                 $objProduct->setProductsOrder('auto_display_start_date', 'dtb_products', 'DESC');
             } elseif ($objDb->sfColumnExists('dtb_products', $this->orderby)) {
                 $objProduct->setProductsOrder($this->orderby, 'dtb_products', 'DESC');
                 break;
             }
         case "rank":
             if (strlen($searchCondition['where_category']) >= 1) {
                 $dtb_product_categories = '(SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ')';
                 $arrOrderVal = $searchCondition['arrvalCategory'];
             } else {
                 $dtb_product_categories = 'dtb_product_categories';
             }
             $col = 'MAX(T3.rank * 2147483648 + T2.rank)';
             $from = "{$dtb_product_categories} T2 JOIN dtb_category T3 ON T2.category_id = T3.category_id";
             $where = 'T2.product_id = alldtl.product_id';
             $sub_sql = $objQuery->getSql($col, $from, $where);
             $objQuery->setOrder("({$sub_sql}) DESC ,product_id DESC");
             break;
     }
     // 取得範囲の指定(開始行番号、行数のセット)
     $objQuery->setLimitOffset($disp_number, $startno);
     $objQuery->setWhere($searchCondition['where']);
     // 表示すべきIDとそのIDの並び順を一気に取得
     $arrProductId = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition['arrval'], $arrOrderVal));
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId);
     // 規格を設定
     $objProduct->setProductsClassByProductIds($arrProductId);
     $arrProducts['productStatus'] = $objProduct->getProductStatus($arrProductId);
     foreach ($arrProducts as $product_id => &$arrProduct) {
         if ($product_id == 'productStatus') {
             continue;
         }
         $category_id = $objProduct->getCategoryIds($product_id);
         $arrProduct["category_id"] = array_shift($category_id);
         $arrProduct["category"] = $this->arrCategory[$arrProduct["category_id"]];
         $arrProduct["category_name"] = $arrProduct["category"]["category_name"];
         if ($objDb->sfColumnExists('dtb_category', 'category_code')) {
             $arrProduct["category_code"] = $arrProduct["category"]["category_code"];
             $arrProduct["category_image1"] = $arrProduct["category"]["category_image1"] ?: 0;
             $arrProduct["category_image2"] = $arrProduct["category"]["category_image2"] ?: 0;
             $arrProduct["category_image3"] = $arrProduct["category"]["category_image3"] ?: 0;
             $arrProduct["category_image4"] = $arrProduct["category"]["category_image4"] ?: 0;
             $arrProduct["category_image5"] = $arrProduct["category"]["category_image5"] ?: 0;
         }
     }
     return $arrProducts;
 }
 /**
  * 
  * @return void
  */
 function doMobileSelectItem()
 {
     $objProduct = new SC_Product_Ex();
     $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam, $this->tpl_classcat_find1, $this->tpl_classcat_find2);
     // この段階では、商品規格ID・数量の入力チェックエラーを出させない。
     // FIXME: エラーチェックの定義で mode で定義を分岐する方が良いように感じる
     unset($this->arrErr['product_class_id']);
     unset($this->arrErr['quantity']);
     // 規格2が設定されていて、エラーを検出した場合
     if ($this->tpl_classcat_find2 and !empty($this->arrErr)) {
         // templateの変更
         $this->tpl_mainpage = 'products/select_find2.tpl';
         return;
     }
     $product_id = $this->objFormParam->getValue('product_id');
     $value1 = $this->objFormParam->getValue('classcategory_id1');
     if (strlen($value1) === 0) {
         $value1 = '__unselected';
     }
     // 規格2が設定されている場合.
     if (SC_Utils_Ex::isBlank($this->objFormParam->getValue('classcategory_id2')) == false) {
         $value2 = '#' . $this->objFormParam->getValue('classcategory_id2');
     } else {
         $value2 = '#0';
     }
     $objProduct->setProductsClassByProductIds(array($product_id));
     $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$value1][$value2]['product_class_id'];
     // 数量の入力を行う
     $this->tpl_mainpage = 'products/select_item.tpl';
 }
예제 #15
0
    /**
     * カテゴリ数の登録を行う.
     *
     *
     * @param  SC_Query $objQuery           SC_Query インスタンス
     * @param  boolean  $is_force_all_count 全カテゴリの集計を強制する場合 true
     * @return void
     */
    public function sfCountCategory($objQuery = NULL, $is_force_all_count = false)
    {
        $objProduct = new SC_Product_Ex();
        if ($objQuery == NULL) {
            $objQuery =& SC_Query_Ex::getSingletonInstance();
        }
        $is_out_trans = false;
        if (!$objQuery->inTransaction()) {
            $objQuery->begin();
            $is_out_trans = true;
        }
        //共通のfrom/where文の構築
        $sql_where = SC_Product_Ex::getProductDispConditions('alldtl');
        // 在庫無し商品の非表示
        if (NOSTOCK_HIDDEN) {
            $where_products_class = '(stock >= 1 OR stock_unlimited = 1)';
            $from = $objProduct->alldtlSQL($where_products_class);
        } else {
            $from = 'dtb_products as alldtl';
        }
        //dtb_category_countの構成
        // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを含まない。
        //まずテーブル内容の元を取得
        if (!$is_force_all_count) {
            $arrCategoryCountOld = $objQuery->select('category_id,product_count', 'dtb_category_count');
        } else {
            $arrCategoryCountOld = array();
        }
        //各カテゴリ内の商品数を数えて取得
        $sql = <<<__EOS__
            SELECT T1.category_id, count(T2.category_id) as product_count
            FROM dtb_category AS T1
                LEFT JOIN dtb_product_categories AS T2
                    ON T1.category_id = T2.category_id
                LEFT JOIN {$from}
                    ON T2.product_id = alldtl.product_id
            WHERE {$sql_where}
            GROUP BY T1.category_id, T2.category_id
__EOS__;
        $arrCategoryCountNew = $objQuery->getAll($sql);
        // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを「含む」。
        //差分を取得して、更新対象カテゴリだけを確認する。
        //各カテゴリ毎のデータ値において以前との差を見る
        //古いデータの構造入れ替え
        $arrOld = array();
        foreach ($arrCategoryCountOld as $item) {
            $arrOld[$item['category_id']] = $item['product_count'];
        }
        //新しいデータの構造入れ替え
        $arrNew = array();
        foreach ($arrCategoryCountNew as $item) {
            $arrNew[$item['category_id']] = $item['product_count'];
        }
        unset($arrCategoryCountOld);
        unset($arrCategoryCountNew);
        $arrDiffCategory_id = array();
        //新しいカテゴリ一覧から見て商品数が異なるデータが無いか確認
        foreach ($arrNew as $cid => $count) {
            if ($arrOld[$cid] != $count) {
                $arrDiffCategory_id[] = $cid;
            }
        }
        //削除カテゴリを想定して、古いカテゴリ一覧から見て商品数が異なるデータが無いか確認。
        foreach ($arrOld as $cid => $count) {
            if ($arrNew[$cid] != $count && $count > 0) {
                $arrDiffCategory_id[] = $cid;
            }
        }
        //対象IDが無ければ終了
        if (count($arrDiffCategory_id) == 0) {
            if ($is_out_trans) {
                $objQuery->commit();
            }
            return;
        }
        //差分対象カテゴリIDの重複を除去
        $arrDiffCategory_id = array_unique($arrDiffCategory_id);
        //dtb_category_countの更新 差分のあったカテゴリだけ更新する。
        foreach ($arrDiffCategory_id as $cid) {
            $sqlval = array();
            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
            $sqlval['product_count'] = (string) $arrNew[$cid];
            if ($sqlval['product_count'] == '') {
                $sqlval['product_count'] = (string) '0';
            }
            if (isset($arrOld[$cid])) {
                $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid));
            } else {
                if ($is_force_all_count) {
                    $ret = $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid));
                    if ($ret > 0) {
                        continue;
                    }
                }
                $sqlval['category_id'] = $cid;
                $objQuery->insert('dtb_category_count', $sqlval);
            }
        }
        unset($arrOld);
        unset($arrNew);
        //差分があったIDとその親カテゴリIDのリストを取得する
        $arrTgtCategory_id = array();
        foreach ($arrDiffCategory_id as $parent_category_id) {
            $arrTgtCategory_id[] = $parent_category_id;
            $arrParentID = $this->sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id);
            $arrTgtCategory_id = array_unique(array_merge($arrTgtCategory_id, $arrParentID));
        }
        unset($arrDiffCategory_id);
        //dtb_category_total_count 集計処理開始
        //更新対象カテゴリIDだけ集計しなおす。
        $arrUpdateData = array();
        $where_products_class = '';
        if (NOSTOCK_HIDDEN) {
            $where_products_class .= '(stock >= 1 OR stock_unlimited = 1)';
        }
        $from = $objProduct->alldtlSQL($where_products_class);
        foreach ($arrTgtCategory_id as $category_id) {
            $arrWhereVal = array();
            list($tmp_where, $arrTmpVal) = $this->sfGetCatWhere($category_id);
            if ($tmp_where != '') {
                $sql_where_product_ids = 'product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')';
                $arrWhereVal = $arrTmpVal;
            } else {
                $sql_where_product_ids = '0<>0';
                // 一致させない
            }
            $where = "({$sql_where}) AND ({$sql_where_product_ids})";
            $arrUpdateData[$category_id] = $objQuery->count($from, $where, $arrWhereVal);
        }
        unset($arrTgtCategory_id);
        // 更新対象だけを更新。
        foreach ($arrUpdateData as $cid => $count) {
            $sqlval = array();
            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
            $sqlval['product_count'] = $count;
            if ($sqlval['product_count'] == '') {
                $sqlval['product_count'] = (string) '0';
            }
            $ret = $objQuery->update('dtb_category_total_count', $sqlval, 'category_id = ?', array($cid));
            if (!$ret) {
                $sqlval['category_id'] = $cid;
                $objQuery->insert('dtb_category_total_count', $sqlval);
            }
        }
        // トランザクション終了処理
        if ($is_out_trans) {
            $objQuery->commit();
        }
    }
 function lfPreGetRecommendProducts($product_id)
 {
     $objProduct = new SC_Product_Ex();
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setOrder('rank DESC');
     $arrRecommendData = $objQuery->select('recommend_product_id, comment', 'dtb_recommend_products as t1 left join dtb_products as t2 on t1.recommend_product_id = t2.product_id', 't1.product_id = ? and t2.del_flg = 0 and t2.status = 1', array($product_id));
     $arrRecommendProductId = array();
     foreach ($arrRecommendData as $recommend) {
         $arrRecommendProductId[] = $recommend['recommend_product_id'];
     }
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrRecommendProductId);
     $arrRecommend = array();
     foreach ($arrRecommendData as $key => $arrRow) {
         $arrRecommendData[$key] = array_merge($arrRow, $arrProducts[$arrRow['recommend_product_id']]);
     }
     return $arrRecommendData;
 }
예제 #17
0
 /**
  *
  * @return void
  */
 public function doJson()
 {
     $this->arrProducts = $this->setStatusDataTo($this->arrProducts, $this->arrSTATUS, $this->arrSTATUS_IMAGE);
     SC_Product_Ex::setPriceTaxTo($this->arrProducts);
     // 一覧メイン画像の指定が無い商品のための処理
     foreach ($this->arrProducts as $key => $val) {
         $this->arrProducts[$key]['main_list_image'] = SC_Utils_Ex::sfNoImageMainList($val['main_list_image']);
     }
     echo SC_Utils_Ex::jsonEncode($this->arrProducts);
     SC_Response_Ex::actionExit();
 }
 /**
  * 規格編集画面を表示する
  *
  * @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);
 }
 /**
  * 都度課金.
  *
  * @param unknown $config
  * @param SC_Customer $objCustomer
  * @param number $ammount
  */
 function doPayCertForAuthorySold($config, SC_Customer $objCustomer, $ammount = 500)
 {
     // TODO 次期リリースで マスタ化
     switch ($ammount) {
         case 1000:
             $ammount = 1000;
             break;
         default:
             $ammount = 500;
     }
     $objQuery = SC_Query_Ex::getSingletonInstance();
     if (!$objCustomer->isLoginSuccess()) {
         $this->doLogin($this->getMode(), $objCustomer, $objQuery);
     }
     // FIXME 1円 1ポイント購入計算
     $point = $ammount;
     if ($this->tpl_point + $point > AU_MAXPOINT) {
         $msg = "合計ポイントが%sポイントを越えるためポイントの購入が出来ません";
         $msg = sprintf($msg, number_format(AU_MAXPOINT));
         SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, $msg);
     }
     $objProduct = new SC_Product_Ex();
     $ammount_in_tax = SC_Helper_TaxRule_Ex::sfCalcIncTax($ammount);
     $_SESSION["return_to_key"] = "pay_cert_for_authory_sold_return_to";
     if ($objProduct->isValidProductId($_REQUEST["product_id"])) {
         $_SESSION[$_SESSION["return_to_key"]] = P_DETAIL_URLPATH . $_REQUEST["product_id"];
     } else {
         $_SESSION[$_SESSION["return_to_key"]] = ROOT_URLPATH . "au/point_add_complete.php?ammount={$ammount}";
     }
     $_SESSION["before_mode"] = "pay_cert_for_authory_sold";
     $okUrl = new Net_URL($_SERVER["SCRIPT_NAME"]);
     $ngUrl = new Net_URL($_SERVER["SCRIPT_NAME"]);
     $okUrl->addQueryString("mode", "pay_cert_for_authory_sold_ok");
     $okUrl->addQueryString("ammount", $ammount);
     $okUrl->addQueryString("ammount_in_tax", $ammount_in_tax);
     $ngUrl->addQueryString("mode", "pay_cert_for_authory_sold_ng");
     $shop_name = mb_convert_kana($this->arrSiteInfo["shop_name"], "AKc");
     $shop_tel = $this->getShopTel();
     // FIXME 決済認可
     $curl = $this->curl_init();
     $post_history = array();
     $post = $this->getPost("PayCertForAuthorySold", $config, array("certType" => "01", "openId" => $objCustomer->getValue("au_open_id"), "amount" => $ammount_in_tax, "commodity" => mb_convert_kana("ポイント購入", "A"), "memberAuthOkUrl" => $okUrl->getURL(), "memberAuthNgUrl" => $ngUrl->getURL(), "serviceName" => $shop_name, "serviceTel" => $shop_tel));
     $post_history[] = $post;
     curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
     $result = $this->curl_result($curl);
     $result["post_history"] = $post_history;
     $this->check_result($result);
     $transactionId = rawurldecode($result["body"]["transactionId"]);
     // FIXME ユーザー認証
     $result = $this->doUserPermitBridge($config, $objCustomer, $transactionId, $post_history);
     header("Location: " . $result["head"]["Location"]);
     SC_Response_Ex::actionExit();
 }
 /**
  * 商品情報を取得する(vw_products_allclass使用)
  *
  * @param SC_Query $objQuery DB操作クラス
  * @return array $arrProduct 取得結果を配列で返す
  */
 function lfGetProductsAllclass(&$objQuery)
 {
     // --- 商品一覧の取得
     $objQuery->setWhere('del_flg = 0 AND status = 1');
     $objQuery->setOrder('product_id');
     $objProduct = new SC_Product_Ex();
     $arrProductLsit = $objProduct->lists($objQuery);
     // 各商品のカテゴリIDとランクの取得
     $arrProducts = array();
     foreach ($arrProductLsit as $key => $val) {
         $sql = '';
         $sql .= ' SELECT';
         $sql .= '   T1.category_id,';
         $sql .= '   T1.rank AS product_rank,';
         $sql .= '   T2.rank AS category_rank';
         $sql .= ' FROM';
         $sql .= '   dtb_product_categories AS T1';
         $sql .= ' LEFT JOIN';
         $sql .= '   dtb_category AS T2';
         $sql .= ' ON';
         $sql .= '   T1.category_id = T2.category_id';
         $sql .= ' WHERE';
         $sql .= '   product_id = ?';
         $arrCategory = $objQuery->getAll($sql, array($val['product_id']));
         if (!empty($arrCategory)) {
             $arrProducts[$key] = array_merge($val, $arrCategory[0]);
         }
     }
     // 税込金額を設定する
     SC_Product_Ex::setIncTaxToProducts($arrProducts);
     return $arrProducts;
 }
예제 #21
0
 function sfSendOrderMail($order_id, $template_id, $subject = "", $header = "", $footer = "", $send = true)
 {
     $arrTplVar = new stdClass();
     $arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
     $arrTplVar->arrInfo = $arrInfo;
     $objQuery = new SC_Query_Ex();
     if ($subject == "" && $header == "" && $footer == "") {
         // メールテンプレート情報の取得
         $where = "template_id = ?";
         $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id));
         $arrTplVar->tpl_header = $arrRet[0]['header'];
         $arrTplVar->tpl_footer = $arrRet[0]['footer'];
         $tmp_subject = $arrRet[0]['subject'];
     } else {
         $arrTplVar->tpl_header = $header;
         $arrTplVar->tpl_footer = $footer;
         $tmp_subject = $subject;
     }
     // 受注情報の取得
     $where = "order_id = ?";
     $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id));
     $arrOrder = $arrRet[0];
     $objQuery->setOrder('order_detail_id');
     $arrTplVar->arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id));
     $objProduct = new SC_Product_Ex();
     $objQuery->setOrder('shipping_id');
     $arrRet = $objQuery->select("*", "dtb_shipping", "order_id = ?", array($order_id));
     foreach (array_keys($arrRet) as $key) {
         $objQuery->setOrder('shipping_id');
         $arrItems = $objQuery->select("*", "dtb_shipment_item", "order_id = ? AND shipping_id = ?", array($order_id, $arrRet[$key]['shipping_id']));
         foreach ($arrItems as $itemKey => $arrDetail) {
             foreach ($arrDetail as $detailKey => $detailVal) {
                 $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']][$detailKey] = $detailVal;
             }
             $arrRet[$key]['shipment_item'][$arrDetail['product_class_id']]['productsClass'] =& $objProduct->getDetailAndProductsClass($arrDetail['product_class_id']);
         }
     }
     $arrTplVar->arrShipping = $arrRet;
     $arrTplVar->Message_tmp = $arrOrder['message'];
     // 会員情報の取得
     $customer_id = $arrOrder['customer_id'];
     $objQuery->setOrder('customer_id');
     $arrRet = $objQuery->select('point', "dtb_customer", "customer_id = ?", array($customer_id));
     $arrCustomer = isset($arrRet[0]) ? $arrRet[0] : "";
     $arrTplVar->arrCustomer = $arrCustomer;
     $arrTplVar->arrOrder = $arrOrder;
     //その他決済情報
     if ($arrOrder['memo02'] != "") {
         $arrOther = unserialize($arrOrder['memo02']);
         foreach ($arrOther as $other_key => $other_val) {
             if (SC_Utils_Ex::sfTrim($other_val['value']) == "") {
                 $arrOther[$other_key]['value'] = "";
             }
         }
         $arrTplVar->arrOther = $arrOther;
     }
     // 都道府県変換
     $arrTplVar->arrPref = $this->arrPref;
     $objCustomer = new SC_Customer_Ex();
     $arrTplVar->tpl_user_point = $objCustomer->getValue('point');
     if (Net_UserAgent_Mobile::isMobile() === true) {
         $objMailView = new SC_MobileView_Ex();
     } else {
         $objMailView = new SC_SiteView_Ex();
     }
     // メール本文の取得
     $objMailView->assignobj($arrTplVar);
     $body = $objMailView->fetch($this->arrMAILTPLPATH[$template_id]);
     // メール送信処理
     $objSendMail = new SC_SendMail_Ex();
     $bcc = $arrInfo['email01'];
     $from = $arrInfo['email03'];
     $error = $arrInfo['email04'];
     $tosubject = $this->sfMakeSubject($tmp_subject, $objMailView);
     $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc);
     $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " " . $arrOrder["order_name02"] . " 様");
     // 送信フラグ:trueの場合は、送信する。
     if ($send) {
         if ($objSendMail->sendMail()) {
             $this->sfSaveMailHistory($order_id, $template_id, $tosubject, $body);
         }
     }
     return $objSendMail;
 }
 /**
  * 該当件数の取得
  *
  * @return int
  */
 function lfGetProductAllNum($searchCondition)
 {
     // 検索結果対象となる商品の数を取得
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setWhere($searchCondition['where_for_count']);
     $objProduct = new SC_Product_Ex();
     return $objProduct->findProductCount($objQuery, $searchCondition['arrval']);
 }
예제 #23
0
 /**
  * 商品を変更
  *
  * @param  SC_FormParam $objFormParam         SC_FormParam インスタンス
  * @param  integer      $edit_product_class_id 変更商品規格ID
  * @param  integer      $change_no            変更対象
  * @return void
  */
 public function shipmentEditProduct(&$objFormParam, $edit_product_class_id, $change_no)
 {
     $arrPreProductClassIds = $objFormParam->getValue('product_class_id');
     $select_shipping_id = $objFormParam->getValue('select_shipping_id');
     $arrShipmentProducts = $this->getShipmentProducts($objFormParam);
     $pre_shipment_product_class_id = $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][$change_no];
     if ($pre_shipment_product_class_id == $edit_product_class_id) {
         // 商品規格に変更がない場合は何もしない
     } elseif (in_array($edit_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])) {
         // 商品規格の変更によって商品の重複が発生する場合は一つにまとめる
         $arrShipmentProducts = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys, $select_shipping_id, $change_no);
         foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) {
             if ($shipment_product_class_id == $edit_product_class_id) {
                 $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index]++;
                 break;
             }
         }
     } else {
         $objProduct = new SC_Product_Ex();
         $arrAddProductInfo = $objProduct->getDetailAndProductsClass($edit_product_class_id);
         //上書き
         $this->changeShipmentProducts($arrShipmentProducts, $arrAddProductInfo, $select_shipping_id, $change_no);
         //受注商品情報も上書き
         $arrTax = SC_Helper_TaxRule_Ex::getTaxRule(0, $edit_product_class_id);
         // 実際はedit
         $arrAddProductInfo['product_name'] = $arrAddProductInfo['product_name'] ? $arrAddProductInfo['product_name'] : $arrAddProductInfo['name'];
         $arrAddProductInfo['price'] = $arrAddProductInfo['price'] ? $arrAddProductInfo['price'] : $arrAddProductInfo['price02'];
         $arrAddProductInfo['quantity'] = 1;
         $arrAddProductInfo['tax_rate'] = $objFormParam->getValue('order_tax_rate') == '' ? $arrTax['tax_rate'] : $objFormParam->getValue('order_tax_rate');
         $arrAddProductInfo['tax_rule'] = $objFormParam->getValue('order_tax_rule') == '' ? $arrTax['tax_rule'] : $objFormParam->getValue('order_tax_rule');
         $arrProductClassIds = $objFormParam->getValue('product_class_id');
         foreach ($arrProductClassIds as $key => $product_class_id) {
             if ($product_class_id == $pre_shipment_product_class_id) {
                 foreach ($this->arrProductKeys as $insert_key) {
                     $value = $objFormParam->getValue($insert_key);
                     $arrAddProducts[$insert_key] = is_array($value) ? $value : array();
                     $arrAddProducts[$insert_key][$key] = $arrAddProductInfo[$insert_key];
                 }
             }
         }
         $objFormParam->setParam($arrAddProducts);
     }
     $objFormParam->setParam($arrShipmentProducts);
     foreach ($arrNewShipmentProducts['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) {
         if (in_array($pre_shipment_product_class_id, $arrShipmentProductClassIds)) {
             $is_product_delete = false;
             break;
         }
     }
     //商品情報から削除
     if ($is_product_delete) {
         $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $pre_shipment_product_class_id, $this->arrProductKeys);
     }
 }
 /**
  * 配送商品を取得する.
  *
  * @param  integer $order_id    受注ID
  * @param  integer $shipping_id 配送先ID
  * @param  boolean $has_detail  商品詳細も取得する場合 true
  * @return array   商品規格IDをキーにした配送商品の配列
  */
 public function getShipmentItems($order_id, $shipping_id, $has_detail = true)
 {
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     $arrResults = array();
     $objQuery->setOrder('order_detail_id');
     $arrItems = $objQuery->select('dtb_shipment_item.*', 'dtb_shipment_item join dtb_order_detail ON dtb_shipment_item.product_class_id = dtb_order_detail.product_class_id AND dtb_shipment_item.order_id = dtb_order_detail.order_id', 'dtb_order_detail.order_id = ? AND shipping_id = ?', array($order_id, $shipping_id));
     foreach ($arrItems as $key => $arrItem) {
         $product_class_id = $arrItem['product_class_id'];
         foreach ($arrItem as $detailKey => $detailVal) {
             $arrResults[$key][$detailKey] = $detailVal;
         }
         // 商品詳細を関連づける
         if ($has_detail) {
             $arrResults[$key]['productsClass'] =& $objProduct->getDetailAndProductsClass($product_class_id);
         }
     }
     return $arrResults;
 }
예제 #25
0
<?php

require_once realpath(dirname(__FILE__)) . '/../require.php';
$qrcode = new Image_QRCode(array("path" => DATA_REALDIR . "module/Image/data", "image_path" => DATA_REALDIR . "module/Image/imagedata"));
$objProduct = new SC_Product_Ex();
if ($objProduct->isValidProductId($_GET["product_id"], true)) {
    $sid = $_GET["sid"];
    $p_detail_url = HTTP_URL . substr(P_DETAIL_URLPATH, strlen(ROOT_URLPATH));
    $p_detail_url = str_replace("detail.php", "detail_spass.php", $p_detail_url);
    $qrcode->makeCode($p_detail_url . $_GET["product_id"] . "&admin=on&sid={$sid}", array('image_type' => 'jpeg', 'error_correct' => 'L'));
}
예제 #26
0
 /**
  * お気に入りを取得する
  *
  * @param mixed $customer_id
  * @param mixed $objPage
  * @access private
  * @return array お気に入り商品一覧
  */
 function lfGetFavoriteProduct($customer_id, &$objPage)
 {
     $objQuery = SC_Query_Ex::getSingletonInstance();
     $objProduct = new SC_Product_Ex();
     $objQuery->setOrder('create_date DESC');
     $arrProductId = $objQuery->getCol('product_id', 'dtb_customer_favorite_products', 'customer_id = ?', array($customer_id));
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setWhere($this->lfMakeWhere('alldtl.', $arrProductId));
     $linemax = $objProduct->findProductCount($objQuery);
     $objPage->tpl_linemax = $linemax;
     // 何件が該当しました。表示用
     // ページ送りの取得
     $objNavi = new SC_PageNavi_Ex($objPage->tpl_pageno, $linemax, SEARCH_PMAX, 'fnNaviPage', NAVI_PMAX);
     $this->tpl_strnavi = $objNavi->strnavi;
     // 表示文字列
     $startno = $objNavi->start_row;
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     //$objQuery->setLimitOffset(SEARCH_PMAX, $startno);
     // 取得範囲の指定(開始行番号、行数のセット)
     $arrProductId = array_slice($arrProductId, $startno, SEARCH_PMAX);
     $where = $this->lfMakeWhere('', $arrProductId);
     $where .= ' AND del_flg = 0';
     $objQuery->setWhere($where, $arrProductId);
     $arrProducts = $objProduct->lists($objQuery);
     //取得している並び順で並び替え
     $arrProducts2 = array();
     foreach ($arrProducts as $item) {
         $arrProducts2[$item['product_id']] = $item;
     }
     $arrProductsList = array();
     foreach ($arrProductId as $product_id) {
         $arrProductsList[] = $arrProducts2[$product_id];
     }
     // 税込金額を設定する
     SC_Product_Ex::setIncTaxToProducts($arrProductsList);
     return $arrProductsList;
 }
 /**
  * @param SC_Helper_DB_Ex $objDb
  */
 public function lfGetProducts(&$objDb)
 {
     $where = 'del_flg = 0';
     $arrWhereVal = array();
     /* 入力エラーなし */
     foreach ($this->arrForm as $key => $val) {
         if ($val == '') {
             continue;
         }
         switch ($key) {
             case 'search_name':
                 $where .= ' AND name ILIKE ?';
                 $arrWhereVal[] = "%{$val}%";
                 break;
             case 'search_category_id':
                 list($tmp_where, $arrTmp) = $objDb->sfGetCatWhere($val);
                 if ($tmp_where != '') {
                     $where .= ' AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')';
                     $arrWhereVal = array_merge((array) $arrWhereVal, (array) $arrTmp);
                 }
                 break;
             case 'search_product_code':
                 $where .= ' AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ?)';
                 $arrWhereVal[] = "{$val}%";
                 break;
             default:
                 break;
         }
     }
     $order = 'update_date DESC, product_id DESC ';
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     // 行数の取得
     $linemax = $objQuery->count('dtb_products', $where, $arrWhereVal);
     $this->tpl_linemax = $linemax;
     // 何件が該当しました。表示用
     // ページ送りの処理
     $page_max = SC_Utils_Ex::sfGetSearchPageMax($_POST['search_page_max']);
     // ページ送りの取得
     $objNavi = new SC_PageNavi_Ex($_POST['search_pageno'], $linemax, $page_max, 'eccube.moveSearchPage', NAVI_PMAX);
     $this->tpl_strnavi = $objNavi->strnavi;
     // 表示文字列
     $startno = $objNavi->start_row;
     // 取得範囲の指定(開始行番号、行数のセット)
     $objQuery->setLimitOffset($page_max, $startno);
     // 表示順序
     $objQuery->setOrder($order);
     // 検索結果の取得
     // FIXME 商品コードの表示
     $arrProducts = $objQuery->select('*', SC_Product_Ex::alldtlSQL(), $where, $arrWhereVal);
     return $arrProducts;
 }
예제 #28
0
 function lfPreGetRecommendProducts($product_id)
 {
     $objProduct = new SC_Product_Ex();
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->setOrder("rank DESC");
     $arrRecommendData = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
     $arrRecommendProductId = array();
     foreach ($arrRecommendData as $recommend) {
         $arrRecommendProductId[] = $recommend["recommend_product_id"];
         $arrRecommendData[$recommend["recommend_product_id"]] = $recommend['comment'];
     }
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $arrProducts = $objProduct->getListByProductIds($objQuery, $arrRecommendProductId);
     //取得している並び順で並び替え
     // FIXME SC_Productあたりにソート処理はもってくべき
     $arrProducts2 = array();
     foreach ($arrProducts as $item) {
         $arrProducts2[$item['product_id']] = $item;
     }
     $arrRecommend = array();
     foreach ($arrRecommendProductId as $product_id) {
         $arrProducts2[$product_id]['comment'] = $arrRecommendData[$product_id];
         $arrRecommend[] = $arrProducts2[$product_id];
     }
     return $arrRecommend;
 }
예제 #29
0
 /**
  * 商品情報の配列に税込金額を設定する
  *
  * @param array $arrProducts 商品情報の配列
  * @return void
  */
 static function setIncTaxToProducts(&$arrProducts)
 {
     foreach ($arrProducts as &$arrProduct) {
         SC_Product_Ex::setIncTaxToProduct($arrProduct);
     }
 }
 /**
  * 全ての商品詳細ページを取得する.
  *
  * @return array 検索エンジンからアクセス可能な商品詳細ページの情報
  */
 public function getAllDetail()
 {
     $objQuery = SC_Query_Ex::getSingletonInstance();
     $sql = 'SELECT product_id, update_date FROM dtb_products WHERE ' . SC_Product_Ex::getProductDispConditions();
     $objQuery->setOrder("product_id");
     $result = $objQuery->getAll($sql);
     $arrRet = array();
     foreach ($result as $row) {
         $arrPage = $row;
         $arrPage['update_date'] = $row['update_date'];
         $arrPage['url'] = HTTP_URL . substr(P_DETAIL_URLPATH, strlen(ROOT_URLPATH)) . $row['product_id'];
         $arrRet[] = $arrPage;
     }
     return $arrRet;
 }