source: temp/trunk/html/products/detail.php @ 6145

Revision 6145, 12.8 KB checked in by naka, 20 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8require_once("../require.php");
9require_once(DATA_PATH . "include/page_layout.inc");
10
11class LC_Page {
12    function LC_Page() {
13        /** ɬ¤º»ØÄꤹ¤ë **/
14        global $arrSTATUS;
15        $this->arrSTATUS = $arrSTATUS;
16        global $arrSTATUS_IMAGE;
17        $this->arrSTATUS_IMAGE = $arrSTATUS_IMAGE;
18        global $arrDELIVERYDATE;
19        $this->arrDELIVERYDATE = $arrDELIVERYDATE;
20        global $arrRECOMMEND;
21        $this->arrRECOMMEND = $arrRECOMMEND;
22       
23        //$this->tpl_mainpage="products/detail.tpl";
24       
25        /*
26         session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç
27         ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£
28         private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£
29        */
30        session_cache_limiter('private-no-expire');
31    }
32}
33
34$objPage = new LC_Page();
35$objView = new SC_SiteView();
36$objCustomer = new SC_Customer();
37$objQuery = new SC_Query();
38
39// ¥ì¥¤¥¢¥¦¥È¥Ç¥¶¥¤¥ó¤ò¼èÆÀ
40$objPage = sfGetPageLayout($objPage, false, "products/detail.php");
41
42// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
43$objFormParam = new SC_FormParam();
44// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
45lfInitParam();
46// POSTÃͤμèÆÀ
47$objFormParam->setParam($_POST);
48
49// ¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹
50$objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
51// ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
52lfInitFile();
53
54// ´ÉÍý¥Ú¡¼¥¸¤«¤é¤Î³Îǧ¤Î¾ì¹ç¤Ï¡¢Èó¸ø³«¤Î¾¦Éʤâɽ¼¨¤¹¤ë¡£
55if($_GET['admin'] == 'on') {
56    $where = "del_flg = 0";
57} else {
58    $where = "del_flg = 0 AND status = 1";
59}
60
61if($_POST['mode'] != "") {
62    $tmp_id = $_POST['product_id'];
63} else {
64    $tmp_id = $_GET['product_id'];
65}
66
67// ÃͤÎÀµÅöÀ­¥Á¥§¥Ã¥¯
68if(!sfIsInt($_GET['product_id']) || !sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) {
69    sfDispSiteError(PRODUCT_NOT_FOUND);
70}
71// ¥í¥°¥¤¥óȽÄê
72if($objCustomer->isLoginSuccess()) {
73    //¤ªµ¤¤ËÆþ¤ê¥Ü¥¿¥óɽ¼¨
74    $objPage->tpl_login = true;
75   
76    $table = "dtb_customer_reading";
77    $where = "customer_id = ? ";
78    $arrval[] = $objCustomer->getValue('customer_id');
79    //¸ÜµÒ¤Î±ÜÍ÷¾¦ÉÊ¿ô
80    $rpcnt = $objQuery->count($table, $where, $arrval);
81
82    //±ÜÍ÷¿ô¤¬ÀßÄê¿ô°Ê²¼
83    if ($rpcnt < CUSTOMER_READING_MAX){
84        //±ÜÍ÷ÍúÎò¤Ë¿·µ¬ÄɲÃ
85        lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
86    } else {
87        //±ÜÍ÷ÍúÎò¤ÎÃæ¤Ç°ìÈָŤ¤¤â¤Î¤òºï½ü¤·¤Æ¿·µ¬ÄɲÃ
88        $where = "customer_id = ? AND update_date = (SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ? ) ";
89        $arrval = array($objCustomer->getValue("customer_id"), $objCustomer->getValue("customer_id"));
90        //ºï½ü
91        $objQuery->delete($table, $where, $arrval);
92        //ÄɲÃ
93        lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id'));
94    }
95}
96
97
98// µ¬³ÊÁªÂò¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎºîÀ®
99$objPage = lfMakeSelect($objPage, $tmp_id);
100
101// ¾¦ÉÊID¤òFORMÆâ¤ËÊÝ»ý¤¹¤ë¡£
102$objPage->tpl_product_id = $tmp_id;
103
104switch($_POST['mode']) {
105case 'cart':
106    // ÆþÎÏÃͤÎÊÑ´¹
107    $objFormParam->convParam();
108    $objPage->arrErr = lfCheckError();
109    if(count($objPage->arrErr) == 0) {
110        $objCartSess = new SC_CartSession();
111        $classcategory_id1 = $_POST['classcategory_id1'];
112        $classcategory_id2 = $_POST['classcategory_id2'];
113               
114        // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç
115        if(!$objPage->tpl_classcat_find1) {
116            $classcategory_id1 = '0';
117        }
118       
119        // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç
120        if(!$objPage->tpl_classcat_find2) {
121            $classcategory_id2 = '0';
122        }
123
124        $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $objFormParam->getValue('quantity'));
125        header("Location: " . URL_CART_TOP);
126
127        exit;
128    }
129    break;
130       
131default:
132    break;
133}
134
135$objQuery = new SC_Query();
136// DB¤«¤é¾¦ÉʾðÊó¤ò¼èÆÀ¤¹¤ë¡£
137$arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id));
138$objPage->arrProduct = $arrRet[0];
139
140// ¹ØÆþÀ©¸Â¿ô¤ò¼èÆÀ
141if($objPage->arrProduct['sale_unlimited'] == 1 || $objPage->arrProduct['sale_limit'] > SALE_LIMIT_MAX) {
142  $objPage->tpl_sale_limit = SALE_LIMIT_MAX;
143} else {
144  $objPage->tpl_sale_limit = $objPage->arrProduct['sale_limit'];
145}
146
147// ¥µ¥Ö¥¿¥¤¥È¥ë¤ò¼èÆÀ
148$arrFirstCat = GetFirstCat($arrRet[0]['category_id']);
149$tpl_subtitle = $arrFirstCat['name'];
150$objPage->tpl_subtitle = $tpl_subtitle;
151
152// DB¤«¤é¤Î¥Ç¡¼¥¿¤ò°ú¤­·Ñ¤°
153$objUpFile->setDBFileList($objPage->arrProduct);
154// ¥Õ¥¡¥¤¥ëɽ¼¨ÍÑÇÛÎó¤òÅϤ¹
155$objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
156// »ÙʧÊýË¡¤Î¼èÆÀ
157$objPage->arrPayment = lfGetPayment();
158// ÆþÎϾðÊó¤òÅϤ¹
159$objPage->arrForm = $objFormParam->getFormParamList();
160//¥ì¥Ó¥å¡¼¾ðÊó¤Î¼èÆÀ
161$objPage->arrReview = lfGetReviewData($tmp_id);
162// ¥¿¥¤¥È¥ë¤Ë¾¦ÉÊ̾¤òÆþ¤ì¤ë
163$objPage->tpl_title = "¾¦Éʾܺ٠". $objPage->arrProduct["name"];
164//¥ª¥¹¥¹¥á¾¦ÉʾðÊóɽ¼¨
165$objPage->arrRecommend = lfPreGetRecommendProducts($tmp_id);
166//¤³¤Î¾¦ÉʤòÇã¤Ã¤¿¿Í¤Ï¤³¤ó¤Ê¾¦ÉʤâÇã¤Ã¤Æ¤¤¤Þ¤¹
167$objPage->arrRelateProducts = lfGetRelateProducts($tmp_id);
168
169$objView->assignobj($objPage);
170$objView->display(SITE_FRAME);
171//-----------------------------------------------------------------------------------------------------------------------------------
172/* ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½ */
173function lfInitFile() {
174    global $objUpFile;
175    $objUpFile->addFile("°ìÍ÷-¥á¥¤¥ó²èÁü", 'main_list_image', array('jpg','gif'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
176    $objUpFile->addFile("¾ÜºÙ-¥á¥¤¥ó²èÁü", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
177    $objUpFile->addFile("¾ÜºÙ-¥á¥¤¥ó³ÈÂç²èÁü", 'main_large_image', array('jpg'), IMAGE_SIZE, false, LARGE_IMAGE_HEIGHT, LARGE_IMAGE_HEIGHT);
178    for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
179        $objUpFile->addFile("¾ÜºÙ-¥µ¥Ö²èÁü$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT);
180        $objUpFile->addFile("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü$cnt", "sub_large_image$cnt", array('jpg'), IMAGE_SIZE, false, LARGE_SUBIMAGE_HEIGHT, LARGE_SUBIMAGE_HEIGHT);
181    }
182    $objUpFile->addFile("¾¦ÉÊÈæ³Ó²èÁü", 'file1', array('jpg'), IMAGE_SIZE, false, NORMAL_IMAGE_HEIGHT, NORMAL_IMAGE_HEIGHT);
183    $objUpFile->addFile("¾¦Éʾܺ٥ե¡¥¤¥ë", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false);
184}
185
186/* µ¬³ÊÁªÂò¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎºîÀ® */
187function lfMakeSelect($objPage, $product_id) {
188    global $objPage;
189    $classcat_find1 = false;
190    $classcat_find2 = false;
191    // ºß¸Ë¤¢¤ê¤Î¾¦ÉʤÎ̵ͭ
192    $stock_find = false;
193   
194    // µ¬³Ê̾°ìÍ÷
195    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
196    // µ¬³ÊʬÎà̾°ìÍ÷
197    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
198    // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
199    $arrProductsClass = lfGetProductsClass($product_id);
200   
201    // µ¬³Ê1¥¯¥é¥¹Ì¾¤Î¼èÆÀ
202    $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
203    // µ¬³Ê2¥¯¥é¥¹Ì¾¤Î¼èÆÀ
204    $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
205   
206    // ¤¹¤Ù¤Æ¤ÎÁȤ߹ç¤ï¤»¿ô
207    $count = count($arrProductsClass);
208   
209    $classcat_id1 = "";
210   
211    $arrSele = array();
212    $arrList = array();
213   
214    $list_id = 0;
215    $arrList[0] = "\tlist0 = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤'";
216    $arrVal[0] = "\tval0 = new Array(''";
217   
218    for ($i = 0; $i < $count; $i++) {
219        // ºß¸Ë¤Î¥Á¥§¥Ã¥¯
220        if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
221            continue;
222        }
223       
224        $stock_find = true;
225       
226        // µ¬³Ê1¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
227        if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
228            $arrList[$list_id].=");\n";
229            $arrVal[$list_id].=");\n";
230            $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
231            $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
232            $list_id++;
233        }
234       
235        // µ¬³Ê2¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
236        $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
237       
238        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹É½¼¨ÃÍ
239        if($arrList[$list_id] == "") {
240            $arrList[$list_id] = "\tlist".$list_id." = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤', '".$arrClassCatName[$classcat_id2]."'";
241        } else {
242            $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
243        }
244       
245        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹POSTÃÍ
246        if($arrVal[$list_id] == "") {
247            $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'";
248        } else {
249            $arrVal[$list_id].= ", '".$classcat_id2."'";
250        }
251    }   
252   
253    $arrList[$list_id].=");\n";
254    $arrVal[$list_id].=");\n";
255       
256    // µ¬³Ê1
257    $objPage->arrClassCat1 = $arrSele;
258   
259    $lists = "\tlists = new Array(";
260    $no = 0;
261   
262    foreach($arrList as $val) {
263        $objPage->tpl_javascript.= $val;
264        if ($no != 0) {
265            $lists.= ",list".$no;
266        } else {
267            $lists.= "list".$no;
268        }
269        $no++;
270    }
271    $objPage->tpl_javascript.=$lists.");\n";
272   
273    $vals = "\tvals = new Array(";
274    $no = 0;
275   
276    foreach($arrVal as $val) {
277        $objPage->tpl_javascript.= $val;
278        if ($no != 0) {
279            $vals.= ",val".$no;
280        } else {
281            $vals.= "val".$no;
282        }
283        $no++;
284    }
285    $objPage->tpl_javascript.=$vals.");\n";
286   
287    // ÁªÂò¤µ¤ì¤Æ¤¤¤ëµ¬³Ê2ID
288    $objPage->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . $_POST['classcategory_id2'] . "');";
289
290    // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
291    if($arrProductsClass[0]['classcategory_id1'] != '0') {
292        $classcat_find1 = true;
293    }
294   
295    // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
296    if($arrProductsClass[0]['classcategory_id2'] != '0') {
297        $classcat_find2 = true;
298    }
299       
300    $objPage->tpl_classcat_find1 = $classcat_find1;
301    $objPage->tpl_classcat_find2 = $classcat_find2;
302    $objPage->tpl_stock_find = $stock_find;
303       
304    return $objPage;
305}
306
307/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
308function lfInitParam() {
309    global $objFormParam;
310
311    $objFormParam->addParam("µ¬³Ê1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
312    $objFormParam->addParam("µ¬³Ê2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
313    $objFormParam->addParam("¸Ä¿ô", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
314}
315
316/* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */
317function lfGetProductsClass($product_id) {
318    $arrRet = array();
319    if(sfIsInt($product_id)) {
320        // ¾¦Éʵ¬³Ê¼èÆÀ
321        $objQuery = new SC_Query();
322        $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
323        $table = "vw_product_class AS prdcls";
324        $where = "product_id = ?";
325        $objQuery->setorder("rank1 DESC, rank2 DESC");
326        $arrRet = $objQuery->select($col, $table, $where, array($product_id));
327    }
328    return $arrRet;
329}
330
331/* ÅÐÏ¿ºÑ¤ß¥ª¥¹¥¹¥á¾¦ÉÊ¤ÎÆÉ¤ß¹þ¤ß */
332function lfPreGetRecommendProducts($product_id) {
333    $objQuery = new SC_Query();
334    $objQuery->setorder("rank DESC");
335    $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
336    $max = count($arrRet);
337    $no = 0;
338    for($i = 0; $i < $max; $i++) {
339        $where = "del_flg = 0 AND product_id = ? AND status = 1";
340        $arrProductInfo = $objQuery->select("main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate", "vw_products_allclass  AS allcls", $where, array($arrRet[$i]['recommend_product_id']));
341               
342        if(count($arrProductInfo) > 0) {
343            $arrRecommend[$no] = $arrProductInfo[0];
344            $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
345            $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
346            $no++;
347        }   
348    }
349    return $arrRecommend;
350}
351
352/* ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯ */
353function lfCheckError() {
354    global $objFormParam;
355    global $objPage;
356    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
357    $arrRet =  $objFormParam->getHashArray();
358    $objErr = new SC_CheckError($arrRet);
359    $objErr->arrErr = $objFormParam->checkError();
360       
361    // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯
362    if ($objPage->tpl_classcat_find1) {
363        $objErr->doFunc(array("µ¬³Ê1", "classcategory_id1"), array("EXIST_CHECK"));
364    }
365    if ($objPage->tpl_classcat_find2) {
366        $objErr->doFunc(array("µ¬³Ê2", "classcategory_id2"), array("EXIST_CHECK"));
367    }
368           
369    return $objErr->arrErr;
370}
371
372//±ÜÍ÷ÍúÎò¿·µ¬ÅÐÏ¿
373function lfRegistReadingData($tmp_id, $customer_id){
374    $objQuery = new SC_Query;
375    $sqlval['customer_id'] = $customer_id;
376    $sqlval['reading_product_id'] = $tmp_id;
377    $sqlval['create_date'] = 'NOW()';
378    $sqlval['update_date'] = 'NOW()';
379    $objQuery->insert("dtb_customer_reading", $sqlval);
380}
381
382//¤³¤Î¾¦ÉʤòÇã¤Ã¤¿¿Í¤Ï¤³¤ó¤Ê¾¦ÉʤâÇã¤Ã¤Æ¤¤¤Þ¤¹
383function lfGetRelateProducts($tmp_id) {
384    $objQuery = new SC_Query;
385    //¼«Æ°Ãê½Ð
386    $objQuery->setorder("random()");
387    //ɽ¼¨·ï¿ô¤ÎÀ©¸Â
388    $objQuery->setlimit(RELATED_PRODUCTS_MAX);
389    //¸¡º÷¾ò·ï
390    $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate";
391    $from = "vw_products_allclass AS allcls ";
392    $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? ";
393    $arrval[] = $tmp_id;
394    //·ë²Ì¤Î¼èÆÀ
395    $arrProducts = $objQuery->select($col, $from, $where, $arrval);
396   
397    return $arrProducts;
398}
399
400//¾¦Éʤ´¤È¤Î¥ì¥Ó¥å¡¼¾ðÊó¤ò¼èÆÀ¤¹¤ë
401function lfGetReviewData($id) {
402    $objQuery = new SC_Query;
403    //¾¦Éʤ´¤È¤Î¥ì¥Ó¥å¡¼¾ðÊó¤ò¼èÆÀ¤¹¤ë
404    $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
405    $from = "dtb_review";
406    $where = "del_flg = 0 AND status = 1 AND product_id = ? ";
407    $arrval[] = $id;
408    $arrReview = $objQuery->select($col, $from, $where, $arrval);
409    return $arrReview;
410}
411
412//»ÙʧÊýË¡¤Î¼èÆÀ
413//payment_id    1:¥¯¥ì¥¸¥Ã¥È¡¡2:¥·¥ç¥Ã¥Ô¥ó¥°¥í¡¼¥ó 
414function lfGetPayment() {
415    $objQuery = new SC_Query;
416    $col = "payment_id, rule, payment_method";
417    $from = "dtb_payment";
418    $where = "del_flg = 0";
419    $order = "payment_id";
420    $objQuery->setorder($order);
421    $arrRet = $objQuery->select($col, $from, $where);
422    return $arrRet;
423}
424
425?>
Note: See TracBrowser for help on using the repository browser.