示例#1
0
 function __construct($uid = NULL)
 {
     parent::__construct();
     $this->table = 'user';
     $this->fields = array_merge($this->fields, array('alias' => '', 'password' => ''));
     if (is_null($uid)) {
         $uid = $this->session->userdata('user/id');
     }
     if ($uid) {
         $user = $this->fetch($uid);
         $this->id = $uid;
         $this->name = $user['name'];
         $this->group = explode(',', $user['group']);
     }
     //TODO 生成了过多的查询,应予以优化
     $this->teams = $this->team->trace($this->id);
     //获取存在数据库中的用户配置项
     $this->db->from('user_config')->where('user', $this->id);
     $config = array_sub($this->db->get()->result_array(), 'value', 'name');
     array_walk($config, function (&$value) {
         $decoded = json_decode($value);
         if (!is_null($decoded)) {
             $value = $decoded;
         }
     });
     $this->config->user = $config;
 }
示例#2
0
 function getTypes()
 {
     $this->db->select('people.type,COUNT(*) AS hits')->from('people')->where('people.company', $this->company->id)->group_by('people.type')->order_by('hits', 'desc');
     $types = array_sub($this->db->get()->result_array(), 'type');
     $types_lang = array();
     foreach ($types as $type) {
         $types_lang[$type] = lang($type);
     }
     return $types_lang;
 }
示例#3
0
 function profile()
 {
     $people_model = new People_model();
     $people = array_merge_recursive($people_model->fetch($this->user->id), $this->input->sessionPost('people'));
     $people_profiles = array_merge_recursive(array_sub($people_model->getProfiles($this->user->id), 'content', 'name'), $this->input->sessionPost('people'));
     $this->load->addViewArrayData(compact('people', 'people_profiles'));
     $this->output->title = '用户资料';
     $this->load->view('user/profile');
     $this->load->view('user/profile_sidebar', true, 'sidebar');
 }
示例#4
0
 function __construct()
 {
     parent::__construct();
     $this->table = 'company';
     $this->recognize($this->input->server('SERVER_NAME'));
     //获取存在数据库中的公司配置项
     $this->db->from('company_config')->where('company', $this->id);
     $config = array_sub($this->db->get()->result_array(), 'value', 'name');
     array_walk($config, function (&$value) {
         $decoded = json_decode($value, true);
         if (!is_null($decoded)) {
             $value = $decoded;
         }
     });
     $this->config->company = $config;
 }
示例#5
0
 function edit($id)
 {
     $this->people->id = $id;
     $this->load->model('staff_model', 'staff');
     try {
         $this->people->data = array_merge($this->people->fetch($id), $this->input->sessionPost('people'));
         $this->people->labels = $this->people->getLabels($this->people->id);
         $this->people->profiles = array_sub($this->people->getProfiles($this->people->id), 'content', 'name');
         if (!$this->people->data['name'] && !$this->people->data['abbreviation']) {
             $this->output->title = '未命名' . lang(CONTROLLER);
         } else {
             $this->output->title = $this->people->data['abbreviation'] ? $this->people->data['abbreviation'] : $this->people->data['name'];
         }
         $available_options = $this->people->getAllLabels();
         $profile_name_options = $this->people->getProfileNames();
         $this->load->addViewData('relative_list', $this->relativeList());
         $this->load->addViewData('profile_list', $this->profileList());
         $this->load->addViewData('project_list', $this->projectList());
         $this->load->addViewData('schedule_list', $this->scheduleList());
         if ($this->people->data['staff']) {
             $this->people->data['staff_name'] = $this->staff->fetch($this->people->data['staff'], 'name');
         }
         $this->load->addViewArrayData(compact('controller', 'available_options', 'profile_name_options'));
         $this->load->addViewData('people', $this->people->data);
         $this->load->addViewData('labels', $this->people->labels);
         $this->load->addViewData('profiles', $this->people->profiles);
         if ($this->input->post('character') && in_array($this->input->post('character'), array('个人', '单位'))) {
             post('people/character', $this->input->post('character'));
         }
         $this->load->view('edit');
         $this->load->view('edit_aside', true, 'sidebar');
     } catch (Exception $e) {
         $this->output->status = 'fail';
         if ($e->getMessage()) {
             $this->output->message($e->getMessage(), 'warning');
         }
     }
 }
示例#6
0
 /**
  * 返回一个可用的profile name列表
  */
 function getProfileNames()
 {
     $this->db->select('people_profile.name,COUNT(*) AS hits', false)->from($this->table . '_profile')->join('people', "people_profile.people = people.id AND people.company = {$this->company->id}")->group_by('people_profile.name')->order_by('hits', 'desc');
     $result = $this->db->get()->result_array();
     return array_sub($result, 'name');
 }
示例#7
0
<button type="submit" name="submit[document]" class="major">保存</button>
<select name="labels[]" class="chosen allow-new" data-placeholder="标签" multiple="multiple">
	<?php 
echo options($this->document->getAllLabels(), $labels);
?>
</select>
<?php 
if ($mod & 2) {
    ?>
<button type="submit" name="submit[delete]" class="major">删除</button>
<?php 
}
if ($mod & 3) {
    ?>
<label>有权限查看:</label>
<select name="read_mod_people" class="chosen" data-placeholder="查看权限" multiple="multiple" title="查看权限">
	<?php 
    echo options(array_sub($this->user->teams, 'name') + $this->user->getArray(array('is_relative_of' => array_merge(array_keys($this->user->teams), array($this->user->id))), 'name', 'id') + $this->user->getArray(array('has_relative_like' => $this->user->id), 'name', 'id') + $this->user->getArray(array('is_secondary_relative_of' => $this->user->id), 'name', 'id') + $this->user->getArray(array('is_both_relative_with' => $this->user->id), 'name', 'id'), $read_mod_people, NULL, true);
    ?>
</select>
<?php 
}
echo $this->javascript('document_edit');
示例#8
0
 /**
  * 根据$this->fields和输入的$data数据,返回一个新的$data_compiled
  */
 function _compile_rows()
 {
     if (!is_array($this->fields)) {
         return;
     }
     $rows_compiled = array();
     foreach ($this->rows as $row) {
         $row_compiled = array();
         if (isset($row['id'])) {
             $row_compiled['_attr']['id'] = $row['id']['data'];
         }
         foreach ($this->row_attr as $attr_name => $attr_value) {
             $row_compiled['_attr'][$attr_name] = $this->parser->parse_string($attr_value, array_sub($row, 'data', NULL, true), true);
         }
         foreach ($this->fields as $field_name => $field) {
             $cell = array('data' => NULL);
             //如果列设定中没有cell,或者cell是数组但没有data键,那么使用原始数据
             if (!isset($field['cell']) || is_array($field['cell']) && !isset($field['cell']['data'])) {
                 if (array_key_exists($field_name, $row) && array_key_exists('data', $row[$field_name])) {
                     $cell['data'] = $row[$field_name]['data'];
                 }
             } else {
                 if (is_array($field['cell'])) {
                     $cell['data'] = $field['cell']['data'];
                 } else {
                     $cell['data'] = $field['cell'];
                 }
             }
             if (array_key_exists('cell', $field) && is_array($field['cell'])) {
                 $cell += $field['cell'];
             }
             foreach ($cell as $attr_name => $attr_value) {
                 $cell[$attr_name] = $this->parser->parse_string($attr_value, array_sub($row, 'data', NULL, true), true);
             }
             //用指定函数来处理$cell[data]
             if (isset($field['parser'])) {
                 foreach ($field['parser']['args'] as $key => $value) {
                     if (array_key_exists($value, $row)) {
                         $field['parser']['args'][$key] = array_key_exists('data', $row[$value]) ? $row[$value]['data'] : $row[$value];
                     }
                 }
                 $cell['data'] = call_user_func_array($field['parser']['function'], $field['parser']['args']);
             }
             $row_compiled[$field_name] = $cell;
         }
         $rows_compiled[] = $row_compiled;
     }
     $this->rows = $rows_compiled;
 }
示例#9
0
 function instrument($type, $condition)
 {
     $paper = $item = array();
     $line = '';
     $item[] = $condition['client_name'] . '( 以下简称"委托人")因与' . $condition['opposite_side'] . $condition['opposite'] . '纠纷一案,聘请上海星瀚律师事务所(以下简称"律师事务所")的律师处理相关法律事宜,经双方协商一致,订立下列条款,共同遵照履行:';
     $paper[] = $item;
     $item = array();
     //添加一级段落
     $item[] = '委托人委托律师事务所处理的事务内容为:';
     $line = '诉讼阶段:';
     $glue = '';
     foreach ($condition['stages'] as $stage) {
         if ($stage != 'total') {
             $line .= $glue;
             $line .= $stage;
             $glue = ',';
         }
     }
     $line .= '(权限详见授权委托书)。';
     $item[] = $line;
     $paper[] = $item;
     $item = array();
     //添加一级段落
     $line = '律师事务所指派';
     $glue = '';
     foreach ($condition['lawyer'] as $lawyer => $hourlyFee) {
         $line .= $glue;
         $line .= $lawyer;
         $glue = ',';
     }
     $line .= '作为本合同项下案件承办律师(以下简称"律师")。';
     $item[] = $line;
     $paper[] = $item;
     $item = array();
     //添加一级段落
     $item[] = '根据双方协商一致,本合同项下律师费按以下方式收取:';
     foreach ($condition['fee'] as $stage => $feeArray) {
         if ($stage != 'total') {
             $item[] = $stage . ':';
         }
         if (array_key_exists('固定', $feeArray) && !array_key_exists('风险', $feeArray)) {
             //固定收费
             $item[] = '固定收费:';
             $item[] = '律师费为' . formalRMB($feeArray['固定']) . ',由委托人于签订本合同二日内向律师事务所支付。';
         } else {
             //含风险收费
             $item[] = '风险代理的基本收费:';
             $item[] = '签订本合同后二日内,委托人应当支付律师事务所' . formalRMB($feeArray['固定']) . '作为律师风险代理的基本律师费。';
             $item[] = '风险代理的风险收费:';
             foreach ($feeArray['风险'] as $riskFeeItem) {
                 $line = '若通过律师工作,委托人能与第三人通过协商、调解、案外和解等方式或通过法院判决、法院调解等方式从而';
                 $line .= $riskFeeItem['condition'];
                 $line .= '则委托人同意另行按';
                 if (isset($riskFeeItem['percent'])) {
                     $line .= '获得上述款项的' . $riskFeeItem['percent'] . '%';
                 }
                 if (isset($riskFeeItem['percent']) && isset($riskFeeItem['fee'])) {
                     $line .= ',以及';
                 }
                 if (isset($riskFeeItem['fee'])) {
                     $line .= formalRMB($riskFeeItem['fee']);
                 }
                 $line .= '的标准向律师事务所支付律师风险代理费。';
             }
             $item[] = $line;
             $item[] = '本条款项下律师费用应在' . $condition['fee_pay_time'] . '支付';
         }
     }
     $item[] = $line;
     $paper[] = $item;
     $item = array();
     //添加一级段落
     if (isset($condition['fee_misc'])) {
         $item[] = '根据双方协商一致,与办理委托事项密切关联的各项支出(以下可简称"办案费用")中,交通费、邮寄费、调查费、复印费、诉讼费、保全费、外地餐饮费、外地住宿费、查询费等由委托人承担。本合同签订后的二日内,委托人应向预付办案费用' . formalRMB($condition['fee_misc']) . ',结案时据实结算。';
     }
     $item[] = $line;
     $paper[] = $item;
     $item = array();
     //添加一级段落
     $q_items = "SELECT * FROM instrument WHERE 1=1 ORDER BY `order`";
     $items = db_toArray($q_items);
     $items = array_sub($items, 'content');
     for ($i = 0; $i < count($items); $i++) {
         $items[$i] = explode("\n", $items[$i]);
     }
     $paper = array_merge($paper, $items);
 }
示例#10
0
function enableTagsPicker()
{
    global $taglist;
    static $taglist_inserted;
    includeJQueryUI();
    addCSS('css/tagit.css');
    addJS('js/tag-it.js');
    addJS('js/tag-it-local.js');
    if (!$taglist_inserted) {
        $taglist_filtered = array();
        foreach ($taglist as $key => $taginfo) {
            # remove unused fields
            $taglist_filtered[$key] = array_sub($taginfo, array("tag", "is_assignable", "trace"));
        }
        addJS('var taglist = ' . json_encode($taglist_filtered) . ';', TRUE);
        $taglist_inserted = TRUE;
    }
}
示例#11
0
 /**
  * update related people of a schedule
  * will add new ones and remove old ones
  * suitbable for all add/remove/update operation when an array of people is given
  * @param int $schedule_id
  * @param array $setto
  */
 function updatePeople($schedule_id, $setto)
 {
     $schedule_id = intval($schedule_id);
     if (!is_array($setto)) {
         $setto = array();
     }
     //操作人总在人员列表中
     if (!in_array($this->user->id, $setto)) {
         array_push($setto, $this->user->id);
     }
     $this->db->select('people')->from('schedule_people')->where('schedule_people.schedule', $schedule_id);
     $origin = array_sub($this->db->get()->result_array(), 'people');
     $insert = array_diff($setto, $origin);
     $delete = array_diff($origin, $setto);
     if ($delete) {
         $this->db->where('schedule', $schedule_id)->where_in('people', $delete)->delete('schedule_people');
     }
     if ($insert) {
         $set = array();
         foreach ($insert as $people) {
             $set[] = array('schedule' => $schedule_id, 'people' => $people);
         }
         $this->db->insert_batch('schedule_people', $set);
         $name = $this->fetch($schedule_id, 'name');
         $this->message->send($name, $insert);
     }
 }
示例#12
0
 /**
  * 当前用户向一个或多个用户或组发送消息
  * 注意,只有不知道dialog的时候才调用此函数,否则使用sendByDialog
  * @param $content
  * @param array or int $user 接收消息的用户或组
  * @return message.id
  * @todo 非本组成员向本组发送消息,应当先经过组长审批
  * @todo 已经存在的组对话,外来发件人不会自动加入会话
  */
 function send($content, $receivers)
 {
     if (!is_array($receivers)) {
         $receivers = array($receivers);
     }
     array_walk($receivers, function ($value) {
         $value = intval($value);
     });
     //根据user过滤收件人,并且去除本人
     $receivers = array_sub($this->db->select('id')->from('user')->where_in('id', $receivers)->where('id !=', $this->user->id)->get()->result_array(), 'id');
     if (empty($receivers)) {
         return;
     }
     $message = $this->add($content);
     $team_receivers = array_sub($this->db->select('id')->from('team')->where_in('id', $receivers)->get()->result_array(), 'id');
     $personal_receivers = array_diff($receivers, $team_receivers);
     //找出组收件人,获得其对话。由于一个组只可能出现在一个会话中,因此单找即可
     $result_existed_team_dialogs = $this->db->select('dialog,user')->from('dialog_user')->where_in('user', $team_receivers)->get()->result_array();
     $team_dialogs = array_sub($result_existed_team_dialogs, 'dialog');
     $team_receivers_with_dialog = array_sub($result_existed_team_dialogs, 'user');
     //获得每个非组收件人和当前用户所在的2人会话
     $this->db->select('d0.dialog, d1.user')->from('dialog_user d0')->join('dialog_user d1', 'd0.dialog = d1.dialog', 'inner')->join('dialog', 'dialog.id = d0.dialog AND dialog.users=2', 'inner')->where('FALSE', NULL, false);
     foreach ($personal_receivers as $personal_receiver) {
         $this->db->or_where("(d0.user = {$this->user->id} AND d1.user = {$personal_receiver})", NULL, false);
     }
     $result_existed_personal_dialogs = $this->db->get()->result_array();
     $personal_dialogs = array_sub($result_existed_personal_dialogs, 'dialog');
     $personal_receivers_with_dialog = array_sub($result_existed_personal_dialogs, 'user');
     //获得不存在会话的收件人
     $personal_receivers_without_dialog = array_diff($personal_receivers, $personal_receivers_with_dialog);
     $team_receivers_without_dialog = array_diff($team_receivers, $team_receivers_with_dialog);
     //创建非组收件人的会话
     foreach ($personal_receivers_without_dialog as $personal_receiver_without_dialog) {
         $this->db->insert('dialog', array('company' => $this->company->id, 'users' => 2, 'uid' => $this->user->id, 'time' => $this->date->now, 'last_message' => $message));
         $dialog = $this->db->insert_id();
         $personal_dialogs[] = $dialog;
         $this->db->insert('dialog_user', array('dialog' => $dialog, 'user' => $personal_receiver_without_dialog, 'title' => $this->user->name, 'read' => false));
         $this->db->insert('dialog_user', array('dialog' => $dialog, 'user' => $this->user->id, 'title' => $this->people->fetch($personal_receiver_without_dialog, 'name'), 'read' => true));
     }
     //创建组收件人的会话
     foreach ($team_receivers_without_dialog as $team_receiver_without_dialog) {
         $team_members_result = $this->db->select('relative')->from('people_relationship')->where('people', $team_receiver_without_dialog)->get()->result_array();
         $team_members = array_sub($team_members_result, 'relative');
         $this->db->insert('dialog', array('company' => $this->company->id, 'users' => count($team_members), 'uid' => $this->user->id, 'time' => $this->date->now, 'last_message' => $message));
         $dialog = $this->db->insert_id();
         $team_dialogs[] = $dialog;
         $set = array(array('dialog' => $dialog, 'user' => $team_receiver_without_dialog, 'title' => $this->team->fetch($team_receiver_without_dialog, 'name')));
         foreach ($team_members as $team_member) {
             $set[] = array('dialog' => $dialog, 'user' => $team_member, 'title' => $this->team->fetch($team_receiver_without_dialog, 'name'));
         }
         if (!in_array($this->user->id, $team_members)) {
             $set[] = array('dialog' => $dialog, 'user' => $this->user->id, 'title' => $this->team->fetch($team_receiver_without_dialog, 'name'));
         }
         $this->db->insert_batch('dialog_user', $set);
     }
     $set = array();
     $dialogs = $personal_dialogs + $team_dialogs;
     //把新消息插入这些会话
     foreach ($dialogs as $dialog) {
         $set[] = array('dialog' => $dialog, 'message' => $message);
     }
     $this->db->insert_batch('dialog_message', $set);
     $this->db->where_in('id', $dialogs)->update('dialog', array('last_message' => $message));
     $this->db->where_in('dialog', $dialogs)->update('dialog_user', array('read' => false));
     $this->db->set('hidden', false)->where_in('dialog', $dialogs)->update('dialog_user');
     $set = $this->db->select('user')->from('dialog_user')->where_in('dialog', $dialogs)->get()->result_array();
     foreach ($set as $key => $val) {
         $set[$key] += array('message' => $message, 'read' => false, 'deleted' => false);
     }
     $this->db->insert_batch('message_user', $set);
     //将发件人的会话和消息标记为已读
     $this->db->where_in('dialog', $dialogs)->where('user', $this->user->id)->update('dialog_user', array('read' => true));
     $this->db->where(array('message' => $message, 'user' => $this->user->id))->update('message_user', array('read' => true));
     return $message;
 }
示例#13
0
 function generateArchiveBonus()
 {
     $this->load->model('cases_model', 'cases');
     $archived_cases = $this->cases->getList(array('end' => array('from' => '2013-01-01', 'to' => '2013-06-30'), 'active' => false, 'without_labels' => array('结案奖金已生成')));
     foreach ($archived_cases as $archived_case) {
         $archived_accounts = $this->account->getList(array('type' => '结案奖金储备', 'project' => $archived_case['id']));
         if (!$archived_accounts) {
             continue;
         }
         $archived_bonus = array_sum(array_sub($archived_accounts, 'amount'));
         $staffs = $this->people->getList(array('in_project' => $archived_case['id'], 'project_people_role' => '实际贡献'));
         foreach ($staffs as $staff) {
             $this->account->add(array('name' => '结案奖金', 'type' => '结案奖金', 'amount' => $archived_bonus * $staff['weight'], 'received' => false, 'count' => false, 'project' => $archived_case['id'], 'people' => $staff['id'], 'display' => true, 'comment' => "结案奖金储备:\n" . implode("\n", array_sub($archived_accounts, 'comment')) . ' 实际贡献:' . round($staff['weight'] * 100, 1) . '%'));
         }
         $this->cases->addLabel($archived_case['id'], '结案奖金已生成');
     }
 }
示例#14
0
 function index()
 {
     //验证
     if ($this->input->get('echostr')) {
         //TODO 需要对来源进行鉴别
         $this->output->set_output($this->input->get('echostr'));
         $this->_validation();
     }
     //消息回复
     ENVIRONMENT === 'development' && ($GLOBALS["HTTP_RAW_POST_DATA"] = '1');
     if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
         xml_parse_into_struct(xml_parser_create(), $GLOBALS["HTTP_RAW_POST_DATA"], $post);
         $post = array_sub($post, 'value', 'tag');
         ENVIRONMENT === 'development' && ($post = array('MSGTYPE' => 'text', 'TOUSERNAME' => 'allstar', 'FROMUSERNAME' => 'uicestone', 'CONTENT' => "陆海"));
         $this->load->addViewArrayData($post);
         $message = '';
         $user = $this->people->getRow(array('has_profiles' => array('weixin_openid' => $post['FROMUSERNAME'])));
         //如果发件人不是已知用户,那么尝试一下将信息作为用户名密码登陆
         if (!$user) {
             $user = array();
             $login = preg_split('/\\s/', $post['CONTENT']);
             if (count($login) === 2) {
                 $user = $this->user->verify($login[0], $login[1]);
             }
             //如果登陆成功,则保存openid今后不用再认证了
             if ($user) {
                 $this->people->addProfile($user['id'], 'weixin_openid', $post['FROMUSERNAME']);
                 $message .= $user['name'] . ', 欢迎你回来' . "\n";
             }
         }
         if ($user) {
             $this->user->__construct($user['id']);
         }
         //文本消息
         if ($post['MSGTYPE'] === 'text') {
             //如果是职员
             if ($this->people->getRow(array('id' => $this->user->id, 'is_staff' => true))) {
                 $people = array_sub($this->people->match($post['CONTENT']), 'id');
                 $data = $this->people->getList(array('id_in' => $people, 'get_profiles' => true));
                 array_walk($data, function (&$value) {
                     $value = array_merge($value, $value['profiles']);
                     unset($value['profiles']);
                 });
                 foreach ($data as $row) {
                     $message .= $row['name'] . "\n";
                     foreach ($row as $field_name => $field_value) {
                         if (in_array($field_name, array('id', 'type', 'name', 'abbreviation'))) {
                             continue;
                         }
                         $message .= $field_name . ": \n  " . $field_value . "\n";
                     }
                     $message .= "\n\n";
                 }
             } else {
                 $message = "上海星瀚律师事务所 021-51096488\n上海市普陀区常德路1211号宝华大厦12楼 地铁七号线长寿路站";
             }
             $this->load->addViewData('message', $message);
             $this->load->view('weixin/reply_text');
         }
     }
 }
示例#15
0
" placeholder="状态" />
			<input type="text" name="status[date]" value="<?php 
    echo $this->value('status/date');
    ?>
" class="date" placeholder="日期" />
			<input type="text" name="status[content]" value="<?php 
    echo $this->value('status/content');
    ?>
" placeholder="内容" />
			<input type="text" name="status[comment]" value="<?php 
    echo $this->value('status/comment');
    ?>
" placeholder="备注" />
			<select name="status[team]">
				<?php 
    echo options(array_sub($this->user->teams, 'name'), $this->value('status/team'), '评价团队', true);
    ?>
			</select>
			<button type="submit" name="submit[status]">添加</button>
		</span>
<?php 
}
?>
	 </div>

	<div class="item" name="profile" locked="locked">
		<div class="title"><label>资料项</label></div>
		<?php 
echo $profile_list;
?>
		<button type="button" class="toggle-add-form">+</button>
示例#16
0
 function getModels()
 {
     $this->db->from('evaluation_model')->where('company', $this->company->id);
     return array_sub($this->db->get()->result_array(), 'name', 'id');
 }
示例#17
0
 function addMod($mod, $people, $document = NULL)
 {
     is_null($document) && ($document = $this->id);
     if (!is_array($people)) {
         $people = array($people);
     }
     $result_document_mod = $this->db->from('document_mod')->where('document', $document)->where_in('people', $people)->get()->result_array();
     $people_with_permission = array_sub($result_document_mod, 'people');
     $people_without_permission = array_diff($people, $people_with_permission);
     foreach ($people_with_permission as $person_with_permission) {
         $this->db->where('document', $document)->where('people', $person_with_permission)->set('mod', '`mod` | ' . intval($mod), false)->update('document_mod');
     }
     $set = array();
     foreach ($people_without_permission as $person_without_permission) {
         $set[] = array('document' => $document, 'people' => $person_without_permission, 'mod' => $mod);
     }
     $this->db->insert_batch('document_mod', $set);
 }
示例#18
0
文件: cases.php 项目: honj51/syssh
 function submit($submit, $id, $button_id = NULL)
 {
     parent::submit($submit, $id, $button_id);
     try {
         if ($submit == 'project') {
             if ($this->cases->data['type'] === 'cases' && !$this->cases->data['num']) {
                 $this->output->message('尚未获取案号,请选择案件领域和分类后获取案号', 'warning');
                 throw new Exception();
             }
             if (isset($this->cases->labels['分类']) && $this->cases->data['type'] === 'cases' && !$this->cases->data['focus']) {
                 if ($this->cases->labels['分类'] === '争议') {
                     $this->output->message('请填写案件争议焦点', 'warning');
                     throw new Exception();
                 } elseif ($this->cases->labels['分类'] === '非争议') {
                     $this->output->message('请填写案件标的', 'warning');
                     throw new Exception();
                 }
             }
         } elseif ($submit == 'client') {
             $this->load->model('client_model', 'client');
             //这样对数组做加法,后者同名键不会替换前者,即后者是前者的补充,而非更新
             $project_client = $this->input->sessionPost('case_client');
             $client = $this->input->sessionPost('client');
             $client_profiles = $this->input->sessionPost('client_profiles');
             $client_labels = $this->input->sessionPost('client_labels');
             if (!$project_client['role']) {
                 $this->output->message('请选择本案地位', 'warning');
                 throw new Exception();
             }
             if ($project_client['client']) {
                 if ($project_client['role'] === '主委托人') {
                     $recent_case_of_client = $this->cases->getRow(array('people' => $project_client['client'], 'role' => '主委托人', 'before' => $this->cases->id, 'order_by' => 'time_contract desc'));
                     $recent_case_of_client_relative = $this->cases->getRow(array('people_is_relative_of' => $project_client['client'], 'role' => '主委托人', 'before' => $this->cases->id, 'order_by' => 'time_contract desc'));
                     $recent_case_of_client_arelative = $this->cases->getRow(array('people_has_relative_like' => $project_client['client'], 'role' => '主委托人', 'before' => $this->cases->id, 'order_by' => 'time_contract desc'));
                     if ($recent_case_of_client) {
                         $recent_case = $recent_case_of_client;
                     }
                     if ($recent_case_of_client_relative && (!isset($recent_case) || $recent_case_of_client_relative['time_contract'] > $recent_case['time_contract'])) {
                         $recent_case = $recent_case_of_client_relative;
                     }
                     if ($recent_case_of_client_arelative && (!isset($recent_case) || $recent_case_of_client_arelative['time_contract'] > $recent_case['time_contract'])) {
                         $recent_case = $recent_case_of_client_arelative;
                     }
                     if (isset($recent_case)) {
                         $this->cases->addLabel($this->cases->id, '再成案');
                         $this->cases->addRelative($this->cases->id, $recent_case['id'], '上次签约案件');
                         $previous_roles = $this->cases->getRolesPeople($recent_case['id']);
                         $recent_case_profiles = array_sub($this->cases->getProfiles($recent_case['id']), 'content', 'name');
                         foreach (array('案源人') as $role) {
                             if (isset($previous_roles[$role])) {
                                 foreach ($previous_roles[$role] as $people) {
                                     $this->cases->addStaff($this->cases->id, $people['people'], $role, $people['weight'] / 2);
                                 }
                             }
                         }
                         $this->cases->addProfile($this->cases->id, '案源系数', 0.2 - (0.2 - $recent_case_profiles['案源系数']) / 2);
                         $this->cases->addProfile($this->cases->id, '案源类型', $recent_case_profiles['案源类型']);
                         $this->output->setData($this->relativeList(), 'relative-list', 'content-table', '.item[name="relative"]>.contentTable', 'replace');
                         $this->output->setData($this->staffList(), 'staff-list', 'content-table', '.item[name="staff"]>.contentTable', 'replace');
                     } else {
                         $this->cases->profiles['案源类型'] = array_sub($this->client->getProfiles($project_client['client']), 'content', 'name')['来源类型'] === '亲友介绍' ? '个人案源' : '所内案源';
                         if ($this->cases->profiles['案源类型'] === '所内案源') {
                             $this->cases->addProfile($this->cases->id, '案源系数', 0.08);
                         } else {
                             $this->cases->addProfile($this->cases->id, '案源系数', 0.2);
                         }
                         $this->cases->addProfile($this->cases->id, '案源类型', $this->cases->profiles['案源类型']);
                     }
                 }
             } else {
                 //添加新客户
                 if (!$client['name']) {
                     $this->output->message('请输入客户或相关人名称', 'warning');
                     throw new Exception();
                 }
                 $new_client = array('name' => $client['name'], 'character' => isset($client['character']) && $client['character'] == '单位' ? '单位' : '个人', 'type' => $client['type'], 'labels' => $client_labels);
                 if (!$client_profiles['电话'] && !$client_profiles['电子邮件']) {
                     $this->output->message('至少输入一种联系方式', 'warning');
                     throw new Exception();
                 }
                 foreach ($client_profiles as $name => $content) {
                     if ($name == '电话') {
                         if ($this->client->isMobileNumber($content)) {
                             $new_client['profiles']['手机'] = $content;
                         } else {
                             $new_client['profiles']['电话'] = $content;
                         }
                         $new_client['phone'] = $content;
                     } elseif ($name == '电子邮件' && $content) {
                         if (!$this->form_validation->valid_email($content)) {
                             $this->output->message('请填写正确的Email地址', 'warning');
                             throw new Exception();
                         }
                         $new_client['email'] = $content;
                     } else {
                         $new_client['profiles'][$name] = $content;
                     }
                 }
                 if ($client['type'] == 'client') {
                     //客户必须输入来源
                     if (empty($client_profiles['来源类型'])) {
                         $this->output->message('请选择客户来源类型', 'warning');
                         throw new Exception();
                     }
                     $this->load->model('staff_model', 'staff');
                     $client['staff'] = $this->staff->check($client['staff_name']);
                     $new_client['staff'] = $client['staff'];
                 } else {
                     //非客户必须输入工作单位
                     if (!$client['work_for']) {
                         $this->output->message('请输入工作单位', 'warning');
                         throw new Exception();
                     }
                 }
                 if ($client['work_for']) {
                     $new_client['work_for'] = $client['work_for'];
                 }
                 $new_client['display'] = true;
                 $project_client['client'] = $this->client->add($new_client);
                 $this->output->message('<a href="#' . $client['type'] . '/' . $project_client['client'] . '">新' . lang($client['type']) . ' ' . $client['name'] . ' 已经添加,点击编辑详细信息</a>');
             }
             if ($this->cases->addPeople($this->cases->id, $project_client['client'], 'client', $project_client['role'])) {
                 $this->output->setData($this->clientList(), 'client-list', 'content-table', '.item[name="client"]>.contentTable', 'replace');
             } else {
                 $this->output->message('客户添加错误', 'warning');
                 throw new Exception();
             }
             unsetPost('case_client');
             $this->session->unset_userdata();
             unsetPost('case_client');
             unsetPost('client');
             unsetPost('client_profiles');
             unsetPost('client_labels');
         } elseif ($submit == 'remove_client') {
             if ($this->cases->removePeople($this->cases->id, $button_id)) {
                 $this->output->setData($this->clientList(), 'client-list', 'content-table', '.item[name="client"]>.contentTable', 'replace');
             }
         } elseif ($submit == 'staff') {
             $this->load->model('staff_model', 'staff');
             $staff = $this->input->sessionPost('staff');
             if (!$staff['id']) {
                 $staff['id'] = $this->staff->check($staff['name']);
                 if (!$staff['id']) {
                     $this->output->message('请输入职员名称', 'warning');
                     throw new Exception();
                 }
             }
             if (!$staff['role']) {
                 $this->output->message('未选择本案职务', 'warning');
                 throw new Exception();
             }
             if (in_array($staff['role'], array('案源人', '接洽律师', '主办律师')) && !$staff['weight']) {
                 $staff['weight'] = 100;
             }
             if ($staff['weight'] === '') {
                 $staff['weight'] = NULL;
             } else {
                 $staff['weight'] /= 100;
             }
             if ($this->cases->addStaff($this->cases->id, $staff['id'], $staff['role'], $staff['weight'])) {
                 $this->message->send('将你加入<a href="#' . $this->cases->data['type'] . '/' . $this->cases->data['id'] . '">案件:' . $this->cases->data['name'] . '</a>', $staff['id']);
                 $this->output->setData($this->staffList(), 'staff-list', 'content-table', '.item[name="staff"]>.contentTable', 'replace');
                 unsetPost('staff/id');
             } else {
                 $this->output->message('人员添加错误', 'warning');
             }
             unsetPost('staff');
         } elseif ($submit == 'remove_staff') {
             if ($this->cases->removePeople($this->cases->id, $button_id)) {
                 $this->output->setData($this->staffList(), 'staff-list', 'content-table', '.item[name="staff"]>.contentTable', 'replace');
             }
         } elseif ($submit == 'fee') {
             $this->load->model('account_model', 'account');
             $fee = $this->input->sessionPost('fee');
             if (!is_numeric($fee['amount'])) {
                 $this->output->message('请预估收费金额(数值)', 'warning');
             }
             if (!$fee['comment']) {
                 $this->output->message('请填写付款条件', 'warning');
             }
             if (!$fee['date']) {
                 $this->output->message('请预估收费时间', 'warning');
             }
             if (count($this->output->message['warning']) > 0) {
                 throw new Exception();
             }
             $this->account->add($fee + array('project' => $this->project->id, 'display' => true));
             $this->output->setData($this->feeList(), 'fee-list', 'content-table', '.item[name="fee"]>.contentTable', 'replace');
             unsetPost('fee');
         } elseif ($submit == 'review') {
             $this->cases->removeLabel($this->cases->id, '等待立案审核');
             $this->cases->addLabel($this->cases->id, '在办');
             $this->output->status = 'refresh';
             $this->output->message('通过立案审核');
         } elseif ($submit == 'apply_lock') {
             //@TODO申请锁定,通过标签和消息系统来解决
         } elseif ($submit == 'lock_client') {
             $this->cases->addLabel($this->cases->id, '客户已锁定');
             $this->output->status = 'refresh';
         } elseif ($submit == 'lock_staff') {
             $this->cases->addLabel($this->cases->id, '职员已锁定');
             $this->output->status = 'refresh';
         } elseif ($submit == 'lock_fee') {
             $this->cases->addLabel($this->cases->id, '费用已锁定');
             $this->output->status = 'refresh';
         } elseif ($submit == 'unlock_client') {
             $this->cases->removeLabel($this->cases->id, '客户已锁定');
             $this->output->status = 'refresh';
         } elseif ($submit == 'unlock_staff') {
             $this->cases->removeLabel($this->cases->id, '职员已锁定');
             $this->output->status = 'refresh';
         } elseif ($submit == 'unlock_fee') {
             $this->cases->removeLabel($this->cases->id, '费用已锁定');
             $this->output->status = 'refresh';
         } elseif ($submit == 'apply_file') {
             $this->cases->addLabel($this->cases->id, '已申请归档');
             $this->cases->update($this->cases->id, array('end' => $this->date->today));
             $this->output->message('归档申请已接受');
         } elseif ($submit == 'review_finance') {
             $this->cases->addLabel($this->cases->id, '通过财务审核');
             $this->output->status = 'refresh';
             $this->output->message('结案财务状况已经审核');
         } elseif ($submit == 'review_info') {
             $this->cases->addLabel($this->cases->id, '通过信息审核');
             $this->output->status = 'refresh';
             $this->output->message('案件信息已经审核');
         } elseif ($submit == 'review_manager') {
             $this->cases->addLabel($this->cases->id, '通过主管审核');
             $this->cases->update($this->cases->id, array('end' => $this->date->today));
             $this->output->status = 'refresh';
             $this->output->message('案件已经审核,已正式归档');
         } elseif ($submit == 'file' && $this->cases->data['type'] === 'cases') {
             $this->cases->removeLabel($this->cases->id, '已申请归档');
             $this->cases->addLabel($this->cases->id, '案卷已归档');
             $this->cases->update($this->cases->id, array('active', false));
             $this->output->status = 'refresh';
             $this->output->message('案卷归档归档完成');
         } elseif ($submit == 'apply_num') {
             if (empty($this->cases->labels['领域'])) {
                 $this->output->message('获得案号前要先选择案件领域', 'warning');
                 throw new Exception();
             }
             if (empty($this->cases->labels['分类'])) {
                 $this->output->message('获得案号前要先选择案件分类', 'warning');
                 throw new Exception();
             }
             if (!$this->cases->data['name']) {
                 $this->output->message('获得案号前要先填写案件名称', 'warning');
                 throw new Exception();
             }
             $this->cases->data['num'] = $this->cases->getNum($this->cases->labels);
             $this->cases->data['display'] = true;
             $this->cases->update($this->cases->id, $this->cases->data);
             $this->cases->updateLabels($this->cases->id, $this->cases->labels);
             $this->output->status = 'redirect';
             $this->output->data = 'cases/' . $this->cases->id;
         }
     } catch (Exception $e) {
         $e->getMessage() && $this->output->message($e->getMessage(), 'warning');
         $this->output->status = 'fail';
     }
 }
示例#19
0
文件: Date.php 项目: srsman/89jian
 /**
  * 返回两个工作日之间加班日的数组
  * @param NULL/int $people
  * @return array
  */
 function overtimedays($people = NULL)
 {
     $this->db->select('date')->from('holidays')->where('is_overtime', true)->where('staff', $people);
     return array_sub($this->db->get()->result_array(), 'date');
 }
示例#20
0
 /**
  * @param array $labels
  * @return array
  */
 function getRelatedRoles($labels = NULL)
 {
     $this->db->select('project_people.role, COUNT(*) AS hits', false)->from('project_people')->join('project', "project_people.project = project.id AND project.company = {$this->company->id}", 'inner')->where('project_people.role IS NOT NULL', NULL, FALSE)->group_by('project_people.role')->order_by('hits', 'desc');
     if ($labels) {
         $this->db->join('project_label', "project_label.project = project_people.project AND project_label.label_name{$this->db->escape_array($labels)}", 'inner');
     }
     $result = $this->db->get()->result_array();
     return array_sub($result, 'role');
 }
示例#21
0
 /**
  * 接受一个label name,返回与其相关的label的id和name构成的数组
  * @param type $label
  * @param type $relation
  */
 function getRelatives($label, $relation = NULL)
 {
     $this->db->select('relative.id,relative.name')->from('label_relationship')->join('label', 'label.id=label_relationship.label', 'inner')->join('label relative', 'relative.id=label_relationship.relative', 'inner')->or_where(array('label.name' => $label, 'label.id' => $label));
     return array_sub($this->db->get()->result_array(), 'name', 'id');
 }
示例#22
0
 /**
  * 获得系统中所有客户的email
  */
 function getAllEmails()
 {
     $query = "\n\t\t\tSELECT content \n\t\t\tFROM people_profile \n\t\t\t\tINNER JOIN people ON people.id=people_profile.people\n\t\t\tWHERE\n\t\t\t\tpeople.type='client' \n\t\t\t\tAND people_profile.name='电子邮件'\n\t\t";
     $result = $this->db->query($query);
     return array_sub($result->result_array(), 'content');
 }
示例#23
0
function buildVSMigratePlan($new_vs_id, $vs_id_list)
{
    $ret = array('properties' => array('vsconfig' => '', 'rsconfig' => ''), 'ports' => array(), 'vips' => array(), 'triplets' => array(), 'messages' => array());
    $config_stat = array('vsconfig' => array(), 'rsconfig' => array());
    $gt = array();
    // grouped triplets
    foreach ($vs_id_list as $vs_id) {
        $vsinfo = spotEntity('ipv4vs', $vs_id);
        // create nesessary vips and ports
        if ($vsinfo['proto'] != 'MARK') {
            $vip_key = $vsinfo['vip_bin'];
            $port_key = $vsinfo['proto'] . '-' . $vsinfo['vport'];
            $ret['vips'][$vip_key] = array('vip' => $vsinfo['vip_bin'], 'vsconfig' => '', 'rsconfig' => '');
            $ret['ports'][$port_key] = array('proto' => $vsinfo['proto'], 'vport' => $vsinfo['vport'], 'vsconfig' => '', 'rsconfig' => '');
        } else {
            $vip_key = '';
            $mark = implode('', unpack('N', $vsinfo['vip_bin']));
            $port_key = $vsinfo['proto'] . '-' . $mark;
            $ret['ports'][$port_key] = array('proto' => $vsinfo['proto'], 'vport' => $mark, 'vsconfig' => '', 'rsconfig' => '');
        }
        // fill triplets
        foreach (SLBTriplet::getTriplets($vsinfo) as $triplet) {
            $tr_key = $triplet->lb['id'] . '-' . $triplet->rs['id'];
            if (!isset($ret['triplets'][$tr_key])) {
                $ret['triplets'][$tr_key] = array('object_id' => $triplet->lb['id'], 'rspool_id' => $triplet->rs['id'], 'vs_id' => $new_vs_id, 'vips' => array(), 'ports' => array());
            }
            $configs = array('vsconfig' => tokenizeConfig($triplet->vs['vsconfig'] . "\n" . $triplet->slb['vsconfig']), 'rsconfig' => tokenizeConfig($triplet->vs['rsconfig'] . "\n" . $triplet->slb['rsconfig']));
            if ($vsinfo['proto'] != 'MARK') {
                if (!isset($ret['triplets'][$tr_key]['ports'][$port_key])) {
                    $ret['triplets'][$tr_key]['ports'][$port_key] = array('proto' => $vsinfo['proto'], 'vport' => $vsinfo['vport'], 'vsconfig' => '', 'rsconfig' => '');
                }
                if (!isset($ret['triplets'][$tr_key]['vips'][$vip_key])) {
                    $ret['triplets'][$tr_key]['vips'][$vip_key] = array('vip' => $vsinfo['vip_bin'], 'prio' => NULL, 'vsconfig' => '', 'rsconfig' => '');
                }
                if ('' != $triplet->slb['prio']) {
                    $ret['triplets'][$tr_key]['vips'][$vip_key]['prio'] = $triplet->slb['prio'];
                }
            } else {
                $ret['triplets'][$tr_key]['ports'][$port_key] = array('proto' => $vsinfo['proto'], 'vport' => $mark, 'vsconfig' => '', 'rsconfig' => '');
            }
            $old_tr_key = $tr_key . '-' . $vip_key . '-' . $port_key;
            $gt['all'][$old_tr_key] = $triplet;
            $gt['ports'][$port_key][$old_tr_key] = $triplet;
            $gt['vips'][$vip_key][$old_tr_key] = $triplet;
            $gt['vip_links'][$tr_key][$vip_key][$old_tr_key] = $triplet;
            $gt['port_links'][$tr_key][$port_key][$old_tr_key] = $triplet;
            foreach ($configs as $conf_type => $list) {
                foreach ($list as $line) {
                    $config_stat[$conf_type][$line][$old_tr_key] = $triplet;
                }
            }
        }
    }
    // reduce common config lines and move them from $config_stat into $ret
    foreach ($config_stat as $conf_type => $stat) {
        foreach ($stat as $line => $used_in_triplets) {
            $added_to_triplets = array();
            $wrong_triplets = array();
            if (!array_sub($gt['all'], $used_in_triplets)) {
                // line used in all triplets
                concatConfig($ret['properties'][$conf_type], $line);
                continue;
            }
            foreach ($gt['ports'] as $port_key => $port_triplets) {
                $diff = array_sub($port_triplets, $used_in_triplets);
                if (count($diff) < count($port_triplets) / 2) {
                    // line used in most triplets of this port
                    $added_to_triplets += $port_triplets;
                    $wrong_triplets += $diff;
                    concatConfig($ret['ports'][$port_key][$conf_type], $line);
                }
            }
            foreach ($gt['vips'] as $vip_key => $vip_triplets) {
                if (!array_sub($vip_triplets, $used_in_triplets)) {
                    if (count($vip_triplets) == count(array_sub($vip_triplets, $added_to_triplets))) {
                        // if none of the $vip_triplets are in $added_to_triplets,
                        // line used in all triplets of this vip
                        $added_to_triplets += $vip_triplets;
                        concatConfig($ret['vips'][$vip_key][$conf_type], $line);
                    }
                }
            }
            foreach ($used_in_triplets as $old_tr_key => $triplet) {
                if (isset($added_to_triplets[$old_tr_key])) {
                    continue;
                }
                $tr_key = $triplet->lb['id'] . '-' . $triplet->rs['id'];
                if ($triplet->vs['proto'] != 'MARK') {
                    $vip_key = $triplet->vs['vip_bin'];
                    $port_key = $triplet->vs['proto'] . '-' . $triplet->vs['vport'];
                } else {
                    $vip_key = '';
                    $port_key = $triplet->vs['proto'] . '-' . implode('', unpack('N', $triplet->vs['vip_bin']));
                }
                // if all the triplets for a given port contain line, add it to the ports' config
                if (!array_sub($gt['port_links'][$tr_key][$port_key], $used_in_triplets)) {
                    if (count($gt['port_links'][$tr_key][$port_key]) == count(array_sub($gt['port_links'][$tr_key][$port_key], $added_to_triplets))) {
                        $added_to_triplets += $gt['port_links'][$tr_key][$port_key];
                        concatConfig($ret['triplets'][$tr_key]['ports'][$port_key][$conf_type], $line);
                    }
                }
                // if all the triplets for a given vip contain line, add it to the vips' config
                if ($vip_key != '') {
                    if (!array_sub($gt['vip_links'][$tr_key][$vip_key], $used_in_triplets)) {
                        if (count($gt['vip_links'][$tr_key][$vip_key]) == count(array_sub($gt['vip_links'][$tr_key][$vip_key], $added_to_triplets))) {
                            $added_to_triplets += $gt['vip_links'][$tr_key][$vip_key];
                            concatConfig($ret['triplets'][$tr_key]['vips'][$vip_key][$conf_type], $line);
                        }
                    }
                }
            }
            // check for failed-to-insert lines
            foreach (array_sub($used_in_triplets, $added_to_triplets) as $old_tr_key => $unused_triplet) {
                $ret['messages'][$old_tr_key][] = "Failed to add {$conf_type} line '{$line}'";
            }
            foreach ($wrong_triplets as $old_tr_key => $triplet) {
                $ret['messages'][$old_tr_key][] = "Added {$conf_type} line '{$line}'";
            }
        }
    }
    // for $line
    return $ret;
}
示例#24
0
 function viewscore($student)
 {
     $this->output->title = '成绩 - ' . $this->student->fetch($student, 'name');
     $exams_scores = $this->student->getscores($student, array('limit' => 'pagination', 'orderby' => 'exam asc'));
     $category = array_sub($exams_scores, 'exam_name');
     $courses = $this->label->getList(array('type' => 'course'));
     $series = array();
     foreach ($courses as $course) {
         $scores = array_sub($exams_scores, $course['name']);
         $has_score = false;
         foreach ($scores as $score) {
             if (!is_null($score)) {
                 $has_score = true;
                 break;
             }
         }
         if ($has_score) {
             $series[] = array('name' => $course['name'], 'color' => '#' . $course['color'], 'data' => array_sub($exams_scores, 'rank_' . $course['name'], false, true));
         }
     }
     $this->load->addViewData('series', json_encode($series, JSON_NUMERIC_CHECK));
     $this->load->addViewData('category', json_encode($category));
     $scores = $this->table->setFields($this->score_list_args)->setData($this->student->getscores($student, array('limit' => 'pagination', 'orderby' => 'exam desc')))->trimColumns()->generate();
     $this->load->addViewData('scores', $scores);
     $this->load->view('student/viewscore');
 }