start(); */ $page_edit_contact = PAGE_EDIT_CONTACT; $page_individual_history_log = INDIVIDUAL_HISTORY_LOG; $storage_period = STORAGE_PERIOD; $default_transaction_type = DEFAULT_TRANSACTION_TYPE; $number_of_transactions = NUMBER_OF_TRANSACTIONS; $change_fund = CHANGE_FUND; $show_shop_id = SHOW_SHOP_ID; //transaction ID if($_GET['trans_id']>0){ $trans_id = $_GET['trans_id']; } else { $trans_id =-1;} //error switch ($_GET['error']) { case 'transactioncomplete': $error_message = 'Paypal transaction was successful'; break; case 'transactioncanceled': //this is a sample error message. insert error case here $error_message = 'Paypal transaction was cancelled'; break; default: $error_message = ''; break; } //delete transaction ID if($_GET['delete_trans_id']>0){ $delete_trans_id = $_GET['delete_trans_id']; } else { $delete_trans_id =-1;} //shop_date ($trans_date => SQL) ($trans_date_state => state) if($_GET['trans_date']>0){ $trans_date = "AND date <= ADDDATE('{$_GET['trans_date']}',1)" ; $trans_date_state = $_GET['trans_date']; } else { $datetoday = current_date(); $trans_date_state = $datetoday; $trans_date ="AND date <= ADDDATE('{$datetoday}',1)"; $trans_date = ""; } //dayname ($shop_dayname => SQL) ($shop_dayname_state => state) if($_GET['shop_dayname']=='alldays'){ $shop_dayname = ''; $shop_dayname_state = 'alldays'; } elseif(isset($_GET['shop_dayname'])) { $shop_dayname = "AND DAYNAME(date) = '" . $_GET['shop_dayname'] . "'"; $shop_dayname_state = $_GET['shop_dayname']; } else { $shop_dayname = ''; $shop_dayname_state = 'alldays'; } //Transaction_type ($trans_type => SQL) ($trans_type_state => state) if($_GET['trans_type']=='all_types'){ $trans_type = ''; $trans_type_state = 'all_types'; } elseif(isset($_GET['trans_type'])) { $trans_type = "AND transaction_log.transaction_type = '" . $_GET['trans_type'] . "'"; $trans_type_state = $_GET['trans_type']; } else { $trans_type = ''; $trans_type_state = 'all_types'; } //record_count (SQL or state) if($_GET['record_count']>0){ $record_count = $_GET['record_count']; $number_of_transactions = $record_count; } else { $record_count = $number_of_transactions; } // create a string to remember state $search_state_array = array( "trans_date" => $trans_date_state, "trans_type" => $trans_type_state, "shop_dayname" => $shop_dayname_state, "record_count" => $record_count ); $count = count($search_state_array); $c = 1; foreach ( $search_state_array as $key => $value ) { if (isset($value)) { $search_state .= $key . "=" . $value; if ($c < $count) { $search_state = $search_state . "&"; } } $c++; } // This is the recordset for the list of logged transactions // What is seen on the main page. mysql_select_db($database_YBDB, $YBDB); $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} 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); //Action on form update $editFormAction = ""; //Form Submit New Transaction=================================================================== if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormNew")) { $trans_type = $_POST['transaction_type']; $shop_id = current_shop_by_ip(); mysql_select_db($database_YBDB, $YBDB); $query_Recordset5 = "SELECT show_startdate FROM transaction_types WHERE transaction_type_id = \"$trans_type\";"; //echo $query_Recordset5; $Recordset5 = mysql_query($query_Recordset5, $YBDB) or die(mysql_error()); $row_Recordset5 = mysql_fetch_assoc($Recordset5); $totalRows_Recordset5 = mysql_num_rows($Recordset5); $initial_date_startstorage = $row_Recordset5['show_startdate']; // Note: storage of time via current_datetime()) seems futile since updated or customized dates do not have a time if ($initial_date_startstorage) { $date_startstorage = current_datetime(); $date = "NULL"; $amount = "NULL"; } else { $date_startstorage = "NULL"; $date = current_datetime(); $amount = "NULL"; } //end if // gets newest transaction ID //mysql_select_db($database_YBDB, $YBDB); $query_Recordset4 = "SELECT MAX(transaction_id) as newtrans FROM transaction_log;"; $Recordset4 = mysql_query($query_Recordset4, $YBDB) or die(mysql_error()); $row_Recordset4 = mysql_fetch_assoc($Recordset4); $totalRows_Recordset4 = mysql_num_rows($Recordset4); $newtrans = $row_Recordset4['newtrans']; //This field is used to set edit box preferences $newtrans = $newtrans + 1; $insertSQL = sprintf("INSERT INTO transaction_log (transaction_type,shop_id, date_startstorage, date, quantity, amount, transaction_id) VALUES (%s,%s, %s ,%s,%s, %s, %s)", GetSQLValueString($_POST['transaction_type'], "text"), GetSQLValueString($shop_id, "text"), GetSQLValueString($date_startstorage, "date"), GetSQLValueString($date, "date"), GetSQLValueString(1, "int"), GetSQLValueString($amount, "float"), GetSQLValueString($newtrans, "int") ); //echo $insertSQL; //mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($insertSQL, $YBDB); // or die(mysql_error()); // Here is the error to check for: "Column 'shop_id' cannot be null" when there is no shop and create transaction is pressed if (mysql_error()) { header("Refresh:0;"); exit(); } $LoadPage = "?trans_id={$newtrans}"; header(sprintf("Location: %s", $LoadPage)); } // end Form Submit New Transaction // Form Close Record if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_POST["EditSubmit"] == "Close")) { header(sprintf("Location: %s",$editFormAction . "?" . $search_state)); //$editFormAction } //Form Edit Record =============================================================================== if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_POST["EditSubmit"] == "Save")) { //Error Correction & good place for jquery $sold_to = (($_POST['sold_to'] == 'no_selection') ? 1268 : $_POST['sold_to'] ); $sold_by = (($_POST['sold_by'] == 'no_selection') ? 1268 : $_POST['sold_by'] ); $date_startstorage = date_update_wo_timestamp($_POST['date_startstorage'], $_POST['db_date_startstorage']); $date = date_update_wo_timestamp($_POST['date'], $_POST['db_date']); $description = $_POST['description']; $check_number = (($_POST['check_number'] == "") ? "" : $_POST['check_number'] ); $transaction_id = $_POST['transaction_id']; // If storage transaction finalized, change transaction_id to most recent transaction_id $current_date = current_date(); $storage_date = split(' ', $_POST['db_date_startstorage']); $transaction_date = split(' ', $_POST['date']); mysql_select_db($database_YBDB, $YBDB); $query = 'SELECT MAX(transaction_id) AS "ti" FROM transaction_log;'; $sql = mysql_query($query, $YBDB) or die(mysql_error()); $result = mysql_fetch_assoc($sql); // percolate transaction_id for completed storage transactions if($date_startstorage) { $new_transaction_id = $result['ti'] + 1; // If startstorage > current date (transaction_id stays the same) // If startstorage =< current date (transaction_id becomes > than last) // not necessary - && $storage_date[0] != $transaction_date[0] if ($current_date >= $storage_date[0] ) { if($_POST['amount'] != "" && $_POST['payment_type'] != "") { $query = 'UPDATE transaction_log SET transaction_id="' . $new_transaction_id . '" WHERE transaction_id="' . $_POST['transaction_id'] . '";'; $sql = mysql_query($query, $YBDB) or die(mysql_error()); $transaction_id = $new_transaction_id; } else { $new_transaction_id = ""; } } } $query = 'SELECT anonymous FROM transaction_log WHERE transaction_id="' . $transaction_id . '";'; $sql = mysql_query($query, $YBDB) or die(mysql_error()); $result = mysql_fetch_assoc($sql); if($result['anonymous']) { // keep the order $updateSQL = sprintf("UPDATE transaction_log SET transaction_type=%s, date_startstorage=%s, date=%s, amount=%s, quantity=%s, description=%s, sold_by=%s, shop_id=%s, check_number=%s WHERE transaction_id=%s", GetSQLValueString($_POST['transaction_type'], "text"), GetSQLValueString($date_startstorage, "date"), GetSQLValueString($date, "date"), GetSQLValueString($_POST['amount'], "double"), GetSQLValueString($_POST['quantity'], "int"), GetSQLValueString($description, "text"), GetSQLValueString($sold_by, "int"), GetSQLValueString($_POST['shop_id'], "int"), GetSQLValueString($check_number, "text"), GetSQLValueString($transaction_id, "int") ); } else { $updateSQL = sprintf("UPDATE transaction_log SET transaction_type=%s, date_startstorage=%s, date=%s, amount=%s, quantity=%s, description=%s, sold_to=%s, sold_by=%s, shop_id=%s, check_number=%s WHERE transaction_id=%s", GetSQLValueString($_POST['transaction_type'], "text"), GetSQLValueString($date_startstorage, "date"), GetSQLValueString($date, "date"), GetSQLValueString($_POST['amount'], "double"), GetSQLValueString($_POST['quantity'], "int"), GetSQLValueString($description, "text"), GetSQLValueString($sold_to, "int"), GetSQLValueString($sold_by, "int"), GetSQLValueString($_POST['shop_id'], "int"), GetSQLValueString($check_number, "text"), GetSQLValueString($transaction_id, "int") ); } //mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($updateSQL, $YBDB) or die(mysql_error()); $trans_id = $transaction_id; header(sprintf("Location: %s",$editFormAction . "?trans_id={$trans_id}&" . $search_state)); //$editFormAction } //Form Edit Record Delete =============================================================================== if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_POST["EditSubmit"] == "Delete")) { $trans_id = $_POST['transaction_id']; header(sprintf("Location: %s",$editFormAction . "?delete_trans_id={$trans_id}&" . $search_state )); //$editFormAction } //Form Confirm Delete =============================================================================== if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ConfirmDelete") && ($_POST["DeleteConfirm"] == "Confirm Delete")) { $delete_trans_id = $_POST['delete_trans_id']; $insertSQL = "DELETE FROM transaction_log WHERE transaction_id = {$delete_trans_id}"; mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($insertSQL, $YBDB) or die(mysql_error()); header(sprintf("Location: %s", PAGE_SALE_LOG . "?" . $search_state)); //$editFormAction //Cancel and go back to transaction ================================================================ } elseif ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ConfirmDelete") && ($_POST["DeleteConfirm"] == "Cancel")) { $delete_trans_id = $_POST['delete_trans_id']; header(sprintf("Location: %s", PAGE_SALE_LOG . "?trans_id={$delete_trans_id}&" . $search_state )); //$editFormAction } //Change Date isset($_POST["MM_update"]) ========================================================= if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { $editFormAction = "?trans_date={$_POST['trans_date']}&trans_type={$_POST['trans_type']}&shop_dayname={$_POST['dayname']}&record_count={$_POST['record_count']}"; header(sprintf("Location: %s",$editFormAction )); //$editFormAction } ?>
-1 ) { ?> -1 ) { // Gets data for the transaction being edited // shows transaction if edit link is clicked mysql_select_db($database_YBDB, $YBDB); $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 $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()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); $trans_type = $row_Recordset2['transaction_type']; //This field is used to set edit box preferences // gets preferences of edit based on Transaction Type //mysql_select_db($database_YBDB, $YBDB); $query_Recordset3 = "SELECT * FROM transaction_types WHERE transaction_type_id = \"$trans_type\";"; $Recordset3 = mysql_query($query_Recordset3, $YBDB) or die(mysql_error()); $row_Recordset3 = mysql_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysql_num_rows($Recordset3); //$handler->debug($row_Recordset3); ?> > "; } else { echo "edit"; } $trans_url = ""; ?> $change_fund && $difference != 0) { $diff = "(" . number_format((float)$difference, 2, '.', '') . ")"; } else { $diff = ""; } } else { $cf = $change_fund; } echo ""; } ?>
Bike, Sale and Donation Log

Edit Transaction:

"; list_CurrentShopUsers_select('sold_to', $row_Recordset2['sold_to']); echo ""; $record_trans_id = $row_Recordset2['transaction_id']; if ($row_Recordset3['anonymous']) { echo ""; if ($row_Recordset2['anonymous']) { echo ""; } else { echo ""; } echo ""; } else { echo ""; } echo ""; echo ""; echo ""; echo ""; echo ""; } elseif($row_Recordset3['show_soldto_not_signed_in']) { echo ""; } ?>
 
 
  -
  " . $row_Recordset2['transaction_type'] . ""; echo ""; //list_transaction_types('transaction_type',$row_Recordset2['transaction_type'] ); ?>
 
 
 
 
 
> > > '; } ?>
  "; list_donation_locations_withheader('sold_to', $row_Recordset2['sold_to']); //- not required to be signed in. echo ""; // echo " Create New Location | // Edit Existing Location"; $record_trans_id = $row_Recordset2['transaction_id']; if ($row_Recordset3['anonymous']) { echo ""; if ($row_Recordset2['anonymous']) { echo ""; } else { echo ""; } echo ""; } else { echo ""; } echo ""; echo ""; echo ""; echo "
  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']); ?>
Donate

Start New Transaction:
    Select Type:

Shop Trans. Date Sale Type Patron Description Type Amount Edit Paid
' . $row_Recordset1['full_name'] . ""; } ?>  >    sold_by . ";"; $sql = mysql_query($query, $YBDB) or die(mysql_error()); $result = mysql_fetch_assoc($sql); if ( $history[$key]->original_price ) { $title = "Date: " . $history[$key]->date. "\r\n" . "Sold By: " . $result['full_name']. "\r\n" . "Original Price: " . $history[$key]->original_price . "\r\n" . "Paid: " . $history[$key]->amount . "\r\n" . "Redeemed Hours: " . floatval($history[$key]->redeemed_hours); echo "title='" . $title . "'"; } else { $title = "Date: " . $history[$key]->date. "\r\n" . "Transaction Performed By: " . $result['full_name']; echo "title='" . $title . "'"; } } ?> >  $value) { if ($i != "trans_id") { $trans_url .= "&$i" . "=" . $value; } } if (isset($trans_url)) { echo "edit >
"; echo 'Change Fund:' . " $$cf"; if ($diff != "") { echo "$diff"; } else { echo ""; } echo '| Credit Card: | Check: + Cash: = Sum: | Difference: '; echo "


Show transactions on or before: transaction type
curdate() AND shop_type = 'Mechanic Operation Shop',0,1) as CanEdit FROM shops WHERE shop_id = $shop_id;"; $query = mysql_query($sql, $YBDB) or die(mysql_error()); $result = mysql_fetch_assoc($query); } if(current_shop_by_ip()>=1) echo ''; else echo ''; if (current_shop_by_ip()>=1) echo "
" . "(" . $result['shop_id'] . ") " . $result['shop_location'] . " - " . $result['shop_type'] . " - " . $result['date']; ?>


"; // populate year pull-down list echo ""; // populate Accounts pull-down list echo ""; echo "

"; list_distinct_shop_years("gnucash_csv_year",""); echo "

"; echo ""; // range bar echo "

"; echo "
"; echo "
    
"; ?>