comparison interface/check_sections.php @ 9:584b1623e9ef

TOC correction list page updated
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 09 Feb 2015 18:59:24 +0100
parents da10158c6d0a
children
comparison
equal deleted inserted replaced
8:da10158c6d0a 9:584b1623e9ef
20 if (isset($_POST['func'])){ 20 if (isset($_POST['func'])){
21 switch ($_POST['func']) { 21 switch ($_POST['func']) {
22 case 'UpdateTOCstatus': 22 case 'UpdateTOCstatus':
23 UpdateTOCstatus($_POST['id'],$_POST['status']); 23 UpdateTOCstatus($_POST['id'],$_POST['status']);
24 break; 24 break;
25 25 case 'UpdateTOCcomments':
26 UpdateTOCcomments($_POST['id'],$_POST['notes']);
27 break;
26 default: 28 default:
27 # code... 29 # code...
28 break; 30 break;
29 } 31 }
32 }
33
34 function UpdateTOCcomments($id, $notes) {
35 $query = "UPDATE books SET comments='".$notes."' WHERE id='".$id."'";
36
37 $result = mysql_query($query);
38 if (!$result){
39 echo mysql_error();
40 echo ("Failed during updating books table.");
41 }
42
30 } 43 }
31 44
32 function UpdateTOCstatus($id, $status) { 45 function UpdateTOCstatus($id, $status) {
33 46
34 $query = "UPDATE books SET toc_correction='".$status."' WHERE id='".$id."'"; 47 $query = "UPDATE books SET toc_correction='".$status."' WHERE id='".$id."'";
92 105
93 106
94 // sorting by the $sort_by parameter 107 // sorting by the $sort_by parameter
95 function checkSections_sort_by($sort_by){ 108 function checkSections_sort_by($sort_by){
96 switch ($sort_by) { 109 switch ($sort_by) {
97
98
99 case 'time': 110 case 'time':
100 $query="(SELECT name AS book_name,level1,level2,period,dynasty,start_year,id, toc_correction from books ORDER BY start_year)"; 111 $query="(SELECT name AS book_name,level1,level2,period,dynasty,start_year,id, toc_correction, comments from books ORDER BY start_year)";
101 $result = mysql_query($query); 112 $result = mysql_query($query);
102 if (!$result){ 113 if (!$result){
103 echo ("Failed during selecting books table."); 114 echo ("Failed during selecting books table.");
104 } 115 }
105 116
106 echo mysql_num_rows($result)." result(s)<br><br>"; 117 echo mysql_num_rows($result)." result(s)<br><br>";
107 118
108 echo "<form autocomplete='off'>"; 119 echo "<form autocomplete='off'>";
109 echo "<table>"; 120 echo "<table>";
110 echo "<tr>"; 121 echo "<tr>";
111 echo "<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2 <td class='period'>period<td class='dynasty'>dynasty<td class='start_year'>start_year<td class='last_editor'>last_editor<td class='edit_time'>edit_time"; 122 echo "<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2
123 <td class='period'>period<td class='dynasty'>dynasty<td class='start_year'>start_year
124 <td class='last_editor'>last_editor<td class='level1'>edit_time
125 <td> <td> <td> Some notes for the book (optional)";
112 while ($row = mysql_fetch_assoc($result)) { 126 while ($row = mysql_fetch_assoc($result)) {
113 $str="<tr>"; 127 $str="<tr>";
114 $str.="<td>".$row['book_name']; 128 $str.="<td>".$row['book_name'];
115 $str.="<td>".$row['level1']; 129 $str.="<td>".$row['level1'];
116 $str.="<td>".$row['level2']; 130 $str.="<td>".$row['level2'];
130 $str.="<td><a href='check_sections_details.php?book_id=".$row['id']."&count=100"."' target='_blank'>"."click here"."</a>"; 144 $str.="<td><a href='check_sections_details.php?book_id=".$row['id']."&count=100"."' target='_blank'>"."click here"."</a>";
131 145
132 //$str.="<td> <input type='radio' name='books'".$row['id']." value='no'/> NotFinished"; 146 //$str.="<td> <input type='radio' name='books'".$row['id']." value='no'/> NotFinished";
133 switch ($row['toc_correction']) { 147 switch ($row['toc_correction']) {
134 case '0': 148 case '0':
135 $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)' checked/> Not Finished"; 149 $str.="<td> <input type='checkbox' name='".$id."' onchange='toc_status(this)' /> Finished";
136 $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)'/> Works-in-progress";
137 $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)' /> Finished";
138 break; 150 break;
139 case '1': 151 case '1':
140 $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)'/> Not Finished"; 152 $str.="<td> <input type='checkbox' name='".$id."' onchange='toc_status(this)' checked='true' /> Finished";
141 $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)' checked/> Works-in-progress";
142 $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)'/> Finished";
143 break; 153 break;
144 case '2':
145 $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)'/> Not Finished";
146 $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)'/> Works-in-progress";
147 $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)' checked/> Finished";
148 break;
149
150 default: 154 default:
151 break; 155 break;
152 } 156 }
153 157 // comments for book
158 $comments = $row['comments'];
159 if ($comments != "") {
160 $str.="<td> <textarea rows='1' cols='30' name='".$id."' maxlength='100' onchange='toc_comments(this)'>".$comments."</textarea>";
161 } else {
162 $str.="<td> <textarea rows='1' cols='30' name='".$id."' maxlength='100' onchange='toc_comments(this)'></textarea>";
163 }
154 echo $str; 164 echo $str;
155 } 165 }
156 echo "</table>"; 166 echo "</table>";
157 echo "</form>"; 167 echo "</form>";
158 break; 168 break;
195 </div> 205 </div>
196 </body> 206 </body>
197 207
198 208
199 <script type="text/javascript"> 209 <script type="text/javascript">
200 210
201 function toc_status(t) { 211 function toc_status(t) {
202 var id = t.name; 212 var id = t.name;
203 var val = t.value; 213 var val;
204 switch(val) { 214
205 case '0': 215 if (t.checked) {
206 $.ajax({ 216 val = '1';
207 url : './check_sections.php', 217 } else {
208 async : false, 218 val = '0';
209 type : 'POST',
210 data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val
211 }).done(function(result) {
212 alert('You update the status of book to "Not Finished"!');
213 });
214
215 break;
216 case '1':
217 $.ajax({
218 url : './check_sections.php',
219 async : false,
220 type : 'POST',
221 data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val
222 }).done(function(result) {
223 alert('You update the status of book to "Works-in-progress"!');
224 });
225
226 break;
227 case '2':
228 $.ajax({
229 url : './check_sections.php',
230 async : false,
231 type : 'POST',
232 data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val
233 }).done(function(result) {
234 alert('You update the status of book to "Finished"!');
235 });
236
237 break;
238 default:
239 break;
240 } 219 }
241 220
221 $.ajax({
222 url : './check_sections.php',
223 async : false,
224 type : 'POST',
225 data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val,
226 complete: function(){
227 switch (val){
228 case '0':
229 alert('You update the status of book to "Not Finished"!');
230 break;
231 case '1':
232 alert('You update the status of book to "Finished"!');
233 break;
234 }
235
236 },
237 error:function() {
238 console.log("error to update toc status");
239 alert('You have NOT updated the status of book. If this issue remains, please contact us. Thanks.');
240 }
241 });
242
243 }
244
245 function toc_comments(t) {
246 console.log(t.value);
247 var text = t.value;
248 var id = t.name;
249
250 $.ajax({
251 url: './check_sections.php',
252 async : false,
253 type: 'POST',
254 data: 'func=UpdateTOCcomments'+'&id='+id+'&notes='+text,
255 complete: function(){
256 console.log('You update the comments of book!');
257 },
258 error:function() {
259 console.log("error to update toc comments");
260 alert('You have NOT updated the status of book. If this issue remains, please contact us. Thanks.');
261 }
262 });
263
242 } 264 }
243 265
244 </script> 266 </script>
245 267
246 268