Source for file LC_Page_Admin_Contents_CSV.php

Documentation is available at LC_Page_Admin_Contents_CSV.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  */
  23.  
  24. // {{{ requires
  25. require_once(CLASS_PATH . "pages/LC_Page.php");
  26. require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
  27.  
  28. /**
  29.  * CSV項目設定 のページクラス.
  30.  *
  31.  * @package Page
  32.  * @author LOCKON CO.,LTD.
  33.  * @version $Id$
  34.  */
  35.  
  36.     // }}}
  37.     // {{{ functions
  38.  
  39.     /**
  40.      * Page を初期化する.
  41.      *
  42.      * @return void 
  43.      */
  44.     function init() {
  45.         parent::init();
  46.         $this->tpl_mainpage = 'contents/csv.tpl';
  47.         $this->tpl_subnavi = 'contents/subnavi.tpl';
  48.         $this->tpl_subno = 'csv';
  49.  
  50.         $this->tpl_mainno = "contents";
  51.         $this->tpl_subtitle = 'CSV出力設定';
  52.     }
  53.  
  54.     /**
  55.      * Page のプロセス.
  56.      *
  57.      * @return void 
  58.      */
  59.     function process() {
  60.         $objView = new SC_AdminView();
  61.         $objSess = new SC_Session();
  62.         $objCSV = new SC_Helper_CSV_Ex();
  63.  
  64.         $this->arrSubnavi = $objCSV->arrSubnavi;
  65.         $this->tpl_subno_csv = $objCSV->arrSubnavi[1];
  66.         $this->arrSubnaviName = $objCSV->arrSubnaviName;
  67.  
  68.         // 認証可否の判定
  69.         $objSess = new SC_Session();
  70.         SC_Utils_Ex::sfIsSuccess($objSess);
  71.  
  72.         $arrOutput = array();
  73.         $arrChoice = array();
  74.  
  75.         $get_tpl_subno_csv = isset($_GET['tpl_subno_csv'])
  76.                                      ? $_GET['tpl_subno_csv'] : "";
  77.  
  78.         // GETで値が送られている場合にはその値を元に画面表示を切り替える
  79.         if ($get_tpl_subno_csv != ""){
  80.             // 送られてきた値が配列に登録されていなければTOPを表示
  81.             if (in_array($get_tpl_subno_csv,$this->arrSubnavi)){
  82.                 $subno_csv = $get_tpl_subno_csv;
  83.             }else{
  84.                 $subno_csv = $this->arrSubnavi[1];
  85.             }
  86.         } else {
  87.             // GETで値がなければPOSTの値を使用する
  88.             if (isset($_POST['tpl_subno_csv'])
  89.                 && $_POST['tpl_subno_csv'] != "") {
  90.  
  91.                 $subno_csv = $_POST['tpl_subno_csv'];
  92.             }else{
  93.                 $subno_csv = $this->arrSubnavi[1];
  94.             }
  95.         }
  96.  
  97.         // subnoの番号を取得
  98.         $subno_id = array_keys($this->arrSubnavi,$subno_csv);
  99.         $subno_id = $subno_id[0];
  100.         // データの登録
  101.  
  102.         if (!isset($_POST['mode'])) $_POST['mode'] = "";
  103.  
  104.         if ($_POST["mode"] == "confirm") {
  105.  
  106.             // エラーチェック
  107.             $this->arrErr = $this->lfCheckError($_POST['output_list']);
  108.  
  109.             if (count($this->arrErr) <= 0){
  110.                 // データの更新
  111.                 $this->lfUpdCsvOutput($subno_id, $_POST['output_list']);
  112.  
  113.                 // 画面のリロード
  114.                 $this->reload(array("tpl_subno_csv" => $subno_csv));
  115.             }
  116.         }
  117.  
  118.         // 出力項目の取得
  119.         $arrOutput = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_csv, "WHERE csv_id = ? AND status = 1", array($subno_id)));
  120.         $arrOutput = SC_Utils_Ex::sfarrCombine($arrOutput['col'], $arrOutput['disp_name']);
  121.  
  122.         // 非出力項目の取得
  123.         $arrChoice = SC_Utils_Ex::sfSwapArray($objCSV->sfgetCsvOutput($subno_csv, "WHERE csv_id = ? AND status = 2", array($subno_id)));
  124.  
  125.         if (!isset($arrChoice['col'])) $arrChoice['col'] = array();
  126.         if (!isset($arrChoice['disp_name'])) $arrChoice['disp_name'] = array();
  127.  
  128.         $arrChoice = SC_Utils_Ex::sfarrCombine($arrChoice['col'], $arrChoice['disp_name']);
  129.  
  130.         $this->arrOutput=$arrOutput;
  131.         $this->arrChoice=$arrChoice;
  132.  
  133.  
  134.         $this->SubnaviName = $this->arrSubnaviName[$subno_id];
  135.         $this->tpl_subno_csv = $subno_csv;
  136.  
  137.         // 画面の表示
  138.         $objView->assignobj($this);
  139.         $objView->display(MAIN_FRAME);
  140.     }
  141.  
  142.    /**
  143.      * デストラクタ.
  144.      *
  145.      * @return void 
  146.      */
  147.     function destroy() {
  148.         parent::destroy();
  149.     }
  150.  
  151.     function lfUpdCsvOutput($csv_id, $arrData = array()){
  152.         $objQuery = new SC_Query();
  153.  
  154.         // ひとまず、全部使用しないで更新する
  155.         $upd_sql = "UPDATE dtb_csv SET status = 2, rank = NULL, update_date = now() WHERE csv_id = ?";
  156.         $objQuery->query($upd_sql, array($csv_id));
  157.  
  158.         // 使用するものだけ、再更新する。
  159.         if (is_array($arrData)) {
  160.             foreach($arrData as $key => $val){
  161.                 $upd_sql = "UPDATE dtb_csv SET status = 1, rank = ? WHERE csv_id = ? AND col = ? ";
  162.                 $objQuery->query($upd_sql, array($key+1, $csv_id,$val));
  163.             }
  164.         }
  165.     }
  166.  
  167.     Function Lfcheckerror($data){
  168.         $objErr = new SC_CheckError();
  169.         $objErr->doFunc( array("出力項目", "output_list"), array("EXIST_CHECK") );
  170.  
  171.         return $objErr->arrErr;
  172.  
  173.     }
  174. }
  175. ?>

Documentation generated on Tue, 28 Apr 2009 18:10:54 +0900 by phpDocumentor 1.4.2