2 /* $Revision: 1.13 $ */
4 $PageSecurity = 11; // only allow accountant access
6 if (isset($_POST['TaxAuthority'])){
7 $TaxAuthority = $_POST['TaxAuthority'];
9 if (isset($_GET['TaxAuthority'])){
10 $TaxAuthority = $_GET['TaxAuthority'];
13 include('includes/session.inc');
14 $title = _('Tax Rates');
15 include('includes/header.inc');
17 /* <-- $Revision: 1.13 $ --> */
19 if (!isset($TaxAuthority)){
20 prnMsg(_('This page can only be called after selecting the tax authority to edit the rates for') . '. ' . _('Please select the Rates link from the tax authority page') . ".<BR><A HREF='$rootpath/TaxAuthorities.php'>" . _('click here') . '</A> ' . _('to go to the Tax Authority page'),'error');
21 include ('includes/footer.inc');
26 if (isset($_POST['UpdateRates'])){
28 $TaxRatesResult = DB_query('SELECT taxauthrates.taxcatid,
30 taxauthrates.dispatchtaxprovince
32 WHERE taxauthrates.taxauthority=' . $TaxAuthority,
35 while ($myrow=DB_fetch_array($TaxRatesResult)){
37 $sql = 'UPDATE taxauthrates SET taxrate=' . ($_POST[$myrow['dispatchtaxprovince'] . '_' . $myrow['taxcatid']]/100) . '
38 WHERE taxcatid = ' . $myrow['taxcatid'] . '
39 AND dispatchtaxprovince = ' . $myrow['dispatchtaxprovince'] . '
40 AND taxauthority = ' . $TaxAuthority;
44 prnMsg(_('All rates updated successfully'),'info');
50 /*Display updated rates
53 $TaxAuthDetail = DB_query('SELECT description FROM taxauthorities WHERE taxid=' . $TaxAuthority,$db);
54 $myrow = DB_fetch_row($TaxAuthDetail);
55 echo '<FONT SIZE=3 COLOR=BLUE><B>' . _('Update') . ' ' . $myrow[0] . ' ' . _('Rates') . '</B></FONT>';
57 echo "<FORM ACTION='" . $_SERVER['PHP_SELF'] . '?' . SID
."' METHOD=POST>";
59 echo "<INPUT TYPE=HIDDEN NAME='TaxAuthority' VALUE=$TaxAuthority>";
61 $TaxRatesResult = DB_query('SELECT taxauthrates.taxcatid,
62 taxcategories.taxcatname,
64 taxauthrates.dispatchtaxprovince,
65 taxprovinces.taxprovincename
66 FROM taxauthrates INNER JOIN taxauthorities
67 ON taxauthrates.taxauthority=taxauthorities.taxid
68 INNER JOIN taxprovinces
69 ON taxauthrates.dispatchtaxprovince= taxprovinces.taxprovinceid
70 INNER JOIN taxcategories
71 ON taxauthrates.taxcatid=taxcategories.taxcatid
72 WHERE taxauthrates.taxauthority=' . $TaxAuthority . "
73 ORDER BY taxauthrates.dispatchtaxprovince,
74 taxauthrates.taxcatid",
77 if (DB_num_rows($TaxRatesResult)>0){
79 echo '<CENTER><TABLE CELLPADDING=2 BORDER=2>';
80 $TableHeader = "<TR><TD Class='tableheader'>" . _('Deliveries From') . '<BR>' . _('Tax Province') . "</TD>
81 <TD Class='tableheader'>" . _('Tax Category') . "</TD>
82 <TD Class='tableheader'>" . _('Tax Rate') . ' %</TD></TR>';
85 $k = 0; //row counter to determine background colour
88 while ($myrow = DB_fetch_array($TaxRatesResult)){
90 if ($OldProvince!=$myrow['dispatchtaxprovince'] AND $OldProvince!=''){
91 echo '<TR BGCOLOR="#555555"><FONT SIZE=1> </FONT><TD COLSPAN=3></TD></TR>';
95 echo "<tr bgcolor='#CCCCCC'>";
98 echo "<tr bgcolor='#EEEEEE'>";
104 <td><INPUT TYPE=TEXT NAME=%s MAXLENGTH=5 SIZE=5 VALUE=%s></td>
106 $myrow['taxprovincename'],
107 $myrow['taxcatname'],
108 $myrow['dispatchtaxprovince'] . '_' . $myrow['taxcatid'],
109 $myrow['taxrate']*100 );
111 $OldProvince = $myrow['dispatchtaxprovince'];
116 echo "<BR><INPUT TYPE=SUBMIT NAME='UpdateRates' VALUE='" . _('Update Rates') . "'></CENTER>";
117 } //end if tax taxcatid/rates to show
119 prnMsg(_('There are no tax rates to show - perhaps the dispatch tax province records have not yet been created?'),'warn');
124 echo '<BR><A HREF="' . $rootpath . '/TaxAuthorities.php?' . SID
. '">' . _('Tax Authorities') . '</A>';
125 echo '<BR><A HREF="' . $rootpath . '/TaxGroups.php?' . SID
. '">' . _('Tax Groupings') . '</A>';
126 echo '<BR><A HREF="' . $rootpath . '/TaxCategories.php?' . SID
. '">' . _('Tax Categories') . '</A>';
127 echo '<BR><A HREF="' . $rootpath . '/TaxProvinces.php?' . SID
. '">' . _('Dispatch Tax Provinces') . '</A>';
129 include( 'includes/footer.inc' );