Changeset 22666 for branches/camp/camp-2_13-tax
- Timestamp:
- 2013/03/10 01:25:51 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/camp/camp-2_13-tax/data/class/helper/SC_Helper_TaxRule.php
r22653 r22666 149 149 { 150 150 // 税情報を設定 151 SC_Helper_TaxRule_Ex::setTaxRule($tax_rate, 152 $tax_adjust, 153 $product_id, 154 $product_class_id, 155 $pref_id, 156 $country_id); 151 SC_Helper_TaxRule_Ex::setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_rule_id=NULL, $tax_adjust=0, $product_id, $product_class_id, $pref_id, $country_id); 157 152 } 158 153 … … 163 158 * @return 164 159 */ 165 function setTaxRule($tax_rate, $tax_adjust=0, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) 166 { 167 // デフォルトの設定とtax_rateの値が同じ場合は登録しない 168 $arrRet = SC_Helper_TaxRule_Ex::getTaxRule(); 169 if( $arrRet['tax_rate'] == $tax_rate ) { 170 return; 171 } 160 function setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_rule_id=NULL, $tax_adjust=0, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) 161 { 162 $table = 'dtb_tax_rule'; 163 $arrValues = array(); 164 $arrValues['calc_rule'] = $calc_rule; 165 $arrValues['tax_rate'] = $tax_rate; 166 $arrValues['tax_adjust'] = $tax_adjust; 167 $arrValues['apply_date'] = $apply_date; 168 $arrValues['member_id'] = $_SESSION['member_id']; 169 $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; 170 172 171 // 新規か更新か? 173 172 $objQuery =& SC_Query_Ex::getSingletonInstance(); 174 $where = 'product_id=? and product_class_id=? and pref_id=? and country_id=?'; 173 if($tax_rule_id == NULL && $product_id != 0 && $product_class_id != 0){ 174 $where = 'product_id = ? AND product_class_id= ? AND pref_id = ? AND country_id = ?'; 175 175 $arrVal = array($product_id, $product_class_id, $pref_id, $country_id); 176 $arrCheck = $objQuery->select('*', 'dtb_tax_rule', $where, $arrVal); 177 178 if(empty($arrCheck)) { 176 $arrCheck = $objQuery->getRow('*', 'dtb_tax_rule', $where, $arrVal); 177 $tax_rule_id = $arrCheck['tax_rule_id']; 178 } 179 180 if($tax_rule_id == NULL) { 179 181 // 税情報を新規 180 $table = 'dtb_tax_rule'; 181 $arrValues = array(); 182 // todo idを計算して設定する必要あり(nextvalに変更?) 183 $arrTaxruleid = $objQuery->select('max(tax_rule_id)', 'dtb_tax_rule'); 184 $arrValues['tax_rule_id'] = $arrTaxruleid[0]['max(tax_rule_id)']+1; 182 // INSERTの実行 183 $arrValues['tax_rule_id'] = $objQuery->nextVal('dtb_tax_rule_tax_rule_id'); 185 184 $arrValues['country_id'] = $country_id; 186 185 $arrValues['pref_id'] = $pref_id; 187 186 $arrValues['product_id'] = $product_id; 188 187 $arrValues['product_class_id'] = $product_class_id; 189 $arrValues['calc_rule'] = $arrRet['calc_rule']; 190 $arrValues['tax_rate'] = $tax_rate; 191 $arrValues['tax_adjust'] = $tax_adjust; 192 $arrValues['apply_date'] = $arrRet['apply_date']; 193 $arrValues['create_date'] = 'CURRENT_TIMESTAMP'; 194 $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; 188 $arrValues['create_date'] = 'CURRENT_TIMESTAMP'; 195 189 196 190 $objQuery->insert($table, $arrValues); 197 191 } else { 198 192 // 税情報を更新 199 $objQuery->update('dtb_tax_rule', array('tax_rate' => $tax_rate), $where, $arrVal); 193 $where = 'tax_rule_id = ?'; 194 $ret = $objQuery->update($table, $arrValues, $where, array($tax_rule_id)); 200 195 } 201 196 } … … 224 219 $where .= ' AND del_flg = 0'; 225 220 } 226 return $objQuery->getRow('*', 'dtb_tax_rule', 'tax_rule_id = ?', array($tax_rule_id));221 return $objQuery->getRow('*', 'dtb_tax_rule', $where, array($tax_rule_id)); 227 222 } 228 223 … … 240 235 } 241 236 242 function registerTaxRuleData($sqlval) {243 $objQuery =& SC_Query_Ex::getSingletonInstance();244 245 $sqlval['apply_date'] = SC_Utils_Ex::sfGetTimestampistime($sqlval['apply_date_year'], $sqlval['apply_date_month'], $sqlval['apply_date_day'],$sqlval['apply_date_hour'], $sqlval['apply_date_minutes']);246 247 unset($sqlval['apply_date_year']);248 unset($sqlval['apply_date_month']);249 unset($sqlval['apply_date_day']);250 unset($sqlval['apply_date_hour']);251 unset($sqlval['apply_date_minutes']);252 253 $tax_rule_id = $sqlval['tax_rule_id'];254 $sqlval['update_date'] = 'CURRENT_TIMESTAMP';255 // 新規登録256 if ($tax_rule_id == '') {257 // INSERTの実行258 $sqlval['create_date'] = 'CURRENT_TIMESTAMP';259 $sqlval['tax_rule_id'] = $objQuery->nextVal('dtb_tax_rule_tax_rule_id');260 $ret = $objQuery->insert('dtb_tax_rule', $sqlval);261 // 既存編集262 } else {263 unset($sqlval['tax_rule_id']);264 unset($sqlval['create_date']);265 $where = 'tax_rule_id = ?';266 $ret = $objQuery->update('dtb_tax_rule', $sqlval, $where, array($tax_rule_id));267 }268 return ($ret) ? $sqlval['tax_rule_id'] : FALSE;269 }270 271 237 /** 272 238 * 税規約の削除. … … 275 241 * @return void 276 242 */ 277 public function deleteTaxRuleData($tax_rule_id) 278 { 279 $objQuery =& SC_Query_Ex::getSingletonInstance(); 243 function deleteTaxRuleData($tax_rule_id) 244 { 245 $objQuery =& SC_Query_Ex::getSingletonInstance(); 246 247 $sqlval = array(); 280 248 $sqlval['del_flg'] = 1; 281 249 $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; … … 283 251 $objQuery->update('dtb_tax_rule', $sqlval, $where, array($tax_rule_id)); 284 252 } 285 286 287 253 }
Note: See TracChangeset
for help on using the changeset viewer.