-
Posts
24,614 -
Joined
-
Last visited
-
Days Won
835
Everything posted by Barand
-
How you do it depends on how you are entering the data. The are basically two approaches... Create the timesheet record first then, each day add that days stafftime record Have a form where you enter the timesheet header data and all days' times at once for a user. If you use the first, have a dropdown so the user can select the timesheet record id and write that id with the day's times into stafftime. Doing it the second way, on posting the form you would first write the timesheet record (id would be an autoincrement column) then call lastInserId() to get the id of that new record. You then insert the time records with that last inserted id as the sheet_id.
-
Received and loaded. Thanks. For each timesheet record you should have up to 7 (1 for each day of the week) records in stafftime. These stafftime records for the week should have a sheet_id value which matches the timesheet id of the parent timesheet record. You stafftime.sheet_id values match none of the timesheet ids.
-
Not what I asked for. There is no way that enables me to run your query on your data. I wanted something similar to what I posted in your previous topic...
-
Do you want to post a dump of your data so I can run your query at my end?
-
Did you read the bit in the JOIN tutorial about LEFT JOIN to a table (user in your case) and then referencing a column from that table in the WHERE clause?
-
Follow the link in my sig. There's a section in the tutorials dedicated to JOINS
-
Put this line immediately before your line that creates your mysqli connection mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); That will force mysqli to report any erors it encounters.
-
As @gizmola said, the first problem is missing style= second) You are using obsolete html markup 3) you have specified a couple of classes but not put them inside the class="w3-container" 4) Again inline style without the style= 5) You have broken up the style attributes with a couple of rogue quotes
-
If you know the cat_id, can't you then determine the category? All you should need to pass is the cat_id, which should be the value in your options.
-
Why? What's the difference between your category and cat_title?
-
Looking at the code you posted it looks you have decided to ignore the rules of syntax for inline style definitions and class specifications. Plus a bit of obsolete html markup thrown in for good measure
-
Haven't we been here before?
-
MySQL SELECT to get total sales by payment method and status
Barand replied to thara's topic in MySQL Help
Here's my attempt SELECT sale_date , sum(cashpaid) + sum(cashpartpaid) + sum(codpaid) as total_cash_sales , sum(cashdue) + sum(cashpartdue) + sum(carddue) + sum(coddue) as total_credit_sales , sum(codpaid) + sum(coddue) as total_cod_sales , sum(cardpaid) as total_card_sales FROM ( SELECT bad.basket_id , bad.amount_due as due , SUM(p.amount_paid) as paid , p.payment_method_id , b.payment_status , DATE(bad.sale_time) as sale_date , CASE WHEN payment_method_id = 1 AND payment_status = 'paid' THEN sum(p.amount_paid) ELSE 0 END as cashpaid , CASE WHEN payment_method_id = 1 AND payment_status = 'due' THEN bad.amount_due ELSE 0 END as cashdue , CASE WHEN payment_method_id = 1 AND payment_status = 'partial' THEN SUM(p.amount_paid) ELSE 0 END as cashpartpaid , CASE WHEN payment_method_id = 1 AND payment_status = 'partial' THEN bad.amount_due - SUM(p.amount_paid) ELSE 0 END as cashpartdue , CASE WHEN payment_method_id = 2 THEN SUM(p.amount_paid) ELSE 0 END as cardpaid , CASE WHEN payment_method_id = 2 THEN bad.amount_due - SUM(p.amount_paid) ELSE 0 END as carddue , CASE WHEN payment_method_id = 4 AND payment_status <> 'due' THEN SUM(p.amount_paid) ELSE 0 END as codpaid , CASE WHEN payment_method_id = 4 AND payment_status = 'due' THEN bad.amount_due ELSE 0 END as coddue FROM basket_amount_due bad JOIN basket b USING (basket_id) LEFT JOIN basket_payment p USING (basket_id) GROUP BY basket_id, payment_method_id ) detail GROUP BY sale_date; -
Or you could do at the source when you query your data. SELECT Firstname , Lastname , Coursename , CASE WHEN DateBooked IS NULL THEN '' ELSE DATE_FORMAT(DateBooked, '%d-%m-%Y') END as DateBooked, , DATE_FORMAT(ExpiryDate, '%d-%m-%Y') as ExpirtyDate , Notes FROM ....
-
I think you'll find they were mentioned a little earlier than that ... ... and I doubt that is the earliest.
- 19 replies
-
- php
- time calculations
-
(and 1 more)
Tagged with:
-
MySQL SELECT to get total sales by payment method and status
Barand replied to thara's topic in MySQL Help
Your payment status values are "Paid/Due/Partial" Do we have a couple of new Schrodinger cats in your latest calculation requirements... -
MySQL SELECT to get total sales by payment method and status
Barand replied to thara's topic in MySQL Help
-
MySQL SELECT to get total sales by payment method and status
Barand replied to thara's topic in MySQL Help
If I were showing totals by "Payment method" I would find it helpful to show the method descriptions in the row output. The main question - is that correct and what you wanted? -
Given the adage "Test data is that data for which the code works", here is the data I used for the queries I posted
- 19 replies
-
- php
- time calculations
-
(and 1 more)
Tagged with:
-
MySQL SELECT to get total sales by payment method and status
Barand replied to thara's topic in MySQL Help
None of those have a value of both 1 AND 2. That would mean, like Schrodinger's cat, they have two values at the same time, Some, though, do have a value of 1 OR 2 -
MySQL SELECT to get total sales by payment method and status
Barand replied to thara's topic in MySQL Help
Firstly, can you show me the record where the "payment_method_id" is both 1 and 2 ? You to need to change around the syntax of that first CASE statement , CASE WHEN p.payment_method_id IN (1, 2) THEN sum(amount_due) ELSE 0 END AS total_cash_sales = where date on or after today but before tomorrow. Isn't that just WHERE DATE(bv.sale_time) = CURDATE() Lastly, are you sure you want to GROUP BY sale_time? That gives you a total for each second, which is probably individual sales - not much of a summary. -
My money's on "Syntax error". (Error 4)
-
This fails $j = "{'admin': 1, 'moderator': 1}" ; $a = json_decode($j, 1); echo '<pre> a ' . print_r($a, 1) . '</pre>'; This works $j = '{"admin": 1, "moderator": 1}' ; $b = json_decode($j, 1); echo '<pre> b ' . print_r($b, 1) . '</pre>'; Note the quotes in the JSON string.
-
Doesn't your console have a "preserve" option? Or, add "return false" to the end of your submitData() function to stop the page refreshing
-
How do you define "does not work"? Because when I use your form and the first function, my console shows the data entered in the form