Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 67c3176d50168df11afc3eaff737635fbabc462b @kurozumi-sub kurozumi-sub committed Jan 10, 2017
@@ -0,0 +1,3 @@
+*.tar.gz
+!.gitkeep
+/nbproject
@@ -0,0 +1,300 @@
+<?php
+
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2014 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.
+ *
+ *
+ */
+
+/**
+ * プラグインの基底クラス
+ *
+ * @package Plugin
+ * @author LOCKON CO.,LTD.
+ * @version $Id: $
+ */
+class CustomerDiscountRate extends SC_Plugin_Base
+{
+ /**
+ * コンストラクタ
+ *
+ * @param array $arrSelfInfo 自身のプラグイン情報
+ * @return void
+ */
+ public function __construct(array $arrSelfInfo)
+ {
+ // プラグインを有効化したときの初期設定をココに追加する
+ if ($arrSelfInfo["enable"] == 1) {
+
+ }
+
+ }
+
+ /**
+ * インストール
+ * installはプラグインのインストール時に実行されます.
+ * 引数にはdtb_pluginのプラグイン情報が渡されます.
+ *
+ * @param array $arrPlugin plugin_infoを元にDBに登録されたプラグイン情報(dtb_plugin)
+ * @return void
+ */
+ public function install($arrPlugin, $objPluginInstaller = null)
+ {
+ // テーブル作成
+ self::createTable();
+
+ // htmlディレクトリにファイルを配置。
+ $src_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/html/";
+ $dest_dir = HTML_REALDIR;
+ SC_Utils::copyDirectory($src_dir, $dest_dir);
+
+ // テンプレートを配置。
+ $src_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/data/Smarty/templates/";
+ $dest_dir = SMARTY_TEMPLATES_REALDIR;
+ SC_Utils::copyDirectory($src_dir, $dest_dir);
+
+ }
+
+ /**
+ * アンインストール
+ * uninstallはアンインストール時に実行されます.
+ * 引数にはdtb_pluginのプラグイン情報が渡されます.
+ *
+ * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin)
+ * @return void
+ */
+ public function uninstall($arrPlugin, $objPluginInstaller = null)
+ {
+ // テーブル削除
+ self::dropTable();
+
+ // htmlディレクトリのファイルを削除。
+ $target_dir = HTML_REALDIR;
+ $source_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/html/";
+ self::deleteDirectory($target_dir, $source_dir);
+
+ // テンプレートを削除。
+ $target_dir = SMARTY_TEMPLATES_REALDIR;
+ $source_dir = PLUGIN_UPLOAD_REALDIR . "{$arrPlugin["plugin_code"]}/data/Smarty/templates/";
+ self::deleteDirectory($target_dir, $source_dir);
+
+ }
+
+ /**
+ * 稼働
+ * enableはプラグインを有効にした際に実行されます.
+ * 引数にはdtb_pluginのプラグイン情報が渡されます.
+ *
+ * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin)
+ * @return void
+ */
+ public function enable($arrPlugin, $objPluginInstaller = null)
+ {
+
+ }
+
+ /**
+ * 停止
+ * disableはプラグインを無効にした際に実行されます.
+ * 引数にはdtb_pluginのプラグイン情報が渡されます.
+ *
+ * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin)
+ * @return void
+ */
+ public function disable($arrPlugin, $objPluginInstaller = null)
+ {
+
+ }
+
+ /**
+ * プラグインヘルパーへ, コールバックメソッドを登録します.
+ *
+ * @param integer $priority
+ */
+ public function register(SC_Helper_Plugin $objHelperPlugin, $priority)
+ {
+ $objHelperPlugin->addAction("loadClassFileChange", array(&$this, "loadClassFileChange"), $priority);
+ $objHelperPlugin->addAction("prefilterTransform", array(&$this, "prefilterTransform"), $priority);
+ $objHelperPlugin->addAction("LC_Page_Admin_Customer_Edit_action_after", array(&$this, "admin_customer_edit_action_after"), $priority);
+
+ }
+
+ /**
+ * SC_系のクラスをフックする
+ *
+ * @param type $classname
+ * @param type $classpath
+ */
+ public function loadClassFileChange(&$classname, &$classpath)
+ {
+ $base_path = PLUGIN_UPLOAD_REALDIR . basename(__DIR__) . "/data/class/";
+ $helper_path = $base_path . "helper/";
+
+ if ($classname == "SC_Product_Ex") {
+ $classname = "plg_CustomerDiscountRate_SC_Product";
+ $classpath = $base_path . $classname . ".php";
+ }
+ if ($classname == "SC_Helper_Customer_Ex") {
+ $classname = "plg_CustomerDiscountRate_SC_Helper_Customer";
+ $classpath = $helper_path . $classname . ".php";
+ }
+
+ }
+
+ public function admin_customer_edit_action_after(LC_Page_EX $objPage)
+ {
+ // モードによる処理切り替え
+ switch ($objPage->getMode()) {
+ case 'edit_search':
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $ret = $objQuery->getRow('*', 'plg_customer_discount_rate', 'customer_id = ? ', array($objPage->arrForm['customer_id']));
+ $objPage->arrForm['discount_rate'] = $ret['discount_rate'];
+ break;
+ case 'confirm':
+ break;
+ case 'complete':
+ $objPage->arrForm['customer_id'];
+ $arrData['discount_rate'] = $objPage->arrForm['discount_rate'];
+ SC_Helper_Customer_Ex::sfEditDiscountRateData($arrData, $objPage->arrForm['customer_id']);
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ /**
+ * テンプレートをフックする
+ *
+ * @param string &$source
+ * @param LC_Page_Ex $objPage
+ * @param string $filename
+ * @return void
+ */
+ public function prefilterTransform(&$source, LC_Page_Ex $objPage, $filename)
+ {
+ $objTransform = new SC_Helper_Transform($source);
+ switch ($objPage->arrPageLayout['device_type_id']) {
+ case DEVICE_TYPE_PC:
+ break;
+ case DEVICE_TYPE_MOBILE:
+ break;
+ case DEVICE_TYPE_SMARTPHONE:
+ break;
+ case DEVICE_TYPE_ADMIN:
+ default:
+ if (strpos($filename, "customer/edit.tpl") !== false) {
+ $template_path = "customer/plg_CustomerDiscountRate_edit.tpl";
+ $template = "<!--{include file='{$template_path}'}-->";
+ $objTransform->select('#customer table.form')->appendChild($template);
+ }
+ if (strpos($filename, "customer/edit_confirm.tpl") !== false) {
+ $template_path = "customer/plg_CustomerDiscountRate_edit_confirm.tpl";
+ $template = "<!--{include file='{$template_path}'}-->";
+ $objTransform->select('#customer table.form')->appendChild($template);
+ }
+ break;
+ }
+ $source = $objTransform->getHTML();
+
+ }
+
+ /**
+ * 指定されたパスを比較して再帰的に削除します。
+ *
+ * @param string $target_dir 削除対象のディレクトリ
+ * @param string $source_dir 比較対象のディレクトリ
+ */
+ public static function deleteDirectory($target_dir, $source_dir)
+ {
+ $dir = opendir($source_dir);
+ while ($name = readdir($dir)) {
+ if ($name == '.' || $name == '..') {
+ continue;
+ }
+
+ $target_path = $target_dir . '/' . $name;
+ $source_path = $source_dir . '/' . $name;
+
+ if (is_file($source_path)) {
+ if (is_file($target_path)) {
+ unlink($target_path);
+ GC_Utils::gfPrintLog("$target_path を削除しました。");
+ }
+ } elseif (is_dir($source_path)) {
+ if (is_dir($target_path)) {
+ self::deleteDirectory($target_path, $source_path);
+ }
+ }
+ }
+ closedir($dir);
+
+ }
+
+ /**
+ * テーブルの追加
+ *
+ * @return void
+ */
+ public static function createTable()
+ {
+ $objQuery = & SC_Query_Ex::getSingletonInstance();
+ switch (DB_TYPE) {
+ case "pgsql":
+ $sql = <<< __EOS__
+ CREATE TABLE plg_customer_discount_rate (
+ customer_id int NOT NULL,
+ discount_rate int,
+ create_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_date timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (customer_id)
+ );
+__EOS__;
+ break;
+ case "mysql":
+ $sql = <<< __EOS__
+ CREATE TABLE plg_customer_discount_rate (
+ customer_id int NOT NULL,
+ discount_rate int,
+ create_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ update_date timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (customer_id)
+ ) ENGINE=InnoDB ;
+__EOS__;
+ break;
+ }
+ $objQuery->query($sql);
+
+ }
+
+ /**
+ * テーブルの削除
+ *
+ * @return void
+ */
+ public static function dropTable($table)
+ {
+ $objQuery = & SC_Query_Ex::getSingletonInstance();
+ $objQuery->query("DROP TABLE plg_customer_discount_rate");
+
+ }
+
+}
No changes.
@@ -0,0 +1,31 @@
+<!--{*
+/*
+* This file is part of EC-CUBE
+*
+* Copyright(c) 2000-2014 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.
+*/
+*}-->
+
+<tr>
+ <th>割引率<span class="attention"> *</span></th>
+ <td>
+ <span class="attention"><!--{$arrErr.discount_rate}--></span>
+ <input type="text" name="discount_rate" value="<!--{$arrForm.discount_rate|h}-->" maxlength="<!--{$smarty.const.TEL_LEN}-->" size="6" class="box6" /> %
+ </td>
+</tr>
@@ -0,0 +1,28 @@
+<!--{*
+/*
+* This file is part of EC-CUBE
+*
+* Copyright(c) 2000-2014 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.
+*/
+*}-->
+
+<tr>
+ <th>割引率</th>
+ <td><!--{$arrForm.discount_rate|default:"0"|h}--> %</td>
+</tr>
No changes.
No changes.
No changes.
No changes.
Oops, something went wrong.

0 comments on commit 67c3176

Please sign in to comment.