public function leave() { $smarty = parent::load('smarty'); $leave_form = parent::load('form', 'LeaveForm', $_POST); parent::load('model', 'forms'); parent::load('model', 'system/contrib/auth.User'); if (!$this->is_post()) { import('system/share/web/paginator'); if (User::has_role('人力资源') || User::has_role('总经理')) { $data = Forms::get_by_type_and_user('请假申请'); $smarty->assign('has_role', true); } else { $data = Forms::get_by_type_and_user('请假申请', User::info('id')); } $paginator = new Paginator((array) $data, $_GET['page'], 10); $smarty->assign('paginator', $paginator->output()); $smarty->assign('page_title', '请假申请'); $smarty->assign('leave_form', $leave_form->output()); $smarty->display('forms/leave'); return; } $form_data = new Forms(); $form_data->user_id = User::info('id'); $form_data->state = 0; $form_data->type = '请假申请'; $form_data->form_data = serialize($_POST); $form_data->save(); import('system/share/network/redirect'); HTTPRedirect::flash_to('forms/leave', '提交请假申请成功, 请耐心等待审核', $smarty); }
public static function userinfo($base_app) { $smarty = $base_app->load('smarty'); $base_app->load('model', 'system/contrib/auth.User'); if (User::is_authenticated()) { $user = array('is_authenticated' => true, 'info' => User::$info); if (User::has_role('人力资源') || User::has_role('总经理')) { $user['is_super_admin'] = true; } } else { $user = array('is_authenticated' => false); } $smarty->assign('user', $user); }
public function index() { $smarty = parent::load('smarty'); parent::load('model', 'articles'); $news = Doctrine_Query::create()->select('id, name, created_at')->from('Article a')->orderBy('id DESC')->limit('6')->fetchArray(); /* * 销售顾问或者销售经理, 显示最近已经联系但是未签约的十个订单 */ parent::load('model', 'system/contrib/auth.User'); if (User::has_role('销售顾问') || User::has_role('销售经理')) { parent::load('model', 'order'); $orders = Doctrine_Query::create()->select('o.*, oc.*')->from('Order o')->leftJoin('o.Customer oc')->where('o.seller_id = ?', User::info('id'))->addWhere('o.workflow_id BETWEEN ? AND ?', array(2, 6))->orderBy('o.subscribe_time DESC')->fetchArray(); $smarty->assign('long_not_orders', $orders); } /* * 判断是否客服 */ if (User::has_role('客服')) { $smarty->assign('is_customer_service', true); } $smarty->assign('news', $news); $smarty->assign('page_title', '管理中心'); $smarty->display('center/index'); }
public function detail($id = null) { $smarty = parent::load('smarty'); $cache_id = 'order_detail_' . $id; $smarty->assign('page_title', '订单详情'); $id = abs(intval($id)); if (!$id) { $smarty->display(404); } $order = Order::get_by_id($id); if ($order->Payment[0]) { $not_payed = 0; foreach ($order->Payment as $p) { if ($p->is_payed != 2) { $not_payed += $p->price; } $p->public = $p->public ? '是' : '否'; $p->invoice = $p->invoice ? '是' : '否'; switch ($p->is_payed) { case 0: $p->is_payed = '未付款'; break; case 1: $p->is_payed = '已付款, 待确认'; break; case 2: $p->is_payed = '已付款, 财务已经确认'; break; case -1: $p->is_payed = $p->content; break; } } } $smarty->assign('not_payed', $not_payed); $smarty->assign('order', $order); /* * 获取工作流程中, 当前的可操作选项 */ $workflow = Workflow::get_by_id($order['workflow_id']); /* * 在订单未联系之前 销售人员不能查看订单, 防止挑 */ if ($workflow->alias == '新增订单管理' && !User::has_role('客服') && !User::has_role('总经理')) { HTTPRedirect::flash_to('order/list', '在联系订单之前,您没有权限进行此操作', $smarty); } $operation = Workflow::get_operation($workflow['sequence'], User::info()); if (User::has_role('技术经理')) { $operation[] = array('label' => '分配任务', 'action' => 'order/select_designer'); } $smarty->assign('operations', $operation); $smarty->display('order/detail', $cache_id); }
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); }