summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorjeff <jeff>2008-04-02 20:42:44 +0000
committerjeff <jeff>2008-04-02 20:42:44 +0000
commit37f181cc0b65e4509dd68593cb7555db42d8e088 (patch)
treeeb6aea3dc3a4d79fbbb2cb549853b2d66d1300dc /httemplate/edit
parent4ddcaeadf6f2a313b37e276275a6d44a4c0d5f7d (diff)
checkpoint tax editors and correct a blunder
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-xhttemplate/edit/part_pkg.cgi7
-rw-r--r--httemplate/edit/part_pkg_taxoverride.html157
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi2
3 files changed, 115 insertions, 51 deletions
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 84f7498e1..2e7c732e6 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -94,13 +94,13 @@ Tax information
<TD align="right">Tax product</TD>
<TD>
<INPUT name="part_pkg_taxproduct_taxproductnum" id="taxproductnum" type="hidden" value="<% $hashref->{'taxproductnum'}%>">
- <INPUT name="part_pkg_taxproduct_description" id="taxproduct_description" type="text" value="<% $taxproduct_description %>" size="12" onclick="overlib( OLiframeContent('part_pkg_taxproduct.html?'+document.getElementById('taxproductnum').value, 800, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
+ <INPUT name="part_pkg_taxproduct_description" id="taxproduct_description" type="text" value="<% $taxproduct_description %>" size="12" onclick="overlib( OLiframeContent('part_pkg_taxproduct.html?'+document.getElementById('taxproductnum').value, 1000, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
</TD>
</TR>
<TR>
<TD colspan="2" align="right">
<INPUT name="tax_override" id="tax_override" type="hidden" value="<% $tax_override %>">
- <A href="javascript:void(0)" onclick="overlib( OLiframeContent('part_pkg_taxoverride.html?'+document.getElementById('tax_override').value, 800, 400, 'tax_product_popup'), CAPTION, 'Edit product tax overrides', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
+ <A href="javascript:void(0)" onclick="overlib( OLiframeContent('part_pkg_taxoverride.html?selected='+document.getElementById('tax_override').value, 1100, 600, 'tax_product_popup'), CAPTION, 'Edit product tax overrides', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
<% $tax_override ? 'Edit tax overrides' : 'Override taxes' %>
</A>
</TD>
@@ -467,7 +467,8 @@ if ( $cgi->param('clone') ) {
(@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1})
unless $part_pkg;
$tax_override =
- join (",", map {$_->taxnum} qsearch('part_pkg_taxoverride',{'pkgpart'=>$1}))
+ join (",", map {$_->taxclassnum}
+ qsearch('part_pkg_taxoverride',{'pkgpart'=>$1}))
unless $part_pkg;
$part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
$pkgpart = $part_pkg->pkgpart;
diff --git a/httemplate/edit/part_pkg_taxoverride.html b/httemplate/edit/part_pkg_taxoverride.html
index 61cca1fbc..ba709ce64 100644
--- a/httemplate/edit/part_pkg_taxoverride.html
+++ b/httemplate/edit/part_pkg_taxoverride.html
@@ -1,61 +1,124 @@
-<%doc>
+<% include('/elements/header-popup.html', 'Override taxes', '', 'onload="resizeFrames()"') %>
- The crappy version
-
-</%doc>
-<% include('/elements/header-popup.html', 'Select tax product') %>
+<TABLE WIDTH="100%" HEIGHT="100%">
+ <TR><TD>
+ <iframe name="selected" src="<% $p %>browse/tax_class.html?_type=select;magic=select;maxrecords=15;offset=<% $selected_offset %>;selected=<% $selected %>;" width="100%" frameborder="0" border="0" id="selectorSelected" scrolling="no">
+</iframe>
+ <BR>
+ </TD></TR>
+
+ <TR><TD>
+<FORM="dummy">
+ <CENTER>
+ <INPUT type="submit" value="Finish" onclick="s=fetchSelected(); s.shift(); parent.document.getElementById('tax_override').value=s.toString(); parent.cClick();">
+ <INPUT type="reset" value="Cancel" onclick="parent.cClick();">
+ </CENTER>
+</FORM>
+ </TD></TR>
+
+ <TR><TD>
+ <iframe name="unselected" src="<% $p %>browse/tax_class.html?_type=select;magic=omit;maxrecords=15;offset=<% $unselected_offset %>;omit=<% $selected %>;" width="100%" frameborder="0" border="0" id="selectorUnselected" scrolling="no">
+</iframe>
+ <BR>
+ </TD></TR>
+
+</TABLE>
<SCRIPT>
- function saveit2() {
- var num = parent.document.getElementById('tax_override');
- var sel = document.getElementById('taxoverride_popup_select');
- var value = '';
- for (i=0; i< sel.length; i++) {
- if (sel.options[i].selected) {
- value = value + sel.options[i].value + ",";
+
+ function resizeFrames() {
+ //frames['selected'].style.height =
+ // frames['selected'].contentWindow.document.body.scrollHeight + "px";
+ //frames['unselected'].style.height =
+ // frames['unselected'].contentWindow.document.body.scrollHeight + "px";
+ var f = document.getElementById('selectorSelected');
+ f.style.height = f.contentWindow.document.body.scrollHeight + "px";
+ var f = document.getElementById('selectorUnselected');
+ f.style.height = f.contentWindow.document.body.scrollHeight + "px";
+ }
+
+ function fetchOffset(search) {
+ var value = 0;
+ if (search.length > 1) {
+ var params = search.split(';');
+ for (i=0; i<params.length; i++) {
+ if (params[i].substr(0,7) == 'offset=') {
+ value = params[i].substr(7);
+ }
+ }
+ }
+ return value;
+ }
+
+ function fetchOffsetStrings() {
+ return 'selected_offset=' +
+ fetchOffset(frames['selected'].location.search) + ';' +
+ 'unselected_offset=' +
+ fetchOffset(frames['unselected'].location.search) + ';';
+ }
+
+ function fetchSelected() {
+ var i;
+ var selected = new Array;
+ var replace = '?';
+ if (window.location.search.length > 1) {
+ var search = window.location.search.substr(1).split(';');
+ for (i=0; i<search.length; i++) {
+ if (search[i].substr(0,9) == 'selected=') {
+ selected = search[i].substr(9).split(',')
+ }else if (search[i].substr(0,16) == 'selected_offset=') {
+ }else if (search[i].substr(0,18) == 'unselected_offset=') {
+ }else if (search[i].length) {
+ replace += search[i] + ';';
+ }
+ }
+ }
+ selected.unshift(replace);
+ return selected;
+ }
+ function doUnselect(classnum) {
+ var selected = fetchSelected();
+ var search = selected.shift();
+ //alert("discovered: "+selected.toString());
+ var i=-1, j=-1, k=selected.length;
+ while(++j < k) {
+ if (!(selected[j]==classnum)) {
+ selected[++i]=selected[j];
+ }
}
+ selected.length = ++i;
+ //alert("finished: "+selected.toString());
+
+ search += "selected=" + selected.toString() + ';';
+ window.location.search = search + fetchOffsetStrings();
}
- if (value.length > 0) {
- value = value.substr(0, value.length-1);
+ function doSelect(classnum) {
+ var selected = fetchSelected();
+ var search = selected.shift();
+ selected.push(classnum);
+ search += "selected=" + selected.toString() + ';';
+ window.location.search = search + fetchOffsetStrings();
}
-
- num.value = value;
- parent.cClick();
- }
</SCRIPT>
-<FORM="dummy" METHOD="POST" onsubmit="saveit2();return false;" >
-
-<% ntable("#cccccc", 2) %>
-<TR>
- <TD align="left">Tax override</TD>
- <TD>
- <% include( '/elements/select-table.html',
- 'table' => 'tax_rate',
- 'name_col' => 'taxname',
- 'curr_value' => \@curr_value,
- 'element_etc' => "id='taxoverride_popup_select'",
- 'multiple' => '1',
- )
- %>
- </TD>
-</TR>
-</TABLE>
-<BR><BR>
-<CENTER><INPUT type="submit" value="Select"></CENTER>
-</FORM>
+
<% include('/elements/footer.html') %>
+<%once>
+
+my $conf = new FS::Conf;
+</%once>
<%init>
-my $conf = new FS::Conf;
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+
+my $selected_offset = $1
+ if $cgi->param('selected_offset') =~/^(\d+)$/;
-my @curr_value;
-my ( $query ) = $cgi->keywords;
-$query =~ /^([\d,]+)$/;
-push @curr_value, split ',', $1
- if $1;
+my $unselected_offset = $1
+ if $cgi->param('unselected_offset') =~/^(\d+)$/;
-unless (scalar(@curr_value)) {
- #push @curr_value, map {$_=>taxnum} $part_pkg->tax_rate;
-}
+my $selected = $1
+ if $cgi->param('selected') =~/^([,\d]+)$/;
</%init>
diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi
index eac20af57..94bff0fbb 100755
--- a/httemplate/edit/process/part_pkg.cgi
+++ b/httemplate/edit/process/part_pkg.cgi
@@ -116,7 +116,7 @@ unless ( $error || $conf->exists('agent_defaultpkg') ) {
unless ( $error ) {
$error = $new->process_m2m(
'link_table' => 'part_pkg_taxoverride',
- 'target_table' => 'tax_rate',
+ 'target_table' => 'tax_class',
'params' => \@tax_overrides,
);
}