PageRenderTime 70ms CodeModel.GetById 3ms RepoModel.GetById 3ms app.codeStats 0ms

/application/modules/membership/models/Group.php

https://github.com/srsree/OurBank
PHP | 345 lines | 254 code | 43 blank | 48 comment | 1 complexity | 44107ce69e00b9b2c74d7029b11e3aef 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 Membership_Model_Group extends Zend_Db_Table {
  41. protected $_name = 'ourbank_members';
  42. public function groupDetails($group_id) {
  43. $db = $this->getAdapter();
  44. $sql = 'select * from ourbank_groupmembers A,
  45. ourbank_membername B
  46. where (A.group_id = ? &&
  47. A.member_id = B.member_id )';
  48. $result = $db->fetchAll($sql, array($group_id));
  49. return $result;
  50. }
  51. public function productDetails() {
  52. $db = $this->getAdapter();
  53. $sql = 'select * from ourbank_productdetails';
  54. $result = $db->fetchAll($sql);
  55. return $result;
  56. }
  57. public function getGroupList($office_id) {
  58. $db = $this->getAdapter();
  59. $sql = 'select * from
  60. ourbank_groupaddress
  61. where
  62. groupoffice_id = ? AND
  63. (groupaccountstatus = 3 OR groupaccountstatus = 1) AND
  64. (recordstatus_id = 3 OR recordstatus_id = 1)';
  65. $result = $db->fetchAll($sql, array($office_id));
  66. return $result;
  67. }
  68. public function getMember($office_id) {
  69. $db = $this->getAdapter();
  70. $sql = "select * from
  71. ourbank_members A,
  72. ourbank_bankaddress B,
  73. ourbank_membername C
  74. where
  75. A.memberbranch_id = ? AND
  76. A.memberbranch_id = B.bank_id AND
  77. A.member_id = C.member_id AND
  78. B.recordstatus_id = 3 AND
  79. (A.member_status = 3 || A.member_status = 1) AND
  80. C.recordstatus_id=3 ";
  81. $result = $db->fetchAll($sql, array($office_id));
  82. return $result;
  83. }
  84. /*
  85. $sql = 'select D.memberfirstname from ourbank_groupmembers A,
  86. ourbank_groupaddress B,
  87. ourbank_members C,
  88. ourbank_membername D
  89. where (B.groupname_id = ? &&
  90. B.group_id = A.group_id &&
  91. B.groupoffice_id = C.memberbranch_id &&
  92. A.member_id != C.member_id &&
  93. C.member_id = D.member_id &&
  94. D.recordstatus_id = 3)';*/
  95. public function offerDetails() {
  96. $db = $this->getAdapter();
  97. $sql = 'select * from ourbank_productsofferdetails';
  98. $result = $db->fetchAll($sql);
  99. return $result;
  100. }
  101. public function groupmemberDetails() {
  102. $db = $this->getAdapter();
  103. $sql = 'select * from
  104. ourbank_members A,
  105. ourbank_groupaddress C,
  106. ourbank_bankaddress D where
  107. (A.member_id = C.group_id &&
  108. C.groupoffice_id = D.bank_id &&
  109. C.recordstatus_id = 3 &&
  110. (A.member_status = 3 || A.member_status = 1)) ';
  111. $result = $db->fetchAll($sql);
  112. return $result;
  113. }
  114. public function groupView($groupname_id) {
  115. $db = $this->getAdapter();
  116. $sql = 'select * from
  117. ourbank_members A,
  118. ourbank_groupaddress C,
  119. ourbank_bankaddress D where
  120. (C.groupname_id = ?) &&
  121. (A.member_id = C.group_id &&
  122. C.groupoffice_id = D.bank_id &&
  123. C.recordstatus_id = 3 &&
  124. C.recordstatus_id = 3
  125. ) ';
  126. return $db->fetchAll($sql,array($groupname_id));
  127. }
  128. public function groupmembersView($groupname_id) {
  129. $db = $this->getAdapter();
  130. $sql = 'select * from
  131. ourbank_groupaddress A,
  132. ourbank_groupmembers B,
  133. ourbank_members C,
  134. ourbank_membername D where
  135. (A.groupname_id = ?) &&
  136. (A.group_id = B.group_id &&
  137. B.member_id = C.member_id &&
  138. C.member_id = D.member_id &&
  139. A.recordstatus_id = 3 &&
  140. D.recordstatus_id = 3 ) ';
  141. $result = $db->fetchAll($sql,array($groupname_id));
  142. return $result;
  143. }
  144. public function groupSearch($input) {
  145. $db = $this->getAdapter();
  146. $sql = "select * from
  147. ourbank_members A,
  148. ourbank_groupaddress C,
  149. ourbank_bankaddress D
  150. where (
  151. A.membercode like ? '%' AND
  152. C.groupname like ? '%' AND
  153. C.groupaddress_location like ? '%' AND
  154. D.bank_id like ? '%') AND
  155. A.member_id = C.group_id AND
  156. C.groupoffice_id = D.bank_id AND
  157. C.recordstatus_id = 3";
  158. return $db->fetchAll($sql,array($input['membercode'],$input['groupname'],
  159. $input['groupaddress_location'],$input['bank_id']));
  160. }
  161. public function clickProductDetails($o_id) {
  162. $db = $this->getAdapter();
  163. $sql = "select * from ourbank_productsofferdetails A,
  164. ourbank_productsloan B,
  165. ourbank_interesttypes C,
  166. ourbank_frequencyofpayment D
  167. where (A.offerproduct_id = ? &&
  168. A.offerproductupdate_id = B.offerproductupdate_id &&
  169. B.interesttype_id= C.interesttype_id &&
  170. B.installmenttype_id =D.timefrequncy_id)";
  171. $result = $db->fetchAll($sql,array($o_id));
  172. return $result;
  173. }
  174. public function savingDetails($o_id) {
  175. $db = $this->getAdapter();
  176. $sql = "select * from ourbank_productsofferdetails A,
  177. ourbank_productssaving B
  178. where (A.offerproduct_id = ? &&
  179. A.offerproductupdate_id = B.offerproductupdate_id )";
  180. $result = $db->fetchAll($sql,array($o_id));
  181. return $result;
  182. }
  183. public function insertloanAccount($input) {
  184. $db = $this->getAdapter();
  185. $db->insert('ourbank_loanaccounts',$input);
  186. return '1';
  187. }
  188. public function insertgroupAccount($input) {
  189. $db = $this->getAdapter();
  190. $db->insert('ourbank_groupmembers',$input);
  191. return '1';
  192. }
  193. public function fetchAllOffice()
  194. {
  195. $db = $this->getAdapter();
  196. $sql = 'SELECT * FROM ourbank_bankaddress where recordstatus_id=3 || recordstatus_id=1';
  197. $result = $db->fetchAll($sql,array());
  198. return $result;
  199. }
  200. public function ProductIdDetails($o_id) {
  201. $db = $this->getAdapter();
  202. $sql = "SELECT * FROM ourbank_productsofferdetails where offerproduct_id = ?";
  203. $result = $db->fetchAll($sql,array($o_id));
  204. return $result;
  205. }
  206. public function accountnumber($group_id) {
  207. $db = $this->getAdapter();
  208. $sql = "select * from ourbank_groupaddress A,
  209. ourbank_members B,
  210. ourbank_productsofferdetails C
  211. where (group_id =? &&
  212. A.group_id=B.member_id)" ;
  213. $result = $db->fetchAll($sql,array($group_id));
  214. return $result;
  215. }
  216. public function productnumber($product_id) {
  217. $db = $this->getAdapter();
  218. $sql = "select * from ourbank_productdetails where product_id= ? " ;
  219. $result = $db->fetchAll($sql,array($product_id));
  220. return $result;
  221. }
  222. public function insertAccount($input) {
  223. $db = $this->getAdapter();
  224. $db->insert('ourbank_accounts',$input);
  225. $result = $db->lastInsertId('ourbank_accounts');
  226. return $result;
  227. }
  228. public function updateRow($mFirstInsertedId,$input) {
  229. $db = $this->getAdapter();
  230. $where[] = "account_id = '".$mFirstInsertedId."'";
  231. $result = $db->update('ourbank_accounts',$input,$where);
  232. }
  233. public function branch()
  234. {
  235. $db = $this->getAdapter();
  236. $sql = 'select * from ourbank_bankaddress where officetype_id =4 && recordstatus_id=3';
  237. $result = $db->fetchAll($sql,array());
  238. return $result;
  239. }
  240. public function member($office_id)
  241. {
  242. $db = $this->getAdapter();
  243. $sql = 'select * from ourbank_members A,
  244. ourbank_membername B
  245. where (A.memberbranch_id =? &&
  246. A.member_id = B.member_id &&
  247. B.recordstatus_id=3)';
  248. $result = $db->fetchAll($sql,array($office_id));
  249. return $result;
  250. }
  251. public function groupName($office_id)
  252. {
  253. $db = $this->getAdapter();
  254. $sql = 'select * from ourbank_groupaddress where groupoffice_id =? && groupaccountstatus = 3';
  255. $result = $db->fetchAll($sql,array($office_id));
  256. return $result;
  257. }
  258. public function insertMember($input) {
  259. $db = $this->getAdapter();
  260. $db->insert('ourbank_members',$input);
  261. $result = $db->lastInsertId('ourbank_members');
  262. return $result;
  263. }
  264. public function insertRow($input) {
  265. $db = $this->getAdapter();
  266. $db->insert('ourbank_members',$input);
  267. $result = $db->lastInsertId('ourbank_members');
  268. return $result;
  269. }
  270. public function updateRow1($memberId,$input) {
  271. $db = $this->getAdapter();
  272. $where[] = "member_id = '".$memberId."'";
  273. $result = $db->update('ourbank_members',$input,$where);
  274. }
  275. public function insertgroupaddress($input) {
  276. $db = $this->getAdapter();
  277. $db->insert('ourbank_groupaddress',$input);
  278. return 1;
  279. }
  280. public function groupUpdate($groupname_id,$input) {
  281. $db = $this->getAdapter();
  282. $where[] = "groupname_id = '".$groupname_id."'";
  283. $result = $db->update('ourbank_groupaddress',$input,$where);
  284. }
  285. public function insertUpdates($previous,$current,$groupname_id) {
  286. $db = $this->getAdapter();
  287. $result=array_keys (array_diff($previous,$current));
  288. foreach($result as $group) {
  289. $table_name='ourbank_groupupdates';
  290. $groupupdates = array('groupupdates_id'=>'',
  291. 'groupname_id'=>$groupname_id,
  292. 'fieldname'=>$group,
  293. 'table_name'=>$table_name,
  294. 'previous_data'=>$previous[$group],
  295. 'current_data'=>$current[$group],
  296. 'modified_date'=>date("Y-m-d"));
  297. $db->insert('ourbank_groupupdates',$groupupdates);
  298. }
  299. return;
  300. }
  301. }