Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/19/2021 in all areas

  1. Just going forward, while these type of all in one functions with data & presentation are enticing (and I certainly wrote many of them back in my early days of web development) it's really an anti-pattern that you should avoid. Have a function that returns the data in a format, ideally json, but at very least in a clean php data like an array. Why json? Because it will be easier for you to wire it into a javascript based UI. In the meantime for server side coding, have a separate view script or template. You might organize these by putting them into a subdir named /views or /templates. You could write a simple render($view, $data) function that takes the parameters and require_once() your $view. At that point, your view templates can just concentrate on html, and using alternative php syntax, handle whatever looping you need.
    1 point
  2. I browsed through the code. Did you write this code? Is it from a Tutorial? I don't understand why something new would use Bootstrap 2.0.1, which is a 7 year old version of Bootstrap. I did not find the error messages you provided in your first message. Are these really the error messages that occurred? Without the exact messages, we can't pinpoint where that code is running from.
    1 point
  3. 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;
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.