mirror of
				https://github.com/fspc/Yellow-Bike-Database.git
				synced 2025-10-31 08:55:36 -04:00 
			
		
		
		
	When no shop, prevents unloaded page transactions from being edited.
This commit is contained in:
		
							parent
							
								
									fd9fe984d1
								
							
						
					
					
						commit
						f8b96a05b7
					
				| @ -2,6 +2,7 @@ | ||||
| 
 | ||||
| // currently css is just hardwired, but that reflects the coding style of YBDB :)
 | ||||
| 
 | ||||
| 
 | ||||
| $(function() { | ||||
| 
 | ||||
| 	$.ajaxSetup({async:false}); // best to do this in $.ajax, 
 | ||||
| @ -12,6 +13,48 @@ $(function() { | ||||
| 	$("input[value='Create Transaction']").attr("tabindex",2); | ||||
| 	$("#trans_date").mask("0000-00-00", {placeholder: "yyyy-mm-dd" }); | ||||
| 
 | ||||
| 
 | ||||
| 	// If page has not been reloaded after a shop period ends, prevent edit from working.
 | ||||
|    // Note: create transaction covered via a mysql_error()), but with a reload.
 | ||||
| 	$('[href*="trans_id="]').click(function(e){   | ||||
|  		var remember_me; | ||||
| 		$.post("json/transaction.php", {shop_exist: 1}, function(data) { | ||||
|    | ||||
|   			if (data == "no_shop") { | ||||
|     			var start_new_shop = "Start New Shop";	 | ||||
|     			$("#current_shop").html(" <a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>"); | ||||
|   			} else { | ||||
|     			remember_me = "unbind"; | ||||
|   			} | ||||
| 		}); | ||||
|   		if (remember_me == "unbind") {  | ||||
|   		 $('[href*="trans_id="]').unbind('click');  | ||||
|   		 } | ||||
|   		 else {   | ||||
|   		 	e.preventDefault();  | ||||
|   		 } | ||||
| 	} ); | ||||
| 
 | ||||
|   // Do the same thing as previously, but for editing a transaction (could make a function :)
 | ||||
| 	$('#save_transaction').click(function(e){   | ||||
|  		var remember_me; | ||||
| 		$.post("json/transaction.php", {shop_exist: 1}, function(data) { | ||||
|    | ||||
|   			if (data == "no_shop") { | ||||
|     			var start_new_shop = "Start New Shop";	 | ||||
|     			$("#transaction_start_error").html(" <a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>"); | ||||
|   			} else { | ||||
|     			remember_me = "unbind"; | ||||
|   			} | ||||
| 		}); | ||||
|   		if (remember_me == "unbind") {  | ||||
|   		 $('#save_transaction').unbind('click');  | ||||
|   		 } | ||||
|   		 else {   | ||||
|   		 	e.preventDefault();  | ||||
|   		 } | ||||
| 	} ); | ||||
| 
 | ||||
| 	// Does a current shop exist?
 | ||||
| 	var open_shop; | ||||
| 	$.post("json/transaction.php", {shop_exist: 1}, function(data) {  | ||||
|  | ||||
| @ -8,7 +8,11 @@ $change_fund = CHANGE_FUND; | ||||
| 
 | ||||
| 	// Is there a current shop?
 | ||||
| 	if(isset($_POST['shop_exist'])) { | ||||
| 		if(current_shop_by_ip()>=1) echo "current_shop"; else echo "no_shop"; | ||||
| 		if(current_shop_by_ip()>=1) {  | ||||
| 			echo "current_shop";  | ||||
| 		} else { | ||||
| 			echo "no_shop"; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	// update whether paid or not
 | ||||
|  | ||||
| @ -1,4 +1,6 @@ | ||||
| <?php | ||||
| 
 | ||||
| error_reporting(E_STRICT); | ||||
| require_once('Connections/YBDB.php'); | ||||
| require_once('Connections/database_functions.php');  | ||||
| 
 | ||||
| @ -71,7 +73,7 @@ if($_GET['record_count']>0){ | ||||
| 
 | ||||
| 
 | ||||
| // This is the recordset for the list of logged transactions	
 | ||||
| 
 | ||||
| // What is seen on the main page.
 | ||||
| 
 | ||||
| mysql_select_db($database_YBDB, $YBDB); | ||||
| $query_Recordset1 = "SELECT *,
 | ||||
| @ -80,7 +82,8 @@ CONCAT('$',FORMAT(amount,2)) as format_amount, | ||||
| CONCAT(contacts.last_name, ', ', contacts.first_name, ' ',contacts.middle_initial) AS full_name, | ||||
| LEFT(IF(show_startdate, CONCAT(' [', | ||||
| 		DATE_FORMAT(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),'%W, %M %D'), '] ', transaction_log.description), | ||||
| 		IF(community_bike,CONCAT('Quantity(', quantity, ')  ', transaction_log.description), description)),100) as description_with_locations | ||||
| 		IF(community_bike,CONCAT('Quantity(', quantity, ')  ', transaction_log.description), description)),100)  | ||||
| 		as description_with_locations | ||||
| FROM transaction_log | ||||
| LEFT JOIN contacts ON transaction_log.sold_to=contacts.contact_id | ||||
| LEFT JOIN transaction_types ON transaction_log.transaction_type=transaction_types.transaction_type_id | ||||
| @ -144,7 +147,12 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormNew")) { | ||||
| 					    | ||||
| 	//echo $insertSQL; 
 | ||||
| 	//mysql_select_db($database_YBDB, $YBDB);
 | ||||
| 	$Result1 = mysql_query($insertSQL, $YBDB) or die(mysql_error());	 | ||||
| 	$Result1 = mysql_query($insertSQL, $YBDB); // or die(mysql_error());
 | ||||
| 	// Here is the error to check for: "Column 'shop_id' cannot be null" when there is no shop and create transaction is pressed	
 | ||||
| 	if (mysql_error()) { | ||||
| 		header("Refresh:0;"); | ||||
| 		exit(); | ||||
| 	}	 | ||||
| 	 | ||||
| 	$LoadPage = $_SERVER['PHP_SELF'] . "?trans_id={$newtrans}"; | ||||
| 	header(sprintf("Location: %s", $LoadPage)); | ||||
| @ -320,6 +328,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { | ||||
| 	  } elseif($trans_id <> -1 ) { | ||||
| 	   | ||||
| 	  // Gets data for the transaction being edited
 | ||||
| 	  // shows transaction if edit link is clicked
 | ||||
| 	  mysql_select_db($database_YBDB, $YBDB); | ||||
| 	  $query_Recordset2 = "SELECT *,
 | ||||
| 								DATE_FORMAT(date_startstorage,'%Y-%m-%d') as date_startstorage_day, | ||||
| @ -355,6 +364,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { | ||||
|                     <input id="save_transaction" type="submit" name="EditSubmit" value="Save" align="right"> | ||||
|                     <input type="submit" name="EditSubmit" value="Close"> | ||||
|                     <input type="submit" name="EditSubmit" value="Delete"> | ||||
|                     <span id="transaction_start_error"></span> | ||||
|                     <!-- Save before using paypal ->> --> | ||||
|                     </td> | ||||
| 		  	    </tr> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user