Want more features on Pastebin? Sign Up, it's FREE!

Opening & Closing Balance

By: wzislam on Nov 13th, 2012  |  syntax: PHP  |  size: 5.27 KB  |  views: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>COMAPNY</title>
  6. <link rel="stylesheet" type="text/css" href="js/calendar.css" />
  7. <link rel="stylesheet" href="styles.css" type="text/css" />
  8. <script type="text/javascript" src="js/jquery.js"></script>
  9. <script type="text/javascript" src="js/calendar.js"></script>
  10. <script type="text/javascript" src="js/jquery.min.js"></script>
  11. <script type="text/javascript" >
  12. function getValue()
  13. {
  14. //alert("test....");
  15. var n = document.getElementById('n').value;
  16. n = Number(n);
  17. document.getElementById('n1').value=n;
  18.  
  19. }
  20. </script>
  21. </head>
  22.  
  23. <body onload="getValue();">
  24. <?php require_once("config/dbConnect.php"); ?>
  25. <div id="header_wrapper_holder_all">
  26. <div id="wrapper" style="border:none">
  27. <div style="width:970px;position:relative;float:left;border-top:solid 1px #000;border-bottom:solid 1px #000">
  28. <table width="100%">
  29. <tr>
  30. <td style="width:220px">Date</td>
  31. <td style="width:300px">Particulars</td>
  32. <td style="width:225px;text-align:center">Debit</td>
  33. <td style="width:225px;text-align:center">Credit</td>
  34. </tr>
  35. </table>
  36. </div>
  37.  
  38. <div style="width:970px;position:relative;float:left;">
  39.  
  40. <table width="100%">
  41. <?php
  42. $prevMonth = date('Y-m-d', strtotime('-1 month'));
  43. $prevMonthFirst = date('Y-m-01', strtotime('-1 month'));
  44. $prevMonthLast = date('Y-m-t', strtotime('-1 month'));
  45. $ledger1 = "SELECT j2.*,j1.*FROM jabeda1 j1,jabeda2 j2 WHERE j1.id = j2.jId AND j2.amount!=0 AND j2.date BETWEEN '$prevMonthFirst' AND '$prevMonthLast'";
  46. //echo $ledger1;
  47. $res1 = mysql_query($ledger1) or die(mysql_error());
  48. $t_debit1 = 0;
  49. $t_credit1 = 0;
  50. while($rowArr1 = mysql_fetch_array($res1))
  51. {
  52. //if($rowArr['amount']!='0')
  53. //{
  54. //echo"<pre>";echo print_r($rowArr);echo"</pre>";
  55. if($rowArr1['input_type']=='Expenses')
  56. {
  57. $t_credit1 = $rowArr1['amount'] + $t_credit1;
  58. }
  59.  
  60. if($rowArr1['input_type']=='Deposit')
  61. {
  62.  
  63. $t_debit1 = $rowArr1['amount'] + $t_debit1;
  64. }
  65.  
  66. }
  67. ?>
  68. <tr>
  69. <td style="width:220px">2012-11-01</td>
  70. <td style="width:300px">Dr Opening balance</td>
  71. <?php
  72.  
  73. $tVal1 = $t_debit1-$t_credit1;
  74. $newTest1 = substr_count($tVal1,"-");
  75. if($newTest1)
  76. {
  77. ?>
  78. <td style="width:225px;text-align:center"><?php echo abs($tVal1); ?></td>
  79. <td style="width:225px;text-align:center">&nbsp;</td>
  80. <?php
  81. }else{
  82. ?>
  83. <td style="width:225px;text-align:center">&nbsp;</td>
  84. <td style="width:225px;text-align:center"><?php echo abs($tVal1); ?></td>
  85. <?php } ?>
  86. </tr>
  87.  
  88. <?php
  89. $date = date('Y-m-d');
  90. $firstDate = date('Y-m-01', strtotime($date));
  91. $lastDate = date('Y-m-t', strtotime($date));
  92. $prevMonth = date('Y-m-d', strtotime('-1 month'));
  93. $nextMonth = date('Y-m-d', strtotime('+1 month'));
  94.  
  95. $ledger = "SELECT j2.*,j1.*FROM jabeda1 j1,jabeda2 j2 WHERE j1.id = j2.jId AND j2.amount!=0 AND j2.date BETWEEN '$firstDate' AND '$lastDate'";
  96. //echo $ledger;
  97. $res = mysql_query($ledger) or die(mysql_error());
  98. $t_debit = 0;
  99. $t_credit = 0;
  100. while($rowArr = mysql_fetch_array($res))
  101. {
  102. //if($rowArr['amount']!='0')
  103. //{
  104. //echo"<pre>";echo print_r($rowArr);echo"</pre>";
  105. if($rowArr['input_type']=='Expenses')
  106. {
  107. $t_credit = $rowArr['amount'] + $t_credit;
  108. ?>
  109.  
  110. <tr>
  111. <td style="width:220px"><?php echo $rowArr['date']; ?></td>
  112. <td style="width:300px;text-align:justify"> <strong>Dr Purchase Local R/M-Credit</strong> </br>Being the amount credit <strong><?php echo $rowArr['name']; ?></strong> </td>
  113. <td style="width:225px;text-align:center">&nbsp;</td>
  114. <td style="width:225px;text-align:center"><?php echo $rowArr['amount']; ?></td>
  115. </tr>
  116. <?php }
  117. if($rowArr['input_type']=='Deposit') {
  118.  
  119. $t_debit = $rowArr['amount'] + $t_debit;
  120. ?>
  121.  
  122. <tr>
  123. <td style="width:220px"><?php echo $rowArr['date']; ?></td>
  124. <td style="width:300px;text-align:justify"><strong>Cr Sales-Credit </strong></br>Being the amount credit sales <strong><?php echo $rowArr['name']; ?></strong></td>
  125. <td style="width:225px;text-align:center"><?php echo $rowArr['amount']; ?></td>
  126. <td style="width:225px;text-align:center"></td>
  127. </tr>
  128.  
  129. <?php } ?>
  130.  
  131. <?php
  132.  
  133. }
  134.  
  135. ?>
  136. </table>
  137. <div id="res">
  138. <table width="100%">
  139. <tr>
  140. <td style="width:50%;font-weight:bold;text-align:center"><?php echo $t_debit;?></td>
  141. <td style="width:50%;font-weight:bold;text-align:center"><?php echo $t_credit;?></td>
  142. </tr>
  143.  
  144. <tr>
  145. <?php
  146. $tVal = $t_debit-$t_credit;
  147. $newTest = substr_count($tVal,"-");
  148. //global $tVal;
  149.  
  150. ?>
  151. <?php
  152. if($newTest)
  153. {
  154. ?>
  155. <td style="width:50%;text-align:center"><?php echo abs($tVal);?></td>
  156. <?php
  157.  
  158. }
  159. else
  160. {
  161. ?>
  162. <td style="width:50%;text-align:center"><?php echo $tVal;?></td>
  163. <?php
  164. }
  165. ?>
  166. </tr>
  167. </table>
  168. </div>
  169.  
  170. <div id="res" style="border-bottom:solid 2px #000;">
  171. <table width="100%">
  172.  
  173. <tr>
  174. <?php
  175. if($newTest)
  176. {
  177. ?>
  178.  
  179. <td style="width:225px;text-align:center;font-weight:bold"><?php echo abs($tVal)+$t_debit;?></td>
  180. <td style="width:225px;text-align:center;font-weight:bold"><?php echo $t_credit;?></td>
  181. <?php
  182.  
  183. }
  184. else
  185. {
  186. ?>
  187.  
  188. <td style="width:50%;text-align:center;font-weight:bold"><?php echo $t_debit;?></td>
  189. <td style="width:50%;text-align:center;font-weight:bold"><?php echo $t_credit+ $t_debit;?></td>
  190. <?php
  191. }
  192. ?>
  193.  
  194. </tr>
  195.  
  196.  
  197. </table>
  198. </div>
  199.  
  200.  
  201. </div>
  202. </div>
  203. </div>
  204. </body>
  205. </html>
clone this paste RAW Paste Data