Changeset 18435 for branches/comu-ver2/data
- Timestamp:
- 2009/12/07 21:43:13 (14 years ago)
- Location:
- branches/comu-ver2/data/class
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/helper/SC_Helper_DB.php
r18380 r18435 1942 1942 } 1943 1943 } 1944 1945 /** 1946 * 商品規格を設定しているか 1947 * 1948 * @param integer $product_id 商品ID 1949 * @return bool 商品規格が存在する場合:true, それ以外:false 1950 */ 1951 function sfHasProductClass($product_id) { 1952 if (!SC_Utils_Ex::sfIsInt($product_id)) return false; 1953 1954 $objQuery = new SC_Query(); 1955 $where = 'product_id = ? AND (classcategory_id1 <> 0 OR classcategory_id2 <> 0)'; 1956 $count = $objQuery->count('dtb_products_class', $where, array($product_id)); 1957 1958 return $count >= 1; 1959 } 1944 1960 } 1945 1961 ?> -
branches/comu-ver2/data/class/pages/admin/products/LC_Page_Admin_Products_Product.php
r18415 r18435 98 98 99 99 // 規格の有り無し判定 100 $this->tpl_nonclass = $this->lfCheckNonClass($_POST['product_id']);100 $this->tpl_nonclass = !$objDb->sfHasProductClass($_POST['product_id']); 101 101 102 102 // 検索パラメータの引き継ぎ … … 148 148 case 'edit': 149 149 if($_POST['product_id'] == "" and SC_Utils_Ex::sfIsInt($_POST['copy_product_id'])){ 150 $this->tpl_nonclass = $this->lfCheckNonClass($_POST['copy_product_id']);150 $this->tpl_nonclass = !$objDb->sfHasProductClass($_POST['copy_product_id']); 151 151 } 152 152 … … 320 320 function lfGetProduct($product_id) { 321 321 $objQuery = new SC_Query(); 322 $objDb = new SC_Helper_DB_Ex(); 323 322 324 $col = "*"; 323 325 $table = "vw_products_nonclass AS noncls "; … … 332 334 array($product_id)); 333 335 //編集時に規格IDが変わってしまうのを防ぐために規格が登録されていなければ規格IDを取得する 334 if ( $this->lfCheckNonClass($_POST['product_id']) ){336 if (!$objDb->sfHasProductClass($_POST['product_id'])) { 335 337 $arrRet[0]['product_class_id'] = SC_Utils::sfGetProductClassId($product_id,"0","0"); 336 338 } … … 433 435 } 434 436 435 if($arrList['product_id'] == "") { 437 // 新規登録(複製時を含む) 438 if ($arrList['product_id'] == "") { 436 439 // product_id 取得(PostgreSQLの場合) 437 440 if(DB_TYPE=='pgsql'){ … … 449 452 } 450 453 454 $arrList['product_id'] = $product_id; 455 451 456 // カテゴリを更新 452 457 $objDb->updateProductCategories($arrList['category_id'], $product_id); 453 458 454 // コピー商品の場合には規格もコピーする459 // 複製商品の場合には規格も複製する 455 460 if($_POST["copy_product_id"] != "" and SC_Utils_Ex::sfIsInt($_POST["copy_product_id"])){ 456 461 457 462 if($this->tpl_nonclass) 458 463 { 459 //規格なしの場合、コピーは価格等の入力が発生しているため、その内容で追加登録を行う 460 $arrList['product_id'] = $product_id; 464 //規格なしの場合、複製は価格等の入力が発生しているため、その内容で追加登録を行う 461 465 $this->lfCopyProductClass($arrList, $objQuery); 462 466 } 463 467 else 464 468 { 465 //規格がある場合の コピーは複製元の内容で追加登録を行う469 //規格がある場合の複製は複製元の内容で追加登録を行う 466 470 // dtb_products_class のカラムを取得 467 471 $dbFactory = SC_DB_DBFactory_Ex::getInstance(); … … 469 473 $arrColList_tmp = array_flip($arrColList); 470 474 471 // コピーしない列475 // 複製しない列 472 476 unset($arrColList[$arrColList_tmp["product_class_id"]]); //規格ID 473 477 unset($arrColList[$arrColList_tmp["product_id"]]); //商品ID … … 479 483 } 480 484 } 481 } else { 485 } 486 // 更新 487 else { 482 488 $product_id = $arrList['product_id']; 483 489 // 削除要求のあった既存ファイルの削除 … … 496 502 if( $_POST["copy_product_id"] == "" ){ 497 503 // 規格登録 498 SC_Utils_Ex::sfInsertProductClass($objQuery, $arrList, $product_id , $arrList['product_class_id']);504 $this->lfInsertDummyProductClass($arrList); 499 505 } 500 506 … … 643 649 // Form用配列を渡す。 644 650 $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); 645 }646 647 /* 規格あり判定用(規格が登録されていない場合:TRUE) */648 function lfCheckNonClass($product_id) {649 if(SC_Utils_Ex::sfIsInt($product_id)) {650 $objQuery = new SC_Query();651 $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0";652 $count = $objQuery->count("dtb_products_class", $where, array($product_id));653 if($count > 0) {654 return false;655 }656 }657 return true;658 651 } 659 652 … … 753 746 $objQuery->begin(); 754 747 $err_flag = false; 755 //非編集項目は コピー、編集項目は上書きして登録748 //非編集項目は複製、編集項目は上書きして登録 756 749 foreach($arrProductClass as $records) 757 750 { … … 786 779 return !$err_flag; 787 780 } 781 782 /** 783 * 規格を設定していない商品を商品規格テーブルに登録 784 * 785 * @param array $arrList 786 * @return void 787 */ 788 function lfInsertDummyProductClass($arrList) { 789 $objQuery = new SC_Query(); 790 $objDb = new SC_Helper_DB_Ex(); 791 792 $product_id = $arrList['product_id']; 793 // 規格登録してある商品の場合、処理しない 794 if ($objDb->sfHasProductClass($product_id)) return; 795 796 // 既存規格の削除 797 $where = 'product_id = ?'; 798 $objQuery->delete('dtb_products_class', $where, array($product_id)); 799 800 // 配列の添字を定義 801 $checkArray = array('product_class_id', 'product_id', 'product_code', 'stock', 'stock_unlimited', 'price01', 'price02'); 802 $sqlval = SC_Utils_Ex::sfArrayIntersectKeys($arrList, $checkArray); 803 $sqlval = SC_Utils_Ex::arrayDefineIndexes($sqlval, $checkArray); 804 805 if (strlen($sqlval['product_class_id']) == 0) { 806 unset($sqlval['product_class_id']); 807 } 808 $sqlval['classcategory_id1'] = '0'; 809 $sqlval['classcategory_id2'] = '0'; 810 $sqlval['stock_unlimited'] = $sqlval['stock_unlimited'] ? '1' : '0'; 811 $sqlval['creator_id'] = strlen($_SESSION['member_id']) >= 1 ? $_SESSION['member_id'] : '0'; 812 $sqlval['create_date'] = 'now()'; 813 814 // INSERTの実行 815 $objQuery->insert('dtb_products_class', $sqlval); 816 } 788 817 } 789 818 ?> -
branches/comu-ver2/data/class/util/SC_Utils.php
r18427 r18435 786 786 } 787 787 788 /* 規格の登録 */789 function sfInsertProductClass($objQuery, $arrList, $product_id , $product_class_id = "") {790 // すでに規格登録があるかどうかをチェックする。791 $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id2 <> 0";792 $count = $objQuery->count("dtb_products_class", $where, array($product_id));793 794 // すでに規格登録がない場合795 if($count == 0) {796 // 既存規格の削除797 $where = "product_id = ?";798 $objQuery->delete("dtb_products_class", $where, array($product_id));799 800 // 配列の添字を定義801 $checkArray = array("product_code", "stock", "stock_unlimited", "price01", "price02");802 $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray);803 804 $sqlval['product_id'] = $product_id;805 if(strlen($product_class_id ) > 0 ){806 $sqlval['product_class_id'] = $product_class_id;807 }808 $sqlval['classcategory_id1'] = '0';809 $sqlval['classcategory_id2'] = '0';810 $sqlval['product_code'] = $arrList["product_code"];811 $sqlval['stock'] = $arrList["stock"];812 $sqlval['stock_unlimited'] = ($arrList["stock_unlimited"]) ? '1' : '0';813 $sqlval['price01'] = $arrList['price01'];814 $sqlval['price02'] = $arrList['price02'];815 $sqlval['creator_id'] = $_SESSION['member_id'];816 $sqlval['create_date'] = "now()";817 818 if($_SESSION['member_id'] == "") {819 $sqlval['creator_id'] = '0';820 }821 822 // INSERTの実行823 $objQuery->insert("dtb_products_class", $sqlval);824 }825 }826 827 788 function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) { 828 789 $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; … … 1680 1641 } 1681 1642 return $array; 1643 } 1644 1645 /** 1646 * $arrSrc のうち、キーが $arrKey に含まれるものを返す 1647 * 1648 * $arrSrc に含まない要素は返されない。 1649 * 1650 * @param array $arrSrc 1651 * @param array $arrKey 1652 * @return array 1653 */ 1654 function sfArrayIntersectKeys($arrSrc, $arrKey) { 1655 $arrRet = array(); 1656 foreach ($arrKey as $key) { 1657 if (isset($arrSrc[$key])) $arrRet[$key] = $arrSrc[$key]; 1658 } 1659 return $arrRet; 1682 1660 } 1683 1661
Note: See TracChangeset
for help on using the changeset viewer.