Source for file LC_Page_Admin_Products.php
Documentation is available at LC_Page_Admin_Products.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(CLASS_PATH . "pages/LC_Page.php");
* @author LOCKON CO.,LTD.
* @version $Id:LC_Page_Admin_Products.php 15532 2007-08-31 14:39:46Z nanasess $
$this->tpl_subnavi = 'products/subnavi.tpl';
$this->tpl_subno = 'index';
$this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
$this->tpl_subtitle = '商品マスタ';
$masterData = new SC_DB_MasterData_Ex();
$this->arrPageMax = $masterData->getMasterData("mtb_page_max");
$this->arrDISP = $masterData->getMasterData("mtb_disp");
$this->arrSTATUS = $masterData->getMasterData("mtb_status");
$this->arrPRODUCTSTATUS_COLOR = $masterData->getMasterData("mtb_product_status_color");
$objDb = new SC_Helper_DB_Ex();
$objDate->setStartYear(RELEASE_YEAR);
$objDate->setEndYear(DATE("Y"));
$this->arrStartYear = $objDate->getYear();
$this->arrStartMonth = $objDate->getMonth();
$this->arrStartDay = $objDate->getDay();
$objDate->setStartYear(RELEASE_YEAR);
$objDate->setEndYear(DATE("Y"));
$this->arrEndYear = $objDate->getYear();
$this->arrEndMonth = $objDate->getMonth();
$this->arrEndDay = $objDate->getDay();
SC_Utils_Ex::sfIsSuccess($objSess);
if (!isset ($_POST['mode'])) $_POST['mode'] = "";
if(isset ($_POST['campaign_id']) && SC_Utils_Ex::sfIsInt($_POST['campaign_id'])
&& $_POST['mode'] == "camp_search") {
$search_data = $objQuery->get("dtb_campaign", "search_condition", "campaign_id = ? ", array($_POST['campaign_id']));
foreach ($arrSearch as $key => $val) {
foreach ($_POST as $key => $val) {
if (ereg("^search_", $key) || ereg("^campaign_", $key)) {
case 'search_product_flag':
$this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
$this->arrForm[$key] = split("-", $val);
$this->arrHidden[$key] = $val;
$this->arrHidden['search_pageno'] = isset ($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
if ($_POST['mode'] == "delete") {
if($_POST['category_id'] != "") {
$where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['category_id']);
$objDb->sfDeleteRankRecord("dtb_products", "product_id", $_POST['product_id'], $where);
$objDb->sfDeleteRankRecord("dtb_products", "product_id", $_POST['product_id']);
$objQuery->delete("dtb_products_class", "product_id = ?", array($_POST['product_id']));
$objDb->sfCategory_Count($objQuery);
if ($_POST['mode'] == "search" || $_POST['mode'] == "csv" || $_POST['mode'] == "delete" || $_POST['mode'] == "delete_all" || $_POST['mode'] == "camp_search") {
$view_where = "del_flg = 0";
if (count($this->arrErr) == 0) {
foreach ($this->arrForm as $key => $val) {
$val = SC_Utils_Ex::sfManualEscape($val);
case 'search_product_id': // 商品ID
$where .= " AND product_id = ?";
$view_where .= " AND product_id = ?";
case 'search_product_class_name': //規格名称
$where_in = " (SELECT classcategory_id FROM dtb_classcategory WHERE class_id IN (SELECT class_id FROM dtb_class WHERE name LIKE ?)) ";
$where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE classcategory_id1 IN " . $where_in;
$where .= " OR classcategory_id2 IN" . $where_in . ")";
$view_where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE classcategory_id1 IN " . $where_in;
$view_where .= " OR classcategory_id2 IN" . $where_in . ")";
case 'search_name': // 商品名
$where .= " AND name ILIKE ?";
$view_where .= " AND name ILIKE ?";
case 'search_category_id': // カテゴリー
list ($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val);
$where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
$view_where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
$arrval = array_merge((array) $arrval, (array) $tmp_arrval);
case 'search_product_code': // 商品コード
$where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)";
$view_where .= " AND EXISTS (SELECT product_id FROM dtb_products_class as cls WHERE cls.product_code ILIKE ? AND dtb_products.product_id = cls.product_id GROUP BY cls.product_id )";
case 'search_startyear': // 登録更新日(FROM)
$date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
$where.= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth']. "/" . $_POST['search_startday'] . "'";
$view_where.= " AND update_date >= '" . $_POST['search_startyear'] . "/" . $_POST['search_startmonth']. "/" . $_POST['search_startday'] . "'";
case 'search_endyear': // 登録更新日(TO)
$date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
$where.= " AND update_date < date('" . $date . "')";
$view_where.= " AND update_date < date('" . $date . "')";
case 'search_product_flag': //種別
$search_product_flag = SC_Utils_Ex::sfSearchCheckBoxes($val);
if($search_product_flag != "") {
$where.= " AND product_flag LIKE ?";
$view_where.= " AND product_flag LIKE ?";
$arrval[] = $search_product_flag;
case 'search_status': // ステータス
foreach ($val as $element){
$tmp_where.= "AND (status = ? ";
$tmp_where.= "OR status = ? ";
$view_where.= " $tmp_where";
$order = "update_date DESC, product_id DESC";
require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
$objCSV = new SC_Helper_CSV_Ex();
$objCSV->sfDownloadProductsCsv($where, $arrval, $order) && exit;
$where = "product_id IN (SELECT product_id FROM vw_products_allclass_detail AS alldtl WHERE $where)";
$objQuery->update("dtb_products", $sqlval, $where, $arrval);
$objQuery->delete("dtb_customer_favorite_products", $where, $arrval);
$col = "product_id, name, category_id, main_list_image, status, product_code, price01, price02, stock, stock_unlimited";
$from = "vw_products_nonclass AS noncls ";
$linemax = $objQuery->count("dtb_products", $view_where, $arrval);
$this->tpl_linemax = $linemax; // 何件が該当しました。表示用
$page_max = $_POST['search_page_max'];
$objNavi = new SC_PageNavi($this->arrHidden['search_pageno'], $linemax, $page_max, "fnNaviSearchPage", NAVI_PMAX);
$startno = $objNavi->start_row;
$this->arrPagenavi = $objNavi->arrPagenavi;
//キャンペーン商品検索時は、全結果の商品IDを変数に格納する
if(isset ($_POST['search_mode']) && $_POST['search_mode'] == 'campaign') {
$arrRet = $objQuery->select($col, $from, $where, $arrval);
$arrRet = sfSwapArray($arrRet);
$pid = implode("-", $arrRet['product_id']);
$this->arrHidden['campaign_product_id'] = $pid;
// if(DB_TYPE != "mysql") $objQuery->setLimitOffset($page_max, $startno);
$objQuery->setLimitOffset($page_max, $startno);
$objQuery->setOrder($order);
$this->arrProducts = $objQuery->select($col, $from, $where, $arrval);
if (count($this->arrProducts) > 0) {
foreach ($this->arrProducts as $key => $val) {
$this->arrProducts[$key]["categories"] = $objDb->sfGetCategoryId($val["product_id"]);
$objDb->g_category_on = false;
list ($this->arrCatKey, $this->arrCatVal) = $objDb->sfGetLevelCatList(false);
$this->arrCatList = $this->lfGetIDName($this->arrCatKey, $this->arrCatVal);
$objView->assignobj($this);
$objView->display(MAIN_FRAME);
* K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換
* C : 「全角ひら仮名」を「全角かた仮名」に変換
* V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します
* n : 「全角」数字を「半角(ハンカク)」に変換
$arrConvList['search_name'] = "KVa";
$arrConvList['search_product_code'] = "KVa";
foreach ($arrConvList as $key => $val) {
if(isset ($objPage->arrForm[$key])) {
$objPage->arrForm[$key] = mb_convert_kana($objPage->arrForm[$key] ,$val);
$objErr->doFunc(array("商品ID", "search_product_id"), array("NUM_CHECK"));
$objErr->doFunc(array("開始日", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
$objErr->doFunc(array("終了日", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE"));
$objErr->doFunc(array("開始日", "終了日", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM"));
for ($cnt = 1; $cnt <= $max; $cnt++ ) {
if ($_POST[$key . $cnt] == "1") {
// カテゴリIDをキー、カテゴリ名を値にする配列を返す。
$max = count($arrCatKey);
for ($cnt = 0; $cnt < $max; $cnt++ ) {
$key = isset ($arrCatKey[$cnt]) ? $arrCatKey[$cnt] : "";
$val = isset ($arrCatVal[$cnt]) ? $arrCatVal[$cnt] : "";
Documentation generated on Fri, 24 Feb 2012 13:58:58 +0900 by Seasoft
|