mirror of
				https://github.com/fspc/Yellow-Bike-Database.git
				synced 2025-10-31 08:55:36 -04:00 
			
		
		
		
	Added some human interaction with Deposit Calculator.
This commit is contained in:
		
							parent
							
								
									890b8f1b15
								
							
						
					
					
						commit
						511dc81471
					
				| @ -11,11 +11,13 @@ $(function() { | ||||
| 	// paid or not?
 | ||||
| 	$(":checked").parent("td").prev().children().hide(); | ||||
| 	$(".paid").click(function() { | ||||
| 
 | ||||
| 		$.ajaxSetup({async:false}); | ||||
| 		 | ||||
| 		if ($(this).prop("checked")) {  | ||||
| 		 | ||||
| 			$(this).closest("tr").css("background-color","#E6E7E6");  | ||||
| 			$('[href*="' + this.name + '"]').hide();  | ||||
| 			console.log(this.name); | ||||
| 	    	$.post("json/transaction.php",{ paid: 1, transaction_id: this.name } ); | ||||
| 	 	}  | ||||
| 	 	else {  | ||||
| @ -24,17 +26,44 @@ $(function() { | ||||
| 	    	$('[href*="' + this.name + '"]').show();  | ||||
| 	    	$.post("json/transaction.php",{ paid: 0, transaction_id: this.name } ); | ||||
| 	  	}  | ||||
| 
 | ||||
| 			// Deposit Calculator
 | ||||
| 			var deposit = {};		 | ||||
| 			$(".deposit input").each(function(count){  | ||||
| 				deposit[count] =  this.name; | ||||
| 			});			 | ||||
| 			 | ||||
| 					 | ||||
| 			$.post("json/transaction.php",{"deposit": deposit}, function(data) { | ||||
| 				var obj = $.parseJSON(data); | ||||
| 				$.each(obj,function(k,v){ | ||||
| 					//console.log(k + "= Cash: " + v.cash + " Check: " + v.check + " Credit: " + v.credit + "\n");
 | ||||
| 					$("#" + k + "_cash span").text("$" + v.cash); | ||||
| 					$("#" + k + "_check span").text("$" + v.check); | ||||
| 					$("#" + k + "_credit span").text("$" + v.credit); | ||||
| 				}); | ||||
| 			});	  	 | ||||
| 			$.ajaxSetup({async:true});	  	 | ||||
| 	  	 | ||||
| 	}); | ||||
| 
 | ||||
| 	// Deposit Calculator
 | ||||
| 	if ( $(".paid").length ) {	 // any transactions?
 | ||||
| 
 | ||||
| 			 | ||||
| 		var deposit = {};		 | ||||
| 		$(".deposit input").each(function(count){  | ||||
| 			deposit[count] =  this.name; | ||||
| 		});			 | ||||
| 		 | ||||
| 		$.post("json/transaction.php",{"deposit": deposit}); | ||||
| 		$.post("json/transaction.php",{"deposit": deposit}, function(data) { | ||||
| 			var obj = $.parseJSON(data); | ||||
| 			$.each(obj,function(k,v){ | ||||
| 				//console.log(k + "= Cash: " + v.cash + " Check: " + v.check + " Credit: " + v.credit + "\n");
 | ||||
| 				$("#" + k + "_cash span").text("$" + v.cash); | ||||
| 				$("#" + k + "_check span").text("$" + v.check); | ||||
| 				$("#" + k + "_credit span").text("$" + v.credit); | ||||
| 			}); | ||||
| 		}); | ||||
| 	 | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -52,6 +52,7 @@ mysql_select_db($database_YBDB, $YBDB); | ||||
| 				    			. $deposit[$key + 1] . ';'; | ||||
| 					$sql = mysql_query($query, $YBDB) or die(mysql_error()); | ||||
| 					$result = mysql_fetch_assoc($sql); | ||||
| 					$result_obj[$deposit[$key]] = $result;  | ||||
| 				} else { | ||||
| 					$query = 'SELECT  SUM(IF(payment_type="check", amount, 0)) AS "check",   | ||||
| 							   			SUM(IF(payment_type="credit", amount, 0)) AS "credit",   | ||||
| @ -59,12 +60,12 @@ mysql_select_db($database_YBDB, $YBDB); | ||||
| 											FROM transaction_log WHERE paid=1 AND transaction_id <' . $deposit[$key] . ';';  | ||||
| 					$sql = mysql_query($query, $YBDB) or die(mysql_error()); | ||||
| 					$result = mysql_fetch_assoc($sql);				 | ||||
| 						 | ||||
| 					$result_obj[$deposit[$key]] = $result;	 | ||||
| 				} | ||||
| 			 | ||||
| 				echo json_encode($result); | ||||
| 
 | ||||
| 			} | ||||
| 			echo json_encode($result_obj);			 | ||||
| 			 | ||||
| 		}  else {  // more deposits than visible
 | ||||
| 
 | ||||
| 				$limit = $visible_count + 1; | ||||
| @ -86,10 +87,11 @@ mysql_select_db($database_YBDB, $YBDB); | ||||
| 					    			. $transaction_id[$key + 1] . ';'; | ||||
| 						$sql = mysql_query($query, $YBDB) or die(mysql_error()); | ||||
| 						$result = mysql_fetch_assoc($sql); | ||||
| 						echo json_encode($result); | ||||
| 					} | ||||
| 						$result_obj[$transaction_id[$key]] = $result; 	 | ||||
| 					}									 | ||||
| 				 | ||||
| 				} // foreach								
 | ||||
| 				} // foreach
 | ||||
| 				echo json_encode($result_obj);								 | ||||
| 		} // end  else for invisibles
 | ||||
| 
 | ||||
| 	} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user