Ignore:
Timestamp:
Oct 31, 2014 2:55:30 PM (11 years ago)
Author:
quyenla
Message:

collaborator

File:
1 edited

Legend:

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

    r363 r366  
    5252
    5353    public function addCollaborator() {
    54        
     54        $result['success'] = 0;
    5555        $result = array();
    5656        $input = $this->input->post();
    5757        $this->load->model('collabolator_model');
    58         $this->collabolator_model->insert($input);
    59         $result['success'] = 1;
     58        if (strlen($input['full_name'])==0)
     59        {
     60            $result['errors'][]="Tên cộng tác viên khÃŽng được để trống";
     61        }
     62        if (strlen($input['login_name'])==0)
     63        {
     64            $result['errors'][]="Tên đăng nhập khÃŽng được để trống";
     65        }
     66        else
     67        {
     68            if ($this->collabolator_model->isExist(array('field'=>'login_name','value'=>$input['login_name'])))
     69            {
     70                $result['errors'][]="Tên đăng nhập đã được sá»­ dụng";
     71            }
     72        }
     73        if (strlen($input['cellphone'])==0)
     74        {
     75            $result['errors'][]="Số điện thoại khÃŽng được để trống";
     76        }
     77        else
     78        {
     79            if ($this->collabolator_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'])))
     80            {
     81                $result['errors'][]="Số điện thoại đã được sá»­ dụng";
     82            }
     83        }
     84        if (strlen($input['passwd'])==0)
     85        {
     86            $result['errors'][]="Mật khẩu khÃŽng được để trống";
     87        }
     88        if ($input['passwd'] != $input['passwd2'])
     89        {
     90            $result['errors'][]="Mật khẩu khÃŽng trùng nhau";
     91        }
     92        if (!isset($result['errors']))
     93        {
     94            unset($input['passwd2']);
     95            $input['activated']=1;
     96            $input['created_time']=date("Y-m-d H:i:s");
     97            $input['updated_time']=date("Y-m-d H:i:s");
     98            $this->load->model('collabolator_model');
     99            $this->collabolator_model->insert($input);
     100            $result['success'] = 1;
     101        }
     102
     103       
    60104        echo json_encode($result);
    61105    }
Note: See TracChangeset for help on using the changeset viewer.