コード例 #1
0
 /**
  * SC_UploadFileクラスの初期化.
  *
  * @param object $objForm SC_FormParamのインスタンス
  * @return object SC_UploadFileのインスタンス
  */
 function lfInitUploadFile($objForm)
 {
     $pkg_dir = SMARTY_TEMPLATES_DIR . $objForm->getValue('template_code');
     $objUpFile = new SC_UploadFile(TEMPLATE_TEMP_DIR, $pkg_dir);
     $objUpFile->addFile("テンプレートファイル", 'template_file', array(), TEMPLATE_SIZE, true, 0, 0, false);
     return $objUpFile;
 }
 /**
  * CSVアップロードを実行する
  *
  * @param SC_FormParam  $objFormParam
  * @param SC_UploadFile $objUpFile
  * @param SC_Helper_DB  $objDb
  * @return void
  */
 function doUploadCsv(&$objFormParam, &$objUpFile)
 {
     // ファイルアップロードのチェック
     $objUpFile->makeTempFile('csv_file');
     $arrErr = $objUpFile->checkExists();
     if (count($arrErr) > 0) {
         $this->arrErr = $arrErr;
         return;
     }
     // 一時ファイル名の取得
     $filepath = $objUpFile->getTempFilePath('csv_file');
     // CSVファイルの文字コード変換
     $enc_filepath = SC_Utils_Ex::sfEncodeFile($filepath, CHAR_CODE, CSV_TEMP_REALDIR);
     // CSVファイルのオープン
     $fp = fopen($enc_filepath, 'r');
     // 失敗した場合はエラー表示
     if (!$fp) {
         SC_Utils_Ex::sfDispError('');
     }
     // 登録先テーブル カラム情報の初期化
     $this->lfInitTableInfo();
     // 登録フォーム カラム情報
     $this->arrFormKeyList = $objFormParam->getKeyList();
     // 登録対象の列数
     $col_max_count = $objFormParam->getCount();
     // 行数
     $line_count = 0;
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->begin();
     $errFlag = false;
     while (!feof($fp)) {
         $arrCSV = fgetcsv($fp, CSV_LINE_MAX);
         // 行カウント
         $line_count++;
         // ヘッダ行はスキップ
         if ($line_count == 1) {
             continue;
         }
         // 空行はスキップ
         if (empty($arrCSV)) {
             continue;
         }
         // 列数が異なる場合はエラー
         $col_count = count($arrCSV);
         if ($col_max_count != $col_count) {
             $this->addRowErr($line_count, t('c_* T_ARG1 was detected for the item quantity. The item quantity is T_ARG2._01', array('T_ARG1' => $col_count, 'T_ARG2' => $col_max_count)));
             $errFlag = true;
             break;
         }
         // シーケンス配列を格納する。
         $objFormParam->setParam($arrCSV, true);
         $arrRet = $objFormParam->getHashArray();
         $objFormParam->setParam($arrRet);
         // 入力値の変換
         $objFormParam->convParam();
         // <br>なしでエラー取得する。
         $arrCSVErr = $this->lfCheckError($objFormParam);
         // 入力エラーチェック
         if (count($arrCSVErr) > 0) {
             foreach ($arrCSVErr as $err) {
                 $this->addRowErr($line_count, $err);
             }
             $errFlag = true;
             break;
         }
         $category_id = $this->lfRegistCategory($objQuery, $line_count, $objFormParam);
         $this->addRowResult($line_count, t('c_Category ID: T_ARG1 /Category name: T_ARG2_01', array('T_ARG1' => $category_id, 'T_ARG2' => $objFormParam->getValue('category_name'))));
     }
     // 実行結果画面を表示
     $this->tpl_mainpage = 'products/upload_csv_category_complete.tpl';
     fclose($fp);
     if ($errFlag) {
         $objQuery->rollback();
         return;
     }
     $objQuery->commit();
     // カテゴリ件数を更新
     SC_Helper_DB_EX::sfCountCategory($objQuery);
     return;
 }
コード例 #3
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     //---- ページ初期設定
     $conn = new SC_DBConn();
     $objView = new SC_AdminView();
     $objDate = new SC_Date();
     $objQuery = new SC_Query();
     $objDb = new SC_Helper_DB_Ex();
     $this->objDate = $objDate;
     $this->arrTemplate = $this->getTemplateList($conn);
     $objSess = new SC_Session();
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     /*
      query:配信履歴「確認」
     */
     if ($_GET["mode"] == "query" && SC_Utils_Ex::sfCheckNumLength($_GET["send_id"])) {
         // 送信履歴より、送信条件確認画面
         $sql = "SELECT search_data FROM dtb_send_history WHERE send_id = ?";
         $result = $conn->getOne($sql, array($_GET["send_id"]));
         $tpl_path = "mail/query.tpl";
         $list_data = unserialize($result);
         // 都道府県を変換
         $list_data['pref_disp'] = $this->arrPref[$list_data['pref']];
         // 配信形式
         $list_data['htmlmail_disp'] = $this->arrHtmlmail[$list_data['htmlmail']];
         // 性別の変換
         if (count($list_data['sex']) > 0) {
             foreach ($list_data['sex'] as $key => $val) {
                 $list_data['sex'][$key] = $this->arrSex[$val];
                 $sex_disp .= $list_data['sex'][$key] . " ";
             }
             $list_data['sex_disp'] = $sex_disp;
         }
         // 職業の変換
         if (count($list_data['job']) > 0) {
             foreach ($list_data['job'] as $key => $val) {
                 $list_data['job'][$key] = $this->arrJob[$val];
                 $job_disp .= $list_data['job'][$key] . " ";
             }
             $list_data['job_disp'] = $job_disp;
         }
         // カテゴリ変換
         $arrCatList = $objDb->sfGetCategoryList();
         $list_data['category_name'] = $arrCatList[$list_data['category_id']];
         $this->list_data = $list_data;
         $this->arrCampaignList = $this->lfGetCampaignList($objQuery);
         $objView->assignobj($this);
         $objView->display($tpl_path);
         exit;
     }
     if ($_POST['mode'] == 'delete') {
     }
     switch ($_POST['mode']) {
         /*
          search:「検索」ボタン
          back:検索結果画面「戻る」ボタン
         */
         case 'delete':
         case 'search':
         case 'back':
             //-- 入力値コンバート
             $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn);
             //-- 入力エラーのチェック
             $this->arrErr = $this->lfErrorCheck($this->list_data);
             //-- 検索開始
             if (!is_array($this->arrErr)) {
                 $this->list_data['name'] = isset($this->list_data['name']) ? SC_Utils_Ex::sfManualEscape($this->list_data['name']) : "";
                 // hidden要素作成
                 $this->arrHidden = $this->lfGetHidden($this->list_data);
                 //-- 検索データ取得
                 $objSelect = new SC_CustomerList($this->list_data, "magazine");
                 // 生成されたWHERE文を取得する
                 list($where, $arrval) = $objSelect->getWhere();
                 // 「WHERE」部分を削除する。
                 $where = ereg_replace("^WHERE", "", $where);
                 // 検索結果の取得
                 $from = "dtb_customer";
                 // 行数の取得
                 $linemax = $objQuery->count($from, $where, $arrval);
                 $this->tpl_linemax = $linemax;
                 // 何件が該当しました。表示用
                 // ページ送りの取得
                 $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnResultPageNavi", NAVI_PMAX);
                 $this->arrPagenavi = $objNavi->arrPagenavi;
                 $startno = $objNavi->start_row;
                 // 取得範囲の指定(開始行番号、行数のセット)
                 $objQuery->setlimitoffset(SEARCH_PMAX, $startno);
                 // 表示順序
                 $objQuery->setorder("customer_id DESC");
                 // 検索結果の取得
                 $col = $objSelect->getMailMagazineColumn($this->lfGetIsMobile($_POST['mail_type']));
                 $this->arrResults = $objQuery->select($col, $from, $where, $arrval);
                 //現在時刻の取得
                 $this->arrNowDate = $this->lfGetNowDate();
             }
             break;
             /*
              input:検索結果画面「htmlmail内容設定」ボタン
             */
         /*
          input:検索結果画面「htmlmail内容設定」ボタン
         */
         case 'input':
             //-- 入力値コンバート
             $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn);
             //-- 入力エラーのチェック
             $this->arrErr = $this->lfErrorCheck($this->list_data);
             //-- エラーなし
             if (!is_array($this->arrErr)) {
                 //-- 現在時刻の取得
                 $this->arrNowDate = $this->lfGetNowDate();
                 $this->arrHidden = $this->lfGetHidden($this->list_data);
                 // hidden要素作成
                 $this->tpl_mainpage = 'mail/input.tpl';
             }
             break;
             /*
              template:テンプレート選択
             */
         /*
          template:テンプレート選択
         */
         case 'template':
             //-- 入力値コンバート
             $this->list_data = $this->lfConvertParam($_POST, $this->arrSearchColumn);
             //-- 時刻設定の取得
             $this->arrNowDate['year'] = isset($_POST['send_year']) ? $_POST['send_year'] : "";
             $this->arrNowDate['month'] = isset($_POST['send_month']) ? $_POST['send_month'] : "";
             $this->arrNowDate['day'] = isset($_POST['send_day']) ? $_POST['send_day'] : "";
             $this->arrNowDate['hour'] = isset($_POST['send_hour']) ? $_POST['send_hour'] : "";
             $this->arrNowDate['minutes'] = isset($_POST['send_minutes']) ? $_POST['send_minutes'] : "";
             //-- 入力エラーのチェック
             $this->arrErr = $this->lfErrorCheck($this->list_data);
             //-- 検索開始
             if (!is_array($this->arrErr)) {
                 $this->list_data['name'] = isset($this->list_data['name']) ? SC_Utils_Ex::sfManualEscape($this->list_data['name']) : "";
                 $this->arrHidden = $this->lfGetHidden($this->list_data);
                 // hidden要素作成
                 $this->tpl_mainpage = 'mail/input.tpl';
                 $template_data = $this->getTemplateData($conn, $_POST['template_id']);
                 if ($template_data) {
                     foreach ($template_data as $key => $val) {
                         $this->list_data[$key] = $val;
                     }
                 }
                 //-- HTMLテンプレートを使用する場合は、HTMLソースを生成してBODYへ挿入
                 if ($this->list_data["mail_method"] == 3) {
                     $objTemplate = new LC_HTMLtemplate();
                     $objTemplate->list_data = lfGetHtmlTemplateData($_POST['template_id']);
                     $objSiteInfo = new SC_SiteInfo();
                     $objTemplate->arrInfo = $objSiteInfo->data;
                     //メール担当写真の表示
                     $objUpFile = new SC_UploadFile(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
                     $objUpFile->addFile("メール担当写真", 'charge_image', array('jpg'), IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
                     $objUpFile->setDBFileList($objTemplate->list_data);
                     $objTemplate->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
                     $objMakeTemplate = new SC_AdminView();
                     $objMakeTemplate->assignobj($objTemplate);
                     $this->list_data["body"] = $objMakeTemplate->fetch("mail/html_template.tpl");
                 }
             }
             break;
             /*
              regist_confirm:「入力内容を確認」
              regist_back:「テンプレート設定画面へ戻る」
              regist_complete:「登録」
             */
         /*
          regist_confirm:「入力内容を確認」
          regist_back:「テンプレート設定画面へ戻る」
          regist_complete:「登録」
         */
         case 'regist_confirm':
         case 'regist_back':
         case 'regist_complete':
             //-- 入力値コンバート
             $this->arrCheckColumn = array_merge($this->arrSearchColumn, $this->arrRegistColumn);
             $this->list_data = $this->lfConvertParam($_POST, $this->arrCheckColumn);
             //現在時刻の取得
             $this->arrNowDate = $this->lfGetNowDate();
             //-- 入力エラーのチェック
             $this->arrErr = $this->lfErrorCheck($this->list_data, 1);
             $this->tpl_mainpage = 'mail/input.tpl';
             $this->arrHidden = $this->lfGetHidden($this->list_data);
             // hidden要素作成
             //-- 検索開始
             if (!is_array($this->arrErr)) {
                 $this->list_data['name'] = isset($this->list_data['name']) ? SC_Utils_Ex::sfManualEscape($this->list_data['name']) : "";
                 if ($_POST['mode'] == 'regist_confirm') {
                     $this->tpl_mainpage = 'mail/input_confirm.tpl';
                 } else {
                     if ($_POST['mode'] == 'regist_complete') {
                         $this->lfRegistData($conn, $this->list_data);
                         if (MELMAGA_SEND == true) {
                             if (MELMAGA_BATCH_MODE) {
                                 $this->sendRedirect($this->getLocation(URL_DIR . "admin/mail/history.php"));
                             } else {
                                 $this->sendRedirect($this->getLocation(URL_DIR . "admin/mail/sendmail.php", array("mode" => "now")));
                             }
                             exit;
                         } else {
                             SC_Utils_Ex::sfErrorHeader(">> 本サイトではメルマガ配信は行えません。");
                         }
                     }
                 }
             }
             break;
         default:
             $this->list_data['mail_type'] = 1;
             break;
     }
     // 配信時間の年を、「現在年~現在年+1」の範囲に設定
     for ($year = date("Y"); $year <= date("Y") + 1; $year++) {
         $arrYear[$year] = $year;
     }
     $this->arrYear = $arrYear;
     $this->arrCustomerOrderId = $this->lfGetCustomerOrderId($_POST['buy_product_code']);
     $this->arrCatList = $objDb->sfGetCategoryList();
     $this->arrCampaignList = $this->lfGetCampaignList($objQuery);
     //---- ページ表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }
コード例 #4
0
 /**
  * ファイル情報の初期化を行う.
  *
  * @param SC_UploadFile $objUpFile
  * @return void
  */
 public function lfInitFile(SC_UploadFile &$objUpFile)
 {
     $objUpFile->addFile('CSVファイル', 'csv_file', array('csv'), CSV_SIZE, true, 0, 0, false);
 }
コード例 #5
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $conn = new SC_DBConn();
     $objView = new SC_AdminView();
     $objSess = new SC_Session();
     $objDate = new SC_Date();
     // 認証可否の判定
     SC_Utils_Ex::sfIsSuccess($objSess);
     if (!isset($_POST['body'])) {
         $_POST['body'] = "";
     }
     if (!isset($_REQUEST['method'])) {
         $_REQUEST['method'] = "";
     }
     if (!isset($_REQUEST['id'])) {
         $_REQUEST['id'] = "";
     }
     if (!isset($_GET['send_id'])) {
         $_GET['send_id'] = "";
     }
     if ($_POST['body']) {
         $this->body = $_POST['body'];
         // HTMLメールテンプレートのプレビュー
     } elseif ($_REQUEST["method"] == "template" && SC_Utils_Ex::sfCheckNumLength($_REQUEST['id'])) {
         $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ?";
         $result = $conn->getAll($sql, array($_REQUEST["id"]));
         $this->list_data = $result[0];
         //メール担当写真の表示
         $objUpFile = new SC_UploadFile(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
         $objUpFile->addFile("メール担当写真", 'charge_image', array('jpg'), IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
         $objUpFile->setDBFileList($this->list_data);
         // Form用配列を渡す。
         $this->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
         // メイン商品の情報取得
         $sql = "SELECT name, main_image, point_rate, deliv_fee, price01_min, price01_max, price02_min, price02_max FROM vw_products_allclass AS allcls WHERE product_id = ?";
         $main = $conn->getAll($sql, array($this->list_data["main_product_id"]));
         $this->list_data["main"] = $main[0];
         // サブ商品の情報取得
         $sql = "SELECT product_id, name, main_list_image, price01_min, price01_max, price02_min, price02_max FROM vw_products_allclass WHERE product_id = ?";
         $k = 0;
         $l = 0;
         for ($i = 1; $i <= 12; $i++) {
             if ($l == 4) {
                 $l = 0;
                 $k++;
             }
             $result = "";
             $j = sprintf("%02d", $i);
             if ($i > 0 && $i < 5) {
                 $k = 0;
             }
             if ($i > 4 && $i < 9) {
                 $k = 1;
             }
             if ($i > 8 && $i < 13) {
                 $k = 2;
             }
             if (is_numeric($this->list_data["sub_product_id" . $j])) {
                 $result = $conn->getAll($sql, array($this->list_data["sub_product_id" . $j]));
                 $this->list_data["sub"][$k][$l] = $result[0];
                 $this->list_data["sub"][$k]["data_exists"] = "OK";
                 //当該段にデータが1つ以上存在するフラグ
             }
             $l++;
         }
         $this->tpl_mainpage = 'mail/html_template.tpl';
     } elseif (SC_Utils_Ex::sfCheckNumLength($_GET['send_id']) || SC_Utils_Ex::sfCheckNumLength($_GET['id'])) {
         if (is_numeric($_GET["send_id"])) {
             $id = $_GET["send_id"];
             $sql = "SELECT body, mail_method FROM dtb_send_history WHERE send_id = ?";
         } else {
             $sql = "SELECT body, mail_method FROM dtb_mailmaga_template WHERE template_id = ?";
             $id = $_GET['id'];
         }
         $result = $conn->getAll($sql, array($id));
         if ($result) {
             if ($result[0]["mail_method"] == 2) {
                 // テキスト形式の時はタグ文字をエスケープ
                 $this->escape_flag = 1;
             }
             $this->body = $result[0]["body"];
         }
     }
     $objView->assignobj($this);
     $objView->display($this->tpl_mainpage);
 }
コード例 #6
0
 /**
  * ファイルの情報をセットする
  *
  * @param SC_UploadFile $objUpFile
  * @param array $arrProduct
  * @param array $arrFile
  * @return bool
  */
 public function lfSetFile(SC_UploadFile $objUpFile, $arrProduct, &$arrFile)
 {
     // DBからのデータを引き継ぐ
     $objUpFile->setDBFileList($arrProduct);
     // ファイル表示用配列を渡す
     $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);
     // サブ画像の有無を判定
     $subImageFlag = false;
     for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) {
         if ($arrFile['sub_image' . $i]['filepath'] != '') {
             $subImageFlag = true;
         }
     }
     return $subImageFlag;
 }