Jump to content

State Selection in Sales Report


peterp

Recommended Posts

Hi All,

          Could somebody please show me how I can include the selection of the 'State' as part of the filter in Sales Reports.

I think this can be done in Admin/templates/reports.index.php but due to my limited knowledge of html/php I'm not sure what changes I have to make.

I'm using cubecart ver 6.2

Thankyou and Best Regards,

Peterp

Link to comment
Share on other sites

Please make these edits:

In admin /sources/reports.index.inc.php, near the bottom, find:

$GLOBALS['smarty']->assign('STATUS', $smarty_data['status']);

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



Change to:

$GLOBALS['smarty']->assign('STATUS', $smarty_data['status']);

if (($countries = $GLOBALS['db']->select('CubeCart_geo_country')) !== false) {
	$store_country = $GLOBALS['config']->get('config', 'store_country');
	foreach ($countries as $country) {
		$country['selected'] = ($country['numcode'] == $store_country) ? true : false ;
		$smarty_data['list_country'][] = $country;
	}
	$GLOBALS['smarty']->assign('LIST_COUNTRY', $smarty_data['list_country']);
	$GLOBALS['smarty']->assign('STATE_JSON', state_json());
}

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



Then, near line 78, find:

$GLOBALS['smarty']->assign('REPORT_TITLE', $report_title);

Change to:

########### Country filtering
if (isset($report_filter['country'])) {
	$where .= ' AND `country_d` = '.(int)$report_filter['country'];
	$report_title .= ' for '.getCountryFormat((int)$report_filter['country'],'numcode','iso3');
	if (isset($report_filter['state']) && is_numeric($report_filter['state'])) {
		$where .= ' AND `state_d` = '.(int)$report_filter['state'];
		$report_title .= ':'.getStateFormat((int)$report_filter['state']);
	}
}

$GLOBALS['smarty']->assign('REPORT_TITLE', $report_title);


In the admin skin template reports.index.php, near the bottom, find:

	</div>

</form>

Change to:

	</div>

<script type="text/javascript">
var county_list = {$STATE_JSON};
</script>

</form>


Then, near line 81, find:

		</div>
		<div>
			<label for="report_status">{$LANG.orders.title_order_status}</label>

Change to:

		</div>

{* State Selector *}
<div>
	<label for="report_country">{$LANG.address.delivery_address}: {$LANG.address.country}</label>
	<span>
		<select name="report[country]" id="report_country" class="textbox country-list" rel="report_state">
{foreach from=$LIST_COUNTRY item=country}			<option value="{$country.numcode}"{if $country.selected} selected="selected"{/if}>{$country.name}</option>{/foreach}
		</select>
	</span>
</div>
<div>
	<label for="report_state">{$LANG.address.delivery_address}: {$LANG.address.state}</label>
	<span>
		<input type="text" id="report_state" name="report[state]" class="textbox state-list">
	</span>
</div>

		<div>
			<label for="report_status">{$LANG.orders.title_order_status}</label>

You may need to have CubeCart clear it's skin cache.

The CubeCart_order_summary table, state and state_d columns can hold anything. Only those countries with identified states/counties (USA, Canada, UK, a few others) will have CubeCart use the actual id value from the geo_zone table. The State text-entry field will change to a selector with the related state/county names. Otherwise, the state and state_d columns will have free-entry text. Since free-entry text is so unreliable to be matched, the database query won't include that - just the country.

 

Link to comment
Share on other sites

Hi Brian,

                This has worked just how I want it thankyou so much this greatly appreciated.

Also Brian thankyou for you invaluable help throughout the last year, and I would like to wish you and your family a very merry christmas and a happy new year.

Thanks again

Best Wishes

Peterp

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...