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

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