Skip to content

Commit

Permalink
half working tax class manager
Browse files Browse the repository at this point in the history
  • Loading branch information
illiphilli committed Jul 11, 2011
1 parent 84108dd commit 24ba9cd
Show file tree
Hide file tree
Showing 6 changed files with 281 additions and 0 deletions.
4 changes: 4 additions & 0 deletions framework/modules/administration/menus/ecomm.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
'text'=>"Address/Geo Settings",
'url'=>makeLink(array('controller'=>'address','action'=>'manage')),
),
array(
'text'=>"Manage Tax Classes",
'url'=>makeLink(array('controller'=>'tax','action'=>'manage')),
),
array(
'text'=>"Manage Status Codes",
'url'=>makeLink(array('controller'=>'order_status','action'=>'manage')),
Expand Down
109 changes: 109 additions & 0 deletions framework/modules/ecommerce/controllers/taxController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

##################################################
#
# Copyright (c) 2004-2011 OIC Group, Inc.
# Created by Adam Kessler @ 05/28/2008
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################

class taxController extends expController {
public $basemodel_name = 'taxclass';

//protected $permissions = array_merge(array("test"=>'Test'), array('copyProduct'=>"Copy Product"));
//protected $add_permissions = array();
public $useractions = null; // keeps it from showing up in available modules to activate

function name() { return $this->displayname(); } //for backwards compat with old modules
function displayname() { return "e-Commerce Tax Class Manager"; }
function description() { return "Manage tax classes for your Ecommerce store"; }
function author() { return "OIC Group, Inc"; }
function hasSources() { return true; }
function hasViews() { return true; }
function hasContent() { return true; }
function supportsWorkflow() { return false; }
function isSearchable() { return true; }
function canImportData() { return true; }
function canExportData() { return true; }

function manage() {
global $db;

expHistory::set('managable', $this->params);

$sql = "
SELECT
exponent_tax_class.id,
exponent_tax_zone.`name` AS zonename,
exponent_tax_rate.rate as rate,
exponent_tax_class.`name` AS classname,
exponent_geo_country.`name` as country,
exponent_geo_region.`name` as state
FROM exponent_tax_class INNER JOIN exponent_tax_rate ON exponent_tax_class.id = exponent_tax_rate.class_id
INNER JOIN exponent_tax_zone ON exponent_tax_rate.zone_id = exponent_tax_zone.id
INNER JOIN exponent_tax_geo ON exponent_tax_geo.zone_id = exponent_tax_zone.id
INNER JOIN exponent_geo_country ON exponent_tax_geo.country_id = exponent_geo_country.id
INNER JOIN exponent_geo_region ON exponent_tax_geo.region_id = exponent_geo_region.id
";

$taxes = $db->selectObjectsBySql($sql);

assign_to_template(array('taxes'=>$taxes));
}

function manage_zones() {
global $db;

expHistory::set('managable', $this->params);

$sql = "
SELECT
*
FROM exponent_tax_zone ORDER BY name ASC;
";

$zones = $db->selectObjectsBySql($sql);

assign_to_template(array('zones'=>$zones));
}

function edit_zone() {
global $db;

$sql = "
SELECT
*
FROM exponent_tax_zone ORDER BY name ASC;
";

$zones = $db->selectObjectsBySql($sql);

assign_to_template(array('zones'=>$zones));
}

function update_zone() {
global $db;
$obj->name = $this->params['name'];
$db->insertObject($obj,'tax_zone');
expHistory::back();
}

}

?>
26 changes: 26 additions & 0 deletions framework/modules/ecommerce/views/tax/edit.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{*
* Copyright (c) 2007-2008 OIC Group, Inc.
* Written and Designed by Adam Kessler
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

{form action=update}
{control type="hidden" name="id" value=$record->id}
{control type="text" name="name" label="Class Name" value=$record->classname}
{control type="text" name="rate" label="Rate" value=$record->rate}
{control type="dropdown" name="zone" label="Zone" values=$record->zones default=$record->zonename}
{control type=state name=state label="State/Province" value=$record->state}
{control type=country name=country label="Country" value=$record->country}

{control type="buttongroup" submit="Submit" cancel="Cancel"}
{/form}
22 changes: 22 additions & 0 deletions framework/modules/ecommerce/views/tax/edit_zone.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{*
* Copyright (c) 2007-2008 OIC Group, Inc.
* Written and Designed by Adam Kessler
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

{form action=update_zone}
{control type="hidden" name="id" value=$record->id}
{control type="text" name="name" label="Zone Name" value=$record->zone}

{control type="buttongroup" submit="Submit" cancel="Cancel"}
{/form}
69 changes: 69 additions & 0 deletions framework/modules/ecommerce/views/tax/manage.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{*
* Copyright (c) 2007-2008 OIC Group, Inc.
* Written and Designed by Adam Kessler
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

{css unique="tax" corecss="tables"}

{/css}

<h1>{"Tax Class Manager"|gettext}</h1>

{icon action=edit class="add" text="Add a Tax Class"}
{icon action=manage_zones class="manage" text="Manage Zones"}
{br}
{br}
<table border="0" cellspacing="0" cellpadding="0" class="exp-skin-table">
<thead>
<tr>
<th>
Class
</th>
<th>
Rate
</th>
<th>
Zone
</th>
<th>
State
</th>
<th>
Country
</th>
</tr>
</thead>
<tbody>
{foreach from=$taxes item=tax key=key name=taxes}
<tr class="{cycle values="odd,even"}">
<td>
{$tax->classname}
</td>
<td>
{$tax->rate|number_format:2}%
</td>
<td>
{$tax->zonename}
</td>
<td>
{$tax->state}
</td>
<td>
{$tax->country}
</td>
</tr>
{/foreach}
</tbody>
</table>

51 changes: 51 additions & 0 deletions framework/modules/ecommerce/views/tax/manage_zones.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{*
* Copyright (c) 2007-2008 OIC Group, Inc.
* Written and Designed by Adam Kessler
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

{css unique="tax" corecss="tables"}

{/css}

<h1>{"Tax Zone Manager"|gettext}</h1>

{icon action=edit_zone class="add" text="Add a Tax Zone"}
{br}
{br}
<table border="0" cellspacing="0" cellpadding="0" class="exp-skin-table">
<thead>
<tr>
<th style="width:50px">
&nbsp;
</th>
<th>
Name
</th>
</tr>
</thead>
<tbody>
{foreach from=$zones item=zone key=key name=zones}
<tr class="{cycle values="odd,even"}">
<td>
{icon action=edit_zone record=$zone img="edit.png"}
{icon action=delete record=$zone img="delete.png"}
</td>
<td>
{$zone->name}
</td>
</tr>
{/foreach}
</tbody>
</table>

0 comments on commit 24ba9cd

Please sign in to comment.