Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

monthly sales - tax report

Recommended Posts

Below is the query that selects the orders


I want to also select on specific manufacturer. This means I need to select the product table using the o.products_id =p.products_id link and then only select on p.manufacturer_id = 1.


Can anyone show me the query mods for below??


$sales_query_raw = "select sum(ot.value) gross_sales, monthname(o.date_purchased) row_month, year(o.date_purchased) row_year, month(o.date_purchased) i_month, dayofmonth(o.date_purchased) row_day from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id) where ";

if ($HTTP_GET_VARS['status']) {

$status = tep_db_prepare_input($HTTP_GET_VARS['status']);

$sales_query_raw .= "o.orders_status =" . $status . " and ";


$sales_query_raw .= "ot.class = " . $class_val_subtotal;

if ($sel_month<>0) $sales_query_raw .= " and month(o.date_purchased) = " . $sel_month;

$sales_query_raw .= " group by year(o.date_purchased), month(o.date_purchased)";

if ($sel_month<>0) $sales_query_raw .= ", o.date_purchased";

$sales_query_raw .= " order by o.date_purchased desc";

$sales_query = tep_db_query($sales_query_raw);

$num_rows = tep_db_num_rows($sales_query);

if ($num_rows==0) echo '<tr><td class="smalltext">' . TEXT_NOTHING_FOUND . '</td></tr>';

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...