PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/business_penalty.php

http://ebpls.googlecode.com/
PHP | 326 lines | 289 code | 25 blank | 12 comment | 97 complexity | 43ae0fe752277ddebb0bd02756c60b67 MD5 | raw file
  1. <?php
  2. //if ($stat != "New") {
  3. //check if have new line or record paid
  4. $newtax=0;
  5. $newfee=0;
  6. if ($stat == 'ReNew' and $monthcounter == $qtrcnt) {
  7. $checknew = mysql_query("select * from tempbusnature where owner_id='$owner_id' and
  8. business_id='$business_id' and date_create like '$yearnow%' and
  9. transaction='New' and active=1");
  10. $havnew = mysql_num_rows($checknew);
  11. if ($havnew>0) { //may bago na line
  12. $nat=0;
  13. while ($newnew = mysql_fetch_assoc($checknew)) {
  14. $nature[$nat] = $newnew[bus_code];
  15. $nat++;
  16. }
  17. }
  18. $checknew12 = mysql_query("select * from tempbusnature where owner_id='$owner_id' and
  19. business_id='$business_id' and date_create like '$yearnow%' and
  20. transaction='$stat' and active=1 and recpaid =1");
  21. $havnew12 = mysql_num_rows($checknew12);
  22. if ($havnew12>0) { //may bago na line
  23. $wagpenalty = 1;
  24. } else {
  25. $wagpenalty = 0;
  26. }
  27. //check kung bayad na luma
  28. $checkluma = mysql_query("select * from tempbusnature where owner_id='$owner_id' and
  29. business_id='$business_id' and date_create like '$yearnow%' and
  30. transaction='$stat' and
  31. recpaid='1' and active=1");
  32. $bayadluma = mysql_num_rows($checkluma);
  33. $checkluma1 = mysql_fetch_assoc($checkluma);
  34. if ($bayadluma>0) { //bayad na
  35. $wagpenalty = 1;
  36. } else {
  37. $wagpenalty = 0;
  38. }
  39. //pano pag may bagong line na hindi pa bayad luma na late na.. bwiset na tax payer na yan
  40. if ($havnew>0) {
  41. //total lahat ng tax nya
  42. $bis=0;
  43. while ($bis<$nat) {
  44. $biset = mysql_query("select * from tempassess
  45. where owner_id='$owner_id' and business_id='$business_id' and
  46. natureid='$nature[$bis]' and active=1 and date_create like '$yearnow%'");
  47. while ($amtbis =mysql_fetch_assoc($biset)) {
  48. $getfeeid = $amtbis[tfoid];
  49. $gettotfee = mysql_query("select * from ebpls_buss_tfo where
  50. tfoid='$getfeeid'");
  51. $gid = mysql_fetch_assoc($gettotfee);
  52. if ($gid[taxfeetype]==1) {
  53. $newtax = $newtax + $amtbis[compval];
  54. } else {
  55. $newfee = $newfee + $amtbis[compval];
  56. }
  57. }
  58. $bis++;
  59. }
  60. }
  61. if (strtolower($pmode) == "quarterly") {
  62. $LBnewtax = $newtax / 4;
  63. if ($staxfee == '1') {
  64. $LBnewfee = $newfee;
  65. } else {
  66. $LBnewfee = $newfee / 4;
  67. }
  68. } elseif (strtolower($pmode) == "semi-annual") {
  69. $LBnewtax = $newtax / 2;
  70. if ($staxfee == '1') {
  71. $LBnewfee = $newfee;
  72. } else {
  73. $LBnewfee = $newfee / 2;
  74. }
  75. } elseif (strtolower($pmode) == "annual") {
  76. $LBnewtax = $newtax;
  77. $LBnewfee = $newfee;
  78. }
  79. //echo "<BR>VooDoo".$newtax."===".$newfee;
  80. } else {
  81. $wagpenalty = 0;
  82. $LBnewtax = 0;
  83. $LBnewfee = 0;
  84. }
  85. $anongmonthito = date('m', $checkluma1[date_create]);
  86. if (strtolower($pmode) == "quarterly") {
  87. if ($anongmonthito >= 1 and $anongmonthito <= 3) {
  88. $anongquartito = 1;
  89. } elseif ($anongmonthito >= 4 and $anongmonthito <=6) {
  90. $anongquartito = 2;
  91. } elseif ($anongmonthito >= 7 and $anongmonthito <= 9) {
  92. $anongquartito = 3;
  93. } elseif ($anongmonthito >= 10 and $anongmonthito <= 12) {
  94. $anongquartito = 4;
  95. }
  96. $sdcounter = $qtrcnt;
  97. } elseif (strtolower($pmode) == "semi-annual") {
  98. if ($anongmonthito >= 1 and $anongmonthito <= 6) {
  99. $anongquartito = 1;
  100. } elseif ($anongmonthito >= 7 and $anongmonthito <=12) {
  101. $anongquartito = 2;
  102. }
  103. $sdcounter = $semcnt;
  104. } elseif (strtolower($pmode) == "annual") {
  105. if ($anongmonthito >= 1 and $anongmonthito <= 12) {
  106. $anongquartito = 1;
  107. }
  108. $sdcounter = 1;
  109. }
  110. if ($sdcounter > $anongmonthito) {
  111. $wagpenalty = 0;
  112. $LBnewtax = 0;
  113. $LBnewfee = 0;
  114. }
  115. //echo $pmode."VooDoo";
  116. /*===========================*/
  117. $yeartoday = date('Y');
  118. $addend = "$yeartoday-";
  119. $getpended = @mysql_query("select * from ebpls_buss_penalty where status = 'A'");
  120. $getpended = @mysql_fetch_assoc($getpended);
  121. $getrenew = @mysql_query("select * from ebpls_buss_penalty1 order by id desc limit 1");
  122. $getrenew = @mysql_fetch_assoc($getrenew);
  123. if (strtolower($pmode)=='quarterly') {
  124. if ($qtrcnt == '1') {
  125. $getpendedrenewal = $getrenew['qtrdue1'];
  126. } elseif ($qtrcnt == '2') {
  127. $getpendedrenewal = $getrenew['qtrdue2'];
  128. } elseif ($qtrcnt == '3') {
  129. $getpendedrenewal = $getrenew['qtrdue3'];
  130. } elseif ($qtrcnt == '4') {
  131. $getpendedrenewal = $getrenew['qtrdue4'];
  132. }
  133. }
  134. if (strtolower($pmode)=='semi-annual') {
  135. if ($semcnt == '1') {
  136. $getpendedrenewal = $getrenew['semdue1'];
  137. } elseif ($semcnt == '2') {
  138. $getpendedrenewal = $getrenew['semdue2'];
  139. }
  140. }
  141. if (strtolower($pmode)=='annual') {
  142. $getpendedrenewal = $getpended['renewaldate'];
  143. }
  144. $renewaldate = "$addend$getpendedrenewal";
  145. $renewaldate = strtotime($renewaldate);
  146. $renewaldate = date('Y-m-d', $renewaldate);
  147. $nStartDate = date('Y-m-d', $startdate);
  148. if ($wagpenalty == 0) {
  149. if ($permit_type == "Business" and $amt2pay != '0') {
  150. $buspen = 0;
  151. $busint = 0;
  152. $olddivtax = $divtax;
  153. $olddivfee = $divfee;
  154. if ($havnew > 0 and $monthcounter==$qtrcnt) {
  155. $divtax = $divtax - $LBnewtax;
  156. }
  157. if ($predcomp == '1' and $stat == "New") {
  158. if (strtolower($pmode) == "quarterly") {
  159. $nTotalTax = $divtax * 4;
  160. } elseif (strtolower($pmode) == "semi-annual") {
  161. $nTotalTax = $divtax * 2;
  162. } elseif (strtolower($pmode) == "annual") {
  163. $nTotalTax = $divtax;
  164. }
  165. } else {
  166. $nTotalTax = $divtax;
  167. }
  168. if ($havnew > 0) {
  169. $nTotalFee = $amt2pay - ($nTotalTax + $LBnewtax);
  170. $nTotalFee = $nTotalFee - $LBnewfee;
  171. } else {
  172. $nTotalFee = $amt2pay - $nTotalTax;
  173. }
  174. //echo "$nTotalTax + $nTotalFee";
  175. $datetoday = date('Y-m-d');
  176. $getrec = @mysql_query("select * from ebpls_business_enterprise where owner_id = '$owner_id' and transaction = '$stat' and active = '1'");
  177. $getrec = @mysql_fetch_assoc($getrec);
  178. $getpermit = @mysql_query("select * from ebpls_business_enterprise_permit where owner_id = '$owner_id' and transaction = '$stat' and active = '1' and business_id = '$getrec[business_id]'");
  179. $getpermit = @mysql_fetch_assoc($getpermit);
  180. $monthnow = date('m');
  181. $monthnow = $monthnow - 0;
  182. $getpaydate = @mysql_query("select * from ebpls_transaction_payment_or a, ebpls_transaction_payment_or_details b where b.permit_type = '$permit_type' and a.trans_id = '$owner_id' and b.payment_id = '$business_id' and a.or_no = b.or_no order by a.or_no desc limit 1");
  183. $getpaydate = @mysql_fetch_assoc($getpaydate);
  184. $lastpaydate = substr($getpaydate[ts],0,4);
  185. $lastpaydateyear = $lastpaydate;
  186. $yeardiff = 0;
  187. if ($datetoday > $renewaldate) {
  188. if ($getpended['indicator'] == '1') {
  189. $buspen = $getpended['rateofpenalty'];
  190. } elseif ($getpended['indicator'] == '2') {
  191. $nratepen = $getpended['rateofpenalty'];
  192. if ($getpended['surtype'] == '1') {
  193. eval("\$buspen=$nTotalTax * $nratepen;");
  194. } elseif ($getpended['surtype'] == '2') {
  195. eval("\$buspen=($nTotalTax + $nTotalFee) * $nratepen;");
  196. }
  197. }
  198. $d = date('m',strtotime($renewaldate)); //setting date
  199. $s = date('m'); //current date
  200. if (strtolower($getpended['optsurcharge']) == "qtr") {
  201. if ($d >=1 and $d <=3) {
  202. $subtrahend = 1;
  203. } elseif ($d >=4 and $d <=6) {
  204. $subtrahend = 2;
  205. } elseif ($d >=7 and $d <=9) {
  206. $subtrahend = 3;
  207. } elseif ($d >=10 and $d <=12) {
  208. $subtrahend = 4;
  209. }
  210. if ($s >=1 and $s <=3) {
  211. $subtractor = 1 + ($ngydiff * 4);
  212. } elseif ($s >=4 and $s <=6) {
  213. $subtractor = 2 + ($ngydiff * 4);
  214. } elseif ($s >=7 and $s <=9) {
  215. $subtractor = 3 + ($ngydiff * 4);
  216. } elseif ($s >=10 and $s <=12) {
  217. $subtractor = 4 + ($ngydiff * 4);
  218. }
  219. }
  220. if (strtolower($getpended['optsurcharge']) == "mon") {
  221. $subtrahend = $d;
  222. $subtractor = $s + ($ngydiff * 12);
  223. }
  224. if (strtolower($getpended['optsurcharge']) == "sem") {
  225. if ($d >=1 and $d <=6) {
  226. $subtrahend = 1;
  227. } elseif ($d >=7 and $d <=12) {
  228. $subtrahend = 2;
  229. }
  230. if ($s >=1 and $s <=6) {
  231. $subtractor = 1 + ($ngydiff * 2);
  232. } elseif ($s >=7 and $s <=12) {
  233. $subtractor = 2 + ($ngydiff * 2);
  234. }
  235. }
  236. if (strtolower($getpended['optsurcharge']) == "ann") {
  237. $subtrahend = 1;
  238. $subtractor = 1 + ($ngydiff);
  239. }
  240. $d = ($subtractor - $subtrahend) + 1;
  241. if ($d > 36) {
  242. $d = 36;
  243. }
  244. $x = 1;
  245. $counter = 1;
  246. $intrate = "1$getpended[rateofinterest]";
  247. if ($getpended['inttype'] == '1') {
  248. $interestrate = $getpended[rateofinterest] * $d;
  249. } elseif ($getpended['inttype'] == '2') {
  250. while ($x <= $d) {
  251. $counter = $counter * $intrate;
  252. $x++;
  253. }
  254. $interestrate = $counter - 1;
  255. }
  256. if ($getpended['feeonly'] == '1') {
  257. $busint = $interestrate * ($nTotalTax);
  258. } elseif ($getpended['feeonly'] == '2') {
  259. $busint = $interestrate * ($nTotalTax + $nTotalFee);
  260. } elseif ($getpended['feeonly'] == '3') {
  261. $busint = $interestrate * (($nTotalTax + $nTotalFee) + $buspen);
  262. }
  263. $buspen = round($buspen,2);
  264. $busint = round($busint,2);
  265. $amt2pay = $amt2pay + $buspen + $busint;
  266. $nSurchargeAmount = $buspen;
  267. $nInterestAmount = $busint;
  268. if ($buspen > 0 || $busint > 0) {
  269. ?>
  270. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  271. <tr>
  272. <td align=left><b>Surcharge</b></td>
  273. <td align=right><b><?php echo number_format($buspen,2);?></b></td>
  274. </tr>
  275. <tr>
  276. <td align=left><b>Interest</b></td>
  277. <td align=right><b><?php echo number_format($busint,2);?></b></td>
  278. </tr>
  279. </table>
  280. <?php
  281. }
  282. }
  283. }
  284. } else {
  285. $LBnewtax=0;
  286. $nSurchargeAmount = 0;
  287. $nInterestAmount = 0;
  288. }
  289. $newtax=0;
  290. $newfee=0;
  291. // $divtax = $olddivtax;
  292. // $divfee = $olddivfee;
  293. if ($buspen == "" or $buspen == 0) {
  294. $nSurchargeAmount = 0;
  295. }
  296. if ($busint == "" or $busint == 0) {
  297. $nInterestAmount = 0;
  298. }
  299. $divtax = $divtax + $LBnewtax;
  300. //echo "$divfee $divtax $getsumnun1 VooDoo";
  301. ?>