Exemplo n.º 1
0
 /**
  * 模块编辑
  */
 public function edit($id)
 {
     $mail_category = Mymail_category::instance($id)->get();
     if (!$mail_category['id']) {
         remind::set(Kohana::lang('o_manage.category_not_exist'), 'manage/mail_category');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $flag = $this->input->post('flag');
         $data = Mymail_category::instance()->get_by_flag($flag);
         if ($flag != $mail_category['flag']) {
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.category_mark_exist'), 'manage/mail_category/add');
             }
         }
         if (Mymail_category::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/mail_category', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/mail_category');
         }
     }
     $this->template->content = new View("manage/mail_category_edit");
     $this->template->content->data = $mail_category;
 }
Exemplo n.º 2
0
 public function add()
 {
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST, array('content'));
         $site_next_flow = site::site_next_flow($this->current_flow);
         $submit_target = intval($this->input->post('submit_target'));
         $faq = Myfaq::instance();
         if ($faq->add($_POST)) {
             //判断添加成功去向
             switch ($submit_target) {
                 case 1:
                     remind::set(Kohana::lang('o_global.add_success'), 'site/faq/add', 'success');
                 case 2:
                     remind::set(Kohana::lang('o_global.add_success'), $site_next_flow['url'], 'success');
                 default:
                     remind::set(Kohana::lang('o_global.add_success'), 'site/faq', 'success');
             }
         } else {
             remind::set(Kohana::lang('o_global.add_error'), 'site/faq/add');
         }
     }
     $this->template->content = new View("site/faq_add");
     $this->template->content->title = "site faq add";
 }
Exemplo n.º 3
0
 /**
  * 模块编辑
  */
 public function edit($id)
 {
     $mail_template = Mymail_template::instance($id)->get();
     if (!$mail_template['id']) {
         remind::set(Kohana::lang('o_manage.template_not_exist'), 'manage/mail_template');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         if (Mymail_template::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/mail_template', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/mail_template');
         }
     }
     $mail_categories = Mymail_category::instance()->mail_categories();
     foreach ($mail_categories as $key => $value) {
         if ($value['id'] == $mail_template['mail_category_id']) {
             $mail_categories[$key]['selected'] = 'selected';
         } else {
             $mail_categories[$key]['selected'] = '';
         }
     }
     $this->template->content = new View("manage/mail_template_edit");
     $this->template->content->data = $mail_template;
     $this->template->content->mail_categories = $mail_categories;
 }
Exemplo n.º 4
0
 public function add()
 {
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST, array('content'));
         $news = Mynews::instance();
         //  print_r($news->add($_POST));die;
         if (empty($_POST['title']) || empty($_POST['content']) || empty($_POST['classid']) || empty($_POST['key'])) {
             remind::set(Kohana::lang('o_global.add_error'), 'site/news/add');
         } else {
             if ($news->add($_POST)) {
                 remind::set(Kohana::lang('o_global.add_success'), 'site/news', 'success');
             } else {
                 remind::set(Kohana::lang('o_global.add_error'), 'site/news/add');
             }
         }
         $data = $news->get();
     }
     $news_categories = Mynews_category::instance()->news_categories(0);
     //print_r($news_categories);die;
     $news = Mynews::instance();
     $data = $news->get();
     $this->template->content = new View("site/news_add");
     $this->template->content->news_categories = $news_categories;
 }
Exemplo n.º 5
0
 public function edit($cardTypeId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     if ($cardTypeId == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $cardType = $this->cardTypeDao->get_by_id($cardTypeId);
     if ($cardType == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     if ($_POST) {
         $data = $_POST;
         $data['id'] = $cardType['id'];
         $data['name'] = $_POST['name'];
         //标签过滤
         tool::filter_strip_tags($data);
         if ($this->cardTypeDao->edit($data)) {
             remind::set(Kohana::lang('o_global.update_success'), 'card/card_type', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("card/card_type_edit");
     $this->template->content->cardType = $cardType;
 }
Exemplo n.º 6
0
 /**
  * edit 
  */
 public function edit($id)
 {
     $action = Myaction::instance($id)->get();
     if (!$action['id']) {
         remind::set(Kohana::lang('o_manage.resources_not_exist'), 'manage/action');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $name = $this->input->post('name');
         $resource = $this->input->post('resource');
         $parent_id = $this->input->post('parent_id');
         if ($name != $action['name']) {
             $data = Myaction::instance()->get_by_name($name);
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.resources_name_exist'), 'manage/action/add');
             }
         }
         if ($resource != $action['resource']) {
             $data = Myaction::instance()->get_by_resource($resource);
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.resources_mark_exist'), 'manage/action/add');
             }
         }
         //zhu add 上级资源不能选择自身,子项
         if ($parent_id > 0) {
             if ($action['id'] == $parent_id) {
                 remind::set(Kohana::lang('o_manage.parent_action_is_self'), 'manage/action/edit/' . $id);
             }
             $sub_ac = Myaction::instance()->actions($id);
             if (is_array($sub_ac) && count($sub_ac)) {
                 foreach ($sub_ac as $ac) {
                     if ($ac['id'] == $parent_id) {
                         remind::set(Kohana::lang('o_manage.parent_action_is_child'), 'manage/action/edit/' . $id);
                     }
                 }
             }
         }
         //zhu add end
         if (Myaction::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/action', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/action/edit/' . $id);
         }
     }
     $actions = Myaction::instance()->actions();
     foreach ($actions as $key => $value) {
         $actions[$key]['selected'] = '';
         if ($actions['id'] = $action['parent_id']) {
             $actions[$key]['selected'] = 'selected';
         }
     }
     $this->template->content = new View("manage/action_edit");
     $this->template->content->actions = $actions;
     $this->template->content->data = $action;
 }
Exemplo n.º 7
0
 /**
  * edit menu
  */
 public function edit($id)
 {
     $menu = Mymenu::instance($id)->get();
     if (!$menu['id']) {
         remind::set(Kohana::lang('o_global.bad_request'), 'manage/menu');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $target = $this->input->post('target');
         $parent_id = $this->input->post('parent_id');
         if ($menu['target'] != $target) {
             $data = Mymenu::instance($id)->get_by_target($target);
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.mark_has_exist'), 'manage/menu/edit/' . $id);
             }
         }
         /* 最多只能添加三级菜单 */
         if ($parent_id > 0) {
             $parent_menu = Mymenu::instance($parent_id)->get();
             if ($parent_menu['level_depth'] >= 3) {
                 remind::set(Kohana::lang('o_manage.menu_can_not_add_level'), 'manage/menu/add');
             }
         }
         /* 添加 */
         if (Mymenu::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/menu', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/menu/edit/' . $id);
         }
     }
     $menus = Mymenu::instance()->menus();
     foreach ($menus as $key => $value) {
         if ($value['id'] == $menu['parent_id']) {
             $menus[$key]['selected'] = 'selected';
         } else {
             $menus[$key]['selected'] = '';
         }
     }
     $actions = Myaction::instance()->actions();
     foreach ($actions as $key => $value) {
         if ($value['id'] == $menu['action_id']) {
             $actions[$key]['selected'] = 'selected';
         } else {
             $actions[$key]['selected'] = '';
         }
     }
     $this->template->content = new View("manage/menu_edit");
     $this->template->content->data = $menu;
     $this->template->content->menus = $menus;
     $this->template->content->actions = $actions;
 }
Exemplo n.º 8
0
 public function add()
 {
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $link = Mysite_link::instance();
         if ($link->add($_POST)) {
             remind::set(Kohana::lang('o_global.add_success'), 'site/link', 'success');
         } else {
             remind::set(Kohana::lang('o_global.add_error'), 'site/link/add/');
         }
     }
     $this->template->content = new View("site/link_edit");
 }
Exemplo n.º 9
0
 /**
  * 添加新支付类型
  */
 function add()
 {
     //权限验证
     role::check('manage_payment_type');
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $payment_type = Mypayment_type::instance();
         if ($payment_type->add($_POST)) {
             remind::set(Kohana::lang('o_global.add_success'), 'manage/payment_type', 'success');
         } else {
             $errors = $payment_type->errors();
             remind::set(Kohana::lang('o_global.add_error'), 'manage/payment_type/add', 'error');
         }
     }
     $this->template->content = new View("manage/payment_type_add");
 }
Exemplo n.º 10
0
 public function edit($salesChannelId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     if ($salesChannelId == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $salesChannel = $this->salesChannelDao->get_by_id($salesChannelId);
     if ($salesChannel == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     if ($_POST) {
         $data = $_POST;
         $data['id'] = $salesChannel['id'];
         $data['updtime'] = date("Y-m-d H:i:s", time());
         $data['des'] = $_POST['des'];
         $data['flag'] = $_POST['flag'];
         //标签过滤
         tool::filter_strip_tags($data);
         if ($this->salesChannelDao->edit($data)) {
             $aLog = array();
             $aLog['userid'] = $this->manager['id'];
             $aLog['apdtime'] = date('Y-m-d H:i:s', time());
             $aLog['target'] = Ac_cardlog_Model::TARGET_SALE_CHANNEL;
             $aLog['targetid'] = $salesChannelId;
             $aLog['action'] = Ac_cardlog_Model::ACTION_CHANGE;
             $updateString = '';
             foreach ($_POST as $key => $value) {
                 $updateString = $updateString . $key . '=' . $value . ',';
             }
             $aLog['detail'] = 'update saleChannel. ' . $updateString;
             $this->cardLogDao->add($aLog);
             remind::set(Kohana::lang('o_global.update_success'), 'card/sales_channel', 'success');
             return;
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
             return;
         }
     }
     $this->template->content = new View("card/sales_channel_edit");
     $this->template->content->salesChannel = $salesChannel;
 }
Exemplo n.º 11
0
 /**
  * 添加新币种
  */
 function add()
 {
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $data = $_POST;
         $currency = Mycurrency::instance();
         if ($currency->exist($data)) {
             remind::set(Kohana::lang('o_site.current_has_exist'), null, 'error');
         } else {
             unset($data['id']);
             $data['active'] = 1;
             if ($id = $currency->add($data)) {
                 //更新默认币种显示
                 Mycurrency::instance($id)->update_currencies_default();
                 $site_next_flow = site::site_next_flow($this->current_flow);
                 $submit_target = intval($this->input->post('submit_target'));
                 //判断添加成功去向
                 switch ($submit_target) {
                     case 1:
                         remind::set(Kohana::lang('o_global.add_success'), 'site/currency/add', 'success');
                     case 2:
                         remind::set(Kohana::lang('o_global.add_success'), $site_next_flow['url'], 'success');
                     default:
                         remind::set(Kohana::lang('o_global.add_success'), 'site/currency', 'success');
                 }
             } else {
                 $errors = $currency->errors();
                 remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
             }
         }
     }
     $currency_code = kohana::config('currency.code');
     $currency_sign = kohana::config('currency.sign');
     $currency_name = kohana::config('currency.name');
     $currency_rate = kohana::config('currency.rate');
     $currency_format = kohana::config('currency.format');
     $currency_data = json_encode(array('code' => $currency_code, 'sign' => $currency_sign, 'name' => $currency_name, 'rate' => $currency_rate));
     $this->template->content = new View("site/currency_add");
     $this->template->content->currency_data = $currency_data;
     $this->template->content->currency_name = $currency_name;
     $this->template->content->currency_format = $currency_format;
 }
 public function add()
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('distribution_system_manage');
     if ($_POST) {
         $data = $_POST;
         $data['type'] = $_POST['contract_type'];
         $data['createtime'] = date("Y-m-d H:i:s", time());
         //标签过滤
         tool::filter_strip_tags($data);
         $templateDao = Superplaner_Realtime_contract_template::instance();
         if ($templateDao->add($data)) {
             remind::set(Kohana::lang('o_global.add_success'), 'superplaner/realtime_contract_template/', 'success');
         } else {
             remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("superplaner/realtime_contract_template_add");
 }
Exemplo n.º 13
0
 /**
  * 修改用户地址
  */
 function do_edit($id)
 {
     //权限验证
     $site_id_list = role::check('user_edit');
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/address');
     }
     if ($_POST) {
         $data = $_POST;
         //标签过滤
         tool::filter_strip_tags($data);
         $data['date_upd'] = date('Y-m-d H:i:s');
         if (Myaddress::instance($id)->edit($data)) {
             remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
 }
Exemplo n.º 14
0
 public function edit($agentId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('distribution_system_manage');
     $aAgent = $this->agentDao->get_by_id($agentId);
     if ($aAgent == null) {
         remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         if (Myagent::instance($agentId)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'distribution/agent', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("distribution/agent_edit");
     $this->template->content->agent = $aAgent;
 }
Exemplo n.º 15
0
 public function edit()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         $id = $this->input->get('id');
         if (empty($id)) {
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 400);
         }
         $data = Myregion::instance($id)->get();
         if (empty($data['id'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 400);
         }
         $pid = $data['p_region_id'];
         $post = $this->input->post();
         if ($post) {
             tool::filter_strip_tags($post);
             if (empty($post['local_name'])) {
                 throw new MyRuntimeException(Kohana::lang('region.local_name_null'), 500);
             }
             if (Myregion::instance()->check_name('local_name', $post['local_name'], $pid, $id)) {
                 throw new MyRuntimeException(Kohana::lang('region.local_name_exists'), 500);
             }
             if (!empty($post['en_name']) && Myregion::instance()->check_name('en_name', $post['en_name'], $pid, $id)) {
                 throw new MyRuntimeException(Kohana::lang('region.en_name_exists'), 500);
             }
             if (Myregion::instance()->update($id, $post)) {
                 remind::set(Kohana::lang('o_global.update_success'), 'site/region', 'success');
             } else {
                 remind::set(Kohana::lang('o_global.update_error'), 'site/region/eidt?id=' . $id);
             }
         }
         if ($pid > 0) {
             $pdata = Myregion::instance($pid)->get();
         } else {
             $pdata = array();
         }
         $this->template->content = new View("site/region_edit", array('data' => $data, 'pdata' => $pdata));
     } catch (MyRuntimeException $ex) {
         $this->_ex($ex, $return_struct);
     }
 }
Exemplo n.º 16
0
 public function edit($contractId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('superplaner_system_manage');
     $contractDao = Superplaner_Realtime_contract::instance();
     $contract = $contractDao->get_by_id($contractId);
     if ($contract == null) {
         remind::set(Kohana::lang('o_contract.contract_not_exists'), request::referrer(), 'error');
     }
     $user = Myuser::instance()->get_by_id($contract['user_id']);
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         if (Superplaner_Realtime_contract::instance($contractId)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'superplaner/realtime_contract/index/' . $user['id'], 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("superplaner/realtime_contract_edit");
     $this->template->content->contract = $contract;
     $this->template->content->user = $user;
 }
Exemplo n.º 17
0
 /**
  * 修改用户信息
  */
 function edit($id)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('user_edit');
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         if (Myuser::instance($id)->set_money($_POST['invite_user_id'], $_POST['reward_money'])) {
             $arr['guest_user_id'] = intval($_POST['user_id']);
             $arr['user_id'] = intval($_POST['invite_user_id']);
             $arr['reward_money'] = intval($_POST['reward_money']);
             $arr['memo'] = '邀请用户奖励';
             $arr['reward_type'] = 'invite';
             $arr['time_stamp'] = date("Y-m-d H:i:s", time());
             User_inviteService::get_instance()->insert($arr);
             $logodata = array();
             $logodata['manager_id'] = $this->manager_id;
             $logodata['ip'] = tool::get_str_ip();
             $logodata['user_log_type'] = 28;
             $logodata['method'] = __CLASS__ . '::' . __METHOD__ . '()';
             $logodata['memo'] = "邀请奖励审核通过, 奖励:" . $_POST['reward_money'];
             ulog::add($logodata);
             remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("user/user_invite_edit");
     $id = intval($id);
     $data = Myuser::instance($id)->get();
     $data['invite'] = Myuser::instance($data['invite_user_id'])->get();
     $sql = " SELECT COUNT(id) AS id FROM user_reward  WHERE guest_user_id = " . $data['id'] . " AND user_id = " . $data['invite']['id'] . "  AND reward_type = 'invite' ";
     $data['reward'] = User_inviteService::get_instance()->get_one($sql);
     $data['reward'] = $data['reward']['id'];
     $this->template->content->data = $data;
 }
Exemplo n.º 18
0
 public function add()
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     $moneyExchangeCode = 'MEX-' . date("ymd-His", time());
     if ($_POST) {
         $data = $_POST;
         $data['code'] = $_POST['code'];
         $data['name'] = $_POST['name'];
         $data['numrmb'] = $_POST['numrmb'];
         $data['numjpy'] = $_POST['numjpy'];
         $data['updtime'] = date("Y-m-d H:i:s", time());
         $data['flag'] = $_POST['flag'];
         //标签过滤
         tool::filter_strip_tags($data);
         if ($cardSerialId = $this->moneyExchangeDao->add($data)) {
             remind::set(Kohana::lang('o_global.add_success'), 'card/money_exchange', 'success');
         } else {
             remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("card/money_exchange_add");
     $this->template->content->moneyExchangeCode = $moneyExchangeCode;
 }
Exemplo n.º 19
0
 public function post()
 {
     role::check('product_filter');
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //* 初始化返回数据 */
         $return_data = array();
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->post();
         $request_data = trims::run($request_data);
         //标签过滤
         tool::filter_strip_tags($request_data);
         if (!isset($request_data['id']) || !is_numeric($request_data['id'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 400);
         }
         // 调用底层服务
         $alias_filter_service = Alias_filterService::get_instance();
         $alias_filter = $alias_filter_service->get($request_data['id']);
         //数据验证
         $validResult = Validation::factory($request_data)->add_rules('title', 'required', 'length[1,100]')->add_rules('uri_name', 'length[0,100]');
         if ($validResult->validate() == FALSE) {
             //* 输出错误的具体信息 ==根据业务逻辑定制== */
             $return_struct['content']['errors'] = $validResult->errors();
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 400);
         }
         //title重复判断
         if ($request_data['title'] != $alias_filter['title'] && $alias_filter_service->check_exist_title($request_data['title'])) {
             throw new MyRuntimeException(Kohana::lang('o_product.category_title_has_exists'), 409);
         }
         //uri_name重复判断
         if ($request_data['uri_name'] != $alias_filter['uri_name'] && $alias_filter_service->check_exist_uri_name($request_data['uri_name'])) {
             throw new MyRuntimeException(Kohana::lang('o_product.uri_name_has_exists'), 409);
         }
         //获取过滤结构
         $filter = array();
         $filter['keywords'] = html::specialchars($request_data['keywords']);
         if (isset($request_data['pricefrom']) && preg_match('/^(0\\.\\d+|[1-9]\\d*(\\.\\d+)?)$/', $request_data['pricefrom'])) {
             $filter['pricefrom'] = $request_data['pricefrom'];
         }
         if (isset($request_data['priceto']) && preg_match('/^(0\\.\\d+|[1-9]\\d*(\\.\\d+)?)$/', $request_data['priceto'])) {
             $filter['priceto'] = $request_data['priceto'];
         }
         if (isset($request_data['brand']) && !empty($request_data['brand'])) {
             $filter['brands'] = $request_data['brand'];
         }
         if (isset($request_data['attribute']) && !empty($request_data['attribute'])) {
             $filter['attributes'] = $request_data['attribute'];
         }
         if (isset($request_data['feature']) && !empty($request_data['feature'])) {
             $filter['features'] = $request_data['feature'];
         }
         //执行修改
         $set_data = array();
         $set_data['id'] = $request_data['id'];
         $set_data['pid'] = $request_data['pid'];
         if ($request_data['oldpid'] != $request_data['pid']) {
             if (!empty($request_data['pid'])) {
                 $parents = $alias_filter_service->get_parents_by_filter_id($request_data['pid']);
                 $parent_ids = array();
                 foreach ($parents as $val) {
                     $parent_ids[] = $val['id'];
                 }
                 if (in_array($request_data['id'], $parent_ids)) {
                     throw new MyRuntimeException('设置父分类错误', 400);
                 }
                 $set_data['level_depth'] = count($parent_ids) + 1;
             } else {
                 $set_data['level_depth'] = 1;
             }
         }
         $set_data['category_id'] = $request_data['category_id'];
         //$set_data['classify_id'] = $request_data['classify_id'];
         $set_data['uri_name'] = $request_data['uri_name'];
         $set_data['title'] = html::specialchars($request_data['title']);
         $set_data['filter_struct'] = json_encode($filter);
         $set_data['update_timestamp'] = time();
         $alias_filter_service->set($set_data['id'], $set_data);
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '操作成功';
         $return_struct['content'] = $return_data;
         $return_struct['action'] = array('type' => 'location', 'url' => url::base() . 'product/' . $this->class_name . '/' . 'index');
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Exemplo n.º 20
0
 public function check_name()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //* 初始化返回数据 */
         $return_data = array();
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         $request_data = trims::run($request_data);
         //标签过滤
         tool::filter_strip_tags($request_data);
         //必须为ajax请求
         if (!$this->is_ajax_request()) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         //* 权限验证 */
         $site_id = site::id();
         if ($site_id == 0) {
             throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         if (!isset($request_data['name']) || empty($request_data['name'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 404);
         }
         $inquieysubject_service = InquirysubjectService::get_instance();
         if (isset($request_data['subject_id']) && is_numeric($request_data['subject_id'])) {
             $inquieysubject = $inquieysubject_service->get($request_data['subject_id']);
             //判断站点
             if ($site_id != $inquieysubject['site_id']) {
                 throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 404);
             }
             if ($inquieysubject['name'] == $request_data['name']) {
                 exit(Kohana::lang('o_global.true'));
             }
         }
         $query_struct = array('where' => array('site_id' => $site_id, 'name' => $request_data['name']));
         // 调用底层服务
         if ($inquieysubject_service->count($query_struct)) {
             exit(Kohana::lang('o_global.false'));
         } else {
             exit(Kohana::lang('o_global.true'));
         }
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Exemplo n.º 21
0
 /**
  * 提交商品修改
  */
 public function post()
 {
     // 初始化返回结构体
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         // 初始化返回数据
         $return_data = array();
         // 收集请求数据
         $request_data = $this->input->post();
         $request_data = trims::run($request_data);
         $url_redirect = url::base() . $this->package_name . '/' . $this->class_name;
         //标签过滤 商品描述保留
         tool::filter_strip_tags($request_data, array('desc', 'pdtdes_content'));
         $product = $request_data;
         //收集商品详细描述表单数据
         $product['descsections'] = array();
         if (!empty($request_data['pdtdes_title']) and is_array($request_data['pdtdes_title'])) {
             foreach ($request_data['pdtdes_title'] as $index => $pdtdes_title) {
                 $descsection = array('title' => $pdtdes_title, 'position' => isset($request_data['pdtdes_position'][$index]) ? $request_data['pdtdes_position'][$index] : '', 'content' => isset($request_data['pdtdes_content'][$index]) ? $request_data['pdtdes_content'][$index] : '');
                 if (isset($request_data['pdtdes_id'][$index])) {
                     $descsection['id'] = $request_data['pdtdes_id'][$index];
                 }
                 $product['descsections'][] = $descsection;
             }
         }
         //收集商品批发数据
         $product['wholesales'] = array('type' => 0, 'items' => array());
         isset($request_data['wholesale_type']) and $product['wholesales']['type'] = $request_data['wholesale_type'];
         if (isset($product['is_wholesale']) && $product['is_wholesale'] > 0) {
             if (!empty($request_data['wholesale_indexs']) and is_array($request_data['wholesale_indexs'])) {
                 foreach ($request_data['wholesale_indexs'] as $index) {
                     $wholesale = array();
                     isset($request_data['wholesale_num_begin_' . $index]) and $wholesale['num_begin'] = $request_data['wholesale_num_begin_' . $index];
                     isset($request_data['wholesale_value_' . $index]) and $wholesale['value'] = $request_data['wholesale_value_' . $index];
                     $product['wholesales']['items'][] = $wholesale;
                 }
             }
         }
         BLL_Product::set(&$product);
         if ($product['id'] <= 0) {
             throw new MyRuntimeException(Kohana::lang('o_product.no_save'), 500);
         }
         if ($request_data['save_redirect'] == 1) {
             $url_redirect .= '/edit?id=' . $product['id'];
         } elseif ($request_data['save_redirect'] == 2) {
             $url_redirect .= '/add';
         }
         remind::set(Kohana::lang('o_product.edit_product_success'), $url_redirect, 'success');
     } catch (MyRuntimeException $ex) {
         $this->_ex($ex, $return_struct, $request_data);
     }
 }
Exemplo n.º 22
0
 /**
  * 编辑商户信息
  */
 public function edit()
 {
     $id = intval($this->uri->segment('id'));
     $manager = Mymanager::instance($id)->get();
     //zhu add
     $this->_check_manager($manager['id']);
     if ($_POST) {
         tool::filter_strip_tags($_POST);
         $password1 = $this->input->post('password1');
         $password2 = $this->input->post('password2');
         $email = $this->input->post('email');
         $username = $this->input->post('username');
         $role_id = intval($this->input->post('role_id'));
         $submit_target = intval($this->input->post('submit_target'));
         //zhu add
         if ($manager['email'] != $email) {
             $data = Mymanager::instance()->get_by_email($email);
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.email_has_exist'), 'manage/manager/add');
             }
         }
         /* 判断用户名是否重复 */
         if (Mymanager::instance()->username_exist($username, $id)) {
             remind::set(Kohana::lang('o_manage.username_can_not_repeat'), 'manage/manager/edit/id/' . $id);
         }
         //验证两次密码是否相同
         if ($password1 != $password2) {
             remind::set(Kohana::lang('o_manage.two_pwd_not_valid'), 'manage/manager/add');
         } else {
             //不填写密码表示不修改密码
             if (empty($password1)) {
                 $_POST['password'] = $manager['password'];
             } else {
                 $_POST['password'] = md5($password1);
             }
         }
         if (Mymanager::instance($id)->edit($_POST)) {
             //zhu modify to acl page
             if ($role_id == 0 || $submit_target > 0) {
                 remind::set(Kohana::lang('o_global.update_success'), 'manage/manager/rule/' . $id, 'success');
             } else {
                 remind::set(Kohana::lang('o_global.update_success'), 'manage/manager', 'success');
             }
         } else {
             $error = Mysite::instance()->error();
             remind::set(Kohana::lang('o_global.update_error') . $error, 'manage/manager');
         }
     }
     //zhu modify
     $role_id = $manager['role_id'];
     if ($role_id > 0) {
         $role = Myrole::instance($role_id)->get();
         if ($manager['is_admin'] != $role['type']) {
             remind::set(Kohana::lang('o_manage.manager_edit_load_error'), 'manage/manager');
         }
     }
     if ($manager['is_admin'] == 1) {
         /* 管理员 */
         $where = array();
         $where['type'] = $manager['is_admin'];
         $where['active'] = 1;
         //zhu add
         /* 管理员的用户组 */
         $roles = Myrole::instance()->roles($where);
         $this->template->content = new View("manage/manager_adminedit");
     } else {
         $parent_id = $manager['parent_id'];
         $parent = Mymanager::instance($parent_id)->get();
         if ($parent['is_admin']) {
             /* 商户 */
             $where = array();
             $where['type'] = 0;
             $where['active'] = 1;
             //zhu add
             $roles = Myrole::instance()->roles($where);
             $this->template->content = new View("manage/manager_edit");
         } else {
             /* 商户子账号 zhu modify */
             //$roles = Myrole::instance()->childrens($parent['role_id']);
             $roles = array();
             if ($parent['role_id'] > 0) {
                 $roles = Myrole::instance()->childrens($parent['role_id']);
             }
             $this->template->content = new View("manage/manager_child_edit");
         }
     }
     foreach ($roles as $key => $value) {
         if ($manager['role_id'] == $value['id']) {
             $roles[$key]['selected'] = 'selected';
         } else {
             $roles[$key]['selected'] = '';
         }
     }
     $this->template->content->roles = $roles;
     $this->template->content->data = $manager;
 }
Exemplo n.º 23
0
 public function put()
 {
     $request_data = $this->input->post();
     //权限检查
     if (isset($request_data['id'])) {
         role::check('product_feature_edit');
     } else {
         role::check('product_feature_add');
     }
     //安全过滤
     $request_data = trims::run($request_data);
     tool::filter_strip_tags($request_data);
     $request_data['type'] = isset($request_data['type']) ? $request_data['type'] : 0;
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //初始化返回数据
         $return_data = array();
         $validation = Validation::factory($request_data);
         $validResult = $validation->pre_filter('trim')->add_rules('name', 'required', 'length[1,100]');
         if ($validResult->validate() == FALSE) {
             $return_struct['content']['errors'] = $validResult->errors();
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 400);
         }
         // 调用底层服务
         $attribute_service = AttributeService::get_instance();
         //是输入项时,要先删除旧的选项值
         if (isset($request_data['type']) && $request_data['type'] == 1) {
             $request_data['option_name'] = '';
             $request_data['id'] > 0 && $attribute_service->clear_attribute_value($request_data['id']);
         } else {
             //数据验证
             if (!isset($request_data['option_name']) || empty($request_data['option_name'])) {
                 throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 400);
             }
         }
         //执行添加
         $set_data = array();
         $set_data['apply'] = self::ATTRIBUTE_TYPE;
         $set_data['name'] = html::specialchars($request_data['name']);
         $set_data['alias'] = html::specialchars($request_data['alias']);
         $set_data['memo'] = html::specialchars($request_data['memo']);
         $set_data['type'] = $request_data['type'];
         if ($request_data['id']) {
             $return_data['id'] = $set_data['id'] = $request_data['id'];
             $attribute_service->update($set_data);
         } else {
             $return_data['id'] = $attribute_service->add($set_data);
         }
         if (!$return_data['id']) {
             throw new MyRuntimeException('Internal Error', 500);
         }
         //option
         if ($request_data['type'] == 0 && isset($request_data['option_name']) && !empty($request_data['option_name'])) {
             foreach ($request_data['option_name'] as $key => $val) {
                 $att_val = array();
                 $att_val['attribute_id'] = $return_data['id'];
                 $att_val['name'] = html::specialchars($val);
                 $att_val['alias'] = isset($request_data['option_alias'][$key]) ? html::specialchars($request_data['option_alias'][$key]) : '';
                 $att_val['order'] = (int) $request_data['option_order'][$key];
                 if (isset($request_data['option_image'][$key]) && !empty($request_data['option_image'][$key])) {
                     $att_val['image'] = $request_data['option_image'][$key];
                 }
                 if (isset($request_data['option_id_old'][$key]) && !empty($request_data['option_id_old'][$key])) {
                     $att_val['id'] = $request_data['option_id_old'][$key];
                 }
                 $flag = $attribute_service->save_attribute_value($att_val);
                 if (!$flag) {
                     throw new MyRuntimeException('Internal Error', 500);
                 }
             }
         }
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '保存成功';
         $return_struct['content'] = $return_data;
         $return_struct['action'] = array('type' => 'location', 'url' => url::base() . 'product/' . $this->class_name . '/index');
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $this->_ex($ex, $request_data, $return_struct);
     }
 }
Exemplo n.º 24
0
 public function post()
 {
     role::check('user_attribute');
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //字符过滤
         tool::filter_strip_tags($_POST);
         //收集信息
         $request_data = $this->input->post();
         $validation = Validation::factory($request_data)->pre_filter('trim')->add_rules('attribute_name', 'required', 'length[1,256]')->add_rules('attribute_type', 'required', 'length[1,64]')->add_rules('id', 'required', 'numeric');
         if ($validation->validate() == FALSE) {
             $return_struct['content']['errors'] = $validation->errors();
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 400);
         }
         //调用底层Service
         $user_attribute_service = User_attributeService::get_instance();
         $user_attribute = $user_attribute_service->get($request_data['id']);
         //检查编辑的是否存在
         if (empty($user_attribute)) {
             throw new MyRuntimeException(kohana::lang('o_user_attribute.user_attribute_not_exist'), 400);
         }
         //判断编辑的是否为系统默认项
         if ($user_attribute['attribute_default']) {
             throw new MyRuntimeException(kohana::lang('o_user_attribute.default_can_not_edit'), 400);
         }
         $insert_data['attribute_required'] = isset($request_data['attribute_required']) ? $request_data['attribute_required'] : 0;
         $insert_data['attribute_name'] = $request_data['attribute_name'];
         $insert_data['attribute_type'] = $request_data['attribute_type'];
         $insert_data['id'] = $request_data['id'];
         //判断是否有选项内容
         if ($offset = strpos($insert_data['attribute_type'], '.')) {
             if (substr($insert_data['attribute_type'], 0, $offset) == 'select') {
                 if (isset($request_data['attribute_option']) && !empty($request_data['attribute_option'])) {
                     $insert_data['attribute_option'] = '';
                     foreach ($request_data['attribute_option'] as $attribute_option) {
                         if (!empty($attribute_option)) {
                             $insert_data['attribute_option'] .= $attribute_option . ',';
                         } else {
                             throw new MyRuntimeException(kohana::lang('o_user_attribute.option_empty'), 400);
                         }
                     }
                     $insert_data['attribute_option'] = trim($insert_data['attribute_option'], ',');
                     if (strlen($insert_data['attribute_option']) > 256) {
                         throw new MyRuntimeException(kohana::lang('o_user_attribute.option_too_length'), 400);
                     }
                 } else {
                     throw new MyRuntimeException(kohana::lang('o_user_attribute.option_need'), 400);
                 }
             } else {
                 $insert_data['attribute_option'] = '';
             }
         } else {
             throw new MyRuntimeException(kohana::lang('o_user_attribute.user_attribute_type_error'), 400);
         }
         $user_attribute_service->set($insert_data['id'], $insert_data);
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = kohana::lang('o_global.update_success');
         $return_struct['content'] = $insert_data;
         $return_struct['action'] = array('type' => 'location', 'url' => url::base() . 'user/' . $this->class_name . '/' . 'index');
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Exemplo n.º 25
0
 public function edit($cardId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     if ($cardId == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $theCard = $this->cardDao->get_by_id($cardId);
     if ($theCard == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     if ($_POST) {
         $data = $_POST;
         $data['id'] = $cardId;
         $data['cardpass'] = $_POST['cardPass'];
         $data['points'] = $_POST['points'];
         $data['flag'] = $_POST['flag'];
         $data['updtime'] = date("Y-m-d H:i:s", time());
         $data['moneyrmb'] = $_POST['moneyRMB'];
         $data['moneyjpy'] = $_POST['moneyJPY'];
         $data['salecost'] = $_POST['saleCost'];
         $data['preflag'] = $data['flag'] == 0 ? $theCard['flag'] : 0;
         //标签过滤
         tool::filter_strip_tags($data);
         if ($this->cardDao->edit($data)) {
             $aLog = array();
             $aLog['userid'] = $this->manager['id'];
             $aLog['apdtime'] = date('Y-m-d H:i:s', time());
             $aLog['target'] = Ac_cardlog_Model::TARGET_CARD;
             $aLog['targetid'] = $cardId;
             $aLog['action'] = Ac_cardlog_Model::ACTION_CHANGE;
             $updateString = '';
             foreach ($_POST as $key => $value) {
                 $updateString = $updateString . $key . '=' . $value . ',';
             }
             $aLog['detail'] = 'update a card. ' . $updateString;
             $this->cardLogDao->add($aLog);
             remind::set(Kohana::lang('o_global.update_success'), 'card/card', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("card/card_edit");
     $this->template->content->card = $theCard;
 }
Exemplo n.º 26
0
 public function do_edit()
 {
     role::check('promotion_coupon');
     // 收集请求数据
     $coupon_id = $this->input->post('id');
     $request_data = $this->input->post();
     $session = Session::instance();
     $session->set_flash('sessionErrorData', $request_data);
     //标签过滤
     tool::filter_strip_tags($request_data);
     $coupon = Mycoupon::instance($coupon_id)->get();
     if (!isset($request_data['with_pmt'])) {
         $request_data['with_pmt'] = 0;
     }
     if ($this->input->post('cpn_type') == 'A' && $coupon['cpn_key'] == '') {
         $request_data['cpn_key'] = mt_rand();
     }
     //时间处理
     if (strtotime($request_data['cpn_time_end']) + 24 * 3600 < time()) {
         remind::set(Kohana::lang('o_promotion.time_end'), request::referrer(), 'error');
     }
     if (strtotime($request_data['cpn_time_end']) < strtotime($request_data['cpn_time_begin'])) {
         remind::set(Kohana::lang('o_promotion.begin_time_over_end'), request::referrer(), 'error');
     }
     $request_data['cpn_time_end'] = date("Y-m-d H:i:s", strtotime($request_data['cpn_time_end']) + 24 * 3600);
     if (Mycoupon::instance()->edit($request_data)) {
         $session->delete('sessionErrorData');
         url::redirect("promotion/cpn_promotion/edit?id=" . $request_data['cpnp_id']);
     } else {
         remind::set(Kohana::lang('o_promotion.update_cpn_error'), request::referrer(), 'error');
     }
 }
Exemplo n.º 27
0
 public function do_edit()
 {
     // 收集请求数据
     $request_data = $this->input->post();
     $session = Session::instance();
     $session->set_flash('sessionErrorData', $request_data);
     //标签过滤
     tool::filter_strip_tags($request_data);
     $pmts_id = $this->input->post('pmts_id');
     $promotion = Mypromotion::instance($request_data['id'])->get();
     if (!$promotion['id']) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     //促销规则时间效验
     if (strtotime($request_data['time_end']) + 24 * 3600 < time()) {
         remind::set(Kohana::lang('o_promotion.time_end'), request::referrer(), 'error');
     }
     if (strtotime($request_data['time_begin']) > strtotime($request_data['time_end'])) {
         remind::set(Kohana::lang('o_promotion.begin_time_over_end'), request::referrer(), 'error');
     }
     $dayTimeStamp = 24 * 3600;
     $request_data['time_end'] = date('Y-m-d H:i:s', strtotime($request_data['time_end']) + $dayTimeStamp);
     $time_begin = strtotime($request_data['time_begin']);
     $time_end = strtotime($request_data['time_end']);
     //促销规则时间必须在促销活动时间内
     $promotion_activity = Mypromotion_activity::instance($promotion['pmta_id'])->get();
     if (!$promotion_activity['id']) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $pmta_time_begin = strtotime($promotion_activity['pmta_time_begin']);
     $pmta_time_end = strtotime($promotion_activity['pmta_time_end']);
     if ($pmta_time_begin > $time_begin || $pmta_time_end < $time_end) {
         remind::set(Kohana::lang('o_promotion.promotion_out_time_range'), request::referrer(), 'error');
     }
     //验证打折值与订单优惠条件
     if (isset($request_data['discount_type'])) {
         if (isset($request_data['price']) && (!preg_match('/^\\d{1,12}(\\.\\d{0,3})?$/', $request_data['price']) || $request_data['price'] < 0)) {
             remind::set(Kohana::lang('o_promotion.cpn_price_error'), request::referrer(), 'error');
         }
         if ($request_data['discount_type'] == 0 && $request_data['price'] > 1) {
             remind::set(Kohana::lang('o_promotion.cpn_price_error'), request::referrer(), 'error');
         }
     }
     if (isset($request_data['quantity_from']) && (!preg_match('/^\\d+$/', $request_data['quantity_from']) || $request_data['quantity_from'] < 0) || isset($request_data['quantity_to']) && (!preg_match('/^\\d+$/', $request_data['quantity_to']) || $request_data['quantity_to'] < 0) || isset($request_data['quantity_from']) && $request_data['quantity_from'] >= $request_data['quantity_to']) {
         remind::set(Kohana::lang('o_promotion.buy_quantitys_error'), request::referrer(), 'error');
     }
     $moneyError = '';
     // extra process needed for IDs
     switch ($pmts_id) {
         case 5:
             // get_gifts_buy_anything
         // get_gifts_buy_anything
         case 6:
             // get_gifts_price_morethan
             $moneyError = '订单金额错误';
             $gift_related_ids = $this->input->post('gift_related_ids');
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift'), request::referrer(), 'error');
             }
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 1:
             // discount_category
             $related_ids = $this->input->post('related_ids');
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_cpn_category'), request::referrer(), 'error');
             }
             empty($moneyError) && ($moneyError = '订单金额错误');
         case 2:
             // discount_product_during
             empty($moneyError) && ($moneyError = '订单金额错误');
         case 3:
             // discount_product_quantity_morethan
         // discount_product_quantity_morethan
         case 12:
             // discount_cart_buy_product
         // discount_cart_buy_product
         case 16:
             // free_shipping_buy_product
             if (!isset($related_ids)) {
                 $related_ids = $this->input->post('related_ids');
             }
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_product'), request::referrer(), 'error');
             }
             // enclose selected category ids with comma
             $request_data['related_ids'] = Mypromotion::enclose_ids($related_ids, ',');
             break;
         case 7:
             // get_gifts_product_price_morethan
             $related_ids = $this->input->post('related_ids');
             $gift_related_ids = $this->input->post('gift_related_ids');
             empty($moneyError) && ($moneyError = '货品金额错误');
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_product'), request::referrer(), 'error');
             }
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift'), request::referrer(), 'error');
             }
             // enclose selected category ids with comma
             $request_data['related_ids'] = Mypromotion::enclose_ids($related_ids, ',');
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 8:
             // get_1_buy_n
             break;
         case 9:
             // get_another_cat_buy_cat
             $related_ids = $this->input->post('related_ids');
             $gift_related_ids = $this->input->post('gift_related_ids');
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_cpn_category'), request::referrer(), 'error');
             }
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift_category'), request::referrer(), 'error');
             }
             // separate selected category ids with comma
             $request_data['related_ids'] = Mypromotion::enclose_ids($related_ids, ',');
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 10:
             // get_catgift_price_morethan
             $gift_related_ids = $this->input->post('gift_related_ids');
             empty($moneyError) && ($moneyError = '订单金额错误');
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift_category'), request::referrer(), 'error');
             }
             // separate selected category ids with comma
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 11:
             empty($moneyError) && ($moneyError = '购物车金额错误');
             break;
         case 14:
             empty($moneyError) && ($moneyError = '订单金额错误');
             break;
     }
     //验证
     if (isset($request_data['money_from']) && (!preg_match('/^\\d{1,12}(\\.\\d{0,3})?$/', $request_data['money_from']) || $request_data['money_from'] < 0) || isset($request_data['money_to']) && (!preg_match('/^\\d{1,12}(\\.\\d{0,3})?$/', $request_data['money_to']) || $request_data['money_to'] < 0) || isset($request_data['money_from']) && $request_data['money_from'] >= $request_data['money_to']) {
         remind::set($moneyError, request::referrer(), 'error');
     }
     if (Mypromotion::instance()->edit($request_data)) {
         $session->delete('sessionErrorData');
         //promotion::delete_memcache($promotion['site_id']);
         remind::set(Kohana::lang('o_global.update_success'), "promotion/promotion_activity", 'success');
     } else {
         remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
     }
 }
Exemplo n.º 28
0
 public function add()
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     if ($_POST) {
         $data = $_POST;
         $data['checkuserid'] = $_POST['checkUserId'];
         $data['checkuser'] = $_POST['checkUser'];
         $data['channelid'] = $_POST['channelId'];
         $data['channelcode'] = $this->salesChannelMap[$data['channelid']]['code'];
         $data['issuetime'] = date("Y-m-d H:i:s", time());
         $data['bgnnum'] = $_POST['beginNum'];
         $data['endnum'] = $_POST['endNum'];
         $data['mailcost'] = $_POST['mailCost'];
         $data['billid'] = 0;
         // 1. check the card mgrnum
         $where = array();
         $where['mgrnum >='] = $data['bgnnum'];
         $where['mgrnum <='] = $data['endnum'];
         $cardCount = $this->cardDao->count_items_with_condition($where);
         if ($cardCount != $data['endnum'] - $data['bgnnum'] + 1) {
             remind::set('目标卡号序列中存在未生成的卡号,请先生成充值卡再发行', request::referrer(), 'error');
             return;
         }
         $where['flag'] = Ac_card_Model::FLAG_CLOSE;
         $cardCount = $this->cardDao->count_items_with_condition($where);
         if ($cardCount > 0) {
             remind::set('目标卡号序列中存在已关闭的卡号,关闭的卡号不能发行', request::referrer(), 'error');
             return;
         }
         $where['flag'] = Ac_card_Model::FLAG_ISSUED;
         $cardCount = $this->cardDao->count_items_with_condition($where);
         if ($cardCount > 0) {
             remind::set('目标卡号序列中存在已发行的卡号,不能重复发行', request::referrer(), 'error');
             return;
         }
         $where['flag'] = Ac_card_Model::FLAG_OPEN;
         $cardCount = $this->cardDao->count_items_with_condition($where);
         if ($cardCount > 0) {
             remind::set('目标卡号序列中存在已生效(开启)的卡号,不能重复发行', request::referrer(), 'error');
             return;
         }
         $where['flag'] = Ac_card_Model::FLAG_USED;
         $cardCount = $this->cardDao->count_items_with_condition($where);
         if ($cardCount > 0) {
             remind::set('目标卡号序列中存在已使用的卡号,不能重复发行', request::referrer(), 'error');
             return;
         }
         //标签过滤
         tool::filter_strip_tags($data);
         if (($cardIssueId = $this->cardIssueSerialDao->add($data)) == false) {
             remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
             return;
         }
         // 2. add IssueBill;
         $theIssueBill = array();
         $theIssueBill['num'] = 'ISB-' . date("ymd-His", time());
         $theIssueBill['user_id'] = $this->manager['id'];
         $theIssueBill['flag'] = Ac_issuebill_Model::FLAG_NEW;
         $theIssueBill['issueid'] = $cardIssueId;
         $theIssueBill['channelid'] = $data['channelid'];
         $theIssueBill['channelcode'] = $data['channelcode'];
         $theIssueBill['bgnnum'] = $data['bgnnum'];
         $theIssueBill['endnum'] = $data['endnum'];
         $theIssueBill['moneys'] = 0;
         $theIssueBill['des'] = '';
         $theIssueBill['apdtime'] = date("Y-m-d H:i:s", time());
         $theIssueBill['updtime'] = date("Y-m-d H:i:s", time());
         tool::filter_strip_tags($theIssueBill);
         if (($issueBillId = $this->issueBillDao->add($theIssueBill)) == false) {
             remind::set('添加发行单据时失败,请检查一致性。', request::referrer(), 'error');
             return;
         }
         $updData = array();
         $updData['id'] = $cardIssueId;
         $updData['billid'] = $issueBillId;
         $this->cardIssueSerialDao->edit($updData);
         // 3. update card flag
         $newValues = array();
         $newValues['flag'] = Ac_card_Model::FLAG_ISSUED;
         $newValues['issueid'] = $cardIssueId;
         $newValues['issuetime'] = $data['issuetime'];
         $newValues['updtime'] = date("Y-m-d H:i:s", time());
         $where = array();
         $where['mgrnum >='] = $data['bgnnum'];
         $where['mgrnum <='] = $data['endnum'];
         $where['flag'] = Ac_card_Model::FLAG_UNISSUE;
         if ($this->cardDao->batch_update($newValues, $where) == false) {
             remind::set('更新充值卡状态失败,请检查一致性。', request::referrer(), 'error');
             return;
         }
         // 4. batch add issueBillDtl
         $cardCount = $data['endnum'] - $data['bgnnum'] + 1;
         $issueBillDtlList = array();
         for ($index = 0; $index < $cardCount; $index++) {
             $aIssueBillDtl = array();
             $aIssueBillDtl['mstid'] = $issueBillId;
             $aIssueBillDtl['num'] = $theIssueBill['num'];
             $mgrNum = $data['bgnnum'] + $index;
             $mgrNum = sprintf('%.0f', $mgrNum);
             $aIssueBillDtl['mgrnum'] = $mgrNum;
             $issueBillDtlList[] = $aIssueBillDtl;
         }
         $this->issueBillDtlDao->batch_insert($issueBillDtlList);
         // 5. add the log
         $aLog = array();
         $aLog['userid'] = $this->manager['id'];
         $aLog['apdtime'] = date('Y-m-d H:i:s', time());
         $aLog['target'] = Ac_cardlog_Model::TARGET_CARD_ISSUE;
         $aLog['targetid'] = $cardIssueId;
         $aLog['action'] = Ac_cardlog_Model::ACTION_CREATE;
         $aLog['detail'] = 'insert new cardIssueSerial: ' . $cardIssueId . '(' . $data['bgnnum'] . '-' . $data['endnum'] . ')';
         $this->cardLogDao->add($aLog);
         remind::set(Kohana::lang('o_global.add_success'), 'card/card_issue_serial', 'success');
         return;
     }
     $this->template->content = new View("card/card_issue_serial_add");
     $this->template->content->channelList = $this->salesChannelMap;
     $this->template->content->manager = $this->manager;
 }
Exemplo n.º 29
0
 /**
  * add doc
  */
 public function add()
 {
     $post = array();
     if ($_POST) {
         $post =& $_POST;
         $site_next_flow = site::site_next_flow($this->current_flow);
         $submit_target = intval($this->input->post('submit_target'));
         $doc = Mydoc::instance();
         //标签过滤
         tool::filter_strip_tags($_POST, array('content'));
         /* 判断url是否重复*/
         $permalink = $this->input->post('permalink');
         if ($doc->url_exist($permalink)) {
             remind::set(Kohana::lang('o_site.url_exist'));
         } else {
             if ($doc->add($_POST)) {
                 //判断添加成功去向
                 switch ($submit_target) {
                     case 1:
                         remind::set(Kohana::lang('o_global.add_success'), 'site/doc/add', 'success');
                         break;
                     case 2:
                         remind::set(Kohana::lang('o_global.add_success'), 'site/doc/add', 'success');
                         break;
                     default:
                         remind::set(Kohana::lang('o_global.update_success'), 'site/doc', 'success');
                 }
             } else {
                 remind::set(Kohana::lang('o_global.access_denied'));
             }
         }
     }
     //分类树
     $category_list = '';
     $categories = Mydoc_category::instance()->doc_categories(0);
     if (!empty($categories)) {
         foreach ($categories as $category) {
             $icon = '';
             for ($i = 1; $i <= $category['level_depth']; $i++) {
                 $icon = $icon . '--';
             }
             $select = '';
             if (isset($post['category_id']) && $post['category_id'] == $category['id']) {
                 $select = ' selected';
             }
             $category_list .= '<option value="' . $category['id'] . '"' . $select . '>' . $icon . $category['category_name'] . '</option>';
         }
     }
     $this->template->content = new View("site/doc_add");
     $this->template->content->post = $post;
     $this->template->content->title = "site doc add";
     $this->template->content->category_list = $category_list;
 }
Exemplo n.º 30
0
 /**
  * 虚拟充值
  * @param unknown_type $id
  */
 function recharge_virtual_money($id)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('user_recharge');
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $userobj = user::get_instance();
         $usermoney = $userobj->get_user_virtual_money($id);
         if ($_POST['money'] > 0) {
             $money_type_name = '竞波币';
             //记录日志
             $data_log = array();
             $data_log['order_num'] = date('YmdHis') . rand(0, 99999);
             $data_log['user_id'] = $id;
             $data_log['log_type'] = 6;
             //参照config acccount_type 设置
             $data_log['is_in'] = 0;
             $data_log['price'] = $_POST['money'];
             $data_log['user_money'] = $usermoney;
             $data_log['memo'] = $_POST['memo'];
             account_virtual_log::get_instance()->add($data_log);
             //$um = user_money::get_instance()->update_money($data_log['is_in'], $data_log['user_id'], $data_log['price'], $data_log['log_type'], $data_log['order_num'], $money_type, $data_log['memo']);
             //添加日志
             $logs_data = array();
             $logs_data['manager_id'] = $this->manager_id;
             $logs_data['user_log_type'] = 29;
             $logs_data['ip'] = tool::get_long_ip();
             $logs_data['memo'] = "成功为用户{$id}充值{$money_type_name}{$_POST['money']}";
             ulog::instance()->add($logs_data);
             remind::set($money_type_name . '充值成功', request::referrer(), 'success');
         }
     }
     $this->template->content = new View("user/user_recharge_virtual");
     $this->template->content->data = Myuser::instance($id)->get();
 }