バージョン選択

フォーラム

メニュー

オンライン状況

62 人のユーザが現在オンラインです。 (54 人のユーザが フォーラム を参照しています。)
登録ユーザ: 1
ゲスト: 61
tattsu もっと...

サイト内検索

機能要望 > 管理機能 > 顧客データをCSVから登録する試験的な実装

管理機能

新規スレッドを追加する

スレッド表示 | 古いものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
nacho
投稿日時: 2012/1/7 1:29
対応状況: −−−
一人前
登録日: 2008/12/8
居住地:
投稿: 103
Re: 顧客データをCSVから登録する試験的な実装
このような機能をこちらでご提供下さり、大変助かります。
只今データの移動作業中なのですが
こちらを利用させて頂こうと、試してみたのですが
「この内容で登録する」をクリック後システムエラーとなってしまいます。

エラーの内容です。
Fatal error: [] operator not supported for strings in /virtual/www/eccube/data/class/pages/admin/customer/LC_Page_Admin_Customer_Import.php on line 167

operator not supported for strings で解決方法を検索したのですが
同じ名前で変数と配列を作ると出てしまう、
変数を配列として初期化することで解決する、
という内容があったのですが、PHP初心者の為
解決の糸口が見えずにおります。

初歩的な質問で申し訳ありませんが、ご教授下さい。

EC-CUBEバージョン 2.11.4
PHPバージョン PHP 5.2.17
DBバージョン PostgreSQL 9.0.1
seventh
投稿日時: 2011/12/21 11:10
対応状況: −−−
新米
登録日: 2011/11/25
居住地:
投稿: 6
Re: 顧客データをCSVから登録する試験的な実装
返信ありがとうございます。

引用:

参考になりそうな記事がございました。
http://www.prime-architect.co.jp/it-354

ありがとうございます。結構大変そうですね。。。

引用:

ちなみに上記は新規登録以外に既存の会員情報の一括更新もできたりなんかもするのでしょうか?

はい。
CSVと一致する顧客IDが存在するかどうかで、insert/updateを切り替えています。
ゲスト
投稿日時: 2011/12/16 16:38
対応状況: −−−
Re: 顧客データをCSVから登録する試験的な実装
引用:
この実装の分かっている問題: - 電子メールの重複チェックがない


参考になりそうな記事がございました。
http://www.prime-architect.co.jp/it-354


顧客データのインポートは大変魅力的ですね!
ちなみに上記は新規登録以外に既存の会員情報の一括更新もできたりなんかもするのでしょうか?
seventh
投稿日時: 2011/12/16 15:09
対応状況: −−−
新米
登録日: 2011/11/25
居住地:
投稿: 6
顧客データをCSVから登録する試験的な実装
顧客データを別システムから持ち込む必要があり、CSVをインポートする機能を試験的に実装してみました。

管理機能の顧客管理の下に、[顧客登録CSV]を追加しています。

同じような問題を抱えている方のお役に立てれば幸いです。


この実装の分かっている問題:
- 電子メールの重複チェックがない
- 必要最低限の列しかない



Index: test/class/page/LC_Page_Admin_Customer_Import_Test.php
===================================================================
--- test/class/page/LC_Page_Admin_Customer_Import_Test.php	(リビジョン 0)
+++ test/class/page/LC_Page_Admin_Customer_Import_Test.php	(リビジョン 0)
@@ -0,0 +1,29 @@
+<?php
+
+require_once dirname(dirname(dirname(__FILE__))) . '/require.php';
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/data/class_extends/page_extends/admin/customer/LC_Page_Admin_Customer_Import_Ex.php';
+
+
+class LC_Page_Admin_Customer_Import_Test extends PHPUnit_Framework_TestCase {
+    public function testAction() {
+        $this->assertTrue(true);
+    }
+}
+
+class Customer_Csv_Importer_Test extends PHPUnit_Framework_TestCase {
+    public function testExecute_1() {
+        $target = new Customer_Csv_Importer();
+        $result = $target->execute(realpath(dirname(__FILE__).'/ng.csv'));
+
+        $this->assertFalse($result);
+    }
+
+    public function testExecute_2() {
+        $target = new Customer_Csv_Importer();
+        $result = $target->execute(realpath(dirname(__FILE__).'/ok.csv'));
+
+        $this->assertTrue($result);
+    }
+}
+
+
Index: html/admin/customer/import.php
===================================================================
--- html/admin/customer/import.php	(リビジョン 0)
+++ html/admin/customer/import.php	(リビジョン 0)
@@ -0,0 +1,18 @@
+<?php
+/** 
+ * 顧客登録CSV
+ *
+ * @package ec-cube
+ * @version $Revision$
+ */
+// {{{ requires
+require_once '../require.php';
+require_once CLASS_EX_REALDIR . 'page_extends/admin/customer/LC_Page_Admin_Customer_Import_Ex.php';
+
+// }}}
+// {{{ generate page
+
+$objPage = new LC_Page_Admin_Customer_Import_Ex();
+register_shutdown_function(array($objPage, 'destroy'));
+$objPage->init();
+$objPage->process();
Index: data/Smarty/templates/admin/customer/subnavi.tpl
===================================================================
--- data/Smarty/templates/admin/customer/subnavi.tpl	(リビジョン 21366)
+++ data/Smarty/templates/admin/customer/subnavi.tpl	(作業コピー)
@@ -24,4 +24,5 @@
 <ul class="level1">
 <li<!--{if $tpl_subno == 'index'}--> class="on"<!--{/if}--> id="navi-customer-index"><a href="<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->customer/<!--{$smarty.const.DIR_INDEX_PATH}-->"><span>顧客マスター</span></a></li>
 <li<!--{if $tpl_subno == 'customer'}--> class="on"<!--{/if}--> id="navi-customer-customer"><a href="<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->customer/edit.php"><span>顧客登録</span></a></li>
+<li<!--{if $tpl_subno == 'import'}--> class="on"<!--{/if}--> id="navi-customer-import"><a href="<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->customer/import.php"><span>顧客登録CSV</span></a></li>
 </ul>
Index: data/Smarty/templates/admin/customer/import.tpl
===================================================================
--- data/Smarty/templates/admin/customer/import.tpl	(リビジョン 0)
+++ data/Smarty/templates/admin/customer/import.tpl	(リビジョン 0)
@@ -0,0 +1,65 @@
+<!--{*
+* 顧客登録CSV
+*
+*
+*}-->
+<form name="form1" id="form1" method="post" action="?" enctype="multipart/form-data"">
+<input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
+<input type="hidden" name="mode" value="import" />
+<div class="contents-main">
+    <!--{if $tpl_errtitle != ""}-->
+        <div class="message">
+            <span class="attention"><!--{$tpl_errtitle}--></span><br />
+            <!--{foreach key=key item=item from=$arrCSVErr}-->
+                <span class="attention"><!--{$item}-->
+                <!--{if $key != 'blank'}-->
+                    [値:<!--{$arrParam[$key]}-->]
+                <!--{/if}-->
+                </span><br />
+            <!--{/foreach}-->
+        </div>
+    <!--{/if}-->
+
+    <!--▼登録テーブルここから-->
+    <table>
+        <tr>
+            <th>CSVファイル</th>
+            <td>
+                <!--{if $arrErr.csv_file}-->
+                    <span class="attention"><!--{$arrErr.csv_file}--></span>
+                <!--{/if}-->
+                <input type="file" name="csv_file" size="40" /><span class="attention">(1行目タイトル行)</span>
+            </td>
+        </tr>
+	<tr>
+            <th>登録情報</th>
+	    <td>
+                <!--{foreach name=title key=key item=item from=$arrTitle}-->
+                    <!--{$smarty.foreach.title.iteration}-->項目:<!--{$item}--><br />
+                <!--{/foreach}-->
+	    </td>
+	</tr>
+        <tr>
+            <th>登録結果</th>
+            <td>
+    <!--{if $arrRowErr}-->
+                    <!--{foreach item=err from=$arrRowErr}-->
+                        <span class="attention"><!--{$err}--></span>
+                    <!--{/foreach}-->
+    <!--{/if}-->
+    <!--{if $arrRowResult}-->
+                    <!--{foreach item=result from=$arrRowResult}-->
+                    <span><!--{$result}--><br/></span>
+                    <!--{/foreach}-->
+    <!--{/if}-->
+            </td>
+        </tr>
+    </table>
+    <!--▲登録テーブルここまで-->
+    <div class="btn-area">
+        <ul>
+            <li><a class="btn-action" href="java script:;" onclick="fnFormModeSubmit('form1', 'import', '', ''); return false;"><span class="btn-next">この内容で登録する</span></a></li>
+        </ul>
+    </div>
+</div>
+</form>
Index: data/module/CsvParser.php
===================================================================
--- data/module/CsvParser.php	(リビジョン 0)
+++ data/module/CsvParser.php	(リビジョン 0)
@@ -0,0 +1,306 @@
+<?php
+/**
+ * read and parse a CSV file
+ *
+ * usage:
+ *   <code>
+ *   $csv = new CsvParser('my_file.csv');
+ *   if ($csv->hasError()) {
+ *     // nice error handler ...
+ *     die;
+ *   }
+ *
+ *   while ($array = $csv->getNext()) {
+ *     print_r($array);
+ *   }
+ *   </code>
+ * 
+ *
+ * 
+ *
+ * Created: 2007-11-12
+ * Last update: 2007-11-20
+ *
+ * @link 
+ * @copyright 
+ * @author OKUMURA Yoshifumi 
+ * @package csvparser
+ * @version $Id$
+ */
+define('MAX_LINE_SIZE', 16384);
+define('END_OF_FILE', "\x1A");
+/**
+ * CSV parser
+ *
+ * @package csvparser
+ * @version $Id$
+ * @author 
+ */
+class CsvParser {
+	/**
+	 * @access private
+	 */
+	var $fp;
+
+	/**
+	 * @access private
+	 */
+	var $_error;
+
+	/**
+	 * @access private
+	 */
+	var $_header;
+
+	/**
+	 * @access private
+	 */
+	var $_filename;
+
+	/**
+	 * @access private
+	 */
+	var $_file_encoding;
+	var $_internal_encoding;
+	var $_total;
+	var $_readed;
+	var $_line_no;
+	var $_raw_data;
+	var $_eof;
+	var $_pointer;
+
+	/**
+	 *
+	 * @static
+	 * @access public
+	 * @param string $filename ファイル名
+	 * @param boolean $has_header (optional) 1行目がヘッダのときはTRUEにする
+	 * @param string $encoding
+	 * @return CsvFile
+	 */
+	function CsvParser($filename, $has_header = FALSE, $encoding = 'Windows-31J') {
+		$this->_error             = NULL;
+		$this->_header            = NULL;
+		$this->_filename          = $filename;
+		$this->_file_encoding     = $encoding;
+		$this->_internal_encoding = mb_internal_encoding();
+		$this->_total      = 0;
+		$this->_readed     = 0;
+		$this->_line_no    = 0;
+		$this->_eof        = FALSE;
+
+		if (($size = filesize($filename)) == FALSE) {
+			$this->_error = sprintf('%s: cannot get size', $filename);
+		}
+		$this->_total = $size;
+
+		if (! $this->openfile()) return;
+
+		if ($has_header) {
+			$this->_header = $this->readLine();
+		}
+	}
+
+	/**
+	 *
+	 * @access public
+	 * @return boolean
+	 */
+	function hasError() {
+		return !empty($this->_error);
+	}
+
+	/**
+	 *
+	 * @return string
+	 */
+	function getError() {
+		return $this->_error;
+	}
+	
+	/**
+	 * ファイルサイズを返す
+	 * @return integer
+	 */
+	function getSize() {
+		return $this->_total;
+	}
+
+	/**
+	 * 読み込み済みのバイト数を返す
+	 * @return integer
+	 */
+	function getReadedSize() {
+		return $this->_readed;
+	}
+
+	/**
+	 *
+	 * @return string
+	 */
+	function getFileName() {
+		return $this->_filename;
+	}
+
+	/**
+	 *
+	 *
+	 * @access public
+	 * @return array
+	 */
+	function getNext() {
+		return $this->readLine();
+	}
+
+	/**
+	 * 行番号を返す
+	 *
+	 * @return integer
+	 */
+	function getLineNo() {
+		return $this->_line_no;
+	}
+
+	/**
+	 * パース前のデータを返す
+	 * getNext()が呼ばれたあとじゃないとダメ
+	 *
+	 * @return string
+	 */
+	function getRawData() {
+		return $this->_raw_data;
+	}
+
+
+	/**
+	 *
+	 * @return boolean
+	 */
+	function eof() {
+		return $this->_eof;
+	}
+
+	/**
+	 * ヘッダをキーとして連想配列を返す
+	 *
+	 * @return array
+	 */
+	function getNextAssoc() {
+		$line = $this->getNext();
+
+		if (empty($this->_header) || empty($line)) return $line;
+
+		$result = array();
+		$count = count($this->_header);
+		for ($i = 0; $i < $count; $i++) {
+			$result[$this->_header[$i]] = array_shift($line);
+		}
+		return $result;
+	}
+
+	/**
+	 *
+	 * @access private
+	 */
+	function readLine() {
+		if (!is_resource($this->fp)) {
+			$this->_eof = TRUE;
+			return NULL;
+		}
+
+		if (feof($this->fp)) {
+			fclose($this->fp);
+			$this->fp = NULL;
+			$this->_eof = TRUE;
+			return NULL;
+		}
+
+		$this->_line_no++;
+		$line = fgets($this->fp, MAX_LINE_SIZE);
+		$this->_raw_data = $line;
+
+		if ($line == END_OF_FILE) {
+			$this->_eof = TRUE;
+			return NULL;
+		}
+
+		if (strlen($line) == 0) return NULL;
+
+		while ((substr_count($line, '"') % 2) == 1 && !feof($this->fp)) {
+			$line .= fgets($this->fp, MAX_LINE_SIZE);
+		}
+
+		$this->_readed += strlen($line);
+
+		// #getRawData()のため
+		$this->_raw_data = $line;
+
+		mb_convert_variables($this->_internal_encoding, $this->_file_encoding, $line);
+
+		$line = preg_replace('/(?:\x0D\x0A|[\x0D\x0A])?$/', '', $line);
+		$line .= ',';
+		if (preg_match_all('/("[^"]*(?:""[^"]*)*"|[^,]*),/', $line, $matches) == 0) {
+			$this->_error = 'cannot parse line';
+			return NULL;
+		}
+		
+		return array_map(array(&$this, 'dequote'), $matches[1]);
+	}
+
+	/**
+	 * remove double quote
+	 * @access private
+	 */
+	function dequote($column) {
+		if (preg_match('/^"(.*)"$/s', $column, $matches)) {
+			return str_replace('""', '"', $matches[1]);
+		}
+		else {
+			return $column;
+		}
+	}
+
+	/**
+	 *
+	 */
+	function openfile() {
+		if (($this->fp = fopen($this->_filename, 'r')) === FALSE) {
+			$this->_error = sprintf('%s: cannot open', $this->_filename);
+			return FALSE;
+		}
+		return TRUE;
+	}
+
+	/**
+	 *
+	 */
+	function __sleep() {
+		if (is_resource($this->fp)) {
+			$this->_pointer = ftell($this->fp);
+			fclose($this->fp);
+		}
+		return array('fp',
+			     '_error',
+			     '_header',
+			     '_filename',
+			     '_file_encoding',
+			     '_internal_encoding',
+			     '_total',
+			     '_readed',
+			     '_line_no',
+			     '_raw_data',
+			     '_eof',
+			     '_pointer',
+			     );
+	}
+
+	/**
+	 *
+	 */
+	function __wakeup() {
+		if ($this->openfile()) {
+			fseek($this->fp, $this->_pointer);
+		}
+		return;
+	}
+}
Index: data/class_extends/page_extends/admin/customer/LC_Page_Admin_Customer_Import_Ex.php
===================================================================
--- data/class_extends/page_extends/admin/customer/LC_Page_Admin_Customer_Import_Ex.php	(リビジョン 0)
+++ data/class_extends/page_extends/admin/customer/LC_Page_Admin_Customer_Import_Ex.php	(リビジョン 0)
@@ -0,0 +1,46 @@
+<?php
+/** 
+ * 顧客登録CSV
+ *
+ * @version $Revision$
+ */
+// {{{ requires
+require_once CLASS_REALDIR . 'pages/admin/customer/LC_Page_Admin_Customer_Import.php';
+
+/**
+ * 顧客登録CSV
+ *
+ */
+class LC_Page_Admin_Customer_Import_Ex extends LC_Page_Admin_Customer_Import {
+
+    // }}}
+    // {{{ functions
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    function process() {
+        parent::process();
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+}
+?>
Index: data/class/pages/admin/customer/LC_Page_Admin_Customer_Import.php
===================================================================
--- data/class/pages/admin/customer/LC_Page_Admin_Customer_Import.php	(リビジョン 0)
+++ data/class/pages/admin/customer/LC_Page_Admin_Customer_Import.php	(リビジョン 0)
@@ -0,0 +1,376 @@
+<?php
+/** 
+ * 顧客登録CSV
+ *
+ * @package eccube
+ * @version $Revision$
+ */
+require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
+require_once CLASS_EX_REALDIR . 'helper_extends/SC_Helper_Customer_Ex.php';
+require_once CLASS_EX_REALDIR . 'util_extends/SC_Utils_Ex.php';
+require_once DATA_REALDIR . 'module/CsvParser.php';
+
+/** 
+ * 顧客登録CSV
+ *
+ * @package eccube
+ */
+class LC_Page_Admin_Customer_Import extends LC_Page_Admin_Ex {
+    /**
+     * dtb_csvテーブルのcsv_id
+     * @var integer
+     */
+    public $csv_id = 101;
+    public $tpl_mainpage = 'customer/import.tpl';
+    public $tpl_mainno = 'customer';
+    public $tpl_subno = 'import';
+    public $tpl_maintitle = '顧客管理';
+    public $tpl_subtitle = '顧客登録CSV';
+    public $arrTitle = array();
+
+    /**
+     * Page を初期化する.
+     *
+     * @return void
+     */
+    function init() {
+        parent::init();
+
+        $this->httpCacheControl('nocache');
+    }
+
+    /**
+     * Page のプロセス.
+     *
+     * @return void
+     */
+    public function process() {
+        parent::process();
+        $this->action();
+        $this->sendResponse();
+    }
+    
+    /**
+     * Page のアクション.
+     *
+     * @return void
+     */
+    function action() {
+        $form = Customer_Import_FormParam_Creator::create();
+        $form->setHtmlDispNameArray();
+        $this->arrTitle = $form->getHtmlDispNameArray();
+        
+        switch ($this->getMode()) {
+          case 'import':
+            $this->doImport('csv_file');
+            break;
+            
+          default:
+            break;
+        }
+    }
+    
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    private function doImport($field) {
+        $file = Customer_Import_UploadFile_Creator::create($field);
+
+        if (count($err = $file->checkExists()) > 0) {
+            $this->arrErr = $err;
+            return;
+        }
+
+        $path = $file->getTempFilePath($field);
+
+        $importer = new Customer_Csv_Importer();
+        $importer->execute($path);
+        
+        $this->arrErr = $importer->getErrors();
+        $this->arrRowErr = $importer->getCsvErrors();
+        $this->arrRowResult = $importer->getCsvResults();
+    }
+    
+}
+
+/** 
+ * CSVインポートを実行します
+ *
+ * @package eccube
+ */
+class Customer_Csv_Importer {
+    private $errors = array();
+    private $csv_errors = array();
+    private $csv_results = array();
+    
+    /** 
+     * メッセージテンプレート
+     */
+    private $col_message =
+      "%d行目:※ 項目数が%d個検出されました。項目数は%d個になります。";
+    private $gen_message = "%d行目:%s";
+    private $res_message = "%d行目:顧客ID:%s / 名前:%s";
+    private $pref_message = "%d行目:都道府県が正しくありません。:%s";
+    
+    /** 
+     * 実行します
+     *
+     *
+     * @param string $path ファイルパス
+     * @return boolean 成功時:true
+     */
+    public function execute($path) {
+        if (($csv = $this->createCsvParser($path)) === false) return false;
+        if (!$this->validateCsv($csv)) return false;
+
+        if (($csv = $this->createCsvParser($path)) === false) return false;
+        if (!$this->importCsv($csv)) return false;
+        
+        return true;
+    }
+
+    /** 
+     * 入力検査
+     * 
+     */
+    private function validateCsv($csv) {
+        $ret = true;
+        $form = Customer_Import_FormParam_Creator::create();
+        $col_max_count = $form->getCount();
+
+        while ($row = $csv->getNext()) {
+            if (empty($row)) continue;
+
+            /* 列数チェック */
+            $col_count = count($row);
+            if ($col_max_count != $col_count) {
+                $this->csv_errors[] =
+                  sprintf($this->col_message,
+                          $csv->getLineNo(), $col_count, $col_max_count);
+                $ret = false;
+                break;
+            }
+
+            /* 固有のチェック */
+            $form->setParam($row, true);
+            $form->convParam();
+            $form_errors = $form->checkError(false);
+
+            if (count($form_errors) > 0) {
+                foreach ($form_errors as $i) {
+                    $this->csv_errors[] = sprintf($this->gen_message,
+                                                  $csv->getLineNo(), $i);
+                }
+                $ret = false;
+            }
+
+            /* 都道府県の検査 */
+            $vars = $form->getHashArray();
+            $pref_id = $this->getPrefId($vars['pref']);
+            if (is_null($pref_id)) {
+                $this->csv_errors = sprintf($this->pref_message,
+                                            $csv->getLineNo(), $vars['pref']);
+                $ret = false;
+            }
+        }
+
+        return $ret;
+    }
+
+    private function importCsv($csv) {
+        $ret = true;
+
+        $form = Customer_Import_FormParam_Creator::create();
+        
+        $objQuery = SC_Query_Ex::getSingletonInstance();
+        $objQuery->begin();
+        
+        while ($row = $csv->getNext()) {
+            if (empty($row)) continue;
+
+            $form->setParam($row, true);
+            $form->convParam();
+
+            $salt = SC_Utils_Ex::sfGetRandomString(10);
+            
+            $vars = $form->getHashArray();
+            $vars['update_date'] = date("Y-m-d H:i:s");
+            $vars['pref'] = $this->getPrefId($vars['pref']);
+            $vars['password'] =
+              SC_Utils_Ex::sfGetHashString($vars['password'], $salt);
+             
+            $customer_id = $this->getCustomerId($vars['customer_id']);
+
+            if (is_null($customer_id)) {
+                $this->insert($vars);
+            }
+            else {
+                $this->update($customer_id, $vars);
+            }
+
+            $this->csv_results[] =
+              sprintf($this->res_message,
+                      $csv->getLineNo(),
+                      $vars['customer_id'],
+                      $vars['name01']);
+        }
+
+        $objQuery->commit();
+        
+        return $ret;
+    }
+
+    private function insert($vars) {
+        $objQuery = SC_Query_Ex::getSingletonInstance();
+
+        $vars['customer_id'] = $objQuery->nextVal('dtb_customer_customer_id');
+        $vars['secret_key'] = SC_Utils_Ex::sfGetUniqRandomId('r');
+        $vars['status'] = 2;    /* 本会員 */
+        $vars['del_flg'] = 0;   /* 未削除 */
+        $vars["create_date"] = 'CURRENT_TIMESTAMP';
+
+        $r = $objQuery->insert('dtb_customer', $vars);
+    }
+
+    private function update($customer_id, $vars) {
+        $objQuery = SC_Query_Ex::getSingletonInstance();
+
+        $objQuery->update('dtb_customer', $vars,
+                          'customer_id = ?', array($customer_id));
+    }
+
+    /** 
+     * mtb_pref.idを返す
+     *
+     * @param string $pref_name
+     * @return integer
+     */
+    private function getPrefId($pref_name) {
+        $objQuery = SC_Query_Ex::getSingletonInstance();
+
+        $result = $objQuery->select('id', 'mtb_pref',
+                                    'name = ?', array($pref_name));
+
+        return isset($result[0]['id']) ?
+          $result[0]['id'] : null;
+    }
+    
+    /** 
+     * customer_idを返す
+     * 見つからなければnullを返す
+     *
+     * @param integer $customer_id
+     * @return integer
+     */
+    private function getCustomerId($customer_id) {
+        $objQuery = SC_Query_Ex::getSingletonInstance();
+
+        $result = $objQuery->select('customer_id', 'dtb_customer',
+                                    'customer_id = ?', array($customer_id));
+
+        return isset($result[0]['customer_id']) ?
+          $result[0]['customer_id'] : null;
+    }
+
+    private function createCsvParser($path) {
+        $csv = new CsvParser($path, true);
+
+        if ($csv->hasError()) {
+            $this->errors = array($field => $csv->getError());
+            return false;
+        }
+
+        return $csv;
+    }
+    
+    /** 
+     * エラーメッセージの配列を返す
+     *
+     * @return array
+     */
+    public function getErrors() {
+        return $this->errors;
+    }
+    
+    /** 
+     * CSV各行のエラーを返す
+     *
+     * @return array
+     */
+    public function getCsvErrors() {
+        return $this->csv_errors;
+    }
+
+    public function getCsvResults() {
+        return $this->csv_results;
+    }
+}
+
+
+/** 
+ * SC_UploadFile_Exオブジェクトを作るクラスです
+ *
+ * @package eccube
+ */
+class Customer_Import_UploadFile_Creator {
+    /** 
+     * SC_UploadFile_Exを返す
+     * 
+     * @return SC_UploadFile_Ex
+     */
+    public function create($field) {
+        $ret = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
+
+        $ret->addFile("CSVファイル", $field, array('csv'), CSV_SIZE, true, 0, 0, false);
+        $ret->makeTempFile($field);
+        
+        return $ret;
+    }
+}
+
+
+
+/** 
+ * CSVインポート用の FormParam_Exを作る
+ *
+ * @package eccube
+ */
+class Customer_Import_FormParam_Creator {
+    /** 
+     * FormParam_Exを返す
+     *
+     * @return SC_FormParam_Ex
+     */
+    public function create() {
+        $objFormParam = new SC_FormParam_Ex();
+        
+        $objFormParam->addParam("顧客ID", 'customer_id', INT_LEN, 'n', array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("パスワード", 'password', STEXT_LEN, 'a', array("EXIST_CHECK", "SPTAB_CHECK", "ALNUM_CHECK", "MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("会社名", 'name01', LTEXT_LEN, 'aKV', array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("会社名フリガナ", 'kana01', LTEXT_LEN, 'aKV', array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("担当者名", 'name02', LTEXT_LEN, 'aKV', array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("担当者名フリガナ", 'kana02', LTEXT_LEN, 'aKV', array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("郵便番号1", "zip01", ZIP01_LEN, 'n', array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objFormParam->addParam("郵便番号2", "zip02", ZIP02_LEN, 'n', array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
+        $objFormParam->addParam("都道府県", 'pref', STEXT_LEN, 'aKV', array("EXIST_CHECK"));
+        $objFormParam->addParam("住所1", "addr01", MTEXT_LEN, 'aKV', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("住所2", "addr02", MTEXT_LEN, 'aKV', array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("お電話番号1", 'tel01', TEL_ITEM_LEN, 'n', array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("お電話番号2", 'tel02', TEL_ITEM_LEN, 'n', array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+        $objFormParam->addParam("お電話番号3", 'tel03', TEL_ITEM_LEN, 'n', array("EXIST_CHECK", "SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
+        $objFormParam->addParam('メールアドレス', 'email', null, 'a', array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK"));
+        
+        return $objFormParam;
+    }
+}
+
スレッド表示 | 古いものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,307名です
総投稿数は109,692件です

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1568
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.