7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2012 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: admin_lotbuyingWidgetContainer.php 5437 2012-12-07 13:14:59Z fishbone $
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getContainerPath() . '/baseIWidgetContainer.php');
17 require_once($gEnvManager->getCurrentIWidgetDbPath() . '/lotbuyingDb.php');
19 class admin_lotbuyingWidgetContainer extends BaseIWidgetContainer
21 private $db; // DB接続オブジェクト
22 private $productClass; // 商品クラス
23 private $productType; // 商品タイプ
28 function __construct()
31 parent::__construct();
34 $this->db = new lotbuyingDb();
39 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
40 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
42 * @param RequestManager $request HTTPリクエスト処理クラス
43 * @param string $act 実行処理
44 * @param object $configObj 定義情報オブジェクト
45 * @param object $optionObj 可変パラメータオブジェクト
46 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
48 function _setTemplate($request, $act, $configObj, $optionObj)
50 return 'admin.tmpl.html';
55 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
57 * @param RequestManager $request HTTPリクエスト処理クラス
58 * @param string $act 実行処理
59 * @param object $configObj 定義情報オブジェクト
60 * @param object $optionObj 可変パラメータオブジェクト
63 function _assign($request, $act, $configObj, $optionObj)
65 $langId = $this->gEnv->getCurrentLanguage(); // 表示言語を取得
68 $id = $optionObj->id; // ユニークなID(配送方法ID)
69 $init = $optionObj->init; // データ初期化を行うかどうか
72 $this->productClass = $request->trimValueOf('iw_product_class'); // 商品クラス
73 $this->productType = $request->trimValueOf('iw_product_type'); // 商品タイプ
74 $count = $request->trimValueOf('iw_count'); // 単位数
75 $discountRate = $request->trimValueOf('iw_discount_rate'); // 割引率
77 if ($act == 'update'){ // 設定更新のとき
79 $this->checkNumeric($count, '個数');
80 $this->checkNumeric($discountRate, '割引率');
82 if ($this->getMsgCount() == 0){ // エラーのないとき
83 $configObj->productClass = $this->productClass; // 商品クラス
84 $configObj->productType = $this->productType; // 商品タイプ
85 $configObj->count = $count; // 単位数
86 $configObj->discountRate = $discountRate; // 割引率
87 $ret = $this->updateConfigObj($configObj);
88 if (!$ret) $this->setMsg(self::MSG_APP_ERR, 'インナーウィジェットデータの更新に失敗しました');
89 // ***** 正常に終了した場合はメッセージを残さない *****
91 } else if ($act == 'content'){ // 画面表示のとき
92 if (!empty($init)){ // 初期表示のとき
93 if (empty($configObj)){ // 定義値がないとき(管理画面なので最初は定義値が存在しない)
94 $this->productClass = '-'; // 商品クラス(選択なし)
95 $this->productType = '-'; // 商品タイプ(選択なし)
97 $discountRate = 10; // 割引率
99 $this->productClass = $configObj->productClass; // 商品クラス
100 $this->productType = $configObj->productType; // 商品タイプ
101 $count = $configObj->count; // 単位数
102 $discountRate = $configObj->discountRate; // 割引率
107 $this->tmpl->addVar("_widget", "count", $count);
108 $this->tmpl->addVar('_widget', 'discount_rate', $discountRate);
112 $this->db->getAllProductClass($langId, array($this, 'productClassLoop'));
115 $this->db->getAllProductType($this->productClass, $langId, array($this, 'productTypeLoop'));
120 * @param int $index 行番号(0~)
121 * @param array $fetchedRow フェッチ取得した行
122 * @param object $param 未使用
123 * @return bool true=処理続行の場合、false=処理終了の場合
125 function productClassLoop($index, $fetchedRow, $param)
127 $id = $fetchedRow['pu_id'];
129 if ($id == $this->productClass) $selected = 'selected'; // 選択中の商品クラス
132 'value' => $this->convertToDispString($id), // ID
133 'name' => $this->convertToDispString($fetchedRow['pu_name']), // 表示名
134 'selected' => $selected // 選択中かどうか
136 $this->tmpl->addVars('product_class_list', $row);
137 $this->tmpl->parseTemplate('product_class_list', 'a');
143 * @param int $index 行番号(0~)
144 * @param array $fetchedRow フェッチ取得した行
145 * @param object $param 未使用
146 * @return bool true=処理続行の場合、false=処理終了の場合
148 function productTypeLoop($index, $fetchedRow, $param)
150 $id = $fetchedRow['py_id'];
152 if ($id == $this->productType) $selected = 'selected'; // 選択中の商品タイプ
155 'value' => $this->convertToDispString($id), // ID
156 'name' => $this->convertToDispString($fetchedRow['py_name']), // 表示名
157 'selected' => $selected // 選択中かどうか
159 $this->tmpl->addVars('product_type_list', $row);
160 $this->tmpl->parseTemplate('product_type_list', 'a');