Ejemplo n.º 1
0
 public function detail($templateId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('distribution_system_manage');
     $templateDao = MyMonth_contract_template::instance();
     $dtlTemplateDao = MyMonth_contract_detail_template::instance();
     $template = $templateDao->get_by_id($templateId);
     if ($template == null) {
         remind::set(Kohana::lang('o_contract.contract_not_exists'), 'distribution/month_contract_template/', 'error');
     }
     $detailSearchStruct = array();
     $detailSearchStruct['where'] = array('contract_id' => $templateId);
     $dtlTemplateList = $dtlTemplateDao->lists($detailSearchStruct);
     $this->template->content = new View("distribution/month_contract_template_detail");
     $this->template->content->template = $template;
     $this->template->content->dataList = $dtlTemplateList;
 }
Ejemplo n.º 2
0
 public function template_use($userId, $templateId)
 {
     $agentDao = Myagent::instance();
     $agent = $agentDao->get_by_user_id($userId);
     if ($agent == null) {
         remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error');
     }
     $mtTemplateDao = MyMonth_contract_template::instance();
     $template = $mtTemplateDao->get_by_id($templateId);
     if ($template == null) {
         remind::set(Kohana::lang('o_contract.contract_not_exists'), request::referrer(), 'error');
     }
     $mtDtlTemplateDao = MyMonth_contract_detail_template::instance();
     $searchStruct = array();
     $searchStruct['where'] = array('contract_id' => $templateId);
     $dtlTemplateList = $mtDtlTemplateDao->lists($searchStruct);
     //		tool::filter_strip_tags($data);
     $mtContractDao = MyMonth_contract::instance();
     $mtContractDtlDao = MyMonth_contract_detail::instance();
     $contract = array();
     $contract['contract_type'] = 0;
     //普通代理返利
     $contract['relation_id'] = 0;
     $contract['agent_id'] = 0;
     $contract['user_id'] = $agent['user_id'];
     $contract['flag'] = 0;
     $contract['type'] = $template['type'];
     $contract['taxrate'] = 0;
     $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['note'] = null;
     if ($contractId = $mtContractDao->add($contract)) {
         foreach ($dtlTemplateList as $aDtlTemplate) {
             $contractDtl = array();
             $contractDtl['contract_id'] = $contractId;
             $contractDtl['grade'] = $aDtlTemplate['grade'];
             $contractDtl['minimum'] = $aDtlTemplate['minimum'];
             $contractDtl['maximum'] = $aDtlTemplate['maximum'];
             $contractDtl['rate'] = $aDtlTemplate['rate'];
             $contractDtl['createtime'] = date("Y-m-d H:i:s", time());
             $mtContractDtlDao->add($contractDtl);
         }
         remind::set(Kohana::lang('o_global.add_success'), 'distribution/month_contract/index/' . $userId, 'success');
     } else {
         remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
     }
 }