- Timestamp:
- 2013/11/18 15:20:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/class/helper/SC_Helper_Address.php
r23124 r23279 39 39 public function registAddress($sqlval) 40 40 { 41 if (self::delivErrorCheck($sqlval)) { 42 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, "入力値が不正です。<br />正しい値を入力してください。"); 43 SC_Response_Ex::actionExit(); 44 } 45 41 46 $objQuery =& SC_Query_Ex::getSingletonInstance(); 42 47 $customer_id = $sqlval['customer_id']; 43 48 $other_deliv_id = $sqlval['other_deliv_id']; 44 49 45 // 顧客IDのチェック46 if (is_null($customer_id) || !is_numeric($customer_id) || !preg_match("/^\d+$/", $customer_id)) {47 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '顧客IDを正しく指定して下さい。');48 }49 50 // 追加 50 51 if (strlen($other_deliv_id == 0)) { 51 // 別のお届け先登録数の取得52 $deliv_count = $objQuery->count('dtb_other_deliv', 'customer_id = ?', array($customer_id));53 52 // 別のお届け先最大登録数に達している場合、エラー 53 $from = 'dtb_other_deliv'; 54 $where = 'customer_id = ?'; 55 $arrVal = array($customer_id); 56 $deliv_count = $objQuery->count($from, $where, $arrVal); 54 57 if ($deliv_count >= DELIV_ADDR_MAX) { 55 58 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先最大登録数に達しています。'); 59 SC_Response_Ex::actionExit(); 56 60 } 57 61 58 // 実行62 // 別のお届け先を追加 59 63 $sqlval['other_deliv_id'] = $objQuery->nextVal('dtb_other_deliv_other_deliv_id'); 60 $objQuery->insert( 'dtb_other_deliv', $sqlval);64 $objQuery->insert($from, $sqlval); 61 65 62 66 // 変更 63 67 } else { 64 $deliv_count = $objQuery->count('dtb_other_deliv','other_deliv_id = ?' ,array($other_deliv_id)); 68 $from = 'dtb_other_deliv'; 69 $where = 'customer_id = ? AND other_deliv_id = ?'; 70 $arrVal = array($customer_id, $other_deliv_id); 71 $deliv_count = $objQuery->count($from, $where, $arrVal); 65 72 if ($deliv_count != 1) { 66 73 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '一致する別のお届け先がありません。'); 74 SC_Response_Ex::actionExit(); 67 75 } 68 76 69 // 実行70 $objQuery->update( 'dtb_other_deliv', $sqlval, 'other_deliv_id = ?', array($other_deliv_id));77 // 別のお届け先を変更 78 $objQuery->update($from, $sqlval, $where, $arrVal); 71 79 } 72 80 } … … 75 83 * お届け先を取得 76 84 * 77 * @param integer $other_deliv_id85 * @param integer $other_deliv_id 78 86 * @return array() 79 87 */ 80 88 public function getAddress($other_deliv_id) 81 89 { 90 $objCustomer = new SC_Customer_Ex(); 91 $customer_id = $objCustomer->getValue('customer_id'); 92 93 if (self::delivErrorCheck(array('customer_id' => $customer_id, 'other_deliv_id' => $other_deliv_id))) { 94 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, "入力値が不正です。<br />正しい値を入力してください。"); 95 SC_Response_Ex::actionExit(); 96 } 97 82 98 $objQuery =& SC_Query_Ex::getSingletonInstance(); 83 $address = $objQuery->select('*', 'dtb_other_deliv', 'other_deliv_id = ?', array($other_deliv_id)); 84 85 return $address ? $address[0] : FALSE; 99 100 $col = '*'; 101 $from = 'dtb_other_deliv'; 102 $where = 'customer_id = ? AND other_deliv_id = ?'; 103 $arrVal = array($customer_id, $other_deliv_id); 104 $address = $objQuery->getRow($col, $from, $where, $arrVal); 105 106 return $address; 86 107 } 87 108 … … 95 116 public function getList($customer_id, $startno = '') 96 117 { 118 if (self::delivErrorCheck(array('customer_id' => $customer_id))) { 119 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, "入力値が不正です。<br />正しい値を入力してください。"); 120 SC_Response_Ex::actionExit(); 121 } 122 97 123 $objQuery =& SC_Query_Ex::getSingletonInstance(); 98 124 $objQuery->setOrder('other_deliv_id DESC'); … … 102 128 } 103 129 104 return $objQuery->select('*', 'dtb_other_deliv', 'customer_id = ?', array($customer_id)); 130 $col = '*'; 131 $from = 'dtb_other_deliv'; 132 $where = 'customer_id = ?'; 133 $arrVal = array($customer_id); 134 return $objQuery->select($col, $from, $where, $arrVal); 105 135 } 106 136 … … 113 143 public function deleteAddress($other_deliv_id) 114 144 { 115 $where = 'other_deliv_id = ?'; 145 $objCustomer = new SC_Customer_Ex(); 146 $customer_id = $objCustomer->getValue('customer_id'); 147 148 if (self::delivErrorCheck(array('customer_id' => $customer_id, 'other_deliv_id' => $other_deliv_id))) { 149 SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, "入力値が不正です。<br />正しい値を入力してください。"); 150 SC_Response_Ex::actionExit(); 151 } 152 116 153 $objQuery =& SC_Query_Ex::getSingletonInstance(); 117 $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id)); 154 155 $from = 'dtb_other_deliv'; 156 $where = 'customer_id = ? AND other_deliv_id = ?'; 157 $arrVal = array($customer_id, $other_deliv_id); 158 $objQuery->delete($from, $where, $arrVal); 118 159 } 119 160 … … 142 183 return $objErr->arrErr; 143 184 } 185 186 /** 187 * お届け先エラーチェック 188 * 189 * @param array $arrParam 190 * @return true / false 191 */ 192 public function delivErrorCheck($arrParam) 193 { 194 $error_flg = false; 195 196 if (is_null($arrParam['customer_id']) || !is_numeric($arrParam['customer_id']) || !preg_match("/^\d+$/", $arrParam['customer_id'])) { 197 $error_flg = true; 198 } 199 200 if (strlen($arrParam['other_deliv_id']) > 0 && (!is_numeric($arrParam['other_deliv_id']) || !preg_match("/^\d+$/", $arrParam['other_deliv_id']))) { 201 $error_flg = true; 202 } 203 204 return $error_flg; 205 } 144 206 }
Note: See TracChangeset
for help on using the changeset viewer.
