public function add($order_id) { import('system/share/network/redirect'); AuthPlugins::required($this, array('销售经理', '销售顾问')); $order_id = abs(intval($order_id)); if (!$this->is_post() || !$order_id) { return false; } /* * 上传方案附件 */ import('system/share/io/filesystem'); FileSystem::init(); $file_path = FileSystem::Upload($_FILES['attachment'], false); if (!$file_path) { HTTPRedirect::flash_to('order/detail/' . $order_id, '文件上传失败:' . FileSystem::$message, $this->smarty); } /* * 写入方案表 */ parent::load('model', 'order'); $solution = new Solution(); $solution->order_id = $order_id; $solution->solution_code = trim(strip_tags($_POST['solution_code'])); $solution->name = trim(strip_tags($_POST['name'])); $solution->attachment = $file_path; $solution->price = abs(intval($_POST['price'])); $solution->save(); HTTPRedirect::flash_to('order/detail/' . $order_id, '添加方案成功', $this->smarty); }
public function __construct() { parent::__construct(); parent::load('model', 'system/contrib/auth'); import('system/share/network/redirect'); $userinfo = User::info(); /*当前客户登陆的话*/ if ($userinfo['role'][0]['alias'] == '客户' || !$userinfo['role'] && User::is_authenticated()) { HTTPRedirect::to('customer'); } }
public function state() { $id = abs(intval($_GET['id'])); $state = abs(intval($_GET['state'])); echo $id; parent::load('model', 'forms'); import('system/share/network/redirect'); $form = FormsTable::getInstance()->find($id); if (!$form) { return false; } $form->state = $state; $form->save(); HTTPRedirect::flash_to('forms/' . $this->maps[$form->type], '操作成功', $this->smarty); }
private function unsupported($type) { import('system/share/network/redirect'); $message = sprintf('不支持的工作类型 %s', $type); HTTPRedirect::flash_to('order/list', $message, $smarty); exit; }
public function decide_programe($order_id) { $workflow = Workflow::get_by_alias('程序验收完成'); import('system/share/io/filesystem'); FileSystem::init(); $http_path = FileSystem::Upload($_FILES['attachment']); if (!$_FILES['attachment'] || !$http_path) { HTTPRedirect::flash_to('customer', '请您上传首页确认书的扫描件', $this->smarty, 'cus_flash_to'); } $order = Order::get_by_id($order_id); $order->programe_decide_attachment = $http_path; $order->save(); Order::set_workflow($order_id, $workflow); $smarty = parent::load('smarty'); import('system/share/network/redirect'); $message = '程序验收完成,等待客户付尾款即可上线'; $flash_to = $userinfo['role']['0']['alias'] == '技术经理' ? 'order/list/' . $workflow->id : 'customer'; $template = $userinfo['role']['0']['alias'] == '技术经理' ? 'flash_to' : 'cus_flash_to'; HTTPRedirect::flash_to($flash_to, $message, $smarty, $template); }
public function change_password() { parent::load('model', 'system/contrib/auth.User'); $user = UserTable::getInstance()->find(User::info('id')); import('system/share/network/redirect'); if ($this->is_post()) { list($func, $random, $encryped) = explode('$', $user->password); /* * 验证原密码 */ if ($user->password && $user->password === User::generate_password($_POST['old_password'], $random, $func)) { $user->password = User::generate_password($_POST['new_password']); $user->save(); User::logout(); $message = '修改密码成功, 请重新登录'; HTTPRedirect::flash_to(url_reverse('auth_login'), $message, $this->smarty); } else { $message = '原密码不正确, 请重试'; HTTPRedirect::flash_to('accounts/change_password', $message, $this->smarty); } } $this->smarty->display('auth/change_password'); }
public static function login_required($base_app) { $base_app->load('model', 'system/contrib/auth.User', false); if (!User::is_authenticated()) { import('system/share/network/redirect'); HTTPRedirect::to('accounts/login'); Boot::shutdown(); } return true; }
public function publish($order_id) { AuthPlugins::required($this, '售后经理'); $workflow = Workflow::get_by_alias('已经上线'); Order::set_workflow($order_id, $workflow); $message = '网站已成功上线, 订单流程完成'; HTTPRedirect::flash_to('order/list/' . $workflow->id, $message, $this->smarty); }
public function workflow_edit($id) { parent::load('model', 'workflow'); parent::load('model', 'order'); parent::load('model', 'system/contrib/auth'); $workflow = WorkflowTable::getInstance()->find($id); $all_roles = RoleTable::getInstance()->findAll(); $workflow_roles = array_filter(explode(',', $workflow->roles)); $options = array(); foreach ($all_roles as $ar) { $options[$ar['id']] = $ar['name']; } if ($this->is_post()) { $workflow->roles = sprintf(',%s,', implode(',', $_POST['roles'])); $workflow->save(); HTTPRedirect::flash_to('manager/workflow_permission', '编辑工作流程权限成功', $this->smarty); } $this->smarty->assign('roles', $workflow_roles); $this->smarty->assign('workflow', $workflow); $this->smarty->assign('all_roles', $options); $this->smarty->display('manager/order/workflow_edit'); }
public function add_customer() { AuthPlugins::required($this, '客服'); $smarty = parent::load('smarty'); $smarty->assign('page_title', '新增订单'); if ($this->is_post()) { unset($_POST['CSRF_TOKEN']); unset($_POST['sub4']); $model = parent::load('model', 'order'); $time_str = sprintf('%s %s:%s', $_POST['subscribe_time'], $_POST['book_hour'], $_POST['book_minu']); $_POST['subscribe_time'] = date('Y-m-d H:i', strtotime($time_str)); try { $customer = new Customer(); $order = new Order(); foreach ($_POST as $k => $v) { if (isset($customer->{$k})) { $customer->{$k} = trim(htmlspecialchars($v)); } else { if (isset($order->{$k})) { $order->{$k} = trim(htmlspecialchars($v)); } } } /* * 客户提供资料 */ if ($_FILES['cus_docs']) { import('system/share/io/filesystem'); FileSystem::init(); $http_path = FileSystem::Upload($_FILES['cus_docs'], false); $customer->docs = $http_path; } /* * 保存客户信息 */ $customer->save(); /* * 取得工作流程ID(订单状态) */ $workflow = Workflow::get_by_alias('新增订单管理'); /* * 新建订单, 并写入当前的订单初始信息 */ $order->Customer = $customer; $order->Workflow = $workflow; /* * 客服 */ $order->CustomerService = User::current(); $order->save(); import('system/share/network/redirect'); $message = '订单信息录入成功, 转入新增订单管理页面'; /* * 清除订单列表缓存 */ // $smarty->clearCache('order/list'); $smarty->clearAllCache(); HTTPRedirect::flash_to($workflow['action'], $message, $smarty); } catch (Doctrine_Query_Exception $e) { $smarty->raise('system'); } } else { parent::load('form', 'NewCustomer'); $smarty->display('customer/add'); } }
public function delete($id) { parent::load('model', 'articles'); parent::load('model', 'system/contrib/auth.User'); $article = ArticleTable::getInstance()->find($id); /* * 判断是否有权限修改此类文章 */ $has_role = Category::has_role($article->Category->id, User::info()); if (!$has_role || !User::has_role('人力资源') || !User::has_role('总经理')) { $this->smarty->display(403); Boot::shutdown(); } if ($article) { $article->delete(); $message = '删除成功'; } else { $message = '文章不存在'; } import('system/share/network/redirect'); HTTPRedirect::flash_to('', $message, $this->smarty); }