1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/products/LC_Page_Admin_Products_Ex.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * 商品登録 のページクラス |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_Products_Product extends LC_Page_Admin_Products_Ex |
---|
35 | { |
---|
36 | |
---|
37 | // }}} |
---|
38 | // {{{ functions |
---|
39 | |
---|
40 | /** |
---|
41 | * Page を初期化する. |
---|
42 | * |
---|
43 | * @return void |
---|
44 | */ |
---|
45 | function init() |
---|
46 | { |
---|
47 | parent::init(); |
---|
48 | $this->tpl_mainpage = 'products/product.tpl'; |
---|
49 | $this->tpl_mainno = 'products'; |
---|
50 | $this->tpl_subno = 'product'; |
---|
51 | $this->tpl_maintitle = '商品管理'; |
---|
52 | $this->tpl_subtitle = '商品登録'; |
---|
53 | |
---|
54 | $masterData = new SC_DB_MasterData_Ex(); |
---|
55 | $this->arrProductType = $masterData->getMasterData('mtb_product_type'); |
---|
56 | $this->arrDISP = $masterData->getMasterData('mtb_disp'); |
---|
57 | $this->arrSTATUS = $masterData->getMasterData('mtb_status'); |
---|
58 | $this->arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image'); |
---|
59 | $this->arrDELIVERYDATE = $masterData->getMasterData('mtb_delivery_date'); |
---|
60 | $this->arrMaker = SC_Helper_Maker_Ex::getIDValueList(); |
---|
61 | $this->arrAllowedTag = $masterData->getMasterData('mtb_allowed_tag'); |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * Page のプロセス. |
---|
66 | * |
---|
67 | * @return void |
---|
68 | */ |
---|
69 | function process() |
---|
70 | { |
---|
71 | $this->action(); |
---|
72 | $this->sendResponse(); |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Page のアクション. |
---|
77 | * |
---|
78 | * @return void |
---|
79 | */ |
---|
80 | function action() |
---|
81 | { |
---|
82 | |
---|
83 | $objFormParam = new SC_FormParam_Ex(); |
---|
84 | |
---|
85 | // アップロードファイル情報の初期化 |
---|
86 | $objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); |
---|
87 | $this->lfInitFile($objUpFile); |
---|
88 | $objUpFile->setHiddenFileList($_POST); |
---|
89 | |
---|
90 | // ダウンロード販売ファイル情報の初期化 |
---|
91 | $objDownFile = new SC_UploadFile_Ex(DOWN_TEMP_REALDIR, DOWN_SAVE_REALDIR); |
---|
92 | $this->lfInitDownFile($objDownFile); |
---|
93 | $objDownFile->setHiddenFileList($_POST); |
---|
94 | |
---|
95 | // 検索パラメーター引き継ぎ |
---|
96 | $this->arrSearchHidden = $this->lfGetSearchParam($_POST); |
---|
97 | |
---|
98 | $mode = $this->getMode(); |
---|
99 | switch ($mode) { |
---|
100 | case 'pre_edit': |
---|
101 | case 'copy' : |
---|
102 | // パラメーター初期化(商品ID) |
---|
103 | $this->lfInitFormParam_PreEdit($objFormParam, $_POST); |
---|
104 | // エラーチェック |
---|
105 | $this->arrErr = $objFormParam->checkError(); |
---|
106 | if (count($this->arrErr) > 0) { |
---|
107 | trigger_error('', E_USER_ERROR); |
---|
108 | } |
---|
109 | |
---|
110 | // 商品ID取得 |
---|
111 | $product_id = $objFormParam->getValue('product_id'); |
---|
112 | // 商品データ取得 |
---|
113 | $arrForm = $this->lfGetFormParam_PreEdit($objUpFile, $objDownFile, $product_id); |
---|
114 | |
---|
115 | // 複製の場合は、ダウンロード商品情報部分はコピーしない |
---|
116 | if ($mode == 'copy') { |
---|
117 | // ダウンロード商品ファイル名をunset |
---|
118 | $arrForm['down_filename'] = ''; |
---|
119 | |
---|
120 | // $objDownFile->setDBDownFile()でsetされたダウンロードファイル名をunset |
---|
121 | unset($objDownFile->save_file[0]); |
---|
122 | } |
---|
123 | |
---|
124 | // ページ表示用パラメーター設定 |
---|
125 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
126 | |
---|
127 | // 商品複製の場合、画像ファイルコピー |
---|
128 | if ($mode == 'copy') { |
---|
129 | $this->arrForm['copy_product_id'] = $this->arrForm['product_id']; |
---|
130 | $this->arrForm['product_id'] = ''; |
---|
131 | // 画像ファイルのコピー |
---|
132 | $this->lfCopyProductImageFiles($objUpFile); |
---|
133 | } |
---|
134 | |
---|
135 | // ページonload時のJavaScript設定 |
---|
136 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
137 | break; |
---|
138 | |
---|
139 | case 'edit': |
---|
140 | // パラメーター初期化, 取得 |
---|
141 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
142 | $arrForm = $objFormParam->getHashArray(); |
---|
143 | // エラーチェック |
---|
144 | $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); |
---|
145 | if (count($this->arrErr) == 0) { |
---|
146 | // 確認画面表示設定 |
---|
147 | $this->tpl_mainpage = 'products/confirm.tpl'; |
---|
148 | $this->arrCatList = $this->lfGetCategoryList_Edit(); |
---|
149 | $this->arrForm = $this->lfSetViewParam_ConfirmPage($objUpFile, $objDownFile, $arrForm); |
---|
150 | } else { |
---|
151 | // 入力画面表示設定 |
---|
152 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
153 | // ページonload時のJavaScript設定 |
---|
154 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
155 | } |
---|
156 | break; |
---|
157 | |
---|
158 | case 'complete': |
---|
159 | // パラメーター初期化, 取得 |
---|
160 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
161 | $arrForm = $this->lfGetFormParam_Complete($objFormParam); |
---|
162 | // エラーチェック |
---|
163 | $this->arrErr = $this->lfCheckError_Edit($objFormParam, $objUpFile, $objDownFile, $arrForm); |
---|
164 | if (count($this->arrErr) == 0) { |
---|
165 | // DBへデータ登録 |
---|
166 | $product_id = $this->lfRegistProduct($objUpFile, $objDownFile, $arrForm); |
---|
167 | |
---|
168 | // 件数カウントバッチ実行 |
---|
169 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
170 | $objDb = new SC_Helper_DB_Ex(); |
---|
171 | $objDb->sfCountCategory($objQuery); |
---|
172 | $objDb->sfCountMaker($objQuery); |
---|
173 | |
---|
174 | // ダウンロード商品の複製時に、ダウンロード商品用ファイルを |
---|
175 | // 変更すると、複製元のファイルが削除されるのを回避。 |
---|
176 | if (!empty($arrForm['copy_product_id'])) { |
---|
177 | $objDownFile->save_file = array(); |
---|
178 | } |
---|
179 | |
---|
180 | // 一時ファイルを本番ディレクトリに移動する |
---|
181 | $this->lfSaveUploadFiles($objUpFile, $objDownFile, $product_id); |
---|
182 | |
---|
183 | $this->tpl_mainpage = 'products/complete.tpl'; |
---|
184 | $this->arrForm['product_id'] = $product_id; |
---|
185 | } else { |
---|
186 | // 入力画面表示設定 |
---|
187 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
188 | // ページonload時のJavaScript設定 |
---|
189 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
190 | } |
---|
191 | break; |
---|
192 | |
---|
193 | // 画像のアップロード |
---|
194 | case 'upload_image': |
---|
195 | case 'delete_image': |
---|
196 | // パラメーター初期化 |
---|
197 | $this->lfInitFormParam_UploadImage($objFormParam); |
---|
198 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
199 | $arrForm = $objFormParam->getHashArray(); |
---|
200 | |
---|
201 | switch ($mode) { |
---|
202 | case 'upload_image': |
---|
203 | // ファイルを一時ディレクトリにアップロード |
---|
204 | $this->arrErr[$arrForm['image_key']] = $objUpFile->makeTempFile($arrForm['image_key'], IMAGE_RENAME); |
---|
205 | if ($this->arrErr[$arrForm['image_key']] == '') { |
---|
206 | // 縮小画像作成 |
---|
207 | $this->lfSetScaleImage($objUpFile, $arrForm['image_key']); |
---|
208 | } |
---|
209 | break; |
---|
210 | case 'delete_image': |
---|
211 | // ファイル削除 |
---|
212 | $this->lfDeleteTempFile($objUpFile, $arrForm['image_key']); |
---|
213 | break; |
---|
214 | default: |
---|
215 | break; |
---|
216 | } |
---|
217 | |
---|
218 | // 入力画面表示設定 |
---|
219 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
220 | // ページonload時のJavaScript設定 |
---|
221 | $anchor_hash = $this->getAnchorHash($arrForm['image_key']); |
---|
222 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
223 | break; |
---|
224 | |
---|
225 | // ダウンロード商品ファイルアップロード |
---|
226 | case 'upload_down': |
---|
227 | case 'delete_down': |
---|
228 | // パラメーター初期化 |
---|
229 | $this->lfInitFormParam_UploadDown($objFormParam); |
---|
230 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
231 | $arrForm = $objFormParam->getHashArray(); |
---|
232 | |
---|
233 | switch ($mode) { |
---|
234 | case 'upload_down': |
---|
235 | // ファイルを一時ディレクトリにアップロード |
---|
236 | $this->arrErr[$arrForm['down_key']] = $objDownFile->makeTempDownFile(); |
---|
237 | break; |
---|
238 | case 'delete_down': |
---|
239 | // ファイル削除 |
---|
240 | $objDownFile->deleteFile($arrForm['down_key']); |
---|
241 | break; |
---|
242 | default: |
---|
243 | break; |
---|
244 | } |
---|
245 | |
---|
246 | // 入力画面表示設定 |
---|
247 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
248 | // ページonload時のJavaScript設定 |
---|
249 | $anchor_hash = $this->getAnchorHash($arrForm['down_key']); |
---|
250 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
251 | break; |
---|
252 | |
---|
253 | // 関連商品選択 |
---|
254 | case 'recommend_select' : |
---|
255 | // パラメーター初期化 |
---|
256 | $this->lfInitFormParam_RecommendSelect($objFormParam); |
---|
257 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
258 | $arrForm = $objFormParam->getHashArray(); |
---|
259 | // 入力画面表示設定 |
---|
260 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
261 | |
---|
262 | // 選択された関連商品IDがすでに登録している関連商品と重複していないかチェック |
---|
263 | $this->lfCheckError_RecommendSelect($this->arrForm, $this->arrErr); |
---|
264 | |
---|
265 | // ページonload時のJavaScript設定 |
---|
266 | $anchor_hash = $this->getAnchorHash($this->arrForm['anchor_key']); |
---|
267 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage($anchor_hash); |
---|
268 | break; |
---|
269 | |
---|
270 | // 確認ページからの戻り |
---|
271 | case 'confirm_return': |
---|
272 | // パラメーター初期化 |
---|
273 | $this->lfInitFormParam($objFormParam, $_POST); |
---|
274 | $arrForm = $objFormParam->getHashArray(); |
---|
275 | // 入力画面表示設定 |
---|
276 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
277 | // ページonload時のJavaScript設定 |
---|
278 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
279 | break; |
---|
280 | |
---|
281 | default: |
---|
282 | // 入力画面表示設定 |
---|
283 | $arrForm = array(); |
---|
284 | $this->arrForm = $this->lfSetViewParam_InputPage($objUpFile, $objDownFile, $arrForm); |
---|
285 | // ページonload時のJavaScript設定 |
---|
286 | $this->tpl_onload = $this->lfSetOnloadJavaScript_InputPage(); |
---|
287 | break; |
---|
288 | } |
---|
289 | |
---|
290 | // 関連商品の読み込み |
---|
291 | $this->arrRecommend = $this->lfGetRecommendProducts($this->arrForm); |
---|
292 | |
---|
293 | } |
---|
294 | |
---|
295 | /** |
---|
296 | * デストラクタ. |
---|
297 | * |
---|
298 | * @return void |
---|
299 | */ |
---|
300 | function destroy() |
---|
301 | { |
---|
302 | parent::destroy(); |
---|
303 | } |
---|
304 | |
---|
305 | /** |
---|
306 | * パラメーター情報の初期化 |
---|
307 | * - 編集/複製モード |
---|
308 | * |
---|
309 | * @param object $objFormParam SC_FormParamインスタンス |
---|
310 | * @param array $arrPost $_POSTデータ |
---|
311 | * @return void |
---|
312 | */ |
---|
313 | function lfInitFormParam_PreEdit(&$objFormParam, $arrPost) |
---|
314 | { |
---|
315 | $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
316 | $objFormParam->setParam($arrPost); |
---|
317 | $objFormParam->convParam(); |
---|
318 | } |
---|
319 | |
---|
320 | /** |
---|
321 | * パラメーター情報の初期化 |
---|
322 | * |
---|
323 | * @param object $objFormParam SC_FormParamインスタンス |
---|
324 | * @param array $arrPost $_POSTデータ |
---|
325 | * @return void |
---|
326 | */ |
---|
327 | function lfInitFormParam(&$objFormParam, $arrPost) |
---|
328 | { |
---|
329 | $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
330 | $objFormParam->addParam('商品名', 'name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
331 | $objFormParam->addParam('商品カテゴリ', 'category_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
332 | $objFormParam->addParam('公開・非公開', 'status', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
333 | $objFormParam->addParam('商品ステータス', 'product_status', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
334 | |
---|
335 | if (!$arrPost['has_product_class']) { |
---|
336 | // 新規登録, 規格なし商品の編集の場合 |
---|
337 | $objFormParam->addParam('商品種別', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
338 | $objFormParam->addParam('ダウンロード商品ファイル名', 'down_filename', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
339 | $objFormParam->addParam('ダウンロード商品実ファイル名', 'down_realfilename', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
340 | $objFormParam->addParam('temp_down_file', 'temp_down_file', '', '', array()); |
---|
341 | $objFormParam->addParam('save_down_file', 'save_down_file', '', '', array()); |
---|
342 | $objFormParam->addParam('商品コード', 'product_code', STEXT_LEN, 'KVna', array('EXIST_CHECK', 'SPTAB_CHECK','MAX_LENGTH_CHECK')); |
---|
343 | $objFormParam->addParam(NORMAL_PRICE_TITLE, 'price01', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
344 | $objFormParam->addParam(SALE_PRICE_TITLE, 'price02', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
345 | $objFormParam->addParam('在庫数', 'stock', AMOUNT_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
346 | $objFormParam->addParam('在庫無制限', 'stock_unlimited', INT_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
347 | } |
---|
348 | $objFormParam->addParam('商品送料', 'deliv_fee', PRICE_LEN, 'n', array('NUM_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
349 | $objFormParam->addParam('ポイント付与率', 'point_rate', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
350 | $objFormParam->addParam('発送日目安', 'deliv_date_id', INT_LEN, 'n', array('NUM_CHECK')); |
---|
351 | $objFormParam->addParam('販売制限数', 'sale_limit', AMOUNT_LEN, 'n', array('SPTAB_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
352 | $objFormParam->addParam('メーカー', 'maker_id', INT_LEN, 'n', array('NUM_CHECK')); |
---|
353 | $objFormParam->addParam('メーカーURL', 'comment1', URL_LEN, 'a', array('SPTAB_CHECK', 'URL_CHECK', 'MAX_LENGTH_CHECK')); |
---|
354 | $objFormParam->addParam('検索ワード', 'comment3', LLTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
355 | $objFormParam->addParam('備考欄(SHOP専用)', 'note', LLTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
356 | $objFormParam->addParam('一覧-メインコメント', 'main_list_comment', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
357 | $objFormParam->addParam('詳細-メインコメント', 'main_comment', LLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
358 | $objFormParam->addParam('save_main_list_image', 'save_main_list_image', '', '', array()); |
---|
359 | $objFormParam->addParam('save_main_image', 'save_main_image', '', '', array()); |
---|
360 | $objFormParam->addParam('save_main_large_image', 'save_main_large_image', '', '', array()); |
---|
361 | $objFormParam->addParam('temp_main_list_image', 'temp_main_list_image', '', '', array()); |
---|
362 | $objFormParam->addParam('temp_main_image', 'temp_main_image', '', '', array()); |
---|
363 | $objFormParam->addParam('temp_main_large_image', 'temp_main_large_image', '', '', array()); |
---|
364 | |
---|
365 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
366 | $objFormParam->addParam('詳細-サブタイトル' . $cnt, 'sub_title' . $cnt, STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
367 | $objFormParam->addParam('詳細-サブコメント' . $cnt, 'sub_comment' . $cnt, LLTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
368 | $objFormParam->addParam('save_sub_image' . $cnt, 'save_sub_image' . $cnt, '', '', array()); |
---|
369 | $objFormParam->addParam('save_sub_large_image' . $cnt, 'save_sub_large_image' . $cnt, '', '', array()); |
---|
370 | $objFormParam->addParam('temp_sub_image' . $cnt, 'temp_sub_image' . $cnt, '', '', array()); |
---|
371 | $objFormParam->addParam('temp_sub_large_image' . $cnt, 'temp_sub_large_image' . $cnt, '', '', array()); |
---|
372 | } |
---|
373 | |
---|
374 | for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) { |
---|
375 | $objFormParam->addParam('関連商品コメント' . $cnt, 'recommend_comment' . $cnt, LTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
376 | $objFormParam->addParam('関連商品ID' . $cnt, 'recommend_id' . $cnt, INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
377 | $objFormParam->addParam('recommend_delete' . $cnt, 'recommend_delete' . $cnt, '', 'n', array()); |
---|
378 | } |
---|
379 | |
---|
380 | $objFormParam->addParam('商品ID', 'copy_product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
381 | |
---|
382 | $objFormParam->addParam('has_product_class', 'has_product_class', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
383 | $objFormParam->addParam('product_class_id', 'product_class_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
384 | |
---|
385 | $objFormParam->setParam($arrPost); |
---|
386 | $objFormParam->convParam(); |
---|
387 | } |
---|
388 | |
---|
389 | /** |
---|
390 | * パラメーター情報の初期化 |
---|
391 | * - 画像ファイルアップロードモード |
---|
392 | * |
---|
393 | * @param object $objFormParam SC_FormParamインスタンス |
---|
394 | * @return void |
---|
395 | */ |
---|
396 | function lfInitFormParam_UploadImage(&$objFormParam) |
---|
397 | { |
---|
398 | $objFormParam->addParam('image_key', 'image_key', '', '', array()); |
---|
399 | } |
---|
400 | |
---|
401 | /** |
---|
402 | * パラメーター情報の初期化 |
---|
403 | * - ダウンロード商品ファイルアップロードモード |
---|
404 | * |
---|
405 | * @param object $objFormParam SC_FormParamインスタンス |
---|
406 | * @return void |
---|
407 | */ |
---|
408 | function lfInitFormParam_UploadDown(&$objFormParam) |
---|
409 | { |
---|
410 | $objFormParam->addParam('down_key', 'down_key', '', '', array()); |
---|
411 | } |
---|
412 | |
---|
413 | /** |
---|
414 | * パラメーター情報の初期化 |
---|
415 | * - 関連商品追加モード |
---|
416 | * |
---|
417 | * @param object $objFormParam SC_FormParamインスタンス |
---|
418 | * @return void |
---|
419 | */ |
---|
420 | function lfInitFormParam_RecommendSelect(&$objFormParam) |
---|
421 | { |
---|
422 | $objFormParam->addParam('anchor_key', 'anchor_key', '', '', array()); |
---|
423 | $objFormParam->addParam('select_recommend_no', 'select_recommend_no', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
424 | } |
---|
425 | |
---|
426 | /** |
---|
427 | * アップロードファイルパラメーター情報の初期化 |
---|
428 | * - 画像ファイル用 |
---|
429 | * |
---|
430 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
431 | * @return void |
---|
432 | */ |
---|
433 | function lfInitFile(&$objUpFile) |
---|
434 | { |
---|
435 | $objUpFile->addFile('一覧-メイン画像', 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, false, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); |
---|
436 | $objUpFile->addFile('詳細-メイン画像', 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); |
---|
437 | $objUpFile->addFile('詳細-メイン拡大画像', 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT); |
---|
438 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
439 | $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT); |
---|
440 | $objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT); |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | /** |
---|
445 | * アップロードファイルパラメーター情報の初期化 |
---|
446 | * - ダウンロード商品ファイル用 |
---|
447 | * |
---|
448 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
449 | * @return void |
---|
450 | */ |
---|
451 | function lfInitDownFile(&$objDownFile) |
---|
452 | { |
---|
453 | $objDownFile->addFile('ダウンロード販売用ファイル', 'down_file', explode(',', DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); |
---|
454 | } |
---|
455 | |
---|
456 | /** |
---|
457 | * フォーム入力パラメーターのエラーチェック |
---|
458 | * |
---|
459 | * @param object $objFormParam SC_FormParamインスタンス |
---|
460 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
461 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
462 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
463 | * @return array エラー情報を格納した連想配列 |
---|
464 | */ |
---|
465 | function lfCheckError_Edit(&$objFormParam, &$objUpFile, &$objDownFile, $arrForm) |
---|
466 | { |
---|
467 | $objErr = new SC_CheckError_Ex($arrForm); |
---|
468 | $arrErr = array(); |
---|
469 | |
---|
470 | // 入力パラメーターチェック |
---|
471 | $arrErr = $objFormParam->checkError(); |
---|
472 | |
---|
473 | // アップロードファイル必須チェック |
---|
474 | $arrErr = array_merge((array)$arrErr, (array)$objUpFile->checkExists()); |
---|
475 | |
---|
476 | // HTMLタグ許可チェック |
---|
477 | $objErr->doFunc(array('詳細-メインコメント', 'main_comment', $this->arrAllowedTag), array('HTML_TAG_CHECK')); |
---|
478 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
479 | $objErr->doFunc(array('詳細-サブコメント' . $cnt, 'sub_comment' . $cnt, $this->arrAllowedTag), array('HTML_TAG_CHECK')); |
---|
480 | } |
---|
481 | |
---|
482 | // 規格情報がない商品の場合のチェック |
---|
483 | if ($arrForm['has_product_class'] != true) { |
---|
484 | // 在庫必須チェック(在庫無制限ではない場合) |
---|
485 | if ($arrForm['stock_unlimited'] != UNLIMITED_FLG_UNLIMITED) { |
---|
486 | $objErr->doFunc(array('在庫数', 'stock'), array('EXIST_CHECK')); |
---|
487 | } |
---|
488 | // ダウンロード商品ファイル必須チェック(ダウンロード商品の場合) |
---|
489 | if ($arrForm['product_type_id'] == PRODUCT_TYPE_DOWNLOAD) { |
---|
490 | $arrErr = array_merge((array)$arrErr, (array)$objDownFile->checkExists()); |
---|
491 | $objErr->doFunc(array('ダウンロード商品ファイル名', 'down_filename'), array('EXIST_CHECK')); |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | $arrErr = array_merge((array)$arrErr, (array)$objErr->arrErr); |
---|
496 | return $arrErr; |
---|
497 | } |
---|
498 | |
---|
499 | /** |
---|
500 | * 関連商品の重複登録チェック、エラーチェック |
---|
501 | * |
---|
502 | * 関連商品の重複があった場合はエラーメッセージを格納し、該当の商品IDをリセットする |
---|
503 | * |
---|
504 | * @param array $arrForm 入力値の配列 |
---|
505 | * @param array $arrErr エラーメッセージの配列 |
---|
506 | * @return void |
---|
507 | */ |
---|
508 | function lfCheckError_RecommendSelect(&$arrForm, &$arrErr) |
---|
509 | { |
---|
510 | $select_recommend_no = $arrForm['select_recommend_no']; |
---|
511 | $select_recommend_id = $arrForm['recommend_id' . $select_recommend_no]; |
---|
512 | |
---|
513 | foreach ($arrForm as $key => $value) { |
---|
514 | if (preg_match('/^recommend_id/', $key)) { |
---|
515 | if ($select_recommend_no == preg_replace('/^recommend_id/', '', $key)) { |
---|
516 | continue; |
---|
517 | } |
---|
518 | $delete_key = 'recommend_delete'.intval(str_replace('recommend_id','',$key)); |
---|
519 | if ($select_recommend_id == $arrForm[$key] && $arrForm[$delete_key] != 1) { |
---|
520 | // 重複した場合、選択されたデータをリセットする |
---|
521 | $arrForm['recommend_id' . $select_recommend_no] = ''; |
---|
522 | $arrErr['recommend_comment' . $select_recommend_no] = '※ すでに登録されている関連商品です。<br />'; |
---|
523 | break; |
---|
524 | } |
---|
525 | } |
---|
526 | } |
---|
527 | } |
---|
528 | |
---|
529 | /** |
---|
530 | * 検索パラメーター引き継ぎ用配列取得 |
---|
531 | * |
---|
532 | * @param array $arrPost $_POSTデータ |
---|
533 | * @return array 検索パラメーター配列 |
---|
534 | */ |
---|
535 | function lfGetSearchParam($arrPost) |
---|
536 | { |
---|
537 | $arrSearchParam = array(); |
---|
538 | $objFormParam = new SC_FormParam_Ex(); |
---|
539 | |
---|
540 | parent::lfInitParam($objFormParam); |
---|
541 | $objFormParam->setParam($arrPost); |
---|
542 | $arrSearchParam = $objFormParam->getSearchArray(); |
---|
543 | |
---|
544 | return $arrSearchParam; |
---|
545 | } |
---|
546 | |
---|
547 | /** |
---|
548 | * フォームパラメーター取得 |
---|
549 | * - 編集/複製モード |
---|
550 | * |
---|
551 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
552 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
553 | * @param integer $product_id 商品ID |
---|
554 | * @return array フォームパラメーター配列 |
---|
555 | */ |
---|
556 | function lfGetFormParam_PreEdit(&$objUpFile, &$objDownFile, $product_id) |
---|
557 | { |
---|
558 | $arrForm = array(); |
---|
559 | |
---|
560 | // DBから商品データ取得 |
---|
561 | $arrForm = $this->lfGetProductData_FromDB($product_id); |
---|
562 | // DBデータから画像ファイル名の読込 |
---|
563 | $objUpFile->setDBFileList($arrForm); |
---|
564 | // DBデータからダウンロードファイル名の読込 |
---|
565 | $objDownFile->setDBDownFile($arrForm); |
---|
566 | |
---|
567 | return $arrForm; |
---|
568 | } |
---|
569 | |
---|
570 | /** |
---|
571 | * フォームパラメーター取得 |
---|
572 | * - 登録モード |
---|
573 | * |
---|
574 | * @param object $objFormParam SC_FormParamインスタンス |
---|
575 | * @return array フォームパラメーター配列 |
---|
576 | */ |
---|
577 | function lfGetFormParam_Complete(&$objFormParam) |
---|
578 | { |
---|
579 | $arrForm = $objFormParam->getHashArray(); |
---|
580 | $arrForm['category_id'] = unserialize($arrForm['category_id']); |
---|
581 | $objFormParam->setValue('category_id', $arrForm['category_id']); |
---|
582 | |
---|
583 | return $arrForm; |
---|
584 | } |
---|
585 | |
---|
586 | /** |
---|
587 | * 表示用フォームパラメーター取得 |
---|
588 | * - 入力画面 |
---|
589 | * |
---|
590 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
591 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
592 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
593 | * @return array 表示用フォームパラメーター配列 |
---|
594 | */ |
---|
595 | function lfSetViewParam_InputPage(&$objUpFile, &$objDownFile, &$arrForm) |
---|
596 | { |
---|
597 | // カテゴリマスターデータ取得 |
---|
598 | $objDb = new SC_Helper_DB_Ex(); |
---|
599 | list($this->arrCatVal, $this->arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
600 | |
---|
601 | if (isset($arrForm['category_id']) && !is_array($arrForm['category_id'])) { |
---|
602 | $arrForm['category_id'] = unserialize($arrForm['category_id']); |
---|
603 | } |
---|
604 | $this->tpl_json_category_id = SC_Utils_Ex::jsonEncode($arrForm['category_id']); |
---|
605 | if ($arrForm['status'] == '') { |
---|
606 | $arrForm['status'] = DEFAULT_PRODUCT_DISP; |
---|
607 | } |
---|
608 | if ($arrForm['product_type_id'] == '') { |
---|
609 | $arrForm['product_type_id'] = DEFAULT_PRODUCT_DOWN; |
---|
610 | } |
---|
611 | // アップロードファイル情報取得(Hidden用) |
---|
612 | $arrHidden = $objUpFile->getHiddenFileList(); |
---|
613 | $arrForm['arrHidden'] = array_merge((array)$arrHidden, (array)$objDownFile->getHiddenFileList()); |
---|
614 | |
---|
615 | // 画像ファイル表示用データ取得 |
---|
616 | $arrForm['arrFile'] = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); |
---|
617 | |
---|
618 | // ダウンロード商品実ファイル名取得 |
---|
619 | $arrForm['down_realfilename'] = $objDownFile->getFormDownFile(); |
---|
620 | |
---|
621 | // 基本情報(デフォルトポイントレート用) |
---|
622 | $arrForm['arrInfo'] = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
623 | |
---|
624 | // サブ情報ありなしフラグ |
---|
625 | $arrForm['sub_find'] = $this->hasSubProductData($arrForm); |
---|
626 | |
---|
627 | return $arrForm; |
---|
628 | } |
---|
629 | |
---|
630 | /** |
---|
631 | * 表示用フォームパラメーター取得 |
---|
632 | * - 確認画面 |
---|
633 | * |
---|
634 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
635 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
636 | * @param array $arrForm フォーム入力パラメーター配列 |
---|
637 | * @return array 表示用フォームパラメーター配列 |
---|
638 | */ |
---|
639 | function lfSetViewParam_ConfirmPage(&$objUpFile, &$objDownFile, &$arrForm) |
---|
640 | { |
---|
641 | // カテゴリ表示用 |
---|
642 | $arrForm['arrCategoryId'] = $arrForm['category_id']; |
---|
643 | // hidden に渡す値は serialize する |
---|
644 | $arrForm['category_id'] = serialize($arrForm['category_id']); |
---|
645 | // 画像ファイル用データ取得 |
---|
646 | $arrForm['arrFile'] = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); |
---|
647 | // ダウンロード商品実ファイル名取得 |
---|
648 | $arrForm['down_realfilename'] = $objDownFile->getFormDownFile(); |
---|
649 | |
---|
650 | return $arrForm; |
---|
651 | } |
---|
652 | |
---|
653 | /** |
---|
654 | * 縮小した画像をセットする |
---|
655 | * |
---|
656 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
657 | * @param string $image_key 画像ファイルキー |
---|
658 | * @return void |
---|
659 | */ |
---|
660 | function lfSetScaleImage(&$objUpFile, $image_key) |
---|
661 | { |
---|
662 | $subno = str_replace('sub_large_image', '', $image_key); |
---|
663 | switch ($image_key) { |
---|
664 | case 'main_large_image': |
---|
665 | // 詳細メイン画像 |
---|
666 | $this->lfMakeScaleImage($objUpFile, $image_key, 'main_image'); |
---|
667 | case 'main_image': |
---|
668 | // 一覧メイン画像 |
---|
669 | $this->lfMakeScaleImage($objUpFile, $image_key, 'main_list_image'); |
---|
670 | break; |
---|
671 | case 'sub_large_image' . $subno: |
---|
672 | // サブメイン画像 |
---|
673 | $this->lfMakeScaleImage($objUpFile, $_POST['image_key'], 'sub_image' . $subno); |
---|
674 | break; |
---|
675 | default: |
---|
676 | break; |
---|
677 | } |
---|
678 | } |
---|
679 | |
---|
680 | /** |
---|
681 | * 画像ファイルのコピー |
---|
682 | * |
---|
683 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
684 | * @return void |
---|
685 | */ |
---|
686 | function lfCopyProductImageFiles(&$objUpFile) |
---|
687 | { |
---|
688 | $arrKey = $objUpFile->keyname; |
---|
689 | $arrSaveFile = $objUpFile->save_file; |
---|
690 | |
---|
691 | foreach ($arrSaveFile as $key => $val) { |
---|
692 | $this->lfMakeScaleImage($objUpFile, $arrKey[$key], $arrKey[$key], true); |
---|
693 | } |
---|
694 | } |
---|
695 | |
---|
696 | /** |
---|
697 | * 縮小画像生成 |
---|
698 | * |
---|
699 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
700 | * @param string $from_key 元画像ファイルキー |
---|
701 | * @param string $to_key 縮小画像ファイルキー |
---|
702 | * @param boolean $forced |
---|
703 | * @return void |
---|
704 | */ |
---|
705 | function lfMakeScaleImage(&$objUpFile, $from_key, $to_key, $forced = false) |
---|
706 | { |
---|
707 | $arrImageKey = array_flip($objUpFile->keyname); |
---|
708 | $from_path = ''; |
---|
709 | |
---|
710 | if ($objUpFile->temp_file[$arrImageKey[$from_key]]) { |
---|
711 | $from_path = $objUpFile->temp_dir . $objUpFile->temp_file[$arrImageKey[$from_key]]; |
---|
712 | } elseif ($objUpFile->save_file[$arrImageKey[$from_key]]) { |
---|
713 | $from_path = $objUpFile->save_dir . $objUpFile->save_file[$arrImageKey[$from_key]]; |
---|
714 | } |
---|
715 | |
---|
716 | if (file_exists($from_path)) { |
---|
717 | // 生成先の画像サイズを取得 |
---|
718 | $to_w = $objUpFile->width[$arrImageKey[$to_key]]; |
---|
719 | $to_h = $objUpFile->height[$arrImageKey[$to_key]]; |
---|
720 | |
---|
721 | if ($forced) { |
---|
722 | $objUpFile->save_file[$arrImageKey[$to_key]] = ''; |
---|
723 | } |
---|
724 | |
---|
725 | if (empty($objUpFile->temp_file[$arrImageKey[$to_key]]) |
---|
726 | && empty($objUpFile->save_file[$arrImageKey[$to_key]]) |
---|
727 | ) { |
---|
728 | // リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
729 | $dst_file = $objUpFile->lfGetTmpImageName(IMAGE_RENAME, '', $objUpFile->temp_file[$arrImageKey[$from_key]]) . $this->lfGetAddSuffix($to_key); |
---|
730 | $path = $objUpFile->makeThumb($from_path, $to_w, $to_h, $dst_file); |
---|
731 | $objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path); |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | /** |
---|
737 | * アップロードファイルパラメーター情報から削除 |
---|
738 | * 一時ディレクトリに保存されている実ファイルも削除する |
---|
739 | * |
---|
740 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
741 | * @param string $image_key 画像ファイルキー |
---|
742 | * @return void |
---|
743 | */ |
---|
744 | function lfDeleteTempFile(&$objUpFile, $image_key) |
---|
745 | { |
---|
746 | // TODO: SC_UploadFile::deleteFileの画像削除条件見直し要 |
---|
747 | $arrTempFile = $objUpFile->temp_file; |
---|
748 | $arrKeyName = $objUpFile->keyname; |
---|
749 | |
---|
750 | foreach ($arrKeyName as $key => $keyname) { |
---|
751 | if ($keyname != $image_key) continue; |
---|
752 | |
---|
753 | if (!empty($arrTempFile[$key])) { |
---|
754 | $temp_file = $arrTempFile[$key]; |
---|
755 | $arrTempFile[$key] = ''; |
---|
756 | |
---|
757 | if (!in_array($temp_file, $arrTempFile)) { |
---|
758 | $objUpFile->deleteFile($image_key); |
---|
759 | } else { |
---|
760 | $objUpFile->temp_file[$key] = ''; |
---|
761 | $objUpFile->save_file[$key] = ''; |
---|
762 | } |
---|
763 | } else { |
---|
764 | $objUpFile->temp_file[$key] = ''; |
---|
765 | $objUpFile->save_file[$key] = ''; |
---|
766 | } |
---|
767 | } |
---|
768 | } |
---|
769 | |
---|
770 | /** |
---|
771 | * アップロードファイルを保存する |
---|
772 | * |
---|
773 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
774 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
775 | * @param integer $product_id 商品ID |
---|
776 | * @return void |
---|
777 | */ |
---|
778 | function lfSaveUploadFiles(&$objUpFile, &$objDownFile, $product_id) |
---|
779 | { |
---|
780 | // TODO: SC_UploadFile::moveTempFileの画像削除条件見直し要 |
---|
781 | $objImage = new SC_Image_Ex($objUpFile->temp_dir); |
---|
782 | $arrKeyName = $objUpFile->keyname; |
---|
783 | $arrTempFile = $objUpFile->temp_file; |
---|
784 | $arrSaveFile = $objUpFile->save_file; |
---|
785 | $arrImageKey = array(); |
---|
786 | foreach ($arrTempFile as $key => $temp_file) { |
---|
787 | if ($temp_file) { |
---|
788 | $objImage->moveTempImage($temp_file, $objUpFile->save_dir); |
---|
789 | $arrImageKey[] = $arrKeyName[$key]; |
---|
790 | if (!empty($arrSaveFile[$key]) |
---|
791 | && !$this->lfHasSameProductImage($product_id, $arrImageKey, $arrSaveFile[$key]) |
---|
792 | && !in_array($temp_file, $arrSaveFile) |
---|
793 | ) { |
---|
794 | $objImage->deleteImage($arrSaveFile[$key], $objUpFile->save_dir); |
---|
795 | } |
---|
796 | } |
---|
797 | } |
---|
798 | $objDownFile->moveTempDownFile(); |
---|
799 | } |
---|
800 | |
---|
801 | /** |
---|
802 | * 同名画像ファイル登録の有無を確認する. |
---|
803 | * |
---|
804 | * 画像ファイルの削除可否判定用。 |
---|
805 | * 同名ファイルの登録がある場合には画像ファイルの削除を行わない。 |
---|
806 | * 戻り値: 同名ファイル有り(true) 同名ファイル無し(false) |
---|
807 | * |
---|
808 | * @param string $product_id 商品ID |
---|
809 | * @param string $arrImageKey 対象としない画像カラム名 |
---|
810 | * @param string $image_file_name 画像ファイル名 |
---|
811 | * @return boolean |
---|
812 | */ |
---|
813 | function lfHasSameProductImage($product_id, $arrImageKey, $image_file_name) |
---|
814 | { |
---|
815 | if (!SC_Utils_Ex::sfIsInt($product_id)) return false; |
---|
816 | if (!$arrImageKey) return false; |
---|
817 | if (!$image_file_name) return false; |
---|
818 | |
---|
819 | $arrWhere = array(); |
---|
820 | $sqlval = array('0', $product_id); |
---|
821 | foreach ($arrImageKey as $image_key) { |
---|
822 | $arrWhere[] = "{$image_key} = ?"; |
---|
823 | $sqlval[] = $image_file_name; |
---|
824 | } |
---|
825 | $where = implode(' OR ', $arrWhere); |
---|
826 | $where = "del_flg = ? AND ((product_id <> ? AND ({$where}))"; |
---|
827 | |
---|
828 | $arrKeyName = $this->objUpFile->keyname; |
---|
829 | foreach ($arrKeyName as $key => $keyname) { |
---|
830 | if (in_array($keyname, $arrImageKey)) continue; |
---|
831 | $where .= " OR {$keyname} = ?"; |
---|
832 | $sqlval[] = $image_file_name; |
---|
833 | } |
---|
834 | $where .= ')'; |
---|
835 | |
---|
836 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
837 | $exists = $objQuery->exists('dtb_products', $where, $sqlval); |
---|
838 | return $exists; |
---|
839 | } |
---|
840 | |
---|
841 | /** |
---|
842 | * DBから商品データを取得する |
---|
843 | * |
---|
844 | * @param integer $product_id 商品ID |
---|
845 | * @return array 商品データ配列 |
---|
846 | */ |
---|
847 | function lfGetProductData_FromDB($product_id) |
---|
848 | { |
---|
849 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
850 | $arrProduct = array(); |
---|
851 | |
---|
852 | // 商品データ取得 |
---|
853 | $col = '*'; |
---|
854 | $table = <<< __EOF__ |
---|
855 | dtb_products AS T1 |
---|
856 | LEFT JOIN ( |
---|
857 | SELECT product_id AS product_id_sub, |
---|
858 | product_code, |
---|
859 | price01, |
---|
860 | price02, |
---|
861 | deliv_fee, |
---|
862 | stock, |
---|
863 | stock_unlimited, |
---|
864 | sale_limit, |
---|
865 | point_rate, |
---|
866 | product_type_id, |
---|
867 | down_filename, |
---|
868 | down_realfilename |
---|
869 | FROM dtb_products_class |
---|
870 | ) AS T2 |
---|
871 | ON T1.product_id = T2.product_id_sub |
---|
872 | __EOF__; |
---|
873 | $where = 'product_id = ?'; |
---|
874 | $objQuery->setLimit('1'); |
---|
875 | $arrProduct = $objQuery->select($col, $table, $where, array($product_id)); |
---|
876 | |
---|
877 | // カテゴリID取得 |
---|
878 | $col = 'category_id'; |
---|
879 | $table = 'dtb_product_categories'; |
---|
880 | $where = 'product_id = ?'; |
---|
881 | $objQuery->setOption(''); |
---|
882 | $arrProduct[0]['category_id'] = $objQuery->getCol($col, $table, $where, array($product_id)); |
---|
883 | |
---|
884 | // 規格情報ありなしフラグ取得 |
---|
885 | $objDb = new SC_Helper_DB_Ex(); |
---|
886 | $arrProduct[0]['has_product_class'] = $objDb->sfHasProductClass($product_id); |
---|
887 | |
---|
888 | // 規格が登録されていなければ規格ID取得 |
---|
889 | if ($arrProduct[0]['has_product_class'] == false) { |
---|
890 | $arrProduct[0]['product_class_id'] = SC_Utils_Ex::sfGetProductClassId($product_id,'0','0'); |
---|
891 | } |
---|
892 | |
---|
893 | // 商品ステータス取得 |
---|
894 | $objProduct = new SC_Product_Ex(); |
---|
895 | $productStatus = $objProduct->getProductStatus(array($product_id)); |
---|
896 | $arrProduct[0]['product_status'] = $productStatus[$product_id]; |
---|
897 | |
---|
898 | // 関連商品データ取得 |
---|
899 | $arrRecommend = $this->lfGetRecommendProductsData_FromDB($product_id); |
---|
900 | $arrProduct[0] = array_merge($arrProduct[0], $arrRecommend); |
---|
901 | |
---|
902 | return $arrProduct[0]; |
---|
903 | } |
---|
904 | |
---|
905 | /** |
---|
906 | * DBから関連商品データを取得する |
---|
907 | * |
---|
908 | * @param integer $product_id 商品ID |
---|
909 | * @return array 関連商品データ配列 |
---|
910 | */ |
---|
911 | function lfGetRecommendProductsData_FromDB($product_id) |
---|
912 | { |
---|
913 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
914 | $arrRecommendProducts = array(); |
---|
915 | |
---|
916 | $col = 'recommend_product_id,'; |
---|
917 | $col.= 'comment'; |
---|
918 | $table = 'dtb_recommend_products'; |
---|
919 | $where = 'product_id = ?'; |
---|
920 | $objQuery->setOrder('rank DESC'); |
---|
921 | $arrRet = $objQuery->select($col, $table, $where, array($product_id)); |
---|
922 | |
---|
923 | $no = 1; |
---|
924 | foreach ($arrRet as $arrVal) { |
---|
925 | $arrRecommendProducts['recommend_id' . $no] = $arrVal['recommend_product_id']; |
---|
926 | $arrRecommendProducts['recommend_comment' . $no] = $arrVal['comment']; |
---|
927 | $no++; |
---|
928 | } |
---|
929 | |
---|
930 | return $arrRecommendProducts; |
---|
931 | } |
---|
932 | |
---|
933 | /** |
---|
934 | * 関連商品データ表示用配列を取得する |
---|
935 | * |
---|
936 | * @param string $arrForm フォーム入力パラメーター配列 |
---|
937 | * @return array 関連商品データ配列 |
---|
938 | */ |
---|
939 | function lfGetRecommendProducts(&$arrForm) |
---|
940 | { |
---|
941 | $arrRecommend = array(); |
---|
942 | |
---|
943 | for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
944 | $keyname = 'recommend_id' . $i; |
---|
945 | $delkey = 'recommend_delete' . $i; |
---|
946 | $commentkey = 'recommend_comment' . $i; |
---|
947 | |
---|
948 | if (!isset($arrForm[$delkey])) $arrForm[$delkey] = null; |
---|
949 | |
---|
950 | if ((isset($arrForm[$keyname]) && !empty($arrForm[$keyname])) && $arrForm[$delkey] != 1) { |
---|
951 | $objProduct = new SC_Product_Ex(); |
---|
952 | $arrRecommend[$i] = $objProduct->getDetail($arrForm[$keyname]); |
---|
953 | $arrRecommend[$i]['product_id'] = $arrForm[$keyname]; |
---|
954 | $arrRecommend[$i]['comment'] = $arrForm[$commentkey]; |
---|
955 | } |
---|
956 | } |
---|
957 | return $arrRecommend; |
---|
958 | } |
---|
959 | |
---|
960 | /** |
---|
961 | * 表示用カテゴリマスターデータ配列を取得する |
---|
962 | * - 編集モード |
---|
963 | * |
---|
964 | * @param void |
---|
965 | * @return array カテゴリマスターデータ配列 |
---|
966 | */ |
---|
967 | function lfGetCategoryList_Edit() |
---|
968 | { |
---|
969 | $objDb = new SC_Helper_DB_Ex(); |
---|
970 | $arrCategoryList = array(); |
---|
971 | |
---|
972 | list($arrCatVal, $arrCatOut) = $objDb->sfGetLevelCatList(false); |
---|
973 | for ($i = 0; $i < count($arrCatVal); $i++) { |
---|
974 | $arrCategoryList[$arrCatVal[$i]] = $arrCatOut[$i]; |
---|
975 | } |
---|
976 | |
---|
977 | return $arrCategoryList; |
---|
978 | } |
---|
979 | |
---|
980 | /** |
---|
981 | * ページonload用JavaScriptを取得する |
---|
982 | * - 入力画面 |
---|
983 | * |
---|
984 | * @param string $anchor_hash アンカー用ハッシュ文字列(省略可) |
---|
985 | * @return string ページonload用JavaScript |
---|
986 | */ |
---|
987 | function lfSetOnloadJavaScript_InputPage($anchor_hash = '') |
---|
988 | { |
---|
989 | return "fnCheckStockLimit('" . DISABLED_RGB . "');fnInitSelect('category_id_unselect'); fnMoveSelect('category_id_unselect', 'category_id');" . $anchor_hash; |
---|
990 | } |
---|
991 | |
---|
992 | /** |
---|
993 | * DBに商品データを登録する |
---|
994 | * |
---|
995 | * @param object $objUpFile SC_UploadFileインスタンス |
---|
996 | * @param object $objDownFile SC_UploadFileインスタンス |
---|
997 | * @param array $arrList フォーム入力パラメーター配列 |
---|
998 | * @return integer 登録商品ID |
---|
999 | */ |
---|
1000 | function lfRegistProduct(&$objUpFile, &$objDownFile, $arrList) |
---|
1001 | { |
---|
1002 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
1003 | $objDb = new SC_Helper_DB_Ex(); |
---|
1004 | |
---|
1005 | // 配列の添字を定義 |
---|
1006 | $checkArray = array('name', 'status', |
---|
1007 | 'main_list_comment', 'main_comment', |
---|
1008 | 'deliv_fee', 'comment1', 'comment2', 'comment3', |
---|
1009 | 'comment4', 'comment5', 'comment6', |
---|
1010 | 'sale_limit', 'deliv_date_id', 'maker_id', 'note'); |
---|
1011 | $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray); |
---|
1012 | |
---|
1013 | // INSERTする値を作成する。 |
---|
1014 | $sqlval['name'] = $arrList['name']; |
---|
1015 | $sqlval['status'] = $arrList['status']; |
---|
1016 | $sqlval['main_list_comment'] = $arrList['main_list_comment']; |
---|
1017 | $sqlval['main_comment'] = $arrList['main_comment']; |
---|
1018 | $sqlval['comment1'] = $arrList['comment1']; |
---|
1019 | $sqlval['comment2'] = $arrList['comment2']; |
---|
1020 | $sqlval['comment3'] = $arrList['comment3']; |
---|
1021 | $sqlval['comment4'] = $arrList['comment4']; |
---|
1022 | $sqlval['comment5'] = $arrList['comment5']; |
---|
1023 | $sqlval['comment6'] = $arrList['comment6']; |
---|
1024 | $sqlval['deliv_date_id'] = $arrList['deliv_date_id']; |
---|
1025 | $sqlval['maker_id'] = $arrList['maker_id']; |
---|
1026 | $sqlval['note'] = $arrList['note']; |
---|
1027 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1028 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
1029 | $arrRet = $objUpFile->getDBFileList(); |
---|
1030 | $sqlval = array_merge($sqlval, $arrRet); |
---|
1031 | |
---|
1032 | for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { |
---|
1033 | $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt]; |
---|
1034 | $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt]; |
---|
1035 | } |
---|
1036 | |
---|
1037 | $objQuery->begin(); |
---|
1038 | |
---|
1039 | // 新規登録(複製時を含む) |
---|
1040 | if ($arrList['product_id'] == '') { |
---|
1041 | $product_id = $objQuery->nextVal('dtb_products_product_id'); |
---|
1042 | $sqlval['product_id'] = $product_id; |
---|
1043 | |
---|
1044 | // INSERTの実行 |
---|
1045 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1046 | $objQuery->insert('dtb_products', $sqlval); |
---|
1047 | |
---|
1048 | $arrList['product_id'] = $product_id; |
---|
1049 | |
---|
1050 | // カテゴリを更新 |
---|
1051 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
1052 | |
---|
1053 | // 複製商品の場合には規格も複製する |
---|
1054 | if ($arrList['copy_product_id'] != '' && SC_Utils_Ex::sfIsInt($arrList['copy_product_id'])) { |
---|
1055 | if (!$arrList['has_product_class']) { |
---|
1056 | //規格なしの場合、複製は価格等の入力が発生しているため、その内容で追加登録を行う |
---|
1057 | $this->lfCopyProductClass($arrList, $objQuery); |
---|
1058 | } else { |
---|
1059 | //規格がある場合の複製は複製元の内容で追加登録を行う |
---|
1060 | // dtb_products_class のカラムを取得 |
---|
1061 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
1062 | $arrColList = $objQuery->listTableFields('dtb_products_class'); |
---|
1063 | $arrColList_tmp = array_flip($arrColList); |
---|
1064 | |
---|
1065 | // 複製しない列 |
---|
1066 | unset($arrColList[$arrColList_tmp['product_class_id']]); //規格ID |
---|
1067 | unset($arrColList[$arrColList_tmp['product_id']]); //商品ID |
---|
1068 | unset($arrColList[$arrColList_tmp['create_date']]); |
---|
1069 | |
---|
1070 | // 複製元商品の規格データ取得 |
---|
1071 | $col = SC_Utils_Ex::sfGetCommaList($arrColList); |
---|
1072 | $table = 'dtb_products_class'; |
---|
1073 | $where = 'product_id = ?'; |
---|
1074 | $objQuery->setOrder('product_class_id'); |
---|
1075 | $arrProductsClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id'])); |
---|
1076 | |
---|
1077 | // 規格データ登録 |
---|
1078 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
1079 | foreach ($arrProductsClass as $arrData) { |
---|
1080 | $sqlval = $arrData; |
---|
1081 | $sqlval['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
1082 | $sqlval['deliv_fee'] = $arrList['deliv_fee']; |
---|
1083 | $sqlval['point_rate'] = $arrList['point_rate']; |
---|
1084 | $sqlval['sale_limit'] = $arrList['sale_limit']; |
---|
1085 | $sqlval['product_id'] = $product_id; |
---|
1086 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1087 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1088 | $objQuery->insert($table, $sqlval); |
---|
1089 | } |
---|
1090 | } |
---|
1091 | } |
---|
1092 | // 更新 |
---|
1093 | } else { |
---|
1094 | $product_id = $arrList['product_id']; |
---|
1095 | // 削除要求のあった既存ファイルの削除 |
---|
1096 | $arrRet = $this->lfGetProductData_FromDB($arrList['product_id']); |
---|
1097 | // TODO: SC_UploadFile::deleteDBFileの画像削除条件見直し要 |
---|
1098 | $objImage = new SC_Image_Ex($objUpFile->temp_dir); |
---|
1099 | $arrKeyName = $objUpFile->keyname; |
---|
1100 | $arrSaveFile = $objUpFile->save_file; |
---|
1101 | $arrImageKey = array(); |
---|
1102 | foreach ($arrKeyName as $key => $keyname) { |
---|
1103 | if ($arrRet[$keyname] && !$arrSaveFile[$key]) { |
---|
1104 | $arrImageKey[] = $keyname; |
---|
1105 | $has_same_image = $this->lfHasSameProductImage($arrList['product_id'], $arrImageKey, $arrRet[$keyname]); |
---|
1106 | if (!$has_same_image) { |
---|
1107 | $objImage->deleteImage($arrRet[$keyname], $objUpFile->save_dir); |
---|
1108 | } |
---|
1109 | } |
---|
1110 | } |
---|
1111 | $objDownFile->deleteDBDownFile($arrRet); |
---|
1112 | // UPDATEの実行 |
---|
1113 | $where = 'product_id = ?'; |
---|
1114 | $objQuery->update('dtb_products', $sqlval, $where, array($product_id)); |
---|
1115 | |
---|
1116 | // カテゴリを更新 |
---|
1117 | $objDb->updateProductCategories($arrList['category_id'], $product_id); |
---|
1118 | } |
---|
1119 | |
---|
1120 | // 商品登録の時は規格を生成する。複製の場合は規格も複製されるのでこの処理は不要。 |
---|
1121 | if ($arrList['copy_product_id'] == '') { |
---|
1122 | // 規格登録 |
---|
1123 | if ($objDb->sfHasProductClass($product_id)) { |
---|
1124 | // 規格あり商品(商品規格テーブルのうち、商品登録フォームで設定するパラメーターのみ更新) |
---|
1125 | $this->lfUpdateProductClass($arrList); |
---|
1126 | } else { |
---|
1127 | // 規格なし商品(商品規格テーブルの更新) |
---|
1128 | $this->lfInsertDummyProductClass($arrList); |
---|
1129 | } |
---|
1130 | } |
---|
1131 | |
---|
1132 | // 商品ステータス設定 |
---|
1133 | $objProduct = new SC_Product_Ex(); |
---|
1134 | $objProduct->setProductStatus($product_id, $arrList['product_status']); |
---|
1135 | |
---|
1136 | // 関連商品登録 |
---|
1137 | $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id); |
---|
1138 | |
---|
1139 | $objQuery->commit(); |
---|
1140 | return $product_id; |
---|
1141 | } |
---|
1142 | |
---|
1143 | /** |
---|
1144 | * 規格を設定していない商品を商品規格テーブルに登録 |
---|
1145 | * |
---|
1146 | * @param array $arrList |
---|
1147 | * @return void |
---|
1148 | */ |
---|
1149 | function lfInsertDummyProductClass($arrList) |
---|
1150 | { |
---|
1151 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
1152 | $objDb = new SC_Helper_DB_Ex(); |
---|
1153 | |
---|
1154 | // 配列の添字を定義 |
---|
1155 | $checkArray = array('product_class_id', 'product_id', 'product_code', 'stock', 'stock_unlimited', 'price01', 'price02', 'sale_limit', 'deliv_fee', 'point_rate' ,'product_type_id', 'down_filename', 'down_realfilename'); |
---|
1156 | $sqlval = SC_Utils_Ex::sfArrayIntersectKeys($arrList, $checkArray); |
---|
1157 | $sqlval = SC_Utils_Ex::arrayDefineIndexes($sqlval, $checkArray); |
---|
1158 | |
---|
1159 | $sqlval['stock_unlimited'] = $sqlval['stock_unlimited'] ? UNLIMITED_FLG_UNLIMITED : UNLIMITED_FLG_LIMITED; |
---|
1160 | $sqlval['creator_id'] = strlen($_SESSION['member_id']) >= 1 ? $_SESSION['member_id'] : '0'; |
---|
1161 | |
---|
1162 | if (strlen($sqlval['product_class_id']) == 0) { |
---|
1163 | $sqlval['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
1164 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1165 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1166 | // INSERTの実行 |
---|
1167 | $objQuery->insert('dtb_products_class', $sqlval); |
---|
1168 | } else { |
---|
1169 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1170 | // UPDATEの実行 |
---|
1171 | $objQuery->update('dtb_products_class', $sqlval, 'product_class_id = ?', array($sqlval['product_class_id'])); |
---|
1172 | |
---|
1173 | } |
---|
1174 | } |
---|
1175 | |
---|
1176 | /** |
---|
1177 | * 規格を設定している商品の商品規格テーブルを更新 |
---|
1178 | * (deliv_fee, point_rate, sale_limit) |
---|
1179 | * |
---|
1180 | * @param array $arrList |
---|
1181 | * @return void |
---|
1182 | */ |
---|
1183 | function lfUpdateProductClass($arrList) |
---|
1184 | { |
---|
1185 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
1186 | $sqlval = array(); |
---|
1187 | |
---|
1188 | $sqlval['deliv_fee'] = $arrList['deliv_fee']; |
---|
1189 | $sqlval['point_rate'] = $arrList['point_rate']; |
---|
1190 | $sqlval['sale_limit'] = $arrList['sale_limit']; |
---|
1191 | $where = 'product_id = ?'; |
---|
1192 | $objQuery->update('dtb_products_class', $sqlval, $where, array($arrList['product_id'])); |
---|
1193 | } |
---|
1194 | |
---|
1195 | /** |
---|
1196 | * DBに関連商品データを登録する |
---|
1197 | * |
---|
1198 | * @param object $objQuery SC_Queryインスタンス |
---|
1199 | * @param string $arrList フォーム入力パラメーター配列 |
---|
1200 | * @param integer $product_id 登録する商品ID |
---|
1201 | * @return void |
---|
1202 | */ |
---|
1203 | function lfInsertRecommendProducts(&$objQuery, $arrList, $product_id) |
---|
1204 | { |
---|
1205 | // 一旦関連商品をすべて削除する |
---|
1206 | $objQuery->delete('dtb_recommend_products', 'product_id = ?', array($product_id)); |
---|
1207 | $sqlval['product_id'] = $product_id; |
---|
1208 | $rank = RECOMMEND_PRODUCT_MAX; |
---|
1209 | for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { |
---|
1210 | $keyname = 'recommend_id' . $i; |
---|
1211 | $commentkey = 'recommend_comment' . $i; |
---|
1212 | $deletekey = 'recommend_delete' . $i; |
---|
1213 | |
---|
1214 | if (!isset($arrList[$deletekey])) $arrList[$deletekey] = null; |
---|
1215 | |
---|
1216 | if ($arrList[$keyname] != '' && $arrList[$deletekey] != '1') { |
---|
1217 | $sqlval['recommend_product_id'] = $arrList[$keyname]; |
---|
1218 | $sqlval['comment'] = $arrList[$commentkey]; |
---|
1219 | $sqlval['rank'] = $rank; |
---|
1220 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
1221 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1222 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1223 | $objQuery->insert('dtb_recommend_products', $sqlval); |
---|
1224 | $rank--; |
---|
1225 | } |
---|
1226 | } |
---|
1227 | } |
---|
1228 | |
---|
1229 | /** |
---|
1230 | * 規格データをコピーする |
---|
1231 | * |
---|
1232 | * @param array $arrList フォーム入力パラメーター配列 |
---|
1233 | * @param object $objQuery SC_Queryインスタンス |
---|
1234 | * @return boolean エラーフラグ |
---|
1235 | */ |
---|
1236 | function lfCopyProductClass($arrList, &$objQuery) |
---|
1237 | { |
---|
1238 | // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得) |
---|
1239 | $col = '*'; |
---|
1240 | $table = 'dtb_products_class'; |
---|
1241 | $where = 'product_id = ?'; |
---|
1242 | $arrProductClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id'])); |
---|
1243 | |
---|
1244 | //トランザクション開始 |
---|
1245 | $objQuery->begin(); |
---|
1246 | $err_flag = false; |
---|
1247 | //非編集項目は複製、編集項目は上書きして登録 |
---|
1248 | foreach ($arrProductClass as $records) { |
---|
1249 | foreach ($records as $key => $value) { |
---|
1250 | if (isset($arrList[$key])) { |
---|
1251 | switch ($key) { |
---|
1252 | case 'stock_unlimited': |
---|
1253 | $records[$key] = (int)$arrList[$key]; |
---|
1254 | break; |
---|
1255 | default: |
---|
1256 | $records[$key] = $arrList[$key]; |
---|
1257 | break; |
---|
1258 | } |
---|
1259 | } |
---|
1260 | } |
---|
1261 | |
---|
1262 | $records['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); |
---|
1263 | $records['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
1264 | $records['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
1265 | $objQuery->insert($table, $records); |
---|
1266 | //エラー発生時は中断 |
---|
1267 | if ($objQuery->isError()) { |
---|
1268 | $err_flag = true; |
---|
1269 | continue; |
---|
1270 | } |
---|
1271 | } |
---|
1272 | //トランザクション終了 |
---|
1273 | if ($err_flag) { |
---|
1274 | $objQuery->rollback(); |
---|
1275 | } else { |
---|
1276 | $objQuery->commit(); |
---|
1277 | } |
---|
1278 | return !$err_flag; |
---|
1279 | } |
---|
1280 | |
---|
1281 | /** |
---|
1282 | * リネームする際は、自動生成される画像名に一意となるように、Suffixを付ける |
---|
1283 | * |
---|
1284 | * @param string $to_key |
---|
1285 | * @return string |
---|
1286 | */ |
---|
1287 | function lfGetAddSuffix($to_key) |
---|
1288 | { |
---|
1289 | if ( IMAGE_RENAME === true) return; |
---|
1290 | |
---|
1291 | // 自動生成される画像名 |
---|
1292 | $dist_name = ''; |
---|
1293 | switch ($to_key) { |
---|
1294 | case 'main_list_image': |
---|
1295 | $dist_name = '_s'; |
---|
1296 | break; |
---|
1297 | case 'main_image': |
---|
1298 | $dist_name = '_m'; |
---|
1299 | break; |
---|
1300 | default: |
---|
1301 | $arrRet = explode('sub_image', $to_key); |
---|
1302 | $dist_name = '_sub' .$arrRet[1]; |
---|
1303 | break; |
---|
1304 | } |
---|
1305 | return $dist_name; |
---|
1306 | } |
---|
1307 | |
---|
1308 | /** |
---|
1309 | * サブ情報の登録があるかを取得する |
---|
1310 | * タイトル, コメント, 画像のいずれかに登録があれば「あり」と判定する |
---|
1311 | * |
---|
1312 | * @param array $arrSubProductData サブ情報配列 |
---|
1313 | * @return boolean true: サブ情報あり, false: サブ情報なし |
---|
1314 | */ |
---|
1315 | function hasSubProductData($arrSubProductData) |
---|
1316 | { |
---|
1317 | $has_subproduct_data = false; |
---|
1318 | |
---|
1319 | for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) { |
---|
1320 | if (SC_Utils_Ex::isBlank($arrSubProductData['sub_title'.$i]) == false |
---|
1321 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_comment'.$i]) == false |
---|
1322 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_image'.$i]) == false |
---|
1323 | || SC_Utils_Ex::isBlank($arrSubProductData['sub_large_image'.$i]) == false |
---|
1324 | || SC_Utils_Ex::isBlank($arrSubProductData['temp_sub_image'.$i]) == false |
---|
1325 | || SC_Utils_Ex::isBlank($arrSubProductData['temp_sub_large_image'.$i]) == false |
---|
1326 | ) { |
---|
1327 | $has_subproduct_data = true; |
---|
1328 | break; |
---|
1329 | } |
---|
1330 | } |
---|
1331 | |
---|
1332 | return $has_subproduct_data; |
---|
1333 | } |
---|
1334 | |
---|
1335 | /** |
---|
1336 | * アンカーハッシュ文字列を取得する |
---|
1337 | * アンカーキーをサニタイジングする |
---|
1338 | * |
---|
1339 | * @param string $anchor_key フォーム入力パラメーターで受け取ったアンカーキー |
---|
1340 | * @return <type> |
---|
1341 | */ |
---|
1342 | function getAnchorHash($anchor_key) |
---|
1343 | { |
---|
1344 | if ($anchor_key != '') { |
---|
1345 | return "location.hash='#" . htmlspecialchars($anchor_key) . "'"; |
---|
1346 | } else { |
---|
1347 | return ''; |
---|
1348 | } |
---|
1349 | } |
---|
1350 | } |
---|