changeset 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
files develop/index.php develop/js/taggingtext.js develop/models/_extractapp_func.php develop/views/Extractapp/taggingtext.php interface/check_sections.php interface/check_sections_details.php
diffstat 6 files changed, 140 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/develop/index.php	Fri Feb 06 09:44:17 2015 +0100
+++ b/develop/index.php	Mon Feb 09 12:28:09 2015 +0100
@@ -2,10 +2,16 @@
 <html>
 <head>
 <title></title>
+<script src="../../js/jquery-1.10.2.min.js"></script>
 
-<script src="../../js/jquery-1.10.2.min.js"></script>
+<!-- Bootstrap -->
+<!-- <link href="../../css/bootstrap.min.css" rel="stylesheet">
+-->
+<script src="../../js/bootstrap.min.js"></script>
+
+
+
 <script src="../../js/taggingtext.js"></script>
-
 </head>
 <body>
 <?php
--- a/develop/js/taggingtext.js	Fri Feb 06 09:44:17 2015 +0100
+++ b/develop/js/taggingtext.js	Mon Feb 09 12:28:09 2015 +0100
@@ -589,20 +589,6 @@
     //el.innerHTML = str.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString);
 }
 
-function smartRegexSave() {
-    var x;
-    var name=prompt("Please enter this Regex name",RegexLoadedName);
-    if (name!=null){
-        $.ajax({
-            type : 'POST',
-            url : '../../models/_extractapp_func.php',
-            async : false,
-            data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name
-        }).done(function(result) {
-            alert("Saved!");
-        });
-    }
-}
 
 function smartRegexLoad(section_id) {
     $('#load_regex_div').html("");
--- a/develop/models/_extractapp_func.php	Fri Feb 06 09:44:17 2015 +0100
+++ b/develop/models/_extractapp_func.php	Mon Feb 09 12:28:09 2015 +0100
@@ -45,7 +45,7 @@
         } else {
             $require = $_POST['text'];
         }
-        
+  
         file_put_contents( $data_path."regex_files/".$_POST['filename'].".txt", $require);   
     }
 }
--- a/develop/views/Extractapp/taggingtext.php	Fri Feb 06 09:44:17 2015 +0100
+++ b/develop/views/Extractapp/taggingtext.php	Mon Feb 09 12:28:09 2015 +0100
@@ -206,6 +206,20 @@
 }
 
 
+function smartRegexSave() {
+    var x;
+    var name=prompt("Please enter this Regex name",RegexLoadedName);
+    if (name!=null){
+        $.ajax({
+            type : 'POST',
+            url : '../../models/_extractapp_func.php',
+            async : false,
+            data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name
+        }).done(function(result) {
+            alert("Saved!");
+        });
+    }
+}
 
 
 $(document).on("change", '#smartRegexPopUpSelectWord', function (e) {
--- 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>
 
+
+
--- a/interface/check_sections_details.php	Fri Feb 06 09:44:17 2015 +0100
+++ b/interface/check_sections_details.php	Mon Feb 09 12:28:09 2015 +0100
@@ -113,8 +113,7 @@
         <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js" type="text/javascript"></script>
         <!--<script src="js/check_sections.js" charset="utf-8"></script>!-->
         
-
-
+        
 </head>
 <body>
 		<div id="loading">...</div>
@@ -139,14 +138,14 @@
 
 				?>
 				<table>
-					<thead>Show editing record:
+					<thead>Show editing records:
 						<button id="show_all">Show all</button>
 						<button id="close">Close</button>
 					</thead>
 					<tbody>
 						<tr>
-							<td>Editor(version)</td>
-							<td>Date/Time</td>
+							<td id="editor_th"></td>
+							<td id="date_th"></td>
 						</tr>
 						<tr>
 							<td><div id="editor"></div></td>
@@ -187,6 +186,8 @@
 		document.getElementById("show_all").onclick = function(){showAll()};
 
 		function showAll() {
+			document.getElementById("editor_th").innerHTML = "Editor(version)";
+			document.getElementById("date_th").innerHTML = "Date/Time";
 			
 			<?php
 				$editors = "";
@@ -212,6 +213,8 @@
 		document.getElementById("close").onclick = function(){closeAll()};
 
 		function closeAll() {
+			document.getElementById("editor_th").innerHTML = "";
+			document.getElementById("date_th").innerHTML = "";
 			document.getElementById("editor").innerHTML = "";
 			document.getElementById("date").innerHTML = "";
 		}