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

Revision 8906, 13.1 KB checked in by kakinaka, 20 years ago (diff)

blank

  • 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->setPrevURL($_SERVER['REQUEST_URI']);
125        $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $objFormParam->getValue('quantity'));
126        header("Location: " . URL_CART_TOP);
127
128        exit;
129    }
130    break;
131       
132default:
133    break;
134}
135
136$objQuery = new SC_Query();
137// DB¤«¤é¾¦ÉʾðÊó¤ò¼èÆÀ¤¹¤ë¡£
138$arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id));
139$objPage->arrProduct = $arrRet[0];
140
141// ¾¦ÉÊ¥³¡¼¥É¤Î¼èÆÀ
142$code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = 1 GROUP BY product_code ORDER BY product_code";
143$arrCode = $objQuery->getall($code_sql);
144       
145sfprintr(sfswaparray($arrCode));
146
147// ¹ØÆþÀ©¸Â¿ô¤ò¼èÆÀ
148if($objPage->arrProduct['sale_unlimited'] == 1 || $objPage->arrProduct['sale_limit'] > SALE_LIMIT_MAX) {
149  $objPage->tpl_sale_limit = SALE_LIMIT_MAX;
150} else {
151  $objPage->tpl_sale_limit = $objPage->arrProduct['sale_limit'];
152}
153
154// ¥µ¥Ö¥¿¥¤¥È¥ë¤ò¼èÆÀ
155$arrFirstCat = GetFirstCat($arrRet[0]['category_id']);
156$tpl_subtitle = $arrFirstCat['name'];
157$objPage->tpl_subtitle = $tpl_subtitle;
158
159// DB¤«¤é¤Î¥Ç¡¼¥¿¤ò°ú¤­·Ñ¤°
160$objUpFile->setDBFileList($objPage->arrProduct);
161// ¥Õ¥¡¥¤¥ëɽ¼¨ÍÑÇÛÎó¤òÅϤ¹
162$objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
163// »ÙʧÊýË¡¤Î¼èÆÀ
164$objPage->arrPayment = lfGetPayment();
165// ÆþÎϾðÊó¤òÅϤ¹
166$objPage->arrForm = $objFormParam->getFormParamList();
167//¥ì¥Ó¥å¡¼¾ðÊó¤Î¼èÆÀ
168$objPage->arrReview = lfGetReviewData($tmp_id);
169// ¥¿¥¤¥È¥ë¤Ë¾¦ÉÊ̾¤òÆþ¤ì¤ë
170$objPage->tpl_title = "¾¦Éʾܺ٠". $objPage->arrProduct["name"];
171//¥ª¥¹¥¹¥á¾¦ÉʾðÊóɽ¼¨
172$objPage->arrRecommend = lfPreGetRecommendProducts($tmp_id);
173//¤³¤Î¾¦ÉʤòÇã¤Ã¤¿¿Í¤Ï¤³¤ó¤Ê¾¦ÉʤâÇã¤Ã¤Æ¤¤¤Þ¤¹
174$objPage->arrRelateProducts = lfGetRelateProducts($tmp_id);
175
176$objView->assignobj($objPage);
177$objView->display(SITE_FRAME);
178//-----------------------------------------------------------------------------------------------------------------------------------
179/* ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½ */
180function lfInitFile() {
181    global $objUpFile;
182    $objUpFile->addFile("°ìÍ÷-¥á¥¤¥ó²èÁü", 'main_list_image', array('jpg','gif'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
183    $objUpFile->addFile("¾ÜºÙ-¥á¥¤¥ó²èÁü", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);
184    $objUpFile->addFile("¾ÜºÙ-¥á¥¤¥ó³ÈÂç²èÁü", 'main_large_image', array('jpg'), IMAGE_SIZE, false, LARGE_IMAGE_HEIGHT, LARGE_IMAGE_HEIGHT);
185    for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) {
186        $objUpFile->addFile("¾ÜºÙ-¥µ¥Ö²èÁü$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT);
187        $objUpFile->addFile("¾ÜºÙ-¥µ¥Ö³ÈÂç²èÁü$cnt", "sub_large_image$cnt", array('jpg'), IMAGE_SIZE, false, LARGE_SUBIMAGE_HEIGHT, LARGE_SUBIMAGE_HEIGHT);
188    }
189    $objUpFile->addFile("¾¦ÉÊÈæ³Ó²èÁü", 'file1', array('jpg'), IMAGE_SIZE, false, NORMAL_IMAGE_HEIGHT, NORMAL_IMAGE_HEIGHT);
190    $objUpFile->addFile("¾¦Éʾܺ٥ե¡¥¤¥ë", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false);
191}
192
193/* µ¬³ÊÁªÂò¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎºîÀ® */
194function lfMakeSelect($objPage, $product_id) {
195    global $objPage;
196    $classcat_find1 = false;
197    $classcat_find2 = false;
198    // ºß¸Ë¤¢¤ê¤Î¾¦ÉʤÎ̵ͭ
199    $stock_find = false;
200   
201    // µ¬³Ê̾°ìÍ÷
202    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
203    // µ¬³ÊʬÎà̾°ìÍ÷
204    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
205    // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
206    $arrProductsClass = lfGetProductsClass($product_id);
207   
208    // µ¬³Ê1¥¯¥é¥¹Ì¾¤Î¼èÆÀ
209    $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']];
210    // µ¬³Ê2¥¯¥é¥¹Ì¾¤Î¼èÆÀ
211    $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']];
212   
213    // ¤¹¤Ù¤Æ¤ÎÁȤ߹ç¤ï¤»¿ô
214    $count = count($arrProductsClass);
215   
216    $classcat_id1 = "";
217   
218    $arrSele = array();
219    $arrList = array();
220   
221    $list_id = 0;
222    $arrList[0] = "\tlist0 = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤'";
223    $arrVal[0] = "\tval0 = new Array(''";
224   
225    for ($i = 0; $i < $count; $i++) {
226        // ºß¸Ë¤Î¥Á¥§¥Ã¥¯
227        if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
228            continue;
229        }
230       
231        $stock_find = true;
232       
233        // µ¬³Ê1¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
234        if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
235            $arrList[$list_id].=");\n";
236            $arrVal[$list_id].=");\n";
237            $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
238            $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
239            $list_id++;
240        }
241       
242        // µ¬³Ê2¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
243        $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
244       
245        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹É½¼¨ÃÍ
246        if($arrList[$list_id] == "") {
247            $arrList[$list_id] = "\tlist".$list_id." = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤', '".$arrClassCatName[$classcat_id2]."'";
248        } else {
249            $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
250        }
251       
252        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹POSTÃÍ
253        if($arrVal[$list_id] == "") {
254            $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'";
255        } else {
256            $arrVal[$list_id].= ", '".$classcat_id2."'";
257        }
258    }   
259   
260    $arrList[$list_id].=");\n";
261    $arrVal[$list_id].=");\n";
262       
263    // µ¬³Ê1
264    $objPage->arrClassCat1 = $arrSele;
265   
266    $lists = "\tlists = new Array(";
267    $no = 0;
268   
269    foreach($arrList as $val) {
270        $objPage->tpl_javascript.= $val;
271        if ($no != 0) {
272            $lists.= ",list".$no;
273        } else {
274            $lists.= "list".$no;
275        }
276        $no++;
277    }
278    $objPage->tpl_javascript.=$lists.");\n";
279   
280    $vals = "\tvals = new Array(";
281    $no = 0;
282   
283    foreach($arrVal as $val) {
284        $objPage->tpl_javascript.= $val;
285        if ($no != 0) {
286            $vals.= ",val".$no;
287        } else {
288            $vals.= "val".$no;
289        }
290        $no++;
291    }
292    $objPage->tpl_javascript.=$vals.");\n";
293   
294    // ÁªÂò¤µ¤ì¤Æ¤¤¤ëµ¬³Ê2ID
295    $objPage->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . $_POST['classcategory_id2'] . "');";
296
297    // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
298    if($arrProductsClass[0]['classcategory_id1'] != '0') {
299        $classcat_find1 = true;
300    }
301   
302    // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
303    if($arrProductsClass[0]['classcategory_id2'] != '0') {
304        $classcat_find2 = true;
305    }
306       
307    $objPage->tpl_classcat_find1 = $classcat_find1;
308    $objPage->tpl_classcat_find2 = $classcat_find2;
309    $objPage->tpl_stock_find = $stock_find;
310       
311    return $objPage;
312}
313
314/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
315function lfInitParam() {
316    global $objFormParam;
317
318    $objFormParam->addParam("µ¬³Ê1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
319    $objFormParam->addParam("µ¬³Ê2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
320    $objFormParam->addParam("¸Ä¿ô", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
321}
322
323/* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */
324function lfGetProductsClass($product_id) {
325    $arrRet = array();
326    if(sfIsInt($product_id)) {
327        // ¾¦Éʵ¬³Ê¼èÆÀ
328        $objQuery = new SC_Query();
329        $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
330        $table = "vw_product_class AS prdcls";
331        $where = "product_id = ?";
332        $objQuery->setorder("rank1 DESC, rank2 DESC");
333        $arrRet = $objQuery->select($col, $table, $where, array($product_id));
334    }
335    return $arrRet;
336}
337
338/* ÅÐÏ¿ºÑ¤ß¥ª¥¹¥¹¥á¾¦ÉÊ¤ÎÆÉ¤ß¹þ¤ß */
339function lfPreGetRecommendProducts($product_id) {
340    $objQuery = new SC_Query();
341    $objQuery->setorder("rank DESC");
342    $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id));
343    $max = count($arrRet);
344    $no = 0;
345    for($i = 0; $i < $max; $i++) {
346        $where = "del_flg = 0 AND product_id = ? AND status = 1";
347        $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']));
348               
349        if(count($arrProductInfo) > 0) {
350            $arrRecommend[$no] = $arrProductInfo[0];
351            $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id'];
352            $arrRecommend[$no]['comment'] = $arrRet[$i]['comment'];
353            $no++;
354        }   
355    }
356    return $arrRecommend;
357}
358
359/* ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯ */
360function lfCheckError() {
361    global $objFormParam;
362    global $objPage;
363    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
364    $arrRet =  $objFormParam->getHashArray();
365    $objErr = new SC_CheckError($arrRet);
366    $objErr->arrErr = $objFormParam->checkError();
367       
368    // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯
369    if ($objPage->tpl_classcat_find1) {
370        $objErr->doFunc(array("µ¬³Ê1", "classcategory_id1"), array("EXIST_CHECK"));
371    }
372    if ($objPage->tpl_classcat_find2) {
373        $objErr->doFunc(array("µ¬³Ê2", "classcategory_id2"), array("EXIST_CHECK"));
374    }
375           
376    return $objErr->arrErr;
377}
378
379//±ÜÍ÷ÍúÎò¿·µ¬ÅÐÏ¿
380function lfRegistReadingData($tmp_id, $customer_id){
381    $objQuery = new SC_Query;
382    $sqlval['customer_id'] = $customer_id;
383    $sqlval['reading_product_id'] = $tmp_id;
384    $sqlval['create_date'] = 'NOW()';
385    $sqlval['update_date'] = 'NOW()';
386    $objQuery->insert("dtb_customer_reading", $sqlval);
387}
388
389//¤³¤Î¾¦ÉʤòÇã¤Ã¤¿¿Í¤Ï¤³¤ó¤Ê¾¦ÉʤâÇã¤Ã¤Æ¤¤¤Þ¤¹
390function lfGetRelateProducts($tmp_id) {
391    $objQuery = new SC_Query;
392    //¼«Æ°Ãê½Ð
393    $objQuery->setorder("random()");
394    //ɽ¼¨·ï¿ô¤ÎÀ©¸Â
395    $objQuery->setlimit(RELATED_PRODUCTS_MAX);
396    //¸¡º÷¾ò·ï
397    $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate";
398    $from = "vw_products_allclass AS allcls ";
399    $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? ";
400    $arrval[] = $tmp_id;
401    //·ë²Ì¤Î¼èÆÀ
402    $arrProducts = $objQuery->select($col, $from, $where, $arrval);
403   
404    return $arrProducts;
405}
406
407//¾¦Éʤ´¤È¤Î¥ì¥Ó¥å¡¼¾ðÊó¤ò¼èÆÀ¤¹¤ë
408function lfGetReviewData($id) {
409    $objQuery = new SC_Query;
410    //¾¦Éʤ´¤È¤Î¥ì¥Ó¥å¡¼¾ðÊó¤ò¼èÆÀ¤¹¤ë
411    $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment";
412    $from = "dtb_review";
413    $where = "del_flg = 0 AND status = 1 AND product_id = ? ";
414    $arrval[] = $id;
415    $arrReview = $objQuery->select($col, $from, $where, $arrval);
416    return $arrReview;
417}
418
419//»ÙʧÊýË¡¤Î¼èÆÀ
420//payment_id    1:¥¯¥ì¥¸¥Ã¥È¡¡2:¥·¥ç¥Ã¥Ô¥ó¥°¥í¡¼¥ó 
421function lfGetPayment() {
422    $objQuery = new SC_Query;
423    $col = "payment_id, rule, payment_method";
424    $from = "dtb_payment";
425    $where = "del_flg = 0";
426    $order = "payment_id";
427    $objQuery->setorder($order);
428    $arrRet = $objQuery->select($col, $from, $where);
429    return $arrRet;
430}
431
432?>
Note: See TracBrowser for help on using the repository browser.