public function commit($parameters) { if (empty($parameters)) { $result = Utils::WrapResultError("无效的数据"); return $result; } $currUser = $parameters["user"]; if (empty($currUser)) { return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN); } try { //写业务表 $apply_id = SysSeq::GetSeqNextValue($this->conn, "we_app_notice", "id"); $sql = "insert into we_app_notice(id,title,content,author,publishdate,publishstaff,publisharea,isprivate,status,eno,appid)values(?,?,?,?,now(),?,?,?,'1',?,?)"; $this->conn->ExecSQL($sql, array((string) $apply_id, (string) $parameters["title"], (string) $parameters["content"], (string) $currUser->getUserName(), (string) $currUser->getUserName(), (string) $parameters["publisharea"], (string) $parameters["isprivate"], (string) $currUser->eno, (string) $parameters["appid"])); //消息内容 $message_body = array("appid" => $parameters["appid"], "title" => $parameters["title"], "id" => $apply_id); //获取发布范围内的人员jid $toDept = explode(",", $parameters["publisharea"]); $tojids = array(); $deptMgr = new Dept($this->conn, $this->conn_im, $this->container); for ($i = 0; $i < count($toDept); $i++) { //获取部门下的所有人员jid $staffjid = $deptMgr->getAllStaffJid($toDept[$i]); for ($i = 0; $i < count($staffjid); $i++) { $tojids[] = $staffjid[$i]["jid"]; if (count($tojids) >= 500) { //向审批人发送消息,一次性最多推送500个帐号 Utils::sendImMessage("", $tojids, "bus_app_msgpush", json_encode($message_body), $this->container, "", "", false, '', '0'); $tojids = array(); } } } if (count($tojids) > 0) { //向审批人发送消息 Utils::sendImMessage("", $tojids, "bus_app_msgpush", json_encode($message_body), $this->container, "", "", false, '', '0'); } $result = Utils::WrapResultOK(""); } catch (\Exception $e) { $this->logger->err($e); $result = Utils::WrapResultError($e->getMessage()); } return $result; }
public function deptchange($deptid) { $conn_im = $this->containter->get("we_data_access_im"); if (empty($deptid)) { return; } $dept = new Dept($this->da, $conn_im, $this->containter); $deptinfo = $dept->getinfo(is_string($deptid) ? $deptid : $deptid['dept_id']); $paths = explode('/', $deptinfo["path"]); if (count($paths) == 0) { return; } foreach ($paths as $key => $value) { if (empty($value)) { continue; } $this->updatedeptversion($value); } }
public function RemoveDefaultGroupMember($parameter) { try { $deptid = isset($parameter["deptid"]) ? $parameter["deptid"] : null; if (empty($deptid)) { return false; } $da = $this->conn; $da_im = $this->conn_im; $deptMgr = new Dept($da, $da_im, $this->container); $ds = $deptMgr->getinfo($deptid); if (!empty($ds)) { $deptid = $ds["fafa_deptid"]; $groupids = $deptMgr->getDeptDefaultGroup($deptid); if (!empty($groupids) && count($groupids) > 0) { $jid = $parameter["jid"]; $group_parameter = array(); for ($i = 0; $i < count($groupids); $i++) { $group_parameter["jid"] = $jid; $group_parameter["groupid"] = $groupids[$i]["groupid"]; $this->delGroupMember($group_parameter); } } } return true; } catch (\Exception $e) { $this->logger->err($e); return false; } }
public function export($paramObj) { $hosturl = $_SERVER['HTTP_HOST']; $now = date('Ymd'); $dir = explode('src', __DIR__); $source = $dir[0] . 'web/EN_Hr_attendanceTemplate.xls'; $tmpFile = $dir[0] . 'web/upload/attendance' . $now . '.xls'; if (file_exists($tmpFile)) { //return Utils::WrapResultOK($hosturl.'/upload/attendance'.$now.'.xls'); } $user = $paramObj['user']; $ymd = $paramObj['ymd']; if (empty($ymd)) { $ymd = date('Y-m-d'); } $deptid = $paramObj['deptid']; if (empty($deptid)) { $dept_name = '公司全员'; } else { $deptMgr = new Dept($this->conn, $this->conn_im, $this->container); $deptdata = $deptMgr->getInfo($deptid); $dept_name = $deptdata['deptname']; } $all = $paramObj['all']; //应考勤人数 $attendanced = $paramObj['attendanced']; //实际考勤人数 $delay = $paramObj['delay']; //迟到人数 $notattendance = $paramObj['notattendance']; //未考勤人数 @copy($source, $tmpFile); $objReader = \PHPExcel_IOFactory::createReader('Excel5'); $objPHPExcel = $objReader->load($tmpFile); $objPHPExcel->setActiveSheetIndex(0); $objWorksheet = $objPHPExcel->getActiveSheet(); $str = '考勤统计'; //iconv('gb2312', 'utf-8', '考勤统计'); $objWorksheet->setTitle($str); $objPHPExcel->setActiveSheetIndex(1); $objWorksheet = $objPHPExcel->getActiveSheet(); $str = '实际考勤人数明细'; //iconv('gb2312', 'utf-8', '实际考勤人数明细'); $objWorksheet->setTitle($str); $objPHPExcel->setActiveSheetIndex(2); $objWorksheet = $objPHPExcel->getActiveSheet(); $str = '未考勤人数明细'; //iconv('gb2312', 'utf-8', '未考勤人数明细'); $objWorksheet->setTitle($str); $objPHPExcel->setActiveSheetIndex(3); $objWorksheet = $objPHPExcel->getActiveSheet(); $str = '迟到考勤人数明细'; //iconv('gb2312', 'utf-8', '迟到考勤人数明细'); $objWorksheet->setTitle($str); $objPHPExcel->setActiveSheetIndex(0); $objWorksheet = $objPHPExcel->getActiveSheet(); //写入部门和日期 $objWorksheet->unmergeCells('F3:I3'); $objWorksheet->unmergeCells('J3:L3'); $objWorksheet->setCellValue('F3', $dept_name); $objWorksheet->setCellValue('J3', $ymd); $objWorksheet->mergeCells('F3:I3'); $objWorksheet->mergeCells('J3:L3'); //统计 人 $objWorksheet->setCellValue('K27', $user->nick_name); //写入应考勤人数 $objWorksheet->setCellValue('G10', $all); //实际考勤人数 $objWorksheet->setCellValue('K10', $attendanced); //未考勤人数 $objWorksheet->setCellValue('G16', $notattendance); //迟到考勤人数 $objWorksheet->setCellValue('K16', $delay); $objWorksheet->setCellValue('G22', '—'); $objWorksheet->setCellValue('K22', '—'); $paramObj['pageIndex'] = 1; $paramObj['limit'] = 1000000; //判断是否需要导入实际考勤明细 $expFlag = isset($paramObj['expdetail_attendanced']) ? (int) $paramObj['expdetail_attendanced'] : 0; if ($expFlag === 1) { $objPHPExcel->setActiveSheetIndex(1); $objWorksheet = $objPHPExcel->getActiveSheet(); $data = $this->getAllAttend($paramObj); $i = 3; foreach ($data['data'] as $key => $value) { $objWorksheet->setCellValue('A' . $i, $i - 2); $objWorksheet->setCellValue('B' . $i, $value['nick_name']); $objWorksheet->setCellValue('C' . $i, $value['dept_name']); $objWorksheet->setCellValue('D' . $i, $value['mobile_bind']); $objWorksheet->setCellValue('E' . $i, $value['state']); $i++; } } //判断是否需要未考勤明细 $expFlag = isset($paramObj['expdetail_notattendanced']) ? (int) $paramObj['expdetail_notattendanced'] : 0; if ($expFlag === 1) { $data = $this->getNoAtten($paramObj); $objPHPExcel->setActiveSheetIndex(2); $objWorksheet = $objPHPExcel->getActiveSheet(); $i = 3; foreach ($data['data'] as $key => $value) { $objWorksheet->setCellValue('A' . $i, $i - 2); $objWorksheet->setCellValue('B' . $i, $value['nick_name']); $objWorksheet->setCellValue('C' . $i, $value['dept_name']); $objWorksheet->setCellValue('D' . $i, $value['mobile_bind']); $objWorksheet->setCellValue('E' . $i, 'state'); $i++; } } //判断是否需要迟到考勤明细 $expFlag = isset($paramObj['expdetail_delay']) ? (int) $paramObj['expdetail_delay'] : 0; if ($expFlag === 1) { $data = $this->getAllLate($paramObj); $objPHPExcel->setActiveSheetIndex(3); $objWorksheet = $objPHPExcel->getActiveSheet(); $i = 3; foreach ($data['data'] as $key => $value) { $objWorksheet->setCellValue('A' . $i, $i - 2); $objWorksheet->setCellValue('B' . $i, $value['nick_name']); $objWorksheet->setCellValue('C' . $i, $value['dept_name']); $objWorksheet->setCellValue('D' . $i, $value['mobile_bind']); $objWorksheet->setCellValue('E' . $i, $value['state']); $objWorksheet->setCellValue('F' . $i, $value['atten_date']); $i++; } } \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5')->save($tmpFile); //根据需要也可以是 Excel2007 //获取协议 $http = $_SERVER['HTTPS'] != 'on' ? 'http://' : 'https://'; return Utils::WrapResultOK($http . $hosturl . '/upload/attendance' . $now . '.xls'); }
public function atten_service($parameter) { try { $deptid = $parameter["deptid"]; $eno = $parameter["eno"]; $login_account = $parameter["jid"]; if ($deptid == "v" . $eno) { $sql = "select login_account from we_service where objid=? and type=1;"; $ds = $this->conn->GetData("table", $sql, array((string) $deptid)); if ($ds && $ds["table"]["recordcount"] > 0) { for ($i = 0; $i < $ds["table"]["recordcount"]; $i++) { $service = $ds["table"]["rows"][$i]["login_account"]; $sql = "insert into im_microaccount_memebr(employeeid,microaccount,lastreadid,subscribedate)values(?,?,(select max(id) from im_microaccount_msg where microaccount=?),now())"; $para = array((string) $login_account, (string) $service, (string) $service); try { $this->conn_im->ExecSQL($sql, $para); } catch (\Exception $e) { $this->logger->err($e->getMessage()); } } } } else { //获取当前部门的所有上级部门 $deptMgr = new Dept($this->conn, $this->conn_im, $this->container); $deptdata = $deptMgr->getInfo($deptid); if (empty($deptdata)) { return; } $path = str_replace('/-10000/v' . $eno . '/', '', rtrim($deptdata['path'], '/')); $path = explode('/', $path); //获取这些部门关联的公众号 $sql = "select login_account from we_service where objid in('" . implode("','", $path) . "') and type=1;"; $ds = $this->conn->GetData("table", $sql, array()); if ($ds && $ds["table"]["recordcount"] > 0) { for ($i = 0; $i < $ds["table"]["recordcount"]; $i++) { $service = $ds["table"]["rows"][$i]["login_account"]; $sql = "insert into im_microaccount_memebr(employeeid,microaccount,lastreadid,subscribedate)values(?,?,(select max(id) from im_microaccount_msg where microaccount=?),now())"; $para = array((string) $login_account, (string) $service, (string) $service); try { $this->conn_im->ExecSQL($sql, $para); } catch (\Exception $e) { $this->logger->err($e->getMessage()); } } } } } catch (\Exception $e) { $this->logger->err($e); } }
public function queryAllCount($paramObj) { $deptid = isset($paramObj['deptid']) ? $paramObj['deptid'] : ''; $info = $this->getInfo(); $eno = $info["eno"]; $edomain = $this->container->getParameter("edomain"); $deptObj = new Dept($this->conn, $this->conn_im, $this->container); if (empty($deptid)) { $sql = 'select count(1) cnt from im_employee where loginname like concat(\'%\',?) '; $result = $this->conn_im->GetData('t', $sql, array($eno . '@' . $edomain)); $result = $result['t']['rows']; } else { $deptdata = $deptObj->getinfo($deptid); $path = $deptdata['path']; $sql = 'select count(1) cnt from im_employee a,im_base_dept b where a.deptid=b.deptid and b.path like concat(?,\'%\') and a.loginname like concat(\'%\',?) '; $result = $this->conn_im->GetData('t', $sql, array((string) $path, $eno . '@' . $edomain)); $result = $result['t']['rows']; } return $result[0]['cnt']; }