/** * CSV 項目を出力する. * * @param integer $csv_id CSV ID * @param string $where SQL の WHERE 句 * @param array $arrVal WHERE 句の要素 * @return array CSV 項目の配列 */ function sfgetCsvOutput($csv_id = "", $where = "", $arrVal = array()) { $objQuery = new SC_Query(); $arrData = array(); $ret = array(); $sql = ""; $sql .= " SELECT "; $sql .= " no, "; $sql .= " csv_id, "; $sql .= " col, "; $sql .= " disp_name, "; $sql .= " rank, "; $sql .= " status, "; $sql .= " create_date, "; $sql .= " update_date "; $sql .= " FROM "; $sql .= " dtb_csv "; if ($where != "") { $sql .= $where; $arrData = $arrVal; } elseif ($csv_id != "") { $sql .= " WHERE csv_id = ? "; $arrData = array($csv_id); } $sql .= " ORDER BY "; $sql .= " rank , no"; $sql .= " "; $ret = $objQuery->getall($sql, $arrData); return $ret; }
function lfGetClassCatListDisp($class_id1, $class_id2, $default = true) { $objQuery = new SC_Query(); if ($class_id2 != "") { // 規格1と規格2 $sql = "SELECT * "; $sql .= "FROM vw_cross_class AS crs_cls "; $sql .= "WHERE class_id1 = ? AND class_id2 = ? ORDER BY rank1 DESC, rank2 DESC;"; $arrRet = $objQuery->getall($sql, array($class_id1, $class_id2)); } else { // 規格1のみ $sql = "SELECT * "; $sql .= "FROM vw_cross_class AS crs_cls "; $sql .= "WHERE class_id1 = ? AND class_id2 = 0 ORDER BY rank1 DESC;"; $arrRet = $objQuery->getall($sql, array($class_id1)); } $max = count($arrRet); if ($default) { // デフォルト値を設定 $this->lfSetDefaultClassCat($objQuery, $_POST['product_id'], $max); } $this->arrForm["class_id1"] = $arrRet[0]['class_id1']; $this->arrForm["class_id2"] = $arrRet[0]['class_id2']; $this->tpl_onload .= "fnCheckAllStockLimit('{$max}', '" . DISABLED_RGB . "');"; return $arrRet; }
function lfBatOrderAgeSub($sql, $start, $end, $start_age, $end_age, $member) { $objQuery = new SC_Query(); $arrRet = $objQuery->getall($sql, array($start, $end)); $sqlval = $arrRet[0]; // 空文字を"0"に変換 foreach ($sqlval as $key => $val) { if ($val == "") { $sqlval[$key] = "0"; } } $sqlval['create_date'] = "now()"; $sqlval['order_date'] = $start; $sqlval['start_age'] = "{$start_age}"; $sqlval['end_age'] = "{$end_age}"; $sqlval['member'] = "{$member}"; $objQuery->insert("dtb_bat_order_daily_age", $sqlval); }
/** 年代別集計 **/ function lfGetOrderAge($type, $sdate, $edate, &$objPage, $graph = true) { list($where, $arrval) = $this->lfGetWhereMember('order_date', $sdate, $edate, $type, "member"); $sql = "SELECT SUM(order_count) AS order_count, SUM(total) AS total, start_age, end_age "; $sql .= "FROM dtb_bat_order_daily_age WHERE {$where} "; $sql .= "GROUP BY start_age, end_age ORDER BY start_age, end_age"; $objQuery = new SC_Query(); $objPage->arrResults = $objQuery->getall($sql, $arrval); $max = count($objPage->arrResults); for ($i = 0; $i < $max; $i++) { if ($objPage->arrResults[$i]['order_count'] > 0) { $objPage->arrResults[$i]['total_average'] = intval($objPage->arrResults[$i]['total'] / $objPage->arrResults[$i]['order_count']); } $start_age = $objPage->arrResults[$i]['start_age']; $end_age = $objPage->arrResults[$i]['end_age']; if ($start_age != "" || $end_age != "") { if ($end_age != 999) { $objPage->arrResults[$i]['age_name'] = $start_age . "〜" . $end_age . "歳"; } else { $objPage->arrResults[$i]['age_name'] = $start_age . "歳〜"; } } else { $objPage->arrResults[$i]['age_name'] = "未回答"; } } // 棒グラフの生成 if ($graph) { $image_key = "age_" . $type; $xtitle = "(年齢)"; $ytitle = "(売上合計)"; $objPage->tpl_image = $this->lfGetGraphBar($objPage->arrResults, "age_name", $image_key, $xtitle, $ytitle, $sdate, $edate); } }
/** * テンプレート変更時に既に存在するキャンペーンのテンプレートがない場合はテンプレートを生成する * */ function lfCopyTemplate($template_code) { //すべてのキャンペーンのテンプレートファイルを確認 $objQuery = new SC_Query(); $sql = "SELECT directory_name,cart_flg FROM dtb_campaign WHERE del_flg = 0"; $result = $objQuery->getall($sql); //デザインテンプレートディレクトリにファイルが存在するか確認 foreach ($result as $key => $val) { //index.phpが存在すればキャンペーンのテンプレートがあると判定 //全部チェックした方がいいか? $campaign_template_file_path = SMARTY_TEMPLATES_DIR . $template_code . "/" . CAMPAIGN_TEMPLATE_DIR . $val['directory_name'] . "/" . CAMPAIGN_TEMPLATE_ACTIVE . "site_frame.tpl"; if (!file_exists($campaign_template_file_path)) { //ファイルがなければコピーして作成 $this->lfCreateTemplate(SMARTY_TEMPLATES_DIR . $template_code . "/" . CAMPAIGN_TEMPLATE_DIR, $val['directory_name'], $val['cart_flg']); } } }
/** * 商品情報を取得する(vw_products_allclass使用) * * @param SC_Query $objQuery DB操作クラス * @return array $arrProduct 取得結果を配列で返す */ function lfGetProductsAllclass($objQuery) { $sql = ""; $sql .= "SELECT\n product_id\n ,name as product_name\n ,category_id\n ,point_rate\n ,comment3\n ,main_list_comment\n ,main_image\n ,main_list_image\n ,product_code_min\n ,product_code_max\n ,price01_min\n ,price01_max\n ,price02_min\n ,price02_max\n ,(SELECT category_name FROM dtb_category AS cat WHERE cat.category_id = allcls.category_id) AS category_name\n ,(SELECT main_large_image FROM dtb_products AS prod WHERE prod.product_id = allcls.product_id) AS main_large_image\n FROM vw_products_allclass as allcls\n WHERE allcls.del_flg = 0 AND allcls.status = 1"; $sql .= " ORDER BY allcls.product_id"; $arrProduct = $objQuery->getall($sql); return $arrProduct; }
/** * 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 lfGetBkupData($where = "", $data = array()) { $objQuery = new SC_Query(); $sql = "SELECT bkup_name, bkup_memo, create_date FROM dtb_bkup "; if ($where != "") { $sql .= $where; } $ret = $objQuery->getall($sql, $data); return $ret; }
/** * 検索結果から顧客IDを指定された場合、顧客情報をフォームに代入する * @param int $edit_customer_id 顧客ID */ function lfSetCustomerInfo($edit_customer_id = "") { // 顧客IDが指定されている場合のみ、処理を実行する if ($edit_customer_id === "") { return; } // 検索で選択された顧客IDが入力されている場合 if (is_null($edit_customer_id) === false && 0 < strlen($edit_customer_id) && SC_Utils_Ex::sfIsInt($edit_customer_id)) { $objQuery = new SC_Query(); // 顧客情報を取得する $arrCustomerInfo = $objQuery->select('*', 'dtb_customer', 'customer_id = ? AND del_flg = 0', array($edit_customer_id)); // 顧客情報を取得する事が出来たら、テンプレートに値を渡す if (0 < count($arrCustomerInfo) && is_array($arrCustomerInfo) === true) { // カラム名にorder_を付ける(テンプレート側でorder_がついている為 foreach ($arrCustomerInfo[0] as $index => $customer_info) { // customer_idにはorder_を付けないようにする $order_index = $index == 'customer_id' ? $index : 'order_' . $index; $arrCustomer[$order_index] = $customer_info; } } // hiddenに渡す $this->edit_customer_id = $edit_customer_id; // 受注日に現在の時刻を取得し、表示させる $create_date = $objQuery->getall('SELECT now() as create_date;'); $arrCustomer['create_date'] = $create_date[0]['create_date']; // 情報上書き $this->objFormParam->setParam($arrCustomer); // 入力値の変換 $this->objFormParam->convParam(); } }
$objQuery = new SC_Query(); // 前のページで正しく登録手続きが行われた記録があるか判定 SC_Utils::sfIsPrePage($objSiteSess); // SPSモジュール連携用 if (file_exists(MODULE_PATH . 'mdl_sps/inc/include.php') && !$objCartSess->getTotalQuantity()) { require_once MODULE_PATH . 'mdl_sps/inc/include.php'; header("Location: " . ERROR_URL); exit; } // アクセスの正当性の判定 $uniqid = SC_Utils::sfCheckNormalAccess($objSiteSess, $objCartSess); $payment_id = $_SESSION["payment_id"]; // 支払いIDが無い場合にはエラー if ($payment_id == "") { SC_Utils::sfDispSiteError(PAGE_ERROR, "", true); } // 決済情報を取得する $objDB = new SC_Helper_DB_Ex(); if ($objDB->sfColumnExists("dtb_payment", "memo01")) { $sql = "SELECT module_path, memo01, memo02, memo03, memo04, memo05, memo06, memo07, memo08, memo09, memo10 FROM dtb_payment WHERE payment_id = ?"; $arrPayment = $objQuery->getall($sql, array($payment_id)); } if (count($arrPayment) > 0) { $path = $arrPayment[0]['module_path']; if (file_exists($path)) { require_once $path; exit; } else { SC_Utils::sfDispSiteError(FREE_ERROR_MSG, "", true, "モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。"); } }
function sfGetClassCatCount() { $sql = "select count(dtb_class.class_id) as count, dtb_class.class_id "; $sql .= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id "; $sql .= "where dtb_class.del_flg = 0 AND dtb_classcategory.del_flg = 0 "; $sql .= "group by dtb_class.class_id, dtb_class.name"; $objQuery = new SC_Query(); $arrList = $objQuery->getall($sql); // キーと値をセットした配列を取得 $arrRet = SC_Utils::sfArrKeyValue($arrList, 'class_id', 'count'); return $arrRet; }
/** * 登録済みSQL一覧を取得する. * * @param string $where Where句 * @param array $arrData 絞り込みデータ * @return array 取得結果の配列 */ function lfGetSqlList($where = "", $arrData = array()) { $objQuery = new SC_Query(); $arrRet = array(); // 結果取得用 $sql = ""; $sql .= " SELECT"; $sql .= " sql_id,"; $sql .= " sql_name,"; $sql .= " csv_sql,"; $sql .= " update_date,"; $sql .= " create_date"; $sql .= " FROM"; $sql .= " dtb_csv_sql"; // Where句の指定があれば結合する if ($where != "") { $sql .= " {$where} "; } else { $sql .= " ORDER BY sql_id "; } $sql .= " "; // データを引数で渡されている場合にはセットする if (count($arrData) > 0) { $arrRet = $objQuery->getall($sql, $arrData); } else { $arrRet = $objQuery->getall($sql); } return $arrRet; }
/** * Page のプロセス(モバイル). * * @return void */ function mobileProcess() { $objView = new SC_MobileView(); $objCartSess = new SC_CartSession(); $objSiteInfo = $objView->objSiteInfo; $objSiteSess = new SC_SiteSession(); $objCustomer = new SC_Customer(); $arrInfo = $objSiteInfo->data; $objQuery = new SC_Query(); $objDb = new SC_Helper_DB_Ex(); // 前のページで正しく登録手続きが行われた記録があるか判定 SC_Utils_Ex::sfIsPrePage($objSiteSess, true); // ユーザユニークIDの取得と購入状態の正当性をチェック $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess); $this->tpl_uniqid = $uniqid; // カート集計処理 $objDb->sfTotalCart($this, $objCartSess, $arrInfo); // 一時受注テーブルの読込 $arrData = $objDb->sfGetOrderTemp($uniqid); // カート集計を元に最終計算 $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, $arrInfo, $objCustomer); // カート内の商品の売り切れチェック $objCartSess->chkSoldOut($objCartSess->getCartList()); // 会員ログインチェック if ($objCustomer->isLoginSuccess(true)) { $this->tpl_login = '******'; $this->tpl_user_point = $objCustomer->getValue('point'); } // 決済区分を取得する $payment_type = ""; if ($objDb->sfColumnExists("dtb_payment", "memo01")) { // MEMO03に値が入っている場合には、モジュール追加されたものとみなす $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?"; $arrPayment = $objQuery->getall($sql, array($arrData['payment_id'])); $payment_type = $arrPayment[0]["memo03"]; } $this->payment_type = $payment_type; if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } switch ($_POST['mode']) { // 前のページに戻る case 'return': // 正常な推移であることを記録しておく $objSiteSess->setRegistFlag(); $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_PAYMENT), true); exit; break; case 'confirm': // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため) // postgresqlとmysqlとで処理を分ける if (DB_TYPE == "pgsql") { $order_id = $objQuery->nextval("dtb_order", "order_id"); } elseif (DB_TYPE == "mysql") { $order_id = $objQuery->get_auto_increment("dtb_order"); } $arrData["order_id"] = $order_id; // セッション情報を保持 $arrData['session'] = serialize($_SESSION); // 集計結果を受注一時テーブルに反映 $objDb->sfRegistTempOrder($uniqid, $arrData); // 正常に登録されたことを記録しておく $objSiteSess->setRegistFlag(); // 決済方法により画面切替 if ($payment_type != "") { $_SESSION["payment_id"] = $arrData['payment_id']; $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_MODULE), true); } else { $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_COMPLETE), true); } exit; break; default: break; } $this->arrData = $arrData; $this->arrInfo = $arrInfo; $objView->assignobj($this); $objView->display(SITE_FRAME); }
function lfGetControlList() { $objQuery = new SC_Query(); // サイト管理情報の取得 $sql = "SELECT * FROM dtb_site_control "; $sql .= "WHERE del_flg = 0"; $arrRet = $objQuery->getall($sql); return $arrRet; }