PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/assessment.php

http://ebpls.googlecode.com/
PHP | 259 lines | 189 code | 62 blank | 8 comment | 26 complexity | 5f4d074f8f2503e277941094504ae4a2 MD5 | raw file
  1. <?php
  2. if ($stat=='New') {
  3. $tftype=1;
  4. } elseif ($stat=='ReNew') {
  5. $tftype=2;
  6. } else {
  7. $tfttype=3;
  8. }
  9. //get naturecode
  10. $getnat = mysql_query ("select a.bus_code, b.naturedesc, a.cap_inv, a.last_yr
  11. from tempbusnature a, ebpls_buss_nature b
  12. where owner_id=$owner_id and business_id=$business_id and a.bus_code=b.natureid")
  13. or die ("cnt1".mysql_error());
  14. while ($getn = mysql_fetch_row($getnat)){
  15. $cnt = mysql_query ("select natureid
  16. from ebpls_buss_taxfeeother a, ebpls_buss_tfo c
  17. where natureid=$getn[0] and a.taxtype='$tftype' and c.tfoid=a.tfoid $tft ")
  18. or die ("cnt2".mysql_error());
  19. $cnt1 = mysql_num_rows($cnt);//get total count of tax per natureid
  20. $lop1 =0;
  21. $getd1 = mysql_query ("select c.tfodesc, a.taxfeeamtfor, a.taxfeeid, b.naturedesc, a.taxfeeind,
  22. a.taxfeeoption, a.taxfeemode,c.taxfeetype
  23. from ebpls_buss_taxfeeother a, ebpls_buss_nature b, ebpls_buss_tfo c
  24. where a.natureid=$getn[0] and b.natureid=$getn[0] and a.taxtype='$tftype'
  25. and c.tfoid=a.tfoid $tft")
  26. or die ("cnt3".mysql_error());
  27. //print labels
  28. print "<br><table border=1 align =center width=300><br>";
  29. print "<tr><td align=left>Line Of Business:</td><td>$getn[1]</td><td>Amount/Formula
  30. </td><td>Tax Due</td></tr>";
  31. print "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
  32. while ($lop1<$cnt1){
  33. while ($getd=mysql_fetch_row($getd1)) {
  34. $lop1=$lop1+=1;
  35. if ($PROCESS=='COMPUTE') {
  36. //gety tempassess
  37. $temp = mysql_query ("select a.natureid, a.taxfeeid, a.multi,
  38. c.tfodesc, b.taxfeeamtfor,b.taxfeeind
  39. from tempassess a, ebpls_buss_taxfeeother b, ebpls_buss_tfo c
  40. where a.assid='$varx' and b.taxtype='$tftype'
  41. and a.owner_id=$owner_id and a.business_id=$business_id and
  42. a.natureid=b.natureid and a.taxfeeid=b.taxfeeid and b.tfoid=c.tfoid $tft
  43. ") or die (mysql_error());
  44. $gethuh = mysql_fetch_row($temp);
  45. if ($gethuh[5]==2) { //compute formula
  46. //$d = '((int)';
  47. //$d='';
  48. echo "\$totind=$getn[2]$gethuh[4];\n";
  49. eval("\$totind=$getn[2]$gethuh[4];");
  50. } elseif ($gethuh[5]==3) { //get range
  51. $gethuh[4]='range';
  52. $getrange = mysql_query("select rangeamount
  53. from ebpls_buss_taxrange where
  54. taxfeeid=$gethuh[1] and rangelow = $gethuh[2]") or die ("f");
  55. $haveex = mysql_num_rows($getrange);
  56. if ($haveex<>1) {
  57. $getrange = mysql_query("select rangeamount from ebpls_buss_taxrange where
  58. taxfeeid=$gethuh[1] and rangelow <= $gethuh[2] and
  59. rangehigh >= $gethuh[2]") or die ("range".mysql_error());
  60. $lookrange = mysql_num_rows($getrange);
  61. if ($lookrange==0) {
  62. $getrange = mysql_query("select rangeamount
  63. from ebpls_buss_taxrange where
  64. taxfeeid=$gethuh[1] and rangeind = 2
  65. ") or die ("range".mysql_error());
  66. }
  67. }
  68. $range = mysql_fetch_row($getrange);
  69. if (is_numeric($range[0])) {
  70. $totind=$range[0];
  71. } else {
  72. $gethuh[4]=$range[0];
  73. eval("\$totind=$gethuh[2]$range[0];");
  74. }
  75. $totind = round($totind,2);
  76. } else { //constant
  77. $totind = $getn[2] * $gethuh[4];
  78. }
  79. $gethuh[2] = round($gethuh[2],2);
  80. $grandamt = $grandamt + $totind;
  81. if ($getd[4]==2 or $getd[4]==3) { //formula and range
  82. $btc = number_format($getn[2], 2);
  83. print "<tr><td align=left width=100>$gethuh[3]</td>
  84. <td align=right><input type=hidden name=x[$varx] size=5 value=$gethuh[2] >$btc</td>";
  85. } elseif ($getd[5]==3) {
  86. print "<tr><td align=left width=100>$gethuh[3]</td>
  87. <td align=right><input type=text name=x[$varx] size=5 value=$gethuh[2] ></td>";
  88. } else { //constant
  89. print "<tr><td align=left width=100>$gethuh[3]</td>
  90. <td align=right><input type=hidden name=x[$varx] size=5 value=$gethuh[2]>$gethuh[2]</td>";
  91. }
  92. $totind = round($totind,2);
  93. $taxdue = number_format($totind,2);
  94. print "<td align=right>
  95. <input type=hidden name=natureid[$varx] value=$gethuh[0]>
  96. <input type=hidden name=z[$varx] value=$gethuh[4]>$gethuh[4]
  97. <input type=hidden name=taxfeeid[$varx] value=$gethuh[1]></td>
  98. <td align=right><input type=hidden name=y$varx value=$totind size=5 readonly>$taxdue</td>
  99. </tr>";
  100. } else { //put to tempassess;
  101. if ($getd[4]==2 and $stat=='New') {
  102. $indi=1;
  103. $xv = $getn[2];
  104. eval("\$totind=$xv$getd[1];");
  105. $rtag ='';
  106. } elseif ($getd[4]==2 and $stat=='ReNew') {
  107. $indi=1;
  108. $xv = $getn[3];
  109. eval("\$totind=$xv$getd[1];");
  110. $rtag ='';
  111. } elseif ($getd[4]==3) {
  112. //$getd[1]='range';
  113. $xv = $getn[2];
  114. $getrange = mysql_query("select rangeamount, rangelow from ebpls_buss_taxrange where
  115. taxfeeid=$getd[2] and rangelow = $xv") or die ("f");
  116. $haveex = mysql_num_rows($getrange);
  117. if ($haveex<>1) {
  118. $getrange = mysql_query("select rangeamount from ebpls_buss_taxrange where
  119. taxfeeid=$getd[2] and rangelow <= $xv and
  120. rangehigh >= $xv") or die ("range".mysql_error());
  121. $lookrange = mysql_num_rows($getrange);
  122. if ($lookrange==0) {
  123. $getrange = mysql_query("select rangeamount from ebpls_buss_taxrange where
  124. taxfeeid=$getd[2] and rangeind = 2
  125. ") or die ("range".mysql_error());
  126. }
  127. }
  128. $range = mysql_fetch_row($getrange);
  129. if (is_numeric($range[0])) {
  130. $totind=$range[0];
  131. $rtag ='range';
  132. } else {
  133. $getd[1]=$range[0];
  134. eval("\$totind=$xv$range[0];");
  135. }
  136. } else {
  137. $indi=0;
  138. $xv=1;
  139. $totind = $getd[1];
  140. $rtag ='';
  141. }
  142. $totind = round($totind,2);
  143. $grandamt = $grandamt + $totind;
  144. if ($getd[4]==2 or $getd[4]==3) {
  145. $xd = number_format($xv,2);
  146. print "<tr><td align=left width=100>$getd[0] </td><td align=right>
  147. <input type=hidden name=x[$varx] size=5 value=$xv>$xd</td>";
  148. } elseif ($getd[5]==3) {
  149. print "<tr><td align=left width=100>$getd[0] </td><td align=right>
  150. <input type=text name=x[$varx] size=5 value=$xv></td>";
  151. } else {
  152. print "<tr><td align=left width=100>$getd[0] </td><td align=right>
  153. <input type=hidden name=x[$varx] size=5 value=$xv>$xv</td>";
  154. }
  155. if (is_numeric($getd[1])) {
  156. $getd[1] = number_format($getd[1],2);
  157. }
  158. $totind=number_format($totind,2);
  159. print "
  160. <td align=right>
  161. <input type=hidden name=natureid[$varx] value=$getn[0]>
  162. <input type=hidden name=z[$varx] value=$getd[1]>$getd[1]&nbsp; $rtag
  163. <input type=hidden name=taxfeeid[$varx] value=$getd[2]></td>
  164. <td align=right><input type=hidden name=y$varx value=$totind size =5 readonly>
  165. $totind</td>
  166. </tr>
  167. ";
  168. //delete if existing
  169. $result = mysql_query ("delete from tempassess where assid='$varx'
  170. and owner_id=$owner_id and business_id=$business_id") or die (mysql_error());
  171. //save to tempassess
  172. if ($indi==0) {
  173. $result = mysql_query ("insert into tempassess
  174. (assid, owner_id, business_id, natureid, taxfeeid, multi, amt, formula)
  175. values
  176. ($varx,$owner_id, $business_id,$getn[0],
  177. $getd[2],$xv,'$getd[1]','0')")or die ("amt11w".mysql_error());
  178. } else {
  179. $result = mysql_query ("insert into tempassess
  180. (assid, owner_id, business_id, natureid, taxfeeid, multi, amt, formula)
  181. values
  182. ($varx,$owner_id, $business_id,$getn[0],
  183. $getd[2],$xv,0,'$getd[1]')")or die ("formula".mysql_error());
  184. }
  185. }
  186. $varx++;
  187. }
  188. }
  189. }
  190. ?>
  191. <table border =1 width=300><br>
  192. <tr><td width=100></td> <td></td><td align=right>Total Tax:</td><td align=right>
  193. <font color=red>Php &nbsp;<?php echo $ga = number_format($grandamt,2); ?></font></td></tr>
  194. </table>
  195. <?php
  196. $ota1 = $grandamt;
  197. ?>