source: branches/beta/html/admin/products/upload_csv.php @ 14922

Revision 14922, 15.5 KB checked in by uehara, 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 */
7mb_language('Japanese');
8
9require_once("../require.php");
10
11class LC_Page {
12    var $arrSession;
13    var $arrCSVErr;
14    function LC_Page() {
15        $this->tpl_mainpage = 'products/upload_csv.tpl';
16        $this->tpl_subnavi = 'products/subnavi.tpl';
17        $this->tpl_mainno = 'products';
18        $this->tpl_subno = 'upload_csv';
19    }
20}
21
22$conn = new SC_DBConn();
23$objPage = new LC_Page();
24$objView = new SC_AdminView();
25$objSess = new SC_Session();
26
27// ǧ¾Ú²ÄÈݤÎȽÄê
28sfIsSuccess($objSess);
29
30// ¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹
31$objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
32// ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
33lfInitFile();
34// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
35$objFormParam = new SC_FormParam();
36// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
37lfInitParam();
38$colmax = $objFormParam->getCount();
39$objFormParam->setHtmlDispNameArray();
40$objPage->arrTitle = $objFormParam->getHtmlDispNameArray();
41
42switch($_POST['mode']) {
43case 'csv_upload':
44    $err = false;
45    // ¥¨¥é¡¼¥Á¥§¥Ã¥¯
46    $arrErr['csv_file'] = $objUpFile->makeTempFile('csv_file');
47   
48    if($arrErr['css_file'] == "") {
49        $arrErr = $objUpFile->checkEXISTS();
50    }
51
52    // ¼Â¹Ô»þ´Ö¤òÀ©¸Â¤·¤Ê¤¤
53    set_time_limit(0);
54   
55    // ½ÐÎϤò¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤·¤Ê¤¤(==ÆüËܸ켫ưÊÑ´¹¤â¤·¤Ê¤¤)
56    ob_end_clean();
57   
58    // IE¤Î¤¿¤á¤Ë256¥Ð¥¤¥È¶õʸ»ú½ÐÎÏ
59    echo str_pad('',256);
60       
61    if($arrErr['csv_file'] == "") {
62        // °ì»þ¥Õ¥¡¥¤¥ë̾¤Î¼èÆÀ
63        $filepath = $objUpFile->getTempFilePath('csv_file');
64        // ¥¨¥ó¥³¡¼¥É
65        $enc_filepath = sfEncodeFile($filepath, CHAR_CODE, CSV_TEMP_DIR);
66       
67        // ¥ì¥³¡¼¥É¿ô¤òÆÀ¤ë
68        $rec_count = lfCSVRecordCount($enc_filepath);       
69       
70        $fp = fopen($enc_filepath, "r");
71        $line = 0;      // ¹Ô¿ô
72        $regist = 0;    // ÅÐÏ¿¿ô
73       
74        $objQuery = new SC_Query();
75        $objQuery->begin();
76       
77        echo "¢£¡¡CSVÅÐÏ¿¿ÊĽ¾õ¶· <br/><br/>\n";               
78               
79        while(!feof($fp) && !$err) {
80            $arrCSV = fgetcsv($fp, CSV_LINE_MAX);
81                       
82            // ¹Ô¥«¥¦¥ó¥È
83            $line++;
84           
85            if($line <= 1) {
86                continue;
87            }           
88                               
89            // ¹àÌÜ¿ô¥«¥¦¥ó¥È
90            $max = count($arrCSV);
91           
92            // ¹àÌÜ¿ô¤¬1°Ê²¼¤Î¾ì¹ç¤Ï̵»ë¤¹¤ë
93            if($max <= 1) {
94                continue;           
95            }
96           
97            // ¹àÌÜ¿ô¥Á¥§¥Ã¥¯
98            if($max != $colmax) {
99                echo "¢¨ ¹àÌÜ¿ô¤¬" . $max . "¸Ä¸¡½Ð¤µ¤ì¤Þ¤·¤¿¡£¹àÌÜ¿ô¤Ï" . $colmax . "¸Ä¤Ë¤Ê¤ê¤Þ¤¹¡£</br>\n";
100                $err = true;
101            } else {
102                // ¥·¡¼¥±¥ó¥¹ÇÛÎó¤ò³ÊǼ¤¹¤ë¡£
103                $objFormParam->setParam($arrCSV, true);
104                $arrRet = $objFormParam->getHashArray();
105                $objFormParam->setParam($arrRet);
106                // ÆþÎÏÃͤÎÊÑ´¹
107                $objFormParam->convParam();
108                // <br>¤Ê¤·¤Ç¥¨¥é¡¼¼èÆÀ¤¹¤ë¡£
109                $arrCSVErr = lfCheckError();
110            }
111           
112            // ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯
113            if(count($arrCSVErr) > 0) {
114                echo "<font color=\"red\">¢£" . $line . "¹ÔÌܤǥ¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£</font></br>\n";
115                foreach($arrCSVErr as $val) {
116                    echo "<font color=\"red\">$val</font></br>\n"; 
117                }
118                $err = true;
119            }
120           
121            if(!$err) {
122                lfRegistProduct($objQuery, $line);
123                $regist++;
124            }
125            $arrParam = $objFormParam->getHashArray();
126 
127            if(!$err) echo $line." / ".$rec_count. "¹ÔÌÜ¡¡¡Ê¾¦ÉÊID¡§".$arrParam['product_id']." / ¾¦ÉÊ̾¡§".$arrParam['name'].")\n<br />";
128            flush();
129        }
130        fclose($fp);
131       
132        if(!$err) {
133            $objQuery->commit();
134            echo "¢£" . $regist . "·ï¤Î¥ì¥³¡¼¥É¤òÅÐÏ¿¤·¤Þ¤·¤¿¡£";
135            // ¾¦ÉÊ·ï¿ô¥«¥¦¥ó¥È´Ø¿ô¤Î¼Â¹Ô
136            sfCategory_Count($objQuery);
137        } else {
138            $objQuery->rollback();
139        }
140    } else {
141        foreach($arrErr as $val) {
142            echo "<font color=\"red\">$val</font></br>\n"; 
143        }
144    }
145    echo "<br/><a href=\"javascript:window.close()\">¢ªÊĤ¸¤ë</a>";
146    flush();
147    exit;   
148    break;
149default:
150    break;
151}
152
153$objView->assignobj($objPage);
154$objView->display(MAIN_FRAME);
155
156//--------------------------------------------------------------------------------------------------------------------------
157
158/*
159 * ´Ø¿ô̾¡§lfInitFile
160 * ÀâÌÀ¡¡¡§¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
161 */function lfInitFile() {
162    global $objUpFile;
163    $objUpFile->addFile("CSV¥Õ¥¡¥¤¥ë", 'csv_file', array('csv'), CSV_SIZE, true, 0, 0, false);
164}
165
166/*
167 * ´Ø¿ô̾¡§lfInitParam
168 * ÀâÌÀ¡¡¡§ÆþÎϾðÊó¤Î½é´ü²½
169 */
170function lfInitParam() {
171    global $objFormParam;
172       
173    $objFormParam->addParam("¾¦ÉÊID", "product_id", INT_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
174    $objFormParam->addParam("¾¦Éʵ¬³ÊID", "product_class_id", INT_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
175   
176    $objFormParam->addParam("µ¬³Ê̾1", "dummy1");
177    $objFormParam->addParam("µ¬³Ê̾2", "dummy2");
178   
179    $objFormParam->addParam("¾¦ÉÊ̾", "name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
180    $objFormParam->addParam("¸ø³«¥Õ¥é¥°(1:¸ø³« 2:Èó¸ø³«)", "status", INT_LEN, "n", array("EXIST_CHECK","MAX_LENGTH_CHECK","NUM_CHECK"));
181    $objFormParam->addParam("¾¦ÉÊ¥¹¥Æ¡¼¥¿¥¹", "product_flag", INT_LEN, "n", array("EXIST_CHECK","MAX_LENGTH_CHECK","NUM_CHECK"));
182    $objFormParam->addParam("¾¦ÉÊ¥³¡¼¥É", "product_code", STEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
183    $objFormParam->addParam(NORMAL_PRICE_TITLE, "price01", PRICE_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
184    $objFormParam->addParam(SALE_PRICE_TITLE, "price02", PRICE_LEN, "n", array("EXIST_CHECK","MAX_LENGTH_CHECK","NUM_CHECK"));
185    $objFormParam->addParam("ºß¸Ë¿ô", "stock", INT_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
186    $objFormParam->addParam("Á÷ÎÁ", "deliv_fee", PRICE_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
187    $objFormParam->addParam("¥Ý¥¤¥ó¥ÈÉÕͿΨ", "point_rate", PERCENTAGE_LEN, "n", array("EXIST_CHECK","MAX_LENGTH_CHECK","NUM_CHECK"));
188    $objFormParam->addParam("¹ØÆþÀ©¸Â", "sale_limit", INT_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
189    $objFormParam->addParam("¥á¡¼¥«¡¼URL", "comment1", URL_LEN, "KVa", array("SPTAB_CHECK","URL_CHECK","MAX_LENGTH_CHECK"));
190    $objFormParam->addParam("¸¡º÷¥ï¡¼¥É", "comment3", LLTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
191    $objFormParam->addParam("°ìÍ÷-¥á¥¤¥ó¥³¥á¥ó¥È", "main_list_comment", LTEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
192    $objFormParam->addParam("°ìÍ÷-¥á¥¤¥ó²èÁü", "main_list_image", LTEXT_LEN, "KVa", array("EXIST_CHECK","FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
193    $objFormParam->addParam("¥á¥¤¥ó¥³¥á¥ó¥È", "main_comment", LTEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
194    $objFormParam->addParam("¥á¥¤¥ó²èÁü", "main_image", LTEXT_LEN, "KVa", array("EXIST_CHECK","FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
195    $objFormParam->addParam("¥á¥¤¥ó³ÈÂç²èÁü", "main_large_image", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
196    $objFormParam->addParam("¥«¥é¡¼Èæ³Ó²èÁü", "file1", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
197    $objFormParam->addParam("¾¦Éʾܺ٥ե¡¥¤¥ë", "file2", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
198    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥¿¥¤¥È¥ë(1)", "sub_title1", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
199    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È(1)", "sub_comment1", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
200    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö²èÁü(1)", "sub_image1", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
201    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü(1)", "sub_large_image1", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
202   
203    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥¿¥¤¥È¥ë(2)", "sub_title2", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
204    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È(2)", "sub_comment2", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
205    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö²èÁü(2)", "sub_image2", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
206    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü(2)", "sub_large_image2", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
207   
208    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥¿¥¤¥È¥ë(3)", "sub_title3", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
209    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È(3)", "sub_comment3", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
210    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö²èÁü(3)", "sub_image3", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
211    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü(3)", "sub_large_image3", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
212       
213    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥¿¥¤¥È¥ë(4)", "sub_title4", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
214    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È(4)", "sub_comment4", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
215    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö²èÁü(4)", "sub_image4", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
216    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü(4)", "sub_large_image4", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
217       
218    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥¿¥¤¥È¥ë(5)", "sub_title5", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
219    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È(5)", "sub_comment5", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
220    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö²èÁü(5)", "sub_image5", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
221    $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü(5)", "sub_large_image5", LTEXT_LEN, "KVa", array("FILE_EXISTS","SPTAB_CHECK","MAX_LENGTH_CHECK"));
222   
223    $objFormParam->addParam("ȯÁ÷ÆüÌÜ°Â", "deliv_date_id", INT_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
224   
225    for ($cnt = 1; $cnt <= RECOMMEND_PRODUCT_MAX; $cnt++) {
226        $objFormParam->addParam("¤ª¤¹¤¹¤á¾¦ÉÊ($cnt)", "recommend_product_id$cnt", INT_LEN, "n", array("MAX_LENGTH_CHECK","NUM_CHECK"));
227        $objFormParam->addParam("¾ÜºÙ-¥µ¥Ö¥³¥á¥ó¥È($cnt)", "recommend_comment$cnt", LTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK"));
228    }
229   
230    $objFormParam->addParam("¾¦ÉÊ¥«¥Æ¥´¥ê", "category_id", STEXT_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
231}
232
233/*
234 * ´Ø¿ô̾¡§lfRegistProduct
235 * °ú¿ô1 ¡§SC_Query¥ª¥Ö¥¸¥§¥¯¥È
236 * ÀâÌÀ¡¡¡§¾¦ÉÊÅÐÏ¿
237 */
238function lfRegistProduct($objQuery, $line = "") {
239    global $objFormParam;
240    $arrRet = $objFormParam->getHashArray();
241   
242    // dtb_products°Ê³°¤ËÅÐÏ¿¤µ¤ì¤ëÃͤò½ü³°¤¹¤ë¡£
243    foreach($arrRet as $key => $val) {
244        switch($key) {
245        case 'product_code':
246        case 'price01':
247        case 'price02':
248        case 'stock':
249        case 'product_class_id':
250        case 'recommend_product_id1':
251        case 'recommend_product_id2':
252        case 'recommend_product_id3':
253        case 'recommend_product_id4':
254        case 'recommend_product_id5':
255        case 'recommend_product_id6':
256        case 'recommend_comment1':
257        case 'recommend_comment2':
258        case 'recommend_comment3':
259        case 'recommend_comment4':
260        case 'recommend_comment5':
261        case 'recommend_comment6':
262            break;
263        default:
264            if(!ereg("^dummy", $key)) {
265                $sqlval[$key] = $val;
266            }
267            break;
268        }
269    }
270    // ÅÐÏ¿»þ´Ö¤òÀ¸À®(DB¤Înow()¤À¤Ècommit¤·¤¿ºÝ¡¢¤¹¤Ù¤ÆƱ°ì¤Î»þ´Ö¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦)
271    $time = date("Y-m-d H:i:s");
272    // Éðʲ¼¤òÀ¸À®
273    if($line != "") {
274        $microtime = sprintf("%06d", $line);
275        $time .= ".$microtime";
276    }   
277    $sqlval['update_date'] = $time;
278    $sqlval['creator_id'] = $_SESSION['member_id'];
279       
280    if($sqlval['sale_limit'] == "") {
281        $sqlval['sale_unlimited'] = '1';
282    } else {
283        $sqlval['sale_unlimited'] = '0';       
284    }
285   
286    if($sqlval['status'] == "") {
287        $sqlval['status'] = 2;
288    }
289
290    if($arrRet['product_id'] != "" && $arrRet['product_class_id'] != "") {
291        // ¥«¥Æ¥´¥êÆâ¥é¥ó¥¯¤ÎÄ´À°½èÍý
292        $old_catid = $objQuery->get("dtb_products", "category_id", "product_id = ?", array($arrRet['product_id']));
293        sfMoveCatRank($objQuery, "dtb_products", "product_id", "category_id", $old_catid, $arrRet['category_id'], $arrRet['product_id']);
294
295        // UPDATE¤Î¼Â¹Ô
296        $where = "product_id = ?";
297        $objQuery->update("dtb_products", $sqlval, $where, array($sqlval['product_id']));
298    } else {
299
300        // ¿·µ¬ÅÐÏ¿
301        $product_id = $objQuery->nextval("dtb_products", "product_id");
302        $sqlval['product_id'] = $product_id;
303        $sqlval['create_date'] = $time;
304       
305        // ¥«¥Æ¥´¥êÆâ¤ÇºÇÂç¤Î¥é¥ó¥¯¤ò³ä¤êÅö¤Æ¤ë
306        $sqlval['rank'] = $objQuery->max("dtb_products", "rank", "category_id = ?", array($arrRet['category_id'])) + 1;
307       
308        // INSERT¤Î¼Â¹Ô
309        $objQuery->insert("dtb_products", $sqlval);
310    }
311   
312    // µ¬³ÊÅÐÏ¿
313    lfRegistProductClass($objQuery, $arrRet, $sqlval['product_id'], $arrRet['product_class_id']);
314   
315    // ¤ª¤¹¤¹¤á¾¦ÉÊÅÐÏ¿
316    $objQuery->delete("dtb_recommend_products", "product_id = ?", array($sqlval['product_id']));
317    for($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {
318        $keyname = "recommend_product_id" . $i;
319        $comment_key = "recommend_comment" . $i;
320        if($arrRet[$keyname] != "") {
321            $arrProduct = $objQuery->select("product_id", "dtb_products", "product_id = ?", array($arrRet[$keyname]));
322            if($arrProduct[0]['product_id'] != "") {
323                $arrval['product_id'] = $sqlval['product_id'];
324                $arrval['recommend_product_id'] = $arrProduct[0]['product_id'];
325                $arrval['comment'] = $arrRet[$comment_key];
326                $arrval['update_date'] = "Now()";
327                $arrval['create_date'] = "Now()";
328                $arrval['creator_id'] = $_SESSION['member_id'];
329                $arrval['rank'] = RECOMMEND_PRODUCT_MAX - $i + 1;
330                $objQuery->insert("dtb_recommend_products", $arrval);
331            }
332        }
333    }
334}
335
336/*
337 * ´Ø¿ô̾¡§lfRegistProductClass
338 * °ú¿ô1 ¡§SC_Query¥ª¥Ö¥¸¥§¥¯¥È
339 * °ú¿ô2 ¡§¾¦Éʵ¬³Ê¾ðÊóÇÛÎó
340 * °ú¿ô3 ¡§¾¦ÉÊID
341 * °ú¿ô4 ¡§¾¦Éʵ¬³ÊID
342 * ÀâÌÀ¡¡¡§¾¦Éʵ¬³ÊÅÐÏ¿
343 */
344function lfRegistProductClass($objQuery, $arrList, $product_id, $product_class_id) {
345    $sqlval['product_code'] = $arrList["product_code"];
346    $sqlval['stock'] = $arrList["stock"];
347    if($sqlval['stock'] == "") {
348        $sqlval['stock_unlimited'] = '1';
349    } else {
350        $sqlval['stock_unlimited'] = '0';       
351    }
352    $sqlval['price01'] = $arrList['price01'];
353    $sqlval['price02'] = $arrList['price02'];
354    $sqlval['creator_id'] = $_SESSION['member_id'];
355    if($sqlval['member_id'] == "") {
356        $sqlval['creator_id'] = '0';
357    }
358       
359    if($product_class_id == "") {
360        // ¿·µ¬ÅÐÏ¿
361        $where = "product_id = ?";
362        // Ç°¤Î¤¿¤á¤Ë´û¸¤Îµ¬³Ê¤òºï½ü
363        $objQuery->delete("dtb_products_class", $where, array($product_id));
364        $sqlval['product_id'] = $product_id;
365        $sqlval['classcategory_id1'] = '0';
366        $sqlval['classcategory_id2'] = '0';
367        $sqlval['create_date'] = "now()";
368        $objQuery->insert("dtb_products_class", $sqlval);
369    } else {
370        // ´û¸ÊÔ½¸
371        $where = "product_id = ? AND product_class_id = ?";
372        $objQuery->update("dtb_products_class", $sqlval, $where, array($product_id, $product_class_id));   
373    }
374}
375
376/*
377 * ´Ø¿ô̾¡§lfCheckError
378 * ÀâÌÀ¡¡¡§ÆþÎÏ¥Á¥§¥Ã¥¯
379 */
380function lfCheckError() {
381    global $objFormParam;
382    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
383    $arrRet =  $objFormParam->getHashArray();
384    $objErr = new SC_CheckError($arrRet);
385    $objErr->arrErr = $objFormParam->checkError(false);
386   
387    if(count($objErr->arrErr) == 0) {
388        $objQuery = new SC_Query();
389        // ¾¦ÉÊID¡¢µ¬³ÊID¤Î¸ºß¥Á¥§¥Ã¥¯
390        if($arrRet['product_id'] != "") {
391            $count = $objQuery->count("dtb_products", "product_id = ?", array($arrRet['product_id']));
392            if($count == 0) {
393                $objErr->arrErr['product_id'] = "¢¨ »ØÄê¤Î¾¦ÉÊID¤Ï¡¢ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£";
394            }
395        }
396               
397        if($arrRet['product_class_id'] != "") {
398            $count = 0;
399            if($arrRet['product_id'] != "") {
400                $count = $objQuery->count("dtb_products_class", "product_id = ? AND product_class_id = ?", array($arrRet['product_id'], $arrRet['product_class_id']));
401            }
402            if($count == 0) {
403                $objErr->arrErr['product_class_id'] = "¢¨ »ØÄê¤Îµ¬³ÊID¤Ï¡¢ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£";
404            }
405        }
406       
407        // ¸ºß¤¹¤ë¥«¥Æ¥´¥êID¤«¥Á¥§¥Ã¥¯
408        $count = $objQuery->count("dtb_category", "category_id = ?", array($arrRet['category_id']));
409        if($count == 0) {
410            $objErr->arrErr['product_id'] = "¢¨ »ØÄê¤Î¥«¥Æ¥´¥êID¤Ï¡¢ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£";
411        }
412    }
413    return $objErr->arrErr;
414}
415
416/*
417 * ´Ø¿ô̾¡§lfCSVRecordCount
418 * ÀâÌÀ¡¡¡§CSV¤Î¥«¥¦¥ó¥È¿ô¤òÆÀ¤ë
419 * °ú¿ô1 ¡§¥Õ¥¡¥¤¥ë¥Ñ¥¹
420 */
421function lfCSVRecordCount($file_name) {
422   
423    $count = 0;
424    $fp = fopen($file_name, "r");
425    while(!feof($fp)) {
426        $arrCSV = fgetcsv($fp, CSV_LINE_MAX);
427        $count++;
428    }
429   
430    return $count-1;
431}
432?>
Note: See TracBrowser for help on using the repository browser.