PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/application/controllers/admin/Members.php

https://gitlab.com/muktobani/web_site
PHP | 274 lines | 217 code | 55 blank | 2 comment | 12 complexity | 83e63b2edafba3a642b66fcc28ed6497 MD5 | raw file
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Members extends CI_Controller {
  4. function __construct() {
  5. parent::__construct();
  6. $this->load->helper(array('form', 'url'));
  7. $this->load->library('form_validation');
  8. $this->data['title'] = 'Members';
  9. $this->data['description'] = 'description';
  10. $this->data['keywords'] = 'keywords';
  11. $this->data['current_page'] = 'Members';
  12. $this->data['valid_year_fees_arr'] = $this->my_model->get_valid_year_fees();
  13. $this->data['yes_no_arr'] = $this->my_model->get_yes_no();
  14. $this->data['blood_group_arr'] = $this->my_model->get_blood_group();
  15. $this->data['name_title_arr'] = $this->my_model->get_name_titile();
  16. $this->data['member_type_arr'] = $this->my_model->get_member_type();
  17. $this->data['status_arr'] = $this->my_model->get_status();
  18. $this->data['time_zone'] = date("Y-m-d h:i:s a");
  19. }
  20. public function index()
  21. {
  22. $this->data['container'] = 'admin/page/members_list_view';
  23. $this->load->view('admin/template',$this->data);
  24. }
  25. public function add()
  26. {
  27. $id=$this->uri->segment(3);
  28. if($id){$this->data['data_arr'] = $this->my_model->sqlQuery('member_info','member_id',$id,'');}
  29. $this->data['countery_arr'] = $this->my_model->getLibArr('select country_id,country_full_name from lib_country','country_id','country_full_name');
  30. $this->data['container'] = 'admin/page/members_add_view';
  31. $this->load->view('admin/template',$this->data);
  32. }
  33. public function save()
  34. {
  35. $this->form_validation->set_rules('cbo_title', 'Title', 'trim|required');
  36. $this->form_validation->set_rules('cbo_first_name', 'First Name', 'trim|required');
  37. $this->form_validation->set_rules('txt_last_name', 'Last Name', 'trim|required');
  38. $this->form_validation->set_rules('txt_mobile', 'Mobile', 'trim|required');
  39. $this->form_validation->set_rules('txt_email', 'Email', 'trim|required|valid_email');
  40. $this->form_validation->set_rules('txt_house_no', 'House No', 'trim|required');
  41. $this->form_validation->set_rules('txt_street_name', 'Street Name', 'trim|required');
  42. $this->form_validation->set_rules('txt_city', 'Suburb ', 'trim|required');
  43. $this->form_validation->set_rules('txt_ref_name', 'Refrred Full Name', 'trim|required');
  44. $this->form_validation->set_rules('cbo_blood_group', 'Glood Group', 'trim|required');
  45. $this->form_validation->set_rules('txt_is_blood_donate', 'Blood Donate?', 'trim|required');
  46. $this->form_validation->set_rules('txt_is_valunteer', 'Valunteer?', 'trim|required');
  47. $this->form_validation->set_rules('txt_ref_mobile', 'Refrred mobile', 'trim|required');
  48. $this->form_validation->set_rules('txt_member_type', 'Member Type', 'trim|required');
  49. $this->form_validation->set_rules('cbo_valid_year_fees', 'Year Fees', 'trim|required');
  50. $this->form_validation->set_rules('txt_is_agree', 'Agree', 'trim|required');
  51. //$this->form_validation->set_rules('txt_password', 'Password', 'trim|required|min_length[4]');
  52. //$this->form_validation->set_rules('txt_re_password', 'Password Confirmation', 'trim|required|matches[txt_password]');
  53. if ($this->form_validation->run() == FALSE)
  54. {
  55. $this->data['container'] = 'admin/page/members_add_view';
  56. $this->load->view('admin/template',$this->data);
  57. }
  58. else
  59. {
  60. if($_FILES['member_photo']['name'][0]){
  61. $photo=$this->my_model->upload_files($_FILES['member_photo'],time(), 'uploads/member/');
  62. $photo=implode(',',$photo);
  63. }
  64. else
  65. {
  66. $icon='member.gif';
  67. }
  68. $this->member_id = $this->my_model->get_max_id('member_info','member_id');
  69. $this->photo = $photo;
  70. $this->user_id = '';
  71. $this->password = md5('123456');
  72. $this->title = $this->input->post('cbo_title');
  73. $this->first_name = $this->input->post('cbo_first_name');
  74. $this->middle_name = $this->input->post('txt_middle_name');
  75. $this->last_name = $this->input->post('txt_last_name');
  76. $this->nick_name = $this->input->post('txt_nick_name');
  77. $this->birth_date = $this->input->post('txt_birth_date');
  78. $this->phone = $this->input->post('txt_phone');
  79. $this->mobile = $this->input->post('txt_mobile');
  80. $this->email = $this->input->post('txt_email');
  81. $this->house_no = $this->input->post('txt_house_no');
  82. $this->street_name = $this->input->post('txt_street_name');
  83. $this->city = $this->input->post('txt_city');
  84. $this->zip = $this->input->post('txt_zip');
  85. $this->ref_name = $this->input->post('txt_ref_name');
  86. $this->ref_mobile = $this->input->post('txt_ref_mobile');
  87. $this->blood_group = $this->input->post('cbo_blood_group');
  88. $this->is_blood_donate = $this->input->post('txt_is_blood_donate');
  89. $this->is_valunteer = $this->input->post('txt_is_valunteer');
  90. $this->member_type = $this->input->post('txt_member_type');
  91. $this->valid_year = $this->input->post('cbo_valid_year_fees');
  92. $this->is_agree = $this->input->post('txt_is_agree');
  93. $this->insert_time = $this->data['time_zone'];
  94. $this->insert_by = 1;
  95. $this->is_active = $this->input->post('cbo_status');
  96. $this->db->insert('member_info', $this);
  97. redirect(URL.'admin/members', 'refresh');
  98. }
  99. }
  100. public function update()
  101. {
  102. $id=$this->input->post('update_id');
  103. $this->form_validation->set_rules('cbo_title', 'Title', 'trim|required');
  104. $this->form_validation->set_rules('cbo_first_name', 'First Name', 'trim|required');
  105. $this->form_validation->set_rules('txt_last_name', 'Last Name', 'trim|required');
  106. $this->form_validation->set_rules('txt_mobile', 'Mobile', 'trim|required');
  107. $this->form_validation->set_rules('txt_email', 'Email', 'trim|required|valid_email');
  108. $this->form_validation->set_rules('txt_house_no', 'House No', 'trim|required');
  109. $this->form_validation->set_rules('txt_street_name', 'Street Name', 'trim|required');
  110. $this->form_validation->set_rules('txt_city', 'Suburb ', 'trim|required');
  111. $this->form_validation->set_rules('txt_ref_name', 'Refrred Full Name', 'trim|required');
  112. $this->form_validation->set_rules('txt_ref_mobile', 'Refrred mobile', 'trim|required');
  113. $this->form_validation->set_rules('cbo_blood_group', 'Glood Group', 'trim|required');
  114. $this->form_validation->set_rules('txt_is_blood_donate', 'Blood Donate?', 'trim|required');
  115. $this->form_validation->set_rules('txt_is_valunteer', 'Valunteer?', 'trim|required');
  116. $this->form_validation->set_rules('txt_member_type', 'Member Type', 'trim|required');
  117. $this->form_validation->set_rules('cbo_valid_year_fees', 'Year Fees', 'trim|required');
  118. $this->form_validation->set_rules('txt_is_agree', 'Agree', 'trim|required');
  119. if ($this->form_validation->run() == FALSE)
  120. {
  121. $this->data['container'] = 'admin/page/members_add_view';
  122. $this->load->view('admin/template',$this->data);
  123. }
  124. else
  125. {
  126. if($_FILES['member_photo']['name'][0]){
  127. $photo=$this->my_model->upload_files($_FILES['member_photo'],time(), 'uploads/member/');
  128. $photo=implode(',',$photo);
  129. $this->photo = $photo;
  130. }
  131. $this->title = $this->input->post('cbo_title');
  132. $this->first_name = $this->input->post('cbo_first_name');
  133. $this->middle_name = $this->input->post('txt_middle_name');
  134. $this->last_name = $this->input->post('txt_last_name');
  135. $this->nick_name = $this->input->post('txt_nick_name');
  136. $this->birth_date = $this->input->post('txt_birth_date');
  137. $this->phone = $this->input->post('txt_phone');
  138. $this->mobile = $this->input->post('txt_mobile');
  139. $this->email = $this->input->post('txt_email');
  140. $this->house_no = $this->input->post('txt_house_no');
  141. $this->street_name = $this->input->post('txt_street_name');
  142. $this->city = $this->input->post('txt_city');
  143. $this->zip = $this->input->post('txt_zip');
  144. $this->ref_name = $this->input->post('txt_ref_name');
  145. $this->ref_mobile = $this->input->post('txt_ref_mobile');
  146. $this->blood_group = $this->input->post('cbo_blood_group');
  147. $this->is_blood_donate = $this->input->post('txt_is_blood_donate');
  148. $this->is_valunteer = $this->input->post('txt_is_valunteer');
  149. $this->member_type = $this->input->post('txt_member_type');
  150. $this->valid_year = $this->input->post('cbo_valid_year_fees');
  151. $this->is_agree = $this->input->post('txt_is_agree');
  152. $this->update_time = $this->data['time_zone'];
  153. $this->update_by = 1;
  154. $this->is_active = $this->input->post('cbo_status');
  155. $this->db->update('member_info', $this,array('member_id'=>$id));
  156. redirect(URL.'admin/members', 'refresh');
  157. }
  158. }
  159. public function delete()
  160. {
  161. $id=$this->uri->segment(3);
  162. $this->my_model->row_delete('member_info','member_id',$id);
  163. $this->data['container'] = 'admin/page/members_list_view';
  164. $this->load->view('admin/template',$this->data);
  165. }
  166. public function approved()
  167. {
  168. $member_id=$this->input->post('data');
  169. $this->is_active = 1;
  170. if($this->db->update('member_info', $this,array('member_id'=>$member_id))){
  171. echo 'Approved Success';
  172. }
  173. else
  174. {
  175. echo 'Not Approved';
  176. }
  177. }
  178. public function unapproved()
  179. {
  180. $member_id=$this->input->post('data');
  181. $this->is_active = 0;
  182. $this->expair_date = date("Y-m-d h:t:s a",time());
  183. if($this->db->update('member_info', $this,array('member_id'=>$member_id))){
  184. echo 'Unapproved Success';
  185. }
  186. else
  187. {
  188. echo 'Not Unapproved';
  189. }
  190. }
  191. public function renew_approved()
  192. {
  193. $member_id=$this->input->post('data');
  194. if($member_id){$this->data['data_arr'] = $this->my_model->sqlQuery('member_info','member_id',$member_id,'');}
  195. $expair_date=date("Y-m-d h:t:s a",strtotime($this->data['data_arr'][0]['renew_apply_for'].' year', strtotime($this->data['data_arr'][0]['expair_date'])));
  196. $this->expair_date = $expair_date;
  197. if($this->db->update('member_info', $this,array('member_id'=>$member_id))){
  198. echo 'Renew approved Success';
  199. }
  200. else
  201. {
  202. echo 'Unable to Renew';
  203. }
  204. exit();
  205. }
  206. public function send_mail()
  207. {
  208. $member_id=$this->input->post('data');
  209. $email_arr = $this->my_model->getLibArr("select member_id,email from member_info where member_id in($member_id)",'member_id','email');
  210. $mail_list = implode(',',$email_arr);
  211. if($this->my_model->sendEmail($mail_list)){
  212. echo 'Mail Senld Success';
  213. }
  214. else
  215. {
  216. echo 'Mail Not Send';
  217. }
  218. }
  219. }