1
1
<? $ this ->template ->add_js ('system/application/views/modules/dashboard/jquery.dashboardtable.js ' )?>
2
- <? if (isset ($ _REQUEST ['action ' ]) && 'deleted ' ==$ _REQUEST ['action ' ]): ?>
3
- <div class="saved">
4
- <a style="float:right;" href="?zone=all-books#tabs-all-books">clear</a>
5
- Book has been deleted
6
- </div><br />
7
- <? endif ?>
8
- <? if (isset ($ _REQUEST ['action ' ]) && 'added ' ==$ _REQUEST ['action ' ]): ?>
9
- <div class="saved">
10
- <a style="float:right;" href="?zone=all-books#tabs-all-books">clear</a>
11
- Book has been added
12
- </div><br />
13
- <? endif ?>
2
+
14
3
<style>
15
4
.admin-nav-wrap {
16
- margin:7px 0;
17
- float:left;
5
+ margin:12px 0px 0px 0px;
18
6
width:100%;
19
7
}
20
8
.book-search-form {
52
40
var rel = $this.attr('rel');
53
41
var id = $this.parents('tr').find("td[property='id']").html();
54
42
var ids = new Array;
55
- var elements = $this.parent( ).find("span");
43
+ var elements = $this.closest('td' ).find("span");
56
44
for (var j = 0; j < elements.length; j++) {
45
+ if (!$(elements[j]).attr('id')) continue;
57
46
ids.push( $(elements[j]).attr('id') );
58
47
}
59
48
var post = {'id':id};
67
56
$.post('api/'+resource, post, function(data) {
68
57
selector.html('');
69
58
var option = $('<option value="0">(Select none)</option>');
70
- selector.append(option);
71
59
for (var j = 0; j < data.length; j++) {
72
60
var rel_id = data[j].user_id;
73
61
if ('undefined'==typeof(rel_id)) rel_id = data[j].book_id;
74
62
var title = data[j].fullname;
75
63
if ('undefined'==typeof(title)) title = data[j].title;
76
64
var selected = (ids.indexOf(rel_id) != -1) ? true : false;
65
+ console.log(ids);
77
66
var option = $('<option value="'+rel_id+'"'+((selected)?' selected':'')+'>'+title+'</option>');
78
67
selector.append(option);
79
68
}
@@ -124,52 +113,37 @@ function submit_value_selector($this) {
124
113
}
125
114
</script>
126
115
127
- <form style="display:inline-block" action="<?= confirm_slash (base_url ())?> system/dashboard#tabs-all-books" method="post">
116
+ <? if (isset ($ _GET ['error ' ]) && $ _GET ['error ' ]==1 ): ?>
117
+ <div class="error" style="max-width:none; margin-bottom:16px;">Title is a required field<a style="float:right;" href="?book_id=<?= ((isset ($ book ->book_id ))?$ book ->book_id :0 )?> &zone=all-books#tabs-all-books">clear</a></div>
118
+ <? endif ; ?>
119
+ <? if (isset ($ _REQUEST ['action ' ]) && 'deleted ' ==$ _REQUEST ['action ' ]): ?>
120
+ <div class="saved" style="max-width:none; margin-bottom:16px;">
121
+ <a style="float:right;" href="?zone=all-books#tabs-all-books">clear</a>
122
+ Book has been deleted
123
+ </div>
124
+ <? endif ?>
125
+ <? if (isset ($ _REQUEST ['action ' ]) && 'added ' ==$ _REQUEST ['action ' ]): ?>
126
+ <div class="saved" style="max-width:none; margin-bottom:16px;">
127
+ <a style="float:right;" href="?zone=all-books#tabs-all-books">clear</a>
128
+ Book has been added and is present in the list below
129
+ </div>
130
+ <? endif ?>
131
+
132
+ <form style="margin:10px 0px 18px 0px; white-space:nowrap;" action="<?= confirm_slash (base_url ())?> system/dashboard#tabs-all-books" method="post">
128
133
<input type="hidden" name="zone" value="all-books" />
129
134
<input type="hidden" name="action" value="do_add_book" />
130
- Add new book: <input type="text" name="title" value="title" style="width:200px;" onfocus="if (this.value=='title') this.value='';" />
131
- <select name="user_id">
132
- <option value="0">(Initial author)</option>
135
+ <span style="float:left; margin-right:6px;">Add new book:</span>
136
+ <input type="text" name="title" value="" placeholder="Title" style="width:200px;float:left;" />
137
+ <input type="text" name="subtitle" value="" placeholder="Subtitle" style="width:200px;float:left;margin-left:8px;" />
138
+ <select name="user_id" style="font-size:12px; float:left; margin-left:8px; margin-right:8px; padding-top:1px; padding-bottom:0px;">
139
+ <option value="0">Initial author</option>
133
140
<? foreach ($ users as $ user ): ?>
134
141
<option value="<?= $ user ->user_id ?> "><?= $ user ->fullname ?> </option>
135
142
<? endforeach ?>
136
- </select>
137
- <input type="submit" value="Go" class="generic_button" />
138
- </form>
139
- <div class="admin-nav-wrap">
140
- <? if (!empty ($ books )): ?>
141
- <?
142
- if ((count ($ books )-1 ) != $ total )
143
- $ count = count ($ books );
144
- else
145
- $ count = count ($ books )-1 ;
146
- ?>
147
- <? if ($ start !== 0 || (count ($ books )-1 ) == $ total ): ?>
148
- <? if ($ start !== 0 ): ?>
149
- <span class="prev"><a href="<?= confirm_slash (base_url ())?> system/dashboard?zone=all-books&start=<?= $ start -$ total?> &total=<?= $ total?> #tabs-all-books">Prev page</a></span>
150
-
151
- <? endif ?>
152
- <b class="total"><?= $ start +1 ?> - <?= $ start + $ count?> </b>
153
- <? if (count ($ books )-1 == $ total ): ?>
154
- <span class="next"><a href="<?= confirm_slash (base_url ())?> system/dashboard?zone=all-books&start=<?= $ start +$ total?> &total=<?= $ total?> #tabs-all-books">Next page</a></span>
155
- <? endif ?>
156
- <form style="display:inline-block" class="jump-form">
157
- <span> Go to page:</span>
158
- <input style="text-align:right" placeholder="<?= $ start /$ total +1 ?> " type="text" class="jump-to-page" size="2" />
159
- </form>
160
-
161
- <? endif ?>
162
- <? endif ?>
163
- <form class="book-search-form">
164
- <input placeholder="Find Book" type="text" class="book-search" size="20" />
165
- <input style="vertical-align:bottom;" type="submit" value="Search" class="generic_button" />
166
- <?= (isset ($ _REQUEST ['id ' ]) && is_numeric ($ _REQUEST ['id ' ])) ? ' Showing book ID ' .$ _REQUEST ['id ' ].' ' : '' ?>
167
- <a href="<?= confirm_slash (base_url ())?> system/dashboard?zone=all-books&start=<?= $ start?> &total=<?= $ total?> #tabs-all-books">clear</a>
168
- </form>
169
- </div>
170
-
171
-
143
+ </select>
144
+ <input type="submit" value="Add" style="padding:3px 8px 1px 8px !important; float:left;" class="generic_button default" />
172
145
<br clear="both" />
146
+ </form>
173
147
174
148
<div class="table_wrapper">
175
149
<table cellspacing="0" cellpadding="0" class="tablesorter">
@@ -192,6 +166,7 @@ function submit_value_selector($this) {
192
166
<tbody>
193
167
<?
194
168
if (!empty ($ books )) {
169
+ $ count = count ($ books );
195
170
for ($ i =0 ;$ i <$ count ;$ i ++) {
196
171
$ desc_excerpt = create_excerpt ($ books [$ i ]->description );
197
172
if (strlen ($ books [$ i ]->description ) == strlen ($ desc_excerpt )) $ desc_excerpt = null ;
@@ -222,7 +197,7 @@ function submit_value_selector($this) {
222
197
}
223
198
echo '<p><a href="javascript:;" class="value_select_trigger multiple generic_button" resource="get_system_users" rel="save_book_users" style="white-space:nowrap;">Edit users</a></p> ' ;
224
199
echo "</td> \n" ;
225
- echo '<td style="white-space:nowrap;"> ' .date ( 'M j, Y g:i A ' , strtotime ($ books [$ i ]->created ) )."</td> \n" ;
200
+ echo '<td style="white-space:nowrap;"> ' .date ( 'M j, Y ' , strtotime ($ books [$ i ]->created ) )."</td> \n" ;
226
201
echo "</tr> \n" ;
227
202
}
228
203
}
@@ -231,7 +206,6 @@ function submit_value_selector($this) {
231
206
</table>
232
207
</div>
233
208
234
- <? if (!empty ($ books )): ?>
235
209
<div class="admin-nav-wrap">
236
210
<?
237
211
if ((count ($ books )-1 ) != $ total )
@@ -246,13 +220,18 @@ function submit_value_selector($this) {
246
220
<? endif ?>
247
221
<b class="total"><?= $ start +1 ?> - <?= $ start + $ count?> </b>
248
222
<? if (count ($ books )-1 == $ total ): ?>
249
- <span class="prev "><a href="<?= confirm_slash (base_url ())?> system/dashboard?zone=all-books&start=<?= $ start +$ total?> &total=<?= $ total?> #tabs-all-books">Next page</a></span>
223
+ <span class="next "><a href="<?= confirm_slash (base_url ())?> system/dashboard?zone=all-books&start=<?= $ start +$ total?> &total=<?= $ total?> #tabs-all-books">Next page</a></span>
250
224
<? endif ?>
251
225
<form style="display:inline-block" class="jump-form">
252
226
<span> Go to page:</span>
253
227
<input style="text-align:right" placeholder="<?= $ start /$ total +1 ?> " type="text" class="jump-to-page" size="2" />
254
228
</form>
229
+
255
230
<? endif ?>
231
+ <form class="book-search-form">
232
+ <input placeholder="Search for a book" type="text" class="book-search" size="20" />
233
+ <input type="submit" value="Search" class="generic_button" style="padding:3px 8px 1px 8px !important; vertical-align:top;" />
234
+ <?= (isset ($ _REQUEST ['id ' ]) && is_numeric ($ _REQUEST ['id ' ])) ? ' Showing book ID ' .$ _REQUEST ['id ' ].' ' : '' ?>
235
+ <a href="<?= confirm_slash (base_url ())?> system/dashboard?zone=all-books&start=<?= $ start?> &total=<?= $ total?> #tabs-all-books">clear</a>
236
+ </form>
256
237
</div>
257
- <? endif ?>
258
- <br />
0 commit comments