public function deleteDeptAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get("we_data_access_im");
     $request = $this->getRequest();
     $deptid = $request->get("dept_id");
     //此处为fafa_deptid
     //返回参数
     $success = true;
     $msg = "";
     try {
         //判断是否有下级部门
         $sql = "select count(*) number from im_base_dept where pid=?";
         $ds = $da_im->GetData("table", $sql, array((string) $deptid));
         if ($ds && $ds["table"]["recordcount"] > 0) {
             $count = $ds["table"]["rows"][0]["number"];
             if ($count > 0) {
                 $success = false;
                 $msg = "不能删除具有下级部门的部门!";
             } else {
                 $sql = "select count(*) number from im_employee where deptid=?;";
                 $ds = $da_im->GetData("table", $sql, array((string) $deptid));
                 if ($ds && $ds["table"]["recordcount"] > 0) {
                     $count = $ds["table"]["rows"][0]["number"];
                     if ($count > 0) {
                         $success = false;
                         $msg = "该部门底下有人员,不允许删除 !";
                     } else {
                         $deptinfo = $this->getDeptInfo($deptid);
                         $deptMrg = new \Justsy\BaseBundle\Management\Dept($da, $da_im, $this->container);
                         $deptdata = $deptMrg->getinfo($deptinfo["deptid"]);
                         //删除部门数据
                         $sql = "delete from we_department where fafa_deptid=?";
                         $da->ExecSQL($sql, array((string) $deptid));
                         //删除im部门
                         $sql_pid = "select pid from im_base_dept where deptid=?;";
                         try {
                             $ds_pid = $da_im->GetData("table", $sql_pid, array((string) $deptid));
                             if ($ds_pid && $ds_pid["table"]["recordcount"] > 0) {
                                 $deptdata["pid"] = $ds_pid["table"]["rows"][0]["pid"];
                             }
                         } catch (\Exception $e) {
                             $deptdata["pid"] = "";
                         }
                         $sql = "delete from im_base_dept where deptid=?;";
                         $da_im->ExecSQL($sql, array((string) $deptid));
                         $msg = "删除部门数据成功!";
                         $parameter = array("flag" => "all", "title" => "removeDept", "message" => json_encode($deptdata), "container" => $this->container);
                         $sendMessage = new SendMessage($da, $da_im);
                         $sendMessage->sendImMessage($parameter);
                     }
                 }
             }
         } else {
             $success = false;
             $msg = "删除部门记录失败,请重试!";
         }
     } catch (\Exception $e) {
         $success = false;
         $this->get("logger")->err($e->getMessage());
         $msg = "删除部门记录失败,请重试!";
     }
     //返回的数据
     $result = array("success" => $success, "msg" => $msg);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Esempio n. 2
0
 private function sendPresence()
 {
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $my_jid = $this->get('security.context')->getToken()->getUser()->fafa_jid;
     //操作成功发送出席
     $sendMessage = new SendMessage($da, $da_im);
     $parameter = array("flag" => "online", "title" => "portal_publish", "message" => "approlechange", "container" => $this->container, "formjid" => $my_jid);
     $sendMessage->sendImPresence($parameter);
 }