Ignore:
Timestamp:
Apr 23, 2015 12:00:06 PM (10 years ago)
Author:
namnd
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php

    r838 r906  
    1717        $admin_info = $this->session->userdata('adminInfo');
    1818        if ($admin_info) {
    19             $data['content'] = $this->getCollaborators();
     19                        $roles=array();
     20            foreach ($admin_info['roles'] as $role)
     21            {
     22                $roles[]=$role['role_name'];
     23            }
     24            //$data['roles']=$roles;
     25            $data['content'] = $this->getCollaborators(array(), $roles);
    2026            $this->load->view('collaborator/index', $data);
    2127        } else {
     
    2430    }
    2531
    26     public function getCollaborators($filters = array()) {
     32    public function getCollaborators($filters = array(), $roles) {
    2733        $this->load->helper('pagging');
    2834        $this->load->model('collabolator_model');
     
    7682        $data['num_links'] = 2;
    7783        $data['paging'] = pagging($data);
    78 
     84                $data['roles'] = $roles;
     85               
    7986        if ($this->input->is_ajax_request()) {
    8087            return $this->load->view('collaborator/listview', $data);
     
    8895        $input = $this->input->post();
    8996        $this->load->model('collabolator_model');
    90         if (strlen($input['full_name'])==0)
    91         {
    92             $result['errors'][]=array("content"=>"Tên cộng tác viên khÃŽng được để trống","field"=>"full_name");
    93         }
    94         if (strlen($input['login_name'])==0)
    95         {
    96             $result['errors'][]=array("content"=>"Tên đăng nhập khÃŽng được để trống","field"=>"login_name");
     97               
     98        if (strlen($input['cellphone'])==0)
     99        {
     100            $result['errors'][] = array("content"=>lang('_SBG_PHONE_REQUIRED_MSG'),"field"=>"cellphone");
    97101        }
    98102        else
    99103        {
    100             if ($this->collabolator_model->isExist(array('field'=>'login_name','value'=>$input['login_name'])))
    101             {
    102                 $result['errors'][]=array("content"=>"Tên đăng nhập đã được sá»­ dụng","field"=>"login_name");
    103             }
    104         }
    105         if (strlen($input['cellphone'])==0)
    106         {
    107             $result['errors'][]=array("content"=>"Số điện thoại khÃŽng được để trống","field"=>"cellphone");
    108         }
    109         else
    110         {
     104                        if (!preg_match('/^([0-9]{10,11}$)$/', $input['cellphone'])) {
     105                                $result['errors'][] = array("content"=>lang('_SBG_PHONE_FORMAT_ERROR_MSG'), "field"=>"cellphone");
     106                        }
     107                       
    111108            if ($this->collabolator_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'])))
    112109            {
    113                 $result['errors'][]=array("content"=>"Số điện thoại đã được sá»­ dụng","field"=>"cellphone");
    114             }
    115         }
    116         if (strlen($input['passwd'])==0)
    117         {
    118             $result['errors'][]=array("content"=>"Mật khẩu khÃŽng được để trống","field"=>"passwd");
    119         }
    120         else
    121         {
    122             if ($input['passwd'] != $input['passwd2'])
    123             {
    124                 $result['errors'][]=array("content"=>"Mật khẩu phải trùng nhau","field"=>"passwd");
    125             }
    126         }
     110                $result['errors'][] = array("content"=>lang("_SBG_PHONE_DUPLICATE_MSG"),"field"=>"cellphone");
     111            }
     112        }
     113       
    127114        if (!isset($result['errors']))
    128115        {
    129             unset($input['passwd2']);
    130             $input['passwd']=md5($input['activated']);
    131             $input['activated']=1;
    132             $input['created_time']=date("Y-m-d H:i:s");
    133             $input['updated_time']=date("Y-m-d H:i:s");
     116   
     117                        $passwd = $this->collabolator_model->createRandomPassword();
     118            $input['passwd'] = md5($input['activated']);
     119                        $input['login_name'] = $input['cellphone'];
     120                        $input['author'] = 1;
     121            $input['activated'] = 1;
     122            $input['created_time'] = date("Y-m-d H:i:s");
     123            $input['updated_time'] = date("Y-m-d H:i:s");
    134124            $this->load->model('collabolator_model');
     125                       
    135126            $this->collabolator_model->insert($input);
    136127            $result['success'] = 1;
Note: See TracChangeset for help on using the changeset viewer.