PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/application/modules_core/client_center/models/mdl_client_account.php

https://bitbucket.org/hlevine/myclientbase-south-african-version
PHP | 79 lines | 48 code | 31 blank | 0 comment | 0 complexity | e00aad868dfb56fe829f3775e809b671 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, GPL-2.0
  1. <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
  2. class Mdl_Client_Account extends MY_Model {
  3. function __construct() {
  4. parent::__construct();
  5. $this->table_name = 'mcb_clients';
  6. $this->primary_key = 'mcb_clients.client_id';
  7. $this->select_fields = '*';
  8. }
  9. function get() {
  10. $params = array(
  11. 'where' => array(
  12. 'mcb_clients.client_id' => $this->session->userdata('client_id')
  13. )
  14. );
  15. return parent::get($params);
  16. }
  17. function validate() {
  18. $this->form_validation->set_rules('client_tax_id', $this->lang->line('tax_id_number'));
  19. $this->form_validation->set_rules('client_address', $this->lang->line('street_address'));
  20. $this->form_validation->set_rules('client_address_2', $this->lang->line('street_address_2'));
  21. $this->form_validation->set_rules('client_city', $this->lang->line('city'));
  22. $this->form_validation->set_rules('client_state', $this->lang->line('state'));
  23. $this->form_validation->set_rules('client_zip', $this->lang->line('zip'));
  24. $this->form_validation->set_rules('client_country', $this->lang->line('country'));
  25. $this->form_validation->set_rules('client_phone_number', $this->lang->line('phone_number'));
  26. $this->form_validation->set_rules('client_fax_number', $this->lang->line('fax_number'));
  27. $this->form_validation->set_rules('client_mobile_number', $this->lang->line('mobile_number'));
  28. $this->form_validation->set_rules('client_email_address', $this->lang->line('email_address'), 'valid_email');
  29. $this->form_validation->set_rules('client_web_address', $this->lang->line('web_address'));
  30. return parent::validate();
  31. }
  32. function save() {
  33. $db_array = parent::db_array();
  34. parent::save($db_array, $this->session->userdata('client_id'));
  35. }
  36. function validate_change_password() {
  37. $this->form_validation->set_rules('password', $this->lang->line('password'), 'required');
  38. $this->form_validation->set_rules('passwordv', $this->lang->line('password_verify'), 'required|matches[password]');
  39. return parent::validate();
  40. }
  41. function save_change_password($password) {
  42. $this->db->set('password', md5($password));
  43. $this->db->where('client_id', $this->session->userdata('client_id'));
  44. $this->db->update('mcb_users');
  45. $this->session->set_flashdata('success_save', TRUE);
  46. }
  47. }
  48. ?>