バージョン選択

フォーラム

メニュー

オンライン状況

53 人のユーザが現在オンラインです。 (44 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 53
もっと...

サイト内検索

質問 > 管理機能 > 商品マスターページで備考を記入、保存ができるようにしたい

管理機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
by0448
投稿日時: 2013/9/4 20:32
対応状況: −−−
長老
登録日: 2011/9/12
居住地: 横浜市
投稿: 186
Re: 商品マスターページで備考を記入、保存ができるようにしたい
bratech 様

ご返答ありがとうございます。

確かに、商品の一番最後のテキストエリアの中身が引っ張られていました。

そこで、以下のように変更しましたところ、今度は先頭のテキストエリア内の情報しか引っ張ってくれなくなりました。



<form name="form2" id="form2" method="post" action="?">
<div class="under_comment">
<textarea name="note" cols="18" rows="7" maxlength="99999" style=""><!--{$arrProducts[cnt].note}--></textarea>
<p class="buttun"><a href="<!--{$smarty.const.ROOT_URLPATH}-->" onclick="fnModeSubmit('upnote', 'product_id', <!--{$arrProducts[cnt].product_id}-->); return true;"><input type="submit" value=" 保存 "></a></p>
</form>



もう一歩というところまで来ております。
また手を尽くしてみようかと思います。

sumida
投稿日時: 2013/9/4 22:00
対応状況: −−−
仙人
登録日: 2013/2/10
居住地: 広島県呉市ときどき瀬戸内海
投稿: 641
Re: 商品マスターページで備考を記入、保存ができるようにしたい
name部分に対し、product_idをキーとした配列を使う手段もありかと思いますが、
(product_idが'1'であれば、'note[1]'というように)
その場合、入力文字に対するエラーチェックがされない。

$objFormParam->addParam("備考欄(SHOP専用)", 'note', LLTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));

これが、無視されるんじゃないかと思います。

できれば、一覧画面ではなく編集画面経由の方が良いのでは。
by0448
投稿日時: 2013/9/4 22:16
対応状況: −−−
長老
登録日: 2011/9/12
居住地: 横浜市
投稿: 186
Re: 商品マスターページで備考を記入、保存ができるようにしたい
sumida 様

ご返答ありがとうございます。

まったく行き詰ってしまいました。

色々組み合わせを替えておりますが、結局のところ見よう見まねなので悪い原因がどこにあるのかわかっておりません。

引用:

sumidaさんは書きました:
name部分に対し、product_idをキーとした配列を使う手段もありかと思いますが、
(product_idが'1'であれば、'note[1]'というように)
その場合、入力文字に対するエラーチェックがされない。


簡単な一言コメントですので、入力エラーチェックはあまり必要としておりませんでした。


引用:


$objFormParam->addParam("備考欄(SHOP専用)", 'note', LLTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));

これが、無視されるんじゃないかと思います。

できれば、一覧画面ではなく編集画面経由の方が良いのでは。



確かにこの一行は必要ないのだと思いました。
ただ、一覧画面からの入力というものをどうしても設置したいと考えております。
そのせいで行き詰っているわけですが。


他人任せで本当に申し訳ありませんが、良い方法がありましたら、ご教授お願いいたします。

yuh
投稿日時: 2013/9/5 12:17
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1819
Re: 商品マスターページで備考を記入、保存ができるようにしたい
index.tplに
<textarea name="note[<!--{$arrProducts[cnt].product_id}-->]" cols="50" rows="7" maxlength="99999" style=""><!--{$arrProducts[cnt].note}--></textarea>
<a href="<!--{$smarty.const.ROOT_URLPATH}-->" onclick="fnModeSubmit('upnote', 'product_id', <!--{$arrProducts[cnt].product_id}-->); return false;">UP</a>

を追加で、
LC_Page_Admin_Products_Ex.phpに

    function lfInitParam(&$objFormParam) {
		parent::lfInitParam($objFormParam);
		$objFormParam->addParam("備考欄(SHOP専用)", 'note', LLTEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
    }
    function doNote($where, $objFormParam) {
		$objQuery =& SC_Query_Ex::getSingletonInstance();
		$note = $objFormParam->getValue('note');;
		$sqlval['note']     = $note[$objFormParam->getValue('product_id')];
		$sqlval['update_date'] = 'now()';
		$arrParam = array($objFormParam->getValue('product_id'));
		$objQuery->update('dtb_products', $sqlval, $where, $arrParam);
    }
    function action() {

        $objDb = new SC_Helper_DB_Ex();
        $objFormParam = new SC_FormParam_Ex();
        $objProduct = new SC_Product_Ex();
        $objQuery =& SC_Query_Ex::getSingletonInstance();

        // パラメーター情報の初期化
        $this->lfInitParam($objFormParam);
        $objFormParam->setParam($_POST);
        $this->arrHidden = $objFormParam->getSearchArray();
        $this->arrForm = $objFormParam->getFormParamList();

        switch ($this->getMode()) {
		        case 'upnote':
			  $this->doNote("product_id = ?", $objFormParam);
		          $this->tpl_onload = "window.alert('編集が完了しました');";
			break;
            case 'delete':
                // 商品、子テーブル(商品規格)、会員お気に入り商品の削除
                $this->doDelete('product_id = ?', array($objFormParam->getValue('product_id')));
                // 件数カウントバッチ実行
                $objDb->sfCountCategory($objQuery);
                $objDb->sfCountMaker($objQuery);
                // 削除後に検索結果を表示するため breakしない

            // 検索パラメーター生成後に処理実行するため breakしない
            case 'csv':
            case 'delete_all':

            case 'search':
                $objFormParam->convParam();
                $objFormParam->trimParam();
                $this->arrErr = $this->lfCheckError($objFormParam);
                $arrParam = $objFormParam->getHashArray();

                if (count($this->arrErr) == 0) {
                    $where = 'del_flg = 0';
                    $arrWhereVal = array();
                    foreach ($arrParam as $key => $val) {
                        if ($val == '') {
                            continue;
                        }
                        $this->buildQuery($key, $where, $arrWhereVal, $objFormParam, $objDb);
                    }

                    $order = 'update_date DESC';

                    /* -----------------------------------------------
                     * 処理を実行
                     * ----------------------------------------------- */
                    switch ($this->getMode()) {
                        // CSVを送信する。
                        case 'csv':
                            $objCSV = new SC_Helper_CSV_Ex();
                            // CSVを送信する。正常終了の場合、終了。
                            $objCSV->sfDownloadCsv(1, $where, $arrWhereVal, $order, true);
                            SC_Response_Ex::actionExit();

                        // 全件削除(ADMIN_MODE)
                        case 'delete_all':
                            $this->doDelete($where, $arrWhereVal);
                            break;

                        // 検索実行
                        default:
                            // 行数の取得
                            $this->tpl_linemax = $this->getNumberOfLines($where, $arrWhereVal);
                            // ページ送りの処理
                            $page_max = SC_Utils_Ex::sfGetSearchPageMax($objFormParam->getValue('search_page_max'));
                            // ページ送りの取得
                            $objNavi = new SC_PageNavi_Ex($this->arrHidden['search_pageno'],
                                                          $this->tpl_linemax, $page_max,
                                                          'fnNaviSearchPage', NAVI_PMAX);
                            $this->arrPagenavi = $objNavi->arrPagenavi;

                            // 検索結果の取得
                            $this->arrProducts = $this->findProducts($where, $arrWhereVal, $page_max, $objNavi->start_row,
                                                                     $order, $objProduct);

                            // 各商品ごとのカテゴリIDを取得
                            if (count($this->arrProducts) > 0) {
                                foreach ($this->arrProducts as $key => $val) {
                                    $this->arrProducts[$key]['categories'] = $objDb->sfGetCategoryId($val['product_id'], 0, true);
                                    $objDb->g_category_on = false;
                                }
                            }
                    }
                }
                break;
        }

        // カテゴリの読込
        list($this->arrCatKey, $this->arrCatVal) = $objDb->sfGetLevelCatList(false);
        $this->arrCatList = $this->lfGetIDName($this->arrCatKey, $this->arrCatVal);

    }
    function findProducts($where, $arrValues, $limit, $offset, $order, &$objProduct) {
        $objQuery =& SC_Query_Ex::getSingletonInstance();

        // 読み込む列とテーブルの指定
        $col = 'product_id, note,name, main_list_image, status, product_code_min, product_code_max, price02_min, price02_max, stock_min, stock_max, stock_unlimited_min, stock_unlimited_max, update_date';
        $from = $objProduct->alldtlSQL();

        $objQuery->setLimitOffset($limit, $offset);
        $objQuery->setOrder($order);

        return $objQuery->select($col, $from, $where, $arrValues);
    }

を追加でできると思います。
エラーチェックは入れてないので、適当に追加してください。

原因はnoteが複数作成される事で上書きされ、空になる事と
noteのデータが読み出されない事が原因です
by0448
投稿日時: 2013/9/6 11:15
対応状況: 解決済
長老
登録日: 2011/9/12
居住地: 横浜市
投稿: 186
Re: 商品マスターページで備考を記入、保存ができるようにしたい
yuh 様

ご返答ありがとうございました。

見事に頂いたコードで思い通りの結果が得られました。
本当にありがとうございます。


note[<!--{$arrProducts[cnt].product_id}-->]

というやり方にはまったく想像が及びませんでした。

改めて勉強になりました。


この度は色々な方々にご協力頂き、ありがとうございました。
皆様に感謝いたします。

« 1 (2)
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は89,085名です
総投稿数は110,033件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2314
5
umebius
2085
6
yuh
1819
7
h_tanaka
1649
8
red
1570
9
mcontact
1297
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.