예제 #1
0
 function _before_insert(&$data, $options)
 {
     $type = $data["type"];
     $dept_id = get_dept_id();
     $data['dept_id'] = $dept_id;
     $data['dept_name'] = get_dept_name();
     $data['emp_no'] = get_emp_no();
     $doc_no_format = M("FlowType")->where("id={$type}")->getField("doc_no_format");
     $short_dept = M("Dept")->where("id={$dept_id}")->getField('short');
     $short_flow = M("FlowType")->where("id={$type}")->getField('short');
     $sql = "SELECT count(*) count FROM `" . $this->tablePrefix . "flow` WHERE type={$type} ";
     $sql .= " and year(FROM_UNIXTIME(create_time))>=year(now())";
     if (strpos($doc_no_format, "{DEPT}") !== false) {
         $sql .= " and dept_id=" . get_dept_id();
     }
     $rs = $this->db->query($sql);
     $count = $rs[0]['count'] + 1;
     if (strpos($doc_no_format, "{DEPT}") !== false) {
         $doc_no_format = str_replace("{DEPT}", $short_dept, $doc_no_format);
     }
     if (strpos($doc_no_format, "{SHORT}") !== false) {
         $doc_no_format = str_replace("{SHORT}", $short_flow, $doc_no_format);
     }
     if (strpos($doc_no_format, "{YYYY}") !== false) {
         $doc_no_format = str_replace("{YYYY}", date('Y', mktime()), $doc_no_format);
     }
     if (strpos($doc_no_format, "{YY}") !== false) {
         $doc_no_format = str_replace("{YY}", date('y', mktime()), $doc_no_format);
     }
     if (strpos($doc_no_format, "{M}") !== false) {
         $doc_no_format = str_replace("{M}", date('m', mktime()), $doc_no_format);
     }
     if (strpos($doc_no_format, "{D}") !== false) {
         $doc_no_format = str_replace("{D}", date('d', mktime()), $doc_no_format);
     }
     if (strpos($doc_no_format, "{#}") !== false) {
         $doc_no_format = str_replace("{#}", str_pad($count, 1, "0", STR_PAD_LEFT), $doc_no_format);
     }
     if (strpos($doc_no_format, "{##}") !== false) {
         $doc_no_format = str_replace("{##}", str_pad($count, 2, "0", STR_PAD_LEFT), $doc_no_format);
     }
     if (strpos($doc_no_format, "{###}") !== false) {
         $doc_no_format = str_replace("{###}", str_pad($count, 3, "0", STR_PAD_LEFT), $doc_no_format);
     }
     if (strpos($doc_no_format, "{####}") !== false) {
         $doc_no_format = str_replace("{####}", str_pad($count, 4, "0", STR_PAD_LEFT), $doc_no_format);
     }
     if (strpos($doc_no_format, "{#####}") !== false) {
         $doc_no_format = str_replace("{#####}", str_pad($count, 5, "0", STR_PAD_LEFT), $doc_no_format);
     }
     if (strpos($doc_no_format, "{######}") !== false) {
         $doc_no_format = str_replace("{######}", str_pad($count, 6, "0", STR_PAD_LEFT), $doc_no_format);
     }
     $data['doc_no'] = $doc_no_format;
 }
 /** 插入新新数据  **/
 protected function _update()
 {
     $model = D("MonthlyReport");
     if (false === $model->create()) {
         $this->error($model->getError());
     }
     if (in_array('user_id', $model->getDbFields())) {
         $model->user_id = get_user_id();
     }
     if (in_array('user_name', $model->getDbFields())) {
         $model->user_name = get_user_name();
     }
     if (in_array('dept_id', $model->getDbFields())) {
         $model->dept_id = get_dept_id();
     }
     if (in_array('dept_name', $model->getDbFields())) {
         $model->dept_name = get_dept_name();
     }
     $model->create_time = time();
     /*保存当前数据对象 */
     $list = $model->save();
     if ($list !== false) {
         //保存成功
         $this->assign('jumpUrl', get_return_url());
         $this->success('保存成功!');
     } else {
         $this->error('保存失败!');
         //失败提示
     }
 }
echo get_user_tel();
?>
 </td>
					    </tr>
					</table>
				</div>
				<div class="username">
					<a href="<?php 
echo U('grzhongxin/index');
?>
" style="color:#fff"><?php 
echo session('user_name');
?>
</a>
					<!-- <?php 
echo get_dept_name();
?>
 -->
					 |&nbsp;
					<a href="<?php 
echo U('login/logout');
?>
" style="color:#fff">退出</a>
				</div>
			</div>
		</div><!-- #header -->
		<div class="main-container" id="main-container">
			<div class="main-container-inner">
				<div class="sidebar" id="sidebar">	
					<!-- <div id="user_info" class="text-center hidden-xs"  >
						<span >当前用户:<?php 
 /**
  * 添加日志
  * @param int $uid
  * @param string $content 今日总结
  * @param string $plan 计划
  * @param string $feedback 问题反馈
  * @param int $time
  * @param int $type 1为安卓 2为ios
  */
 public function addLog()
 {
     $uid = UID;
     // $uid=$_REQUEST['uid'];
     $content = $_REQUEST['content'];
     // $plan=$_REQUEST['plan'];
     // $feedback=$_REQUEST['feedback'];
     $time = NOW_TIME;
     $type = $_REQUEST['type'] ? $_REQUEST['type'] : 1;
     //		if($type!=1){
     //			$content=base64_decode($content);
     //			$plan=base64_decode($plan);
     //			$feedback=base64_decode($feedback);
     //		}
     $model = D('work_log');
     $data = array('user_id' => $uid, 'user_name' => get_user_name(), 'dept_id' => get_dept_id(), 'dept_name' => get_dept_name(), 'create_time' => time(), 'content' => $content ? $content : '', 'start_date' => date('Y-m-d', $time), 'end_date' => date('Y-m-d', $time));
     $res = $model->add($data);
     if ($res) {
         $this->result('1', '添加成功!');
     } else {
         $this->result('0', '未知错误!');
     }
 }
예제 #5
0
 public function mine()
 {
     $widget['date-range'] = true;
     $this->assign("widget", $widget);
     $this->assign('user_id', get_user_id());
     $this->assign("title", '日志查询');
     $auth = $this->config['auth'];
     $this->assign('auth', $auth);
     if ($_GET['id']) {
         $id = $_GET['id'];
         $this->assign("XIN", 0);
     } else {
         $id = get_user_id();
         $this->assign("XIN", 1);
     }
     if ($auth['admin']) {
         $rolein = false;
         $role = D('role_user')->where('user_id = ' . get_user_id())->field('role_id')->select();
         for ($i = 0; $i < count($role); $i++) {
             if ($role[$i]['role_id'] == 1 || $role[$i]['role_id'] == 12) {
                 $rolein = true;
                 continue;
             }
         }
         $node = D("Dept");
         $dept_id = get_dept_id();
         $dept_name = get_dept_name();
         $menu = array();
         $dept_menu = $node->field('id,pid,name')->where("is_del=0")->order('sort asc')->select();
         if ($rolein) {
             $dept_tree = list_to_tree($dept_menu);
         } else {
             $dept_tree = list_to_tree($dept_menu, $dept_id);
         }
         $count = count($dept_tree);
         //            dump(get_user_id());
         //            exit;
         if (empty($count)) {
             /*获取部门列表*/
             $html = '';
             $html = $html . "<option value='{$dept_id}'>{$dept_name}</option>";
             $this->assign('dept_list', $html);
             /*获取人员列表*/
             $where['dept_id'] = array('eq', $dept_id);
             $emp_list = D("User")->where($where)->getField('id,emp_name');
             //				$this->assign('emp_list',$emp_list);
         } else {
             /*获取部门列表*/
             $this->assign('dept_list', select_tree_menu($dept_tree));
             $dept_list = tree_to_list($dept_tree);
             $dept_list = rotate($dept_list);
             $dept_list = $dept_list['id'];
             /*获取人员列表*/
             $where['dept_id'] = array('in', $dept_list);
             $emp_list = D("User")->where($where)->getField('id,emp_name');
             //				$this->assign('emp_list',$emp_list);
         }
     }
     $map = $this->_search();
     $map['user_id'] = $id;
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($map);
     }
     $model = D("WorkLog");
     if (!empty($model)) {
         $this->_list($model, $map);
         //			$this -> _list($model,'');
     }
     $this->assign("uid", $id);
     $this->display();
 }
 /**
  * 添加日志
  * @param int $uid
  * @param string $content 今日总结
  * @param string $plan 计划
  * @param string $feedback 问题反馈
  * @param int $time
  * @param int $type 1为安卓 2为ios
  */
 public function addLog()
 {
     $uid = $_REQUEST('uid');
     $content = $_REQUEST('content');
     $plan = $_REQUEST('plan');
     $feedback = $_REQUEST('feedback');
     $time = $_REQUEST('time');
     $type = $_REQUEST('type') ? $_REQUEST('type') : 1;
     if ($type != 1) {
         $content = base64_decode($content);
         $plan = base64_decode($plan);
         $feedback = base64_decode($feedback);
     }
     $model = D('work_log');
     $data = array('user_id' => $uid, 'user_name' => get_user_name(), 'dept_id' => get_dept_id(), 'dept_name' => get_dept_name(), 'create_time' => time(), 'content' => $content ? $content : '', 'plan' => $plan ? $plan : '', 'feedback' => $feedback ? $feedback : '', 'start_date' => date('Y-m-d', $time), 'end_date' => date('Y-m-d', $time));
     $res = $model->add($data);
     if ($res) {
         $this->result('1', '添加成功!');
     } else {
         $this->result('0', '未知错误!');
     }
 }
 /**
  * 添加 AND 临时保存  草稿箱修改公文 
  * @param unknown $doc_type 公文类型
  * @param unknown $doc_model 发文字号
  * @param unknown $doc_level 秘密等级
  * @param unknown $doc_acute 紧急程度
  * @param unknown $doc_title 公文标题	
  * @param unknown $doc_content 公文内容
  * @param unknown $doc_keyword 关键词
  * @param string $people_sh 传uid
  * @param string $people_qf 传uid
  * @param string $people_sj 传uid 多人逗号分隔
  * @param string $sid 附件id 多个附件 分号分割
  * @param int $type 1为安卓 2为ios
  * @param int $status 1 添加 2保存 3修改
  * @param int $flow_id 传入要修改的公文id
  */
 public function addAndEdditDoc()
 {
     // var_dump('5456656');
     // exit;
     $doc_type = $_REQUEST['doc_type'];
     $doc_model = $_REQUEST['doc_model'];
     $doc_level = $_REQUEST['doc_level'];
     $doc_acute = $_REQUEST['doc_acute'];
     $doc_title = $_REQUEST['doc_title'];
     $doc_content = $_REQUEST['doc_content'];
     $doc_keyword = $_REQUEST['keyword'];
     $people_sh = $_REQUEST['people_sh'];
     $people_qf = $_REQUEST['people_qf'];
     $people_sj = $_REQUEST['people_sj'];
     $sid = $_REQUEST['sid'];
     $type = $_REQUEST['type'];
     $status = $_REQUEST['status'];
     $id = $_REQUEST['flow_id'];
     $flow = M('flow');
     if ($type == 2) {
         $doc_type = base64_decode($doc_type);
         $doc_level = base64_decode($doc_level);
         $doc_model = base64_decode($doc_model);
         $doc_acute = base64_decode($doc_acute);
         $doc_title = base64_decode($doc_title);
         $doc_content = base64_decode($doc_content);
         $doc_keyword = base64_decode($doc_keyword);
     }
     $str = '';
     $peopel_sj = explode(',', $people_sj);
     for ($i = 0; $i < count($peopel_sj); $i++) {
         $str .= get_userName($peopel_sj[$i]) . "|";
         $html = '<span>' . get_userName($peopel_sj[$i]) . '</span>';
     }
     $id = get_user_id();
     $data = array('docNo' => $doc_model, 'name' => $doc_title, 'content' => $doc_content, 'drafter_name' => get_user_name(), 'confirm' => get_userName($people_sh) . '|', 'confirm_name' => get_userName($people_sh), 'consult' => get_userName($people_qf), 'consult_name' => get_userName($people_qf), 'refer' => $str, 'refer_name' => $html, 'add_file' => $sid, 'user_id' => get_user_id(), 'emp_no' => get_userEmpNo($id), 'user_name' => get_user_name(), 'dept_id' => get_dept_id(), 'dept_name' => get_dept_name(), 'create_time' => time(), 'update_time' => 0, 'step' => $status == 1 ? 20 : 10, 'is_del' => 0, 'doc_type' => $doc_type, 'doc_level' => $doc_level, 'doc_acute' => $doc_acute);
     // var_dump($data);
     // exit;
     $res = $flow->add($data);
     if ($status <= 2) {
         if ($res) {
             $log_data = array('flow_id' => $res, 'emp_no' => get_userName($people_sh), 'step' => 21, 'create_time' => time(), 'update_time' => time(), 'is_del' => 0);
             M('flow_log')->add($log_data);
             $this->result('1', '添加成功!');
         } else {
             $this->result('0', '未知错误!');
         }
     } else {
         if ($status > 2) {
             $info = M('Flow')->where(array('id' => $id))->save($data);
             if ($info) {
                 $this->result('1', '保存成功!');
             } else {
                 $this->result('0', '失败!');
             }
         }
     }
 }