/**
  * 上传图片 for xhEditor.
  *
  * @Route("image_upload_for_xheditor", name="site_common_image_upload_for_xheditor")
  */
 public function imageUploadAction()
 {
     if ($img_save_path = ImageUpload::handleUpload(trim($this->getRequestItem('name')))) {
         return new JsonResponse(['err' => '', 'msg' => ['url' => '/' . $img_save_path]]);
     }
     return new JsonResponse(['err' => '上传错误', 'msg' => []]);
 }
 /**
  * 联系人执行更新.
  *
  * @Route("/update", name="site_admin_human_update")
  */
 public function updateAction()
 {
     if ($redirect = $this->ifNotLoginedRedirect()) {
         return $redirect;
     }
     $id = intval($this->getRequestItem('id'));
     $admin_id = intval($this->getRequestItem('admin_id', 0));
     $relation_ids = $this->getRequestItem('relation_ids', []);
     $name = trim($this->getRequestItem('name'));
     $ename = trim($this->getRequestItem('ename'));
     $sex = intval($this->getRequestItem('sex', 3));
     $favicon = trim($this->getRequestItem('favicon'));
     $birthday1 = trim($this->getRequestItem('birthday1'));
     $birthday2 = trim($this->getRequestItem('birthday2'));
     $native_place = trim($this->getRequestItem('native_place'));
     $address = trim($this->getRequestItem('address'));
     $education = trim($this->getRequestItem('education'));
     $school = trim($this->getRequestItem('school'));
     $vocation = trim($this->getRequestItem('vocation'));
     $company = trim($this->getRequestItem('company'));
     $phones = trim($this->getRequestItem('phones'));
     $social_account = trim($this->getRequestItem('social_account'));
     $remarks = trim($this->getRequestItem('remarks'));
     $order_no = intval($this->getRequestItem('order_no', 0));
     $status = intval($this->getRequestItem('status', 1));
     if (empty($id)) {
         return new JsonResponse(['statusCode' => 300, 'message' => '没有传递ID']);
     }
     if (empty($admin_id)) {
         return new JsonResponse(['statusCode' => 300, 'message' => '关联者不能为空']);
     }
     if (empty($relation_ids)) {
         return new JsonResponse(['statusCode' => 300, 'message' => '关系不能为空']);
     }
     if (empty($name)) {
         return new JsonResponse(['statusCode' => 300, 'message' => '姓名不能为空']);
     }
     if (!in_array($sex, [1, 2, 3])) {
         return new JsonResponse(['statusCode' => 300, 'message' => '性别非法']);
     }
     if (!in_array($status, [1, 2])) {
         return new JsonResponse(['statusCode' => 300, 'message' => '状态非法']);
     }
     $human = $this->getOneDataById('SiteCommonBundle:Humans', $id);
     $human->setAdminId($admin_id);
     $human->setRelationIds(implode(',', $relation_ids));
     $human->setName($name);
     $human->setEname($ename);
     $human->setSex($sex);
     $human->setFavicon(ImageUpload::handleUpload('favicon_file') ?: $favicon);
     $human->setBirthday1(strtotime($birthday1));
     $human->setBirthday2(strtotime($birthday2));
     $human->setNativePlace($native_place);
     $human->setAddress(json_encode($this->stringToArray($address)));
     $human->setEducation($education);
     $human->setSchool(json_encode($this->stringToArray($school)));
     $human->setVocation($vocation);
     $human->setCompany(json_encode($this->stringToArray($company)));
     $human->setPhones(json_encode($this->stringToArray($phones)));
     $human->setSocialAccount(json_encode($this->stringToArray($social_account)));
     $human->setRemarks($remarks);
     $human->setOrderNo($order_no);
     $human->setStatus($status);
     $human->setUtime($this->getNowTime());
     $this->saveDataChange($human);
     $this->saveAdminLog("<font color='blue'>修改</font> 联系人(id: {$id}, name: {$name})");
     return new JsonResponse(['statusCode' => 200, 'message' => '修改成功', 'callbackType' => 'closeCurrent']);
 }