Mercurial > hg > extraction-interface
diff interface/check_sections.php @ 8:da10158c6d0a
add toc_correction status in books table. On TOC correction list page, providing the status checking box for users.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 09 Feb 2015 12:28:09 +0100 |
parents | 0e9a7c69f22c |
children | 584b1623e9ef |
line wrap: on
line diff
--- a/interface/check_sections.php Fri Feb 06 09:44:17 2015 +0100 +++ b/interface/check_sections.php Mon Feb 09 12:28:09 2015 +0100 @@ -17,6 +17,30 @@ die ('Can\'t use foo : ' . mysql_error()); } +if (isset($_POST['func'])){ + switch ($_POST['func']) { + case 'UpdateTOCstatus': + UpdateTOCstatus($_POST['id'],$_POST['status']); + break; + + default: + # code... + break; + } +} + +function UpdateTOCstatus($id, $status) { + + $query = "UPDATE books SET toc_correction='".$status."' WHERE id='".$id."'"; + + $result = mysql_query($query); + if (!$result){ + echo mysql_error(); + echo ("Failed during updating books table."); + } + +} + function checkSections($count){ /* $query="SELECT books.name AS book_name, books.level1, books.level2, books.period, books.id, sections.name, start_page, end_page, COUNT( * ) AS count @@ -70,41 +94,18 @@ // sorting by the $sort_by parameter function checkSections_sort_by($sort_by){ switch ($sort_by) { - case '_time': - $query="(SELECT name AS book_name,level1,level2,period,dynasty,start_year,id from books ORDER BY start_year)"; + + + case 'time': + $query="(SELECT name AS book_name,level1,level2,period,dynasty,start_year,id, toc_correction from books ORDER BY start_year)"; $result = mysql_query($query); if (!$result){ echo ("Failed during selecting books table."); } + echo mysql_num_rows($result)." result(s)<br><br>"; - echo mysql_num_rows($result)." result(s)<br><br>"; - echo "<table>"; - echo "<tr>"; - 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"; - while ($row = mysql_fetch_assoc($result)) { - $str="<tr>"; - $str.="<td>".$row['book_name']; - $str.="<td>".$row['level1']; - $str.="<td>".$row['level2']; - $str.="<td>".$row['period']; - $str.="<td>".$row['dynasty']; - $str.="<td>".$row['start_year']; - $str.="<td><a href='check_sections_details.php?book_id=".$row['id']."&count=100"."' target='_blank'>"."click here"."</a>"; - echo $str; - } - echo "</table>"; - break; - - case 'time': - $query="(SELECT name AS book_name,level1,level2,period,dynasty,start_year,id from books ORDER BY start_year)"; - $result = mysql_query($query); - if (!$result){ - echo ("Failed during selecting books table."); - } - - - echo mysql_num_rows($result)." result(s)<br><br>"; + echo "<form autocomplete='off'>"; echo "<table>"; echo "<tr>"; 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"; @@ -116,7 +117,8 @@ $str.="<td>".$row['period']; $str.="<td>".$row['dynasty']; $str.="<td>".$row['start_year']; - + $id = $row['id']; + // query last_editor and last_edit_time $query_editor = "(SELECT editor, date from sections_versions WHERE books_id='".$row['id']."' ORDER BY version DESC)"; $row_sections_versions = mysql_fetch_assoc(mysql_query($query_editor)); // the first one @@ -126,9 +128,33 @@ $str.="<td>".$last_edit_time; $str.="<td><a href='check_sections_details.php?book_id=".$row['id']."&count=100"."' target='_blank'>"."click here"."</a>"; + + //$str.="<td> <input type='radio' name='books'".$row['id']." value='no'/> NotFinished"; + switch ($row['toc_correction']) { + case '0': + $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)' checked/> Not Finished"; + $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)'/> Works-in-progress"; + $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)' /> Finished"; + break; + case '1': + $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)'/> Not Finished"; + $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)' checked/> Works-in-progress"; + $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)'/> Finished"; + break; + case '2': + $str.="<td> <input type='radio' name='".$id."' value='0' onClick='toc_status(this)'/> Not Finished"; + $str.="<td> <input type='radio' name='".$id."' value='1' onClick='toc_status(this)'/> Works-in-progress"; + $str.="<td> <input type='radio' name='".$id."' value='2' onClick='toc_status(this)' checked/> Finished"; + break; + + default: + break; + } + echo $str; } echo "</table>"; + echo "</form>"; break; default: @@ -168,5 +194,58 @@ ?> </div> </body> + + +<script type="text/javascript"> + + function toc_status(t) { + var id = t.name; + var val = t.value; + switch(val) { + case '0': + $.ajax({ + url : './check_sections.php', + async : false, + type : 'POST', + data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val + }).done(function(result) { + alert('You update the status of book to "Not Finished"!'); + }); + + break; + case '1': + $.ajax({ + url : './check_sections.php', + async : false, + type : 'POST', + data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val + }).done(function(result) { + alert('You update the status of book to "Works-in-progress"!'); + }); + + break; + case '2': + $.ajax({ + url : './check_sections.php', + async : false, + type : 'POST', + data : 'func=UpdateTOCstatus'+'&id='+id+'&status='+val + }).done(function(result) { + alert('You update the status of book to "Finished"!'); + }); + + break; + default: + break; + } + + } + +</script> + + + </html> + +