Browse Source

Replaces some hardwired variables with user-defined constants.

devel
Jonathan Rosenbaum 10 years ago
parent
commit
d2332719a0
  1. 6
      Connections/database_functions.php
  2. 11
      shop_log.php
  3. 3
      stats/stats_monthlysalestax.php
  4. 17
      transaction_log.php

6
Connections/database_functions.php

@ -1,5 +1,11 @@
<?php
require_once('YBDB.php');
// User defined constants - read populate.sql for directions
define("STORAGE_PERIOD", 14);
define("ACCOUNTING_GROUP", "Sales");
define("DEFAULT_TRANSACTION_TYPE", "Sale - Used Parts");
define("DEFAULT_SHOP_USER", "Volunteer");
//constants
define("PAGE_START_SHOP", "/start_shop.php");

11
shop_log.php

@ -4,6 +4,7 @@ require_once('Connections/database_functions.php');
$page_edit_contact = PAGE_EDIT_CONTACT;
$page_individual_history_log = INDIVIDUAL_HISTORY_LOG;
$default_shop_user = DEFAULT_SHOP_USER;
mysql_select_db($database_YBDB, $YBDB);
//?shop_id=2
@ -31,7 +32,13 @@ if($_GET['new_user_id']>0){
}
$query_Recordset1 = "SELECT shop_hours.shop_visit_id, shop_hours.contact_id, shop_hours.shop_user_role, shop_hours.project_id, shop_hours.time_in, shop_hours.time_out, TIME_FORMAT(TIMEDIFF(time_out, time_in),'%k:%i') as et, shop_hours.comment, CONCAT(contacts.last_name, ', ', contacts.first_name, ' ',contacts.middle_initial) AS full_name, contacts.first_name FROM shop_hours
$query_Recordset1 = "SELECT shop_hours.shop_visit_id, shop_hours.contact_id,
shop_hours.shop_user_role, shop_hours.project_id,
shop_hours.time_in, shop_hours.time_out,
TIME_FORMAT(TIMEDIFF(time_out, time_in),'%k:%i')
AS et, shop_hours.comment,
CONCAT(contacts.last_name, ', ', contacts.first_name, ' ',contacts.middle_initial)
AS full_name, contacts.first_name FROM shop_hours
LEFT JOIN shop_user_roles ON shop_hours.shop_user_role=shop_user_roles.shop_user_role_id
LEFT JOIN contacts ON shop_hours.contact_id=contacts.contact_id
WHERE shop_hours.shop_id = $shop_id ORDER BY hours_rank, time_in DESC;";
@ -148,7 +155,7 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit")) {
&nbsp;&nbsp;&nbsp;&nbsp;last name quickly</span>
<?php list_contacts_select_user('contact_id', $new_user_id); ?></td>
<td valign="bottom"><strong>
<?php list_shop_user_roles('user_role','Personal'); ?>
<?php list_shop_user_roles('user_role', $default_shop_user); ?>
</strong></td>
<td valign="bottom"><strong>
<?php if($totalRows_Recordset1 <> 0){

3
stats/stats_monthlysalestax.php

@ -2,6 +2,7 @@
require_once('../Connections/YBDB.php');
require_once('../Connections/database_functions.php');
$page_individual_history_log = INDIVIDUAL_HISTORY_LOG;
$accounting_group = ACCOUNTING_GROUP;
switch ($_GET['error']) {
case 'no_shop':
@ -19,7 +20,7 @@ mysql_select_db($database_YBDB, $YBDB);
$query_Recordset1 = "SELECT year(t.date) as Year,quarter(t.date) as Quarter, month(t.date) as Month, round(sum(amount),2) as TotalSales, tt.accounting_group as AccountingGroup
FROM transaction_log t
LEFT JOIN transaction_types tt ON t.transaction_type = tt.transaction_type_id
WHERE tt.accounting_group = 'Sales'
WHERE tt.accounting_group = '$accounting_group'
GROUP BY year(t.date), month(t.date)
ORDER BY year(t.date) DESC, month(t.date) DESC;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());

17
transaction_log.php

@ -4,6 +4,8 @@ require_once('Connections/database_functions.php');
$page_edit_contact = PAGE_EDIT_CONTACT;
$page_individual_history_log = INDIVIDUAL_HISTORY_LOG;
$storage_period = STORAGE_PERIOD;
$default_transaction_type = DEFAULT_TRANSACTION_TYPE;
//transaction ID
if($_GET['trans_id']>0){
@ -14,10 +16,10 @@ if($_GET['trans_id']>0){
//error
switch ($_GET['error']) {
case 'transactioncomplete':
$error_message = 'Paypal transaction was sucessful';
$error_message = 'Paypal transaction was successful';
break;
case 'transactioncanceled': //this is a sample error message. insert error case here
$error_message = 'Paypal transaction was canceled';
$error_message = 'Paypal transaction was cancelled';
break;
default:
$error_message = '';
@ -71,12 +73,12 @@ DATE_FORMAT(date,'%m/%d (%a)') as date_wday,
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 14 DAY),'%W, %M %D'), '] ', transaction_log.description),
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
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
WHERE 1=1 {$trans_date} {$shop_dayname} {$trans_type} ORDER BY date_wday DESC LIMIT 0, $record_count;";
WHERE 1=1 {$trans_date} {$shop_dayname} {$trans_type} ORDER BY transaction_id DESC LIMIT 0, $record_count;";
$Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
@ -228,8 +230,8 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
$query_Recordset2 = "SELECT *,
DATE_FORMAT(date_startstorage,'%Y-%m-%d') as date_startstorage_day,
DATE_FORMAT(date,'%Y-%m-%d') as date_day,
DATE_FORMAT(DATE_ADD(date_startstorage,INTERVAL 14 DAY),'%W, %M %D') as storage_deadline,
DATEDIFF(DATE_ADD(date_startstorage,INTERVAL 14 DAY),CURRENT_DATE()) as storage_days_left,
DATE_FORMAT(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),'%W, %M %D') as storage_deadline,
DATEDIFF(DATE_ADD(date_startstorage,INTERVAL $storage_period DAY),CURRENT_DATE()) as storage_days_left,
FORMAT(amount,2) as format_amount
FROM transaction_log WHERE transaction_id = $trans_id; ";
$Recordset2 = mysql_query($query_Recordset2, $YBDB) or die(mysql_error());
@ -364,7 +366,7 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
<form method="post" name="FormNew" action="<?php echo $editFormAction; ?>">
<tr bordercolor="#CCCCCC" bgcolor="#CCCC33">
<td colspan="8"><p><strong>Start New Transaction:</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;Select Type: <?php list_transaction_types('transaction_type','Sale - Used Parts'); ?>
<td colspan="8"><p><strong>Start New Transaction:</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;Select Type: <?php list_transaction_types('transaction_type',$default_transaction_type); ?>
<input type="submit" name="Submit43" value="Create Transaction" />
</p> </td>
</tr>
@ -399,6 +401,7 @@ FROM transaction_log WHERE transaction_id = $trans_id; ";
<td><input class="paid" type="checkbox" name="<?php echo $row_Recordset1['transaction_id']; ?>"
value="<?php echo $row_Recordset1['paid'];?>"
<?php if ($row_Recordset1['paid'] == 1) { echo " checked"; } ?>
>
</td>
</tr>

Loading…
Cancel
Save