Browse Source

Added not logged-in logic for transaction edit, also:

1). Added error spans for transaction edit
2). Removed some css from transaction.js
3). Added css for errors to transaction.css
devel
Jonathan Rosenbaum 9 years ago
parent
commit
304c9e2f37
  1. 15
      css/transactions.css
  2. 25
      js/transaction.js
  3. 10
      json/transaction.php
  4. 43
      transaction_log.php

15
css/transactions.css

@ -56,3 +56,18 @@ input[value=Save]:focus, input[value=Close]:focus {
#range_slider {
padding-top: 8px;
}
/* center error text by description when editing transactions */
[name=description], #description_error {
vertical-align: middle;
}
/* errors */
#current_shop,
#transaction_start_error,
#sold_by_error, #sold_to_error,
#description_error,
#payment_error, #payment_type_error,
#quantity_error {
color: red;
}

25
js/transaction.js

@ -1,6 +1,6 @@
/* jQuery fun with transactions - Jonathan Rosenbaum */
// currently css is just hardwired, but that reflects the coding style of YBDB :)
// currently some css is just hardwired, but that reflects the coding style of YBDB :)
$(function() {
@ -24,7 +24,7 @@ $(function() {
if (data == "no_shop") {
var start_new_shop = "Start New Shop";
$("#current_shop").html("&nbsp<a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>");
$("#current_shop").html("&nbsp<a href='shop_log.php'>" + start_new_shop + "</a>");
} else {
remember_me = "unbind";
}
@ -44,7 +44,7 @@ $(function() {
if (data == "no_shop") {
var start_new_shop = "Start New Shop";
$("#transaction_start_error").html("&nbsp<a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>");
$("#transaction_start_error").html("&nbsp<a href='shop_log.php'>" + start_new_shop + "</a>");
} else {
remember_me = "unbind";
}
@ -66,19 +66,19 @@ $(function() {
var start_new_shop = "Start New Shop";
$("input[name='Submit43']").click(function(){
$("#current_shop").html("&nbsp<a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>");
$("#current_shop").html("&nbsp<a href='shop_log.php'>" + start_new_shop + "</a>");
event.preventDefault();
});
$('[href*="trans_id="]').click(function(){
$("#current_shop").html("&nbsp<a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>");
$("#current_shop").html("&nbsp<a href='shop_log.php'>" + start_new_shop + "</a>");
event.preventDefault();
});
$(".paid").click(function() {
$("#current_shop").html("&nbsp<a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>");
$("#current_shop").html("&nbsp<a href='shop_log.php'>" + start_new_shop + "</a>");
return false;
});
$('.editable_change').mouseover(function() {
$("#current_shop").html("&nbsp<a style='color:red' href='shop_log.php'>" + start_new_shop + "</a>");
$("#current_shop").html("&nbsp<a href='shop_log.php'>" + start_new_shop + "</a>");
$('.editable_change').editable("disable");
});
}
@ -255,7 +255,6 @@ $(function() {
slider_pointer.on("set",function(){
if( $(this).val()[0] == $(this).val()[1] ) {
console.log("slider handle is on the same value");
var Format = wNumb({decimals:0});
var value = Format.from( $(this).val()[0] );
@ -451,6 +450,16 @@ $(function() {
$transaction_id = $("input[name='transaction_id']").val();
//var check_number = $("#check_number").on("input");
// If patron isn't logged in replace pull-down with patrons name
var sold_to = $("[name='sold_to']").val();
if (sold_to == "no_selection") {
$.post("json/transaction.php",{ not_logged_in: 1, transaction_id: $transaction_id }, function(data) {
if (data) {
$("[name='sold_to']").replaceWith("<span name='sold_to'>" + data + "</span>");
}
} );
}
// Anonymous Transaction?
if ($("#anonymous").prop("checked")) { // on reload

10
json/transaction.php

@ -63,6 +63,16 @@ $change_fund = CHANGE_FUND;
echo json_encode($send_back);
}
// Patron who made a transaction not logged in.
if (isset($_POST['not_logged_in'])) {
$query = "SELECT CONCAT(contacts.last_name, ', ', contacts.first_name, ' ',contacts.middle_initial) AS full_name
FROM transaction_log, contacts
WHERE transaction_id=" . $_POST['transaction_id'] .
" AND contacts.contact_id = transaction_log.sold_to;";
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
echo $result["full_name"];
}
// Anonymous transaction - save and communicate back settings
if(isset($_POST['anonymous'])) {

43
transaction_log.php

@ -333,7 +333,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<tr bordercolor="#CCCCCC" bgcolor="#99CC33">
<td colspan="9" bgcolor="#99CC33"><div align="center"><strong>Bike, Sale and Donation Log</strong></div></td>
</tr>
<?php // show delete tranaction confirmation =========================================
<?php // show delete transaction confirmation =========================================
if($delete_trans_id <> -1 ) { ?>
<form method="post" name="FormConfirmDelete" action="<?php echo $editFormAction; ?>">
<tr bordercolor="#CCCCCC" bgcolor="#CCCC33">
@ -438,18 +438,20 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
} ?></td>
</tr>
<?php // end if show amount
<?php // start show amount
if($row_Recordset3['community_bike']){ //community bike will allow a quantity to be selected for Yellow Bikes and Kids Bikes?>
<tr>
<td>&nbsp;</td>
<td valign="top"><label for="quantity">Quantity:</label></td>
<td><input name="quantity" type="text" id="quantity" value="<?php echo $row_Recordset2['quantity']; ?>" size="3" maxlength="3" /></td>
<td><input name="quantity" type="text" id="quantity" value="<?php echo $row_Recordset2['quantity']; ?>" size="3" maxlength="3" />
<span id="quantity_error"></span></td>
</tr>
<?php } // end if show quanitity for community bikes
<?php } // end if show quantity for community bikes
if($row_Recordset3['show_description']){ ?>
<tr><td>&nbsp;</td>
<td valign="top"><label><?php echo $row_Recordset3['fieldname_description']; ?>:</label></td>
<td><textarea name="description" cols="45" rows="3"><?php echo $row_Recordset2['description']; ?></textarea></td>
<td><textarea name="description" cols="45" rows="3"><?php echo $row_Recordset2['description']; ?></textarea>
<span id="description_error"></span></td>
</tr>
<?php if($row_Recordset3['show_amount']){ ?>
@ -459,7 +461,8 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
<?php } else { ?>
<td><label>Paid:</label></td>
<?php } ?>
<td><input name="amount" type="text" id="amount" value="<?php echo $row_Recordset2['format_amount']; ?>" size="6" /></td>
<td><input name="amount" type="text" id="amount" value="<?php echo $row_Recordset2['format_amount']; ?>" size="6" />
<span id="payment_error"></span></td>
</tr>
<?php } ?>
@ -482,18 +485,19 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
$row_Recordset2['check_number'] . '".>';
}
?>
</td>
<span id="payment_type_error"></span></td>
</tr>
<?php } ?>
<?php } // end if show_description
if($row_Recordset3['show_soldto_location']){ // if location show row?>
<tr><td>&nbsp;</td>
<td><label><?php echo $row_Recordset3['fieldname_soldto']; ?>:</label></td>
<?php // Patron
if($row_Recordset3['show_soldto_location']){
<?php } // end if show_payment
// Patron
if($row_Recordset3['show_soldto_location']){ // if location show row?> <tr><td>&nbsp;</td>
<td><label><?php echo $row_Recordset3['fieldname_soldto']; ?>:</label></td>
<?php
if($row_Recordset3['show_soldto_location']){
// list_donation_locations_withheader('sold_to', $row_Recordset2['sold_to']); - not required to be signed in.
echo "<td>";
echo "<td>";
list_CurrentShopUsers_select('sold_to', $row_Recordset2['sold_to']);
$record_trans_id = $row_Recordset2['transaction_id'];
if ($row_Recordset3['anonymous']) {
@ -507,19 +511,22 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
} else {
echo "<span id='anon' style='display:none;'><label for='anonymous' id='anonymous_label'>Anonymous:</label></span>";
}
echo "</td>";
echo "<span id='sold_to_error'></span></td>";
// echo " <a href=\"location_add_edit.php?trans_id={$record_trans_id}&contact_id=new_contact\">Create New Location</a> | <a href=\"location_add_edit_select.php?trans_id={$record_trans_id}&contact_id=new_contact\">Edit Existing Location</a>";
} ?>
</tr> <?php } //end if show location row ?>
<tr><td>&nbsp;</td>
<td><label><?php echo $row_Recordset3['fieldname_soldby']; ?>:</label></td>
<td><label><?php // sold by or received by
echo $row_Recordset3['fieldname_soldby']; ?>:</label></td>
<td><?php if(current_shop_by_ip()>0) list_current_coordinators_select('sold_by', $row_Recordset2['sold_by']);
else list_contacts_coordinators('sold_by//,', $row_Recordset2['sold_by']);
//list_contacts_coordinators('sold_by', $row_Recordset2['sold_by']);
//list_current_coordinators_select('sold_by', $row_Recordset2['sold_by']);
?>
</td>
<span id="sold_by_error"></span></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="FormEdit">

Loading…
Cancel
Save