- Timestamp:
- 2007/07/20 15:58:59 (17 years ago)
- Location:
- branches/feature-module-update
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update
-
Property
svn:ignore
set to
.cache
.settings
.projectOptions
-
Property
svn:ignore
set to
-
branches/feature-module-update/html/admin/products/category.php
r12157 r15078 14 14 $this->tpl_subno = 'category'; 15 15 $this->tpl_onload = " fnSetFocus('category_name'); "; 16 $this->tpl_subtitle = ' ¥«¥Æ¥´¥ê¡¼ÅÐÏ¿';16 $this->tpl_subtitle = 'カテゴリー登録'; 17 17 } 18 18 } … … 23 23 $objSess = new SC_Session(); 24 24 25 // ǧ¾Ú²ÄÈݤÎȽÄê25 // 認証可否の判定 26 26 sfIsSuccess($objSess); 27 27 28 // ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹28 // パラメータ管理クラス 29 29 $objFormParam = new SC_FormParam(); 30 // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½30 // パラメータ情報の初期化 31 31 lfInitParam(); 32 // POST ÃͤμèÆÀ32 // POST値の取得 33 33 $objFormParam->setParam($_POST); 34 34 35 // Ä̾ï»þ¤Ï¿Æ¥«¥Æ¥´¥ê¤ò0¤ËÀßÄꤹ¤ë¡£35 // 通常時は親カテゴリを0に設定する。 36 36 $objPage->arrForm['parent_category_id'] = $_POST['parent_category_id']; 37 37 … … 49 49 lfInsertCat($_POST['parent_category_id']); 50 50 } else { 51 print(" ¥«¥Æ¥´¥ê¤ÎÅÐÏ¿ºÇÂç¿ô¤òĶ¤¨¤Þ¤·¤¿¡£");51 print("カテゴリの登録最大数を超えました。"); 52 52 } 53 53 } else { … … 60 60 break; 61 61 case 'pre_edit': 62 // ÊÔ½¸¹àÌܤΥ«¥Æ¥´¥ê̾¤òDB¤è¤ê¼èÆÀ¤¹¤ë¡£62 // 編集項目のカテゴリ名をDBより取得する。 63 63 $oquery = new SC_Query(); 64 64 $where = "category_id = ?"; 65 65 $cat_name = $oquery->get("dtb_category", "category_name", $where, array($_POST['category_id'])); 66 // ÆþÎϹàÌܤ˥«¥Æ¥´¥ê̾¤òÆþÎϤ¹¤ë¡£66 // 入力項目にカテゴリ名を入力する。 67 67 $objPage->arrForm['category_name'] = $cat_name; 68 // POST ¥Ç¡¼¥¿¤ò°ú¤·Ñ¤°68 // POSTデータを引き継ぐ 69 69 $objPage->arrForm['category_id'] = $_POST['category_id']; 70 70 break; 71 71 case 'delete': 72 72 $objQuery = new SC_Query(); 73 // »Ò¥«¥Æ¥´¥ê¤Î¥Á¥§¥Ã¥¯73 // 子カテゴリのチェック 74 74 $where = "parent_category_id = ? AND del_flg = 0"; 75 75 $count = $objQuery->count("dtb_category", $where, array($_POST['category_id'])); 76 76 if($count != 0) { 77 $objPage->arrErr['category_name'] = " ¢¨ »Ò¥«¥Æ¥´¥ê¤¬Â¸ºß¤¹¤ë¤¿¤áºï½ü¤Ç¤¤Þ¤»¤ó¡£<br>";78 } 79 // ÅÐÏ¿¾¦ÉʤΥÁ¥§¥Ã¥¯77 $objPage->arrErr['category_name'] = "※ 子カテゴリが存在するため削除できません。<br>"; 78 } 79 // 登録商品のチェック 80 80 $where = "category_id = ? AND del_flg = 0"; 81 81 $count = $objQuery->count("dtb_products", $where, array($_POST['category_id'])); 82 82 if($count != 0) { 83 $objPage->arrErr['category_name'] = " ¢¨ ¥«¥Æ¥´¥êÆâ¤Ë¾¦Éʤ¬Â¸ºß¤¹¤ë¤¿¤áºï½ü¤Ç¤¤Þ¤»¤ó¡£<br>";83 $objPage->arrErr['category_name'] = "※ カテゴリ内に商品が存在するため削除できません。<br>"; 84 84 } 85 85 86 86 if(!isset($objPage->arrErr['category_name'])) { 87 // ¥é¥ó¥¯ÉÕ¤¥ì¥³¡¼¥É¤Îºï½ü(¢¨½èÍýÉé²Ù¤ò¹Íθ¤·¤Æ¥ì¥³¡¼¥É¤´¤Èºï½ü¤¹¤ë¡£)87 // ランク付きレコードの削除(※処理負荷を考慮してレコードごと削除する。) 88 88 sfDeleteRankRecord("dtb_category", "category_id", $_POST['category_id'], "", true); 89 89 } … … 94 94 $up_id = lfGetUpRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 95 95 if($up_id != "") { 96 // ¾å¤Î¥°¥ë¡¼¥×¤Îrank¤«¤é¸º»»¤¹¤ë¿ô96 // 上のグループのrankから減算する数 97 97 $my_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 98 // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤Îrank¤Ë²Ã»»¤¹¤ë¿ô98 // 自分のグループのrankに加算する数 99 99 $up_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id); 100 100 if($my_count > 0 && $up_count > 0) { 101 // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤Ë²Ã»»101 // 自分のグループに加算 102 102 lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $up_count); 103 // ¾å¤Î¥°¥ë¡¼¥×¤«¤é¸º»»103 // 上のグループから減算 104 104 lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id, $my_count); 105 105 } … … 112 112 $down_id = lfGetDownRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 113 113 if($down_id != "") { 114 // ²¼¤Î¥°¥ë¡¼¥×¤Îrank¤Ë²Ã»»¤¹¤ë¿ô114 // 下のグループのrankに加算する数 115 115 $my_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 116 // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤Îrank¤«¤é¸º»»¤¹¤ë¿ô116 // 自分のグループのrankから減算する数 117 117 $down_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id); 118 118 if($my_count > 0 && $down_count > 0) { 119 // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤«¤é¸º»»119 // 自分のグループから減算 120 120 lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id, $my_count); 121 // ²¼¤Î¥°¥ë¡¼¥×¤Ë²Ã»»121 // 下のグループに加算 122 122 lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $down_count); 123 123 } … … 139 139 //----------------------------------------------------------------------------------------------------------------------------------- 140 140 141 // ¥«¥Æ¥´¥ê¤Î¿·µ¬ÄɲÃ141 // カテゴリの新規追加 142 142 function lfInsertCat($parent_category_id) { 143 143 global $objFormParam; 144 144 145 145 $objQuery = new SC_Query(); 146 $objQuery->begin(); // ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î³«»Ï146 $objQuery->begin(); // トランザクションの開始 147 147 148 148 149 149 if($parent_category_id == 0) { 150 // ROOT ³¬ÁؤǺÇÂç¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£150 // ROOT階層で最大のランクを取得する。 151 151 $where = "parent_category_id = ?"; 152 152 $rank = $objQuery->max("dtb_category", "rank", $where, array($parent_category_id)) + 1; 153 153 } else { 154 // ¿Æ¤Î¥é¥ó¥¯¤ò¼«Ê¬¤Î¥é¥ó¥¯¤È¤¹¤ë¡£154 // 親のランクを自分のランクとする。 155 155 $where = "category_id = ?"; 156 156 $rank = $objQuery->get("dtb_category", "rank", $where, array($parent_category_id)); 157 // Äɲå쥳¡¼¥É¤Î¥é¥ó¥¯°Ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä¤¢¤²¤ë¡£157 // 追加レコードのランク以上のレコードを一つあげる。 158 158 $sqlup = "UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?"; 159 159 $objQuery->exec($sqlup, array($rank)); … … 161 161 162 162 $where = "category_id = ?"; 163 // ¼«Ê¬¤Î¥ì¥Ù¥ë¤ò¼èÆÀ¤¹¤ë(¿Æ¤Î¥ì¥Ù¥ë+ 1)163 // 自分のレベルを取得する(親のレベル + 1) 164 164 $level = $objQuery->get("dtb_category", "level", $where, array($parent_category_id)) + 1; 165 165 166 // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£166 // 入力データを渡す。 167 167 $sqlval = $objFormParam->getHashArray(); 168 168 $sqlval['create_date'] = "Now()"; … … 173 173 $sqlval['level'] = $level; 174 174 175 // INSERT ¤Î¼Â¹Ô175 // INSERTの実行 176 176 $objQuery->insert("dtb_category", $sqlval); 177 177 178 $objQuery->commit(); // ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î½ªÎ»179 } 180 181 // ¥«¥Æ¥´¥ê¤ÎÊÔ½¸178 $objQuery->commit(); // トランザクションの終了 179 } 180 181 // カテゴリの編集 182 182 function lfUpdateCat($category_id) { 183 183 global $objFormParam; 184 184 $objQuery = new SC_Query(); 185 // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£185 // 入力データを渡す。 186 186 $sqlval = $objFormParam->getHashArray(); 187 187 $sqlval['update_date'] = "Now()"; … … 190 190 } 191 191 192 // ¥«¥Æ¥´¥ê¤Î¼èÆÀ192 // カテゴリの取得 193 193 function lfGetCat($parent_category_id) { 194 194 $objQuery = new SC_Query(); … … 205 205 } 206 206 207 /* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½*/207 /* パラメータ情報の初期化 */ 208 208 function lfInitParam() { 209 209 global $objFormParam; 210 $objFormParam->addParam(" ¥«¥Æ¥´¥ê̾", "category_name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));211 } 212 213 /* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯*/210 $objFormParam->addParam("カテゴリ名", "category_name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 211 } 212 213 /* 入力内容のチェック */ 214 214 function lfCheckError($array) { 215 215 global $objFormParam; … … 217 217 $objErr->arrErr = $objFormParam->checkError(); 218 218 219 // ³¬ÁØ¥Á¥§¥Ã¥¯219 // 階層チェック 220 220 if(!isset($objErr->arrErr['category_name'])) { 221 221 $objQuery = new SC_Query(); … … 223 223 224 224 if($level >= LEVEL_MAX) { 225 $objErr->arrErr['category_name'] = " ¢¨ ".LEVEL_MAX."³¬Áذʾå¤ÎÅÐÏ¿¤Ï¤Ç¤¤Þ¤»¤ó¡£<br>";225 $objErr->arrErr['category_name'] = "※ ".LEVEL_MAX."階層以上の登録はできません。<br>"; 226 226 } 227 227 } 228 228 229 // ½ÅÊ£¥Á¥§¥Ã¥¯229 // 重複チェック 230 230 if(!isset($objErr->arrErr['category_name'])) { 231 231 $objQuery = new SC_Query(); 232 232 $where = "parent_category_id = ? AND category_name = ?"; 233 233 $arrRet = $objQuery->select("category_id, category_name", "dtb_category", $where, array($_POST['parent_category_id'], $array['category_name'])); 234 // ÊÔ½¸Ãæ¤Î¥ì¥³¡¼¥É°Ê³°¤ËƱ¤¸Ì¾¾Î¤¬Â¸ºß¤¹¤ë¾ì¹ç234 // 編集中のレコード以外に同じ名称が存在する場合 235 235 if ($arrRet[0]['category_id'] != $_POST['category_id'] && $arrRet[0]['category_name'] == $_POST['category_name']) { 236 $objErr->arrErr['category_name'] = " ¢¨ ´û¤ËƱ¤¸ÆâÍƤÎÅÐÏ¿¤¬Â¸ºß¤·¤Þ¤¹¡£<br>";236 $objErr->arrErr['category_name'] = "※ 既に同じ内容の登録が存在します。<br>"; 237 237 } 238 238 } … … 242 242 243 243 244 // ʤӤ¬1¤Ä²¼¤ÎID¤ò¼èÆÀ¤¹¤ë¡£244 // 並びが1つ下のIDを取得する。 245 245 function lfGetDownRankID($objQuery, $table, $pid_name, $id_name, $id) { 246 // ¿ÆID¤ò¼èÆÀ¤¹¤ë¡£246 // 親IDを取得する。 247 247 $col = "$pid_name"; 248 248 $where = "$id_name = ?"; 249 249 $pid = $objQuery->get($table, $col, $where, $id); 250 // ¤¹¤Ù¤Æ¤Î»Ò¤ò¼èÆÀ¤¹¤ë¡£250 // すべての子を取得する。 251 251 $col = "$id_name"; 252 252 $where = "del_flg = 0 AND $pid_name = ? ORDER BY rank DESC"; … … 263 263 } 264 264 265 // ʤӤ¬1¤Ä¾å¤ÎID¤ò¼èÆÀ¤¹¤ë¡£265 // 並びが1つ上のIDを取得する。 266 266 function lfGetUpRankID($objQuery, $table, $pid_name, $id_name, $id) { 267 // ¿ÆID¤ò¼èÆÀ¤¹¤ë¡£267 // 親IDを取得する。 268 268 $col = "$pid_name"; 269 269 $where = "$id_name = ?"; 270 270 $pid = $objQuery->get($table, $col, $where, $id); 271 // ¤¹¤Ù¤Æ¤Î»Ò¤ò¼èÆÀ¤¹¤ë¡£271 // すべての子を取得する。 272 272 $col = "$id_name"; 273 273 $where = "del_flg = 0 AND $pid_name = ? ORDER BY rank DESC"; … … 285 285 286 286 function lfCountChilds($objQuery, $table, $pid_name, $id_name, $id) { 287 // »ÒID°ìÍ÷¤ò¼èÆÀ287 // 子ID一覧を取得 288 288 $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id); 289 289 return count($arrRet); … … 291 291 292 292 function lfUpRankChilds($objQuery, $table, $pid_name, $id_name, $id, $count) { 293 // »ÒID°ìÍ÷¤ò¼èÆÀ293 // 子ID一覧を取得 294 294 $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id); 295 295 $line = sfGetCommaList($arrRet); … … 301 301 302 302 function lfDownRankChilds($objQuery, $table, $pid_name, $id_name, $id, $count) { 303 // »ÒID°ìÍ÷¤ò¼èÆÀ303 // 子ID一覧を取得 304 304 $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id); 305 305 $line = sfGetCommaList($arrRet);
Note: See TracChangeset
for help on using the changeset viewer.