예제 #1
0
 public function template_use($userId, $templateId)
 {
     $agentDao = Superplaner::instance();
     $agent = $agentDao->get_by_user_id($userId);
     if ($agent == null) {
         remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error');
     }
     $rtTemplateDao = Superplaner_Realtime_contract_template::instance();
     $template = $rtTemplateDao->get_by_id($templateId);
     if ($template == null) {
         remind::set(Kohana::lang('o_contract.contract_not_exists'), request::referrer(), 'error');
     }
     $contract = array();
     $contract['user_id'] = $agent['user_id'];
     $contract['type'] = $template['type'];
     $contract['rate'] = $template['rate'];
     $contract['taxrate'] = $template['taxrate'];
     $contract['createtime'] = date("Y-m-d H:i:s", time());
     $contract['starttime'] = date("Y-m-d H:i:s", time());
     $contract['lastsettletime'] = date("Y-m-d H:i:s", time());
     $contract['flag'] = 0;
     //新建的都是关闭状态
     $contract['note'] = null;
     $rtContractDao = Superplaner_Realtime_contract::instance();
     if ($rtContractDao->add($contract)) {
         remind::set(Kohana::lang('o_global.add_success'), 'superplaner/realtime_contract/index/' . $userId, 'success');
     } else {
         remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
     }
 }
예제 #2
0
 public function close($agentId)
 {
     //权限验证
     role::check('superplaner_system_manage');
     if (!$agentId) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     $agentDao = Superplaner::instance();
     $aAgent = $agentDao->get_by_id($agentId);
     if ($aAgent == null) {
         remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error');
     }
     $aAgent['flag'] = 0;
     if ($agentDao->edit($aAgent)) {
         remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
     } else {
         remind::set(Kohana::lang('o_global.update_fail'), request::referrer(), 'error');
     }
 }