Ejemplo n.º 1
0
 function submit($submit, $id, $button_id = NULL)
 {
     parent::submit($submit, $id, $button_id);
     try {
         if ($submit == 'indicator') {
             $indicator = $this->input->sessionPost('indicator');
             $evaluation_indicator = $this->input->sessionPost('evaluation_indicator');
             $this->evaluation->addIndicator($this->evaluation->id, $indicator, $evaluation_indicator);
             $this->output->setData($this->indicatorList(), 'indicator-list', 'content-table', '.item[name="indicator"]>.contentTable', 'replace');
             unsetPost('indicator');
             unsetPost('evaluation_indicator');
         } elseif ($submit == 'apply_model') {
             if (!$this->input->post('indicator_model')) {
                 $this->output->message('请选择模版', 'warning');
                 throw new Exception();
             }
             $this->evaluation->applyModel($this->evaluation->id, $this->input->post('indicator_model'));
             $this->output->message('评价模版已应用');
             $this->output->setData($this->indicatorList(), 'indicator-list', 'content-table', '.item[name="indicator"]>.contentTable', 'replace');
             $this->output->setData($this->peopleList(), 'people-list', 'content-table', '.item[name="people"]>.contentTable', 'replace');
         }
     } catch (Exception $e) {
         $e->getMessage() && $this->output->message($e->getMessage(), 'warning');
         $this->output->status = 'fail';
     }
 }
Ejemplo n.º 2
0
 function submit($submit, $id, $button_id = NULL)
 {
     $this->project->id = $id;
     $this->project->data = array_merge($this->project->fetch($id), $this->input->sessionPost('project'));
     $this->project->labels = array_merge($this->project->getLabels($this->project->id), $this->input->sessionPost('labels'));
     $this->project->profiles = $this->input->sessionPost('profiles');
     $this->load->library('form_validation');
     try {
         if (isset($this->form_validation_rules[$submit])) {
             $this->form_validation->set_rules($this->form_validation_rules[$submit]);
             if ($this->form_validation->run() === false) {
                 $this->output->message(validation_errors(), 'warning');
                 throw new Exception();
             }
         }
         if ($submit == 'cancel') {
             unsetPost();
             $this->output->status = 'close';
         } elseif ($submit == 'project') {
             if (!$this->project->data['display']) {
                 $this->project->data['display'] = true;
                 $this->output->data = CONTROLLER . '/' . $this->project->id;
                 $this->output->status = 'redirect';
             }
             $this->project->update($this->project->id, $this->project->data);
             $this->project->updateLabels($this->project->id, $this->input->sessionPost('labels'));
             $this->project->updateProfiles($this->project->id, $this->input->sessionPost('profiles'));
             unsetPost();
             $this->output->message($this->output->title . ' 已保存');
         } elseif ($submit == 'people') {
             $people = $this->input->sessionPost('people');
             if ($this->project->addPeople($this->project->id, $people['id'], NULL, $people['role'])) {
                 $this->message->send('将你加入<a href="#' . $this->project->data['type'] . '/' . $this->project->data['id'] . '">事务:' . $this->project->data['name'] . '</a>', $people['id']);
                 $this->output->setData($this->peopleList(), 'people-list', 'content-table', '.item[name="people"]>.contentTable', 'replace');
             } else {
                 $this->output->message('人员添加错误', 'warning');
             }
             unsetPost('people');
         } elseif ($submit == 'remove_people') {
             if ($this->project->removePeople($this->project->id, $button_id)) {
                 $this->output->setData($this->peopleList(), 'people-list', 'content-table', '.item[name="people"]>.contentTable', 'replace');
             }
         } elseif ($submit == 'account') {
             $this->load->model('account_model', 'account');
             $account = $this->input->sessionPost('account');
             if (!is_numeric($account['amount'])) {
                 $this->output->message('请预估收费金额(数值)', 'warning');
             }
             if (!$account['comment']) {
                 $this->output->message('请填写付款条件', 'warning');
             }
             if (!$account['date']) {
                 $this->output->message('请预估收费时间', 'warning');
             }
             if (count($this->output->message['warning']) > 0) {
                 throw new Exception();
             }
             if ($this->cases->data['type'] === 'query') {
                 $subject = '咨询费';
             } elseif (in_array('法律顾问', $this->project->labels)) {
                 $subject = '顾问费';
             } else {
                 $subject = '律师费';
             }
             $this->account->add($account + array('project' => $this->project->id, 'subject' => $subject, 'display' => true));
             $this->output->setData($this->accountList(), 'account-list', 'content-table', '.item[name="account"]>.contentTable', 'replace');
             unsetPost('account');
         } elseif ($submit == 'remove_fee' || $submit == 'remove_miscfee') {
             $this->project->removeFee($this->project->id, $button_id);
             if ($submit == 'remove_fee') {
                 $this->output->setData($this->accountList(), 'account-list', 'content-table', '.item[name="account"]>.contentTable', 'replace');
             } else {
                 $this->output->setData($this->miscfeeList(), 'miscfee-list', 'content-table', '.item[name="miscfee"]>.contentTable', 'replace');
             }
         } elseif ($submit == 'document') {
             $this->load->model('document_model', 'document');
             $document = $this->input->sessionPost('document');
             $document_labels = $this->input->sessionPost('document_labels');
             if (!$document_labels) {
                 $document_labels = array();
             }
             if (!$document['id']) {
                 $this->output->message('请选择要上传的文件', 'warning');
                 throw new Exception();
             }
             $this->document->update($document['id'], $document);
             $this->document->addLabels($document['id'], $document_labels);
             $this->document->addmod(1, $this->people->getArray(array('in_project' => $this->project->id), 'id'), $document['id']);
             $this->project->addDocument($this->project->id, $document['id']);
             $this->output->setData($this->documentList(), 'document-list', 'content-table', '.item[name="document"]>.contentTable', 'replace');
             unsetPost('document');
         } elseif ($submit == 'remove_document') {
             if ($this->project->removeDocument($this->project->id, $button_id)) {
                 $this->output->setData($this->documentList(), 'document-list', 'content-table', '.item[name="document"]>.contentTable', 'replace');
             }
         }
         if (is_null($this->output->status)) {
             $this->output->status = 'success';
         }
     } catch (Exception $e) {
         $e->getMessage() && $this->output->message($e->getMessage(), 'warning');
         $this->output->status = 'fail';
     }
 }
Ejemplo n.º 3
0
 /**
  * 提交处理
  */
 function submit($submit, $id, $button_id = NULL)
 {
     $this->people->id = $id;
     $this->people->data = array_merge($this->people->fetch($id), $this->input->sessionPost('people'));
     $this->load->library('form_validation');
     try {
         if (isset($this->form_validation_rules[$submit])) {
             $this->form_validation->set_rules($this->form_validation_rules[$submit]);
             if ($this->form_validation->run() === false) {
                 $this->output->message(validation_errors(), 'warning');
                 throw new Exception();
             }
         }
         if ($submit == 'cancel') {
             unsetPost();
             $this->output->status = 'close';
         } elseif ($submit == 'people') {
             $this->people->labels = $this->input->sessionPost('labels');
             $this->people->profiles = $this->input->sessionPost('profiles');
             if (!$this->people->data['display']) {
                 $this->people->data['display'] = true;
                 $this->output->data = CONTROLLER . '/' . $this->people->id;
                 $this->output->status = 'redirect';
             }
             if ($this->people->data['character'] != '单位' && !$this->people->data['gender']) {
                 //个人,则性别必填
                 $this->output->message('选择性别', 'warning');
                 throw new Exception();
             }
             if ($this->people->data['birthday'] === '') {
                 $this->people->data['birthday'] = NULL;
             }
             $this->people->update($this->people->id, $this->people->data);
             $this->people->updateProfiles($this->people->id, $this->people->profiles);
             unsetPost();
             $this->output->message($this->output->title . ' 已保存');
         } elseif ($submit == 'relative') {
             $relative = $this->input->sessionPost('relative');
             if (!$relative['id']) {
                 $this->people->profiles = $this->input->sessionPost('relative_profiles');
                 if (count($this->people->profiles) == 0) {
                     $this->output->message('请至少输入一种联系方式', 'warning');
                     throw new Exception();
                 }
                 if (!$this->people->profiles['电话'] && !$this->people->profiles['电子邮件']) {
                     $this->output->message('至少输入一种联系方式', 'warning');
                     throw new Exception();
                 }
                 foreach ($this->people->profiles as $name => $content) {
                     if ($name == '电话') {
                         if ($this->people->isMobileNumber($content)) {
                             $relative['profiles']['手机'] = $content;
                         } else {
                             $relative['profiles']['电话'] = $content;
                         }
                         $relative['phone'] = $content;
                     } elseif ($name == '电子邮件' && $content) {
                         if (!$this->form_validation->valid_email($content)) {
                             $this->output->message('请填写正确的Email地址', 'warning');
                             throw new Exception();
                         }
                         $relative['email'] = $content;
                     } else {
                         $relative['profiles'][$name] = $content;
                     }
                 }
                 $relative += array('type' => 'client', 'abbreviation' => $relative['name'], 'character' => isset($relative['character']) && $relative['character'] == '单位' ? '单位' : '个人', 'profiles' => $this->people->profiles, 'labels' => array('类型' => '潜在客户'));
                 $relative['display'] = true;
                 $relative['id'] = $this->people->add($relative);
                 $this->output->message('新客户 <a href="#' . CONTROLLER . '/' . $relative['id'] . '">' . $relative['name'] . ' </a>已经添加');
             }
             $this->people->addRelationship($this->people->id, $relative['id'], empty($relative['relation']) ? NULL : $relative['relation']);
             $this->output->setData($this->relativeList(), 'relative-list', 'content-table', '.item[name="relative"]>.contentTable', 'replace');
             unsetPost('relative');
         } elseif ($submit == 'remove_relative') {
             $this->people->removeRelationship($this->people->id, $button_id);
             $this->output->setData($this->relativeList(), 'relative-list', 'content-table', '.item[name="relative"]>.contentTable', 'replace');
         } elseif ($submit == 'profile') {
             $profile = $this->input->sessionPost('profile');
             if (!$profile['name']) {
                 $this->output->message('请选择资料项名称', 'warning');
                 throw new Exception();
             }
             $this->people->addProfile($this->people->id, $profile['name'], $profile['content'], $profile['comment']);
             $this->output->setData($this->profileList(), 'profile-list', 'content-table', '.item[name="profile"]>.contentTable', 'replace');
             unsetPost('profile');
         } elseif ($submit == 'remove_profile') {
             $this->people->removeProfile($this->people->id, $button_id);
             $this->output->setData($this->profileList(), 'profile-list', 'content-table', '.item[name="profile"]>.contentTable', 'replace');
         } elseif ($submit == 'status') {
             $status = $this->input->sessionPost('status');
             if (!$status['name']) {
                 $this->output->message('请填写状态标题', 'warning');
                 throw new Exception();
             }
             $this->people->addStatus($this->people->id, $status['name'], $status['date'], $status['content'], $status['team'], $status['comment']);
             $this->output->setData($this->statusList(), 'status-list', 'content-table', '.item[name="status"]>.contentTable', 'replace');
             unsetPost('status');
         } elseif ($submit == 'remove_status') {
             $this->people->removestatus($this->people->id, $button_id);
             $this->output->setData($this->statusList(), 'status-list', 'content-table', '.item[name="status"]>.contentTable', 'replace');
         } elseif ($submit == 'changetype') {
             $this->people->update($this->people->id, array('type' => $this->input->post('type')));
         }
         if (is_null($this->output->status)) {
             $this->output->status = 'success';
         }
     } catch (Exception $e) {
         $this->output->status = 'fail';
     }
 }
Ejemplo n.º 4
0
 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';
     }
 }
Ejemplo n.º 5
0
 function submit($submit, $id)
 {
     $this->account->id = $id;
     $this->account->data = array_merge($this->account->fetch($id), $this->input->sessionPost('account'));
     try {
         if ($submit == 'cancel') {
             unsetPost();
             $this->output->status = 'close';
         }
         if ($submit == 'account') {
             if ($this->account->data['way'] == 'out') {
                 $this->account->data['amount'] = -abs($this->account->data['amount']);
             }
             //根据way设置amount的正负号
             if (!$this->account->data['name'] && $this->account->data['project']) {
                 $this->load->model('project_model', 'project');
                 $this->account->data['name'] = $this->project->fetch($this->account->data['project'], 'name') . ' ' . $this->account->data['subject'];
             }
             if (!$this->account->data['display']) {
                 $this->account->data['display'] = true;
                 $this->output->status = 'redirect';
                 $this->output->data = 'account/' . $this->account->id;
             }
             $this->account->update($this->account->id, $this->account->data);
             unsetPost();
             $this->output->message($this->output->title . ' 已保存');
         }
         if (is_null($this->output->status)) {
             $this->output->status = 'success';
         }
     } catch (Exception $e) {
         $this->output->status = 'fail';
     }
 }
Ejemplo n.º 6
0
 function submit($submit, $id = NULL)
 {
     if (isset($id)) {
         $this->document->id = $id;
         $this->document->data = array_merge($this->document->fetch($id), $this->input->sessionPost('document'));
         $this->document->labels = array_merge($this->document->getLabels($this->document->id), $this->input->sessionPost('labels'));
     }
     $this->load->library('form_validation');
     try {
         if ($submit == 'upload') {
             $config = array('upload_path' => UPLOADPATH, 'allowed_types' => '*', 'encrypt_name' => true);
             $this->load->library('upload', $config);
             if (!$this->upload->do_upload('document')) {
                 $this->output->message($this->upload->display_errors(), 'warning');
                 throw new Exception();
             }
             $file_info = $this->upload->data();
             $file_info['mail_name'] = substr($file_info['client_name'], 0, -strlen($file_info['file_ext']));
             $document_id = $this->document->add(array('name' => $file_info['mail_name'], 'filename' => $file_info['client_name'], 'extname' => $file_info['file_ext'], 'size' => $file_info['file_size'], 'display' => true));
             $labels = $this->config->user_item('search/labels', 'index');
             if ($labels) {
                 $this->document->addLabels($document_id, $labels);
             }
             rename(UPLOADPATH . $file_info['file_name'], UPLOADPATH . $document_id);
             $data = array('id' => $document_id, 'name' => $file_info['mail_name']);
             $this->output->data = $data;
         } elseif ($submit == 'document') {
             $this->document->update($this->document->id, $this->document->data);
             unsetPost();
             $this->output->message($this->output->title . ' 已保存');
         } elseif ($submit == 'delete') {
             if ($this->document->delete($id)) {
                 $this->output->status = 'close';
             } else {
                 throw new Exception('无法删除此文档,可能已与其他数据关联');
             }
         }
     } catch (Exception $e) {
         if ($e->getMessage()) {
             $this->output->message($e->getMessage(), 'warning');
         }
         $this->output->status = 'fail';
     }
     $this->output->as_ajax = true;
 }