8 require_once(dirname(__FILE__) .
'/../../lib/Model.php');
33 $where =
" WHERE `bid` = '" . $this->
esc($this->bid) .
"'";
35 if ($cnd[
'cnd_kana'] !=
'') {
36 $where .=
" AND `kana` LIKE '%" . $this->
esc($cnd[
'cnd_kana']) .
"%'";
39 if ($cnd[
'cnd_name'] !=
'') {
40 $where .=
" AND `name` LIKE '%" . $this->
esc($cnd[
'cnd_name']) .
"%'";
48 $sql =
"SELECT COUNT(*) AS `cnt` FROM `t_item`" . $where;
51 return $rec[0][
'cnt'];
61 $sql =
"SELECT * FROM `t_item`" . $where
62 .
" ORDER BY `ccd`, `account`, `item`, `kana`"
63 .
" LIMIT " . $pg[
'ofst'] .
", " . $pg[
'rpp']
71 'last' => $pg[
'last'],
72 'page' => $pg[
'page'],
80 $sql =
"SELECT * FROM `t_item` WHERE `id` = '" . $this->
esc($id) .
"'";
84 return (empty($rec[0])) ? [] : $rec[0];
94 $ccd = substr($param[
'kcode'], 0, 4);
95 $account = substr($param[
'kcode'], 4, 2);
99 $sql =
"UPDATE `t_item` SET"
100 .
" `ccd`" .
" = '" . $this->
esc($ccd) .
"'"
101 .
", `account`" .
" = '" . $this->
esc($account) .
"'"
102 .
", `item`" .
" = '" . $this->
esc($param[
'item']) .
"'"
103 .
", `kana`" .
" = '" . $this->
esc($param[
'kana']) .
"'"
104 .
", `name`" .
" = '" . $this->
esc($param[
'name']) .
"'"
105 .
", `valid_flg`" .
" = " . $this->
esc($param[
'valid_flg'])
106 .
", `update_person`" .
" = " . $_SESSION[
'minfo'][
'mid']
107 .
" WHERE `id` = '" . $this->
esc($param[
'id']) .
"'"
109 $ans = $this->
query($sql);
111 }
catch(Exception $e) {
112 $err = $e->getMessage();
133 $ccd = substr($param[
'kcode'], 0, 4);
134 $account = substr($param[
'kcode'], 4, 2);
138 $sql =
"INSERT INTO `t_item`"
139 .
" (`bid`, `kcd`, `ccd`, `account`, `item`, `kana`, `name`, `valid_flg`, `delete_flg`, `edit_flg`, `update_person`)"
141 .
" ('" . $this->
esc($param[
'bid']) .
"'"
142 .
", '" . sprintf(
"%s%s%02d", $ccd, $account, $param[
'item']) .
"'"
143 .
", '" . $this->
esc($ccd) .
"'"
144 .
", '" . $this->
esc($account) .
"'"
145 .
", '" . $this->
esc($param[
'item']) .
"'"
146 .
", '" . $this->
esc($param[
'kana']) .
"'"
147 .
", '" . $this->
esc($param[
'name']) .
"'"
148 .
", " . $param[
'valid_flg']
151 .
", '" . $_SESSION[
'minfo'][
'mid'].
"'"
154 $ans = $this->
query($sql);
156 }
catch(Exception $e) {
157 $err = $e->getMessage();
171 public function delete($param) {
181 $sql =
"DELETE FROM `t_item` WHERE `id` = '" . $this->
esc($id) .
"'";
182 $ans = $this->
query($sql);
184 }
catch(Exception $e) {
185 $err = $e->getMessage();
201 $ccd = substr($param[
'kcode'], 0, 4);
202 $account = substr($param[
'kcode'], 4, 2);
206 $sql =
"SELECT COUNT(*) AS `cnt`"
208 .
" WHERE `bid` = '" . $this->
esc($param[
'bid']) .
"'"
209 .
" AND `ccd` = '" . $this->
esc($ccd) .
"'"
210 .
" AND `account` = '" . $this->
esc($account) .
"'"
211 .
" AND `item` = '" . $this->
esc($param[
'item']) .
"'"
214 if (empty($param[
'insert'])) {
215 $sql .=
" AND `id` != '" . $this->
esc($param[
'id']) .
"'";
222 return $rec[0][
'cnt'];
234 $sql =
"UPDATE `t_item` SET"
235 .
" `valid_flg` = " . $param[
'valid_flg']
236 .
" WHERE `id` = '" . $this->
esc($param[
'id']) .
"'"
238 $ans = $this->
query($sql);
240 }
catch(Exception $e) {
241 $err = $e->getMessage();