Jump to content

Inventory Report


adamfrey

Recommended Posts

I wholesale some items, so it would be great to be able to look at the inventory for the whole store or just by one brand/manufacturer.  Would be even MORE amazing if it showed the item sales over the past 6 or 12 months....one can dream...maybe I just need a customer SQL report...

Link to comment
Share on other sites

Try this edit:

reports.index.php:

Find:

  </fieldset>
  <div><input type="submit" class="button" value="{$LANG.common.display}"></div>
  </div>
  
</form>

Add above:

<!-- -->
    <div>
      <label for="manufacturer_search">{$LANG.catalogue.choose_manufacturers}</label>
      <span>{* {$LANG.catalogue.error_manufacturer_none}{$LANG.catalogue.manufacturer_limit}{$LANG.catalogue.title_manufacturer} *}
        <select id="manufacturer_search" multiple="multiple" name="report[manufacturer][]">
          {foreach from=$MANUFACTURERS item=manufacturer }
          <option value="{$manufacturer.value}" {$manufacturer.selected}>{$manufacturer.name}</option>
          {/foreach}
        </select>
      </span>
    </div>
<!-- -->



reports.index.inc.php

Find:

$GLOBALS['main']->addTabControl($lang['reports']['tab_results'], 'results');
## Fetch data, and display, and/or provide download
$oid_col = $GLOBALS['config']->get('config', 'oid_mode') =='i' ?  $GLOBALS['config']->get('config', 'oid_col') : 'cart_order_id';

Add before:

## Manufacturer filtering
if (isset($report_filter['manufacturer']) && is_array($report_filter['manufacturer'])) {
    foreach ($report_filter['manufacturer'] as $value) {
        $select_manufacturer[(int)$value] = true;
        $manufacturer[] = (int)$value;
    }
    if (($inventory_of_these_manufacturers = $GLOBALS['db']->select('CubeCart_inventory',array('product_id'), sprintf('`manufacturer` IN (%s)', implode(',', $manufacturer)))) !== false) {
        foreach($inventory_of_these_manufacturers as $inv_man) { $man_result[$inv_man['product_id']] = true; $man_result_ids[] = $inv_man['product_id']; }
    }
    if (!empty($man_result_ids) && ($orders_having_items_with_these_manufacturer_ids = $GLOBALS['db']->select('CubeCart_order_inventory', array('cart_order_id'), sprintf('`product_id` IN (%s)', implode(',', $man_result_ids)))) !== false) {
        foreach($orders_having_items_with_these_manufacturer_ids as $an_order) { $order_result[$an_order['cart_order_id']] = true; $cart_result_ids[] = "'".$an_order['cart_order_id']."'"; }
    }
    if (!empty($cart_result_ids)) { $where .= sprintf(' AND `cart_order_id` IN (%s)', implode(',', $cart_result_ids)); }
    $GLOBALS['smarty']->assign('REPORT_TITLE', $report_title." == Selected Manufacturers");
}


Find:

$page_content = $GLOBALS['smarty']->fetch('templates/reports.index.php');

foreach ($GLOBALS['hooks']->load('admin.reports.display') as $hook) {
    include $hook;
}

Add above:

/* */
// Fetch all data from CubeCart_manufacturers
$manufacturers = $GLOBALS['db']->select('CubeCart_manufacturers', false);
// Build $smarty_data['manufacturers'][] = array('value', 'selected', 'name')
foreach ($manufacturers as $manufacturer) {
  $smarty_data['manufacturers'][] = array(
    'value' => $manufacturer['id'],
    'name' => $manufacturer['name'],
    'selected' => (isset($select_manufacturer[$manufacturer['id']]) && $select_manufacturer[$manufacturer['id']]) ? ' selected="selected"' : ''
  );
}
// Assign to "MANUFACTURERS"
$GLOBALS['smarty']->assign('MANUFACTURERS',$smarty_data['manufacturers']);
$GLOBALS['smarty']->assign('MANUFACTURERS_SELECT',$select_manufacturer);
$GLOBALS['smarty']->assign('MANUFACTURERS_REPORT_FILTER',$report_filter['manufacturer']);

Actually, this could be done with Code Snippets, or probably with a plugin.

But try this and see if it gets you what you want.

In admin, Sales Reports, Filter tab, there will be a multi-select list to fetch orders that have only an item(s) from the selected manufacturers.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...