| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | require_once("../require.php"); |
|---|
| 8 | |
|---|
| 9 | class LC_Page { |
|---|
| 10 | |
|---|
| 11 | function LC_Page() { |
|---|
| 12 | $this->tpl_mainpage = 'contents/recomend_search.tpl'; |
|---|
| 13 | $this->tpl_mainno = 'contents'; |
|---|
| 14 | $this->tpl_subnavi = ''; |
|---|
| 15 | $this->tpl_subno = ""; |
|---|
| 16 | } |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | $conn = new SC_DBConn(); |
|---|
| 20 | $objPage = new LC_Page(); |
|---|
| 21 | $objView = new SC_AdminView(); |
|---|
| 22 | $objSess = new SC_Session(); |
|---|
| 23 | |
|---|
| 24 | // ǧ¾Ú²ÄÈݤÎȽÄê |
|---|
| 25 | sfIsSuccess($objSess); |
|---|
| 26 | |
|---|
| 27 | if ($_POST['mode'] == "search") { |
|---|
| 28 | |
|---|
| 29 | // POSTÃͤΰú¤·Ñ¤® |
|---|
| 30 | $objPage->arrForm = $_POST; |
|---|
| 31 | // ÆþÎÏʸ»ú¤Î¶¯À©ÊÑ´¹ |
|---|
| 32 | lfConvertParam(); |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | $where = "del_flg = 0"; |
|---|
| 36 | |
|---|
| 37 | /* ÆþÎÏ¥¨¥é¡¼¤Ê¤· */ |
|---|
| 38 | foreach ($objPage->arrForm as $key => $val) { |
|---|
| 39 | if($val == "") { |
|---|
| 40 | continue; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | switch ($key) { |
|---|
| 44 | case 'search_name': |
|---|
| 45 | |
|---|
| 46 | $where .= " AND name ILIKE ?"; |
|---|
| 47 | $arrval[] = "%$val%"; |
|---|
| 48 | break; |
|---|
| 49 | case 'search_category_id': |
|---|
| 50 | // »Ò¥«¥Æ¥´¥êID¤Î¼èÆÀ |
|---|
| 51 | $arrRet = sfGetChildsID("dtb_category", "parent_category_id", "category_id", $val); |
|---|
| 52 | $tmp_where = ""; |
|---|
| 53 | foreach ($arrRet as $val) { |
|---|
| 54 | if($tmp_where == "") { |
|---|
| 55 | $tmp_where.= " AND ( category_id = ?"; |
|---|
| 56 | } else { |
|---|
| 57 | $tmp_where.= " OR category_id = ?"; |
|---|
| 58 | } |
|---|
| 59 | $arrval[] = $val; |
|---|
| 60 | } |
|---|
| 61 | $where.= $tmp_where . " )"; |
|---|
| 62 | break; |
|---|
| 63 | case 'search_product_code': |
|---|
| 64 | $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)"; |
|---|
| 65 | $where .= " OR product_code ILIKE ?"; |
|---|
| 66 | $arrval[] = "%$val%"; |
|---|
| 67 | $arrval[] = "%$val%"; |
|---|
| 68 | break; |
|---|
| 69 | default: |
|---|
| 70 | break; |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | $order = "update_date DESC, product_id DESC"; |
|---|
| 75 | |
|---|
| 76 | // ÆÉ¤ß¹þ¤àÎó¤È¥Æ¡¼¥Ö¥ë¤Î»ØÄê |
|---|
| 77 | $col = "product_id, name, category_id, main_list_image, status, product_code, price01, stock, stock_unlimited"; |
|---|
| 78 | $from = "vw_products_nonclass AS noncls "; |
|---|
| 79 | |
|---|
| 80 | $objQuery = new SC_Query(); |
|---|
| 81 | // ¹Ô¿ô¤Î¼èÆÀ |
|---|
| 82 | $linemax = $objQuery->count("dtb_products", $where, $arrval); |
|---|
| 83 | $objPage->tpl_linemax = $linemax; // ²¿·ï¤¬³ºÅö¤·¤Þ¤·¤¿¡£É½¼¨ÍÑ |
|---|
| 84 | |
|---|
| 85 | // ¥Ú¡¼¥¸Á÷¤ê¤Î½èÍý |
|---|
| 86 | if(is_numeric($_POST['search_page_max'])) { |
|---|
| 87 | $page_max = $_POST['search_page_max']; |
|---|
| 88 | } else { |
|---|
| 89 | $page_max = SEARCH_PMAX; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | // ¥Ú¡¼¥¸Á÷¤ê¤Î¼èÆÀ |
|---|
| 93 | $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX); |
|---|
| 94 | $objPage->tpl_strnavi = $objNavi->strnavi; // ɽ¼¨Ê¸»úÎó |
|---|
| 95 | $startno = $objNavi->start_row; |
|---|
| 96 | |
|---|
| 97 | // ¼èÆÀÈϰϤλØÄê(³«»Ï¹ÔÈֹ桢¹Ô¿ô¤Î¥»¥Ã¥È) |
|---|
| 98 | if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno); |
|---|
| 99 | // ɽ¼¨½ç½ø |
|---|
| 100 | $objQuery->setorder($order); |
|---|
| 101 | |
|---|
| 102 | // view¤â¹Ê¹þ¤ß¤ò¤«¤±¤ë(mysqlÍÑ) |
|---|
| 103 | sfViewWhere("&&noncls_where&&", $where, $arrval, $objQuery->order . " " . $objQuery->setlimitoffset($page_max, $startno, true)); |
|---|
| 104 | |
|---|
| 105 | // ¸¡º÷·ë²Ì¤Î¼èÆÀ |
|---|
| 106 | $objPage->arrProducts = $objQuery->select($col, $from, $where, $arrval); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | // ¥«¥Æ¥´¥ê¼èÆÀ |
|---|
| 110 | $objPage->arrCatList = sfGetCategoryList(); |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | //----¡¡¥Ú¡¼¥¸É½¼¨ |
|---|
| 118 | $objView->assignobj($objPage); |
|---|
| 119 | $objView->display($objPage->tpl_mainpage); |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | //--------------------------------------------------------------------------------------------------------------------------------------------------------- |
|---|
| 124 | |
|---|
| 125 | /* ¼èÆÀʸ»úÎó¤ÎÊÑ´¹ */ |
|---|
| 126 | function lfConvertParam() { |
|---|
| 127 | global $objPage; |
|---|
| 128 | /* |
|---|
| 129 | * ʸ»úÎó¤ÎÊÑ´¹ |
|---|
| 130 | * K : ¡ÖȾ³Ñ(Êݶ¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹ |
|---|
| 131 | * C : ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹ |
|---|
| 132 | * V : ÂùÅÀÉÕ¤¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹ |
|---|
| 133 | * n : ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(Êݶ¸)¡×¤ËÊÑ´¹ |
|---|
| 134 | */ |
|---|
| 135 | $arrConvList['search_name'] = "KVa"; |
|---|
| 136 | $arrConvList['search_product_code'] = "KVa"; |
|---|
| 137 | |
|---|
| 138 | // ʸ»úÊÑ´¹ |
|---|
| 139 | foreach ($arrConvList as $key => $val) { |
|---|
| 140 | // POST¤µ¤ì¤Æ¤¤¿ÃͤΤßÊÑ´¹¤¹¤ë¡£ |
|---|
| 141 | if(isset($objPage->arrForm[$key])) { |
|---|
| 142 | $objPage->arrForm[$key] = mb_convert_kana($objPage->arrForm[$key] ,$val); |
|---|
| 143 | } |
|---|
| 144 | } |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | ?> |
|---|