| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * http://www.lockon.co.jp/
|
|---|
| 6 | */
|
|---|
| 7 | require_once("../../require.php");
|
|---|
| 8 |
|
|---|
| 9 | //---- ¥Ú¡¼¥¸É½¼¨¥¯¥é¥¹
|
|---|
| 10 | class 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 |
|
|---|
| 26 | if(lfCheckLimitDate($dir_name)) {
|
|---|
| 27 | $status = CAMPAIGN_TEMPLATE_ACTIVE;
|
|---|
| 28 | } else {
|
|---|
| 29 | $status = CAMPAIGN_TEMPLATE_END;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | if($_GET['init'] != "") {
|
|---|
| 33 | $objPage->tpl_init = 'false';
|
|---|
| 34 | lfDispProductsList($_GET['ids']);
|
|---|
| 35 | } else {
|
|---|
| 36 | $objPage->tpl_init = 'true';
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | switch($_POST['mode']) {
|
|---|
| 40 |
|
|---|
| 41 | case 'cart':
|
|---|
| 42 | $objPage->arrErr = lfCheckError($_POST['product_id']);
|
|---|
| 43 | if(count($objPage->arrErr) == 0) {
|
|---|
| 44 | $objCartSess = new SC_CartSession();
|
|---|
| 45 | $classcategory_id = "classcategory_id". $_POST['product_id'];
|
|---|
| 46 | $classcategory_id1 = $_POST[$classcategory_id. '_1'];
|
|---|
| 47 | $classcategory_id2 = $_POST[$classcategory_id. '_2'];
|
|---|
| 48 | $quantity = "quantity". $_POST['product_id'];
|
|---|
| 49 | // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç
|
|---|
| 50 | if(!$objPage->tpl_classcat_find1[$_POST['product_id']]) {
|
|---|
| 51 | $classcategory_id1 = '0';
|
|---|
| 52 | }
|
|---|
| 53 | // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç
|
|---|
| 54 | if(!$objPage->tpl_classcat_find2[$_POST['product_id']]) {
|
|---|
| 55 | $classcategory_id2 = '0';
|
|---|
| 56 | }
|
|---|
| 57 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
|
|---|
| 58 | $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]);
|
|---|
| 59 | header("Location: " . URL_CART_TOP);
|
|---|
| 60 | exit;
|
|---|
| 61 | }
|
|---|
| 62 | break;
|
|---|
| 63 | default :
|
|---|
| 64 | break;
|
|---|
| 65 | }
|
|---|
| 66 | // ÆþÎϾðÊó¤òÅϤ¹
|
|---|
| 67 | $objPage->arrForm = $_POST;
|
|---|
| 68 | $objPage->tpl_dir_name = CAMPAIGN_TEMPLATE_PATH . $dir_name . "/" . $status;
|
|---|
| 69 |
|
|---|
| 70 | //----¡¡¥Ú¡¼¥¸É½¼¨
|
|---|
| 71 | $objView->assignobj($objPage);
|
|---|
| 72 | $objView->display($objPage->tpl_mainpage);
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | //---------------------------------------------------------------------------------------------------------------------------------------------------------
|
|---|
| 76 | /*
|
|---|
| 77 | * ´Ø¿ô̾¡§lfCheckLimitDate()
|
|---|
| 78 | * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê̾
|
|---|
| 79 | * ÀâÌÀ¡¡¡§¥¥ã¥ó¥Ú¡¼¥óÃæ¤«¥Á¥§¥Ã¥¯
|
|---|
| 80 | * Ìá¤êÃÍ¡§¥¥ã¥ó¥Ú¡¼¥óÃæ¤Ê¤é true ½ªÎ»¤Ê¤é false
|
|---|
| 81 | */
|
|---|
| 82 | function lfCheckLimitDate($directory_name) {
|
|---|
| 83 |
|
|---|
| 84 | global $objQuery;
|
|---|
| 85 |
|
|---|
| 86 | $col = "start_date,end_date";
|
|---|
| 87 | $arrRet = $objQuery->select($col, "dtb_campaign", "directory_name = ? AND del_flg = 0", array($directory_name));
|
|---|
| 88 |
|
|---|
| 89 | // ³«»ÏÆü»þ¡¦Ää»ßÆü»þ¤òÀ®·¿
|
|---|
| 90 | $start_date = (date("YmdHis", strtotime($arrRet[0]['start_date'])));
|
|---|
| 91 | $end_date = (date("YmdHis", strtotime($arrRet[0]['end_date'])));
|
|---|
| 92 | $now_date = (date("YmdHis"));
|
|---|
| 93 |
|
|---|
| 94 | // ¥¥ã¥ó¥Ú¡¼¥ó¤¬³«ºÅÃæ¤«¥Á¥§¥Ã¥¯
|
|---|
| 95 | if($now_date > $start_date && $now_date < $end_date) {
|
|---|
| 96 | return true;
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | return false;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | /* ¾¦ÉʰìÍ÷¤Îɽ¼¨ */
|
|---|
| 103 | function lfDispProductsList($ids) {
|
|---|
| 104 |
|
|---|
| 105 | global $objQuery;
|
|---|
| 106 | global $objPage;
|
|---|
| 107 |
|
|---|
| 108 | // µ¬³Ê̾°ìÍ÷
|
|---|
| 109 | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
|
|---|
| 110 | // µ¬³ÊʬÎà̾°ìÍ÷
|
|---|
| 111 | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
|
|---|
| 112 |
|
|---|
| 113 | $arrProductIds = split('-', $ids);
|
|---|
| 114 | if(!is_array($arrProductIds)) {
|
|---|
| 115 | $arrProductIds[0] = $ids;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | // where¶çÀ¸À®
|
|---|
| 119 | $count = 0;
|
|---|
| 120 | $where = "product_id IN (";
|
|---|
| 121 | foreach($arrProductIds as $key =>$val) {
|
|---|
| 122 | if($count > 0) $where .= ",";
|
|---|
| 123 | $where .= "?";
|
|---|
| 124 | $arrval[] = $val;
|
|---|
| 125 | $count++;
|
|---|
| 126 | }
|
|---|
| 127 | $where .= ")";
|
|---|
| 128 |
|
|---|
| 129 | // ¾¦ÉʰìÍ÷
|
|---|
| 130 | $arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval);
|
|---|
| 131 |
|
|---|
| 132 | for($i = 0; $i < count($arrProducts); $i++) {
|
|---|
| 133 | $objPage = lfMakeSelect($arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);
|
|---|
| 134 | // ¹ØÆþÀ©¸Â¿ô¤ò¼èÆÀ
|
|---|
| 135 | $objPage = lfGetSaleLimit($arrProducts);
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | foreach($arrProducts as $key =>$val) {
|
|---|
| 139 | $arrCamp[$val['product_id']] = $val;
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | $objPage->arrProducts = $arrCamp;
|
|---|
| 143 |
|
|---|
| 144 | return $objPage;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | /* µ¬³Ê¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹¤ÎºîÀ® */
|
|---|
| 148 | function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
|
|---|
| 149 | global $objPage;
|
|---|
| 150 |
|
|---|
| 151 | $classcat_find1 = false;
|
|---|
| 152 | $classcat_find2 = false;
|
|---|
| 153 | // ºß¸Ë¤¢¤ê¤Î¾¦ÉʤÎÍ̵
|
|---|
| 154 | $stock_find = false;
|
|---|
| 155 |
|
|---|
| 156 | // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ
|
|---|
| 157 | $arrProductsClass = lfGetProductsClass($product_id);
|
|---|
| 158 |
|
|---|
| 159 | // µ¬³Ê1¥¯¥é¥¹Ì¾¤Î¼èÆÀ
|
|---|
| 160 | $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']];
|
|---|
| 161 | // µ¬³Ê2¥¯¥é¥¹Ì¾¤Î¼èÆÀ
|
|---|
| 162 | $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']];
|
|---|
| 163 |
|
|---|
| 164 | // ¤¹¤Ù¤Æ¤ÎÁȤ߹ç¤ï¤»¿ô
|
|---|
| 165 | $count = count($arrProductsClass);
|
|---|
| 166 |
|
|---|
| 167 | $classcat_id1 = "";
|
|---|
| 168 |
|
|---|
| 169 | $arrSele = array();
|
|---|
| 170 | $arrList = array();
|
|---|
| 171 |
|
|---|
| 172 | $list_id = 0;
|
|---|
| 173 | $arrList[0] = "\tlist". $product_id. "_0 = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤'";
|
|---|
| 174 | $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
|
|---|
| 175 |
|
|---|
| 176 | for ($i = 0; $i < $count; $i++) {
|
|---|
| 177 | // ºß¸Ë¤Î¥Á¥§¥Ã¥¯
|
|---|
| 178 | if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
|
|---|
| 179 | continue;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | $stock_find = true;
|
|---|
| 183 |
|
|---|
| 184 | // µ¬³Ê1¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
|
|---|
| 185 | if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
|
|---|
| 186 | $arrList[$list_id].=");\n";
|
|---|
| 187 | $arrVal[$list_id].=");\n";
|
|---|
| 188 | $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
|
|---|
| 189 | $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
|
|---|
| 190 | $list_id++;
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | // µ¬³Ê2¤Î¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹ÍÑ
|
|---|
| 194 | $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
|
|---|
| 195 |
|
|---|
| 196 | // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹É½¼¨ÃÍ
|
|---|
| 197 | if($arrList[$list_id] == "") {
|
|---|
| 198 | $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('ÁªÂò¤·¤Æ¤¯¤À¤µ¤¤', '". $arrClassCatName[$classcat_id2]. "'";
|
|---|
| 199 | } else {
|
|---|
| 200 | $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | // ¥»¥ì¥¯¥È¥Ü¥Ã¥¯¥¹POSTÃÍ
|
|---|
| 204 | if($arrVal[$list_id] == "") {
|
|---|
| 205 | $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
|
|---|
| 206 | } else {
|
|---|
| 207 | $arrVal[$list_id].= ", '".$classcat_id2."'";
|
|---|
| 208 | }
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | $arrList[$list_id].=");\n";
|
|---|
| 212 | $arrVal[$list_id].=");\n";
|
|---|
| 213 |
|
|---|
| 214 | // µ¬³Ê1
|
|---|
| 215 | $objPage->arrClassCat1[$product_id] = $arrSele;
|
|---|
| 216 |
|
|---|
| 217 | $lists = "\tlists".$product_id. " = new Array(";
|
|---|
| 218 | $no = 0;
|
|---|
| 219 | foreach($arrList as $val) {
|
|---|
| 220 | $objPage->tpl_javascript.= $val;
|
|---|
| 221 | if ($no != 0) {
|
|---|
| 222 | $lists.= ",list". $product_id. "_". $no;
|
|---|
| 223 | } else {
|
|---|
| 224 | $lists.= "list". $product_id. "_". $no;
|
|---|
| 225 | }
|
|---|
| 226 | $no++;
|
|---|
| 227 | }
|
|---|
| 228 | $objPage->tpl_javascript.= $lists.");\n";
|
|---|
| 229 |
|
|---|
| 230 | $vals = "\tvals".$product_id. " = new Array(";
|
|---|
| 231 | $no = 0;
|
|---|
| 232 | foreach($arrVal as $val) {
|
|---|
| 233 | $objPage->tpl_javascript.= $val;
|
|---|
| 234 | if ($no != 0) {
|
|---|
| 235 | $vals.= ",val". $product_id. "_". $no;
|
|---|
| 236 | } else {
|
|---|
| 237 | $vals.= "val". $product_id. "_". $no;
|
|---|
| 238 | }
|
|---|
| 239 | $no++;
|
|---|
| 240 | }
|
|---|
| 241 | $objPage->tpl_javascript.= $vals.");\n";
|
|---|
| 242 |
|
|---|
| 243 | // ÁªÂò¤µ¤ì¤Æ¤¤¤ëµ¬³Ê2ID
|
|---|
| 244 | $classcategory_id = "classcategory_id". $product_id;
|
|---|
| 245 | $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); ";
|
|---|
| 246 |
|
|---|
| 247 | // µ¬³Ê1¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
|
|---|
| 248 | if($arrProductsClass[0]['classcategory_id1'] != '0') {
|
|---|
| 249 | $classcat_find1 = true;
|
|---|
| 250 | }
|
|---|
| 251 |
|
|---|
| 252 | // µ¬³Ê2¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
|
|---|
| 253 | if($arrProductsClass[0]['classcategory_id2'] != '0') {
|
|---|
| 254 | $classcat_find2 = true;
|
|---|
| 255 | }
|
|---|
| 256 |
|
|---|
| 257 | $objPage->tpl_classcat_find1[$product_id] = $classcat_find1;
|
|---|
| 258 | $objPage->tpl_classcat_find2[$product_id] = $classcat_find2;
|
|---|
| 259 | $objPage->tpl_stock_find[$product_id] = $stock_find;
|
|---|
| 260 |
|
|---|
| 261 | return $objPage;
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | /* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */
|
|---|
| 265 | function lfGetProductsClass($product_id) {
|
|---|
| 266 | $arrRet = array();
|
|---|
| 267 | if(sfIsInt($product_id)) {
|
|---|
| 268 | // ¾¦Éʵ¬³Ê¼èÆÀ
|
|---|
| 269 | $objQuery = new SC_Query();
|
|---|
| 270 | $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
|
|---|
| 271 | $table = "vw_product_class AS prdcls";
|
|---|
| 272 | $where = "product_id = ?";
|
|---|
| 273 | $objQuery->setorder("rank1 DESC, rank2 DESC");
|
|---|
| 274 | $arrRet = $objQuery->select($col, $table, $where, array($product_id));
|
|---|
| 275 | }
|
|---|
| 276 | return $arrRet;
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | /* ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯ */
|
|---|
| 280 | function lfCheckError($id) {
|
|---|
| 281 | global $objPage;
|
|---|
| 282 |
|
|---|
| 283 | // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
|
|---|
| 284 | $objErr = new SC_CheckError();
|
|---|
| 285 |
|
|---|
| 286 | $classcategory_id1 = "classcategory_id". $id. "_1";
|
|---|
| 287 | $classcategory_id2 = "classcategory_id". $id. "_2";
|
|---|
| 288 | $quantity = "quantity". $id;
|
|---|
| 289 | // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯
|
|---|
| 290 | if ($objPage->tpl_classcat_find1[$id]) {
|
|---|
| 291 | $objErr->doFunc(array("µ¬³Ê1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
|
|---|
| 292 | }
|
|---|
| 293 | if ($objPage->tpl_classcat_find2[$id]) {
|
|---|
| 294 | $objErr->doFunc(array("µ¬³Ê2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
|
|---|
| 295 | }
|
|---|
| 296 | $objErr->doFunc(array("¸Ä¿ô", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
|
|---|
| 297 |
|
|---|
| 298 | return $objErr->arrErr;
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 | // ¹ØÆþÀ©¸Â¿ô¤ÎÀßÄê
|
|---|
| 302 | function lfGetSaleLimit($product) {
|
|---|
| 303 | global $objPage;
|
|---|
| 304 | //ºß¸Ë¤¬Ìµ¸Â¤Þ¤¿¤Ï¹ØÆþÀ©¸ÂÃͤ¬ÀßÄêÃͤè¤êÂ礤¤¾ì¹ç
|
|---|
| 305 | if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) {
|
|---|
| 306 | $objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;
|
|---|
| 307 | } else {
|
|---|
| 308 | $objPage->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | return $objPage;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | //»ÙʧÊýË¡¤Î¼èÆÀ
|
|---|
| 315 | //payment_id 1:Âå¶â°ú´¹¡¡2:¶ä¹Ô¿¶¤ê¹þ¤ß¡¡3:¸½¶â½ñα
|
|---|
| 316 | function lfGetPayment() {
|
|---|
| 317 | $objQuery = new SC_Query;
|
|---|
| 318 | $col = "payment_id, rule, payment_method";
|
|---|
| 319 | $from = "dtb_payment";
|
|---|
| 320 | $where = "del_flg = 0";
|
|---|
| 321 | $order = "payment_id";
|
|---|
| 322 | $objQuery->setorder($order);
|
|---|
| 323 | $arrRet = $objQuery->select($col, $from, $where);
|
|---|
| 324 | return $arrRet;
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | ?> |
|---|