0){ $trans_id = $_GET['trans_id']; } else { $trans_id =-1;} //error switch ($_GET['error']) { case 'transactioncomplete': $error_message = 'Paypal transaction was sucessful'; break; case 'transactioncanceled': //this is a sample error message. insert error case here $error_message = 'Paypal transaction was canceled'; 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 if($_GET['trans_date']>0){ $trans_date = "AND date <= ADDDATE('{$_GET['trans_date']}',1)" ; } else { $datetoday = current_date(); $trans_date ="AND date <= ADDDATE('{$datetoday}',1)"; $trans_date = ""; } //dayname if($_GET['shop_dayname']=='alldays'){ $shop_dayname = ''; } elseif(isset($_GET['shop_dayname'])) { $shop_dayname = "AND DAYNAME(date) = '" . $_GET['shop_dayname'] . "'"; } else { $shop_dayname = ''; } //Transaction_type if($_GET['trans_type']=='all_types'){ $trans_type = ''; } elseif(isset($_GET['trans_type'])) { $trans_type = "AND transaction_log.transaction_type = '" . $_GET['trans_type'] . "'"; } else { $trans_type = ''; } //record_count if($_GET['record_count']>0){ $record_count = $_GET['record_count']; } else { $record_count = 30;} // This is the recordset for the list of logged transactions mysql_select_db($database_YBDB, $YBDB); $query_Recordset1 = "SELECT *, 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(community_bike,CONCAT(quantity, ' Bikes: ', location_name),IF(show_soldto_location, CONCAT(location_name,' Donation'), description)),25) 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 = $_SERVER['PHP_SELF']; //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']; if ($initial_date_startstorage) { $date_startstorage = current_datetime(); $date = "NULL"; } else { $date_startstorage = "NULL"; $date = current_datetime(); } //end if $insertSQL = sprintf("INSERT INTO transaction_log (transaction_type,shop_id, date_startstorage, date, quantity) VALUES (%s,%s, %s ,%s,%s)", GetSQLValueString($_POST['transaction_type'], "text"), GetSQLValueString($shop_id, "text"), GetSQLValueString($date_startstorage, "date"), GetSQLValueString($date, "date"), GetSQLValueString(1, "int")); //echo $insertSQL; mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($insertSQL, $YBDB) or die(mysql_error()); // 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 $LoadPage = $_SERVER['PHP_SELF'] . "?trans_id={$newtrans}"; header(sprintf("Location: %s", $LoadPage)); } // end Form Submit New Transaction //Form Edit Record =============================================================================== if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "FormEdit") && ($_POST["EditSubmit"] == "Update")) { //Error Correction $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']); $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 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($_POST['description'], "text"), GetSQLValueString($sold_to, "int"), GetSQLValueString($sold_by, "int"), GetSQLValueString($_POST['shop_id'], "int"), GetSQLValueString($_POST['transaction_id'], "int")); //"2006-10-12 18:15:00" mysql_select_db($database_YBDB, $YBDB); $Result1 = mysql_query($updateSQL, $YBDB) or die(mysql_error()); $trans_id = $_POST['transaction_id']; header(sprintf("Location: %s",$editFormAction . "?trans_id={$trans_id}" )); //$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}" )); //$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 )); //$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}" )); //$editFormAction } //Change Date isset($_POST["MM_update"]) ========================================================= if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "ChangeDate")) { $editFormAction = $_SERVER['PHP_SELF'] . "?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) echo "current shop"; else echo "no shop"; ?> |