public function addtaskAction() { $this->view->pageTitle = $this->translate('user_addtask_headline'); $this->view->form = new User_Form_EditTask(array(), true); $req = $this->getRequest(); if ($req->isPost()) { // there are profile updates if ($this->view->form->isValid($_POST)) { $values = $this->view->form->getValues(); $t = new User_Model_Task(); $t->name = $values['taskname']; $t->save(); $this->session->message = $this->translate('user_admin_taskadd_success'); $this->_helper->redirector->gotoSimple('tasks', 'admin', 'user'); } else { $this->view->message = $this->translate('user_admin_taskadd_failed'); } } }
private function send($id, $updFlg) { $user_session = new Zend_Session_Namespace('user'); $user = $user_session->user_info['employee_id']; $user_name = $user_session->user_info['user_name']; $now = date('Y-m-d H:i:s'); $employee = new Hra_Model_Employee(); $mail = new Application_Model_Log_Mail(); $task = new User_Model_Task(); $process = new User_Model_Process(); $record = $task->getJoinList("id=" . $id); if (!$record) { return; } $record = $record[0]; if ($record['type'] == '独立') { $where = " task_id = {$id} and employee_id = {$user}"; } else { $where = " task_id = {$id}"; } $join = array('type' => INNERJOIN, 'table' => $employee, 'condition' => $employee->getName() . '.id = ' . $process->getName() . '.employee_id', 'cols' => array('cname')); $pro = $process->getJoinList($where, $join); $to_id = $record['responsible_id']; $cc_id = $record['follow_id']; // 上级 if ($to_id == $user) { $up = $employee->getAdapter()->query("select manager_id from oa_employee where id = {$user}")->fetchObject(); if ($up && $up->manager_id && $up->manager_id != $user) { if ($cc_id) { $cc_id .= ',' . $up->manager_id; } else { $cc_id = $up->manager_id; } } } $to = $employee->getAdapter()->query("select group_concat(email) as mail_to from oa_employee where id in ( " . $to_id . ")")->fetchObject(); $ccmail = null; if ($cc_id) { $cc = $employee->getAdapter()->query("select group_concat(email) as mail_to from oa_employee where id in ( " . $cc_id . ")")->fetchObject(); $ccmail = $cc->mail_to; } if ($updFlg == 'add') { $title = "新任务提示"; $content = $user_name . "创建了新任务 " . $record['title']; } else { if ($updFlg == 'update') { $title = "任务更新提示"; $content = $user_name . "更新了任务 " . $record['title']; } else { $title = "任务删除提示"; $content = $user_name . "删除了任务 " . $record['title']; } } $content .= "<p><b>任务名称:</b>" . $record['title'] . "</p>"; $content .= "<p><b>当前状态:</b>" . $record['state'] . "</p>"; $content .= "<p><b>任务时间:</b>" . $record['start'] . "到" . $record['end'] . "</p>"; $content .= "<p><b>任务描述:</b>" . $record['notes'] . "</p>"; $content .= "<p><b>重要程度:</b>" . $record['important'] . "</p>"; $content .= "<p><b>优先级:</b>" . $record['priority'] . "</p>"; $content .= "<p><b>协作模式:</b>" . $record['type'] . "</p>"; $creater = $employee->getById($record['create_user']); $content .= "<p><b>创建人:</b>" . $creater['cname'] . "</p>"; $content .= "<p><b>创建时间:</b>" . $record['create_time'] . "</p>"; $content .= "<p><b>进度</b></p>"; foreach ($pro as $p) { $content .= "<p> "; if ($record['type'] == '协作') { $content .= $p['cname'] . " "; } $content .= $p['update_time'] . " " . $p['status'] . " " . $p['rate'] . "% " . $p['remark'] . "</p>"; } $mailData = array('type' => '任务', 'subject' => $title, 'to' => $to->mail_to, 'cc' => $ccmail, 'content' => $content, 'send_time' => $now, 'add_date' => $now); $mailId = $mail->insert($mailData); if ($mailId) { $mail->send($mailId); } }