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

Revision 11053, 7.4 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);
105sfprintr($arrProducts);
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    return $objPage;
113}
114
115/* µ¬³Ê¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎºîÀ® */
116function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
117    global $objPage;
118   
119    $classcat_find1 = false;
120    $classcat_find2 = false;
121    // ºß¸Ë¤¢¤ê¤Î¾¦ÉʤÎ̵ͭ
122    $stock_find = false;
123   
124    // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
125    $arrProductsClass = lfGetProductsClass($product_id);
126   
127    // µ¬³Ê1¥¯¥é¥¹Ì¾¤Î¼èÆÀ
128    $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']];
129    // µ¬³Ê2¥¯¥é¥¹Ì¾¤Î¼èÆÀ
130    $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']];
131   
132    // ¤¹¤Ù¤Æ¤ÎÁȤ߹ç¤ï¤»¿ô
133    $count = count($arrProductsClass);
134   
135    $classcat_id1 = "";
136   
137    $arrSele = array();
138    $arrList = array();
139   
140    $list_id = 0;
141    $arrList[0] = "\tlist". $product_id. "_0 = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤'";
142    $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
143   
144    for ($i = 0; $i < $count; $i++) {
145        // ºß¸Ë¤Î¥Á¥§¥Ã¥¯
146        if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
147            continue;
148        }
149       
150        $stock_find = true;
151       
152        // µ¬³Ê1¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
153        if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
154            $arrList[$list_id].=");\n";
155            $arrVal[$list_id].=");\n";
156            $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
157            $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
158            $list_id++;
159        }
160       
161        // µ¬³Ê2¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
162        $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
163       
164        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹É½¼¨ÃÍ
165        if($arrList[$list_id] == "") {
166            $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤', '". $arrClassCatName[$classcat_id2]. "'";
167        } else {
168            $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
169        }
170       
171        // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹POSTÃÍ
172        if($arrVal[$list_id] == "") {
173            $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
174        } else {
175            $arrVal[$list_id].= ", '".$classcat_id2."'";
176        }
177    }   
178   
179    $arrList[$list_id].=");\n";
180    $arrVal[$list_id].=");\n";
181       
182    // µ¬³Ê1
183    $objPage->arrClassCat1[$product_id] = $arrSele;
184   
185    $lists = "\tlists".$product_id. " = new Array(";
186    $no = 0;
187    foreach($arrList as $val) {
188        $objPage->tpl_javascript.= $val;
189        if ($no != 0) {
190            $lists.= ",list". $product_id. "_". $no;
191        } else {
192            $lists.= "list". $product_id. "_". $no;
193        }
194        $no++;
195    }
196    $objPage->tpl_javascript.= $lists.");\n";
197   
198    $vals = "\tvals".$product_id. " = new Array(";
199    $no = 0;
200    foreach($arrVal as $val) {
201        $objPage->tpl_javascript.= $val;
202        if ($no != 0) {
203            $vals.= ",val". $product_id. "_". $no;
204        } else {
205            $vals.= "val". $product_id. "_". $no;
206        }
207        $no++;
208    }
209    $objPage->tpl_javascript.= $vals.");\n";
210   
211    // ÁªÂò¤µ¤ì¤Æ¤¤¤ëµ¬³Ê2ID
212    $classcategory_id = "classcategory_id". $product_id;
213    $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); ";
214
215    // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
216    if($arrProductsClass[0]['classcategory_id1'] != '0') {
217        $classcat_find1 = true;
218    }
219   
220    // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
221    if($arrProductsClass[0]['classcategory_id2'] != '0') {
222        $classcat_find2 = true;
223    }
224       
225    $objPage->tpl_classcat_find1[$product_id] = $classcat_find1;
226    $objPage->tpl_classcat_find2[$product_id] = $classcat_find2;
227    $objPage->tpl_stock_find[$product_id] = $stock_find;
228       
229    return $objPage;
230}
231
232/* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */
233function lfGetProductsClass($product_id) {
234    $arrRet = array();
235    if(sfIsInt($product_id)) {
236        // ¾¦Éʵ¬³Ê¼èÆÀ
237        $objQuery = new SC_Query();
238        $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
239        $table = "vw_product_class AS prdcls";
240        $where = "product_id = ?";
241        $objQuery->setorder("rank1 DESC, rank2 DESC");
242        $arrRet = $objQuery->select($col, $table, $where, array($product_id));
243    }
244    return $arrRet;
245}
246
247// ¹ØÆþÀ©¸Â¿ô¤ÎÀßÄê
248function lfGetSaleLimit($product) {
249    global $objPage;
250    //ºß¸Ë¤¬Ìµ¸Â¤Þ¤¿¤Ï¹ØÆþÀ©¸ÂÃͤ¬ÀßÄêÃͤè¤êÂ礭¤¤¾ì¹ç
251    if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
252        $objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
253    } else {
254        $objPage->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
255    }
256   
257    return $objPage;
258}
259
260//»ÙʧÊýË¡¤Î¼èÆÀ
261//payment_id    1:Âå¶â°ú´¹¡¡2:¶ä¹Ô¿¶¤ê¹þ¤ß¡¡3:¸½¶â½ñα
262function lfGetPayment() {
263    $objQuery = new SC_Query;
264    $col = "payment_id, rule, payment_method";
265    $from = "dtb_payment";
266    $where = "del_flg = 0";
267    $order = "payment_id";
268    $objQuery->setorder($order);
269    $arrRet = $objQuery->select($col, $from, $where);
270    return $arrRet;
271}
272
273?>
Note: See TracBrowser for help on using the repository browser.