Changeset 21441 for branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSV.php
- Timestamp:
- 2012/02/06 11:05:15 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSV.php
r21425 r21441 106 106 107 107 // CSV構造がインポート可能かのチェック 108 if (!$objCSV->sfIsImportCSVFrame($arrCSVFrame) ) {108 if (!$objCSV->sfIsImportCSVFrame($arrCSVFrame) ) { 109 109 // 無効なフォーマットなので初期状態に強制変更 110 110 $arrCSVFrame = $objCSV->sfGetCsvOutput($this->csv_id, '', array(), 'no'); … … 125 125 $this->arrTitle = $objFormParam->getHtmlDispNameArray(); 126 126 127 switch ($this->getMode()) {127 switch ($this->getMode()) { 128 128 case 'csv_upload': 129 129 $this->doUploadCsv($objFormParam, $objUpFile); … … 301 301 $arrCSVFrame = $this->lfSetParamDefaultValue($arrCSVFrame); 302 302 // CSV項目毎の処理 303 foreach ($arrCSVFrame as $item) {303 foreach ($arrCSVFrame as $item) { 304 304 if($item['status'] == CSV_COLUMN_STATUS_FLG_DISABLE) continue; 305 305 //サブクエリ構造の場合は AS名 を使用 306 if (preg_match_all('/\(.+\)\s+as\s+(.+)$/i', $item['col'], $match, PREG_SET_ORDER)) {306 if (preg_match_all('/\(.+\)\s+as\s+(.+)$/i', $item['col'], $match, PREG_SET_ORDER)) { 307 307 $col = $match[0][1]; 308 } else{308 } else { 309 309 $col = $item['col']; 310 310 } 311 311 // HTML_TAG_CHECKは別途実行なので除去し、別保存しておく 312 if (strpos(strtoupper($item['error_check_types']), 'HTML_TAG_CHECK') !== FALSE) {312 if (strpos(strtoupper($item['error_check_types']), 'HTML_TAG_CHECK') !== FALSE) { 313 313 $this->arrTagCheckItem[] = $item; 314 314 $error_check_types = str_replace('HTML_TAG_CHECK', '', $item['error_check_types']); 315 } else{315 } else { 316 316 $error_check_types = $item['error_check_types']; 317 317 } 318 318 $arrErrorCheckTypes = explode(',', $error_check_types); 319 foreach ($arrErrorCheckTypes as $key => $val) {320 if (trim($val) == "") {319 foreach ($arrErrorCheckTypes as $key => $val) { 320 if (trim($val) == "") { 321 321 unset($arrErrorCheckTypes[$key]); 322 } else{322 } else { 323 323 $arrErrorCheckTypes[$key] = trim($val); 324 324 } … … 348 348 $objErr->arrErr = $objFormParam->checkError(false); 349 349 // HTMLタグチェックの実行 350 foreach ($this->arrTagCheckItem as $item) {350 foreach ($this->arrTagCheckItem as $item) { 351 351 $objErr->doFunc(array( $item['disp_name'], $item['col'], $this->arrAllowedTag), array("HTML_TAG_CHECK")); 352 352 } 353 353 // このフォーム特有の複雑系のエラーチェックを行う 354 if (count($objErr->arrErr) == 0) {354 if (count($objErr->arrErr) == 0) { 355 355 $objErr->arrErr = $this->lfCheckErrorDetail($arrRet, $objErr->arrErr); 356 356 } … … 392 392 $sqlval = $this->lfSetProductDefaultData($sqlval); 393 393 394 if ($sqlval['product_id'] != "") {394 if ($sqlval['product_id'] != "") { 395 395 // 同じidが存在すればupdate存在しなければinsert 396 396 $where = "product_id = ?"; … … 404 404 // シーケンスの調整 405 405 $seq_count = $objQuery->currVal('dtb_products_product_id'); 406 if ($seq_count < $sqlval['product_id']){406 if ($seq_count < $sqlval['product_id']) { 407 407 $objQuery->setVal('dtb_products_product_id', $sqlval['product_id'] + 1); 408 408 } … … 455 455 $sqlval = $this->lfSetProductClassDefaultData($sqlval); 456 456 457 if ($product_class_id == "") {457 if ($product_class_id == "") { 458 458 // 新規登録 459 459 $sqlval['product_id'] = $product_id; … … 469 469 } 470 470 // 支払い方法登録 471 if ($arrList['product_payment_ids'] != "") {471 if ($arrList['product_payment_ids'] != "") { 472 472 $arrPayment_id = explode(',', $arrList['product_payment_ids']); 473 473 $objProduct->setPaymentOptions($product_class_id, $arrPayment_id); … … 488 488 function lfRegistReccomendProducts($objQuery, $arrList, $product_id) { 489 489 $objQuery->delete("dtb_recommend_products", "product_id = ?", array($product_id)); 490 for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {490 for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { 491 491 $keyname = "recommend_product_id" . $i; 492 492 $comment_key = "recommend_comment" . $i; 493 if ($arrList[$keyname] != "") {493 if ($arrList[$keyname] != "") { 494 494 $arrProduct = $objQuery->select("product_id", "dtb_products", "product_id = ?", array($arrList[$keyname])); 495 if ($arrProduct[0]['product_id'] != "") {495 if ($arrProduct[0]['product_id'] != "") { 496 496 $arrval['product_id'] = $product_id; 497 497 $arrval['recommend_product_id'] = $arrProduct[0]['product_id']; … … 514 514 */ 515 515 function lfSetParamDefaultValue(&$arrCSVFrame) { 516 foreach ($arrCSVFrame as $key => $val) {517 switch ($val['col']) {516 foreach ($arrCSVFrame as $key => $val) { 517 switch ($val['col']) { 518 518 case 'status': 519 519 $arrCSVFrame[$key]['default'] = DEFAULT_PRODUCT_DISP; … … 548 548 function lfSetProductDefaultData(&$sqlval) { 549 549 //新規登録時のみ設定する項目 550 if ($sqlval['product_id'] == "") {551 if ($sqlval['status'] == "") {550 if ($sqlval['product_id'] == "") { 551 if ($sqlval['status'] == "") { 552 552 $sqlval['status'] = DEFAULT_PRODUCT_DISP; 553 553 } 554 554 } 555 555 //共通で空欄時に上書きする項目 556 if ($sqlval['del_flg'] == ""){556 if ($sqlval['del_flg'] == "") { 557 557 $sqlval['del_flg'] = '0'; //有効 558 558 } 559 if ($sqlval['creator_id'] == "") {559 if ($sqlval['creator_id'] == "") { 560 560 $sqlval['creator_id'] = $_SESSION['member_id']; 561 561 } … … 571 571 function lfSetProductClassDefaultData(&$sqlval) { 572 572 //新規登録時のみ設定する項目 573 if ($sqlval['product_class_id'] == "") {574 if ($sqlval['point_rate'] == "") {573 if ($sqlval['product_class_id'] == "") { 574 if ($sqlval['point_rate'] == "") { 575 575 $sqlval['point_rate'] = $this->arrInfo['point_rate']; 576 576 } 577 if ($sqlval['product_type_id'] == "") {577 if ($sqlval['product_type_id'] == "") { 578 578 $sqlval['product_type_id'] = DEFAULT_PRODUCT_DOWN; 579 579 } 580 580 // TODO: 在庫数、無制限フラグの扱いについて仕様がぶれているので要調整 581 if ($sqlval['stock'] == "" and $sqlval['stock_unlimited'] != UNLIMITED_FLG_UNLIMITED) {581 if ($sqlval['stock'] == "" and $sqlval['stock_unlimited'] != UNLIMITED_FLG_UNLIMITED) { 582 582 //在庫数設定がされておらず、かつ無制限フラグが設定されていない場合、強制無制限 583 583 $sqlval['stock_unlimited'] = UNLIMITED_FLG_UNLIMITED; … … 589 589 $sqlval['stock'] = ''; 590 590 } 591 } else{591 } else { 592 592 //更新時のみ設定する項目 593 if (array_key_exists('stock_unlimited', $sqlval) and $sqlval['stock_unlimited'] == UNLIMITED_FLG_UNLIMITED) {593 if (array_key_exists('stock_unlimited', $sqlval) and $sqlval['stock_unlimited'] == UNLIMITED_FLG_UNLIMITED) { 594 594 $sqlval['stock'] = ''; 595 595 } 596 596 } 597 597 //共通で設定する項目 598 if ($sqlval['del_flg'] == ""){598 if ($sqlval['del_flg'] == "") { 599 599 $sqlval['del_flg'] = '0'; //有効 600 600 } 601 if ($sqlval['creator_id'] == "") {601 if ($sqlval['creator_id'] == "") { 602 602 $sqlval['creator_id'] = $_SESSION['member_id']; 603 603 } … … 614 614 function lfCheckErrorDetail($item, $arrErr) { 615 615 // 規格IDの存在チェック 616 if (!$this->lfIsDbRecord('dtb_products_class', 'product_class_id', $item)) {616 if (!$this->lfIsDbRecord('dtb_products_class', 'product_class_id', $item)) { 617 617 $arrErr['product_class_id'] = "※ 指定の商品規格IDは、登録されていません。"; 618 618 } … … 620 620 if(array_search('product_class_id', $this->arrFormKeyList) !== FALSE 621 621 and $item['product_class_id'] != "") { 622 if ($item['product_id'] == "") {622 if ($item['product_id'] == "") { 623 623 $arrErr['product_class_id'] = "※ 商品規格ID指定時には商品IDの指定が必須です。"; 624 } else{624 } else { 625 625 if(!$this->objDb->sfIsRecord('dtb_products_class', 'product_id, product_class_id' 626 626 , array($item['product_id'], $item['product_class_id']))) { … … 630 630 } 631 631 // 規格組合せIDの存在チェック 632 // if (!$this->lfIsDbRecord('dtb_class_combination', 'class_combination_id', $item)) {632 // if (!$this->lfIsDbRecord('dtb_class_combination', 'class_combination_id', $item)) { 633 633 // SC_Utils::sfIsRecord が del_flg が無いと使えない為、個別処理 634 634 if(array_search('class_combination_id', $this->arrFormKeyList) !== FALSE … … 636 636 $objQuery =& SC_Query_Ex::getSingletonInstance(); 637 637 $ret = $objQuery->get('class_combination_id', 'dtb_class_combination', 'class_combination_id = ?', array($item['class_combination_id'])); 638 if ($ret == "") {638 if ($ret == "") { 639 639 $arrErr['class_combination_id'] = "※ 指定の規格組合せIDは、登録されていません。"; 640 640 } 641 641 } 642 642 // 表示ステータスの存在チェック 643 if (!$this->lfIsArrayRecord($this->arrDISP, 'status', $item)) {643 if (!$this->lfIsArrayRecord($this->arrDISP, 'status', $item)) { 644 644 $arrErr['status'] = "※ 指定の表示ステータスは、登録されていません。"; 645 645 } 646 646 // メーカーIDの存在チェック 647 if (!$this->lfIsArrayRecord($this->arrMaker, 'maker_id', $item)) {647 if (!$this->lfIsArrayRecord($this->arrMaker, 'maker_id', $item)) { 648 648 $arrErr['maker_id'] = "※ 指定のメーカーIDは、登録されていません。"; 649 649 } 650 650 // 発送日目安IDの存在チェック 651 if (!$this->lfIsArrayRecord($this->arrDELIVERYDATE, 'deliv_date_id', $item)) {651 if (!$this->lfIsArrayRecord($this->arrDELIVERYDATE, 'deliv_date_id', $item)) { 652 652 $arrErr['deliv_date_id'] = "※ 指定の発送日目安IDは、登録されていません。"; 653 653 } 654 654 // 発送日目安IDの存在チェック 655 if (!$this->lfIsArrayRecord($this->arrProductType, 'product_type_id', $item)) {655 if (!$this->lfIsArrayRecord($this->arrProductType, 'product_type_id', $item)) { 656 656 $arrErr['product_type_id'] = "※ 指定の商品種別IDは、登録されていません。"; 657 657 } 658 658 // 関連商品IDの存在チェック 659 for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {659 for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { 660 660 if(array_search('recommend_product_id' . $i, $this->arrFormKeyList) !== FALSE 661 661 and $item['recommend_product_id' . $i] != "" … … 665 665 } 666 666 // カテゴリIDの存在チェック 667 if (!$this->lfIsDbRecordMulti('dtb_category', 'category_id', 'category_ids', $item, ',')) {667 if (!$this->lfIsDbRecordMulti('dtb_category', 'category_id', 'category_ids', $item, ',')) { 668 668 $arrErr['category_ids'] = "※ 指定のカテゴリIDは、登録されていません。"; 669 669 } 670 670 // 商品ステータスIDの存在チェック 671 if (!$this->lfIsArrayRecordMulti($this->arrSTATUS, 'product_statuses', $item, ',')) {671 if (!$this->lfIsArrayRecordMulti($this->arrSTATUS, 'product_statuses', $item, ',')) { 672 672 $arrErr['product_statuses'] = "※ 指定の商品ステータスIDは、登録されていません。"; 673 673 } 674 674 // 支払い方法IDの存在チェック 675 if (!$this->lfIsArrayRecordMulti($this->arrPayments, 'product_payment_ids', $item, ',')) {675 if (!$this->lfIsArrayRecordMulti($this->arrPayments, 'product_payment_ids', $item, ',')) { 676 676 $arrErr['product_payment_ids'] = "※ 指定の支払い方法IDは、登録されていません。"; 677 677 } … … 679 679 if(array_search('del_flg', $this->arrFormKeyList) !== FALSE 680 680 and $item['del_flg'] != "") { 681 if (!($item['del_flg'] == "0" or $item['del_flg'] == "1")) {681 if (!($item['del_flg'] == "0" or $item['del_flg'] == "1")) { 682 682 $arrErr['del_flg'] = "※ 削除フラグは「0」(有効)、「1」(削除)のみが有効な値です。"; 683 683 } … … 686 686 TODO: 在庫数の扱いが2.4仕様ではぶれているのでどうするか・・ 687 687 // 在庫数/在庫無制限フラグの有効性に関するチェック 688 if ($item['stock'] == "") {689 if (array_search('stock_unlimited', $this->arrFormKeyList) === FALSE) {688 if ($item['stock'] == "") { 689 if (array_search('stock_unlimited', $this->arrFormKeyList) === FALSE) { 690 690 $arrErr['stock'] = "※ 在庫数は必須です(無制限フラグ項目がある場合のみ空欄許可)。"; 691 }else if ($item['stock_unlimited'] != UNLIMITED_FLG_UNLIMITED) {691 }else if ($item['stock_unlimited'] != UNLIMITED_FLG_UNLIMITED) { 692 692 $arrErr['stock'] = "※ 在庫数または在庫無制限フラグのいずれかの入力が必須です。"; 693 693 } … … 698 698 and $item['product_type_id'] == PRODUCT_TYPE_NORMAL) { 699 699 //実商品の場合 700 if ($item['down_filename'] != "") {700 if ($item['down_filename'] != "") { 701 701 $arrErr['down_filename'] = "※ 実商品の場合はダウンロードファイル名は入力できません。"; 702 702 } 703 if ($item['down_realfilename'] != "") {703 if ($item['down_realfilename'] != "") { 704 704 $arrErr['down_realfilename'] = "※ 実商品の場合はダウンロード商品用ファイルアップロードは入力できません。"; 705 705 } … … 707 707 and $item['product_type_id'] == PRODUCT_TYPE_DOWNLOAD) { 708 708 //ダウンロード商品の場合 709 if ($item['down_filename'] == "") {709 if ($item['down_filename'] == "") { 710 710 $arrErr['down_filename'] = "※ ダウンロード商品の場合はダウンロードファイル名は必須です。"; 711 711 } 712 if ($item['down_realfilename'] == "") {712 if ($item['down_realfilename'] == "") { 713 713 $arrErr['down_realfilename'] = "※ ダウンロード商品の場合はダウンロード商品用ファイルアップロードは必須です。"; 714 714 } … … 729 729 $time = date("Y-m-d H:i:s"); 730 730 // 秒以下を生成 731 if ($line_no != '') {731 if ($line_no != '') { 732 732 $microtime = sprintf("%06d", $line_no); 733 733 $time .= ".$microtime"; … … 746 746 */ 747 747 function lfIsArrayRecordMulti($arr, $keyname, $item, $delimiter = ',') { 748 if (array_search($keyname, $this->arrFormKeyList) === FALSE) {748 if (array_search($keyname, $this->arrFormKeyList) === FALSE) { 749 749 return true; 750 750 } 751 if ($item[$keyname] == "") {751 if ($item[$keyname] == "") { 752 752 return true; 753 753 } 754 754 $arrItems = explode($delimiter, $item[$keyname]); 755 755 //空項目のチェック 1つでも空指定があったら不正とする。 756 if (array_search("", $arrItems) !== FALSE) {756 if (array_search("", $arrItems) !== FALSE) { 757 757 return false; 758 758 } 759 759 //キー項目への存在チェック 760 foreach ($arrItems as $item) {761 if (!array_key_exists($item, $arr)) {760 foreach ($arrItems as $item) { 761 if (!array_key_exists($item, $arr)) { 762 762 return false; 763 763 } … … 777 777 */ 778 778 function lfIsDbRecordMulti($table, $tblkey, $keyname, $item, $delimiter = ',') { 779 if (array_search($keyname, $this->arrFormKeyList) === FALSE) {779 if (array_search($keyname, $this->arrFormKeyList) === FALSE) { 780 780 return true; 781 781 } 782 if ($item[$keyname] == "") {782 if ($item[$keyname] == "") { 783 783 return true; 784 784 } 785 785 $arrItems = explode($delimiter, $item[$keyname]); 786 786 //空項目のチェック 1つでも空指定があったら不正とする。 787 if (array_search("", $arrItems) !== FALSE) {787 if (array_search("", $arrItems) !== FALSE) { 788 788 return false; 789 789 } … … 793 793 $objQuery =& SC_Query_Ex::getSingletonInstance(); 794 794 $db_count = $objQuery->count($table, $where, $arrItems); 795 if ($count != $db_count) {795 if ($count != $db_count) { 796 796 return false; 797 797 }
Note: See TracChangeset
for help on using the changeset viewer.