24 | | if($dsn == "") { |
25 | | if(defined('DEFAULT_DSN')) { |
26 | | $dsn = DEFAULT_DSN; |
27 | | } else { |
28 | | return; |
29 | | } |
30 | | } |
31 | | |
32 | | $objQuery = new SC_Query($dsn, true, true); |
33 | | list($db_type) = split(":", $dsn); |
34 | | if($db_type == 'mysql') { |
35 | | $val = $objQuery->getOne("select version()"); |
36 | | $version = "MySQL " . $val; |
37 | | } |
38 | | if($db_type == 'pgsql') { |
39 | | $val = $objQuery->getOne("select version()"); |
40 | | $arrLine = split(" " , $val); |
41 | | $version = $arrLine[0] . " " . $arrLine[1]; |
42 | | } |
43 | | return $version; |
44 | | } |
45 | | |
46 | | /* ¥Æ¡¼¥Ö¥ë¤Î¸ºß¥Á¥§¥Ã¥¯ */ |
| 24 | if($dsn == "") { |
| 25 | if(defined('DEFAULT_DSN')) { |
| 26 | $dsn = DEFAULT_DSN; |
| 27 | } else { |
| 28 | return; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | $objQuery = new SC_Query($dsn, true, true); |
| 33 | list($db_type) = split(":", $dsn); |
| 34 | if($db_type == 'mysql') { |
| 35 | $val = $objQuery->getOne("select version()"); |
| 36 | $version = "MySQL " . $val; |
| 37 | } |
| 38 | if($db_type == 'pgsql') { |
| 39 | $val = $objQuery->getOne("select version()"); |
| 40 | $arrLine = split(" " , $val); |
| 41 | $version = $arrLine[0] . " " . $arrLine[1]; |
| 42 | } |
| 43 | return $version; |
| 44 | } |
| 45 | |
| 46 | /* テーブルの存在チェック */ |
48 | | if($dsn == "") { |
49 | | if(defined('DEFAULT_DSN')) { |
50 | | $dsn = DEFAULT_DSN; |
51 | | } else { |
52 | | return; |
53 | | } |
54 | | } |
55 | | |
56 | | $objQuery = new SC_Query($dsn, true, true); |
57 | | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
58 | | if(!$objQuery->isError()) { |
59 | | list($db_type) = split(":", $dsn); |
60 | | // postgresql¤Èmysql¤È¤Ç½èÍý¤òʬ¤±¤ë |
61 | | if ($db_type == "pgsql") { |
62 | | $sql = "SELECT |
63 | | relname |
64 | | FROM |
65 | | pg_class |
66 | | WHERE |
67 | | (relkind = 'r' OR relkind = 'v') AND |
68 | | relname = ? |
69 | | GROUP BY |
70 | | relname"; |
71 | | $arrRet = $objQuery->getAll($sql, array($table_name)); |
72 | | if(count($arrRet) > 0) { |
73 | | return true; |
74 | | } |
75 | | }else if ($db_type == "mysql") { |
76 | | $sql = "SHOW TABLE STATUS LIKE ?"; |
77 | | $arrRet = $objQuery->getAll($sql, array($table_name)); |
78 | | if(count($arrRet) > 0) { |
79 | | return true; |
80 | | } |
81 | | } |
82 | | } |
83 | | return false; |
84 | | } |
85 | | |
86 | | // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯¤ÈºîÀ® |
| 48 | if($dsn == "") { |
| 49 | if(defined('DEFAULT_DSN')) { |
| 50 | $dsn = DEFAULT_DSN; |
| 51 | } else { |
| 52 | return; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | $objQuery = new SC_Query($dsn, true, true); |
| 57 | // 正常に接続されている場合 |
| 58 | if(!$objQuery->isError()) { |
| 59 | list($db_type) = split(":", $dsn); |
| 60 | // postgresqlとmysqlとで処理を分ける |
| 61 | if ($db_type == "pgsql") { |
| 62 | $sql = "SELECT |
| 63 | relname |
| 64 | FROM |
| 65 | pg_class |
| 66 | WHERE |
| 67 | (relkind = 'r' OR relkind = 'v') AND |
| 68 | relname = ? |
| 69 | GROUP BY |
| 70 | relname"; |
| 71 | $arrRet = $objQuery->getAll($sql, array($table_name)); |
| 72 | if(count($arrRet) > 0) { |
| 73 | return true; |
| 74 | } |
| 75 | }else if ($db_type == "mysql") { |
| 76 | $sql = "SHOW TABLE STATUS LIKE ?"; |
| 77 | $arrRet = $objQuery->getAll($sql, array($table_name)); |
| 78 | if(count($arrRet) > 0) { |
| 79 | return true; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | // カラムの存在チェックと作成 |
88 | | if($dsn == "") { |
89 | | if(defined('DEFAULT_DSN')) { |
90 | | $dsn = DEFAULT_DSN; |
91 | | } else { |
92 | | return; |
93 | | } |
94 | | } |
95 | | |
96 | | // ¥Æ¡¼¥Ö¥ë¤¬Ìµ¤±¤ì¤Ð¥¨¥é¡¼ |
97 | | if(!sfTabaleExists($table_name, $dsn)) return false; |
98 | | |
99 | | $objQuery = new SC_Query($dsn, true, true); |
100 | | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
101 | | if(!$objQuery->isError()) { |
102 | | list($db_type) = split(":", $dsn); |
103 | | |
104 | | // ¥«¥é¥à¥ê¥¹¥È¤ò¼èÆÀ |
105 | | $arrRet = sfGetColumnList($table_name, $objQuery, $db_type); |
106 | | if(count($arrRet) > 0) { |
107 | | if(in_array($col_name, $arrRet)){ |
108 | | return true; |
109 | | } |
110 | | } |
111 | | } |
112 | | |
113 | | // ¥«¥é¥à¤òÄɲ乤ë |
114 | | if($add){ |
115 | | $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); |
116 | | return true; |
117 | | } |
118 | | |
119 | | return false; |
120 | | } |
121 | | |
122 | | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß¥Á¥§¥Ã¥¯¤ÈºîÀ® |
| 88 | if($dsn == "") { |
| 89 | if(defined('DEFAULT_DSN')) { |
| 90 | $dsn = DEFAULT_DSN; |
| 91 | } else { |
| 92 | return; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // テーブルが無ければエラー |
| 97 | if(!sfTabaleExists($table_name, $dsn)) return false; |
| 98 | |
| 99 | $objQuery = new SC_Query($dsn, true, true); |
| 100 | // 正常に接続されている場合 |
| 101 | if(!$objQuery->isError()) { |
| 102 | list($db_type) = split(":", $dsn); |
| 103 | |
| 104 | // カラムリストを取得 |
| 105 | $arrRet = sfGetColumnList($table_name, $objQuery, $db_type); |
| 106 | if(count($arrRet) > 0) { |
| 107 | if(in_array($col_name, $arrRet)){ |
| 108 | return true; |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | // カラムを追加する |
| 114 | if($add){ |
| 115 | $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | // インデックスの存在チェックと作成 |
124 | | if($dsn == "") { |
125 | | if(defined('DEFAULT_DSN')) { |
126 | | $dsn = DEFAULT_DSN; |
127 | | } else { |
128 | | return; |
129 | | } |
130 | | } |
131 | | |
132 | | // ¥Æ¡¼¥Ö¥ë¤¬Ìµ¤±¤ì¤Ð¥¨¥é¡¼ |
133 | | if(!sfTabaleExists($table_name, $dsn)) return false; |
134 | | |
135 | | $objQuery = new SC_Query($dsn, true, true); |
136 | | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
137 | | if(!$objQuery->isError()) { |
138 | | list($db_type) = split(":", $dsn); |
139 | | switch($db_type) { |
140 | | case 'pgsql': |
141 | | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß³Îǧ |
142 | | $arrRet = $objQuery->getAll("SELECT relname FROM pg_class WHERE relname = ?", array($index_name)); |
143 | | break; |
144 | | case 'mysql': |
145 | | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß³Îǧ |
146 | | $arrRet = $objQuery->getAll("SHOW INDEX FROM ? WHERE Key_name = ?", array($table_name, $index_name)); |
147 | | break; |
148 | | default: |
149 | | return false; |
150 | | } |
151 | | // ¤¹¤Ç¤Ë¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬Â¸ºß¤¹¤ë¾ì¹ç |
152 | | if(count($arrRet) > 0) { |
153 | | return true; |
154 | | } |
155 | | } |
156 | | |
157 | | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤òºîÀ®¤¹¤ë |
158 | | if($add){ |
159 | | switch($db_type) { |
160 | | case 'pgsql': |
161 | | $objQuery->query("CREATE INDEX ? ON ? (?)", array($index_name, $table_name, $col_name)); |
162 | | break; |
163 | | case 'mysql': |
164 | | $objQuery->query("CREATE INDEX ? ON ? (?(?))", array($index_name, $table_name, $col_name, $length)); |
165 | | break; |
166 | | default: |
167 | | return false; |
168 | | } |
169 | | return true; |
170 | | } |
171 | | return false; |
172 | | } |
173 | | |
174 | | // ¥Ç¡¼¥¿¤Î¸ºß¥Á¥§¥Ã¥¯ |
| 124 | if($dsn == "") { |
| 125 | if(defined('DEFAULT_DSN')) { |
| 126 | $dsn = DEFAULT_DSN; |
| 127 | } else { |
| 128 | return; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | // テーブルが無ければエラー |
| 133 | if(!sfTabaleExists($table_name, $dsn)) return false; |
| 134 | |
| 135 | $objQuery = new SC_Query($dsn, true, true); |
| 136 | // 正常に接続されている場合 |
| 137 | if(!$objQuery->isError()) { |
| 138 | list($db_type) = split(":", $dsn); |
| 139 | switch($db_type) { |
| 140 | case 'pgsql': |
| 141 | // インデックスの存在確認 |
| 142 | $arrRet = $objQuery->getAll("SELECT relname FROM pg_class WHERE relname = ?", array($index_name)); |
| 143 | break; |
| 144 | case 'mysql': |
| 145 | // インデックスの存在確認 |
| 146 | $arrRet = $objQuery->getAll("SHOW INDEX FROM ? WHERE Key_name = ?", array($table_name, $index_name)); |
| 147 | break; |
| 148 | default: |
| 149 | return false; |
| 150 | } |
| 151 | // すでにインデックスが存在する場合 |
| 152 | if(count($arrRet) > 0) { |
| 153 | return true; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // インデックスを作成する |
| 158 | if($add){ |
| 159 | switch($db_type) { |
| 160 | case 'pgsql': |
| 161 | $objQuery->query("CREATE INDEX ? ON ? (?)", array($index_name, $table_name, $col_name)); |
| 162 | break; |
| 163 | case 'mysql': |
| 164 | $objQuery->query("CREATE INDEX ? ON ? (?(?))", array($index_name, $table_name, $col_name, $length)); |
| 165 | break; |
| 166 | default: |
| 167 | return false; |
| 168 | } |
| 169 | return true; |
| 170 | } |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | // データの存在チェック |
210 | | // ¥Ç¡¼¥¿¥½¡¼¥¹ |
211 | | if($dsn == "") { |
212 | | if(defined('DEFAULT_DSN')) { |
213 | | $dsn = DEFAULT_DSN; |
214 | | } else { |
215 | | return; |
216 | | } |
217 | | } |
218 | | |
219 | | // ¥¯¥¨¥êÀ¸À® |
220 | | $target_column = "control_flg"; |
221 | | $table_name = "dtb_site_control"; |
222 | | $where = "control_id = ?"; |
223 | | $arrval = array($control_id); |
224 | | $control_flg = 0; |
225 | | |
226 | | // ¥¯¥¨¥êȯ¹Ô |
227 | | $objQuery = new SC_Query($dsn, true, true); |
228 | | $arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval); |
229 | | |
230 | | // ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ì¤Ð¥Õ¥é¥°¤ò¼èÆÀ¤¹¤ë |
231 | | if (count($arrSiteControl) > 0) { |
232 | | $control_flg = $arrSiteControl[0]["control_flg"]; |
233 | | } |
234 | | |
235 | | return $control_flg; |
236 | | } |
237 | | |
238 | | // ¥Æ¡¼¥Ö¥ë¤Î¥«¥é¥à°ìÍ÷¤ò¼èÆÀ¤¹¤ë |
| 210 | // データソース |
| 211 | if($dsn == "") { |
| 212 | if(defined('DEFAULT_DSN')) { |
| 213 | $dsn = DEFAULT_DSN; |
| 214 | } else { |
| 215 | return; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | // クエリ生成 |
| 220 | $target_column = "control_flg"; |
| 221 | $table_name = "dtb_site_control"; |
| 222 | $where = "control_id = ?"; |
| 223 | $arrval = array($control_id); |
| 224 | $control_flg = 0; |
| 225 | |
| 226 | // クエリ発行 |
| 227 | $objQuery = new SC_Query($dsn, true, true); |
| 228 | $arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval); |
| 229 | |
| 230 | // データが存在すればフラグを取得する |
| 231 | if (count($arrSiteControl) > 0) { |
| 232 | $control_flg = $arrSiteControl[0]["control_flg"]; |
| 233 | } |
| 234 | |
| 235 | return $control_flg; |
| 236 | } |
| 237 | |
| 238 | // テーブルのカラム一覧を取得する |
240 | | if($objQuery == "") $objQuery = new SC_Query(); |
241 | | $arrRet = array(); |
242 | | |
243 | | // postgresql¤Èmysql¤È¤Ç½èÍý¤òʬ¤±¤ë |
244 | | if ($db_type == "pgsql") { |
245 | | $sql = "SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname=? AND c.oid=a.attrelid AND a.attnum > 0 AND not a.attname like '........pg.dropped.%........' ORDER BY a.attnum"; |
246 | | $arrColList = $objQuery->getAll($sql, array($table_name)); |
247 | | $arrColList = sfswaparray($arrColList); |
248 | | $arrRet = $arrColList["attname"]; |
249 | | }else if ($db_type == "mysql") { |
250 | | $sql = "SHOW COLUMNS FROM $table_name"; |
251 | | $arrColList = $objQuery->getAll($sql); |
252 | | $arrColList = sfswaparray($arrColList); |
253 | | $arrRet = $arrColList["Field"]; |
254 | | } |
255 | | return $arrRet; |
256 | | } |
257 | | |
258 | | // ¥¤¥ó¥¹¥È¡¼¥ë½é´ü½èÍý |
| 240 | if($objQuery == "") $objQuery = new SC_Query(); |
| 241 | $arrRet = array(); |
| 242 | |
| 243 | // postgresqlとmysqlとで処理を分ける |
| 244 | if ($db_type == "pgsql") { |
| 245 | $sql = "SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname=? AND c.oid=a.attrelid AND a.attnum > 0 AND not a.attname like '........pg.dropped.%........' ORDER BY a.attnum"; |
| 246 | $arrColList = $objQuery->getAll($sql, array($table_name)); |
| 247 | $arrColList = sfswaparray($arrColList); |
| 248 | $arrRet = $arrColList["attname"]; |
| 249 | }else if ($db_type == "mysql") { |
| 250 | $sql = "SHOW COLUMNS FROM $table_name"; |
| 251 | $arrColList = $objQuery->getAll($sql); |
| 252 | $arrColList = sfswaparray($arrColList); |
| 253 | $arrRet = $arrColList["Field"]; |
| 254 | } |
| 255 | return $arrRet; |
| 256 | } |
| 257 | |
| 258 | // インストール初期処理 |
322 | | |
323 | | class LC_ErrorPage { |
324 | | function LC_ErrorPage() { |
325 | | $this->tpl_mainpage = 'login_error.tpl'; |
326 | | $this->tpl_title = '¥¨¥é¡¼'; |
327 | | } |
328 | | } |
329 | | |
330 | | $objPage = new LC_ErrorPage(); |
331 | | $objView = new SC_AdminView(); |
332 | | |
333 | | switch ($type) { |
334 | | case LOGIN_ERROR: |
335 | | $objPage->tpl_error="£É£Ä¤Þ¤¿¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£"; |
336 | | break; |
337 | | case ACCESS_ERROR: |
338 | | $objPage->tpl_error="¥í¥°¥¤¥óǧ¾Ú¤Î͸ú´ü¸ÂÀÚ¤ì¤Î²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
339 | | break; |
340 | | case AUTH_ERROR: |
341 | | $objPage->tpl_error="¤³¤Î¥Õ¥¡¥¤¥ë¤Ë¤Ï¥¢¥¯¥»¥¹¸¢¸Â¤¬¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
342 | | break; |
343 | | case INVALID_MOVE_ERRORR: |
344 | | $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£"; |
345 | | break; |
346 | | default: |
347 | | $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
348 | | break; |
349 | | } |
350 | | |
351 | | $objView->assignobj($objPage); |
352 | | $objView->display(LOGIN_FRAME); |
353 | | |
354 | | exit; |
355 | | } |
356 | | |
357 | | /* ¥µ¥¤¥È¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ */ |
| 322 | |
| 323 | class LC_ErrorPage { |
| 324 | function LC_ErrorPage() { |
| 325 | $this->tpl_mainpage = 'login_error.tpl'; |
| 326 | $this->tpl_title = 'エラー'; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | $objPage = new LC_ErrorPage(); |
| 331 | $objView = new SC_AdminView(); |
| 332 | |
| 333 | switch ($type) { |
| 334 | case LOGIN_ERROR: |
| 335 | $objPage->tpl_error="IDまたはパスワードが正しくありません。<br />もう一度ご確認のうえ、再度入力してください。"; |
| 336 | break; |
| 337 | case ACCESS_ERROR: |
| 338 | $objPage->tpl_error="ログイン認証の有効期限切れの可能性があります。<br />もう一度ご確認のうえ、再度ログインしてください。"; |
| 339 | break; |
| 340 | case AUTH_ERROR: |
| 341 | $objPage->tpl_error="このファイルにはアクセス権限がありません。<br />もう一度ご確認のうえ、再度ログインしてください。"; |
| 342 | break; |
| 343 | case INVALID_MOVE_ERRORR: |
| 344 | $objPage->tpl_error="不正なページ移動です。<br />もう一度ご確認のうえ、再度入力してください。"; |
| 345 | break; |
| 346 | default: |
| 347 | $objPage->tpl_error="エラーが発生しました。<br />もう一度ご確認のうえ、再度ログインしてください。"; |
| 348 | break; |
| 349 | } |
| 350 | |
| 351 | $objView->assignobj($objPage); |
| 352 | $objView->display(LOGIN_FRAME); |
| 353 | |
| 354 | exit; |
| 355 | } |
| 356 | |
| 357 | /* サイトエラーページの表示 */ |
359 | | global $objCampaignSess; |
360 | | |
361 | | if ($objSiteSess != "") { |
362 | | $objSiteSess->setNowPage('error'); |
363 | | } |
364 | | |
365 | | class LC_ErrorPage { |
366 | | function LC_ErrorPage() { |
367 | | $this->tpl_mainpage = 'error.tpl'; |
368 | | $this->tpl_css = URL_DIR.'css/layout/error.css'; |
369 | | $this->tpl_title = '¥¨¥é¡¼'; |
370 | | } |
371 | | } |
372 | | |
373 | | $objPage = new LC_ErrorPage(); |
374 | | |
375 | | if($is_mobile === true) { |
376 | | $objView = new SC_MobileView(); |
377 | | } else { |
378 | | $objView = new SC_SiteView(); |
379 | | } |
380 | | |
381 | | switch ($type) { |
382 | | case PRODUCT_NOT_FOUND: |
383 | | $objPage->tpl_error="¤´»ØÄê¤Î¥Ú¡¼¥¸¤Ï¤´¤¶¤¤¤Þ¤»¤ó¡£"; |
384 | | break; |
385 | | case PAGE_ERROR: |
386 | | $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£"; |
387 | | break; |
388 | | case CART_EMPTY: |
389 | | $objPage->tpl_error="¥«¡¼¥È¤Ë¾¦Éʤ¬¤¬¤¢¤ê¤Þ¤»¤ó¡£"; |
390 | | break; |
391 | | case CART_ADD_ERROR: |
392 | | $objPage->tpl_error="¹ØÆþ½èÍýÃæ¤Ï¡¢¥«¡¼¥È¤Ë¾¦ÉʤòÄɲ乤뤳¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£"; |
393 | | break; |
394 | | case CANCEL_PURCHASE: |
395 | | $objPage->tpl_error="¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£°Ê²¼¤ÎÍ×°ø¤¬¹Í¤¨¤é¤ì¤Þ¤¹¡£<br />¡¦¥»¥Ã¥·¥ç¥ó¾ðÊó¤Î͸ú´ü¸Â¤¬ÀÚ¤ì¤Æ¤ë¾ì¹ç<br />¡¦¹ØÆþ¼ê³¤Ãæ¤Ë¿·¤·¤¤¹ØÆþ¼ê³¤¤ò¼Â¹Ô¤·¤¿¾ì¹ç<br />¡¦¤¹¤Ç¤Ë¹ØÆþ¼ê³¤¤ò´°Î»¤·¤Æ¤¤¤ë¾ì¹ç"; |
396 | | break; |
397 | | case CATEGORY_NOT_FOUND: |
398 | | $objPage->tpl_error="¤´»ØÄê¤Î¥«¥Æ¥´¥ê¤Ï¸ºß¤·¤Þ¤»¤ó¡£"; |
399 | | break; |
400 | | case SITE_LOGIN_ERROR: |
401 | | $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£"; |
402 | | break; |
403 | | case TEMP_LOGIN_ERROR: |
404 | | $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />ËÜÅÐÏ¿¤¬¤ªºÑ¤ß¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢²¾ÅÐÏ¿¥á¡¼¥ë¤ËµºÜ¤µ¤ì¤Æ¤¤¤ë<br />URL¤è¤êËÜÅÐÏ¿¤ò¹Ô¤Ã¤Æ¤¯¤À¤µ¤¤¡£"; |
405 | | break; |
406 | | case CUSTOMER_ERROR: |
407 | | $objPage->tpl_error="ÉÔÀµ¤Ê¥¢¥¯¥»¥¹¤Ç¤¹¡£"; |
408 | | break; |
409 | | case SOLD_OUT: |
410 | | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤´¹ØÆþ¤ÎľÁ°¤ÇÇä¤êÀڤ줿¾¦Éʤ¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
411 | | break; |
412 | | case CART_NOT_FOUND: |
413 | | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥«¡¼¥ÈÆâ¤Î¾¦ÉʾðÊó¤Î¼èÆÀ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
414 | | break; |
415 | | case LACK_POINT: |
416 | | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥Ý¥¤¥ó¥È¤¬ÉÔ¤·¤Æ¤ª¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
417 | | break; |
418 | | case FAVORITE_ERROR: |
419 | | $objPage->tpl_error="´û¤Ë¤ªµ¤¤ËÆþ¤ê¤ËÄɲäµ¤ì¤Æ¤¤¤ë¾¦ÉʤǤ¹¡£"; |
420 | | break; |
421 | | case EXTRACT_ERROR: |
422 | | $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤Î²òÅà¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë½ñ¤¹þ¤ß¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
423 | | break; |
424 | | case FTP_DOWNLOAD_ERROR: |
425 | | $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤ÎFTP¥À¥¦¥ó¥í¡¼¥É¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
426 | | break; |
427 | | case FTP_LOGIN_ERROR: |
428 | | $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
429 | | break; |
430 | | case FTP_CONNECT_ERROR: |
431 | | $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
432 | | break; |
433 | | case CREATE_DB_ERROR: |
434 | | $objPage->tpl_error="DB¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥æ¡¼¥¶¡¼¤Ë¤Ï¡¢DBºîÀ®¤Î¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
435 | | break; |
436 | | case DB_IMPORT_ERROR: |
437 | | $objPage->tpl_error="¥Ç¡¼¥¿¥Ù¡¼¥¹¹½Â¤¤Î¥¤¥ó¥Ý¡¼¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\nsql¥Õ¥¡¥¤¥ë¤¬²õ¤ì¤Æ¤¤¤ë²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
438 | | break; |
439 | | case FILE_NOT_FOUND: |
440 | | $objPage->tpl_error="»ØÄê¤Î¥Ñ¥¹¤Ë¡¢ÀßÄê¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó¡£"; |
441 | | break; |
442 | | case WRITE_FILE_ERROR: |
443 | | $objPage->tpl_error="ÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤á¤Þ¤»¤ó¡£\nÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤ß¸¢¸Â¤òÍ¿¤¨¤Æ¤¯¤À¤µ¤¤¡£"; |
444 | | break; |
445 | | case FREE_ERROR_MSG: |
446 | | $objPage->tpl_error=$err_msg; |
447 | | break; |
448 | | default: |
449 | | $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£"; |
450 | | break; |
451 | | } |
452 | | |
453 | | $objPage->return_top = $return_top; |
454 | | |
455 | | $objView->assignobj($objPage); |
456 | | |
457 | | if(is_object($objCampaignSess)) { |
458 | | // ¥Õ¥ì¡¼¥à¤òÁªÂò(¥¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹) |
459 | | $objCampaignSess->pageView($objView); |
460 | | } else { |
461 | | $objView->display(SITE_FRAME); |
462 | | } |
463 | | exit; |
464 | | } |
465 | | |
466 | | /* ǧ¾Ú¤Î²ÄÈÝȽÄê */ |
| 359 | global $objCampaignSess; |
| 360 | |
| 361 | if ($objSiteSess != "") { |
| 362 | $objSiteSess->setNowPage('error'); |
| 363 | } |
| 364 | |
| 365 | class LC_ErrorPage { |
| 366 | function LC_ErrorPage() { |
| 367 | $this->tpl_mainpage = 'error.tpl'; |
| 368 | $this->tpl_css = URL_DIR.'css/layout/error.css'; |
| 369 | $this->tpl_title = 'エラー'; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | $objPage = new LC_ErrorPage(); |
| 374 | |
| 375 | if($is_mobile === true) { |
| 376 | $objView = new SC_MobileView(); |
| 377 | } else { |
| 378 | $objView = new SC_SiteView(); |
| 379 | } |
| 380 | |
| 381 | switch ($type) { |
| 382 | case PRODUCT_NOT_FOUND: |
| 383 | $objPage->tpl_error="ご指定のページはございません。"; |
| 384 | break; |
| 385 | case PAGE_ERROR: |
| 386 | $objPage->tpl_error="不正なページ移動です。"; |
| 387 | break; |
| 388 | case CART_EMPTY: |
| 389 | $objPage->tpl_error="カートに商品ががありません。"; |
| 390 | break; |
| 391 | case CART_ADD_ERROR: |
| 392 | $objPage->tpl_error="購入処理中は、カートに商品を追加することはできません。"; |
| 393 | break; |
| 394 | case CANCEL_PURCHASE: |
| 395 | $objPage->tpl_error="この手続きは無効となりました。以下の要因が考えられます。<br />・セッション情報の有効期限が切れてる場合<br />・購入手続き中に新しい購入手続きを実行した場合<br />・すでに購入手続きを完了している場合"; |
| 396 | break; |
| 397 | case CATEGORY_NOT_FOUND: |
| 398 | $objPage->tpl_error="ご指定のカテゴリは存在しません。"; |
| 399 | break; |
| 400 | case SITE_LOGIN_ERROR: |
| 401 | $objPage->tpl_error="メールアドレスもしくはパスワードが正しくありません。"; |
| 402 | break; |
| 403 | case TEMP_LOGIN_ERROR: |
| 404 | $objPage->tpl_error="メールアドレスもしくはパスワードが正しくありません。<br />本登録がお済みでない場合は、仮登録メールに記載されている<br />URLより本登録を行ってください。"; |
| 405 | break; |
| 406 | case CUSTOMER_ERROR: |
| 407 | $objPage->tpl_error="不正なアクセスです。"; |
| 408 | break; |
| 409 | case SOLD_OUT: |
| 410 | $objPage->tpl_error="申し訳ございませんが、ご購入の直前で売り切れた商品があります。この手続きは無効となりました。"; |
| 411 | break; |
| 412 | case CART_NOT_FOUND: |
| 413 | $objPage->tpl_error="申し訳ございませんが、カート内の商品情報の取得に失敗しました。この手続きは無効となりました。"; |
| 414 | break; |
| 415 | case LACK_POINT: |
| 416 | $objPage->tpl_error="申し訳ございませんが、ポイントが不足しております。この手続きは無効となりました。"; |
| 417 | break; |
| 418 | case FAVORITE_ERROR: |
| 419 | $objPage->tpl_error="既にお気に入りに追加されている商品です。"; |
| 420 | break; |
| 421 | case EXTRACT_ERROR: |
| 422 | $objPage->tpl_error="ファイルの解凍に失敗しました。\n指定のディレクトリに書き込み権限が与えられていない可能性があります。"; |
| 423 | break; |
| 424 | case FTP_DOWNLOAD_ERROR: |
| 425 | $objPage->tpl_error="ファイルのFTPダウンロードに失敗しました。"; |
| 426 | break; |
| 427 | case FTP_LOGIN_ERROR: |
| 428 | $objPage->tpl_error="FTPログインに失敗しました。"; |
| 429 | break; |
| 430 | case FTP_CONNECT_ERROR: |
| 431 | $objPage->tpl_error="FTPログインに失敗しました。"; |
| 432 | break; |
| 433 | case CREATE_DB_ERROR: |
| 434 | $objPage->tpl_error="DBの作成に失敗しました。\n指定のユーザーには、DB作成の権限が与えられていない可能性があります。"; |
| 435 | break; |
| 436 | case DB_IMPORT_ERROR: |
| 437 | $objPage->tpl_error="データベース構造のインポートに失敗しました。\nsqlファイルが壊れている可能性があります。"; |
| 438 | break; |
| 439 | case FILE_NOT_FOUND: |
| 440 | $objPage->tpl_error="指定のパスに、設定ファイルが存在しません。"; |
| 441 | break; |
| 442 | case WRITE_FILE_ERROR: |
| 443 | $objPage->tpl_error="設定ファイルに書き込めません。\n設定ファイルに書き込み権限を与えてください。"; |
| 444 | break; |
| 445 | case FREE_ERROR_MSG: |
| 446 | $objPage->tpl_error=$err_msg; |
| 447 | break; |
| 448 | default: |
| 449 | $objPage->tpl_error="エラーが発生しました。"; |
| 450 | break; |
| 451 | } |
| 452 | |
| 453 | $objPage->return_top = $return_top; |
| 454 | |
| 455 | $objView->assignobj($objPage); |
| 456 | |
| 457 | if(is_object($objCampaignSess)) { |
| 458 | // フレームを選択(キャンペーンページから遷移なら変更) |
| 459 | $objCampaignSess->pageView($objView); |
| 460 | } else { |
| 461 | $objView->display(SITE_FRAME); |
| 462 | } |
| 463 | exit; |
| 464 | } |
| 465 | |
| 466 | /* 認証の可否判定 */ |
537 | | // ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ |
538 | | $uniqid = $objSiteSess->getUniqId(); |
539 | | // ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤¿»þ¤Î¥«¡¼¥ÈÆâÍÆ¤¬¥³¥Ô¡¼¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Î¤ß¥³¥Ô¡¼¤¹¤ë¡£ |
540 | | $objCartSess->saveCurrentCart($uniqid); |
541 | | // POST¤Î¥æ¥Ë¡¼¥¯ID¤È¥»¥Ã¥·¥ç¥ó¤Î¥æ¥Ë¡¼¥¯ID¤òÈæ³Ó(¥æ¥Ë¡¼¥¯ID¤¬POST¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¥¹¥ë¡¼) |
542 | | $ret = $objSiteSess->checkUniqId(); |
543 | | if($ret != true) { |
544 | | // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ |
545 | | sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); |
546 | | } |
547 | | |
548 | | // ¥«¡¼¥ÈÆâ¤¬¶õ¤Ç¤Ê¤¤¤« || ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤«¤éÊѲ½¤¬¤Ê¤¤¤« |
549 | | $quantity = $objCartSess->getTotalQuantity(); |
550 | | $ret = $objCartSess->checkChangeCart(); |
551 | | if($ret == true || !($quantity > 0)) { |
552 | | // ¥«¡¼¥È¾ðÊóɽ¼¨¤Ë¶¯À©°Üư¤¹¤ë |
553 | | header("Location: ".URL_CART_TOP); |
554 | | exit; |
555 | | } |
556 | | return $uniqid; |
557 | | } |
558 | | |
559 | | /* DBÍÑÆüÉÕʸ»úÎó¼èÆÀ */ |
| 537 | // ユーザユニークIDの取得 |
| 538 | $uniqid = $objSiteSess->getUniqId(); |
| 539 | // 購入ボタンを押した時のカート内容がコピーされていない場合のみコピーする。 |
| 540 | $objCartSess->saveCurrentCart($uniqid); |
| 541 | // POSTのユニークIDとセッションのユニークIDを比較(ユニークIDがPOSTされていない場合はスルー) |
| 542 | $ret = $objSiteSess->checkUniqId(); |
| 543 | if($ret != true) { |
| 544 | // エラーページの表示 |
| 545 | sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); |
| 546 | } |
| 547 | |
| 548 | // カート内が空でないか || 購入ボタンを押してから変化がないか |
| 549 | $quantity = $objCartSess->getTotalQuantity(); |
| 550 | $ret = $objCartSess->checkChangeCart(); |
| 551 | if($ret == true || !($quantity > 0)) { |
| 552 | // カート情報表示に強制移動する |
| 553 | header("Location: ".URL_CART_TOP); |
| 554 | exit; |
| 555 | } |
| 556 | return $uniqid; |
| 557 | } |
| 558 | |
| 559 | /* DB用日付文字列取得 */ |
583 | | |
584 | | if($prefix == "") { |
585 | | $dir_name = sfUpDirName(); |
586 | | $file_name = $dir_name . date("ymdHis") .".csv"; |
587 | | } else { |
588 | | $file_name = $prefix . date("ymdHis") .".csv"; |
589 | | } |
590 | | |
591 | | /* HTTP¥Ø¥Ã¥À¤Î½ÐÎÏ */ |
592 | | Header("Content-disposition: attachment; filename=${file_name}"); |
593 | | Header("Content-type: application/octet-stream; name=${file_name}"); |
594 | | Header("Cache-Control: "); |
595 | | Header("Pragma: "); |
596 | | |
597 | | /* i18n¢· ¤À¤ÈÀµ¾ï¤Ëưºî¤·¤Ê¤¤¤¿¤á¡¢mb¢· ¤ËÊѹ¹ |
598 | | if (i18n_discover_encoding($data) == CHAR_CODE){ |
599 | | $data = i18n_convert($data,'SJIS',CHAR_CODE); |
600 | | } |
601 | | */ |
602 | | if (mb_internal_encoding() == CHAR_CODE){ |
603 | | $data = mb_convert_encoding($data,'SJIS',CHAR_CODE); |
604 | | } |
605 | | |
606 | | /* ¥Ç¡¼¥¿¤ò½ÐÎÏ */ |
607 | | echo $data; |
608 | | } |
609 | | |
610 | | /* 1³¬Áؾå¤Î¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ¤¹¤ë */ |
| 583 | |
| 584 | if($prefix == "") { |
| 585 | $dir_name = sfUpDirName(); |
| 586 | $file_name = $dir_name . date("ymdHis") .".csv"; |
| 587 | } else { |
| 588 | $file_name = $prefix . date("ymdHis") .".csv"; |
| 589 | } |
| 590 | |
| 591 | /* HTTPヘッダの出力 */ |
| 592 | Header("Content-disposition: attachment; filename=${file_name}"); |
| 593 | Header("Content-type: application/octet-stream; name=${file_name}"); |
| 594 | Header("Cache-Control: "); |
| 595 | Header("Pragma: "); |
| 596 | |
| 597 | /* i18n~ だと正常に動作しないため、mb~ に変更 |
| 598 | if (i18n_discover_encoding($data) == CHAR_CODE){ |
| 599 | $data = i18n_convert($data,'SJIS',CHAR_CODE); |
| 600 | } |
| 601 | */ |
| 602 | if (mb_internal_encoding() == CHAR_CODE){ |
| 603 | $data = mb_convert_encoding($data,'SJIS',CHAR_CODE); |
| 604 | } |
| 605 | |
| 606 | /* データを出力 */ |
| 607 | echo $data; |
| 608 | } |
| 609 | |
| 610 | /* 1階層上のディレクトリ名を取得する */ |
636 | | $objQuery = new SC_Query(); |
637 | | $objQuery->begin(); |
638 | | $where = "$colname = ?"; |
639 | | if($andwhere != "") { |
640 | | $where.= " AND $andwhere"; |
641 | | } |
642 | | // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ |
643 | | $rank = $objQuery->get($table, "rank", $where, array($id)); |
644 | | // ¥é¥ó¥¯¤ÎºÇÂçÃͤò¼èÆÀ |
645 | | $maxrank = $objQuery->max($table, "rank", $andwhere); |
646 | | // ¥é¥ó¥¯¤¬ºÇÂçÃͤè¤ê¤â¾®¤µ¤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£ |
647 | | if($rank < $maxrank) { |
648 | | // ¥é¥ó¥¯¤¬°ì¤Ä¾å¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ |
649 | | $where = "rank = ?"; |
650 | | if($andwhere != "") { |
651 | | $where.= " AND $andwhere"; |
652 | | } |
653 | | $uprank = $rank + 1; |
654 | | $up_id = $objQuery->get($table, $colname, $where, array($uprank)); |
655 | | // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô |
656 | | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
657 | | $objQuery->exec($sqlup, array($rank + 1, $id)); |
658 | | $objQuery->exec($sqlup, array($rank, $up_id)); |
659 | | } |
660 | | $objQuery->commit(); |
661 | | } |
662 | | |
663 | | // ¥é¥ó¥¥ó¥°¤ò²¼¤²¤ë¡£ |
| 636 | $objQuery = new SC_Query(); |
| 637 | $objQuery->begin(); |
| 638 | $where = "$colname = ?"; |
| 639 | if($andwhere != "") { |
| 640 | $where.= " AND $andwhere"; |
| 641 | } |
| 642 | // 対象項目のランクを取得 |
| 643 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
| 644 | // ランクの最大値を取得 |
| 645 | $maxrank = $objQuery->max($table, "rank", $andwhere); |
| 646 | // ランクが最大値よりも小さい場合に実行する。 |
| 647 | if($rank < $maxrank) { |
| 648 | // ランクが一つ上のIDを取得する。 |
| 649 | $where = "rank = ?"; |
| 650 | if($andwhere != "") { |
| 651 | $where.= " AND $andwhere"; |
| 652 | } |
| 653 | $uprank = $rank + 1; |
| 654 | $up_id = $objQuery->get($table, $colname, $where, array($uprank)); |
| 655 | // ランク入れ替えの実行 |
| 656 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
| 657 | $objQuery->exec($sqlup, array($rank + 1, $id)); |
| 658 | $objQuery->exec($sqlup, array($rank, $up_id)); |
| 659 | } |
| 660 | $objQuery->commit(); |
| 661 | } |
| 662 | |
| 663 | // ランキングを下げる。 |
665 | | $objQuery = new SC_Query(); |
666 | | $objQuery->begin(); |
667 | | $where = "$colname = ?"; |
668 | | if($andwhere != "") { |
669 | | $where.= " AND $andwhere"; |
670 | | } |
671 | | // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ |
672 | | $rank = $objQuery->get($table, "rank", $where, array($id)); |
673 | | |
674 | | // ¥é¥ó¥¯¤¬1(ºÇ¾®ÃÍ)¤è¤ê¤âÂ礤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£ |
675 | | if($rank > 1) { |
676 | | // ¥é¥ó¥¯¤¬°ì¤Ä²¼¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ |
677 | | $where = "rank = ?"; |
678 | | if($andwhere != "") { |
679 | | $where.= " AND $andwhere"; |
680 | | } |
681 | | $downrank = $rank - 1; |
682 | | $down_id = $objQuery->get($table, $colname, $where, array($downrank)); |
683 | | // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô |
684 | | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
685 | | $objQuery->exec($sqlup, array($rank - 1, $id)); |
686 | | $objQuery->exec($sqlup, array($rank, $down_id)); |
687 | | } |
688 | | $objQuery->commit(); |
689 | | } |
690 | | |
691 | | //----¡¡»ØÄê½ç°Ì¤Ø°Üư |
| 665 | $objQuery = new SC_Query(); |
| 666 | $objQuery->begin(); |
| 667 | $where = "$colname = ?"; |
| 668 | if($andwhere != "") { |
| 669 | $where.= " AND $andwhere"; |
| 670 | } |
| 671 | // 対象項目のランクを取得 |
| 672 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
| 673 | |
| 674 | // ランクが1(最小値)よりも大きい場合に実行する。 |
| 675 | if($rank > 1) { |
| 676 | // ランクが一つ下のIDを取得する。 |
| 677 | $where = "rank = ?"; |
| 678 | if($andwhere != "") { |
| 679 | $where.= " AND $andwhere"; |
| 680 | } |
| 681 | $downrank = $rank - 1; |
| 682 | $down_id = $objQuery->get($table, $colname, $where, array($downrank)); |
| 683 | // ランク入れ替えの実行 |
| 684 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
| 685 | $objQuery->exec($sqlup, array($rank - 1, $id)); |
| 686 | $objQuery->exec($sqlup, array($rank, $down_id)); |
| 687 | } |
| 688 | $objQuery->commit(); |
| 689 | } |
| 690 | |
| 691 | //---- 指定順位へ移動 |
693 | | $objQuery = new SC_Query(); |
694 | | $objQuery->begin(); |
695 | | |
696 | | // ¼«¿È¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë |
697 | | $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId)); |
698 | | $max = $objQuery->max($tableName, "rank", $where); |
699 | | |
700 | | // ÃͤÎÄ´À°¡ÊµÕ½ç¡Ë |
701 | | if($pos > $max) { |
702 | | $position = 1; |
703 | | } else if($pos < 1) { |
704 | | $position = $max; |
705 | | } else { |
706 | | $position = $max - $pos + 1; |
707 | | } |
708 | | |
709 | | if( $position > $rank ) $term = "rank - 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤êÂ礤¤¾ì¹ç |
710 | | if( $position < $rank ) $term = "rank + 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤ê¾®¤µ¤¤¾ì¹ç |
711 | | |
712 | | //--¡¡»ØÄꤷ¤¿½ç°Ì¤Î¾¦Éʤ«¤é°Üư¤µ¤»¤ë¾¦ÉʤޤǤÎrank¤ò£±¤Ä¤º¤é¤¹ |
713 | | $sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0"; |
714 | | if($where != "") { |
715 | | $sql.= " AND $where"; |
716 | | } |
717 | | |
718 | | if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position )); |
719 | | if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 )); |
720 | | |
721 | | //-- »ØÄꤷ¤¿½ç°Ì¤Ørank¤ò½ñ¤´¹¤¨¤ë¡£ |
722 | | $sql = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 "; |
723 | | if($where != "") { |
724 | | $sql.= " AND $where"; |
725 | | } |
726 | | |
727 | | $objQuery->exec( $sql, array( $position, $keyId ) ); |
728 | | $objQuery->commit(); |
729 | | } |
730 | | |
731 | | // ¥é¥ó¥¯¤ò´Þ¤à¥ì¥³¡¼¥É¤Îºï½ü |
732 | | // ¥ì¥³¡¼¥É¤´¤Èºï½ü¤¹¤ë¾ì¹ç¤Ï¡¢$delete¤òtrue¤Ë¤¹¤ë¡£ |
| 693 | $objQuery = new SC_Query(); |
| 694 | $objQuery->begin(); |
| 695 | |
| 696 | // 自身のランクを取得する |
| 697 | $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId)); |
| 698 | $max = $objQuery->max($tableName, "rank", $where); |
| 699 | |
| 700 | // 値の調整(逆順) |
| 701 | if($pos > $max) { |
| 702 | $position = 1; |
| 703 | } else if($pos < 1) { |
| 704 | $position = $max; |
| 705 | } else { |
| 706 | $position = $max - $pos + 1; |
| 707 | } |
| 708 | |
| 709 | if( $position > $rank ) $term = "rank - 1"; //入れ替え先の順位が入れ換え元の順位より大きい場合 |
| 710 | if( $position < $rank ) $term = "rank + 1"; //入れ替え先の順位が入れ換え元の順位より小さい場合 |
| 711 | |
| 712 | //-- 指定した順位の商品から移動させる商品までのrankを1つずらす |
| 713 | $sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0"; |
| 714 | if($where != "") { |
| 715 | $sql.= " AND $where"; |
| 716 | } |
| 717 | |
| 718 | if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position )); |
| 719 | if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 )); |
| 720 | |
| 721 | //-- 指定した順位へrankを書き換える。 |
| 722 | $sql = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 "; |
| 723 | if($where != "") { |
| 724 | $sql.= " AND $where"; |
| 725 | } |
| 726 | |
| 727 | $objQuery->exec( $sql, array( $position, $keyId ) ); |
| 728 | $objQuery->commit(); |
| 729 | } |
| 730 | |
| 731 | // ランクを含むレコードの削除 |
| 732 | // レコードごと削除する場合は、$deleteをtrueにする。 |
734 | | $objQuery = new SC_Query(); |
735 | | $objQuery->begin(); |
736 | | // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
737 | | $where = "$colname = ?"; |
738 | | if($andwhere != "") { |
739 | | $where.= " AND $andwhere"; |
740 | | } |
741 | | $rank = $objQuery->get($table, "rank", $where, array($id)); |
742 | | |
743 | | if(!$delete) { |
744 | | // ¥é¥ó¥¯¤òºÇ²¼°Ì¤Ë¤¹¤ë¡¢DEL¥Õ¥é¥°ON |
745 | | $sqlup = "UPDATE $table SET rank = 0, del_flg = 1, update_date = Now() "; |
746 | | $sqlup.= "WHERE $colname = ?"; |
747 | | // UPDATE¤Î¼Â¹Ô |
748 | | $objQuery->exec($sqlup, array($id)); |
749 | | } else { |
750 | | $objQuery->delete($table, "$colname = ?", array($id)); |
751 | | } |
752 | | |
753 | | // Äɲå쥳¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä¤º¤é¤¹¡£ |
754 | | $where = "rank > ?"; |
755 | | if($andwhere != "") { |
756 | | $where.= " AND $andwhere"; |
757 | | } |
758 | | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
759 | | $objQuery->exec($sqlup, array($rank)); |
760 | | $objQuery->commit(); |
761 | | } |
762 | | |
763 | | // ¥ì¥³¡¼¥É¤Î¸ºß¥Á¥§¥Ã¥¯ |
| 734 | $objQuery = new SC_Query(); |
| 735 | $objQuery->begin(); |
| 736 | // 削除レコードのランクを取得する。 |
| 737 | $where = "$colname = ?"; |
| 738 | if($andwhere != "") { |
| 739 | $where.= " AND $andwhere"; |
| 740 | } |
| 741 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
| 742 | |
| 743 | if(!$delete) { |
| 744 | // ランクを最下位にする、DELフラグON |
| 745 | $sqlup = "UPDATE $table SET rank = 0, del_flg = 1, update_date = Now() "; |
| 746 | $sqlup.= "WHERE $colname = ?"; |
| 747 | // UPDATEの実行 |
| 748 | $objQuery->exec($sqlup, array($id)); |
| 749 | } else { |
| 750 | $objQuery->delete($table, "$colname = ?", array($id)); |
| 751 | } |
| 752 | |
| 753 | // 追加レコードのランクより上のレコードを一つずらす。 |
| 754 | $where = "rank > ?"; |
| 755 | if($andwhere != "") { |
| 756 | $where.= " AND $andwhere"; |
| 757 | } |
| 758 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
| 759 | $objQuery->exec($sqlup, array($rank)); |
| 760 | $objQuery->commit(); |
| 761 | } |
| 762 | |
| 763 | // レコードの存在チェック |
1015 | | // ´ü´Ö»ØÄê |
1016 | | $error = 0; |
1017 | | if ( $start_month || $start_day || $start_year){ |
1018 | | if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1; |
1019 | | } else { |
1020 | | $error = 1; |
1021 | | } |
1022 | | if ( $end_month || $end_day || $end_year){ |
1023 | | if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2; |
1024 | | } |
1025 | | if ( ! $error ){ |
1026 | | $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000"; |
1027 | | $date2 = $end_year ."/".sprintf("%02d",$end_month) ."/".sprintf("%02d",$end_day) ." 235959"; |
1028 | | if ($date1 > $date2) $error = 3; |
1029 | | } else { |
1030 | | $error = 1; |
1031 | | } |
1032 | | return array($date1, $date2, $error); |
1033 | | } |
1034 | | |
1035 | | // ¥¨¥é¡¼²Õ½ê¤ÎÇØ·Ê¿§¤òÊѹ¹¤¹¤ë¤¿¤á¤Îfunction SC_View¤ÇÆÉ¤ß¹þ¤à |
| 1015 | // 期間指定 |
| 1016 | $error = 0; |
| 1017 | if ( $start_month || $start_day || $start_year){ |
| 1018 | if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1; |
| 1019 | } else { |
| 1020 | $error = 1; |
| 1021 | } |
| 1022 | if ( $end_month || $end_day || $end_year){ |
| 1023 | if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2; |
| 1024 | } |
| 1025 | if ( ! $error ){ |
| 1026 | $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000"; |
| 1027 | $date2 = $end_year ."/".sprintf("%02d",$end_month) ."/".sprintf("%02d",$end_day) ." 235959"; |
| 1028 | if ($date1 > $date2) $error = 3; |
| 1029 | } else { |
| 1030 | $error = 1; |
| 1031 | } |
| 1032 | return array($date1, $date2, $error); |
| 1033 | } |
| 1034 | |
| 1035 | // エラー箇所の背景色を変更するためのfunction SC_Viewで読み込む |
1067 | | $objQuery = new SC_Query(); |
1068 | | $where = "del_flg = 0"; |
1069 | | |
1070 | | if($addwhere != "") { |
1071 | | $where.= " AND $addwhere"; |
1072 | | } |
1073 | | |
1074 | | $objQuery->setoption("ORDER BY rank DESC"); |
1075 | | |
1076 | | if($products_check) { |
1077 | | $col = "T1.category_id, category_name, level"; |
1078 | | $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; |
1079 | | $where .= " AND product_count > 0"; |
1080 | | } else { |
1081 | | $col = "category_id, category_name, level"; |
1082 | | $from = "dtb_category"; |
1083 | | } |
1084 | | |
1085 | | $arrRet = $objQuery->select($col, $from, $where); |
1086 | | |
1087 | | $max = count($arrRet); |
1088 | | for($cnt = 0; $cnt < $max; $cnt++) { |
1089 | | $id = $arrRet[$cnt]['category_id']; |
1090 | | $name = $arrRet[$cnt]['category_name']; |
1091 | | $arrList[$id] = ""; |
1092 | | /* |
1093 | | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
1094 | | $arrList[$id].= "¡¡"; |
1095 | | } |
1096 | | */ |
1097 | | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
1098 | | $arrList[$id].= $head; |
1099 | | } |
1100 | | $arrList[$id].= $name; |
1101 | | } |
1102 | | return $arrList; |
1103 | | } |
1104 | | |
1105 | | // ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ¡Ê¿Æ¥«¥Æ¥´¥ê¤ÎValue:0) |
| 1067 | $objQuery = new SC_Query(); |
| 1068 | $where = "del_flg = 0"; |
| 1069 | |
| 1070 | if($addwhere != "") { |
| 1071 | $where.= " AND $addwhere"; |
| 1072 | } |
| 1073 | |
| 1074 | $objQuery->setoption("ORDER BY rank DESC"); |
| 1075 | |
| 1076 | if($products_check) { |
| 1077 | $col = "T1.category_id, category_name, level"; |
| 1078 | $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; |
| 1079 | $where .= " AND product_count > 0"; |
| 1080 | } else { |
| 1081 | $col = "category_id, category_name, level"; |
| 1082 | $from = "dtb_category"; |
| 1083 | } |
| 1084 | |
| 1085 | $arrRet = $objQuery->select($col, $from, $where); |
| 1086 | |
| 1087 | $max = count($arrRet); |
| 1088 | for($cnt = 0; $cnt < $max; $cnt++) { |
| 1089 | $id = $arrRet[$cnt]['category_id']; |
| 1090 | $name = $arrRet[$cnt]['category_name']; |
| 1091 | $arrList[$id] = ""; |
| 1092 | /* |
| 1093 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
| 1094 | $arrList[$id].= " "; |
| 1095 | } |
| 1096 | */ |
| 1097 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
| 1098 | $arrList[$id].= $head; |
| 1099 | } |
| 1100 | $arrList[$id].= $name; |
| 1101 | } |
| 1102 | return $arrList; |
| 1103 | } |
| 1104 | |
| 1105 | // カテゴリツリーの取得(親カテゴリのValue:0) |
1107 | | $objQuery = new SC_Query(); |
1108 | | $col = "category_id, category_name, level"; |
1109 | | $where = "del_flg = 0"; |
1110 | | $objQuery->setoption("ORDER BY rank DESC"); |
1111 | | $arrRet = $objQuery->select($col, "dtb_category", $where); |
1112 | | $max = count($arrRet); |
1113 | | |
1114 | | for($cnt = 0; $cnt < $max; $cnt++) { |
1115 | | if($parent_zero) { |
1116 | | if($arrRet[$cnt]['level'] == LEVEL_MAX) { |
1117 | | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
1118 | | } else { |
1119 | | $arrValue[$cnt] = ""; |
1120 | | } |
1121 | | } else { |
1122 | | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
1123 | | } |
1124 | | |
1125 | | $arrOutput[$cnt] = ""; |
1126 | | /* |
1127 | | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
1128 | | $arrOutput[$cnt].= "¡¡"; |
1129 | | } |
1130 | | */ |
1131 | | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
1132 | | $arrOutput[$cnt].= CATEGORY_HEAD; |
1133 | | } |
1134 | | $arrOutput[$cnt].= $arrRet[$cnt]['category_name']; |
1135 | | } |
1136 | | return array($arrValue, $arrOutput); |
| 1107 | $objQuery = new SC_Query(); |
| 1108 | $col = "category_id, category_name, level"; |
| 1109 | $where = "del_flg = 0"; |
| 1110 | $objQuery->setoption("ORDER BY rank DESC"); |
| 1111 | $arrRet = $objQuery->select($col, "dtb_category", $where); |
| 1112 | $max = count($arrRet); |
| 1113 | |
| 1114 | for($cnt = 0; $cnt < $max; $cnt++) { |
| 1115 | if($parent_zero) { |
| 1116 | if($arrRet[$cnt]['level'] == LEVEL_MAX) { |
| 1117 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
| 1118 | } else { |
| 1119 | $arrValue[$cnt] = ""; |
| 1120 | } |
| 1121 | } else { |
| 1122 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
| 1123 | } |
| 1124 | |
| 1125 | $arrOutput[$cnt] = ""; |
| 1126 | /* |
| 1127 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
| 1128 | $arrOutput[$cnt].= " "; |
| 1129 | } |
| 1130 | */ |
| 1131 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
| 1132 | $arrOutput[$cnt].= CATEGORY_HEAD; |
| 1133 | } |
| 1134 | $arrOutput[$cnt].= $arrRet[$cnt]['category_name']; |
| 1135 | } |
| 1136 | return array($arrValue, $arrOutput); |
1219 | | if ($old_catid == $new_catid) { |
1220 | | return; |
1221 | | } |
1222 | | // µì¥«¥Æ¥´¥ê¤Ç¤Î¥é¥ó¥¯ºï½ü½èÍý |
1223 | | // °Üư¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
1224 | | $where = "$id_name = ?"; |
1225 | | $rank = $objQuery->get($table, "rank", $where, array($id)); |
1226 | | // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä²¼¤Ë¤º¤é¤¹¡£ |
1227 | | $where = "rank > ? AND $cat_name = ?"; |
1228 | | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
1229 | | $objQuery->exec($sqlup, array($rank, $old_catid)); |
1230 | | // ¿·¥«¥Æ¥´¥ê¤Ç¤ÎÅÐÏ¿½èÍý |
1231 | | // ¿·¥«¥Æ¥´¥ê¤ÎºÇÂç¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
1232 | | $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1; |
1233 | | $where = "$id_name = ?"; |
1234 | | $sqlup = "UPDATE $table SET rank = ? WHERE $where"; |
1235 | | $objQuery->exec($sqlup, array($max_rank, $id)); |
1236 | | } |
1237 | | |
1238 | | /* ÀǶâ·×»» */ |
| 1219 | if ($old_catid == $new_catid) { |
| 1220 | return; |
| 1221 | } |
| 1222 | // 旧カテゴリでのランク削除処理 |
| 1223 | // 移動レコードのランクを取得する。 |
| 1224 | $where = "$id_name = ?"; |
| 1225 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
| 1226 | // 削除レコードのランクより上のレコードを一つ下にずらす。 |
| 1227 | $where = "rank > ? AND $cat_name = ?"; |
| 1228 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
| 1229 | $objQuery->exec($sqlup, array($rank, $old_catid)); |
| 1230 | // 新カテゴリでの登録処理 |
| 1231 | // 新カテゴリの最大ランクを取得する。 |
| 1232 | $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1; |
| 1233 | $where = "$id_name = ?"; |
| 1234 | $sqlup = "UPDATE $table SET rank = ? WHERE $where"; |
| 1235 | $objQuery->exec($sqlup, array($max_rank, $id)); |
| 1236 | } |
| 1237 | |
| 1238 | /* 税金計算 */ |
1305 | | if(sfIsInt($product_id)) { |
1306 | | $objQuery = new SC_Query(); |
1307 | | $where = "now() >= cast(start_date as date) AND "; |
1308 | | $where .= "now() < cast(end_date as date) AND "; |
1309 | | |
1310 | | $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )"; |
1311 | | //ÅÐÏ¿(¹¹¿·)ÆüÉÕ½ç |
1312 | | $objQuery->setorder('update_date DESC'); |
1313 | | //¥¥ã¥ó¥Ú¡¼¥ó¥Ý¥¤¥ó¥È¤Î¼èÆÀ |
1314 | | $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id)); |
1315 | | } |
1316 | | //Ê£¿ô¤Î¥¥ã¥ó¥Ú¡¼¥ó¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾¦Éʤϡ¢ºÇ¿·¤Î¥¥ã¥ó¥Ú¡¼¥ó¤«¤é¥Ý¥¤¥ó¥È¤ò¼èÆÀ |
1317 | | if($arrRet[0]['campaign_point_rate'] != "") { |
1318 | | $campaign_point_rate = $arrRet[0]['campaign_point_rate']; |
1319 | | $real_point = $campaign_point_rate / 100; |
1320 | | } else { |
1321 | | $real_point = $point_rate / 100; |
1322 | | } |
1323 | | $ret = $price * $real_point; |
1324 | | switch($rule) { |
1325 | | // »Í¼Î¸ÞÆþ |
1326 | | case 1: |
1327 | | $ret = round($ret); |
1328 | | break; |
1329 | | // ÀÚ¤ê¼Î¤Æ |
1330 | | case 2: |
1331 | | $ret = floor($ret); |
1332 | | break; |
1333 | | // ÀÚ¤ê¾å¤² |
1334 | | case 3: |
1335 | | $ret = ceil($ret); |
1336 | | break; |
1337 | | // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤² |
1338 | | default: |
1339 | | $ret = ceil($ret); |
1340 | | break; |
1341 | | } |
1342 | | //¥¥ã¥ó¥Ú¡¼¥ó¾¦Éʤξì¹ç |
1343 | | if($campaign_point_rate != "") { |
1344 | | $ret = "(".$arrRet[0]['campaign_name']."¥Ý¥¤¥ó¥ÈΨ".$campaign_point_rate."%)".$ret; |
1345 | | } |
1346 | | return $ret; |
1347 | | } |
1348 | | |
1349 | | /* µ¬³ÊʬÎà¤Î·ï¿ô¼èÆÀ */ |
| 1305 | if(sfIsInt($product_id)) { |
| 1306 | $objQuery = new SC_Query(); |
| 1307 | $where = "now() >= cast(start_date as date) AND "; |
| 1308 | $where .= "now() < cast(end_date as date) AND "; |
| 1309 | |
| 1310 | $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )"; |
| 1311 | //登録(更新)日付順 |
| 1312 | $objQuery->setorder('update_date DESC'); |
| 1313 | //キャンペーンポイントの取得 |
| 1314 | $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id)); |
| 1315 | } |
| 1316 | //複数のキャンペーンに登録されている商品は、最新のキャンペーンからポイントを取得 |
| 1317 | if($arrRet[0]['campaign_point_rate'] != "") { |
| 1318 | $campaign_point_rate = $arrRet[0]['campaign_point_rate']; |
| 1319 | $real_point = $campaign_point_rate / 100; |
| 1320 | } else { |
| 1321 | $real_point = $point_rate / 100; |
| 1322 | } |
| 1323 | $ret = $price * $real_point; |
| 1324 | switch($rule) { |
| 1325 | // 四捨五入 |
| 1326 | case 1: |
| 1327 | $ret = round($ret); |
| 1328 | break; |
| 1329 | // 切り捨て |
| 1330 | case 2: |
| 1331 | $ret = floor($ret); |
| 1332 | break; |
| 1333 | // 切り上げ |
| 1334 | case 3: |
| 1335 | $ret = ceil($ret); |
| 1336 | break; |
| 1337 | // デフォルト:切り上げ |
| 1338 | default: |
| 1339 | $ret = ceil($ret); |
| 1340 | break; |
| 1341 | } |
| 1342 | //キャンペーン商品の場合 |
| 1343 | if($campaign_point_rate != "") { |
| 1344 | $ret = "(".$arrRet[0]['campaign_name']."ポイント率".$campaign_point_rate."%)".$ret; |
| 1345 | } |
| 1346 | return $ret; |
| 1347 | } |
| 1348 | |
| 1349 | /* 規格分類の件数取得 */ |
1365 | | // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£ |
1366 | | $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0"; |
1367 | | $count = $objQuery->count("dtb_products_class", $where, array($product_id)); |
1368 | | |
1369 | | // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤Ê¤¤¾ì¹ç |
1370 | | if($count == 0) { |
1371 | | // ´û¸µ¬³Ê¤Îºï½ü |
1372 | | $where = "product_id = ?"; |
1373 | | $objQuery->delete("dtb_products_class", $where, array($product_id)); |
1374 | | $sqlval['product_id'] = $product_id; |
1375 | | $sqlval['classcategory_id1'] = '0'; |
1376 | | $sqlval['classcategory_id2'] = '0'; |
1377 | | $sqlval['product_code'] = $arrList["product_code"]; |
1378 | | $sqlval['stock'] = $arrList["stock"]; |
1379 | | $sqlval['stock_unlimited'] = $arrList["stock_unlimited"]; |
1380 | | $sqlval['price01'] = $arrList['price01']; |
1381 | | $sqlval['price02'] = $arrList['price02']; |
1382 | | $sqlval['creator_id'] = $_SESSION['member_id']; |
1383 | | $sqlval['create_date'] = "now()"; |
1384 | | |
1385 | | if($_SESSION['member_id'] == "") { |
1386 | | $sqlval['creator_id'] = '0'; |
1387 | | } |
1388 | | |
1389 | | // INSERT¤Î¼Â¹Ô |
1390 | | $objQuery->insert("dtb_products_class", $sqlval); |
1391 | | } |
| 1365 | // すでに規格登録があるかどうかをチェックする。 |
| 1366 | $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0"; |
| 1367 | $count = $objQuery->count("dtb_products_class", $where, array($product_id)); |
| 1368 | |
| 1369 | // すでに規格登録がない場合 |
| 1370 | if($count == 0) { |
| 1371 | // 既存規格の削除 |
| 1372 | $where = "product_id = ?"; |
| 1373 | $objQuery->delete("dtb_products_class", $where, array($product_id)); |
| 1374 | $sqlval['product_id'] = $product_id; |
| 1375 | $sqlval['classcategory_id1'] = '0'; |
| 1376 | $sqlval['classcategory_id2'] = '0'; |
| 1377 | $sqlval['product_code'] = $arrList["product_code"]; |
| 1378 | $sqlval['stock'] = $arrList["stock"]; |
| 1379 | $sqlval['stock_unlimited'] = $arrList["stock_unlimited"]; |
| 1380 | $sqlval['price01'] = $arrList['price01']; |
| 1381 | $sqlval['price02'] = $arrList['price02']; |
| 1382 | $sqlval['creator_id'] = $_SESSION['member_id']; |
| 1383 | $sqlval['create_date'] = "now()"; |
| 1384 | |
| 1385 | if($_SESSION['member_id'] == "") { |
| 1386 | $sqlval['creator_id'] = '0'; |
| 1387 | } |
| 1388 | |
| 1389 | // INSERTの実行 |
| 1390 | $objQuery->insert("dtb_products_class", $sqlval); |
| 1391 | } |
1409 | | list($product_id, $classcategory_id1, $classcategory_id2) = $arrID; |
1410 | | |
1411 | | if($classcategory_id1 == "") { |
1412 | | $classcategory_id1 = '0'; |
1413 | | } |
1414 | | if($classcategory_id2 == "") { |
1415 | | $classcategory_id2 = '0'; |
1416 | | } |
1417 | | |
1418 | | // ¾¦Éʵ¬³Ê¼èÆÀ |
1419 | | $objQuery = new SC_Query(); |
1420 | | $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited"; |
1421 | | $table = "vw_product_class AS prdcls"; |
1422 | | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
1423 | | $objQuery->setorder("rank1 DESC, rank2 DESC"); |
1424 | | $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2)); |
1425 | | return $arrRet[0]; |
1426 | | } |
1427 | | |
1428 | | /* ½¸·×¾ðÊó¤ò¸µ¤ËºÇ½ª·×»» */ |
| 1409 | list($product_id, $classcategory_id1, $classcategory_id2) = $arrID; |
| 1410 | |
| 1411 | if($classcategory_id1 == "") { |
| 1412 | $classcategory_id1 = '0'; |
| 1413 | } |
| 1414 | if($classcategory_id2 == "") { |
| 1415 | $classcategory_id2 = '0'; |
| 1416 | } |
| 1417 | |
| 1418 | // 商品規格取得 |
| 1419 | $objQuery = new SC_Query(); |
| 1420 | $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited"; |
| 1421 | $table = "vw_product_class AS prdcls"; |
| 1422 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
| 1423 | $objQuery->setorder("rank1 DESC, rank2 DESC"); |
| 1424 | $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2)); |
| 1425 | return $arrRet[0]; |
| 1426 | } |
| 1427 | |
| 1428 | /* 集計情報を元に最終計算 */ |
1430 | | // ¾¦Éʤιç·×¸Ä¿ô |
1431 | | $total_quantity = $objCartSess->getTotalQuantity(true); |
1432 | | |
1433 | | // ÀǶâ¤Î¼èÆÀ |
1434 | | $arrData['tax'] = $objPage->tpl_total_tax; |
1435 | | // ¾®·×¤Î¼èÆÀ |
1436 | | $arrData['subtotal'] = $objPage->tpl_total_pretax; |
1437 | | |
1438 | | // ¹ç·×Á÷ÎÁ¤Î¼èÆÀ |
1439 | | $arrData['deliv_fee'] = 0; |
1440 | | |
1441 | | // ¾¦Éʤ´¤È¤ÎÁ÷ÎÁ¤¬Í¸ú¤Î¾ì¹ç |
1442 | | if (OPTION_PRODUCT_DELIV_FEE == 1) { |
1443 | | $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee(); |
1444 | | } |
1445 | | |
1446 | | // ÇÛÁ÷¶È¼Ô¤ÎÁ÷ÎÁ¤¬Í¸ú¤Î¾ì¹ç |
1447 | | if (OPTION_DELIV_FEE == 1) { |
1448 | | // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë |
1449 | | $arrData['deliv_fee']+= sfGetDelivFee($arrData['deliv_pref'], $arrData['payment_id']); |
1450 | | } |
1451 | | |
1452 | | // Á÷ÎÁ̵ÎÁ¤Î¹ØÆþ¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç |
1453 | | if(DELIV_FREE_AMOUNT > 0) { |
1454 | | if($total_quantity >= DELIV_FREE_AMOUNT) { |
1455 | | $arrData['deliv_fee'] = 0; |
1456 | | } |
1457 | | } |
1458 | | |
1459 | | // Á÷ÎÁ̵ÎÁ¾ò·ï¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç |
1460 | | if($arrInfo['free_rule'] > 0) { |
1461 | | // ¾®·×¤¬ÌµÎÁ¾ò·ï¤òͤ¨¤Æ¤¤¤ë¾ì¹ç |
1462 | | if($arrData['subtotal'] >= $arrInfo['free_rule']) { |
1463 | | $arrData['deliv_fee'] = 0; |
1464 | | } |
1465 | | } |
1466 | | |
1467 | | // ¹ç·×¤Î·×»» |
1468 | | $arrData['total'] = $objPage->tpl_total_pretax; // ¾¦Éʹç·× |
1469 | | $arrData['total']+= $arrData['deliv_fee']; // Á÷ÎÁ |
1470 | | $arrData['total']+= $arrData['charge']; // ¼ê¿ôÎÁ |
1471 | | // ¤ª»Ùʧ¤¤¹ç·× |
1472 | | $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE); |
1473 | | // ²Ã»»¥Ý¥¤¥ó¥È¤Î·×»» |
1474 | | $arrData['add_point'] = sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo); |
1475 | | |
1476 | | if($objCustomer != "") { |
1477 | | // ÃÂÀ¸Æü·î¤Ç¤¢¤Ã¤¿¾ì¹ç |
1478 | | if($objCustomer->isBirthMonth()) { |
1479 | | $arrData['birth_point'] = BIRTH_MONTH_POINT; |
1480 | | $arrData['add_point'] += $arrData['birth_point']; |
1481 | | } |
1482 | | } |
1483 | | |
1484 | | if($arrData['add_point'] < 0) { |
1485 | | $arrData['add_point'] = 0; |
1486 | | } |
1487 | | |
1488 | | return $arrData; |
1489 | | } |
1490 | | |
1491 | | /* ¥«¡¼¥ÈÆâ¾¦Éʤν¸·×½èÍý */ |
| 1430 | // 商品の合計個数 |
| 1431 | $total_quantity = $objCartSess->getTotalQuantity(true); |
| 1432 | |
| 1433 | // 税金の取得 |
| 1434 | $arrData['tax'] = $objPage->tpl_total_tax; |
| 1435 | // 小計の取得 |
| 1436 | $arrData['subtotal'] = $objPage->tpl_total_pretax; |
| 1437 | |
| 1438 | // 合計送料の取得 |
| 1439 | $arrData['deliv_fee'] = 0; |
| 1440 | |
| 1441 | // 商品ごとの送料が有効の場合 |
| 1442 | if (OPTION_PRODUCT_DELIV_FEE == 1) { |
| 1443 | $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee(); |
| 1444 | } |
| 1445 | |
| 1446 | // 配送業者の送料が有効の場合 |
| 1447 | if (OPTION_DELIV_FEE == 1) { |
| 1448 | // 送料の合計を計算する |
| 1449 | $arrData['deliv_fee']+= sfGetDelivFee($arrData['deliv_pref'], $arrData['payment_id']); |
| 1450 | } |
| 1451 | |
| 1452 | // 送料無料の購入数が設定されている場合 |
| 1453 | if(DELIV_FREE_AMOUNT > 0) { |
| 1454 | if($total_quantity >= DELIV_FREE_AMOUNT) { |
| 1455 | $arrData['deliv_fee'] = 0; |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | // 送料無料条件が設定されている場合 |
| 1460 | if($arrInfo['free_rule'] > 0) { |
| 1461 | // 小計が無料条件を超えている場合 |
| 1462 | if($arrData['subtotal'] >= $arrInfo['free_rule']) { |
| 1463 | $arrData['deliv_fee'] = 0; |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | // 合計の計算 |
| 1468 | $arrData['total'] = $objPage->tpl_total_pretax; // 商品合計 |
| 1469 | $arrData['total']+= $arrData['deliv_fee']; // 送料 |
| 1470 | $arrData['total']+= $arrData['charge']; // 手数料 |
| 1471 | // お支払い合計 |
| 1472 | $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE); |
| 1473 | // 加算ポイントの計算 |
| 1474 | $arrData['add_point'] = sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo); |
| 1475 | |
| 1476 | if($objCustomer != "") { |
| 1477 | // 誕生日月であった場合 |
| 1478 | if($objCustomer->isBirthMonth()) { |
| 1479 | $arrData['birth_point'] = BIRTH_MONTH_POINT; |
| 1480 | $arrData['add_point'] += $arrData['birth_point']; |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | if($arrData['add_point'] < 0) { |
| 1485 | $arrData['add_point'] = 0; |
| 1486 | } |
| 1487 | |
| 1488 | return $arrData; |
| 1489 | } |
| 1490 | |
| 1491 | /* カート内商品の集計処理 */ |
1493 | | // µ¬³Ê̾°ìÍ÷ |
1494 | | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); |
1495 | | // µ¬³ÊʬÎà̾°ìÍ÷ |
1496 | | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
1497 | | |
1498 | | $objPage->tpl_total_pretax = 0; // ÈñÍѹç·×(Àǹþ¤ß) |
1499 | | $objPage->tpl_total_tax = 0; // ¾ÃÈñÀǹç·× |
1500 | | $objPage->tpl_total_point = 0; // ¥Ý¥¤¥ó¥È¹ç·× |
1501 | | |
1502 | | // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ |
1503 | | $arrCart = $objCartSess->getCartList(); |
1504 | | $max = count($arrCart); |
1505 | | $cnt = 0; |
1506 | | |
1507 | | for ($i = 0; $i < $max; $i++) { |
1508 | | // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ |
1509 | | $arrData = sfGetProductsClass($arrCart[$i]['id']); |
1510 | | $limit = ""; |
1511 | | // DB¤Ë¸ºß¤¹¤ë¾¦ÉÊ |
1512 | | if (count($arrData) > 0) { |
1513 | | |
1514 | | // ¹ØÆþÀ©¸Â¿ô¤òµá¤á¤ë¡£ |
1515 | | if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') { |
1516 | | if($arrData['sale_limit'] < $arrData['stock']) { |
1517 | | $limit = $arrData['sale_limit']; |
1518 | | } else { |
1519 | | $limit = $arrData['stock']; |
1520 | | } |
1521 | | } else { |
1522 | | if ($arrData['sale_unlimited'] != '1') { |
1523 | | $limit = $arrData['sale_limit']; |
1524 | | } |
1525 | | if ($arrData['stock_unlimited'] != '1') { |
1526 | | $limit = $arrData['stock']; |
1527 | | } |
1528 | | } |
1529 | | |
1530 | | if($limit != "" && $limit < $arrCart[$i]['quantity']) { |
1531 | | // ¥«¡¼¥ÈÆâ¾¦ÉÊ¿ô¤òÀ©¸Â¤Ë¹ç¤ï¤»¤ë |
1532 | | $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit); |
1533 | | $quantity = $limit; |
1534 | | $objPage->tpl_message = "¢¨¡Ö" . $arrData['name'] . "¡×¤ÏÈÎÇäÀ©¸Â¤·¤Æ¤ª¤ê¤Þ¤¹¡¢°ìÅ٤ˤ³¤ì°Ê¾å¤Î¹ØÆþ¤Ï¤Ç¤¤Þ¤»¤ó¡£"; |
1535 | | } else { |
1536 | | $quantity = $arrCart[$i]['quantity']; |
1537 | | } |
1538 | | |
1539 | | $objPage->arrProductsClass[$cnt] = $arrData; |
1540 | | $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; |
1541 | | $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no']; |
1542 | | $objPage->arrProductsClass[$cnt]['class_name1'] = $arrClassName[$arrData['class_id1']]; |
1543 | | $objPage->arrProductsClass[$cnt]['class_name2'] = $arrClassName[$arrData['class_id2']]; |
1544 | | $objPage->arrProductsClass[$cnt]['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']]; |
1545 | | $objPage->arrProductsClass[$cnt]['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']]; |
1546 | | |
1547 | | // ²èÁü¥µ¥¤¥º |
1548 | | list($image_width, $image_height) = getimagesize(IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"])); |
1549 | | $objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60; |
1550 | | $objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80; |
1551 | | |
1552 | | // ²Á³Ê¤ÎÅÐÏ¿ |
1553 | | if ($arrData['price02'] != "") { |
1554 | | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']); |
1555 | | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02']; |
1556 | | } else { |
1557 | | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']); |
1558 | | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01']; |
1559 | | } |
1560 | | // ¥Ý¥¤¥ó¥ÈÉÕͿΨ¤ÎÅÐÏ¿ |
1561 | | $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']); |
1562 | | // ¾¦Éʤ´¤È¤Î¹ç·×¶â³Û |
1563 | | $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']); |
1564 | | // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë |
1565 | | $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']); |
1566 | | $cnt++; |
1567 | | } else { |
1568 | | // DB¤Ë¾¦Éʤ¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï¥«¡¼¥È¾¦Éʤκï½ü |
1569 | | $objCartSess->delProductKey('id', $arrCart[$i]['id']); |
1570 | | } |
1571 | | } |
1572 | | |
1573 | | // Á´¾¦Éʹç·×¶â³Û(Àǹþ¤ß) |
1574 | | $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo); |
1575 | | // Á´¾¦Éʹç·×¾ÃÈñÀÇ |
1576 | | $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo); |
1577 | | // Á´¾¦Éʹç·×¥Ý¥¤¥ó¥È |
1578 | | $objPage->tpl_total_point = $objCartSess->getAllProductsPoint(); |
1579 | | |
1580 | | return $objPage; |
1581 | | } |
1582 | | |
1583 | | /* DB¤«¤é¼è¤ê½Ð¤·¤¿ÆüÉÕ¤Îʸ»úÎó¤òÄ´À°¤¹¤ë¡£*/ |
| 1493 | // 規格名一覧 |
| 1494 | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); |
| 1495 | // 規格分類名一覧 |
| 1496 | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
| 1497 | |
| 1498 | $objPage->tpl_total_pretax = 0; // 費用合計(税込み) |
| 1499 | $objPage->tpl_total_tax = 0; // 消費税合計 |
| 1500 | $objPage->tpl_total_point = 0; // ポイント合計 |
| 1501 | |
| 1502 | // カート内情報の取得 |
| 1503 | $arrCart = $objCartSess->getCartList(); |
| 1504 | $max = count($arrCart); |
| 1505 | $cnt = 0; |
| 1506 | |
| 1507 | for ($i = 0; $i < $max; $i++) { |
| 1508 | // 商品規格情報の取得 |
| 1509 | $arrData = sfGetProductsClass($arrCart[$i]['id']); |
| 1510 | $limit = ""; |
| 1511 | // DBに存在する商品 |
| 1512 | if (count($arrData) > 0) { |
| 1513 | |
| 1514 | // 購入制限数を求める。 |
| 1515 | if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') { |
| 1516 | if($arrData['sale_limit'] < $arrData['stock']) { |
| 1517 | $limit = $arrData['sale_limit']; |
| 1518 | } else { |
| 1519 | $limit = $arrData['stock']; |
| 1520 | } |
| 1521 | } else { |
| 1522 | if ($arrData['sale_unlimited'] != '1') { |
| 1523 | $limit = $arrData['sale_limit']; |
| 1524 | } |
| 1525 | if ($arrData['stock_unlimited'] != '1') { |
| 1526 | $limit = $arrData['stock']; |
| 1527 | } |
| 1528 | } |
| 1529 | |
| 1530 | if($limit != "" && $limit < $arrCart[$i]['quantity']) { |
| 1531 | // カート内商品数を制限に合わせる |
| 1532 | $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit); |
| 1533 | $quantity = $limit; |
| 1534 | $objPage->tpl_message = "※「" . $arrData['name'] . "」は販売制限しております、一度にこれ以上の購入はできません。"; |
| 1535 | } else { |
| 1536 | $quantity = $arrCart[$i]['quantity']; |
| 1537 | } |
| 1538 | |
| 1539 | $objPage->arrProductsClass[$cnt] = $arrData; |
| 1540 | $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; |
| 1541 | $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no']; |
| 1542 | $objPage->arrProductsClass[$cnt]['class_name1'] = $arrClassName[$arrData['class_id1']]; |
| 1543 | $objPage->arrProductsClass[$cnt]['class_name2'] = $arrClassName[$arrData['class_id2']]; |
| 1544 | $objPage->arrProductsClass[$cnt]['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']]; |
| 1545 | $objPage->arrProductsClass[$cnt]['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']]; |
| 1546 | |
| 1547 | // 画像サイズ |
| 1548 | list($image_width, $image_height) = getimagesize(IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"])); |
| 1549 | $objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60; |
| 1550 | $objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80; |
| 1551 | |
| 1552 | // 価格の登録 |
| 1553 | if ($arrData['price02'] != "") { |
| 1554 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']); |
| 1555 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02']; |
| 1556 | } else { |
| 1557 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']); |
| 1558 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01']; |
| 1559 | } |
| 1560 | // ポイント付与率の登録 |
| 1561 | $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']); |
| 1562 | // 商品ごとの合計金額 |
| 1563 | $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']); |
| 1564 | // 送料の合計を計算する |
| 1565 | $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']); |
| 1566 | $cnt++; |
| 1567 | } else { |
| 1568 | // DBに商品が見つからない場合はカート商品の削除 |
| 1569 | $objCartSess->delProductKey('id', $arrCart[$i]['id']); |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | // 全商品合計金額(税込み) |
| 1574 | $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo); |
| 1575 | // 全商品合計消費税 |
| 1576 | $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo); |
| 1577 | // 全商品合計ポイント |
| 1578 | $objPage->tpl_total_point = $objCartSess->getAllProductsPoint(); |
| 1579 | |
| 1580 | return $objPage; |
| 1581 | } |
| 1582 | |
| 1583 | /* DBから取り出した日付の文字列を調整する。*/ |
1622 | | $objQuery = new SC_Query(); |
1623 | | |
1624 | | $deliv_id = ""; |
1625 | | |
1626 | | // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢Âбþ¤·¤¿ÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë |
1627 | | if($payment_id != "") { |
1628 | | $where = "del_flg = 0 AND payment_id = ?"; |
1629 | | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
1630 | | $deliv_id = $arrRet[0]['deliv_id']; |
1631 | | // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÀèÆ¬¤ÎÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë |
1632 | | } else { |
1633 | | $where = "del_flg = 0"; |
1634 | | $objQuery->setOrder("rank DESC"); |
1635 | | $objQuery->setLimitOffset(1); |
1636 | | $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where); |
1637 | | $deliv_id = $arrRet[0]['deliv_id']; |
1638 | | } |
1639 | | |
1640 | | // ÇÛÁ÷¶È¼Ô¤«¤éÇÛÁ÷ÎÁ¤ò¼èÆÀ |
1641 | | if($deliv_id != "") { |
1642 | | |
1643 | | // ÅÔÆ»Éܸ©¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÅìµþÅÔ¤ÎÈÖ¹æ¤ò»ØÄꤷ¤Æ¤ª¤¯ |
1644 | | if($pref == "") { |
1645 | | $pref = 13; |
1646 | | } |
1647 | | |
1648 | | $objQuery = new SC_Query(); |
1649 | | $where = "deliv_id = ? AND pref = ?"; |
1650 | | $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref)); |
1651 | | } |
1652 | | return $arrRet[0]['fee']; |
1653 | | } |
1654 | | |
1655 | | /* »Ùʧ¤¤ÊýË¡¤Î¼èÆÀ */ |
| 1622 | $objQuery = new SC_Query(); |
| 1623 | |
| 1624 | $deliv_id = ""; |
| 1625 | |
| 1626 | // 支払い方法が指定されている場合は、対応した配送業者を取得する |
| 1627 | if($payment_id != "") { |
| 1628 | $where = "del_flg = 0 AND payment_id = ?"; |
| 1629 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
| 1630 | $deliv_id = $arrRet[0]['deliv_id']; |
| 1631 | // 支払い方法が指定されていない場合は、先頭の配送業者を取得する |
| 1632 | } else { |
| 1633 | $where = "del_flg = 0"; |
| 1634 | $objQuery->setOrder("rank DESC"); |
| 1635 | $objQuery->setLimitOffset(1); |
| 1636 | $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where); |
| 1637 | $deliv_id = $arrRet[0]['deliv_id']; |
| 1638 | } |
| 1639 | |
| 1640 | // 配送業者から配送料を取得 |
| 1641 | if($deliv_id != "") { |
| 1642 | |
| 1643 | // 都道府県が指定されていない場合は、東京都の番号を指定しておく |
| 1644 | if($pref == "") { |
| 1645 | $pref = 13; |
| 1646 | } |
| 1647 | |
| 1648 | $objQuery = new SC_Query(); |
| 1649 | $where = "deliv_id = ? AND pref = ?"; |
| 1650 | $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref)); |
| 1651 | } |
| 1652 | return $arrRet[0]['fee']; |
| 1653 | } |
| 1654 | |
| 1655 | /* 支払い方法の取得 */ |
1683 | | global $arrMAILTPLPATH; |
1684 | | $objQuery = new SC_Query(); |
1685 | | // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ |
1686 | | $where = "template_id = ?"; |
1687 | | $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id)); |
1688 | | $objPage->tpl_header = $arrRet[0]['header']; |
1689 | | $objPage->tpl_footer = $arrRet[0]['footer']; |
1690 | | $tmp_subject = $arrRet[0]['subject']; |
1691 | | |
1692 | | $objSiteInfo = new SC_SiteInfo(); |
1693 | | $arrInfo = $objSiteInfo->data; |
1694 | | |
1695 | | $objMailView = new SC_SiteView(); |
1696 | | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
1697 | | $objMailView->assignobj($objPage); |
1698 | | $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]); |
1699 | | |
1700 | | // ¥á¡¼¥ëÁ÷¿®½èÍý |
1701 | | $objSendMail = new GC_SendMail(); |
1702 | | $from = $arrInfo['email03']; |
1703 | | $error = $arrInfo['email04']; |
1704 | | $tosubject = $tmp_subject; |
1705 | | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error); |
1706 | | $objSendMail->setTo($to, $to_name); |
1707 | | $objSendMail->sendMail(); // ¥á¡¼¥ëÁ÷¿® |
1708 | | } |
1709 | | |
1710 | | /* ¼õÃí´°Î»¥á¡¼¥ëÁ÷¿® */ |
| 1683 | global $arrMAILTPLPATH; |
| 1684 | $objQuery = new SC_Query(); |
| 1685 | // メールテンプレート情報の取得 |
| 1686 | $where = "template_id = ?"; |
| 1687 | $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id)); |
| 1688 | $objPage->tpl_header = $arrRet[0]['header']; |
| 1689 | $objPage->tpl_footer = $arrRet[0]['footer']; |
| 1690 | $tmp_subject = $arrRet[0]['subject']; |
| 1691 | |
| 1692 | $objSiteInfo = new SC_SiteInfo(); |
| 1693 | $arrInfo = $objSiteInfo->data; |
| 1694 | |
| 1695 | $objMailView = new SC_SiteView(); |
| 1696 | // メール本文の取得 |
| 1697 | $objMailView->assignobj($objPage); |
| 1698 | $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]); |
| 1699 | |
| 1700 | // メール送信処理 |
| 1701 | $objSendMail = new GC_SendMail(); |
| 1702 | $from = $arrInfo['email03']; |
| 1703 | $error = $arrInfo['email04']; |
| 1704 | $tosubject = $tmp_subject; |
| 1705 | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error); |
| 1706 | $objSendMail->setTo($to, $to_name); |
| 1707 | $objSendMail->sendMail(); // メール送信 |
| 1708 | } |
| 1709 | |
| 1710 | /* 受注完了メール送信 */ |
1712 | | global $arrMAILTPLPATH; |
1713 | | |
1714 | | $objPage = new LC_Page(); |
1715 | | $objSiteInfo = new SC_SiteInfo(); |
1716 | | $arrInfo = $objSiteInfo->data; |
1717 | | $objPage->arrInfo = $arrInfo; |
1718 | | |
1719 | | $objQuery = new SC_Query(); |
1720 | | |
1721 | | if($subject == "" && $header == "" && $footer == "") { |
1722 | | // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ |
1723 | | $where = "template_id = ?"; |
1724 | | $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array('1')); |
1725 | | $objPage->tpl_header = $arrRet[0]['header']; |
1726 | | $objPage->tpl_footer = $arrRet[0]['footer']; |
1727 | | $tmp_subject = $arrRet[0]['subject']; |
1728 | | } else { |
1729 | | $objPage->tpl_header = $header; |
1730 | | $objPage->tpl_footer = $footer; |
1731 | | $tmp_subject = $subject; |
1732 | | } |
1733 | | |
1734 | | // ¼õÃí¾ðÊó¤Î¼èÆÀ |
1735 | | $where = "order_id = ?"; |
1736 | | $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id)); |
1737 | | $arrOrder = $arrRet[0]; |
1738 | | $arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id)); |
1739 | | |
1740 | | $objPage->Message_tmp = $arrOrder['message']; |
1741 | | |
1742 | | // ¸ÜµÒ¾ðÊó¤Î¼èÆÀ |
1743 | | $customer_id = $arrOrder['customer_id']; |
1744 | | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
1745 | | $arrCustomer = $arrRet[0]; |
1746 | | |
1747 | | $objPage->arrCustomer = $arrCustomer; |
1748 | | $objPage->arrOrder = $arrOrder; |
1749 | | |
1750 | | //¤½¤Î¾·èºÑ¾ðÊó |
1751 | | if($arrOrder['memo02'] != "") { |
1752 | | $arrOther = unserialize($arrOrder['memo02']); |
1753 | | |
1754 | | foreach($arrOther as $other_key => $other_val){ |
1755 | | if(sfTrim($other_val["value"]) == ""){ |
1756 | | $arrOther[$other_key]["value"] = ""; |
1757 | | } |
1758 | | } |
1759 | | |
1760 | | $objPage->arrOther = $arrOther; |
1761 | | } |
1762 | | |
1763 | | // ÅÔÆ»Éܸ©ÊÑ´¹ |
1764 | | global $arrPref; |
1765 | | $objPage->arrOrder['deliv_pref'] = $arrPref[$objPage->arrOrder['deliv_pref']]; |
1766 | | |
1767 | | $objPage->arrOrderDetail = $arrOrderDetail; |
1768 | | |
1769 | | $objCustomer = new SC_Customer(); |
1770 | | $objPage->tpl_user_point = $objCustomer->getValue('point'); |
1771 | | |
1772 | | $objMailView = new SC_SiteView(); |
1773 | | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
1774 | | $objMailView->assignobj($objPage); |
1775 | | $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]); |
1776 | | |
1777 | | // ¥á¡¼¥ëÁ÷¿®½èÍý |
1778 | | $objSendMail = new GC_SendMail(); |
1779 | | $bcc = $arrInfo['email01']; |
1780 | | $from = $arrInfo['email03']; |
1781 | | $error = $arrInfo['email04']; |
1782 | | |
1783 | | $tosubject = sfMakeSubject($tmp_subject); |
1784 | | |
1785 | | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
1786 | | $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." ÍÍ"); |
1787 | | |
1788 | | |
1789 | | // Á÷¿®¥Õ¥é¥°:true¤Î¾ì¹ç¤Ï¡¢Á÷¿®¤¹¤ë¡£ |
1790 | | if($send) { |
1791 | | if ($objSendMail->sendMail()) { |
1792 | | sfSaveMailHistory($order_id, $template_id, $tosubject, $body); |
1793 | | } |
1794 | | } |
1795 | | |
1796 | | return $objSendMail; |
1797 | | } |
1798 | | |
1799 | | // ¥Æ¥ó¥×¥ì¡¼¥È¤ò»ÈÍѤ·¤¿¥á¡¼¥ë¤ÎÁ÷¿® |
| 1712 | global $arrMAILTPLPATH; |
| 1713 | |
| 1714 | $objPage = new LC_Page(); |
| 1715 | $objSiteInfo = new SC_SiteInfo(); |
| 1716 | $arrInfo = $objSiteInfo->data; |
| 1717 | $objPage->arrInfo = $arrInfo; |
| 1718 | |
| 1719 | $objQuery = new SC_Query(); |
| 1720 | |
| 1721 | if($subject == "" && $header == "" && $footer == "") { |
| 1722 | // メールテンプレート情報の取得 |
| 1723 | $where = "template_id = ?"; |
| 1724 | $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array('1')); |
| 1725 | $objPage->tpl_header = $arrRet[0]['header']; |
| 1726 | $objPage->tpl_footer = $arrRet[0]['footer']; |
| 1727 | $tmp_subject = $arrRet[0]['subject']; |
| 1728 | } else { |
| 1729 | $objPage->tpl_header = $header; |
| 1730 | $objPage->tpl_footer = $footer; |
| 1731 | $tmp_subject = $subject; |
| 1732 | } |
| 1733 | |
| 1734 | // 受注情報の取得 |
| 1735 | $where = "order_id = ?"; |
| 1736 | $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id)); |
| 1737 | $arrOrder = $arrRet[0]; |
| 1738 | $arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id)); |
| 1739 | |
| 1740 | $objPage->Message_tmp = $arrOrder['message']; |
| 1741 | |
| 1742 | // 顧客情報の取得 |
| 1743 | $customer_id = $arrOrder['customer_id']; |
| 1744 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
| 1745 | $arrCustomer = $arrRet[0]; |
| 1746 | |
| 1747 | $objPage->arrCustomer = $arrCustomer; |
| 1748 | $objPage->arrOrder = $arrOrder; |
| 1749 | |
| 1750 | //その他決済情報 |
| 1751 | if($arrOrder['memo02'] != "") { |
| 1752 | $arrOther = unserialize($arrOrder['memo02']); |
| 1753 | |
| 1754 | foreach($arrOther as $other_key => $other_val){ |
| 1755 | if(sfTrim($other_val["value"]) == ""){ |
| 1756 | $arrOther[$other_key]["value"] = ""; |
| 1757 | } |
| 1758 | } |
| 1759 | |
| 1760 | $objPage->arrOther = $arrOther; |
| 1761 | } |
| 1762 | |
| 1763 | // 都道府県変換 |
| 1764 | global $arrPref; |
| 1765 | $objPage->arrOrder['deliv_pref'] = $arrPref[$objPage->arrOrder['deliv_pref']]; |
| 1766 | |
| 1767 | $objPage->arrOrderDetail = $arrOrderDetail; |
| 1768 | |
| 1769 | $objCustomer = new SC_Customer(); |
| 1770 | $objPage->tpl_user_point = $objCustomer->getValue('point'); |
| 1771 | |
| 1772 | $objMailView = new SC_SiteView(); |
| 1773 | // メール本文の取得 |
| 1774 | $objMailView->assignobj($objPage); |
| 1775 | $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]); |
| 1776 | |
| 1777 | // メール送信処理 |
| 1778 | $objSendMail = new GC_SendMail(); |
| 1779 | $bcc = $arrInfo['email01']; |
| 1780 | $from = $arrInfo['email03']; |
| 1781 | $error = $arrInfo['email04']; |
| 1782 | |
| 1783 | $tosubject = sfMakeSubject($tmp_subject); |
| 1784 | |
| 1785 | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
| 1786 | $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." 様"); |
| 1787 | |
| 1788 | |
| 1789 | // 送信フラグ:trueの場合は、送信する。 |
| 1790 | if($send) { |
| 1791 | if ($objSendMail->sendMail()) { |
| 1792 | sfSaveMailHistory($order_id, $template_id, $tosubject, $body); |
| 1793 | } |
| 1794 | } |
| 1795 | |
| 1796 | return $objSendMail; |
| 1797 | } |
| 1798 | |
| 1799 | // テンプレートを使用したメールの送信 |
1801 | | $objMailView = new SC_SiteView(); |
1802 | | $objSiteInfo = new SC_SiteInfo(); |
1803 | | $arrInfo = $objSiteInfo->data; |
1804 | | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
1805 | | $objPage->tpl_shopname=$arrInfo['shop_name']; |
1806 | | $objPage->tpl_infoemail = $arrInfo['email02']; |
1807 | | $objMailView->assignobj($objPage); |
1808 | | $body = $objMailView->fetch($tplpath); |
1809 | | // ¥á¡¼¥ëÁ÷¿®½èÍý |
1810 | | $objSendMail = new GC_SendMail(); |
1811 | | $to = mb_encode_mimeheader($to); |
1812 | | $bcc = $arrInfo['email01']; |
1813 | | $from = $arrInfo['email03']; |
1814 | | $error = $arrInfo['email04']; |
1815 | | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
1816 | | $objSendMail->sendMail(); |
1817 | | } |
1818 | | |
1819 | | // Ä̾ï¤Î¥á¡¼¥ëÁ÷¿® |
| 1801 | $objMailView = new SC_SiteView(); |
| 1802 | $objSiteInfo = new SC_SiteInfo(); |
| 1803 | $arrInfo = $objSiteInfo->data; |
| 1804 | // メール本文の取得 |
| 1805 | $objPage->tpl_shopname=$arrInfo['shop_name']; |
| 1806 | $objPage->tpl_infoemail = $arrInfo['email02']; |
| 1807 | $objMailView->assignobj($objPage); |
| 1808 | $body = $objMailView->fetch($tplpath); |
| 1809 | // メール送信処理 |
| 1810 | $objSendMail = new GC_SendMail(); |
| 1811 | $to = mb_encode_mimeheader($to); |
| 1812 | $bcc = $arrInfo['email01']; |
| 1813 | $from = $arrInfo['email03']; |
| 1814 | $error = $arrInfo['email04']; |
| 1815 | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
| 1816 | $objSendMail->sendMail(); |
| 1817 | } |
| 1818 | |
| 1819 | // 通常のメール送信 |
1821 | | $objSiteInfo = new SC_SiteInfo(); |
1822 | | $arrInfo = $objSiteInfo->data; |
1823 | | // ¥á¡¼¥ëÁ÷¿®½èÍý |
1824 | | $objSendMail = new GC_SendMail(); |
1825 | | $bcc = $arrInfo['email01']; |
1826 | | $from = $arrInfo['email03']; |
1827 | | $error = $arrInfo['email04']; |
1828 | | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
1829 | | $objSendMail->sendMail(); |
1830 | | } |
1831 | | |
1832 | | //·ï̾¤Ë¥Æ¥ó¥×¥ì¡¼¥È¤òÍѤ¤¤ë |
| 1821 | $objSiteInfo = new SC_SiteInfo(); |
| 1822 | $arrInfo = $objSiteInfo->data; |
| 1823 | // メール送信処理 |
| 1824 | $objSendMail = new GC_SendMail(); |
| 1825 | $bcc = $arrInfo['email01']; |
| 1826 | $from = $arrInfo['email03']; |
| 1827 | $error = $arrInfo['email04']; |
| 1828 | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
| 1829 | $objSendMail->sendMail(); |
| 1830 | } |
| 1831 | |
| 1832 | //件名にテンプレートを用いる |
1868 | | $objCustomer = new SC_Customer(); |
1869 | | // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý |
1870 | | if ($objCustomer->isLoginSuccess()) { |
1871 | | // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ® |
1872 | | $sqlval['order_temp_id'] = $uniqid; |
1873 | | $sqlval['update_date'] = 'Now()'; |
1874 | | $sqlval['customer_id'] = $objCustomer->getValue('customer_id'); |
1875 | | $sqlval['order_name01'] = $objCustomer->getValue('name01'); |
1876 | | $sqlval['order_name02'] = $objCustomer->getValue('name02'); |
1877 | | $sqlval['order_kana01'] = $objCustomer->getValue('kana01'); |
1878 | | $sqlval['order_kana02'] = $objCustomer->getValue('kana02'); |
1879 | | $sqlval['order_sex'] = $objCustomer->getValue('sex'); |
1880 | | $sqlval['order_zip01'] = $objCustomer->getValue('zip01'); |
1881 | | $sqlval['order_zip02'] = $objCustomer->getValue('zip02'); |
1882 | | $sqlval['order_pref'] = $objCustomer->getValue('pref'); |
1883 | | $sqlval['order_addr01'] = $objCustomer->getValue('addr01'); |
1884 | | $sqlval['order_addr02'] = $objCustomer->getValue('addr02'); |
1885 | | $sqlval['order_tel01'] = $objCustomer->getValue('tel01'); |
1886 | | $sqlval['order_tel02'] = $objCustomer->getValue('tel02'); |
1887 | | $sqlval['order_tel03'] = $objCustomer->getValue('tel03'); |
1888 | | if (defined('MOBILE_SITE')) { |
1889 | | $sqlval['order_email'] = $objCustomer->getValue('email_mobile'); |
1890 | | } else { |
1891 | | $sqlval['order_email'] = $objCustomer->getValue('email'); |
1892 | | } |
1893 | | $sqlval['order_job'] = $objCustomer->getValue('job'); |
1894 | | $sqlval['order_birth'] = $objCustomer->getValue('birth'); |
1895 | | } |
1896 | | return $sqlval; |
1897 | | } |
1898 | | |
1899 | | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ø¤Î½ñ¤¹þ¤ß½èÍý |
| 1868 | $objCustomer = new SC_Customer(); |
| 1869 | // 会員情報登録処理 |
| 1870 | if ($objCustomer->isLoginSuccess()) { |
| 1871 | // 登録データの作成 |
| 1872 | $sqlval['order_temp_id'] = $uniqid; |
| 1873 | $sqlval['update_date'] = 'Now()'; |
| 1874 | $sqlval['customer_id'] = $objCustomer->getValue('customer_id'); |
| 1875 | $sqlval['order_name01'] = $objCustomer->getValue('name01'); |
| 1876 | $sqlval['order_name02'] = $objCustomer->getValue('name02'); |
| 1877 | $sqlval['order_kana01'] = $objCustomer->getValue('kana01'); |
| 1878 | $sqlval['order_kana02'] = $objCustomer->getValue('kana02'); |
| 1879 | $sqlval['order_sex'] = $objCustomer->getValue('sex'); |
| 1880 | $sqlval['order_zip01'] = $objCustomer->getValue('zip01'); |
| 1881 | $sqlval['order_zip02'] = $objCustomer->getValue('zip02'); |
| 1882 | $sqlval['order_pref'] = $objCustomer->getValue('pref'); |
| 1883 | $sqlval['order_addr01'] = $objCustomer->getValue('addr01'); |
| 1884 | $sqlval['order_addr02'] = $objCustomer->getValue('addr02'); |
| 1885 | $sqlval['order_tel01'] = $objCustomer->getValue('tel01'); |
| 1886 | $sqlval['order_tel02'] = $objCustomer->getValue('tel02'); |
| 1887 | $sqlval['order_tel03'] = $objCustomer->getValue('tel03'); |
| 1888 | if (defined('MOBILE_SITE')) { |
| 1889 | $sqlval['order_email'] = $objCustomer->getValue('email_mobile'); |
| 1890 | } else { |
| 1891 | $sqlval['order_email'] = $objCustomer->getValue('email'); |
| 1892 | } |
| 1893 | $sqlval['order_job'] = $objCustomer->getValue('job'); |
| 1894 | $sqlval['order_birth'] = $objCustomer->getValue('birth'); |
| 1895 | } |
| 1896 | return $sqlval; |
| 1897 | } |
| 1898 | |
| 1899 | // 受注一時テーブルへの書き込み処理 |
1901 | | if($uniqid != "") { |
1902 | | // ´û¸¥Ç¡¼¥¿¤Î¥Á¥§¥Ã¥¯ |
1903 | | $objQuery = new SC_Query(); |
1904 | | $where = "order_temp_id = ?"; |
1905 | | $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid)); |
1906 | | // ´û¸¥Ç¡¼¥¿¤¬¤Ê¤¤¾ì¹ç |
1907 | | if ($cnt == 0) { |
1908 | | // ½é²ó½ñ¤¹þ¤ß»þ¤Ë²ñ°÷¤ÎÅÐÏ¿ºÑ¤ß¾ðÊó¤ò¼è¤ê¹þ¤à |
1909 | | $sqlval = sfGetCustomerSqlVal($uniqid, $sqlval); |
1910 | | $sqlval['create_date'] = "now()"; |
1911 | | $objQuery->insert("dtb_order_temp", $sqlval); |
1912 | | } else { |
1913 | | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); |
1914 | | } |
1915 | | } |
1916 | | } |
1917 | | |
1918 | | /* ²ñ°÷¤Î¥á¥ë¥Þ¥¬ÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤Î¥Á¥§¥Ã¥¯(²¾²ñ°÷¤ò´Þ¤Þ¤Ê¤¤) */ |
| 1901 | if($uniqid != "") { |
| 1902 | // 既存データのチェック |
| 1903 | $objQuery = new SC_Query(); |
| 1904 | $where = "order_temp_id = ?"; |
| 1905 | $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid)); |
| 1906 | // 既存データがない場合 |
| 1907 | if ($cnt == 0) { |
| 1908 | // 初回書き込み時に会員の登録済み情報を取り込む |
| 1909 | $sqlval = sfGetCustomerSqlVal($uniqid, $sqlval); |
| 1910 | $sqlval['create_date'] = "now()"; |
| 1911 | $objQuery->insert("dtb_order_temp", $sqlval); |
| 1912 | } else { |
| 1913 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); |
| 1914 | } |
| 1915 | } |
| 1916 | } |
| 1917 | |
| 1918 | /* 会員のメルマガ登録があるかどうかのチェック(仮会員を含まない) */ |
1935 | | $path = $dir .$file_name; // cgi¥Õ¥¡¥¤¥ë¤Î¥Õ¥ë¥Ñ¥¹À¸À® |
1936 | | $now_dir = getcwd(); // require¤¬¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¤Î¤Ç¡¢cgi¼Â¹Ô¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Üư¤¹¤ë |
1937 | | chdir($dir); |
1938 | | |
1939 | | // ¥Ñ¥¤¥×ÅϤ·¤Ç¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤écgiµ¯Æ° |
1940 | | $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info"; |
1941 | | |
1942 | | $tmpResult = popen($cmd, "r"); |
1943 | | |
1944 | | // ·ë²Ì¼èÆÀ |
1945 | | while( ! FEOF ( $tmpResult ) ) { |
1946 | | $result .= FGETS($tmpResult); |
1947 | | } |
1948 | | pclose($tmpResult); // ¥Ñ¥¤¥×¤òÊĤ¸¤ë |
1949 | | chdir($now_dir); //¡¡¸µ¤Ë¤¤¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ëµ¢¤ë |
1950 | | |
1951 | | // ·ë²Ì¤òÏ¢ÁÛÇÛÎ󤨳ÊǼ |
1952 | | $result = ereg_replace("&$", "", $result); |
1953 | | foreach (explode("&",$result) as $data) { |
1954 | | list($key, $val) = explode("=", $data, 2); |
1955 | | $return[$key] = $val; |
1956 | | } |
1957 | | |
1958 | | return $return; |
1959 | | } |
1960 | | |
1961 | | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤«¤é¾ðÊó¤ò¼èÆÀ¤¹¤ë |
| 1935 | $path = $dir .$file_name; // cgiファイルのフルパス生成 |
| 1936 | $now_dir = getcwd(); // requireがうまくいかないので、cgi実行ディレクトリに移動する |
| 1937 | chdir($dir); |
| 1938 | |
| 1939 | // パイプ渡しでコマンドラインからcgi起動 |
| 1940 | $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info"; |
| 1941 | |
| 1942 | $tmpResult = popen($cmd, "r"); |
| 1943 | |
| 1944 | // 結果取得 |
| 1945 | while( ! FEOF ( $tmpResult ) ) { |
| 1946 | $result .= FGETS($tmpResult); |
| 1947 | } |
| 1948 | pclose($tmpResult); // パイプを閉じる |
| 1949 | chdir($now_dir); // 元にいたディレクトリに帰る |
| 1950 | |
| 1951 | // 結果を連想配列へ格納 |
| 1952 | $result = ereg_replace("&$", "", $result); |
| 1953 | foreach (explode("&",$result) as $data) { |
| 1954 | list($key, $val) = explode("=", $data, 2); |
| 1955 | $return[$key] = $val; |
| 1956 | } |
| 1957 | |
| 1958 | return $return; |
| 1959 | } |
| 1960 | |
| 1961 | // 受注一時テーブルから情報を取得する |
1975 | | global $g_category_on; |
1976 | | global $g_category_id; |
1977 | | if(!$g_category_on) { |
1978 | | $g_category_on = true; |
1979 | | $category_id = (int) $category_id; |
1980 | | $product_id = (int) $product_id; |
1981 | | if(sfIsInt($category_id) && sfIsRecord("dtb_category","category_id", $category_id)) { |
1982 | | $g_category_id = $category_id; |
1983 | | } else if (sfIsInt($product_id) && sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { |
1984 | | $objQuery = new SC_Query(); |
1985 | | $where = "product_id = ?"; |
1986 | | $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id)); |
1987 | | $g_category_id = $category_id; |
1988 | | } else { |
1989 | | // ÉÔÀµ¤Ê¾ì¹ç¤Ï¡¢0¤òÊÖ¤¹¡£ |
1990 | | $g_category_id = 0; |
1991 | | } |
1992 | | } |
1993 | | return $g_category_id; |
1994 | | } |
1995 | | |
1996 | | // ROOTID¼èÆÀȽÄêÍѤΥ°¥í¡¼¥Ð¥ëÊÑ¿ô(°ìÅÙ¼èÆÀ¤µ¤ì¤Æ¤¤¤¿¤éºÆ¼èÆÀ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë) |
| 1975 | global $g_category_on; |
| 1976 | global $g_category_id; |
| 1977 | if(!$g_category_on) { |
| 1978 | $g_category_on = true; |
| 1979 | $category_id = (int) $category_id; |
| 1980 | $product_id = (int) $product_id; |
| 1981 | if(sfIsInt($category_id) && sfIsRecord("dtb_category","category_id", $category_id)) { |
| 1982 | $g_category_id = $category_id; |
| 1983 | } else if (sfIsInt($product_id) && sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { |
| 1984 | $objQuery = new SC_Query(); |
| 1985 | $where = "product_id = ?"; |
| 1986 | $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id)); |
| 1987 | $g_category_id = $category_id; |
| 1988 | } else { |
| 1989 | // 不正な場合は、0を返す。 |
| 1990 | $g_category_id = 0; |
| 1991 | } |
| 1992 | } |
| 1993 | return $g_category_id; |
| 1994 | } |
| 1995 | |
| 1996 | // ROOTID取得判定用のグローバル変数(一度取得されていたら再取得しないようにする) |
2072 | | // ÇÛÎó¤Ç¤Ê¤¤¾ì¹ç |
2073 | | if(!is_array($data)) { |
2074 | | if (DB_TYPE == "pgsql") { |
2075 | | $ret = pg_escape_string($data); |
2076 | | }else if(DB_TYPE == "mysql"){ |
2077 | | $ret = mysql_real_escape_string($data); |
2078 | | } |
2079 | | $ret = ereg_replace("%", "\\%", $ret); |
2080 | | $ret = ereg_replace("_", "\\_", $ret); |
2081 | | return $ret; |
2082 | | } |
2083 | | |
2084 | | // ÇÛÎó¤Î¾ì¹ç |
2085 | | foreach($data as $val) { |
2086 | | if (DB_TYPE == "pgsql") { |
2087 | | $ret = pg_escape_string($val); |
2088 | | }else if(DB_TYPE == "mysql"){ |
2089 | | $ret = mysql_real_escape_string($val); |
2090 | | } |
2091 | | |
2092 | | $ret = ereg_replace("%", "\\%", $ret); |
2093 | | $ret = ereg_replace("_", "\\_", $ret); |
2094 | | $arrRet[] = $ret; |
2095 | | } |
2096 | | |
2097 | | return $arrRet; |
2098 | | } |
2099 | | |
2100 | | // ¼õÃíÈÖ¹æ¡¢ÍøÍѥݥ¤¥ó¥È¡¢²Ã»»¥Ý¥¤¥ó¥È¤«¤éºÇ½ª¥Ý¥¤¥ó¥È¤ò¼èÆÀ |
| 2072 | // 配列でない場合 |
| 2073 | if(!is_array($data)) { |
| 2074 | if (DB_TYPE == "pgsql") { |
| 2075 | $ret = pg_escape_string($data); |
| 2076 | }else if(DB_TYPE == "mysql"){ |
| 2077 | $ret = mysql_real_escape_string($data); |
| 2078 | } |
| 2079 | $ret = ereg_replace("%", "\\%", $ret); |
| 2080 | $ret = ereg_replace("_", "\\_", $ret); |
| 2081 | return $ret; |
| 2082 | } |
| 2083 | |
| 2084 | // 配列の場合 |
| 2085 | foreach($data as $val) { |
| 2086 | if (DB_TYPE == "pgsql") { |
| 2087 | $ret = pg_escape_string($val); |
| 2088 | }else if(DB_TYPE == "mysql"){ |
| 2089 | $ret = mysql_real_escape_string($val); |
| 2090 | } |
| 2091 | |
| 2092 | $ret = ereg_replace("%", "\\%", $ret); |
| 2093 | $ret = ereg_replace("_", "\\_", $ret); |
| 2094 | $arrRet[] = $ret; |
| 2095 | } |
| 2096 | |
| 2097 | return $arrRet; |
| 2098 | } |
| 2099 | |
| 2100 | // 受注番号、利用ポイント、加算ポイントから最終ポイントを取得 |
2102 | | $objQuery = new SC_Query(); |
2103 | | $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); |
2104 | | $customer_id = $arrRet[0]['customer_id']; |
2105 | | if($customer_id != "" && $customer_id >= 1) { |
2106 | | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
2107 | | $point = $arrRet[0]['point']; |
2108 | | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
2109 | | } else { |
2110 | | $total_point = ""; |
2111 | | $point = ""; |
2112 | | } |
2113 | | return array($point, $total_point); |
2114 | | } |
2115 | | |
2116 | | /* ¥É¥á¥¤¥ó´Ö¤Ç͸ú¤Ê¥»¥Ã¥·¥ç¥ó¤Î¥¹¥¿¡¼¥È */ |
| 2102 | $objQuery = new SC_Query(); |
| 2103 | $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); |
| 2104 | $customer_id = $arrRet[0]['customer_id']; |
| 2105 | if($customer_id != "" && $customer_id >= 1) { |
| 2106 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
| 2107 | $point = $arrRet[0]['point']; |
| 2108 | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
| 2109 | } else { |
| 2110 | $total_point = ""; |
| 2111 | $point = ""; |
| 2112 | } |
| 2113 | return array($point, $total_point); |
| 2114 | } |
| 2115 | |
| 2116 | /* ドメイン間で有効なセッションのスタート */ |
2197 | | if($byte) { |
2198 | | if(strlen($str) > ($len + 2)) { |
2199 | | $ret =substr($str, 0, $len); |
2200 | | $cut = substr($str, $len); |
2201 | | } else { |
2202 | | $ret = $str; |
2203 | | $commadisp = false; |
2204 | | } |
2205 | | } else { |
2206 | | if(mb_strlen($str) > ($len + 1)) { |
2207 | | $ret = mb_substr($str, 0, $len); |
2208 | | $cut = mb_substr($str, $len); |
2209 | | } else { |
2210 | | $ret = $str; |
2211 | | $commadisp = false; |
2212 | | } |
2213 | | } |
2214 | | |
2215 | | // ³¨Ê¸»ú¥¿¥°¤ÎÅÓÃæ¤ÇʬÃǤµ¤ì¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£ |
2216 | | if (isset($cut)) { |
2217 | | // ʬ³ä°ÌÃÖ¤è¤êÁ°¤ÎºÇ¸å¤Î [ °Ê¹ß¤ò¼èÆÀ¤¹¤ë¡£ |
2218 | | $head = strrchr($ret, '['); |
2219 | | |
2220 | | // ʬ³ä°ÌÃÖ¤è¤ê¸å¤ÎºÇ½é¤Î ] °ÊÁ°¤ò¼èÆÀ¤¹¤ë¡£ |
2221 | | $tail_pos = strpos($cut, ']'); |
2222 | | if ($tail_pos !== false) { |
2223 | | $tail = substr($cut, 0, $tail_pos + 1); |
2224 | | } |
2225 | | |
2226 | | // ʬ³ä°ÌÃÖ¤è¤êÁ°¤Ë [¡¢¸å¤Ë ] ¤¬¸«¤Ä¤«¤Ã¤¿¾ì¹ç¤Ï¡¢[ ¤«¤é ] ¤Þ¤Ç¤ò |
2227 | | // Àܳ¤·¤Æ³¨Ê¸»ú¥¿¥°1¸Äʬ¤Ë¤Ê¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£ |
2228 | | if ($head !== false && $tail_pos !== false) { |
2229 | | $subject = $head . $tail; |
2230 | | if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) { |
2231 | | // ³¨Ê¸»ú¥¿¥°¤¬¸«¤Ä¤«¤Ã¤¿¤Î¤Çºï½ü¤¹¤ë¡£ |
2232 | | $ret = substr($ret, 0, -strlen($head)); |
2233 | | } |
2234 | | } |
2235 | | } |
2236 | | |
2237 | | if($commadisp){ |
2238 | | $ret = $ret . "..."; |
2239 | | } |
2240 | | return $ret; |
2241 | | } |
2242 | | |
2243 | | // ǯ¡¢·î¡¢Äù¤áÆü¤«¤é¡¢Àè·î¤ÎÄù¤áÆü+1¡¢º£·î¤ÎÄù¤áÆü¤òµá¤á¤ë¡£ |
| 2197 | if($byte) { |
| 2198 | if(strlen($str) > ($len + 2)) { |
| 2199 | $ret =substr($str, 0, $len); |
| 2200 | $cut = substr($str, $len); |
| 2201 | } else { |
| 2202 | $ret = $str; |
| 2203 | $commadisp = false; |
| 2204 | } |
| 2205 | } else { |
| 2206 | if(mb_strlen($str) > ($len + 1)) { |
| 2207 | $ret = mb_substr($str, 0, $len); |
| 2208 | $cut = mb_substr($str, $len); |
| 2209 | } else { |
| 2210 | $ret = $str; |
| 2211 | $commadisp = false; |
| 2212 | } |
| 2213 | } |
| 2214 | |
| 2215 | // 絵文字タグの途中で分断されないようにする。 |
| 2216 | if (isset($cut)) { |
| 2217 | // 分割位置より前の最後の [ 以降を取得する。 |
| 2218 | $head = strrchr($ret, '['); |
| 2219 | |
| 2220 | // 分割位置より後の最初の ] 以前を取得する。 |
| 2221 | $tail_pos = strpos($cut, ']'); |
| 2222 | if ($tail_pos !== false) { |
| 2223 | $tail = substr($cut, 0, $tail_pos + 1); |
| 2224 | } |
| 2225 | |
| 2226 | // 分割位置より前に [、後に ] が見つかった場合は、[ から ] までを |
| 2227 | // 接続して絵文字タグ1個分になるかどうかをチェックする。 |
| 2228 | if ($head !== false && $tail_pos !== false) { |
| 2229 | $subject = $head . $tail; |
| 2230 | if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) { |
| 2231 | // 絵文字タグが見つかったので削除する。 |
| 2232 | $ret = substr($ret, 0, -strlen($head)); |
| 2233 | } |
| 2234 | } |
| 2235 | } |
| 2236 | |
| 2237 | if($commadisp){ |
| 2238 | $ret = $ret . "..."; |
| 2239 | } |
| 2240 | return $ret; |
| 2241 | } |
| 2242 | |
| 2243 | // 年、月、締め日から、先月の締め日+1、今月の締め日を求める。 |
2245 | | $end_year = $year; |
2246 | | $end_month = $month; |
2247 | | |
2248 | | // ³«»Ï·î¤¬½ªÎ»·î¤ÈƱ¤¸¤«Èݤ« |
2249 | | $same_month = false; |
2250 | | |
2251 | | // ³ºÅö·î¤ÎËöÆü¤òµá¤á¤ë¡£ |
2252 | | $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year)); |
2253 | | |
2254 | | // ·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç |
2255 | | if($end_last_day < $close_day) { |
2256 | | // Äù¤áÆü¤ò·îËöÆü¤Ë¹ç¤ï¤»¤ë |
2257 | | $end_day = $end_last_day; |
2258 | | } else { |
2259 | | $end_day = $close_day; |
2260 | | } |
2261 | | |
2262 | | // Á°·î¤Î¼èÆÀ |
2263 | | $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year)); |
2264 | | $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year)); |
2265 | | // Á°·î¤ÎËöÆü¤òµá¤á¤ë¡£ |
2266 | | $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year)); |
2267 | | |
2268 | | // Á°·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç |
2269 | | if ($start_last_day < $close_day) { |
2270 | | // ·îËöÆü¤Ë¹ç¤ï¤»¤ë |
2271 | | $tmp_day = $start_last_day; |
2272 | | } else { |
2273 | | $tmp_day = $close_day; |
2274 | | } |
2275 | | |
2276 | | // Àè·î¤ÎËöÆü¤ÎÍâÆü¤ò¼èÆÀ¤¹¤ë |
2277 | | $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
2278 | | $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
2279 | | $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
2280 | | |
2281 | | // ÆüÉդκîÀ® |
2282 | | $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day); |
2283 | | $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day); |
2284 | | |
2285 | | return array($start_date, $end_date); |
2286 | | } |
2287 | | |
2288 | | // PDFÍѤÎRGB¥«¥é¡¼¤òÊÖ¤¹ |
| 2245 | $end_year = $year; |
| 2246 | $end_month = $month; |
| 2247 | |
| 2248 | // 開始月が終了月と同じか否か |
| 2249 | $same_month = false; |
| 2250 | |
| 2251 | // 該当月の末日を求める。 |
| 2252 | $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year)); |
| 2253 | |
| 2254 | // 月の末日が締め日より少ない場合 |
| 2255 | if($end_last_day < $close_day) { |
| 2256 | // 締め日を月末日に合わせる |
| 2257 | $end_day = $end_last_day; |
| 2258 | } else { |
| 2259 | $end_day = $close_day; |
| 2260 | } |
| 2261 | |
| 2262 | // 前月の取得 |
| 2263 | $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year)); |
| 2264 | $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year)); |
| 2265 | // 前月の末日を求める。 |
| 2266 | $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year)); |
| 2267 | |
| 2268 | // 前月の末日が締め日より少ない場合 |
| 2269 | if ($start_last_day < $close_day) { |
| 2270 | // 月末日に合わせる |
| 2271 | $tmp_day = $start_last_day; |
| 2272 | } else { |
| 2273 | $tmp_day = $close_day; |
| 2274 | } |
| 2275 | |
| 2276 | // 先月の末日の翌日を取得する |
| 2277 | $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
| 2278 | $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
| 2279 | $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
| 2280 | |
| 2281 | // 日付の作成 |
| 2282 | $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day); |
| 2283 | $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day); |
| 2284 | |
| 2285 | return array($start_date, $end_date); |
| 2286 | } |
| 2287 | |
| 2288 | // PDF用のRGBカラーを返す |
2304 | | $objQuery = new SC_Query(); |
2305 | | $objConn = new SC_DBConn(); |
2306 | | $objPage = new LC_Page(); |
2307 | | |
2308 | | $random_id = sfGetUniqRandomId(); |
2309 | | $arrRegistMailMagazine["mail_flag"] = $mail_flag; |
2310 | | $arrRegistMailMagazine["email"] = $email; |
2311 | | $arrRegistMailMagazine["temp_id"] =$random_id; |
2312 | | $arrRegistMailMagazine["end_flag"]='0'; |
2313 | | $arrRegistMailMagazine["update_date"] = 'now()'; |
2314 | | |
2315 | | //¥á¥ë¥Þ¥¬²¾ÅÐÏ¿Íѥե饰 |
2316 | | $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email)); |
2317 | | $objConn->query("BEGIN"); |
2318 | | switch ($flag){ |
2319 | | case '0': |
2320 | | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine); |
2321 | | break; |
2322 | | |
2323 | | case '1': |
2324 | | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = '" .addslashes($email). "'"); |
2325 | | break; |
2326 | | } |
2327 | | $objConn->query("COMMIT"); |
2328 | | $subject = sfMakeSubject('¥á¥ë¥Þ¥¬²¾ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£'); |
2329 | | $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id']; |
2330 | | switch ($mail_flag){ |
2331 | | case '1': |
2332 | | $objPage->tpl_name = "ÅÐÏ¿"; |
2333 | | $objPage->tpl_kindname = "HTML"; |
2334 | | break; |
2335 | | |
2336 | | case '2': |
2337 | | $objPage->tpl_name = "ÅÐÏ¿"; |
2338 | | $objPage->tpl_kindname = "¥Æ¥¥¹¥È"; |
2339 | | break; |
2340 | | |
2341 | | case '3': |
2342 | | $objPage->tpl_name = "²ò½ü"; |
2343 | | break; |
2344 | | } |
2345 | | $objPage->tpl_email = $email; |
2346 | | sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage); |
2347 | | } |
2348 | | |
2349 | | // ºÆµ¢Åª¤Ë¿ÃÊÇÛÎó¤ò¸¡º÷¤·¤Æ°ì¼¡¸µÇÛÎó(Hidden°úÅϤ·ÍÑÇÛÎó)¤ËÊÑ´¹¤¹¤ë¡£ |
| 2304 | $objQuery = new SC_Query(); |
| 2305 | $objConn = new SC_DBConn(); |
| 2306 | $objPage = new LC_Page(); |
| 2307 | |
| 2308 | $random_id = sfGetUniqRandomId(); |
| 2309 | $arrRegistMailMagazine["mail_flag"] = $mail_flag; |
| 2310 | $arrRegistMailMagazine["email"] = $email; |
| 2311 | $arrRegistMailMagazine["temp_id"] =$random_id; |
| 2312 | $arrRegistMailMagazine["end_flag"]='0'; |
| 2313 | $arrRegistMailMagazine["update_date"] = 'now()'; |
| 2314 | |
| 2315 | //メルマガ仮登録用フラグ |
| 2316 | $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email)); |
| 2317 | $objConn->query("BEGIN"); |
| 2318 | switch ($flag){ |
| 2319 | case '0': |
| 2320 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine); |
| 2321 | break; |
| 2322 | |
| 2323 | case '1': |
| 2324 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = '" .addslashes($email). "'"); |
| 2325 | break; |
| 2326 | } |
| 2327 | $objConn->query("COMMIT"); |
| 2328 | $subject = sfMakeSubject('メルマガ仮登録が完了しました。'); |
| 2329 | $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id']; |
| 2330 | switch ($mail_flag){ |
| 2331 | case '1': |
| 2332 | $objPage->tpl_name = "登録"; |
| 2333 | $objPage->tpl_kindname = "HTML"; |
| 2334 | break; |
| 2335 | |
| 2336 | case '2': |
| 2337 | $objPage->tpl_name = "登録"; |
| 2338 | $objPage->tpl_kindname = "テキスト"; |
| 2339 | break; |
| 2340 | |
| 2341 | case '3': |
| 2342 | $objPage->tpl_name = "解除"; |
| 2343 | break; |
| 2344 | } |
| 2345 | $objPage->tpl_email = $email; |
| 2346 | sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage); |
| 2347 | } |
| 2348 | |
| 2349 | // 再帰的に多段配列を検索して一次元配列(Hidden引渡し用配列)に変換する。 |
2380 | | $basename = basename($_SERVER["REQUEST_URI"]); |
2381 | | |
2382 | | if($basename == "") { |
2383 | | $path = $_SERVER["REQUEST_URI"] . "index.php"; |
2384 | | } else { |
2385 | | $path = $_SERVER["REQUEST_URI"]; |
2386 | | } |
2387 | | |
2388 | | if($_GET['tpl'] != "") { |
2389 | | $tpl_name = $_GET['tpl']; |
2390 | | } else { |
2391 | | $tpl_name = ereg_replace("^/", "", $path); |
2392 | | $tpl_name = ereg_replace("/", "_", $tpl_name); |
2393 | | $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name); |
2394 | | } |
2395 | | |
2396 | | $template_path = TEMPLATE_FTP_DIR . $tpl_name; |
2397 | | |
2398 | | if($is_mobile === true) { |
2399 | | $objView = new SC_MobileView(); |
2400 | | $objView->assignobj($objPage); |
2401 | | $objView->display(SITE_FRAME); |
2402 | | } else if(file_exists($template_path)) { |
2403 | | $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR); |
2404 | | $objView->assignobj($objPage); |
2405 | | $objView->display($tpl_name); |
2406 | | } else { |
2407 | | $objView = new SC_SiteView(); |
2408 | | $objView->assignobj($objPage); |
2409 | | $objView->display(SITE_FRAME); |
2410 | | } |
2411 | | } |
2412 | | |
2413 | | //²ñ°÷ÊÔ½¸ÅÐÏ¿½èÍý |
| 2380 | $basename = basename($_SERVER["REQUEST_URI"]); |
| 2381 | |
| 2382 | if($basename == "") { |
| 2383 | $path = $_SERVER["REQUEST_URI"] . "index.php"; |
| 2384 | } else { |
| 2385 | $path = $_SERVER["REQUEST_URI"]; |
| 2386 | } |
| 2387 | |
| 2388 | if($_GET['tpl'] != "") { |
| 2389 | $tpl_name = $_GET['tpl']; |
| 2390 | } else { |
| 2391 | $tpl_name = ereg_replace("^/", "", $path); |
| 2392 | $tpl_name = ereg_replace("/", "_", $tpl_name); |
| 2393 | $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name); |
| 2394 | } |
| 2395 | |
| 2396 | $template_path = TEMPLATE_FTP_DIR . $tpl_name; |
| 2397 | |
| 2398 | if($is_mobile === true) { |
| 2399 | $objView = new SC_MobileView(); |
| 2400 | $objView->assignobj($objPage); |
| 2401 | $objView->display(SITE_FRAME); |
| 2402 | } else if(file_exists($template_path)) { |
| 2403 | $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR); |
| 2404 | $objView->assignobj($objPage); |
| 2405 | $objView->display($tpl_name); |
| 2406 | } else { |
| 2407 | $objView = new SC_SiteView(); |
| 2408 | $objView->assignobj($objPage); |
| 2409 | $objView->display(SITE_FRAME); |
| 2410 | } |
| 2411 | } |
| 2412 | |
| 2413 | //会員編集登録処理 |
2415 | | $objQuery = new SC_Query(); |
2416 | | |
2417 | | foreach ($arrRegistColumn as $data) { |
2418 | | if ($data["column"] != "password") { |
2419 | | if($array[ $data['column'] ] != "") { |
2420 | | $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; |
2421 | | } else { |
2422 | | $arrRegist[ $data['column'] ] = NULL; |
2423 | | } |
2424 | | } |
2425 | | } |
2426 | | if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) { |
2427 | | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
2428 | | } else { |
2429 | | $arrRegist["birth"] = NULL; |
2430 | | } |
2431 | | |
2432 | | //-- ¥Ñ¥¹¥ï¡¼¥É¤Î¹¹¿·¤¬¤¢¤ë¾ì¹ç¤Ï°Å¹æ²½¡£¡Ê¹¹¿·¤¬¤Ê¤¤¾ì¹ç¤ÏUPDATEʸ¤ò¹½À®¤·¤Ê¤¤¡Ë |
2433 | | if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
2434 | | $arrRegist["update_date"] = "NOW()"; |
2435 | | |
2436 | | //-- ÊÔ½¸ÅÐÏ¿¼Â¹Ô |
2437 | | if (defined('MOBILE_SITE')) { |
2438 | | $arrRegist['email_mobile'] = $arrRegist['email']; |
2439 | | unset($arrRegist['email']); |
2440 | | } |
2441 | | $objQuery->begin(); |
2442 | | $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id'])); |
2443 | | $objQuery->commit(); |
2444 | | } |
2445 | | |
2446 | | // PHP¤Îmb_convert_encoding´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë |
| 2415 | $objQuery = new SC_Query(); |
| 2416 | |
| 2417 | foreach ($arrRegistColumn as $data) { |
| 2418 | if ($data["column"] != "password") { |
| 2419 | if($array[ $data['column'] ] != "") { |
| 2420 | $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; |
| 2421 | } else { |
| 2422 | $arrRegist[ $data['column'] ] = NULL; |
| 2423 | } |
| 2424 | } |
| 2425 | } |
| 2426 | if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) { |
| 2427 | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
| 2428 | } else { |
| 2429 | $arrRegist["birth"] = NULL; |
| 2430 | } |
| 2431 | |
| 2432 | //-- パスワードの更新がある場合は暗号化。(更新がない場合はUPDATE文を構成しない) |
| 2433 | if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
| 2434 | $arrRegist["update_date"] = "NOW()"; |
| 2435 | |
| 2436 | //-- 編集登録実行 |
| 2437 | if (defined('MOBILE_SITE')) { |
| 2438 | $arrRegist['email_mobile'] = $arrRegist['email']; |
| 2439 | unset($arrRegist['email']); |
| 2440 | } |
| 2441 | $objQuery->begin(); |
| 2442 | $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id'])); |
| 2443 | $objQuery->commit(); |
| 2444 | } |
| 2445 | |
| 2446 | // PHPのmb_convert_encoding関数をSmartyでも使えるようにする |
2479 | | $sql = ""; |
2480 | | |
2481 | | //¥Æ¡¼¥Ö¥ëÆâÍÆ¤Îºï½ü |
2482 | | $objQuery->query("DELETE FROM dtb_category_count"); |
2483 | | $objQuery->query("DELETE FROM dtb_category_total_count"); |
2484 | | |
2485 | | //³Æ¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò¿ô¤¨¤Æ³ÊǼ |
2486 | | $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) "; |
2487 | | $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 "; |
2488 | | $sql .= " ON T1.category_id = T2.category_id "; |
2489 | | $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; |
2490 | | $sql .= " GROUP BY T1.category_id, T2.category_id "; |
2491 | | $objQuery->query($sql); |
2492 | | |
2493 | | //»Ò¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò½¸·×¤¹¤ë |
2494 | | $arrCat = $objQuery->getAll("SELECT * FROM dtb_category"); |
2495 | | |
2496 | | $sql = ""; |
2497 | | foreach($arrCat as $key => $val){ |
2498 | | |
2499 | | // »ÒID°ìÍ÷¤ò¼èÆÀ |
2500 | | $arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']); |
2501 | | $line = sfGetCommaList($arrRet); |
2502 | | |
2503 | | $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) "; |
2504 | | $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count "; |
2505 | | $sql .= " WHERE category_id IN (" . $line . ")"; |
2506 | | |
2507 | | $objQuery->query($sql, array($val['category_id'])); |
2508 | | } |
2509 | | } |
2510 | | |
2511 | | // 2¤Ä¤ÎÇÛÎó¤òÍѤ¤¤ÆÏ¢ÁÛÇÛÎó¤òºîÀ®¤¹¤ë |
| 2479 | $sql = ""; |
| 2480 | |
| 2481 | //テーブル内容の削除 |
| 2482 | $objQuery->query("DELETE FROM dtb_category_count"); |
| 2483 | $objQuery->query("DELETE FROM dtb_category_total_count"); |
| 2484 | |
| 2485 | //各カテゴリ内の商品数を数えて格納 |
| 2486 | $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) "; |
| 2487 | $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 "; |
| 2488 | $sql .= " ON T1.category_id = T2.category_id "; |
| 2489 | $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; |
| 2490 | $sql .= " GROUP BY T1.category_id, T2.category_id "; |
| 2491 | $objQuery->query($sql); |
| 2492 | |
| 2493 | //子カテゴリ内の商品数を集計する |
| 2494 | $arrCat = $objQuery->getAll("SELECT * FROM dtb_category"); |
| 2495 | |
| 2496 | $sql = ""; |
| 2497 | foreach($arrCat as $key => $val){ |
| 2498 | |
| 2499 | // 子ID一覧を取得 |
| 2500 | $arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']); |
| 2501 | $line = sfGetCommaList($arrRet); |
| 2502 | |
| 2503 | $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) "; |
| 2504 | $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count "; |
| 2505 | $sql .= " WHERE category_id IN (" . $line . ")"; |
| 2506 | |
| 2507 | $objQuery->query($sql, array($val['category_id'])); |
| 2508 | } |
| 2509 | } |
| 2510 | |
| 2511 | // 2つの配列を用いて連想配列を作成する |
2531 | | $objQuery = new SC_Query(); |
2532 | | $col = $pid_name . "," . $id_name; |
2533 | | $arrData = $objQuery->select($col, $table); |
2534 | | |
2535 | | $arrPID = array(); |
2536 | | $arrPID[] = $id; |
2537 | | $arrChildren = array(); |
2538 | | $arrChildren[] = $id; |
2539 | | |
2540 | | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); |
2541 | | |
2542 | | while(count($arrRet) > 0) { |
2543 | | $arrChildren = array_merge($arrChildren, $arrRet); |
2544 | | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); |
2545 | | } |
2546 | | |
2547 | | return $arrChildren; |
2548 | | } |
2549 | | |
2550 | | /* ¿ÆIDľ²¼¤Î»ÒID¤ò¤¹¤Ù¤Æ¼èÆÀ¤¹¤ë */ |
| 2531 | $objQuery = new SC_Query(); |
| 2532 | $col = $pid_name . "," . $id_name; |
| 2533 | $arrData = $objQuery->select($col, $table); |
| 2534 | |
| 2535 | $arrPID = array(); |
| 2536 | $arrPID[] = $id; |
| 2537 | $arrChildren = array(); |
| 2538 | $arrChildren[] = $id; |
| 2539 | |
| 2540 | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); |
| 2541 | |
| 2542 | while(count($arrRet) > 0) { |
| 2543 | $arrChildren = array_merge($arrChildren, $arrRet); |
| 2544 | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); |
| 2545 | } |
| 2546 | |
| 2547 | return $arrChildren; |
| 2548 | } |
| 2549 | |
| 2550 | /* 親ID直下の子IDをすべて取得する */ |
2641 | | $objQuery = new SC_Query(); |
2642 | | $col = ""; |
2643 | | $col .= " cat.category_id,"; |
2644 | | $col .= " cat.category_name,"; |
2645 | | $col .= " cat.parent_category_id,"; |
2646 | | $col .= " cat.level,"; |
2647 | | $col .= " cat.rank,"; |
2648 | | $col .= " cat.creator_id,"; |
2649 | | $col .= " cat.create_date,"; |
2650 | | $col .= " cat.update_date,"; |
2651 | | $col .= " cat.del_flg, "; |
2652 | | $col .= " ttl.product_count"; |
2653 | | $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; |
2654 | | // ÅÐÏ¿¾¦ÉÊ¿ô¤Î¥Á¥§¥Ã¥¯ |
2655 | | if($count_check) { |
2656 | | $where = "del_flg = 0 AND product_count > 0"; |
2657 | | } else { |
2658 | | $where = "del_flg = 0"; |
2659 | | } |
2660 | | $objQuery->setoption("ORDER BY rank DESC"); |
2661 | | $arrRet = $objQuery->select($col, $from, $where); |
2662 | | |
2663 | | $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); |
2664 | | |
2665 | | foreach($arrRet as $key => $array) { |
2666 | | foreach($arrParentID as $val) { |
2667 | | if($array['category_id'] == $val) { |
2668 | | $arrRet[$key]['display'] = 1; |
2669 | | break; |
2670 | | } |
2671 | | } |
2672 | | } |
2673 | | |
2674 | | return $arrRet; |
2675 | | } |
2676 | | |
2677 | | // ¿Æ¥«¥Æ¥´¥ê¡¼¤òÏ¢·ë¤·¤¿Ê¸»úÎó¤ò¼èÆÀ¤¹¤ë |
| 2641 | $objQuery = new SC_Query(); |
| 2642 | $col = ""; |
| 2643 | $col .= " cat.category_id,"; |
| 2644 | $col .= " cat.category_name,"; |
| 2645 | $col .= " cat.parent_category_id,"; |
| 2646 | $col .= " cat.level,"; |
| 2647 | $col .= " cat.rank,"; |
| 2648 | $col .= " cat.creator_id,"; |
| 2649 | $col .= " cat.create_date,"; |
| 2650 | $col .= " cat.update_date,"; |
| 2651 | $col .= " cat.del_flg, "; |
| 2652 | $col .= " ttl.product_count"; |
| 2653 | $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; |
| 2654 | // 登録商品数のチェック |
| 2655 | if($count_check) { |
| 2656 | $where = "del_flg = 0 AND product_count > 0"; |
| 2657 | } else { |
| 2658 | $where = "del_flg = 0"; |
| 2659 | } |
| 2660 | $objQuery->setoption("ORDER BY rank DESC"); |
| 2661 | $arrRet = $objQuery->select($col, $from, $where); |
| 2662 | |
| 2663 | $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); |
| 2664 | |
| 2665 | foreach($arrRet as $key => $array) { |
| 2666 | foreach($arrParentID as $val) { |
| 2667 | if($array['category_id'] == $val) { |
| 2668 | $arrRet[$key]['display'] = 1; |
| 2669 | break; |
| 2670 | } |
| 2671 | } |
| 2672 | } |
| 2673 | |
| 2674 | return $arrRet; |
| 2675 | } |
| 2676 | |
| 2677 | // 親カテゴリーを連結した文字列を取得する |
2679 | | // ¾¦Éʤ¬Â°¤¹¤ë¥«¥Æ¥´¥êID¤ò½Ä¤Ë¼èÆÀ |
2680 | | $objQuery = new SC_Query(); |
2681 | | $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
2682 | | $ConbName = ""; |
2683 | | |
2684 | | // ¥«¥Æ¥´¥ê¡¼Ì¾¾Î¤ò¼èÆÀ¤¹¤ë |
2685 | | foreach($arrCatID as $key => $val){ |
2686 | | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
2687 | | $arrVal = array($val); |
2688 | | $CatName = $objQuery->getOne($sql,$arrVal); |
2689 | | $ConbName .= $CatName . ' | '; |
2690 | | } |
2691 | | // ºÇ¸å¤Î ¡Ã ¤ò¥«¥Ã¥È¤¹¤ë |
2692 | | $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); |
2693 | | |
2694 | | return $ConbName; |
2695 | | } |
2696 | | |
2697 | | // »ØÄꤷ¤¿¥«¥Æ¥´¥ê¡¼ID¤ÎÂ祫¥Æ¥´¥ê¡¼¤ò¼èÆÀ¤¹¤ë |
| 2679 | // 商品が属するカテゴリIDを縦に取得 |
| 2680 | $objQuery = new SC_Query(); |
| 2681 | $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
| 2682 | $ConbName = ""; |
| 2683 | |
| 2684 | // カテゴリー名称を取得する |
| 2685 | foreach($arrCatID as $key => $val){ |
| 2686 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
| 2687 | $arrVal = array($val); |
| 2688 | $CatName = $objQuery->getOne($sql,$arrVal); |
| 2689 | $ConbName .= $CatName . ' | '; |
| 2690 | } |
| 2691 | // 最後の | をカットする |
| 2692 | $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); |
| 2693 | |
| 2694 | return $ConbName; |
| 2695 | } |
| 2696 | |
| 2697 | // 指定したカテゴリーIDの大カテゴリーを取得する |