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

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