/application/modules/reports/models/Par.php

https://github.com/srsree/OurBank · PHP · 155 lines · 87 code · 24 blank · 44 comment · 0 complexity · c59e6c9dad44720e5d7c6f640ca6167c MD5 · raw file

  1. <?php
  2. /*
  3. ############################################################################
  4. # This file is part of OurBank.
  5. ############################################################################
  6. # OurBank is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. ############################################################################
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. ############################################################################
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. ############################################################################
  19. */
  20. ?>
  21. <?php
  22. /*
  23. ############################################################################
  24. # This file is part of OurBank.
  25. ############################################################################
  26. # OurBank is free software: you can redistribute it and/or modify
  27. # it under the terms of the GNU Affero General Public License as
  28. # published by the Free Software Foundation, either version 3 of the
  29. # License, or (at your option) any later version.
  30. ############################################################################
  31. # This program is distributed in the hope that it will be useful,
  32. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  34. # GNU Affero General Public License for more details.
  35. ############################################################################
  36. # You should have received a copy of the GNU Affero General Public License
  37. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  38. ############################################################################
  39. */
  40. class Reports_Model_Par extends Zend_Db_Table
  41. {
  42. protected $_name = 'ourbank_transaction';
  43. public function getDue30() {
  44. $date = date("Y-m-d");// current date
  45. $enddate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -30 days"));
  46. $select = $this->select()
  47. ->setIntegrityCheck(false)
  48. ->from(array('A' => 'ourbank_installmentdetails'))
  49. ->where('A.installment_status = 5')
  50. ->where('A.accountinstallment_date >= "'.$enddate.'" AND A.accountinstallment_date <= "'.$date.'"')
  51. ->join(array('C'=>'ourbank_accounts'),'C.account_id = A.account_id')
  52. ->where('C.accountstatus_id =3 OR C.accountstatus_id =1' );
  53. // ->group('B.offerproductname');
  54. //die($select->__toString());
  55. return $this->fetchAll($select);
  56. }
  57. public function getDueabove30less60() {
  58. $date = date("Y-m-d");// current date
  59. $fromDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -30 days"));
  60. $toDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -60 days"));
  61. $select = $this->select()
  62. ->setIntegrityCheck(false)
  63. ->from(array('A' => 'ourbank_installmentdetails'))
  64. ->where('A.installment_status = 5')
  65. ->where('A.accountinstallment_date > "'.$toDate.'" AND A.accountinstallment_date <="'.$fromDate.'" ')
  66. ->join(array('C'=>'ourbank_accounts'),'C.account_id = A.account_id')
  67. ->where('C.accountstatus_id =3 OR C.accountstatus_id =1' );
  68. // ->group('B.offerproductname');
  69. // die($select->__toString());
  70. return $this->fetchAll($select);
  71. }
  72. public function getDueabove60less90() {
  73. $date = date("Y-m-d");// current date
  74. $fromDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -60 days"));
  75. $toDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -90 days"));
  76. $select = $this->select()
  77. ->setIntegrityCheck(false)
  78. ->from(array('A' => 'ourbank_installmentdetails'),array('SUM(accountinstallment_amount) as sum'))
  79. ->where('A.installment_status = 5')
  80. ->where('A.accountinstallment_date > "'.$toDate.'" AND A.accountinstallment_date <="'.$fromDate.'" ')
  81. ->join(array('C'=>'ourbank_accounts'),'C.account_id = A.account_id')
  82. ->where('C.accountstatus_id =3 OR C.accountstatus_id =1' )
  83. ->group('C.account_id');
  84. // die($select->__toString());
  85. return $this->fetchAll($select);
  86. }
  87. public function getDueabove90less180() {
  88. $date = date("Y-m-d");// current date
  89. $fromDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -90 days"));
  90. $toDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -180 days"));
  91. $select = $this->select()
  92. ->setIntegrityCheck(false)
  93. ->from(array('A' => 'ourbank_installmentdetails'),array('SUM(accountinstallment_amount) as sum'))
  94. ->where('A.installment_status = 5')
  95. ->where('A.accountinstallment_date > "'.$toDate.'" AND A.accountinstallment_date <="'.$fromDate.'" ')
  96. ->join(array('C'=>'ourbank_accounts'),'C.account_id = A.account_id')
  97. ->where('C.accountstatus_id =3 OR C.accountstatus_id =1' )
  98. ->group('C.account_id');
  99. // die($select->__toString());
  100. return $this->fetchAll($select);
  101. }
  102. public function getDueabove180less360() {
  103. $date = date("Y-m-d");// current date
  104. $fromDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -180 days"));
  105. $toDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -360 days"));
  106. $select = $this->select()
  107. ->setIntegrityCheck(false)
  108. ->from(array('A' => 'ourbank_installmentdetails'),array('SUM(accountinstallment_amount) as sum'))
  109. ->where('A.installment_status = 5')
  110. ->where('A.accountinstallment_date > "'.$toDate.'" AND A.accountinstallment_date <="'.$fromDate.'" ')
  111. ->join(array('C'=>'ourbank_accounts'),'C.account_id = A.account_id')
  112. ->where('C.accountstatus_id =3 OR C.accountstatus_id =1' )
  113. ->group('C.account_id');
  114. // die($select->__toString());
  115. return $this->fetchAll($select);
  116. }
  117. public function getDueabove360() {
  118. $date = date("Y-m-d");// current date
  119. $toDate = date('Y-m-d',strtotime(date("Y-m-d", strtotime($date)) . " -360 days"));
  120. $select = $this->select()
  121. ->setIntegrityCheck(false)
  122. ->from(array('A' => 'ourbank_installmentdetails'),array('SUM(accountinstallment_amount) as sum'))
  123. ->where('A.installment_status = 5')
  124. ->where('A.accountinstallment_date < "'.$toDate.'"')
  125. ->join(array('C'=>'ourbank_accounts'),'C.account_id = A.account_id')
  126. ->where('C.accountstatus_id =3 OR C.accountstatus_id =1' )
  127. ->group('C.account_id');
  128. // die($select->__toString());
  129. return $this->fetchAll($select);
  130. }
  131. }