Wordpress database - obtaining quantity of sales figures - mysql

Here is what I want to do. I am setting up a new commerce website for myself using WooCommerce. From each sale I will be donating $5 to a charity. In the header of my Wordpress site I want to have a counter that shows how much money we have donated in this current week.
So how do I get the required number from the WP database? I guess I need to some how extract the number of sales from the database, multiply that by 5 and put it in the header.php with a $ infront of it.
I don't mind if I have to change code at the beginning of each week to reset the counter.

Simple solution store a value of number of sales, create a wordpress option and increment it in the process of making the sale.
Otherwise you need to look more into the db structure of your ecommerce code and perform a count query of all records between today - 7d and today.

Related

I'm trying to create a multi-table Query on MS Access. Both tables contain dates but at different frequency

I'm trying to create a Multi-Table Query on Access to improve operational efficiency.
I have two Tables:
EPOS (where: Date/Item Code/Sales for the day are contained on a daily basis)
MATERIAL (where: Date/Item Code/Opening Stock for the day are contained on a weekly basis)
I have Daily data for EPOS (Sales), but only Weekly data for MATERIAL (Opening Stock).
I'm trying to Run a Query that allows me to filter by item code in the Design View, and display daily data for EPOS and just weekly data for Opening Stock.
I'm trying to have it displayed at this frequency, with Opening Stock being shown just for where data is available.
When I've tried, my data would only be displayed on a Weekly Frequency (basically, only where Opening Stock information is available).
See here
I tried my best to make my request as clear and concise as possible, any questions, please ask.
Thanks in advance for your help.

Handling a "ledger" in MySQL and keeping track of the total balance

I have a sort of simple ledger in my app. I keep track of each balance adjustment i.e. deposit $10 into an account with $5 creates a new row containing the amount of $10 and the total of $15. The $15 number is the part I'm having a hard time figuring out how I should handle it.
I can do it totally app code side with my DB adapter by getting the last row's total and adding to the new amount and creating a new total_balance based on that. This, however, feels wrong to me for some reason. I feel like I should be able to do this logic all in MySQL somehow.
Something like "create a new record WHERE user_id='123' and the amount is +10" and it'd make a new record with 15 for the total_balance automatically.
Is this possible?

Access 2010 update date field based on another field

I'm relatively new to Access and VBA but I have managed to get some basic VBA tricks working in both Access and Excel. Now I've got a challenge that I can't seem to crack. I'm building a database to track maintenance of a small trucking fleet. I've got most of the tables and forms I need to do the basic tracking and management of equipment and maintenance in place.
One of the things we're tracking is called PM's which stands for preventative maintenance (lube jobs and oil changes). We do those on calendar intervals for trailers and mileage intervals for tractors. Right now, I'm trying to get the calendar tracked equipment working. I've a table called tblEquipmentMaster which is where all the specifics for each piece of equipment is kept (make, model, year, VIN, etc) and that table has a field called LastPMDate. All the maintenance records go in two other tables, tblMaintenance which records the unit number, vendor, invoice date and invoice amount and tblMaintenanceDetails which records the each line item of work that was performed on the unit (i.e. replaced water pump, replaced headlight etc).
The maintenance details table also contains a drop down list of standard maintenance codes to allow for easier searching of certain maintenance items later. One of those codes is PM. I also have several forms built to interact with these tables including a data entry form for adding new maintenance records.
What I'm trying to accomplish is to have the LastPMDate field for any unit number in tblEquipmentMaster automatically update to match the InvoiceDate field in tblMaintenance anytime an invoice is entered for that unit number which has a line item containing the code PM.
I've tried building an update query to do this but in addition to changing the LastPMDate field like I want it to, it also ends up changing the invoice dates for all previous PM invoices to the date of the last invoice which contained a PM. Not good.
So my question is, would an update query be the best way to do this or would I be better off with some sort of VBA solution? I have an add record button on my maintenance invoice data entry form which users use as a save record/clear form button when all the info for an invoice has been entered. I'm thinking some VBA code tied to the on_click of that button which would look at the invoice you just added, determine if it contains the PM maintenance code, then update LastPMDate field for that unit number with invoice date from that invoice would be a good way to do it but I honestly have no idea what functions or methods I'd need to get that to work.
Any insights or suggestions appreciated.
It's very hard to follow the flow of what you are describing, even if I have experience of PM and AM (Autonomous maintenance).
What is lacking is the relations between the three tables.
Nevertheless I prefer VBA solutions (maybe because I started programming when everything had to be written...). With VBA you can finely control your workflow.
If I understood well the 1st table is tblMaintenance in which you have the Invoice data.
Then you should have to scan the tblMaintenanceDetails to find the list of PMs and filter the tblEquipmentMaster with current PM value to update the LastPMDate with the date of the 1st table.
Did I succeed in providing you an idea to solve your problem?
Let me know.

Access: Updating end of day Share values from Yahoo finance

am about to make an addition to my database that might make life much easier for users that are not normally accustomed to using it.
I have a table in my database; which holds Historical_stock_data and Historical_currency_data (Values to convert Share Price into dollars) in the other table. Each of them have basically got four & three columns (StockCode, Dates, SharePrice, Volume) and (CurrencyCode, Dates, Rates) respectively.
Now at the end of each trading day; I need to update the both tables. There around 200 companies in the database; and currently I basically have a portfolio in Yahoo finance holding all 200 companies which I download into Excel and edit so it matches the columns; and then manually update the database by adding to the table. (I can use the transfer spreadsheet method as well to do this but I ran into a problem once with it so do it manually now; my coding skills are not the greatest)
The currency prices, since there are only around 6 currencies in the database to dollars; I update them manually; this is not an issue at the moment; but if more companies from different countries are included than it would be easier; and besides it is always better to automate things; so was wondering if this was possible as well.
So if there was a way to update these values directly into Access at the end of each day without having to bother with Excel; that would be great. If there is then if I'm shown an example of what sort of code to use with just one example; I should be able to finish it.
Search on "yahoo stock price excel" and you should find lots of sample code. Then convert the code to using recordsets/tables instead of cells and you're done.

I want to display clients based on a five day week on a form (All 5 days at once)

I've got a list of clients who have certain tasks done on a weekly basis. Currently we use an excel spreadsheet that keeps track of this but I am in the works of automating it. In the process of moving this into our MS Access system, I have created a form that does this for a single day and can display a report that outputs in the manner I want the form to look but I cannot get the form to look like that so the user can see all the days of the week for all the clients at once. I suppose I could do this in a subform per client but it seems a bit messy...
The spreadsheet we currently use has Column headers that state the Date and the rows are sort of grouped up by client that are for the number of times the given action occured, the timestamp of when it happened and other various data that happened on that day.
For the life of me I cannot think of a way to view all the records for that given week, grouped in detail per client all at once on the form. I can think of some ways to do this through VBA with recordsets but would like to know is there is a simpler way to do this that is easier to maintain.
Is there a way to do this with the use of a query and a few small scale tricks that don't involve storing recordsets? Keep in mind that this is for Access 2000, I only wish we would upgrade to '03.
Why not use five subforms? One for today, another for tomorrow, etc for
the next five business days. – Tony Toews Sep 12 at 20:57
That is the answer I've gone with and it works BEAUTIFULLY with the setup we are using. Thanks for the wonderful idea!