public function __construct() { /* * Call parent construct */ parent::__construct(); import('system/contrib/admin/base'); import('system/contrib/auth/plugins'); /* * Initialize the Pluggable if it doesn't initialized. */ if (!Pluggable::$inited) { Pluggable::init($this); } /* * smarty instance */ $this->smarty = $this->load('smarty'); /* * admin_required, if use RBAC, this will another use */ AuthPlugins::admin_required($this); Pluggable::trigger('before_admin_site_run'); $this->smarty->assign('admin_menus', BaseAdmin::build_menus()); }
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($params = null) { self::$instance = $this; self::$current_application = ini('runtime/application'); self::_check_dependence(self::$current_application); Pluggable::trigger('after_application_construct'); /* * 基础是否登录权限判断 */ if (ini('runtime/application') != 'system/contrib/auth' && ini('runtime/action') != 'login' && ini('runtime/application' != 'system/contrib/dev_tools')) { import('system/contrib/auth/plugins'); AuthPlugins::login_required($this); } }
public function add($order_id) { AuthPlugins::required($this, array('销售经理', '销售顾问')); $order_id = abs(intval($order_id)); $content = trim(nl2br(strip_tags($_POST['content']))); if (!$order_id || !$this->is_post() || !$content) { return false; } parent::load('model', 'Order.Communication'); $c = new Communication(); $c->order_id = $order_id; $c->content = $content; $c->user_id = User::info('id'); $c->save(); echo 'ok'; }
public function start($type, $order_id) { AuthPlugins::required($this, $this->available_type_permission[$type]); if (!array_key_exists($type, $this->available_type)) { $this->unsupported($type); } $smarty = parent::load('smarty'); import('system/share/network/redirect'); parent::load('model', 'system/contrib/auth'); parent::load('model', 'order'); parent::load('model', 'work'); /* * 是否此人工作 */ $order = Order::get_by_id($order_id); $userinfo = User::info(); if ($order->designer_id != $userinfo['id'] && $order->layouter_id != $userinfo['id'] && $order->programmer != $userinfo['id']) { $message = '这份工作好像不属于你'; HTTPRedirect::flash_to('order', $message, $smarty); } /* * 下一工作流程 */ $workflow = Workflow::get_by_alias($this->available_type[$type]); $work = OrderWork::get_by_order($order_id, $type); /* * 工作已经开始 */ if ($work) { $message = sprintf('此订单的 %s 工作已经开始', $this->available_type[$type]); HTTPRedirect::flash_to('order/list/' . $workflow->id, $message, $smarty); } $work = new OrderWork(); $work->order_id = $order_id; $work->process = '10'; $work->type = $type; $work->user_id = User::info('id'); $work->save(); $message = '标记工作开始成功, 工作进度被设为10%, 请及时登记您的工作进度'; HTTPRedirect::flash_to('order/list/' . $workflow->id, $message, $smarty); }
public function decide_inner($order_id) { AuthPlugins::required($this, array('客户', '技术经理')); $smarty = parent::load('smarty'); import('system/share/network/redirect'); $order = Order::get_by_id($order_id); /* * 判断尾款是否已付,如果已付,直接转入售后部门上线 */ $last_pay = Payment::get_by_order_and_state($order_id, 2, 'last'); $workflow = Workflow::get_by_alias('布局任务'); $userinfo = User::info(); if (!$order || ($order->Customer->CustomerUser->id != $userinfo['id'] || $userinfo['role']['0']['alias'] == '技术经理')) { echo '无效的订单ID或者您不是此订单的所有者'; exit; } $order->workflow_id = $workflow->id; $order->save(); $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 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 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'); } }