同期式の読み込みに変えても問題無さそうなところは非同期から同期式に変更。
伝票編集画面のアイテム一覧表示に作成したWidgetを使うように変更。
@@ -12,33 +12,25 @@ | ||
12 | 12 | |
13 | 13 | app.pageTitle = "事務所一覧"; |
14 | 14 | app.pageLoadHandler = function (pageElem) { |
15 | + | |
16 | + var box = getElementsByCssSelector(pageElem, ".box")[0]; | |
17 | + box.appendChild(createNodeWithScript(syncLoad("master/office/list_widget.html"))); | |
18 | + var config = digestCookie(location.hash); | |
19 | + var cols = null; | |
20 | + if ('cols' in config) { | |
21 | + cols = config.cols; | |
22 | + } | |
23 | + w = new MasterOfficeListWidget(box, cols); | |
24 | + w.type = "link"; | |
25 | + if (app.privileges["Master/Office"]) { | |
26 | + w.linkCaption = "編集"; | |
27 | + $("addBtn").show(); | |
28 | + }else { | |
29 | + w.linkCaption = "閲覧"; | |
30 | + $("addBtn").remove(); | |
31 | + } | |
15 | 32 | |
16 | - app.ajaxRequest( | |
17 | - 'master/office/list_widget.html', | |
18 | - 'get', | |
19 | - {}, | |
20 | - function (transport) { | |
21 | - var box = getElementsByCssSelector(pageElem, ".box")[0]; | |
22 | - box.appendChild(createNodeWithScript(transport.responseText)); | |
23 | - var config = digestCookie(location.hash); | |
24 | - var cols = null; | |
25 | - if ('cols' in config) { | |
26 | - cols = config.cols; | |
27 | - } | |
28 | - w = new MasterOfficeListWidget(box, cols); | |
29 | - w.type = "link"; | |
30 | - if (app.privileges["Master/Office"]) { | |
31 | - w.linkCaption = "編集"; | |
32 | - $("addBtn").show(); | |
33 | - }else { | |
34 | - w.linkCaption = "閲覧"; | |
35 | - $("addBtn").remove(); | |
36 | - } | |
37 | - | |
38 | - w.search(); | |
39 | - | |
40 | - } | |
41 | - ); | |
33 | + w.search(); | |
42 | 34 | |
43 | 35 | }; |
44 | 36 |
@@ -215,11 +215,10 @@ | ||
215 | 215 | |
216 | 216 | this.getSelectedRecords = function () { |
217 | 217 | |
218 | - if (type != "select") { | |
218 | + if (this.type != "select") { | |
219 | 219 | return null; |
220 | 220 | } |
221 | - | |
222 | - var elems = getElementsByCssSelector(form, "name=item_serials[]") | |
221 | + var elems = getElementsByCssSelector(form, 'input[name="item_serials[]"]'); | |
223 | 222 | var recs = {}; |
224 | 223 | for (var i=0, len=elems.length; i<len; ++i) { |
225 | 224 | var elem = elems[i]; |
@@ -128,7 +128,7 @@ | ||
128 | 128 | |
129 | 129 | class ItemData |
130 | 130 | { |
131 | - static function SelectList($con, $criteria, $assoc = false) | |
131 | + static function SelectList($con, $criteria) | |
132 | 132 | { |
133 | 133 | $stmt = buildStatement( |
134 | 134 | $con, |
@@ -185,7 +185,7 @@ | ||
185 | 185 | $criteria |
186 | 186 | ); |
187 | 187 | $stmt->execute(); |
188 | - return getMetasAndRecords($stmt, ($assoc ? PDO::FETCH_BOTH : PDO::FETCH_NUM)); | |
188 | + return getMetasAndRecords($stmt, PDO::FETCH_BOTH); | |
189 | 189 | } |
190 | 190 | |
191 | 191 | static function Add($con, $params) |
@@ -14,31 +14,23 @@ | ||
14 | 14 | app.pageTitle = "品目情報一覧"; |
15 | 15 | app.pageLoadHandler = function (pageElem) { |
16 | 16 | |
17 | - app.ajaxRequest( | |
18 | - 'master/item/list_widget.html', | |
19 | - 'get', | |
20 | - {}, | |
21 | - function (transport) { | |
22 | - var box = getElementsByCssSelector(pageElem, ".box")[0]; | |
23 | - box.appendChild(createNodeWithScript(transport.responseText)); | |
24 | - | |
25 | - w = new MasterItemListWidget(box); | |
26 | - w.type = "link"; | |
27 | - w.linkCaption = "編集"; | |
28 | - if (app.privileges["Master/Item"]) { | |
29 | - w.linkCaption = "編集"; | |
30 | - $("addBtn").show(); | |
31 | - $("addBtn2").show(); | |
32 | - }else { | |
33 | - w.linkCaption = "閲覧"; | |
34 | - $("addBtn").remove(); | |
35 | - $("addBtn2").remove(); | |
36 | - } | |
37 | - w.search(); | |
38 | - | |
39 | - } | |
40 | - ); | |
41 | - | |
17 | + var box = getElementsByCssSelector(pageElem, ".box")[0]; | |
18 | + box.appendChild(createNodeWithScript(syncLoad("master/item/list_widget.html"))); | |
19 | + | |
20 | + w = new MasterItemListWidget(box); | |
21 | + w.type = "link"; | |
22 | + w.linkCaption = "編集"; | |
23 | + if (app.privileges["Master/Item"]) { | |
24 | + w.linkCaption = "編集"; | |
25 | + $("addBtn").show(); | |
26 | + $("addBtn2").show(); | |
27 | + }else { | |
28 | + w.linkCaption = "閲覧"; | |
29 | + $("addBtn").remove(); | |
30 | + $("addBtn2").remove(); | |
31 | + } | |
32 | + w.search(); | |
33 | + | |
42 | 34 | }; |
43 | 35 | |
44 | 36 | </script> |
@@ -0,0 +1,220 @@ | ||
1 | + | |
2 | +<style type="text/css"> | |
3 | + | |
4 | +td { | |
5 | + padding-left : 0.2em; | |
6 | + padding-right : 0.2em; | |
7 | +} | |
8 | + | |
9 | +</style> | |
10 | + | |
11 | +<form method="get"> | |
12 | + | |
13 | +<div class="template" style="display:none"><!-- | |
14 | + | |
15 | +<table class="grid" style="width:100%;"> | |
16 | + <thead> | |
17 | + <tr class="resizable"> | |
18 | + <th style="width:4em;"> | |
19 | + <img | |
20 | + src="img/lenz.png" | |
21 | + style="cursor:pointer;" | |
22 | + onclick="toggleVisibility(getElementsByCssSelector(getParentElementByCssSelector(this, 'form'), '.search_condition')[0]);" | |
23 | + /> | |
24 | + <img | |
25 | + src="img/tool.png" | |
26 | + style="cursor:pointer;" | |
27 | + onclick="toggleVisibility(getElementsByCssSelector(getParentElementByCssSelector(this, 'form'), '.grid_setting')[0]);" | |
28 | + /> | |
29 | + </th> | |
30 | +#cols{ | |
31 | +#id <th>ユーザーID</th> | |
32 | +#name <th>名前</th> | |
33 | +#role_name <th>役割</th> | |
34 | +#sales_code <th>営業コード</th> | |
35 | +#slip_count <th>伝票カウント</th> | |
36 | +#tel <th>電話番号</th> | |
37 | +#email <th>e-mail</th> | |
38 | +#url <th>URL</th> | |
39 | +#status <th>状態</th> | |
40 | +#} | |
41 | + </tr> | |
42 | + </thead> | |
43 | + <tbody> | |
44 | +<% | |
45 | +for (var i=0; i<records.length; ++i) { | |
46 | + var rec = records[i]; | |
47 | +%> | |
48 | + <tr> | |
49 | + <td style="text-align:center;"><A href="#master/user/edit?id=<%= rec['id'] %>"><%=linkCaption%></A></td> | |
50 | +#cols{ | |
51 | +#id <td><%= rec['id'].escapeHTML() %></td> | |
52 | +#name <td><%= rec['name'].escapeHTML() %></td> | |
53 | +#role_name <td><%= rec['role_name'].escapeHTML() %></td> | |
54 | +#sales_code <td><%= rec['sales_code'] %></td> | |
55 | +#slip_count <td class="number"><%= rec['slip_count'] %></td> | |
56 | +#tel <td><%= rec['tel'].escapeHTML() %></td> | |
57 | +#email <td><%= rec['email'].escapeHTML() %></td> | |
58 | +#url <td><%= rec['url'].escapeHTML() %></td> | |
59 | +#status <td><%= rec['status'] %></td> | |
60 | +#} | |
61 | + </tr> | |
62 | +<% } %> | |
63 | + </tbody> | |
64 | +</table> | |
65 | +--> | |
66 | +</div> | |
67 | + | |
68 | +<div class="instance"></div> | |
69 | + | |
70 | +<div | |
71 | + class="search_condition search_box curvy" | |
72 | + style="position:absolute; left:100px; top:200px; z-index:10; visibility:hidden; " | |
73 | +> | |
74 | + <div class="titlebar draggable unselectable" unselectable="on" dragtarget=".search_condition" style=""> | |
75 | + 検索設定 | |
76 | + <div class="curvy titlebar_closebtn" onclick="this.parentNode.parentNode.style.visibility='hidden';">×</div> | |
77 | + </div> | |
78 | + <div style="margin-top:0.3em;"> | |
79 | + <table> | |
80 | + <tr> | |
81 | + <td style="min-width:6em;">ユーザーID</td> | |
82 | + <td style="min-width:8em;"><INPUT type="text" name="criteria[id]" class="word" value="" autofocus /></td> | |
83 | + </tr> | |
84 | + <tr> | |
85 | + <td>役割</td><td><INPUT type="text" name="criteria[role_serial]" class="word" value="" /></td> | |
86 | + </tr> | |
87 | + <tr> | |
88 | + <td>名前</td><td><INPUT type="text" name="criteria[name]" value="" style="ime-mode:active;" /></td> | |
89 | + </tr> | |
90 | + <tr> | |
91 | + <td>営業コード</td><td><INPUT type="text" name="criteria[sales_code]" class="sales_code" value="" /></td> | |
92 | + </tr> | |
93 | + <tr> | |
94 | + <td>電話番号</td><td><INPUT type="text" name="criteria[tel]" value="" style="ime-mode:inactive;" /></td> | |
95 | + </tr> | |
96 | + <tr> | |
97 | + <td>e-mail</td><td><INPUT type="text" name="criteria[email]" value="" style="ime-mode:inactive;" /></td> | |
98 | + </tr> | |
99 | + <tr> | |
100 | + <td>URL</td><td><INPUT type="text" name="criteria[url]" value="" style="ime-mode:inactive;" /></td> | |
101 | + </tr> | |
102 | + <tr> | |
103 | + <td>状態</td><td><INPUT type="text" name="criteria[status]" value="" /></td> | |
104 | + </tr> | |
105 | + </table> | |
106 | + </div> | |
107 | + <div style="text-align:center; height:2em; margin-top:0.3em;"> | |
108 | + <INPUT class="update_btn" type="button" value="表更新" accesskey="s" /> | |
109 | + <INPUT type="button" value="クリア" onclick="clearForm('criteria[');" /> | |
110 | + </div> | |
111 | +</div> | |
112 | + | |
113 | +<div | |
114 | + class="grid_setting search_box curvy" | |
115 | + style="position:absolute; width:30em; left:200px; top:200px; z-index:10; visibility:hidden;" | |
116 | +> | |
117 | + <div class="titlebar draggable unselectable" unselectable="on" dragtarget=".grid_setting" style=""> | |
118 | + 表項目設定 | |
119 | + <div class="curvy titlebar_closebtn" onclick="this.parentNode.parentNode.style.visibility='hidden';">×</div> | |
120 | + </div> | |
121 | + <div class="doublelist" style="margin-top:0.3em;"></div> | |
122 | + <div style="text-align:center; height:2em; margin-top:0.3em;"> | |
123 | + <INPUT class="update_btn" type="button" value="適用" /> | |
124 | + <INPUT class="reset_btn" type="button" value="リセット" /> | |
125 | + </div> | |
126 | +</div> | |
127 | + | |
128 | +</form> | |
129 | + | |
130 | +<script language="JavaScript"> | |
131 | + | |
132 | +var MasterUserListWidget = function (nodes, cols) { | |
133 | + | |
134 | + var form = getElementsByCssSelector(nodes, "form")[0]; | |
135 | + var searchConditionWnd = getElementsByCssSelector(nodes, ".search_condition")[0]; | |
136 | + var gridSettingWnd = getElementsByCssSelector(nodes, ".grid_setting")[0]; | |
137 | + | |
138 | + Event.observe( | |
139 | + getElementsByCssSelector(searchConditionWnd, ".update_btn")[0], | |
140 | + "click", | |
141 | + function () { | |
142 | + this.search(); | |
143 | + }.bind(this) | |
144 | + ); | |
145 | + | |
146 | + var data = null; | |
147 | + var dlWidget = null; | |
148 | + | |
149 | + var defaultCols = [ | |
150 | + {value:'id', text:'ユーザーID'}, | |
151 | + {value:'name', text:'名前'}, | |
152 | + {value:'role_name', text:'役割'}, | |
153 | + {value:'sales_code', text:'営業コード'}, | |
154 | + {value:'slip_count', text:'伝票カウント'}, | |
155 | + {value:'email', text:'e-mail'}, | |
156 | + {value:'url', text:'URL'}, | |
157 | + {value:'status', text:'状態'} | |
158 | + ]; | |
159 | + | |
160 | + var dlNode = getElementsByCssSelector(nodes, ".doublelist")[0]; | |
161 | + var src = syncLoad('js/doublelist.html'); | |
162 | + dlNode.appendChild(createNodeWithScript(src)); | |
163 | + dlWidget = new DoubleListWidget(dlNode, '表示列', '非表示列'); | |
164 | + | |
165 | + if (!cols) { | |
166 | + cols = collectMember(defaultCols, 'value'); | |
167 | + } | |
168 | + dlWidget.set(defaultCols, cols); | |
169 | + | |
170 | + Event.observe( | |
171 | + getElementsByCssSelector(gridSettingWnd, ".update_btn")[0], | |
172 | + "click", | |
173 | + function () { | |
174 | + this.setRecords(); | |
175 | + }.bind(this) | |
176 | + ); | |
177 | + | |
178 | + Event.observe( | |
179 | + getElementsByCssSelector(gridSettingWnd, ".reset_btn")[0], | |
180 | + "click", | |
181 | + function () { | |
182 | + dlWidget.reset(defaultCols); | |
183 | + } | |
184 | + ); | |
185 | + | |
186 | + this.search = function () { | |
187 | + var params = Form.serialize(form, true); | |
188 | + for (var i in params) { | |
189 | + if (!params[i].length) { | |
190 | + delete params[i]; | |
191 | + } | |
192 | + } | |
193 | + app.ajaxRequest( | |
194 | + "master/user/list", | |
195 | + 'get', | |
196 | + params, | |
197 | + function(transport) { | |
198 | + data = transport.responseJSON; | |
199 | + this.setRecords(); | |
200 | + }.bind(this) | |
201 | + ); | |
202 | + }; | |
203 | + | |
204 | + this.setRecords = function () { | |
205 | + data.linkCaption = this.linkCaption; | |
206 | + data.type = this.type; | |
207 | + data.cols = dlWidget.get(); | |
208 | + var templateEl = getElementsByCssSelector(form, ".template")[0]; | |
209 | + var instanceEl = getElementsByCssSelector(form, ".instance")[0]; | |
210 | + app.templateUpdate(templateEl, instanceEl, data); | |
211 | + app.setHelpers(); | |
212 | + } | |
213 | + | |
214 | + this.getCols = function () { | |
215 | + return dlWidget.get(); | |
216 | + }; | |
217 | + | |
218 | +}; | |
219 | + | |
220 | +</script> |
@@ -4,198 +4,38 @@ | ||
4 | 4 | <A id="addBtn" style="display:none;" href="#master/user/add" accesskey="1">1. 新規追加</A> |
5 | 5 | </div> |
6 | 6 | |
7 | -<style type="text/css"> | |
7 | +<div class="box"></div> | |
8 | 8 | |
9 | -td { | |
10 | - padding-left : 0.2em; | |
11 | - padding-right : 0.2em; | |
12 | -} | |
13 | - | |
14 | -</style> | |
15 | - | |
16 | -<form id="form" method="get" action="list"> | |
17 | - | |
18 | -<div | |
19 | - id="search_condition" | |
20 | - class="search_box curvy" | |
21 | - style="position:absolute; left:100px; top:200px; z-index:10; visibility:hidden; " | |
22 | -> | |
23 | - <div class="titlebar draggable unselectable" unselectable="on" dragtarget="#search_condition" style=""> | |
24 | - 検索設定 | |
25 | - <div class="curvy titlebar_closebtn" onclick="$('search_condition').style.visibility='hidden';">×</div> | |
26 | - </div> | |
27 | - <div style="margin-top:0.3em;"> | |
28 | - <table> | |
29 | - <tr> | |
30 | - <td style="min-width:6em;">ユーザーID</td> | |
31 | - <td style="min-width:8em;"><INPUT type="text" name="criteria[id]" class="word" value="" autofocus /></td> | |
32 | - </tr> | |
33 | - <tr> | |
34 | - <td>役割</td><td><INPUT type="text" name="criteria[role_serial]" class="word" value="" /></td> | |
35 | - </tr> | |
36 | - <tr> | |
37 | - <td>名前</td><td><INPUT type="text" name="criteria[name]" value="" style="ime-mode:active;" /></td> | |
38 | - </tr> | |
39 | - <tr> | |
40 | - <td>営業コード</td><td><INPUT type="text" name="criteria[sales_code]" class="sales_code" value="" /></td> | |
41 | - </tr> | |
42 | - <tr> | |
43 | - <td>電話番号</td><td><INPUT type="text" name="criteria[tel]" value="" style="ime-mode:inactive;" /></td> | |
44 | - </tr> | |
45 | - <tr> | |
46 | - <td>e-mail</td><td><INPUT type="text" name="criteria[email]" value="" style="ime-mode:inactive;" /></td> | |
47 | - </tr> | |
48 | - <tr> | |
49 | - <td>URL</td><td><INPUT type="text" name="criteria[url]" value="" style="ime-mode:inactive;" /></td> | |
50 | - </tr> | |
51 | - <tr> | |
52 | - <td>状態</td><td><INPUT type="text" name="criteria[status]" value="" /></td> | |
53 | - </tr> | |
54 | - </table> | |
55 | - </div> | |
56 | - <div style="text-align:center; height:2em; margin-top:0.3em;"> | |
57 | - <INPUT type="button" value="s 実行" accesskey="s" onclick="search(this.form);" /> | |
58 | - <INPUT type="button" value="クリア" onclick="clearForm('criteria[');" /> | |
59 | - </div> | |
60 | -</div> | |
61 | - | |
62 | -<div | |
63 | - class="grid_setting search_box curvy" | |
64 | - style="position:absolute; width:30em; left:200px; top:200px; z-index:10; visibility:hidden;" | |
65 | -> | |
66 | - <div class="titlebar draggable unselectable" unselectable="on" dragtarget=".grid_setting" style=""> | |
67 | - 表項目設定 | |
68 | - <div class="curvy titlebar_closebtn" onclick="this.parentNode.parentNode.style.visibility='hidden';">×</div> | |
69 | - </div> | |
70 | - <div style="margin-top:0.3em;" id="doublelist"></div> | |
71 | - <div style="text-align:center; height:2em; margin-top:0.3em;"> | |
72 | - <INPUT type="button" value="適用" onclick="setRecords();" /> | |
73 | - <INPUT type="button" value="リセット" onclick="dlWidget.reset(defaultCols);" /> | |
74 | - </div> | |
75 | -</div> | |
76 | - | |
77 | -<div id="template" style="display:none"><!-- | |
78 | - | |
79 | -<table class="grid" style="width:100%;"> | |
80 | - <thead> | |
81 | - <tr class="resizable"> | |
82 | - <th style="width:4em;"> | |
83 | - <A href="javascript:toggleVisibility($('search_condition'));"><img src="img/lenz.png" border=0 | |
84 | - /></A><A href="javascript:toggleVisibility(getElementsByCssSelector(document, '.grid_setting')[0]);"><img src="img/tool.png" border=0 /></A> | |
85 | - </th> | |
86 | -#cols{ | |
87 | -#id <th>ユーザーID</th> | |
88 | -#name <th>名前</th> | |
89 | -#role_name <th>役割</th> | |
90 | -#sales_code <th>営業コード</th> | |
91 | -#slip_count <th>伝票カウント</th> | |
92 | -#tel <th>電話番号</th> | |
93 | -#email <th>e-mail</th> | |
94 | -#url <th>URL</th> | |
95 | -#status <th>状態</th> | |
96 | -#} | |
97 | - </tr> | |
98 | - </thead> | |
99 | - <tbody> | |
100 | -<% | |
101 | -for (var i=0; i<records.length; ++i) { | |
102 | - var rec = records[i]; | |
103 | -%> | |
104 | - <tr> | |
105 | - <td style="text-align:center;"><A href="#master/user/edit?id=<%= rec['id'] %>"><%=linkCaption%></A></td> | |
106 | -#cols{ | |
107 | -#id <td><%= rec['id'].escapeHTML() %></td> | |
108 | -#name <td><%= rec['name'].escapeHTML() %></td> | |
109 | -#role_name <td><%= rec['role_name'].escapeHTML() %></td> | |
110 | -#sales_code <td><%= rec['sales_code'] %></td> | |
111 | -#slip_count <td class="number"><%= rec['slip_count'] %></td> | |
112 | -#tel <td><%= rec['tel'].escapeHTML() %></td> | |
113 | -#email <td><%= rec['email'].escapeHTML() %></td> | |
114 | -#url <td><%= rec['url'].escapeHTML() %></td> | |
115 | -#status <td><%= rec['status'] %></td> | |
116 | -#} | |
117 | - </tr> | |
118 | -<% } %> | |
119 | - </tbody> | |
120 | -</table> | |
121 | ---> | |
122 | -</div> | |
123 | - | |
124 | -<div id="list"> | |
125 | -</div> | |
126 | - | |
127 | -</form> | |
128 | - | |
129 | 9 | <script language="JavaScript"> |
130 | 10 | |
131 | -var data = null; | |
132 | -var dlWidget = null; | |
11 | +var w = null; | |
133 | 12 | |
134 | -search = function (form) { | |
135 | - var params = Form.serialize(form, true); | |
136 | - for (var i in params) { | |
137 | - if (!params[i].length) { | |
138 | - delete params[i]; | |
139 | - } | |
140 | - } | |
141 | - app.ajaxRequest( | |
142 | - null, | |
143 | - 'get', | |
144 | - params, | |
145 | - function(transport) { | |
146 | - data = transport.responseJSON; | |
147 | - if (data.privileges["Master/User"]) { | |
148 | - data.linkCaption = "編集"; | |
149 | - $("addBtn").show(); | |
150 | - }else { | |
151 | - data.linkCaption = "閲覧"; | |
152 | - $("addBtn").remove(); | |
153 | - } | |
154 | - setRecords(); | |
155 | - }, | |
156 | - function () { | |
157 | - alert('Something went wrong...') | |
158 | - } | |
159 | - ); | |
160 | -}; | |
161 | - | |
162 | -setRecords = function () { | |
163 | - data.cols = dlWidget.get(); | |
164 | - app.templateUpdate($("template"), $("list"), data); | |
165 | - app.setHelpers(); | |
166 | -} | |
167 | - | |
168 | -var defaultCols = [ | |
169 | - {value:'id', text:'ユーザーID'}, | |
170 | - {value:'name', text:'名前'}, | |
171 | - {value:'role_name', text:'役割'}, | |
172 | - {value:'sales_code', text:'営業コード'}, | |
173 | - {value:'slip_count', text:'伝票カウント'}, | |
174 | - {value:'email', text:'e-mail'}, | |
175 | - {value:'url', text:'URL'}, | |
176 | - {value:'status', text:'状態'} | |
177 | -]; | |
178 | - | |
179 | 13 | app.pageTitle = "ユーザー一覧"; |
14 | +app.pageLoadHandler = function (pageElem) { | |
180 | 15 | |
181 | -app.pageLoadHandler = function () { | |
16 | + var box = getElementsByCssSelector(pageElem, ".box")[0]; | |
17 | + box.appendChild(createNodeWithScript(syncLoad('master/user/list_widget.html'))); | |
182 | 18 | var config = digestCookie(location.hash); |
19 | + var cols = null; | |
183 | 20 | if ('cols' in config) { |
184 | - var cols = config.cols; | |
21 | + cols = config.cols; | |
22 | + } | |
23 | + w = new MasterUserListWidget(box, cols); | |
24 | + w.type = "link"; | |
25 | + if (app.privileges["Master/User"]) { | |
26 | + w.linkCaption = "編集"; | |
27 | + $("addBtn").show(); | |
185 | 28 | }else { |
186 | - var cols = collectMember(defaultCols, 'value'); | |
29 | + w.linkCaption = "閲覧"; | |
30 | + $("addBtn").remove(); | |
187 | 31 | } |
32 | + | |
33 | + w.search(); | |
188 | 34 | |
189 | - var dlNode = $("doublelist"); | |
190 | - var src = syncLoad('js/doublelist.html'); | |
191 | - dlNode.appendChild(createNodeWithScript(src)); | |
192 | - dlWidget = new DoubleListWidget(dlNode, '表示列', '非表示列'); | |
193 | - dlWidget.set(defaultCols, cols); | |
194 | - search($('form')); | |
195 | 35 | }; |
196 | 36 | |
197 | 37 | app.pageUnloadHandler = function () { |
198 | - var config = {"cols":data.cols}; | |
38 | + var config = {"cols":w.getCols()}; | |
199 | 39 | return config; |
200 | 40 | }; |
201 | 41 |
@@ -1,32 +0,0 @@ | ||
1 | -<?php | |
2 | - | |
3 | -// Copyright (c) 2009 Katsuhisa Yuasa <berupon [at] gmail.com> | |
4 | -// License http://www.opensource.org/licenses/mit-license.html | |
5 | - | |
6 | -require_once('model.php'); | |
7 | -require_once(dirname(__FILE__) . '/../master/item/model.php'); | |
8 | - | |
9 | -$memberNames = explodeTrim(' | |
10 | - code, | |
11 | - category_serial, | |
12 | - supply_name, | |
13 | - supply_model_number, | |
14 | - product_name, | |
15 | - product_model_number, | |
16 | - attribute1, | |
17 | - attribute2, | |
18 | - attribute3, | |
19 | - attribute4, | |
20 | - counting_type | |
21 | -'); | |
22 | - | |
23 | -$criteria = prepareArray($memberNames, $params, 'criteria'); | |
24 | - | |
25 | -list($metas, $records) = ItemData::SelectList($con, $criteria, true); | |
26 | -outputJSON( | |
27 | - array( | |
28 | - 'ci' => array_flip(getColumnValues($metas, 'name')), | |
29 | - 'records' => $records | |
30 | - ) | |
31 | -); | |
32 | - |
@@ -1,183 +0,0 @@ | ||
1 | - | |
2 | -<script language="JavaScript"> | |
3 | - | |
4 | -var searchData = null; | |
5 | - | |
6 | -function search() { | |
7 | - var form = $('search_form'); | |
8 | - var params = Form.serialize(form, true); | |
9 | - for (var i in params) { | |
10 | - if (!params[i].length) { | |
11 | - delete params[i]; | |
12 | - } | |
13 | - } | |
14 | - app.ajaxRequest( | |
15 | - "slip/item_list", | |
16 | - 'get', | |
17 | - params, | |
18 | - function(transport) { | |
19 | - searchData = transport.responseJSON; | |
20 | - var list = $("itemlist"); | |
21 | - app.templateUpdate($("itemlist_template"), list, searchData); | |
22 | - var elems = list.getElementsByTagName("table"); | |
23 | - if (elems.length == 1) { | |
24 | - mergeRepeativeValueRows(elems[0], [3,-1], [1,2,3,4,5,6,7,8,9,10]); | |
25 | - } | |
26 | - ResizableColumns(); | |
27 | - }, | |
28 | - function () { | |
29 | - alert('Something went wrong...') | |
30 | - } | |
31 | - ); | |
32 | -} | |
33 | - | |
34 | -function getSelectedRecords() { | |
35 | - | |
36 | - var elems = filterByForm( | |
37 | - document.getElementsByName('item_serials[]'), | |
38 | - $('search_form') | |
39 | - ); | |
40 | - var recs = {}; | |
41 | - for (var i=0, len=elems.length; i<len; ++i) { | |
42 | - var elem = elems[i]; | |
43 | - if (elem.checked) { | |
44 | - var rec = searchData.records[i]; | |
45 | - recs[rec.serial] = rec; | |
46 | - } | |
47 | - } | |
48 | - return recs; | |
49 | -} | |
50 | - | |
51 | -</script> | |
52 | - | |
53 | -<form id="search_form"> | |
54 | - | |
55 | - <div id="search_condition" class="search_box curvy" style="position:fixed; left:100px; top:200px; min-width:16em; z-index:10; visibility:hidden;"> | |
56 | - <div class="titlebar draggable unselectable" unselectable="on" dragtarget="#search_condition" style=""> | |
57 | - 検索設定 | |
58 | - <div class="curvy titlebar_closebtn" onclick="$('search_condition').style.visibility='hidden';">×</div> | |
59 | - </div> | |
60 | - <div style="padding:0.2em;"> | |
61 | - <table border=0 style="width:100%;"> | |
62 | - <tr> | |
63 | - <td>品目分類</td> | |
64 | - <td> | |
65 | - <select id='criteria[category_serial]' name='criteria[category_serial]' onChange=""> | |
66 | - </select> | |
67 | - </td> | |
68 | - </tr> | |
69 | - <tr> | |
70 | - <td>コード</td> | |
71 | - <td><INPUT type="text" name="criteria[code]" value="" style="ime-mode:inactive;" /></td> | |
72 | - </tr> | |
73 | - <tr> | |
74 | - <td>仕入れ名称</td> | |
75 | - <td><INPUT type="text" name="criteria[supply_name]" value="" style="ime-mode:active;" /></td> | |
76 | - </tr> | |
77 | - <tr> | |
78 | - <td>仕入れ型番</td> | |
79 | - <td><INPUT type="text" name="criteria[supply_model_number]" value="" /></td> | |
80 | - </tr> | |
81 | - <tr> | |
82 | - <td>販売名称</td> | |
83 | - <td><INPUT type="text" name="criteria[product_name]" value="" style="ime-mode:active;" /></td> | |
84 | - </tr> | |
85 | - <tr> | |
86 | - <td>販売型番</td> | |
87 | - <td><INPUT type="text" name="criteria[product_model_number]" value="" /></td> | |
88 | - </tr> | |
89 | - <tr> | |
90 | - <td>属性1</td> | |
91 | - <td><INPUT type="text" name="criteria[attribute1]" value="" /></td> | |
92 | - </tr> | |
93 | - <tr> | |
94 | - <td>属性2</td> | |
95 | - <td><INPUT type="text" name="criteria[attribute2]" value="" /></td> | |
96 | - </tr> | |
97 | - <tr> | |
98 | - <td>属性3</td> | |
99 | - <td><INPUT type="text" name="criteria[attribute3]" value="" /></td> | |
100 | - </tr> | |
101 | - <tr> | |
102 | - <td>属性4</td> | |
103 | - <td><INPUT type="text" name="criteria[attribute4]" value="" /></td> | |
104 | - </tr> | |
105 | - <tr> | |
106 | - <td>数量単位</td> | |
107 | - <td><INPUT type="text" name="criteria[counting_type]" value="" style="ime-mode:active;" /></td> | |
108 | - </tr> | |
109 | - </table> | |
110 | - </div> | |
111 | - <div style="text-align:center; height:2em; margin-top:0.3em;"> | |
112 | - <INPUT type="button" value="表更新" accesskey="s" onclick="search();" /> | |
113 | - <INPUT type="button" value="クリア" onclick="clearForm('criteria[');" /> | |
114 | - </div> | |
115 | - </div> | |
116 | - | |
117 | - <div id="itemlist_template" style="display:none"><!-- | |
118 | - <table class="grid" style="" onclick="selectInnerCheckBox(event);"> | |
119 | - <thead> | |
120 | - <tr> | |
121 | - <th></th> | |
122 | - <th colspan=3>品目分類</th> | |
123 | - <th colspan=7> </th> | |
124 | - </tr> | |
125 | - | |
126 | - <tr class="resizable"> | |
127 | - <th style="width:3em;" onclick="toggleVisibility($('search_condition'));" class="search_button"></th> | |
128 | - <th>コード</th> | |
129 | - <th>仕入れ名称</th> | |
130 | - <th>仕入れ型番</th> | |
131 | - <th>販売名称</th> | |
132 | - <th>販売型番</th> | |
133 | - <th style="">属性1</th> | |
134 | - <th style="">属性2</th> | |
135 | - <th style="">属性3</th> | |
136 | - <th style="">属性4</th> | |
137 | - <th style="">数量単位</th> | |
138 | - </tr> | |
139 | - </thead> | |
140 | - <tbody> | |
141 | -<% | |
142 | -var lastCategorySerial = -1; | |
143 | -for (var i=0; i<records.length; ++i) { | |
144 | - var rec = records[i]; | |
145 | - if (rec[ci.category_serial] != lastCategorySerial) { | |
146 | - lastCategorySerial = rec[ci.category_serial]; | |
147 | - var attributes = data.item_category_attributes[rec[ci.category_serial]]; | |
148 | -%> | |
149 | - <tr style="background-color:#cccccc;"> | |
150 | - <th class="category"> </th> | |
151 | - <th class="category" colspan=5><%= rec[ci.category_path].escapeHTML() %></th> | |
152 | - <th class="category"><%= attributes[0]['name'].escapeHTML() %><BR><%= attributes[0]['counting_type'].escapeHTML() %></th> | |
153 | - <th class="category"><%= attributes[1]['name'].escapeHTML() %><BR><%= attributes[1]['counting_type'].escapeHTML() %></th> | |
154 | - <th class="category"><%= attributes[2]['name'].escapeHTML() %><BR><%= attributes[2]['counting_type'].escapeHTML() %></th> | |
155 | - <th class="category"><%= attributes[3]['name'].escapeHTML() %><BR><%= attributes[3]['counting_type'].escapeHTML() %></th> | |
156 | - <th class="category"> </th> | |
157 | - </tr> | |
158 | -<% } %> | |
159 | - <tr> | |
160 | - <td style="text-align:center;"><input type='checkbox' name='item_serials[]' value='<%=rec[ci.serial]%>' ></td> | |
161 | - <td><%= rec[ci.code].escapeHTML() %> </td> | |
162 | - <td><%= rec[ci.supply_name].escapeHTML() %> </td> | |
163 | - <td><%= rec[ci.supply_model_number].escapeHTML() %> </td> | |
164 | - <td><%= rec[ci.product_name].escapeHTML() %> </td> | |
165 | - <td><%= rec[ci.product_model_number].escapeHTML() %> </td> | |
166 | - <td style="text-align:right;"><%= rec[ci.attribute1].escapeHTML() %> </td> | |
167 | - <td style="text-align:right;"><%= rec[ci.attribute2].escapeHTML() %> </td> | |
168 | - <td style="text-align:right;"><%= rec[ci.attribute3].escapeHTML() %> </td> | |
169 | - <td style="text-align:right;"><%= rec[ci.attribute4].escapeHTML() %> </td> | |
170 | - <td><%= rec[ci.counting_type].escapeHTML() %> </td> | |
171 | - </tr> | |
172 | -<% } %> | |
173 | - </tbody> | |
174 | - </table> | |
175 | ---> | |
176 | - </div> | |
177 | - | |
178 | - <div id="itemlist"></div> | |
179 | - | |
180 | - <input id="itemlist_confirm_btn" type="button" value="決定" style="margin-top:5px;" /><BR> | |
181 | - | |
182 | -</form> | |
183 | - |
@@ -208,7 +208,10 @@ | ||
208 | 208 | |
209 | 209 | </form> |
210 | 210 | |
211 | -<div id="itemlist_box" style="padding:1em; display:none;"></div> | |
211 | +<div id="itemlist" style="padding:1em; display:none;"> | |
212 | + <div class="box"></div> | |
213 | + <input class="confirm_btn" type="button" value="決定" style="margin-top:5px;" /><BR> | |
214 | +</div> | |
212 | 215 | |
213 | 216 | <script language="JavaScript"> |
214 | 217 |
@@ -292,26 +295,24 @@ | ||
292 | 295 | } |
293 | 296 | |
294 | 297 | var first = true; |
298 | +var itemListWidget = null; | |
295 | 299 | |
296 | 300 | openItemList = function () { |
301 | + | |
297 | 302 | if (first) { |
298 | - app.ajaxRequest( | |
299 | - 'slip/item_list.html', | |
300 | - 'get', | |
301 | - {}, | |
302 | - function (transport) { | |
303 | - var box = $("itemlist_box"); | |
304 | - box.appendChild(createNodeWithScript(transport.responseText)); | |
305 | - setSelectOptions($('criteria[category_serial]'), recordsToArray(data.item_category_records, 'serial', 'path')); | |
306 | - search(); | |
307 | - Event.observe($('itemlist_confirm_btn'), 'click', addSelectedItem); | |
308 | - app.setPopup(box); | |
309 | - Element.show(box); | |
310 | - first = false; | |
311 | - app.showPopup(); | |
312 | - app.setHelpers(); | |
313 | - } | |
314 | - ); | |
303 | + var itemListNode = $("itemlist"); | |
304 | + var box = getElementsByCssSelector(itemListNode, ".box")[0]; | |
305 | + box.appendChild(createNodeWithScript(syncLoad("master/item/list_widget.html"))); | |
306 | + itemListWidget = new MasterItemListWidget(box); | |
307 | + itemListWidget.type = "select"; | |
308 | + itemListWidget.search(); | |
309 | + var confirmBtn = getElementsByCssSelector(itemListNode, "input.confirm_btn")[0]; | |
310 | + Event.observe(confirmBtn, 'click', addSelectedItem); | |
311 | + app.setPopup(itemListNode); | |
312 | + Element.show(itemListNode); | |
313 | + first = false; | |
314 | + app.showPopup(); | |
315 | + app.setHelpers(); | |
315 | 316 | }else { |
316 | 317 | app.showPopup(); |
317 | 318 | } |
@@ -319,7 +320,7 @@ | ||
319 | 320 | |
320 | 321 | addSelectedItem = function () { |
321 | 322 | |
322 | - var recs = getSelectedRecords(); | |
323 | + var recs = itemListWidget.getSelectedRecords(); | |
323 | 324 | if (items) { |
324 | 325 | collectInputData(); |
325 | 326 | var keys = Object.keys(recs); |