Exemple #1
0
 public function commit($parameters)
 {
     if (empty($parameters)) {
         $result = Utils::WrapResultError("无效的数据");
         return $result;
     }
     $currUser = $parameters["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     $audit_staffs = $parameters["audit_staffs"];
     //审批人。多个审批人使用;分隔
     if (empty($audit_staffs)) {
         return Utils::WrapResultError("审批人不能为空");
     }
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     try {
         $content = $currUser->nick_name . "申请请假" . $parameters["days"] . "天";
         //创建新流程
         $result = $wfl->createWorkflow(array("appid" => $parameters["appid"], "user" => $currUser, "to" => $audit_staffs, "wf_name" => "请假申请", "wf_content" => $content, "wf_type" => $wf_type, "attachment" => $parameters["attachment"]));
         if (!empty($result)) {
             try {
                 //写业务表
                 $apply_id = SysSeq::GetSeqNextValue($this->conn, "we_app_apply_leave", "id");
                 $sql = "insert into we_app_apply_leave(id,wf_id,leavetype,start_date,end_date,days,reason,create_datetime,staff,eno,appid)values(?,?,?,?,?,?,?,now(),?,?,?)";
                 $this->conn->ExecSQL($sql, array((string) $apply_id, (string) $result["wf_id"], (string) $parameters["leavetype"], (string) $parameters["start_date"], (string) $parameters["end_date"], (double) $parameters["days"], (string) $parameters["reason"], (string) $currUser->getUserName(), (string) $currUser->eno, (string) $parameters["appid"]));
             } catch (\Exception $e) {
                 $wfl->removeWorkflow(array("wf_id" => $result["wf_id"]));
                 throw new \Exception($e);
             }
             //获取审批人的jid
             $to = explode(";", $audit_staffs);
             $tojids = array();
             for ($i = 0; $i < count($to); $i++) {
                 $staff = new Staff($this->conn, $this->conn_im, $to[$i], $this->logger, $this->container);
                 $staffdata = $staff->getInfo();
                 if (empty($staffdata)) {
                     continue;
                 }
                 $tojids[] = $staffdata["fafa_jid"];
             }
             //向审批人发送消息
             Utils::sendImMessage("", $tojids, "bus_apply", json_encode($re), $this->container, "", "", false, '', '0');
         }
         return $result;
     } catch (\Exception $e) {
         $this->logger->err($e);
         $result = Utils::WrapResultError($e->getMessage());
     }
     return $result;
 }
Exemple #2
0
 public function joinapply($paraObj)
 {
     $currUser = $paraObj["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     if ($currUser->eno != Utils::$PUBLIC_ENO) {
         return Utils::WrapResultError("你已成功加入企业,不能再提交加入请求");
     }
     //判断用户是否已提交过加入申请
     //没有等待处理中的申请或者已被拒绝时才能申请新的加入企业
     $paraObj["submit_staff"] = $currUser->getUsername();
     $paraObj["wf_type"] = "WF_EN_JOIN";
     $nodeinfo = $wfl->getNode($paraObj);
     if (!empty($nodeinfo) && $nodeinfo["status"] != "0" && $nodeinfo["status"] != "-1") {
         return Utils::WrapResultError($nodeinfo["status"] == "9" ? "你已提交过请求,请等待企业审核" : "你请求的企业已同意你加入,不能再提交请求");
     }
     $joineno = $paraObj["eno"];
     if (empty($joineno)) {
         $joineno = $paraObj["ename"];
         if (empty($joineno)) {
             return Utils::WrapResultError("未指定申请加入的企业");
         }
         $endata = $this->getInfoByName($joineno);
         if (empty($endata)) {
             return Utils::WrapResultError("无效的企业名称");
         }
         $joineno = $endata["eno"];
     } else {
         $endata = $this->getInfo($joineno);
         if (empty($endata)) {
             return Utils::WrapResultError("无效的企业编号");
         }
     }
     $to = $endata["sys_manager"];
     if (empty($to)) {
         $to = $endata["create_staff"];
     }
     if (empty($to)) {
         return Utils::WrapResultError("该企业未指定管理员");
     }
     $message = $paraObj["user"]->nick_name . "请求加入企业";
     $re = $wfl->createWorkflow(array("appid" => $joineno, "user" => $paraObj["user"], "to" => $to, "wf_name" => "新员工请求加入企业", "wf_content" => $message, "wf_type" => "WF_EN_JOIN"));
     if ($re) {
         Utils::sendImMessage("", explode(";", $to), "enterprise_joinapply", json_encode($re), $this->container, "", "", true, '', '0');
         $re = $wfl->getNode(array("node_id" => $re["node_id"]));
         $re["eno"] = $joineno;
         $re["ename"] = $endata["ename"];
         $re["logo_path"] = $endata["logo_path"];
     }
     return Utils::WrapResultOK($re);
 }