source: temp/branches/ec-cube-beta/html/campaign/default/index.php @ 11054

Revision 11054, 7.5 KB checked in by uehara, 20 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../../require.php");
8
9//---- ¥Ú¡¼¥¸É½¼¨¥¯¥é¥¹
10class LC_Page {
11   
12    function LC_Page() {
13        $this->tpl_mainpage = TEMPLATE_DIR . '/campaign/index.tpl';
14    }
15}
16
17$objPage = new LC_Page();
18$objView = new SC_SiteView(false);
19$objQuery = new SC_Query();
20
21// ¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ
22$dir_name = dirname($_SERVER['PHP_SELF']);
23$arrDir = split('/', $dir_name);
24$dir_name = $arrDir[count($arrDir) -1];
25
26if(lfCheckLimitDate($dir_name)) {
27    $status = CAMPAIGN_TEMPLATE_ACTIVE;
28} else {
29    $status = CAMPAIGN_TEMPLATE_END;
30}
31
32if($_GET['init'] != "") {
33    $objPage->tpl_init = 'false';
34    lfDispProductsList($_GET['ids']);
35} else {
36    $objPage->tpl_init = 'true';   
37}
38
39$objPage->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name  . "/" . $status;
40
41sfprintr($objPage);
42
43
44//----¡¡¥Ú¡¼¥¸É½¼¨
45$objView->assignobj($objPage);
46$objView->display($objPage->tpl_mainpage);
47
48
49//---------------------------------------------------------------------------------------------------------------------------------------------------------
50/*
51 * ´Ø¿ô̾¡§lfCheckLimitDate()
52 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê̾
53 * ÀâÌÀ¡¡¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤«¥Á¥§¥Ã¥¯
54 * Ìá¤êÃÍ¡§¥­¥ã¥ó¥Ú¡¼¥óÃæ¤Ê¤é true ½ªÎ»¤Ê¤é false
55 */
56function lfCheckLimitDate($directory_name) {
57   
58    global $objQuery;
59   
60    $col = "start_date,end_date";
61    $arrRet = $objQuery->select($col, "dtb_campaign", "directory_name = ? AND del_flg = 0", array($directory_name));
62
63    // ³«»ÏÆü»þ¡¦Ää»ßÆü»þ¤òÀ®·¿
64    $start_date = (date("YmdHis", strtotime($arrRet[0]['start_date'])));
65    $end_date = (date("YmdHis", strtotime($arrRet[0]['end_date'])));
66    $now_date = (date("YmdHis"));
67
68    // ¥­¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅÃæ¤«¥Á¥§¥Ã¥¯
69    if($now_date > $start_date && $now_date < $end_date) {
70        return true;
71    }
72       
73    return false;
74}
75
76/* ¾¦ÉʰìÍ÷¤Îɽ¼¨ */
77function lfDispProductsList($ids) {
78   
79    global $objQuery;
80    global $objPage;
81
82    // µ¬³Ê̾°ìÍ÷
83    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
84    // µ¬³ÊʬÎà̾°ìÍ÷
85    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
86   
87    $arrProductIds = split('-', $ids);
88    if(!is_array($arrProductIds)) {
89        $arrProductIds[0] = $ids;
90    }
91   
92    // where¶çÀ¸À®
93    $count = 0;
94    $where = "product_id IN (";
95    foreach($arrProductIds as $key =>$val) {
96        if($count > 0) $where .= ",";
97        $where .= "?";
98        $arrval[] = $val;
99        $count++;
100    }
101    $where .= ")";
102
103    // ¾¦ÉʰìÍ÷
104    $arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval);
105
106    for($i = 0; $i < count($arrProducts); $i++) {
107        $objPage = lfMakeSelect($arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
108        // ¹ØÆþÀ©¸Â¿ô¤ò¼èÆÀ
109        $objPage = lfGetSaleLimit($arrProducts);
110    }
111
112    foreach($arrProductIds as $key =>$val) {
113        $arrCamp[$val['product_id']] = $val[$val['product_id']];
114    }
115   
116    $objPage->arrProducts = $arrCamp;
117   
118    return $objPage;
119}
120
121/* µ¬³Ê¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎºîÀ® */
122function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
123    global $objPage;
124   
125    $classcat_find1 = false;
126    $classcat_find2 = false;
127    // ºß¸Ë¤¢¤ê¤Î¾¦ÉʤÎ̵ͭ
128    $stock_find = false;
129   
130    // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
131    $arrProductsClass = lfGetProductsClass($product_id);
132   
133    // µ¬³Ê1¥¯¥é¥¹Ì¾¤Î¼èÆÀ
134    $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']];
135    // µ¬³Ê2¥¯¥é¥¹Ì¾¤Î¼èÆÀ
136    $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']];
137   
138    // ¤¹¤Ù¤Æ¤ÎÁȤ߹ç¤ï¤»¿ô
139    $count = count($arrProductsClass);
140   
141    $classcat_id1 = "";
142   
143    $arrSele = array();
144    $arrList = array();
145   
146    $list_id = 0;
147    $arrList[0] = "\tlist". $product_id. "_0 = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤'";
148    $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
149   
150    for ($i = 0; $i < $count; $i++) {
151        // ºß¸Ë¤Î¥Á¥§¥Ã¥¯
152        if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
153            continue;
154        }
155       
156        $stock_find = true;
157       
158        // µ¬³Ê1¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
159        if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
160            $arrList[$list_id].=");\n";
161            $arrVal[$list_id].=");\n";
162            $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
163            $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
164            $list_id++;
165        }
166       
167        // µ¬³Ê2¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
168        $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
169       
170        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹É½¼¨ÃÍ
171        if($arrList[$list_id] == "") {
172            $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤', '". $arrClassCatName[$classcat_id2]. "'";
173        } else {
174            $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
175        }
176       
177        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹POSTÃÍ
178        if($arrVal[$list_id] == "") {
179            $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
180        } else {
181            $arrVal[$list_id].= ", '".$classcat_id2."'";
182        }
183    }   
184   
185    $arrList[$list_id].=");\n";
186    $arrVal[$list_id].=");\n";
187       
188    // µ¬³Ê1
189    $objPage->arrClassCat1[$product_id] = $arrSele;
190   
191    $lists = "\tlists".$product_id. " = new Array(";
192    $no = 0;
193    foreach($arrList as $val) {
194        $objPage->tpl_javascript.= $val;
195        if ($no != 0) {
196            $lists.= ",list". $product_id. "_". $no;
197        } else {
198            $lists.= "list". $product_id. "_". $no;
199        }
200        $no++;
201    }
202    $objPage->tpl_javascript.= $lists.");\n";
203   
204    $vals = "\tvals".$product_id. " = new Array(";
205    $no = 0;
206    foreach($arrVal as $val) {
207        $objPage->tpl_javascript.= $val;
208        if ($no != 0) {
209            $vals.= ",val". $product_id. "_". $no;
210        } else {
211            $vals.= "val". $product_id. "_". $no;
212        }
213        $no++;
214    }
215    $objPage->tpl_javascript.= $vals.");\n";
216   
217    // ÁªÂò¤µ¤ì¤Æ¤¤¤ëµ¬³Ê2ID
218    $classcategory_id = "classcategory_id". $product_id;
219    $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); ";
220
221    // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
222    if($arrProductsClass[0]['classcategory_id1'] != '0') {
223        $classcat_find1 = true;
224    }
225   
226    // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
227    if($arrProductsClass[0]['classcategory_id2'] != '0') {
228        $classcat_find2 = true;
229    }
230       
231    $objPage->tpl_classcat_find1[$product_id] = $classcat_find1;
232    $objPage->tpl_classcat_find2[$product_id] = $classcat_find2;
233    $objPage->tpl_stock_find[$product_id] = $stock_find;
234       
235    return $objPage;
236}
237
238/* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */
239function lfGetProductsClass($product_id) {
240    $arrRet = array();
241    if(sfIsInt($product_id)) {
242        // ¾¦Éʵ¬³Ê¼èÆÀ
243        $objQuery = new SC_Query();
244        $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
245        $table = "vw_product_class AS prdcls";
246        $where = "product_id = ?";
247        $objQuery->setorder("rank1 DESC, rank2 DESC");
248        $arrRet = $objQuery->select($col, $table, $where, array($product_id));
249    }
250    return $arrRet;
251}
252
253// ¹ØÆþÀ©¸Â¿ô¤ÎÀßÄê
254function lfGetSaleLimit($product) {
255    global $objPage;
256    //ºß¸Ë¤¬Ìµ¸Â¤Þ¤¿¤Ï¹ØÆþÀ©¸ÂÃͤ¬ÀßÄêÃͤè¤êÂ礭¤¤¾ì¹ç
257    if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
258        $objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
259    } else {
260        $objPage->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
261    }
262   
263    return $objPage;
264}
265
266//»ÙʧÊýË¡¤Î¼èÆÀ
267//payment_id    1:Âå¶â°ú´¹¡¡2:¶ä¹Ô¿¶¤ê¹þ¤ß¡¡3:¸½¶â½ñα
268function lfGetPayment() {
269    $objQuery = new SC_Query;
270    $col = "payment_id, rule, payment_method";
271    $from = "dtb_payment";
272    $where = "del_flg = 0";
273    $order = "payment_id";
274    $objQuery->setorder($order);
275    $arrRet = $objQuery->select($col, $from, $where);
276    return $arrRet;
277}
278
279?>
Note: See TracBrowser for help on using the repository browser.