source: branches/beta/html/admin/products/product.php @ 16696

Revision 16696, 22.3 KB checked in by adachi, 15 years ago (diff)

未定義関数の修正

Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8
9class LC_Page {
10    var $arrCatList;
11    var $arrSRANK;
12    var $arrForm;
13    var $arrSubList;
14    var $arrHidden;
15    var $arrTempImage;
16    var $arrSaveImage;
17    var $tpl_mode;
18    function LC_Page() {
19        $this->tpl_mainpage = 'products/product.tpl';
20        $this->tpl_subnavi = 'products/subnavi.tpl';
21        $this->tpl_mainno = 'products';
22        $this->tpl_subno = 'product';
23        $this->tpl_subtitle = '¾¦ÉÊÅÐÏ¿';
24        global $arrSRANK;
25        $this->arrSRANK = $arrSRANK;
26        global $arrDISP;
27        $this->arrDISP = $arrDISP;
28        global $arrCLASS;
29        $this->arrCLASS = $arrCLASS;
30        global $arrSTATUS;
31        $this->arrSTATUS = $arrSTATUS;
32        global $arrSTATUS_VALUE;
33        $this->arrSTATUS_VALUE = $arrSTATUS_VALUE;
34        global $arrSTATUS_IMAGE;
35        $this->arrSTATUS_IMAGE = $arrSTATUS_IMAGE;
36        global $arrDELIVERYDATE;
37        $this->arrDELIVERYDATE = $arrDELIVERYDATE;
38        $this->tpl_nonclass = true;
39        $this->tpl_movilink_flg
40            = function_exists('sfIsMoviLink') ? sfIsMoviLink() : '';
41    }
42}
43
44$objPage = new LC_Page();
45$objView = new SC_AdminView();
46$objSiteInfo = new SC_SiteInfo();
47$objQuery = new SC_Query();
48
49// ǧ¾Ú²ÄÈݤÎȽÄê
50$objSess = new SC_Session();
51sfIsSuccess($objSess);
52
53// ¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹
54$objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR, FTP_IMAGE_TEMP_DIR, FTP_IMAGE_SAVE_DIR, MULTI_WEB_SERVER_MODE);
55
56// ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
57lfInitFile();
58// Hidden¤«¤é¤Î¥Ç¡¼¥¿¤ò°ú¤­·Ñ¤°
59$objUpFile->setHiddenFileList($_POST);
60
61// ¸¡º÷¥Ñ¥é¥á¡¼¥¿¤Î°ú¤­·Ñ¤®
62foreach ($_POST as $key => $val) {
63    if (ereg("^search_", $key)) {
64        $objPage->arrSearchHidden[$key] = $val;
65    }
66}
67
68// FORM¥Ç¡¼¥¿¤Î°ú¤­·Ñ¤®
69$objPage->arrForm = $_POST;
70
71switch($_POST['mode']) {
72// ¸¡º÷²èÌ̤«¤é¤ÎÊÔ½¸
73case 'pre_edit':
74case 'copy' :
75    // ÊÔ½¸»þ
76    if(sfIsInt($_POST['product_id'])){
77        // DB¤«¤é¾¦ÉʾðÊó¤ÎÆɹþ
78        $arrForm = lfGetProduct($_POST['product_id']);
79        // DB¥Ç¡¼¥¿¤«¤é²èÁü¥Õ¥¡¥¤¥ë̾¤ÎÆɹþ
80        $objUpFile->setDBFileList($arrForm);
81
82        if($_POST['mode'] == "copy"){
83            $arrForm["copy_product_id"] = $arrForm["product_id"];
84            $arrForm["product_id"] = "";
85            // ²èÁü¥Õ¥¡¥¤¥ë¤Î¥³¥Ô¡¼
86            $arrKey = $objUpFile->keyname;
87            $arrSaveFile = $objUpFile->save_file;
88
89            foreach($arrSaveFile as $key => $val){
90                lfMakeScaleImage($arrKey[$key], $arrKey[$key], true);
91            }
92        }
93        $objPage->arrForm = $arrForm;
94
95        // ¾¦ÉÊ¥¹¥Æ¡¼¥¿¥¹¤ÎÊÑ´¹
96        $arrRet = sfSplitCBValue($objPage->arrForm['product_flag'], "product_flag");
97        $objPage->arrForm = array_merge($objPage->arrForm, $arrRet);
98        // DB¤«¤é¤ª¤¹¤¹¤á¾¦ÉʤÎÆɤ߹þ¤ß
99        $objPage->arrRecommend = lfPreGetRecommendProducts($_POST['product_id']);
100
101        // µ¬³ÊÅÐÏ¿¤¢¤ê¤Ê¤·È½Äê
102        $objPage->tpl_nonclass = lfCheckNonClass($_POST['product_id']);
103        lfProductPage();        // ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸
104    }
105    break;
106// ¾¦ÉÊÅÐÏ¿¡¦ÊÔ½¸
107case 'edit':
108    // µ¬³ÊÅÐÏ¿¤¢¤ê¤Ê¤·È½Äê
109    $tpl_nonclass = lfCheckNonClass($_POST['product_id']);
110
111    if($_POST['product_id'] == "" and sfIsInt($_POST['copy_product_id'])){
112        $tpl_nonclass = lfCheckNonClass($_POST['copy_product_id']);
113    }
114    $objPage->tpl_nonclass = $tpl_nonclass;
115
116    // ÆþÎÏÃͤÎÊÑ´¹
117    $objPage->arrForm = lfConvertParam($objPage->arrForm);
118    // ¥¨¥é¡¼¥Á¥§¥Ã¥¯
119    $objPage->arrErr = lfErrorCheck($objPage->arrForm);
120    // ¥Õ¥¡¥¤¥ë¸ºß¥Á¥§¥Ã¥¯
121    $objPage->arrErr = array_merge((array)$objPage->arrErr, (array)$objUpFile->checkEXISTS());
122    // ¥¨¥é¡¼¤Ê¤·¤Î¾ì¹ç
123    if(count($objPage->arrErr) == 0) {
124        lfProductConfirmPage(); // ³Îǧ¥Ú¡¼¥¸
125    } else {
126        lfProductPage();        // ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸
127    }
128    break;
129// ³Îǧ¥Ú¡¼¥¸¤«¤é´°Î»¥Ú¡¼¥¸¤Ø
130case 'complete':
131    $objPage->tpl_mainpage = 'products/complete.tpl';
132
133    $objPage->tpl_product_id = lfRegistProduct($_POST);     // ¥Ç¡¼¥¿ÅÐÏ¿
134
135    $objQuery = new SC_Query();
136    // ·ï¿ô¥«¥¦¥ó¥È¥Ð¥Ã¥Á¼Â¹Ô
137    sfCategory_Count($objQuery);
138    // °ì»þ¥Õ¥¡¥¤¥ë¤òËÜÈ֥ǥ£¥ì¥¯¥È¥ê¤Ë°ÜÆ°¤¹¤ë
139    $objUpFile->moveTempFile();
140
141    break;
142// ²èÁü¤Î¥¢¥Ã¥×¥í¡¼¥É
143case 'upload_image':
144    // ¥Õ¥¡¥¤¥ë¸ºß¥Á¥§¥Ã¥¯
145    $objPage->arrErr = array_merge((array)$objPage->arrErr, (array)$objUpFile->checkEXISTS($_POST['image_key']));
146    // ²èÁüÊݸ½èÍý
147    $objPage->arrErr[$_POST['image_key']] = $objUpFile->makeTempFile($_POST['image_key']);
148
149    // Ãæ¡¢¾®²èÁüÀ¸À®
150    lfSetScaleImage();
151
152    lfProductPage(); // ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸
153    break;
154// ²èÁü¤Îºï½ü
155case 'delete_image':
156    $objUpFile->deleteFile($_POST['image_key']);
157    lfProductPage(); // ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸
158    break;
159// ³Îǧ¥Ú¡¼¥¸¤«¤é¤ÎÌá¤ê
160case 'confirm_return':
161    // µ¬³ÊÅÐÏ¿¤¢¤ê¤Ê¤·È½Äê
162    $objPage->tpl_nonclass = lfCheckNonClass($_POST['product_id']);
163    lfProductPage();        // ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸
164    break;
165// ¤ª¤¹¤¹¤á¾¦ÉÊÁªÂò
166case 'recommend_select' :
167    lfProductPage();        // ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸
168    break;
169default:
170    // ¸ø³«¡¦Èó¸ø³«¤Î¥Ç¥Õ¥©¥ë¥ÈÃÍ
171    $objPage->arrForm['status'] = DEFAULT_PRODUCT_DISP;
172    lfProductPage();        // ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸
173    break;
174}
175
176if($_POST['mode'] != 'pre_edit') {
177    // ¤ª¤¹¤¹¤á¾¦ÉʤÎÆɤ߹þ¤ß
178    $objPage->arrRecommend = lfGetRecommendProducts();
179}
180
181// ´ðËܾðÊó¤òÅϤ¹
182$objPage->arrInfo = $objSiteInfo->data;
183
184// ¥µ¥Ö¾ðÊó¤ÎÆþÎϤ¬¤¢¤ë¤«¤É¤¦¤«¥Á¥§¥Ã¥¯¤¹¤ë
185$sub_find = false;
186for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
187    if( $objPage->arrForm['sub_title'.$cnt] != "" ||
188        $objPage->arrForm['sub_comment'.$cnt] != "" ||
189        $objPage->arrForm['sub_image'.$cnt] != "" ||
190        $objPage->arrForm['sub_large_image'.$cnt] != "" ||
191        is_array($objPage->arrFile['sub_image'.$cnt]) ||
192        is_array($objPage->arrFile['sub_large_image'.$cnt])) {
193        $sub_find = true;
194        break;
195    }
196}
197// ¥µ¥Ö¾ðÊóɽ¼¨¡¦Èóɽ¼¨¤Î¥Á¥§¥Ã¥¯¤Ë»ÈÍѤ¹¤ë¡£
198$objPage->sub_find = $sub_find;
199
200$objView->assignobj($objPage);
201$objView->display(MAIN_FRAME);
202//-----------------------------------------------------------------------------------------------------------------------------
203
204/* ¤ª¤¹¤¹¤á¾¦ÉʤÎÆɤ߹þ¤ß */
205function lfGetRecommendProducts() {
206    global $objPage;
207    $objQuery = new SC_Query();
208
209    for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {
210        $keyname = "recommend_id" . $i;
211        $delkey = "recommend_delete" . $i;
212        $commentkey = "recommend_comment" . $i;
213
214        if($_POST[$keyname] != "" && $_POST[$delkey] != 1) {
215            $arrRet = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($_POST[$keyname]));
216            $arrRecommend[$i] = $arrRet[0];
217            $arrRecommend[$i]['product_id'] = $_POST[$keyname];
218            $arrRecommend[$i]['comment'] = $objPage->arrForm[$commentkey];
219        }
220    }
221    return $arrRecommend;
222}
223
224/* ¤ª¤¹¤¹¤á¾¦ÉʤÎÅÐÏ¿ */
225function lfInsertRecommendProducts($objQuery, $arrList, $product_id) {
226    // °ìö¥ª¥¹¥¹¥á¾¦Éʤò¤¹¤Ù¤Æºï½ü¤¹¤ë
227    $objQuery->delete("dtb_recommend_products", "product_id = ?", array($product_id));
228    $sqlval['product_id'] = $product_id;
229    $rank = RECOMMEND_PRODUCT_MAX;
230    for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {
231        $keyname = "recommend_id" . $i;
232        $commentkey = "recommend_comment" . $i;
233        $deletekey = "recommend_delete" . $i;
234        if($arrList[$keyname] != "" && $arrList[$deletekey] != '1') {
235            $sqlval['recommend_product_id'] = $arrList[$keyname];
236            $sqlval['comment'] = $arrList[$commentkey];
237            $sqlval['rank'] = $rank;
238            $sqlval['creator_id'] = $_SESSION['member_id'];
239            $sqlval['create_date'] = "now()";
240            $sqlval['update_date'] = "now()";
241            $objQuery->insert("dtb_recommend_products", $sqlval);
242            $rank--;
243        }
244    }
245}
246
247/* ÅÐÏ¿ºÑ¤ß¤ª¤¹¤¹¤á¾¦ÉʤÎÆɤ߹þ¤ß */
248function lfPreGetRecommendProducts($product_id) {
249    $objQuery = new SC_Query();
250    $objQuery->setorder("rank DESC");
251    $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
252    $max = count($arrRet);
253    $no = 1;
254
255    for($i = 0; $i < $max; $i++) {
256        $arrProductInfo = $objQuery->select("main_list_image, product_code_min, name", "vw_products_allclass AS allcls", "product_id = ?", array($arrRet[$i]['recommend_product_id']));
257        $arrRecommend[$no] = $arrProductInfo[0];
258        $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
259        $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
260        $no++;
261    }
262    return $arrRecommend;
263}
264
265/* ¾¦ÉʾðÊó¤ÎÆɤ߹þ¤ß */
266function lfGetProduct($product_id) {
267    $objQuery = new SC_Query();
268    $col = "*";
269    $table = "vw_products_nonclass AS noncls ";
270    $where = "product_id = ?";
271
272    // view¤â¹Ê¹þ¤ß(mysqlÂбþ)
273    sfViewWhere("&&noncls_where&&", $where, array($product_id));
274
275    $arrRet = $objQuery->select($col, $table, $where, array($product_id));
276
277    // ¥â¥Ó¥ê¥ó¥¯¤¬Í­¸ú¤Ê¾ì¹ç
278    if(sfIsMoviLink()) {
279        $col = "movilink_net_percent, movilink_net_fix, movilink_draft_text1, movilink_draft_text2, movilink_code1, movilink_kana, movilink_price";
280        $table = "dtb_products";
281        $where = "product_id = ?";
282        $arrMoviLink = $objQuery->select($col, $table, $where, array($product_id));
283        foreach($arrMoviLink[0] as $key => $val) {
284            $arrRet[0][$key] = $val;
285        }
286    }
287
288    return $arrRet[0];
289}
290
291/* ¾¦ÉÊÅÐÏ¿¥Ú¡¼¥¸É½¼¨ÍÑ */
292function lfProductPage() {
293    global $objPage;
294    global $objUpFile;
295
296    // ¥«¥Æ¥´¥ê¤ÎÆɹþ
297    list($objPage->arrCatVal, $objPage->arrCatOut) = sfGetLevelCatList(false);
298
299    if($objPage->arrForm['status'] == "") {
300        $objPage->arrForm['status'] = 1;
301    }
302
303    if(!is_array($objPage->arrForm['product_flag'])) {
304        // ¾¦ÉÊ¥¹¥Æ¡¼¥¿¥¹¤Îʬ³äÆɹþ
305        $objPage->arrForm['product_flag'] = sfSplitCheckBoxes($objPage->arrForm['product_flag']);
306    }
307
308    // HIDDENÍѤËÇÛÎó¤òÅϤ¹¡£
309    $objPage->arrHidden = array_merge((array)$objPage->arrHidden, (array)$objUpFile->getHiddenFileList());
310    // FormÍÑÇÛÎó¤òÅϤ¹¡£
311    $objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
312
313
314    // ¥¢¥ó¥«¡¼¤òÀßÄê
315    if($_POST['image_key'] != ""){
316        $anchor_hash = "location.hash='#" . $_POST['image_key'] . "'";
317    }elseif($_POST['anchor_key'] != ""){
318        $anchor_hash = "location.hash='#" . $_POST['anchor_key'] . "'";
319    }
320
321    $objPage->tpl_onload = "fnCheckSaleLimit('" . DISABLED_RGB . "'); fnCheckStockLimit('" . DISABLED_RGB . "'); " . $anchor_hash;
322}
323
324/* ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½ */
325function lfInitFile() {
326    global $objUpFile;
327    $objUpFile->addFile("°ìÍ÷-¥á¥¤¥ó²èÁü", 'main_list_image', array('jpg', 'gif', 'png'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
328    $objUpFile->addFile("¾ÜºÙ-¥á¥¤¥ó²èÁü", 'main_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
329    $objUpFile->addFile("¾ÜºÙ-¥á¥¤¥ó³ÈÂç²èÁü", 'main_large_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT);
330    for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
331        $objUpFile->addFile("¾ÜºÙ-¥µ¥Ö²èÁü$cnt", "sub_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_WIDTH, NORMAL_SUBIMAGE_HEIGHT);
332        $objUpFile->addFile("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü$cnt", "sub_large_image$cnt", array('jpg', 'gif', 'png'), IMAGE_SIZE, false, LARGE_SUBIMAGE_WIDTH, LARGE_SUBIMAGE_HEIGHT);
333    }
334    $objUpFile->addFile("¾¦ÉÊÈæ³Ó²èÁü", 'file1', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, OTHER_IMAGE1_WIDTH, OTHER_IMAGE1_HEIGHT);
335    $objUpFile->addFile("¾¦Éʾܺ٥ե¡¥¤¥ë", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false);
336}
337
338/* ¾¦ÉʤÎÅÐÏ¿ */
339function lfRegistProduct($arrList) {
340    global $objUpFile;
341    global $arrSTATUS;
342    $objQuery = new SC_Query();
343    $objQuery->begin();
344
345    // INSERT¤¹¤ëÃͤòºîÀ®¤¹¤ë¡£
346    $sqlval['name'] = $arrList['name'];
347    $sqlval['category_id'] = $arrList['category_id'];
348    $sqlval['status'] = $arrList['status'];
349    $sqlval['product_flag'] = $arrList['product_flag'];
350    $sqlval['main_list_comment'] = $arrList['main_list_comment'];
351    $sqlval['main_comment'] = $arrList['main_comment'];
352    $sqlval['point_rate'] = $arrList['point_rate'];
353    $sqlval['deliv_fee'] = $arrList['deliv_fee'];
354    $sqlval['comment1'] = $arrList['comment1'];
355    $sqlval['comment2'] = $arrList['comment2'];
356    $sqlval['comment3'] = $arrList['comment3'];
357    $sqlval['comment4'] = $arrList['comment4'];
358    $sqlval['comment5'] = $arrList['comment5'];
359    $sqlval['comment6'] = $arrList['comment6'];
360    $sqlval['main_list_comment'] = $arrList['main_list_comment'];
361    $sqlval['sale_limit'] = $arrList['sale_limit'];
362    $sqlval['sale_unlimited'] = $arrList['sale_unlimited'];
363    $sqlval['deliv_date_id'] = $arrList['deliv_date_id'];
364    $sqlval['update_date'] = "Now()";
365    $sqlval['creator_id'] = $_SESSION['member_id'];
366
367    // ¥â¥Ó¥ê¥ó¥¯¤¬Í­¸ú¤Ê¾ì¹ç
368    if(sfIsMoviLink()) {
369        $sqlval['movilink_net_percent'] = $arrList['movilink_net_percent'];
370        $sqlval['movilink_net_fix'] = $arrList['movilink_net_fix'];
371        $sqlval['movilink_draft_text1'] = $arrList['movilink_draft_text1'];
372        $sqlval['movilink_draft_text2'] = $arrList['movilink_draft_text2'];
373        $sqlval['movilink_code1'] = $arrList['movilink_code1'];
374        $sqlval['movilink_kana'] = $arrList['movilink_kana'];
375        $sqlval['movilink_price'] = $arrList['movilink_price'];
376    }
377
378    $arrRet = $objUpFile->getDBFileList();
379    $sqlval = array_merge($sqlval, $arrRet);
380
381    for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
382        $sqlval['sub_title'.$cnt] = $arrList['sub_title'.$cnt];
383        $sqlval['sub_comment'.$cnt] = $arrList['sub_comment'.$cnt];
384    }
385
386    if($arrList['product_id'] == "") {
387        if (DB_TYPE == "pgsql") {
388            $product_id = $objQuery->nextval("dtb_products", "product_id");
389            $sqlval['product_id'] = $product_id;
390        }
391        // ¥«¥Æ¥´¥êÆâ¤ÇºÇÂç¤Î¥é¥ó¥¯¤ò³ä¤êÅö¤Æ¤ë
392        $sqlval['rank'] = $objQuery->max("dtb_products", "rank", "category_id = ?", array($arrList['category_id'])) + 1;
393        // INSERT¤Î¼Â¹Ô
394        $sqlval['create_date'] = "Now()";
395        $objQuery->insert("dtb_products", $sqlval);
396
397        if (DB_TYPE == "mysql") {
398            $product_id = $objQuery->nextval("dtb_products", "product_id");
399            $sqlval['product_id'] = $product_id;
400        }
401
402        // ¥³¥Ô¡¼¾¦Éʤξì¹ç¤Ë¤Ïµ¬³Ê¤â¥³¥Ô¡¼¤¹¤ë
403        if($_POST["copy_product_id"] != "" and sfIsInt($_POST["copy_product_id"])){
404            // dtb_products_class ¤Î¥«¥é¥à¤ò¼èÆÀ
405            $arrColList = sfGetColumnList("dtb_products_class", $objQuery);
406            $arrColList_tmp = array_flip($arrColList);
407
408            // ¥³¥Ô¡¼¤·¤Ê¤¤Îó
409            unset($arrColList[$arrColList_tmp["product_class_id"]]);     //µ¬³ÊID
410            unset($arrColList[$arrColList_tmp["product_id"]]);           //¾¦ÉÊID
411
412            $col = sfGetCommaList($arrColList);
413
414            $objQuery->query("INSERT INTO dtb_products_class (product_id, ". $col .") SELECT ?, " . $col. " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"]));
415
416        }
417
418    } else {
419        $product_id = $arrList['product_id'];
420        // ºï½üÍ×µá¤Î¤¢¤Ã¤¿´û¸¥Õ¥¡¥¤¥ë¤Îºï½ü
421        $arrRet = lfGetProduct($arrList['product_id']);
422        $objUpFile->deleteDBFile($arrRet);
423
424        // ¥«¥Æ¥´¥êÆâ¥é¥ó¥¯¤ÎÄ´À°½èÍý
425        $old_catid = $objQuery->get("dtb_products", "category_id", "product_id = ?", array($arrList['product_id']));
426        sfMoveCatRank($objQuery, "dtb_products", "product_id", "category_id", $old_catid, $arrList['category_id'], $arrList['product_id']);
427
428        // UPDATE¤Î¼Â¹Ô
429        $where = "product_id = ?";
430        $objQuery->update("dtb_products", $sqlval, $where, array($arrList['product_id']));
431    }
432
433    // µ¬³ÊÅÐÏ¿
434    sfInsertProductClass($objQuery, $arrList, $product_id);
435
436    // ¤ª¤¹¤¹¤á¾¦ÉÊÅÐÏ¿
437    lfInsertRecommendProducts($objQuery, $arrList, $product_id);
438
439    $objQuery->commit();
440    return $product_id;
441}
442
443
444/* ¼èÆÀʸ»úÎó¤ÎÊÑ´¹ */
445function lfConvertParam($array) {
446    /*
447     *  ʸ»úÎó¤ÎÊÑ´¹
448     *  K :  ¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹
449     *  C :  ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹
450     *  V :  ÂùÅÀÉÕ¤­¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹
451     *  n :  ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)¡×¤ËÊÑ´¹
452     */
453    // ¿Íʪ´ðËܾðÊó
454
455    // ¥¹¥Ý¥Ã¥È¾¦ÉÊ
456    $arrConvList['name'] = "KVa";
457    $arrConvList['main_list_comment'] = "KVa";
458    $arrConvList['main_comment'] = "KVa";
459    $arrConvList['price01'] = "n";
460    $arrConvList['price02'] = "n";
461    $arrConvList['stock'] = "n";
462    $arrConvList['sale_limit'] = "n";
463    $arrConvList['point_rate'] = "n";
464    $arrConvList['product_code'] = "KVna";
465    $arrConvList['comment1'] = "a";
466    // Á÷ÎÁ¤Î»ØÄê¤Ê¤·
467    $arrConvList['deliv_fee'] = "n";
468
469    // ¾ÜºÙ-¥µ¥Ö
470    for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
471        $arrConvList["sub_title$cnt"] = "KVa";
472    }
473    for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
474        $arrConvList["sub_comment$cnt"] = "KVa";
475    }
476
477    // ¤ª¤¹¤¹¤á¾¦ÉÊ
478    for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) {
479        $arrConvList["recommend_comment$cnt"] = "KVa";
480    }
481
482    // ʸ»úÊÑ´¹
483    foreach ($arrConvList as $key => $val) {
484        // POST¤µ¤ì¤Æ¤­¤¿ÃͤΤßÊÑ´¹¤¹¤ë¡£
485        if(isset($array[$key])) {
486            $array[$key] = mb_convert_kana($array[$key] ,$val);
487        }
488    }
489
490    global $arrSTATUS;
491    $array['product_flag'] = sfMergeCheckBoxes($array['product_flag'], count($arrSTATUS));
492
493    return $array;
494}
495
496// ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯
497function lfErrorCheck($array) {
498    global $objPage;
499    global $arrAllowedTag;
500
501    $objErr = new SC_CheckError($array);
502    $objErr->doFunc(array("¾¦ÉÊ̾", "name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
503    $objErr->doFunc(array("¾¦ÉÊ¥«¥Æ¥´¥ê", "category_id", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
504    $objErr->doFunc(array("°ìÍ÷-¥á¥¤¥ó¥³¥á¥ó¥È", "main_list_comment", MTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
505    $objErr->doFunc(array("¾ÜºÙ-¥á¥¤¥ó¥³¥á¥ó¥È", "main_comment", LLTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
506    $objErr->doFunc(array("¾ÜºÙ-¥á¥¤¥ó¥³¥á¥ó¥È", "main_comment", $arrAllowedTag), array("HTML_TAG_CHECK"));
507    $objErr->doFunc(array("¥Ý¥¤¥ó¥ÈÉÕͿΨ", "point_rate", PERCENTAGE_LEN), array("EXIST_CHECK", "NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
508    $objErr->doFunc(array("¾¦ÉÊÁ÷ÎÁ", "deliv_fee", PRICE_LEN), array("NUM_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
509    $objErr->doFunc(array("¸¡º÷¥ï¡¼¥É", "comment3", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
510    $objErr->doFunc(array("¥á¡¼¥«¡¼URL", "comment1", URL_LEN), array("SPTAB_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK"));
511    $objErr->doFunc(array("ȯÁ÷ÆüÌÜ°Â", "deliv_date_id", INT_LEN), array("NUM_CHECK"));
512
513    // ¥â¥Ó¥ê¥ó¥¯¤¬Í­¸ú¤Ê¾ì¹ç
514    if(function_exists('sfIsMoviLink') && sfIsMoviLink()) {
515        $objErr->doFunc(array("¹­¹ð¼çÍ;¦ÉÊ¥³¡¼¥É", "movilink_code1", STEXT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
516        $objErr->doFunc(array("¾¦ÉÊ̾(¥Õ¥ê¥¬¥Ê)", "movilink_kana", STEXT_LEN), array("EXIST_CHECK", "KANA_CHECK", "MAX_LENGTH_CHECK"));
517        $objErr->doFunc(array("¾¦ÉʲÁ³Ê", "movilink_price", INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
518
519        if($array['movilink_net_fix'] == "") {
520            $objErr->doFunc(array("¾¦ÉÊÊó½·Î¨", "movilink_net_percent", PERCENTAGE_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
521        }
522
523        if($array['movilink_net_percent'] == "") {
524            $objErr->doFunc(array("¾¦ÉÊÊó½·³Û", "movilink_net_fix", INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
525        }
526
527        if($array['movilink_net_fix'] != "" && $array['movilink_net_percent'] != "") {
528            $objErr->arrErr['movilink_net_fix'] = "¢¨ ¾¦ÉÊÊó½·Î¨¤«¾¦ÉÊÊ󽷳ۤΤɤÁ¤é¤«¤òµ­Æþ¤·¤Æ¤¯¤À¤µ¤¤<br>";
529            $objErr->arrErr['movilink_net_percent'] = "¢¨ ¾¦ÉÊÊó½·Î¨¤«¾¦ÉÊÊ󽷳ۤΤɤÁ¤é¤«¤òµ­Æþ¤·¤Æ¤¯¤À¤µ¤¤<br>";
530        }
531        $objErr->doFunc(array("¹­¹ð¥¿¥°¸¶¹Æ1", "movilink_draft_text1", 8), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
532        $objErr->doFunc(array("¹­¹ð¥¿¥°¸¶¹Æ2", "movilink_draft_text2", 8), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
533    }
534
535    if($objPage->tpl_nonclass) {
536        $objErr->doFunc(array("¾¦ÉÊ¥³¡¼¥É", "product_code", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK","MAX_LENGTH_CHECK"));
537        $objErr->doFunc(array("Ä̾ï²Á³Ê", "price01", PRICE_LEN), array("ZERO_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
538        $objErr->doFunc(array("¾¦ÉʲÁ³Ê", "price02", PRICE_LEN), array("EXIST_CHECK", "NUM_CHECK", "ZERO_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
539
540        if($array['stock_unlimited'] != "1") {
541            $objErr->doFunc(array("ºß¸Ë¿ô", "stock", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
542        }
543    }
544
545    if($array['sale_unlimited'] != "1") {
546        $objErr->doFunc(array("¹ØÆþÀ©¸Â", "sale_limit", AMOUNT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
547    }
548
549    if(isset($objErr->arrErr['category_id'])) {
550        // ¼«Æ°ÁªÂò¤òËɤ°¤¿¤á¤Ë¥À¥ß¡¼Ê¸»ú¤òÆþ¤ì¤Æ¤ª¤¯
551        $objPage->arrForm['category_id'] = "#";
552    }
553
554    for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
555        $objErr->doFunc(array("¾ÜºÙ-¥µ¥Ö¥¿¥¤¥È¥ë$cnt", "sub_title$cnt", STEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
556        $objErr->doFunc(array("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È$cnt", "sub_comment$cnt", LLTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
557        $objErr->doFunc(array("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È$cnt", "sub_comment$cnt", $arrAllowedTag),  array("HTML_TAG_CHECK"));
558    }
559
560    for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) {
561        if($_POST["recommend_id$cnt"] != "" && $_POST["recommend_delete$cnt"] != 1) {
562            $objErr->doFunc(array("¤ª¤¹¤¹¤á¾¦ÉÊ¥³¥á¥ó¥È$cnt", "recommend_comment$cnt", LTEXT_LEN), array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
563        }
564    }
565
566    return $objErr->arrErr;
567}
568
569/* ³Îǧ¥Ú¡¼¥¸É½¼¨ÍÑ */
570function lfProductConfirmPage() {
571    global $objPage;
572    global $objUpFile;
573    $objPage->tpl_mainpage = 'products/confirm.tpl';
574    $objPage->arrForm['mode'] = 'complete';
575    // ¥«¥Æ¥´¥ê¤ÎÆɹþ
576    $objPage->arrCatList = sfGetCategoryList();
577    // FormÍÑÇÛÎó¤òÅϤ¹¡£
578    $objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
579}
580
581/* µ¬³Ê¤¢¤êȽÄêÍÑ(µ¬³Ê¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç:TRUE) */
582function lfCheckNonClass($product_id) {
583    if(sfIsInt($product_id)) {
584        $objQuery  = new SC_Query();
585        $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";
586        $count = $objQuery->count("dtb_products_class", $where, array($product_id));
587        if($count > 0) {
588            return false;
589        }
590    }
591    return true;
592}
593
594// ½Ì¾®¤·¤¿²èÁü¤ò¥»¥Ã¥È¤¹¤ë
595function lfSetScaleImage(){
596
597    $subno = str_replace("sub_large_image", "", $_POST['image_key']);
598    switch ($_POST['image_key']){
599        case "main_large_image":
600            // ¾ÜºÙ¥á¥¤¥ó²èÁü
601            lfMakeScaleImage($_POST['image_key'], "main_image");
602        case "main_image":
603            // °ìÍ÷¥á¥¤¥ó²èÁü
604            lfMakeScaleImage($_POST['image_key'], "main_list_image");
605            break;
606        case "sub_large_image" . $subno:
607            // ¥µ¥Ö¥á¥¤¥ó²èÁü
608            lfMakeScaleImage($_POST['image_key'], "sub_image" . $subno);
609            break;
610        default:
611            break;
612    }
613}
614
615// ½Ì¾®²èÁüÀ¸À®
616function lfMakeScaleImage($from_key, $to_key, $forced = false){
617    global $objUpFile;
618    $arrImageKey = array_flip($objUpFile->keyname);
619
620    if($objUpFile->temp_file[$arrImageKey[$from_key]]){
621        $from_path = $objUpFile->temp_dir . $objUpFile->temp_file[$arrImageKey[$from_key]];
622    }elseif($objUpFile->save_file[$arrImageKey[$from_key]]){
623        $from_path = $objUpFile->save_dir . $objUpFile->save_file[$arrImageKey[$from_key]];
624    }else{
625        return "";
626    }
627
628    if(file_exists($from_path)){
629        // ¸µ²èÁü¥µ¥¤¥º¤ò¼èÆÀ
630        list($from_w, $from_h) = getimagesize($from_path);
631
632        // À¸À®Àè¤Î²èÁü¥µ¥¤¥º¤ò¼èÆÀ
633        $to_w = $objUpFile->width[$arrImageKey[$to_key]];
634        $to_h = $objUpFile->height[$arrImageKey[$to_key]];
635
636
637        if($forced) $objUpFile->save_file[$arrImageKey[$to_key]] = "";
638
639        if(($objUpFile->temp_file[$arrImageKey[$to_key]] == "" and $objUpFile->save_file[$arrImageKey[$to_key]] == "")){
640            $path = $objUpFile->makeThumb($from_path, $to_w, $to_h);
641            $objUpFile->temp_file[$arrImageKey[$to_key]] = basename($path);
642        }
643    }else{
644        return "";
645    }
646}
647
648?>
Note: See TracBrowser for help on using the repository browser.