mirror of
				https://github.com/fspc/Yellow-Bike-Database.git
				synced 2025-11-04 09:25:34 -05:00 
			
		
		
		
	Correct transaction_id for storage transactions in history.
This commit is contained in:
		
							parent
							
								
									b54cfe2312
								
							
						
					
					
						commit
						8f8e1623df
					
				@ -609,8 +609,24 @@ $(function() {
 | 
			
		||||
 | 
			
		||||
			// Save history 				
 | 
			
		||||
			if (success === "Success") {
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
				transaction_id = $("input[name='transaction_id']").val();
 | 
			
		||||
 | 
			
		||||
				var date = $("#date").val();
 | 
			
		||||
				if (date === "") {
 | 
			
		||||
					date = "0000-00-00";				
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
				// find new transaction_id if date has changed for a storage transaction
 | 
			
		||||
				//  this is the most recent transaction_id					
 | 
			
		||||
				if ($("#date_startstorage").val() && date !== "0000-00-00") {
 | 
			
		||||
					$.post("json/transaction.php",{ most_recent_transaction_id: 1 }, function(data) {
 | 
			
		||||
						transaction_id = Number(data) + 1;
 | 
			
		||||
					} );
 | 
			
		||||
				}	
 | 
			
		||||
	
 | 
			
		||||
				
 | 
			
		||||
				var span_or_select = $("[name='sold_to']").is("span"), sold_to;
 | 
			
		||||
				if (span_or_select) {
 | 
			
		||||
					sold_to = $("#sold_to").val();
 | 
			
		||||
@ -645,7 +661,7 @@ $(function() {
 | 
			
		||||
								{   			
 | 
			
		||||
										transaction_id: transaction_id,
 | 
			
		||||
										date_startstorage: $("#date_startstorage").val(),
 | 
			
		||||
										date: $("#date").val(),
 | 
			
		||||
										date: date,
 | 
			
		||||
										transaction_type: $("#transaction_type").val(),
 | 
			
		||||
										amount: $("#amount").val(),
 | 
			
		||||
										description: $("#description").val(), 
 | 
			
		||||
@ -658,6 +674,11 @@ $(function() {
 | 
			
		||||
										anonymous: anonymous				
 | 
			
		||||
								};
 | 
			
		||||
	
 | 
			
		||||
				// transaction_id hasn't changed yet if it is a storage transaction
 | 
			
		||||
				if ($("#date_startstorage").val() && date !== "0000-00-00") {
 | 
			
		||||
					transaction_id = transaction_id - 1;
 | 
			
		||||
				}	
 | 
			
		||||
	
 | 
			
		||||
				// check for prior transactions
 | 
			
		||||
				$.post("json/transaction.php",{ history_select: 1, transaction_id: transaction_id }, function(data) {
 | 
			
		||||
			
 | 
			
		||||
@ -668,6 +689,7 @@ $(function() {
 | 
			
		||||
																	history: transaction_history });
 | 
			
		||||
					
 | 
			
		||||
					} else { // more than 1 transaction in the history
 | 
			
		||||
					
 | 
			
		||||
 | 
			
		||||
						transaction_history = $.parseJSON(data);
 | 
			
		||||
						transaction_history.push(current_transaction);
 | 
			
		||||
 | 
			
		||||
@ -89,6 +89,7 @@ $change_fund = CHANGE_FUND;
 | 
			
		||||
		}
 | 
			
		||||
	} 
 | 
			
		||||
 | 
			
		||||
	// Transaction history - fetch history
 | 
			
		||||
	if(isset($_POST['history_select'])) {
 | 
			
		||||
		$query = 'SELECT history FROM transaction_log WHERE transaction_id="' . $_POST['transaction_id'] . '";';
 | 
			
		||||
		$sql = mysql_query($query, $YBDB) or die(mysql_error());	
 | 
			
		||||
@ -100,6 +101,7 @@ $change_fund = CHANGE_FUND;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Transaction history - update transaction history
 | 
			
		||||
	if(isset($_POST['history_update'])) {
 | 
			
		||||
		$json = json_encode($_POST['history']);
 | 
			
		||||
		$query = "UPDATE transaction_log SET history='$json'" .  
 | 
			
		||||
@ -108,6 +110,14 @@ $change_fund = CHANGE_FUND;
 | 
			
		||||
		//echo ;	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Check for most recent transaction_id if transaction_id has changed
 | 
			
		||||
	if(isset($_POST['most_recent_transaction_id'])) {
 | 
			
		||||
		$query = 'SELECT MAX(transaction_id) as transaction_id FROM transaction_log;';
 | 
			
		||||
		$sql = mysql_query($query, $YBDB) or die(mysql_error());	
 | 
			
		||||
		$result = mysql_fetch_assoc($sql);	
 | 
			
		||||
		echo $result['transaction_id'];	
 | 
			
		||||
	}	
 | 
			
		||||
 | 
			
		||||
	// check if start storage date has been changed since original shop date
 | 
			
		||||
	if(isset($_POST['date_startstorage'])) {
 | 
			
		||||
		$query = 'SELECT shops.date FROM transaction_log, shops WHERE transaction_id=' . $_POST['transaction_id'] .
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user