/application/modules/accounting/models/Savings.php

https://github.com/srsree/OurBank · PHP · 311 lines · 268 code · 25 blank · 18 comment · 0 complexity · bdfc04d8568f34d244238bd1d612c922 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. class Accounting_Model_Savings extends Zend_Db_Table {
  23. public function searchMembercode($post = array()) {
  24. $this->db = Zend_Db_Table::getDefaultAdapter();
  25. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  26. $sql="SELECT b.membertype_ID as type,
  27. b.member_id as id,
  28. b.membercode as code,
  29. a.memberfirstname as Name,
  30. c.office_name as Office
  31. from ourbank_membername a,
  32. ourbank_members b,
  33. ourbank_officenames c
  34. where a.member_id=b.member_id AND
  35. c.office_id = a.memberoffice_id AND
  36. (a.memberfirstname like '$membercode' '%' or b.membercode like '$membercode' '%')
  37. UNION
  38. select b.membertype_ID as type,
  39. b.member_id as id,
  40. b.membercode as code,
  41. a.groupname as Name,
  42. c.office_name as office
  43. from ourbank_groupaddress a,
  44. ourbank_members b,
  45. ourbank_officenames c
  46. where b.member_id = a.group_id AND
  47. c.office_id = a.groupoffice_id AND
  48. (a.groupname like '$membercode' '%' or b.membercode like '$membercode' '%')";
  49. $result = $this->db->fetchAll($sql,array($membercode));
  50. return $result;
  51. }
  52. public function fetchMemberDetails($memberId) {
  53. $this->db = Zend_Db_Table::getDefaultAdapter();
  54. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  55. $sql = "SELECT * FROM ourbank_members A,
  56. ourbank_officenames C
  57. where A.member_id='$memberId' AND
  58. A.memberbranch_id=C.office_id AND
  59. C.recordstatus_id=3";
  60. $result = $this->db->fetchAll($sql,array($memberId));
  61. return $result;
  62. }
  63. public function fetchmemberName($memberId) {
  64. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  65. $sql = "SELECT memberfirstname FROM ourbank_membername
  66. WHERE member_id='$memberId' AND
  67. recordstatus_id=3";
  68. $result = $this->db->fetchAll($sql,array($memberId));
  69. return $result;
  70. }
  71. public function fetchSavingsProducts($membertypeId) {
  72. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  73. $sql = "select A.offerproductname,
  74. B.product_id,A.offerproduct_id
  75. from ourbank_productsofferdetails A,
  76. ourbank_productdetails B
  77. where (A.applicableto='$membertypeId' OR
  78. A.applicableto = '1') AND
  79. A.recordstatus_id = 3 AND
  80. (B.recordstatus_id = 3 OR
  81. B.recordstatus_id = 1) AND
  82. A.product_id=B.product_id AND
  83. B.category_id = 1";
  84. $result = $this->db->fetchAll($sql,array($membertypeId));
  85. return $result;
  86. }
  87. public function fetchGroupDetails($memberId) {
  88. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  89. $sql = "SELECT * FROM ourbank_groupaddress
  90. WHERE group_id='$memberId' AND
  91. groupaccountstatus=3";
  92. $result = $this->db->fetchAll($sql,array($memberId));
  93. return $result;
  94. }
  95. public function accountsSearch($memberId) {
  96. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  97. $sql = "SELECT * FROM ourbank_accounts A,
  98. ourbank_productsofferdetails B,
  99. ourbank_productdetails C
  100. WHERE A.member_id='$memberId' AND
  101. A.product_id=B.offerproduct_id AND
  102. B.product_id=C.product_id AND
  103. A.accountstatus_id=1 AND
  104. B.recordstatus_id=3 AND
  105. (C.recordstatus_id=3 OR
  106. C.recordstatus_id = 1) AND
  107. C.category_id = 1";
  108. $result = $this->db->fetchAll($sql,array($memberId));
  109. return $result;
  110. }
  111. public function fetchLoansProducts($membertypeId) {
  112. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  113. $sql = "select A.offerproduct_id,A.offerproductname
  114. from ourbank_productsofferdetails A,
  115. ourbank_productdetails B
  116. where (A.applicableto='$membertypeId' OR
  117. A.applicableto = '1') AND
  118. A.recordstatus_id=3 AND
  119. B.recordstatus_id=3 AND
  120. A.product_id=B.product_id AND
  121. B.category_id=2 AND
  122. A.closedate >= curdate()";
  123. $result = $this->db->fetchAll($sql,array($membertypeId));
  124. return $result;
  125. }
  126. public function accountsSearch1($memberId) {
  127. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  128. $sql = "SELECT * FROM ourbank_accounts A,
  129. ourbank_productsofferdetails B,
  130. ourbank_productdetails C
  131. WHERE A.member_id='$memberId' AND
  132. A.product_id=B.offerproduct_id AND
  133. B.product_id=C.product_id AND
  134. A.accountstatus_id= 1 AND
  135. B.recordstatus_id=3 AND
  136. (C.recordstatus_id=3 OR
  137. C.recordstatus_id = 1)AND
  138. C.category_id = 2";
  139. $result = $this->db->fetchAll($sql,array($memberId));
  140. return $result;
  141. }
  142. public function loansProductsFetch($productId) {
  143. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  144. $sql = "select * from ourbank_productsofferdetails A,
  145. ourbank_productsloan B,
  146. ourbank_productdetails D
  147. where (A.offerproduct_id='$productId') AND
  148. (A.offerproductupdate_id=B.offerproductupdate_id) AND
  149. (A.recordstatus_id=3) AND
  150. (A.product_id=D.product_id) AND
  151. (A.recordstatus_id=3)";
  152. $result = $this->db->fetchAll($sql,array($productId));
  153. return $result;
  154. }
  155. public function fetchingInterests($productId) {
  156. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  157. $sql = "select * from ourbank_interest_periods
  158. where (offerproduct_id='$productId') and
  159. (intereststatus_id=3)";
  160. $result = $this->db->fetchAll($sql,array($productId));
  161. return $result;
  162. }
  163. public function interestperiods($productId) {
  164. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  165. $sql = "select max(period_ofrange_monthto)
  166. from ourbank_interest_periods
  167. where offerproduct_id='$productId'
  168. AND intereststatus_id=3 ";
  169. $result = $this->db->fetchOne($sql);
  170. return $result;
  171. }
  172. public function fetchSavingDetails($memberId,$membertypeId) {
  173. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  174. $sql = "SELECT * FROM ourbank_accounts A,
  175. ourbank_productsofferdetails B,
  176. ourbank_productdetails C
  177. WHERE A.member_id='$memberId' AND
  178. A.membertype_id = $membertypeId AND
  179. A.product_id = B.offerproduct_id AND
  180. B.recordstatus_id = '3' AND
  181. B.product_id = C.product_id AND
  182. C.category_id = 1 AND
  183. (C.recordstatus_id = 3 OR
  184. C.recordstatus_id = 3)AND
  185. A.accountstatus_id = 1";
  186. $result = $this->db->fetchAll($sql,array($memberId));
  187. return $result;
  188. }
  189. public function accountnumber($memberId) {
  190. $this->db = Zend_Db_Table::getDefaultAdapter();
  191. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  192. $sql = "select * from ourbank_members where member_id =? " ;
  193. $result = $this->db->fetchAll($sql,array($memberId));
  194. return $result;
  195. }
  196. public function savingsProductFetch($productId) {
  197. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  198. $sql = "select * from ourbank_productsofferdetails A,
  199. ourbank_product_fixedrecurring C,
  200. ourbank_productdetails D
  201. where (A.offerproduct_id='$productId') AND
  202. (A.offerproductupdate_id=C.offerproductupdate_id) AND
  203. (C.productstatus_id=3) AND
  204. (A.recordstatus_id=3) AND
  205. (A.product_id=D.product_id) AND
  206. (A.recordstatus_id=3) AND
  207. (C.productstatus_id = 3) AND
  208. (D.recordstatus_id = 3 OR
  209. D.recordstatus_id = 1)";
  210. $result = $this->db->fetchAll($sql,array($productId));
  211. return $result;
  212. }
  213. public function personalSavingsFetch($productId) {
  214. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  215. $sql = "select * from ourbank_productsofferdetails A,
  216. ourbank_productssaving B,
  217. ourbank_productdetails D
  218. where (A.offerproduct_id='$productId') AND
  219. (A.offerproductupdate_id=B.offerproductupdate_id) AND
  220. (A.recordstatus_id = 3 OR A.recordstatus_id = 1) AND
  221. (A.product_id=D.product_id)";
  222. $result = $this->db->fetchAll($sql,array($productId));
  223. return $result;
  224. }
  225. public function Loanfee() {
  226. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  227. $sql = "select * from ourbank_feedetails where fee_action_id = 10 AND recordstatus_id = 3";
  228. $result = $this->db->fetchAll($sql,array());
  229. return $result;
  230. }
  231. public function Savingfee() {
  232. $this->db = Zend_Db_Table::getDefaultAdapter();
  233. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  234. $sql = "select * from ourbank_feedetails where fee_action_id = 7 AND recordstatus_id = 3";
  235. $result = $this->db->fetchAll($sql,array());
  236. return $result;
  237. }
  238. public function interestFromUrl($productId,$country) {
  239. $this->db = Zend_Db_Table::getDefaultAdapter();
  240. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  241. $sql = "SELECT A.interest FROM ourbank_interest_periods A,
  242. ourbank_productsofferdetails B
  243. WHERE A.period_ofrange_monthfrom <= $country AND
  244. A.period_ofrange_monthto >= $country AND
  245. B.offerproduct_id = $productId AND
  246. A.offerproduct_id=B.offerproduct_id AND
  247. A.intereststatus_id=3";
  248. $result = $this->db->fetchOne($sql,array($productId));
  249. return $result;
  250. }
  251. public function fetchbranchid($memberId) {
  252. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  253. $sql = "SELECT * FROM ourbank_members where member_id='$memberId'";
  254. $result = $this->db->fetchAll($sql,array($memberId));
  255. return $result;
  256. }
  257. public function fetchbranchaccount($branchID) {
  258. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  259. $sql = "SELECT * FROM ourbank_bankaccounts where bank_branch_id='$branchID'";
  260. $result = $this->db->fetchAll($sql,array($branchID));
  261. return $result;
  262. }
  263. public function groupMembers($memberId) {
  264. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  265. $sql = "SELECT B.memberfirstname,B.member_id FROM
  266. ourbank_groupmembers A,
  267. ourbank_membername B
  268. WHERE A.group_id='$memberId' AND
  269. A.member_id=B.member_id";
  270. $result = $this->db->fetchAll($sql,array($memberId));
  271. return $result;
  272. }
  273. public function fetchaccountnumber($accountid) {
  274. $this->db = Zend_Db_Table::getDefaultAdapter();
  275. $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
  276. $sql = "SELECT account_number FROM ourbank_accounts
  277. WHERE account_id='$accountid'";
  278. $result = $this->db->fetchAll($sql,array($accountid));
  279. return $result;
  280. }
  281. public function ourbankRecurringInstalmentsInsertion($input = array()) {
  282. $this->db = Zend_Db_Table::getDefaultAdapter();
  283. $this->db->insert("ourbank_recurringpaydetails",$input);
  284. return '1';
  285. }
  286. }