Browse Source

Added payment_type.

devel
Jonathan Rosenbaum 10 years ago
parent
commit
f72f022811
  1. 8
      Connections/database_functions.php
  2. 39
      js/transaction.js
  3. 11
      json/transaction.php
  4. 3
      shop_log.php
  5. 2
      sql/populate.sql
  6. 11
      transaction_log.php

8
Connections/database_functions.php

@ -1,12 +1,16 @@
<?php <?php
require_once('YBDB.php'); require_once('YBDB.php');
// User defined constants - read populate.sql for directions // User defined constants - read sql/populate.sql for an explanation
define("STORAGE_PERIOD", 14); define("STORAGE_PERIOD", 14);
define("ACCOUNTING_GROUP", "Sales"); define("ACCOUNTING_GROUP", "Sales");
define("DEFAULT_TRANSACTION_TYPE", "Sale - Used Parts"); define("DEFAULT_TRANSACTION_TYPE", "Sale - Used Parts");
define("DEFAULT_SHOP_USER", "Volunteer"); define("DEFAULT_SHOP_USER", "Volunteer");
// How many hours should the shop be open from the time a person logins? Hours display in pulldown in shop_log.php
// No overtime for volunteers. :)
define("SHOP_HOURS_LENGTH", 10);
/* /*
Choose your timezone from http://php.net/manual/en/timezones.php Choose your timezone from http://php.net/manual/en/timezones.php
@ -184,7 +188,7 @@ function currency_format($value, $places = 2){
else echo number_format($value,$places); else echo number_format($value,$places);
} }
//function to convert server time (UTC) to local time. To be used by all other current date / time requests. //function to convert server time to local time. To be used by all other current date / time requests.
function local_datetime(){ function local_datetime(){
// $hours_offset = UTC_TIME_OFFSET; // $hours_offset = UTC_TIME_OFFSET;
// $min_offset = 0; // $min_offset = 0;

39
js/transaction.js

@ -4,28 +4,45 @@
$(function() { $(function() {
// paid or not?
$(".paid").click(function() { $(".paid").click(function() {
if ($(this).prop("checked")) { if ($(this).prop("checked")) {
//console.log("turn color on"); //console.log("turn color on");
$(this).closest("tr").css("background-color","#99CC33"); $(this).closest("tr").css("background-color","#99CC33");
$.post("json/transaction.php",{ paid: 1, transaction_id: this.name } ); $.post("json/transaction.php",{ paid: 1, transaction_id: this.name } );
} }
else { else {
//console.log("turn color off"); //console.log("turn color off");
$(this).closest("tr").css("background-color","transparent"); $(this).closest("tr").css("background-color","transparent");
$.post("json/transaction.php",{ paid: 0, transaction_id: this.name } ); $.post("json/transaction.php",{ paid: 0, transaction_id: this.name } );
} }
}); });
// make tabbing more predictable
$("input[name='shop_id']").attr("tabindex",1); // editing a transaction
$("select[name='transaction_type']").attr("tabindex",2); if ( $("input[name='shop_id']").length ) {
$("input[name='date']").attr("tabindex",3);
$("input[name='amount']").attr("tabindex",4) // make tabbing more predictable
$("input[name='quantity']").attr("tabindex",5) $("input[name='shop_id']").attr("tabindex",1);
$("textarea[name='description']").attr("tabindex",6) $("select[name='transaction_type']").attr("tabindex",2);
$("select[name='sold_to']").attr("tabindex",8) $("input[name='date_startstorage']").attr("tabindex",3);
$("select[name='sold_by']").attr("tabindex",9) $("input[name='date']").attr("tabindex",4);
$("input[name='amount']").attr("tabindex",5);
$("input[name='quantity']").attr("tabindex",6);
$("textarea[name='description']").attr("tabindex",7);
$("input[name='payment_type']").attr("tabindex",8);
$("select[name='sold_to']").attr("tabindex",9);
$("select[name='sold_by']").attr("tabindex",10);
$transaction_id = $("input[name='transaction_id']").val();
// what type of payment? cash, credit or check?
$("input[name='payment_type']").click(function() {
if ($(this).prop("checked")) {
$.post("json/transaction.php",{ payment_type: this.value, transaction_id: $transaction_id } );
}
});
} // editing a transaction
}); });

11
json/transaction.php

@ -4,6 +4,7 @@ require_once('../Connections/YBDB.php');
mysql_select_db($database_YBDB, $YBDB); mysql_select_db($database_YBDB, $YBDB);
// update whether paid or not
if(isset($_POST['paid'])) { if(isset($_POST['paid'])) {
if ($_POST['paid'] == 1) { if ($_POST['paid'] == 1) {
@ -18,4 +19,14 @@ mysql_select_db($database_YBDB, $YBDB);
} }
} }
// update payment type
if(isset($_POST['payment_type'])) {
$query = 'UPDATE transaction_log SET payment_type="' .
$_POST['payment_type'] . '" WHERE transaction_id=' .
$_POST['transaction_id'] . ";";
$result = mysql_query($query, $YBDB) or die(mysql_error());
}
?> ?>

3
shop_log.php

@ -5,6 +5,7 @@ require_once('Connections/database_functions.php');
$page_edit_contact = PAGE_EDIT_CONTACT; $page_edit_contact = PAGE_EDIT_CONTACT;
$page_individual_history_log = INDIVIDUAL_HISTORY_LOG; $page_individual_history_log = INDIVIDUAL_HISTORY_LOG;
$default_shop_user = DEFAULT_SHOP_USER; $default_shop_user = DEFAULT_SHOP_USER;
$shop_hours_length = SHOP_HOURS_LENGTH;
mysql_select_db($database_YBDB, $YBDB); mysql_select_db($database_YBDB, $YBDB);
//?shop_id=2 //?shop_id=2
@ -215,7 +216,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit")) {
<td><a href="<?php echo "{$page_individual_history_log}?contact_id=" . $row_Recordset1['contact_id']; ?>"><?php echo $row_Recordset1['full_name']; ?></a></td> <td><a href="<?php echo "{$page_individual_history_log}?contact_id=" . $row_Recordset1['contact_id']; ?>"><?php echo $row_Recordset1['full_name']; ?></a></td>
<td><?php echo $row_Recordset1['shop_user_role']; ?></td> <td><?php echo $row_Recordset1['shop_user_role']; ?></td>
<td><?php echo date_to_time($row_Recordset1['time_in']); ?></td> <td><?php echo date_to_time($row_Recordset1['time_in']); ?></td>
<td><?php echo list_time($row_Recordset1['time_in'],$row_Recordset1['time_out'],'time_out',0,1,'none', 8,$row_Recordset1['et']); ?></td> <td><?php echo list_time($row_Recordset1['time_in'],$row_Recordset1['time_out'],'time_out',0,1,'none', $shop_hours_length, $row_Recordset1['et']); ?></td>
<td><?php sign_out($row_Recordset1['time_out'], $row_Recordset1['first_name']); ?>&nbsp</td> <td><?php sign_out($row_Recordset1['time_out'], $row_Recordset1['first_name']); ?>&nbsp</td>
<td><?php if($shop_CanEdit == 1) {echo "<a href=\"{$_SERVER['PHP_SELF']}?shop_id={$shop_id}&visit_id={$row_Recordset1['shop_visit_id']}\">edit</a>";} else {echo "&nbsp";} ?></td> <td><?php if($shop_CanEdit == 1) {echo "<a href=\"{$_SERVER['PHP_SELF']}?shop_id={$shop_id}&visit_id={$row_Recordset1['shop_visit_id']}\">edit</a>";} else {echo "&nbsp";} ?></td>
</tr> </tr>

2
sql/populate.sql

@ -145,4 +145,4 @@ INSERT INTO transaction_types
-- description, sold_to, sold_by, quantity, shop_id, paid -- description, sold_to, sold_by, quantity, shop_id, paid
ALTER TABLE transaction_log ADD paid tinyint(1) NOT NULL DEFAULT '0'; ALTER TABLE transaction_log ADD paid tinyint(1) NOT NULL DEFAULT '0';
ALTER TABLE transaction_log ADD payment_type varchar(5) DEFAULT NULL; ALTER TABLE transaction_log ADD payment_type varchar(6) DEFAULT NULL;

11
transaction_log.php

@ -319,15 +319,18 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
if($row_Recordset3['show_description']){ ?> if($row_Recordset3['show_description']){ ?>
<tr><td>&nbsp;</td> <tr><td>&nbsp;</td>
<td valign="top"><label><?php echo $row_Recordset3['fieldname_description']; ?>:</label></td> <td valign="top"><label><?php echo $row_Recordset3['fieldname_description']; ?>:</label></td>
<td><textarea name="description" cols="45" rows="2"><?php echo $row_Recordset2['description']; ?></textarea></td> <td><textarea name="description" cols="45" rows="3"><?php echo $row_Recordset2['description']; ?></textarea></td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td><label>Payment Type:</label></td> <td><label>Payment Type:</label></td>
<td> <td>
<input type="radio" name="payment_type" value="cash">Cash <input type="radio" name="payment_type" value="cash"
<input type="radio" name="payment_type" value="credit">Credit Card <?php if ($row_Recordset2['payment_type'] == "cash") { echo " checked"; } ?> >Cash
<input type="radio" name="payment_type" value="check">Check <input type="radio" name="payment_type" value="credit"
<?php if ($row_Recordset2['payment_type'] == "credit") { echo " checked"; } ?> >Credit Card
<input type="radio" name="payment_type" value="check"
<?php if ($row_Recordset2['payment_type'] == "check") { echo " checked"; } ?> >Check
</td> </td>
</tr> </tr>
<?php } // end if show_description <?php } // end if show_description

Loading…
Cancel
Save