diff --git a/Connections/database_functions.php b/Connections/database_functions.php index 7e4308d..90248a1 100644 --- a/Connections/database_functions.php +++ b/Connections/database_functions.php @@ -51,6 +51,12 @@ define("CSV_DIRECTORY","csv"); // mkdir csv // chown www-data:www-data csv // chmod 0700 csv + +// Define array mapping for Accounts. Usually Assets since Income is the main type of transaction. +$gnucash_accounts = array( "Assets:Current Assets:Checking", + "Assets:Current Assets:PayPal", + "Assets:Account Receivable" + ); // other constants define("PAGE_START_SHOP", "/start_shop.php"); @@ -75,7 +81,7 @@ function generate_list($querySQL,$list_value,$list_text, $form_name, $default_va $default_delimiter = ''; // if a form name is supplied HTML listbox code is inserted - if($form_name == "transaction_type"){ + if($form_name == "transaction_type" || $form_name == "gnucash_csv_year"){ echo ""; @@ -98,15 +104,8 @@ function generate_list($querySQL,$list_value,$list_text, $form_name, $default_va // if a form name is supplied HTML listbox code is inserted if($form_name <> "none"){echo "";} } - -// Function provides specific MySQL parameters to the function that generates the list box code -function list_contacts($form_name = "none", $default_value = "", $max_name_length = 20){ - $querySQL = "SELECT LEFT(CONCAT(last_name, ', ', first_name, ' ',middle_initial),$max_name_length) AS full_name, contact_id, hidden FROM contacts WHERE (first_name <> '' OR last_name <> '') AND hidden <> 1 ORDER BY last_name, first_name, middle_initial"; - $list_value = "contact_id"; - $list_text = "full_name"; - generate_list($querySQL,$list_value,$list_text,$form_name, $default_value); -} - + + function list_CurrentShopUsers($form_name = "none", $default_value = "", $max_name_length = 20){ $current_shop = current_shop_by_ip(); $querySQL = "SELECT full_name, shop_hours.contact_id ,hidden FROM shop_hours @@ -116,8 +115,20 @@ ORDER BY full_name;"; $list_value = "contact_id"; $list_text = "full_name"; generate_list($querySQL,$list_value,$list_text,$form_name, $default_value); +} + +// ##################### +// Drop down list queries - functions below could be made into one function if query, $list_value and $list_text parameters were passed + +// Function provides specific MySQL parameters to the function that generates the list box code +function list_contacts($form_name = "none", $default_value = "", $max_name_length = 20){ + $querySQL = "SELECT LEFT(CONCAT(last_name, ', ', first_name, ' ',middle_initial),$max_name_length) AS full_name, contact_id, hidden FROM contacts WHERE (first_name <> '' OR last_name <> '') AND hidden <> 1 ORDER BY last_name, first_name, middle_initial"; + $list_value = "contact_id"; + $list_text = "full_name"; + generate_list($querySQL,$list_value,$list_text,$form_name, $default_value); } + function list_coordinators($form_name = "none", $default_value = "", $max_name_length = 20){ $querySQL = "SELECT LEFT(CONCAT(last_name, ', ', first_name, ' ',middle_initial),40) AS full_name, contacts.contact_id, hidden, shop_user_role FROM contacts LEFT JOIN (SELECT contact_id, shop_user_role, sales FROM shop_hours @@ -204,9 +215,19 @@ function list_donation_locations($form_name = "none", $default_value = "", $max_ $list_value = "contact_id"; $list_text = "full_name"; generate_list($querySQL,$list_value,$list_text,$form_name, $default_value); -} +} + +// Function provides specific MySQL parameters to the function that generates the list box code +function list_distinct_shop_years($form_name = "none", $default_value = ""){ + $querySQL = "SELECT DISTINCT YEAR(date) AS date FROM shops WHERE date!='NULL' ORDER BY date DESC;"; + $list_value = "date"; + $list_text = "date"; + generate_list($querySQL,$list_value,$list_text,$form_name, $default_value); +} + +// ##################### -// +// Date/Time functions function currency_format($value, $places = 2){ echo "$ "; if(is_null($value)) echo number_format(0,$places); @@ -215,10 +236,6 @@ function currency_format($value, $places = 2){ //function to convert server time to local time. To be used by all other current date / time requests. function local_datetime(){ - // $hours_offset = UTC_TIME_OFFSET; - // $min_offset = 0; - //return time() + ( $hours_offset * 60 * 60 + $min_offset * 60 ); - //offset hours; 60 mins; 60secs offset date_default_timezone_set(TIMEZONE); return time(); } @@ -271,6 +288,8 @@ function datetime_to_date($date_in){ $date_out = date("Y-m-d", mktime($H, $i, $s, $m,$d,$Y)); return $date_out; } + +// END Date/Time functions //Function creates list box with times every 15 minutes for the specified number of hours function list_15min($start_time, $start_offset_min, $form_name, $hours, $display_elapsed_hours, $default_value){ @@ -364,6 +383,9 @@ function dateandtimein($date, $time){ return $time; } + +// Drop-Down lists + function list_contacts_edit_add($form_name = "contact_id", $default_value = "") { echo "\n"; } + +// END Drop-Down lists function max_shop_id(){ global $database_YBDB, $YBDB; @@ -471,7 +495,8 @@ function max_shop_id(){ $totalRows_Recordset1 = mysql_num_rows($Recordset1); return $row_Recordset1['shop_id']; } - + +// Is there currently a shop? function current_shop_by_ip(){ global $database_YBDB, $YBDB; $IP = $_SERVER['REMOTE_ADDR']; diff --git a/css/transactions.css b/css/transactions.css index 03497b3..10aa9d9 100644 --- a/css/transactions.css +++ b/css/transactions.css @@ -1,7 +1,7 @@ /* sensible UI defaults for transaction views */ /* right-align labels */ -td > label:not(.payment_type):not(.open_shop) { +td > label:not(.payment_type):not(.open_shop):not(.gnucash_csv) { float: right; padding-right: 5px; } @@ -43,3 +43,16 @@ input[value=Save]:focus, input[value=Close]:focus { .deposit [type='checkbox'] { display: none; } + +/* gnucash */ +[name=gnucash_csv_year] { + width: 80px; +} + +#gnucash_csv_range { + width: 300px; +} + +#range_slider { + padding-top: 8px; +} \ No newline at end of file diff --git a/include_header.html b/include_header.html index 30661a3..6705c0e 100644 --- a/include_header.html +++ b/include_header.html @@ -23,12 +23,16 @@ function resetTimer() YBDB + + + + diff --git a/js/transaction.js b/js/transaction.js index b5c62cd..ab4e08f 100644 --- a/js/transaction.js +++ b/js/transaction.js @@ -145,6 +145,22 @@ $(function() { } }); + // gnucash deposit range slider + $('#gnucash_csv_range').noUiSlider({ + start: [ 20, 30 ], + range: { + 'min': 10, + 'max': 40 + } + }); + // gnucash account multi-select + $("#gnucash_csv_accounts").chosen({ + placeholder_text_multiple: "Select Accounts", + width: "260px" + }); + + $("[name='gnucash_csv_year']").chosen(); + // null or real number function payment_result(result) { if (result == null) { diff --git a/transaction_log.php b/transaction_log.php index 7dc6339..9fca2f0 100644 --- a/transaction_log.php +++ b/transaction_log.php @@ -688,7 +688,32 @@ if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) {
- + +
+ "; + // populate year pull-down list + echo ""; + + // populate Accounts pull-down list + echo "

"; + list_distinct_shop_years("gnucash_csv_year",""); + echo "
+
"; + + echo ""; + + echo "
+
"; + echo "
"; + + echo "
"; + + ?>