Ejemplo n.º 1
0
 function getList($args = array())
 {
     !isset($args['type']) && ($args['type'] = 'client');
     if (array_key_exists('staff', $args)) {
         $this->db->where('people.staff', $args['staff']);
     }
     return parent::getList($args);
 }
Ejemplo n.º 2
0
 function add($data = array())
 {
     $user_id = parent::add($data);
     $data = array_intersect_key($data, self::$fields);
     $data['id'] = $user_id;
     $data['company'] = $this->company->id;
     $this->db->insert('user', $data);
     return $user_id;
 }
Ejemplo n.º 3
0
    /**
     * 
     * @param array $args
     *	in_class bool 只显示属于某个班级的学生
     * @return type
     */
    function getList($args = array())
    {
        !isset($args['type']) && ($args['type'] = 'student');
        $this->db->select('
			people.*,
			people_team.id AS class,people_team.name AS class_name
		', false)->join('people_relationship class_student', "class_student.relative = people.id AND class_student.is_on = TRUE", isset($args['in_class']) && $args['in_class'] ? 'inner' : 'left')->join('people people_team', "people_team.id = class_student.people", isset($args['in_class']) && $args['in_class'] ? 'inner' : 'left')->where('people_team.type', 'classes');
        if (isset($args['team'])) {
            $this->db->where_in('class_student.people', $args['team']);
            unset($args['team']);
        }
        $args['orderby'] = 'num';
        return parent::getList($args);
    }
Ejemplo n.º 4
0
 /**
  * 根据部分客户名称返回匹配的客户id和名称列表
  * @param $part_of_name
  * @return array
  */
 function match($part_of_name)
 {
     $this->db->join('staff', 'staff.id = people.id', 'inner');
     return parent::match($part_of_name);
 }
Ejemplo n.º 5
0
 function getList($args = array())
 {
     !isset($args['type']) && ($args['type'] = 'client');
     return parent::getList($args);
 }
Ejemplo n.º 6
0
 /**
  * 返回相关人列表
  */
 function relativeList()
 {
     $people = new People_model();
     $list = $this->table->setFields($this->relative_list_args)->setRowAttributes(array('hash' => '{type}/{id}'))->setData($people->getList(array('is_relative_of' => $this->people->id)))->generate();
     return $list;
 }
Ejemplo n.º 7
0
 function __construct()
 {
     parent::__construct();
     $this->fields['type'] = 'contact';
 }
Ejemplo n.º 8
0
 function submit($submit)
 {
     $this->load->library('form_validation');
     try {
         if ($submit == 'profile') {
             if ($this->input->post('password_new')) {
                 if ($this->user->verify($this->user->name, $this->input->post('password')) === false) {
                     throw new Exception('当前密码错误');
                 }
                 if ($this->input->post('password_new') !== $this->input->post('password_new_confirm')) {
                     throw new Exception('两次密码输入不一致');
                 }
                 $this->user->updatePassword($this->user->id, $this->input->post('password_new'));
                 $this->output->message('用户名/密码修改成功');
             }
             if ($this->input->post('username') && $this->input->post('username') !== $this->user->name) {
                 $this->form_validation->set_rules('username', '用户名', 'is_unique[user.name]');
                 if ($this->form_validation->run() !== false) {
                     $this->user->updateUsername($this->user->id, $this->input->post('username'));
                 } else {
                     throw new Exception(validation_errors());
                 }
             }
             $people = $this->input->sessionPost('people');
             $profiles = $this->input->sessionPost('profiles');
             $people_model = new People_model();
             $people_model->update($this->user->id, $people);
             $people_model->updateProfiles($this->user->id, $profiles);
             $this->output->message($this->output->title . ' 已保存');
         } elseif ($submit == 'signup') {
             $this->form_validation->set_rules('username', '用户名', 'required|is_unique[user.name]')->set_rules('password', '密码', 'required')->set_rules('password_confirm', '确认密码', 'matches[password]')->set_message('matches', '两次密码输入不一致');
             if ($this->form_validation->run() === false) {
                 $this->output->message(validation_errors(), 'warning');
                 throw new Exception();
             }
             $data = array('name' => $this->input->post('username'), 'password' => $this->input->post('password'));
             $user_id = $this->user->add($data);
             $this->session->set_userdata('user/id', $user_id);
             $this->user->__construct($user_id);
             $this->output->status = 'redirect_href';
             $this->output->data = '';
         }
     } catch (Exception $e) {
         if ($e->getMessage()) {
             $this->output->message($e->getMessage(), 'warning');
         }
         $this->output->status = 'failed';
     }
     if (is_null($this->output->status)) {
         $this->output->status = 'success';
     }
 }