function lfCheckCategoryId($category_id) { if ($category_id && !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array) $category_id, 'del_flg = 0')) { return 0; } return $category_id; }
public function doAction($arrParam) { $arrRequest = $this->doInitParam($arrParam); if (!$this->isParamError()) { $category_id = $arrRequest['BrowseNodeId']; if ($category_id && !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array) $category_id, 'del_flg = 0')) { $category_id = '0'; } else { if (SC_Utils_Ex::isBlank($category_id)) { $category_id = '0'; } } // LC_Page_Products_CategoryList::lfGetCategories() と相当類似しているので共通化したい $arrCategory = null; // 選択されたカテゴリ $arrChildren = array(); // 子カテゴリ $arrAll = SC_Helper_DB_Ex::sfGetCatTree($category_id, true); foreach ($arrAll as $category) { if ($category_id != 0 && $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 (!SC_Utils_Ex::isBlank($arrCategory)) { $arrData = array('BrowseNodeId' => $category_id, 'Name' => $arrCategory['category_name'], 'PageURL' => HTTP_URL . 'products/list.php?category_id=' . $arr['category_id'], 'has_children' => count($arrChildren) > 0); } else { $arrData = array('BrowseNodeId' => $category_id, 'Name' => 'ホーム', 'PageURL' => HTTP_URL, 'has_children' => count($arrChildren) > 0); } if (!SC_Utils_Ex::isBlank($arrChildren)) { $arrData['Children'] = array(); foreach ($arrChildren as $category) { $arrData['Children']['BrowseNode'][] = array('BrowseNodeId' => $category['category_id'], 'Name' => $category['category_name'], 'PageURL' => HTTP_URL . 'products/list.php?category_id=' . $category['category_id'], 'has_children' => $category['has_children']); } } $this->setResponse('BrowseNode', $arrData); // TODO: Ancestors 親ノード return true; } return false; }
/** * Page のプロセス. * * @return void */ function process() { $objView = new SC_SiteView(); $objCartSess = new SC_CartSession("", false); $objDb = new SC_Helper_DB_Ex(); // 管理ページからの確認の場合は、非公開の商品も表示する。 if (isset($_GET['admim']) && $_GET['admin'] == 'on') { $where = "del_flg = 0"; } else { $where = "del_flg = 0 AND status = 1"; } // 値の正当性チェック if (!SC_Utils_Ex::sfIsInt($_GET['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_GET['product_id'], $where)) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } $image_key = $_GET['image']; $objQuery = new SC_Query(); // カラムが存在していなければエラー画面を表示 if (!$objDb->sfColumnExists("dtb_products", $image_key)) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } $col = "name, {$image_key}"; $arrRet = $objQuery->select($col, "dtb_products", "product_id = ?", array($_GET['product_id'])); $image_path = IMAGE_SAVE_DIR . $arrRet[0][$image_key]; if (file_exists($image_path)) { list($width, $height) = getimagesize($image_path); } else { $width = 0; $height = 0; } $this->tpl_width = $width; $this->tpl_height = $height; $this->tpl_table_width = $this->tpl_width + 20; $this->tpl_table_height = $this->tpl_height + 20; $this->tpl_image = $arrRet[0][$image_key]; $this->tpl_name = $arrRet[0]['name']; $objView->assignobj($this); $objView->display($this->tpl_mainpage); }
/** * 選択中の商品のカテゴリを取得する. * * @param integer $product_id プロダクトID * @param integer $category_id カテゴリID * @return array 選択中の商品のカテゴリIDの配列 * */ function sfGetCategoryId($product_id, $category_id = 0, $closed = false) { if ($closed) { $status = ""; } else { $status = "status = 1"; } $category_id = (int) $category_id; $product_id = (int) $product_id; if (SC_Utils_Ex::sfIsInt($category_id) && $category_id != 0 && SC_Helper_DB_Ex::sfIsRecord("dtb_category", "category_id", $category_id)) { $category_id = array($category_id); } else { if (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $product_id, $status)) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $where = "product_id = ?"; $category_id = $objQuery->getCol("category_id", "dtb_product_categories", "product_id = ?", array($product_id)); } else { // 不正な場合は、空の配列を返す。 $category_id = array(); } } return $category_id; }
function lfCheckError() { // 入力データを渡す。 $arrRet = $this->objFormParam->getHashArray(); $objErr = new SC_CheckError($arrRet); $objErr->arrErr = $this->objFormParam->checkError(); if (!isset($objErr->arrErr['name']) && $_POST['deliv_id'] == "") { // 既存チェック $objDb = new SC_Helper_DB_Ex(); $ret = $objDb->sfIsRecord("dtb_deliv", "service_name", array($arrRet['service_name'])); if ($ret) { $objErr->arrErr['name'] = "※ 同じ名称の組み合わせは登録できません。<br>"; } } return $objErr->arrErr; }
/** * このフォーム特有の複雑な入力チェックを行う. * * @param array 確認対象データ * @param array エラー配列 * @return array エラー配列 */ function lfCheckErrorDetail($item, $arrErr) { $objQuery =& SC_Query_Ex::getSingletonInstance(); /* // カテゴリIDの存在チェック if (!$this->lfIsDbRecord('dtb_category', 'category_id', $item)) { $arrErr['category_id'] = '※ 指定のカテゴリIDは、登録されていません。'; } */ // 親カテゴリIDの存在チェック if (array_search('parent_category_id', $this->arrFormKeyList) !== FALSE && $item['parent_category_id'] != '' && $item['parent_category_id'] != '0' && !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', array($item['parent_category_id']))) { $arrErr['parent_category_id'] = t('c_* The designated new category ID (T_ARG1) does not exist._01', array('T_ARG1' => $item['parent_category_id'])); } // 削除フラグのチェック if (array_search('del_flg', $this->arrFormKeyList) !== FALSE && $item['del_flg'] != '') { if (!($item['del_flg'] == '0' or $item['del_flg'] == '1')) { $arrErr['del_flg'] = t("c_* Only '0' (active) and '1' (delete) are effective for the deletion flag. _01"); } } // 重複チェック 同じカテゴリ内に同名の存在は許可されない if (array_search('category_name', $this->arrFormKeyList) !== FALSE && $item['category_name'] != '') { $parent_category_id = $item['parent_category_id']; if ($parent_category_id == '') { $parent_category_id = (string) '0'; } $where = 'parent_category_id = ? AND category_id <> ? AND category_name = ?'; $exists = $objQuery->exists('dtb_category', $where, array($parent_category_id, $item['category_id'], $item['category_name'])); if ($exists) { $arrErr['category_name'] = t('c_* A category of the same name already exists._01'); } } // 登録数上限チェック $where = 'del_flg = 0'; $count = $objQuery->count('dtb_category', $where); if ($count >= CATEGORY_MAX) { $item['category_name'] = t('c_* The maximum number of categories that can be registered has been exceeded._01'); } // 階層上限チェック if (array_search('parent_category_id', $this->arrFormKeyList) !== FALSE and $item['parent_category_id'] != '') { $level = $objQuery->get('level', 'dtb_category', 'category_id = ?', array($parent_category_id)); if ($level >= LEVEL_MAX) { $arrErr['parent_category_id'] = t('c_* Registration of the T_ARG1 hierarchy or higher is not possible._01', array('T_ARG1' => LEVEL_MAX)); } } return $arrErr; }
/** * Page のプロセス. * * @return void */ function process() { $objView = new SC_SiteView(); $conn = new SC_DBConn(); $objDb = new SC_Helper_DB_Ex(); //表示件数の選択 if (isset($_POST['disp_number']) && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { $this->disp_number = $_POST['disp_number']; } else { //最小表示件数を選択 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); } //表示順序の保存 $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : ""; // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); if (!isset($_GET['mode'])) { $_GET['mode'] = ""; } if (!isset($_GET['name'])) { $_GET['name'] = ""; } if (!isset($_POST['orderby'])) { $_POST['orderby'] = ""; } if (empty($arrCategory_id)) { $arrCategory_id = array("0"); } // タイトル編集 $tpl_subtitle = ""; if ($_GET['mode'] == 'search') { $tpl_subtitle = "検索結果"; } elseif (empty($arrCategory_id[0])) { $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(0); } // 商品一覧の表示処理 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_POST['orderby']); // 検索条件を画面に表示 // カテゴリー検索条件 if (strlen($_GET['category_id']) == 0) { $arrSearch['category'] = "指定なし"; } else { $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id); $arrSearch['category'] = $arrCat; } // 商品名検索条件 if ($_GET['name'] === "") { $arrSearch['name'] = "指定なし"; } else { $arrSearch['name'] = $_GET['name']; } } // レイアウトデザインを取得 $layout = new SC_Helper_PageLayout_Ex(); $layout->sfGetPageLayout($this, false, "products/list.php"); if (isset($_POST['mode']) && $_POST['mode'] == "cart" && $_POST['product_id'] != "") { // 値の正当性チェック if (!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } 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($this->getLocation(URL_CART_TOP)); exit; } } } $this->tpl_subtitle = $tpl_subtitle; // 支払方法の取得 $this->arrPayment = $this->lfGetPayment(); // 入力情報を渡す $this->arrForm = $_POST; $this->lfConvertParam(); $this->category_id = $arrCategory_id[0]; $this->arrSearch = $arrSearch; $objView->assignobj($this); $objView->display(SITE_FRAME); }
/** * 選択中の商品のカテゴリを取得する. * * @param integer $product_id プロダクトID * @param integer $category_id カテゴリID * @param bool $closed 非表示の商品を含む場合はtrue * @return array 選択中の商品のカテゴリIDの配列 * */ public function sfGetCategoryId($product_id, $category_id = 0, $closed = false) { if ($closed) { $status = ''; } else { $status = 'status = 1'; } $category_id = (int) $category_id; $product_id = (int) $product_id; $objCategory = new SC_Helper_Category_Ex(); if ($objCategory->isValidCategoryId($category_id, $closed)) { $category_id = array($category_id); } elseif (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $product_id, $status)) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id)); } else { // 不正な場合は、空の配列を返す。 $category_id = array(); } return $category_id; }
/** * このフォーム特有の複雑な入力チェックを行う. * * @param array 確認対象データ * @param array エラー配列 * @return array エラー配列 */ function lfCheckErrorDetail($item, $arrErr) { $objQuery =& SC_Query_Ex::getSingletonInstance(); /* // カテゴリIDの存在チェック if (!$this->lfIsDbRecord('dtb_category', 'category_id', $item)) { $arrErr['category_id'] = '※ 指定のカテゴリIDは、登録されていません。'; } */ // 親カテゴリIDの存在チェック if (array_search('parent_category_id', $this->arrFormKeyList) !== FALSE && $item['parent_category_id'] != '' && $item['parent_category_id'] != '0' && !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', array($item['parent_category_id']))) { $arrErr['parent_category_id'] = '※ 指定の親カテゴリID(' . $item['parent_category_id'] . ')は、存在しません。'; } // 削除フラグのチェック if (array_search('del_flg', $this->arrFormKeyList) !== FALSE && $item['del_flg'] != '') { if (!($item['del_flg'] == '0' or $item['del_flg'] == '1')) { $arrErr['del_flg'] = '※ 削除フラグは「0」(有効)、「1」(削除)のみが有効な値です。'; } } // 重複チェック 同じカテゴリ内に同名の存在は許可されない if (array_search('category_name', $this->arrFormKeyList) !== FALSE && $item['category_name'] != '') { $parent_category_id = $item['parent_category_id']; if ($parent_category_id == '') { $parent_category_id = (string) '0'; } $where = 'parent_category_id = ? AND category_id <> ? AND category_name = ?'; $exists = $objQuery->exists('dtb_category', $where, array($parent_category_id, $item['category_id'], $item['category_name'])); if ($exists) { $arrErr['category_name'] = '※ 既に同名のカテゴリが存在します。'; } } // 登録数上限チェック $where = 'del_flg = 0'; $count = $objQuery->count('dtb_category', $where); if ($count >= CATEGORY_MAX) { $item['category_name'] = '※ カテゴリの登録最大数を超えました。'; } // 階層上限チェック if (array_search('parent_category_id', $this->arrFormKeyList) !== FALSE and $item['parent_category_id'] != '') { $level = $objQuery->get('level', 'dtb_category', 'category_id = ?', array($parent_category_id)); if ($level >= LEVEL_MAX) { $arrErr['parent_category_id'] = '※ ' . LEVEL_MAX . '階層以上の登録はできません。'; } } return $arrErr; }
function lfCheckProductId($admin_mode, $product_id) { // 管理機能からの確認の場合は、非公開の商品も表示する。 if (isset($admin_mode) && $admin_mode == 'on') { SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex()); $status = true; $where = 'del_flg = 0'; } else { $status = false; $where = 'del_flg = 0 AND status = 1'; } if (!SC_Utils_Ex::sfIsInt($product_id) || SC_Utils_Ex::sfIsZeroFilling($product_id) || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array) $product_id, $where)) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } return $product_id; }
/** * 同じ内容の配送方法が存在するか確認. * * @param array $arrDeliv * @return boolean */ public function checkExist($arrDeliv) { $objDb = new SC_Helper_DB_Ex(); if ($arrDeliv['deliv_id'] == '') { $ret = $objDb->sfIsRecord('dtb_deliv', 'service_name', array($arrDeliv['service_name'])); } else { $objQuery =& SC_Query_Ex::getSingletonInstance(); $ret = $objQuery->count('dtb_deliv', 'deliv_id != ? AND service_name = ? AND del_flg = 0', array($arrDeliv['deliv_id'], $arrDeliv['service_name'])) > 0 ? true : false; } return $ret; }
/** * 有効な商品IDかチェックする. * * @param int $product_id * @param bool $include_hidden * @param bool $include_deleted * @return bool */ public function isValidProductId($product_id, $include_hidden = false, $include_deleted = false) { $where = ''; if (!$include_hidden) { $where .= 'status = 1'; } if (!$include_deleted) { if ($where != '') { $where .= ' AND '; } $where .= 'del_flg = 0'; } if (SC_Utils_Ex::sfIsInt($product_id) && !SC_Utils_Ex::sfIsZeroFilling($product_id) && SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', array($product_id), $where)) { return true; } return false; }
/** * 指定されたキーと値の有効性のDB確認 * * @param string $table テーブル名 * @param string $keyname キー名 * @param array $item 入力データ配列 * @return boolean true:有効なデータがある false:有効ではない */ public function lfIsDbRecord($table, $keyname, $item) { if (array_search($keyname, $this->arrFormKeyList) !== FALSE && $item[$keyname] != '' && !SC_Helper_DB_Ex::sfIsRecord($table, $keyname, (array) $item[$keyname])) { return false; } return true; }
/** * カテゴリ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 array $arrForm メーカー情報 * @return array $objErr->arrErr エラー内容 */ function lfCheckError(&$arrForm, &$objFormParam) { $arrErr = $objFormParam->checkError(); if (!empty($arrErr)) { return $arrErr; } // maker_id の正当性チェック if (!empty($arrForm['maker_id'])) { $objDb = new SC_Helper_DB_Ex(); if (!SC_Utils_Ex::sfIsInt($arrForm['maker_id']) || SC_Utils_Ex::sfIsZeroFilling($arrForm['maker_id']) || !$objDb->sfIsRecord('dtb_maker', 'maker_id', array($arrForm['maker_id']))) { // maker_idが指定されていて、且つその値が不正と思われる場合はエラー $arrErr['maker_id'] = t('c_* The manufacturer ID is inadequate<br />_01'); } } if (!isset($arrErr['name'])) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $arrMaker = array(); $arrMaker = $objQuery->select('maker_id, name', 'dtb_maker', 'del_flg = 0 AND name = ?', array($arrForm['name'])); // 編集中のレコード以外に同じ名称が存在する場合 if ($arrMaker[0]['maker_id'] != $arrForm['maker_id'] && $arrMaker[0]['name'] == $arrForm['name']) { $arrErr['name'] = t('c_* Registration of the same contents already exists.<br />_01'); } } return $arrErr; }
function lfCheckError(&$objFormParam) { // 入力データを渡す。 $arrRet = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($arrRet); $objErr->arrErr = $objFormParam->checkError(); if (!isset($objErr->arrErr['name'])) { // 既存チェック $objDb = new SC_Helper_DB_Ex(); if ($arrRet['deliv_id'] == '') { $ret = $objDb->sfIsRecord('dtb_deliv', 'service_name', array($arrRet['service_name'])); } else { $objQuery =& SC_Query_Ex::getSingletonInstance(); $ret = $objQuery->count('dtb_deliv', 'deliv_id != ? AND service_name = ? ', array($arrRet['deliv_id'], $arrRet['service_name'])) > 0 ? true : false; } if ($ret) { $objErr->arrErr['service_name'] = t('c_* It is not possible register a combination of the same name.<br>_01'); } } return $objErr->arrErr; }
/** * * @param SC_Product_Ex $objProduct * @param SC_FormParam_Ex $objFormParam * @return void */ public function doDefault(&$objProduct, &$objFormParam) { //商品一覧の表示処理 $strnavi = $this->objNavi->strnavi; // 表示文字列 $this->tpl_strnavi = empty($strnavi) ? ' ' : $strnavi; // 規格1クラス名 $this->tpl_class_name1 = $objProduct->className1; // 規格2クラス名 $this->tpl_class_name2 = $objProduct->className2; // 規格1 $this->arrClassCat1 = $objProduct->classCats1; // 規格1が設定されている $this->tpl_classcat_find1 = $objProduct->classCat1_find; // 規格2が設定されている $this->tpl_classcat_find2 = $objProduct->classCat2_find; $this->tpl_stock_find = $objProduct->stock_find; $this->tpl_product_class_id = $objProduct->product_class_id; $this->tpl_product_type = $objProduct->product_type; // 商品ステータスを取得 $this->productStatus = $this->arrProducts['productStatus']; unset($this->arrProducts['productStatus']); $this->tpl_javascript .= 'eccube.productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';'; if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_PC) { //onloadスクリプトを設定. 在庫ありの商品のみ出力する foreach ($this->arrProducts as $arrProduct) { if ($arrProduct['stock_unlimited_max'] || $arrProduct['stock_max'] > 0) { $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});"; } } } //カート処理 $target_product_id = intval($this->arrForm['product_id']); if ($target_product_id > 0) { // 商品IDの正当性チェック if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $this->arrForm['product_id'], 'del_flg = 0 AND status = 1')) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } // 入力内容のチェック $arrErr = $this->lfCheckError($objFormParam); if (empty($arrErr)) { $this->lfAddCart($this->arrForm); // 開いているカテゴリーツリーを維持するためのパラメーター $arrQueryString = array('category_id' => $this->arrForm['category_id']); SC_Response_Ex::sendRedirect(CART_URL, $arrQueryString); SC_Response_Ex::actionExit(); } $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id); } else { // カート「戻るボタン」用に保持 $netURL = new Net_URL(); //該当メソッドが無いため、$_SESSIONに直接セット $_SESSION['cart_referer_url'] = $netURL->getURL(); } $this->tpl_javascript .= 'function fnOnLoad() {' . $js_fnOnLoad . '}'; $this->tpl_onload .= 'fnOnLoad(); '; }
/** * 入力エラーチェック. * * @param array $arrForm メーカー情報 * @return array $objErr->arrErr エラー内容 */ function lfCheckError(&$arrForm, &$objFormParam) { $arrErr = $objFormParam->checkError(); if (!empty($arrErr)) { return $arrErr; } // maker_id の正当性チェック if (!empty($arrForm['maker_id'])) { $objDb = new SC_Helper_DB_Ex(); if (!SC_Utils_Ex::sfIsInt($arrForm['maker_id']) || SC_Utils_Ex::sfIsZeroFilling($arrForm['maker_id']) || !$objDb->sfIsRecord('dtb_maker', 'maker_id', array($arrForm['maker_id']))) { // maker_idが指定されていて、且つその値が不正と思われる場合はエラー $arrErr['maker_id'] = '※ メーカーIDが不正です<br />'; } } if (!isset($arrErr['name'])) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $arrMaker = array(); $arrMaker = $objQuery->select('maker_id, name', 'dtb_maker', 'del_flg = 0 AND name = ?', array($arrForm['name'])); // 編集中のレコード以外に同じ名称が存在する場合 if ($arrMaker[0]['maker_id'] != $arrForm['maker_id'] && $arrMaker[0]['name'] == $arrForm['name']) { $arrErr['name'] = '※ 既に同じ内容の登録が存在します。<br />'; } } return $arrErr; }
function lfCheckError(&$objFormParam) { // 入力データを渡す。 $arrRet = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($arrRet); $objErr->arrErr = $objFormParam->checkError(); if (!isset($objErr->arrErr['name'])) { // 既存チェック $objDb = new SC_Helper_DB_Ex(); if ($arrRet['deliv_id'] == '') { $ret = $objDb->sfIsRecord('dtb_deliv', 'service_name', array($arrRet['service_name'])); } else { $objQuery =& SC_Query_Ex::getSingletonInstance(); $ret = $objQuery->count('dtb_deliv', 'deliv_id != ? AND service_name = ? ', array($arrRet['deliv_id'], $arrRet['service_name'])) > 0 ? true : false; } if ($ret) { $objErr->arrErr['service_name'] = '※ 同じ名称の組み合わせは登録できません。<br>'; } } return $objErr->arrErr; }
/** * Page のプロセス(モバイル). * * FIXME 要リファクタリング * * @return void */ function mobileProcess() { $objView = new SC_MobileView(); $objCustomer = new SC_Customer(); $objQuery = new SC_Query(); $objDb = new SC_Helper_DB_Ex(); // パラメータ管理クラス $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($_POST['mode'])) { $_POST['mode'] = ""; } if (!empty($_POST['mode'])) { $tmp_id = $_POST['product_id']; } else { $tmp_id = $_GET['product_id']; } // 値の正当性チェック if (!SC_Utils_Ex::sfIsInt($tmp_id) || !$objDb->sfIsRecord("dtb_products", "product_id", $tmp_id, 'del_flg = 0 AND status = 1')) { 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->lfMakeSelectMobile($this, $tmp_id); // 商品IDをFORM内に保持する。 $this->tpl_product_id = $tmp_id; switch ($_POST['mode']) { case 'select': // 規格1が設定されている場合 if ($this->tpl_classcat_find1) { // templateの変更 $this->tpl_mainpage = "products/select_find1.tpl"; break; } case 'select2': $this->arrErr = $this->lfCheckError(); // 規格1が設定されている場合 if ($this->tpl_classcat_find1 and $this->arrErr['classcategory_id1']) { // templateの変更 $this->tpl_mainpage = "products/select_find1.tpl"; break; } // 規格2が設定されている場合 if ($this->tpl_classcat_find2) { $this->arrErr = array(); $this->tpl_mainpage = "products/select_find2.tpl"; break; } case 'selectItem': $this->arrErr = $this->lfCheckError(); // 規格1が設定されている場合 if ($this->tpl_classcat_find2 and $this->arrErr['classcategory_id2']) { // templateの変更 $this->tpl_mainpage = "products/select_find2.tpl"; break; } // 商品数の選択を行う $this->tpl_mainpage = "products/select_item.tpl"; break; 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']; // 規格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')); $this->sendRedirect($this->getLocation(MOBILE_URL_CART_TOP), true); exit; } break; default: break; } $objQuery = new SC_Query(); // DBから商品情報を取得する。 $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($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']; } // サブタイトルを取得 $arrFirstCat = $objDb->sfGetFirstCat($arrRet[0]['category_id']); $tpl_subtitle = $arrFirstCat['name']; $this->tpl_subtitle = $tpl_subtitle; // 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); // タイトルに商品名を入れる $this->tpl_title = "商品詳細 " . $this->arrProduct["name"]; //オススメ商品情報表示 $this->arrRecommend = $this->lfPreGetRecommendProducts($tmp_id); //この商品を買った人はこんな商品も買っています $this->arrRelateProducts = $this->lfGetRelateProducts($tmp_id); $objView->assignobj($this); $objView->display(SITE_FRAME); }
function lfRegistFavoriteProduct($favorite_product_id, $customer_id) { // ログイン中のユーザが商品をお気に入りにいれる処理 if (!SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $favorite_product_id, 'del_flg = 0 AND status = 1')) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); return false; } else { $objQuery =& SC_Query_Ex::getSingletonInstance(); $exists = $objQuery->exists('dtb_customer_favorite_products', 'customer_id = ? AND product_id = ?', array($customer_id, $favorite_product_id)); if (!$exists) { $sqlval['customer_id'] = $customer_id; $sqlval['product_id'] = $favorite_product_id; $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; $objQuery->begin(); $objQuery->insert('dtb_customer_favorite_products', $sqlval); $objQuery->commit(); } // お気に入りに登録したことを示すフラグ $this->just_added_favorite = true; return true; } }
/** * 有効なカテゴリーIDかチェックする. * * @param int $category_id * @param bool $include_deleted * @return bool */ public function isValidCategoryId($category_id, $include_deleted = false) { if ($include_deleted) { $where = ''; } else { $where = 'del_flg = 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), $where)) { return true; } return false; }
/** * 入力エラーチェック. * * @param array $arrForm メーカー情報 * @return array $objErr->arrErr エラー内容 */ function lfErrorCheck(&$arrForm) { $objErr = new SC_CheckError_Ex($arrForm); $objErr->doFunc(array("メーカー名", 'name', SMTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); // maker_id の正当性チェック if (!empty($arrForm['maker_id'])) { $objDb = new SC_Helper_DB_Ex(); if (!SC_Utils_Ex::sfIsInt($arrForm['maker_id']) || SC_Utils_Ex::sfIsZeroFilling($arrForm['maker_id']) || !$objDb->sfIsRecord('dtb_maker', 'maker_id', array($arrForm['maker_id']))) { // maker_idが指定されていて、且つその値が不正と思われる場合はエラー $objErr->arrErr['maker_id'] = "※ メーカーIDが不正です<br />"; } } if (!isset($objErr->arrErr['name'])) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $arrMaker = array(); $arrMaker = $objQuery->select("maker_id, name", "dtb_maker", "del_flg = 0 AND name = ?", array($arrForm['name'])); // 編集中のレコード以外に同じ名称が存在する場合 if ($arrMaker[0]['maker_id'] != $arrForm['maker_id'] && $arrMaker[0]['name'] == $arrForm['name']) { $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br />"; } } return $objErr->arrErr; }
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; }