mirror of
				https://github.com/fspc/Yellow-Bike-Database.git
				synced 2025-10-31 17:05:36 -04:00 
			
		
		
		
	jQuery - when paid checkbox is checked/unchecked database is updated.
Color changes, too.
This commit is contained in:
		
							parent
							
								
									87eb7fba3a
								
							
						
					
					
						commit
						508ed7c3b9
					
				| @ -24,6 +24,7 @@ function resetTimer() | ||||
| <title>YBDB</title> | ||||
| <link href="css_yb_standard.css" rel="stylesheet" type="text/css" /> | ||||
| <script src="js/jquery-2.1.1.js"></script> | ||||
| <script src="js/transaction.js"></script> | ||||
| 
 | ||||
| </head> | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										20
									
								
								js/transaction.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								js/transaction.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| /* jQuery fun with transactions - Jonathan Rosenbaum */ | ||||
| 
 | ||||
| // currently css is just hardwired, but that reflects the coding style of YBDB :)
 | ||||
| 
 | ||||
| $(function() { | ||||
| 
 | ||||
| 	$(".paid").click(function() { | ||||
| 		if ($(this).prop("checked")) {  | ||||
| 			//console.log("turn color on");
 | ||||
| 			$(this).closest("tr").css("background-color","#99CC33");   | ||||
| 	    	$.post("json/transaction.php",{ paid: 1, transaction_id: this.name } ); | ||||
| 	 	}  | ||||
| 	  	else {  | ||||
| 	  		//console.log("turn color off");
 | ||||
| 	    	$(this).closest("tr").css("background-color","transparent");   | ||||
| 	    	$.post("json/transaction.php",{ paid: 0, transaction_id: this.name } ); | ||||
| 	  	}  | ||||
| 	}); | ||||
| 
 | ||||
| }); | ||||
							
								
								
									
										21
									
								
								json/transaction.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								json/transaction.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| <?php | ||||
| 
 | ||||
| require_once('../Connections/YBDB.php'); | ||||
| mysql_select_db($database_YBDB, $YBDB); | ||||
| 
 | ||||
| 
 | ||||
| 	if(isset($_POST['paid'])) { | ||||
| 			if ($_POST['paid'] == 1) {			 | ||||
| 			 | ||||
| 				$query = "UPDATE transaction_log SET paid=1 WHERE transaction_id=" . $_POST['transaction_id'] . ";";				  | ||||
| 				$result = mysql_query($query, $YBDB) or die(mysql_error()); | ||||
| 		 | ||||
| 			} elseif($_POST['paid'] == 0) { | ||||
| 	  			 | ||||
| 			  	$query = "UPDATE transaction_log SET paid=0 WHERE transaction_id=" . $_POST['transaction_id'] . ";"; | ||||
| 			  	$result = mysql_query($query, $YBDB) or die(mysql_error());	     | ||||
| 		 | ||||
| 			} | ||||
| 	  } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -385,7 +385,10 @@ FROM transaction_log WHERE transaction_id = $trans_id; "; | ||||
|         <?php while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { //do { ?>
 | ||||
|          | ||||
|         <form method="post" name="FormView_<?php echo $row_Recordset1['transaction_id']; ?>" action="<?php echo $editFormAction; ?>"> | ||||
|           <tr bordercolor='#CCCCCC' <?php echo ((intval($row_Recordset1['transaction_id']) == intval($trans_id)) ? "bgcolor='#CCCC33'" :  "")?> >
 | ||||
|           <tr bordercolor='#CCCCCC' <?php | ||||
|           	echo ((intval($row_Recordset1['transaction_id']) == intval($trans_id)) ? "bgcolor='#CCCC33'" :  ""); | ||||
|           	if ($row_Recordset1['paid'] == 1) { echo "bgcolor='#99CC33'"; }  | ||||
|           ?> >
 | ||||
|           <td><?php echo $row_Recordset1['shop_id']; ?></td>
 | ||||
| 		  <td><?php echo $row_Recordset1['date_wday']; ?></td>
 | ||||
| 		  <td><?php echo $row_Recordset1['transaction_type']; ?></td>
 | ||||
| @ -393,7 +396,11 @@ FROM transaction_log WHERE transaction_id = $trans_id; "; | ||||
| 		  <td><?php echo $row_Recordset1['description_with_locations']; ?> </td>
 | ||||
| 		  <td><?php echo $row_Recordset1['full_name']; ?></td>
 | ||||
| 		  <td><?php $record_trans_id = $row_Recordset1['transaction_id']; echo "<a href=\"{$_SERVER['PHP_SELF']}?trans_id={$record_trans_id}\">edit</a>"; ?></td>
 | ||||
| 		  <td><input class="paid" type="checkbox" name="<?php echo $row_Recordset1['transaction_id']; ?>" value="<?php echo $row_Recordset1['paid']; ?>"></td> | ||||
| 		  <td><input class="paid" type="checkbox" name="<?php echo $row_Recordset1['transaction_id']; ?>"  | ||||
| 		  														value="<?php echo $row_Recordset1['paid'];?>" | ||||
| 																<?php if ($row_Recordset1['paid'] == 1) { echo "  checked"; }  ?>		  														
 | ||||
| 		  														> | ||||
| 		  </td> | ||||
| 	    </tr> | ||||
|           <input type="hidden" name="MM_insert" value="FormUpdate"> | ||||
|           <input type="hidden" name="shop_visit_id" value="<?php echo $row_Recordset1['transaction_id']; ?>"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user