From db93ad11038a628216c8204e37fae38130722c92 Mon Sep 17 00:00:00 2001 From: Jonathan Rosenbaum Date: Tue, 22 Jan 2019 06:25:40 +0000 Subject: [PATCH] Closes #85 Also, counts returned transactions for both stats_monthlysalestax.php and stats_shoptransactiontotals.php .. no more guessing required. --- stats/stats_monthlysalestax.php | 4 ++- stats/stats_shoptransactiontotals.php | 2 +- transaction_log.php | 43 ++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/stats/stats_monthlysalestax.php b/stats/stats_monthlysalestax.php index 460114b..4a75574 100644 --- a/stats/stats_monthlysalestax.php +++ b/stats/stats_monthlysalestax.php @@ -62,7 +62,9 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1); - + + ' . $row_Recordset1['Month'] . ''; ?> + diff --git a/stats/stats_shoptransactiontotals.php b/stats/stats_shoptransactiontotals.php index 964b182..b72c149 100644 --- a/stats/stats_shoptransactiontotals.php +++ b/stats/stats_shoptransactiontotals.php @@ -65,7 +65,7 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1); - ' . $row_Recordset1['ShopID'] . ''; ?> + ' . $row_Recordset1['ShopID'] . ''; ?> diff --git a/transaction_log.php b/transaction_log.php index 0f716c6..4c9f2ae 100644 --- a/transaction_log.php +++ b/transaction_log.php @@ -101,8 +101,9 @@ if($_GET['search']==''){ $search_state = ''; } -// currently used for links in reports, and not for transaction_log page search mechanism +//// currently used for links in reports, and not for transaction_log page search mechanism +// Shop Transaction Totals (stats_shoptransactiontotals.php) - by shop if($_GET['shop_id_search']==''){ $shop_id_search = ''; } elseif(isset($_GET['shop_id_search'])) { @@ -111,7 +112,16 @@ if($_GET['shop_id_search']==''){ $shop_id_search = ''; } -//record_count (SQL or state) +// Sales Tax Report (stats_monthlysalestax.php)- by month +if($_GET['month_search']==''){ + $month_search = ''; +} elseif(isset($_GET['month_search'])) { + $month_search = "AND DATE(date) >='" . $_GET['month_search'] . "' AND DATE(date) <= LAST_DAY('" . $_GET['month_search'] . "')"; +} else { + $month_search = ''; +} + +//// record_count (SQL or state) if($_GET['record_count']>0){ $record_count = $_GET['record_count']; $number_of_transactions = $record_count; @@ -144,6 +154,27 @@ foreach ( $search_state_array as $key => $value ) { // What is seen on the main page. mysql_select_db($database_YBDB, $YBDB); + +// count for $month_search and $shop_id_search +if($month_search || $shop_id_search) { + $query_Recordset1 = "SELECT *, + DATE_FORMAT(date,'%m/%d/%y (%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 $storage_period DAY),'%W, %M %D'), '] ', transaction_log.description), + IF(community_bike,CONCAT('Quantity(', quantity, ') ', transaction_log.description), description)),2000) + 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} {$contact_id} {$search} {$shop_id_search} {$month_search};"; + $Recordset1 = mysql_query($query_Recordset1, $YBDB) or die(mysql_error()); + $totalRows_Recordset1 = mysql_num_rows($Recordset1); + //$handler->debug($totalRows_Recordset1); + $record_count = $totalRows_Recordset1; +} + $query_Recordset1 = "SELECT *, DATE_FORMAT(date,'%m/%d/%y (%a)') as date_wday, CONCAT('$',FORMAT(amount,2)) as format_amount, @@ -155,10 +186,13 @@ LEFT(IF(show_startdate, CONCAT(' [', 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} {$contact_id} {$search} {$shop_id_search} ORDER BY transaction_id DESC LIMIT 0, $record_count;"; +WHERE 1=1 {$trans_date} {$shop_dayname} {$trans_type} {$contact_id} {$search} {$shop_id_search} {$month_search} 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); +//$handler->debug($query_Recordset1); + + //Action on form update $editFormAction = ""; @@ -675,7 +709,8 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {

Start New Transaction:
    Select Type: -

+

+