SettingController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class SettingController extends DooController {
  6. public $staff = array ();
  7. public function beforeRun($resource, $action) {
  8. }
  9. function __construct() {
  10. if (isset ( $_COOKIE ["staff"] )) {
  11. if (! empty ( $_COOKIE ["staff"] )) {
  12. Doo::loadModel ( 'staff' );
  13. $staff = new staff ();
  14. $this->staff = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  15. return "/";
  16. }
  17. }
  18. Doo::loadCore ( 'uri/DooUriRouter' );
  19. $router = new DooUriRouter ();
  20. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  21. if ($routeRs ['1'] != "login") {
  22. header ( 'Content-Type:text/html;charset=utf-8' );
  23. @header ( "Location: /login" );
  24. }
  25. }
  26. /**
  27. * 员工信息
  28. */
  29. function settingEmployeeInfo() {
  30. Doo::loadModel ( 'staff' );
  31. $staff = new staff ();
  32. $isShowMsg = false;
  33. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  34. if ($detail ['telephone'] == "")
  35. $isShowMsg = true;
  36. if ($detail ['qq'] == "")
  37. $isShowMsg = true;
  38. if ($detail ['wecat'] == "")
  39. $isShowMsg = true;
  40. if ($detail ['phone'] == "")
  41. $isShowMsg = true;
  42. if ($detail ['email'] == "")
  43. $isShowMsg = true;
  44. if ($detail ['birthday'] == "")
  45. $isShowMsg = true;
  46. if ($detail ['marriage'] == "")
  47. $isShowMsg = true;
  48. if ($detail ['living'] == "")
  49. $isShowMsg = true;
  50. if ($detail ['nativePlace'] == "")
  51. $isShowMsg = true;
  52. if ($detail ['emergencyContacts'] == "")
  53. $isShowMsg = true;
  54. $this->data ['isShowMsg'] = $isShowMsg;
  55. $this->data ['staff'] = $this->staff;
  56. $this->data ['memu'] = "adminmyinfo";
  57. $this->data ['hrMemu'] = "settingEmployeeInfo";
  58. $this->render ( "/setting/settingEmployeeInfo", $this->data );
  59. }
  60. function settingAvatarInfo(){
  61. $this->data ['staff'] = $this->staff;
  62. $this->data ['memu'] = "adminmyinfo";
  63. $this->data ['hrMemu'] = "settingAvatarInfo";
  64. $this->render ( "/setting/settingAvatarInfo", $this->data );
  65. }
  66. /**
  67. * 证件信息
  68. */
  69. function settingCredentialInfo() {
  70. Doo::loadModel ( 'staff' );
  71. $staff = new staff ();
  72. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  73. $this->data ['staff'] = $this->staff;
  74. $this->data ['memu'] = "adminmyinfo";
  75. $this->data ['hrMemu'] = "settingEmployeeInfo";
  76. $this->render ( "/setting/settingCredentialInfo", $this->data );
  77. }
  78. /**
  79. * 财务信息
  80. */
  81. function settingFinanceInfo() {
  82. $this->data ['staff'] = $this->staff;
  83. $this->data ['memu'] = "adminmyinfo";
  84. $this->data ['hrMemu'] = "settingEmployeeInfo";
  85. $this->render ( "/setting/settingFinanceInfo", $this->data );
  86. }
  87. function settingPW() {
  88. $this->data ['msg'] = urldecode ( $this->params ['msg'] );
  89. $this->data ['staff'] = $this->staff;
  90. $this->data ['memu'] = "adminmyinfo";
  91. $this->data ['hrMemu'] = "settingPW";
  92. $this->render ( "/setting/settingPW", $this->data );
  93. }
  94. /*
  95. * 更新密码
  96. */
  97. function updateMyPW() {
  98. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  99. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  100. $rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";
  101. Doo::loadModel ( 'staff' );
  102. $staff = new staff ();
  103. Doo::loadModel ( 'staffDynamic' );
  104. $staffDynamic = new staffDynamic ();
  105. $staff->sid = $this->staff ['sid'];
  106. $msg = "更新成功";
  107. if ($this->staff ['passwork'] == md5 ( $oldpassword )) {
  108. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  109. $staff->passwork = md5 ( $newpassword );
  110. else
  111. $msg = "密码不一致";
  112. } else {
  113. if ($oldpassword != "")
  114. $msg = "密码错误";
  115. }
  116. $staff->update ( array (
  117. 'where' => ' sid=' . $this->staff ['sid']
  118. ) );
  119. return "/settingPW/" . $msg;
  120. }
  121. /**
  122. * 微信通知设置
  123. */
  124. function notificationConf() {
  125. Doo::loadModel ( "notificationConf" );
  126. $notificationConf = new notificationConf ();
  127. $detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );
  128. $rule = json_decode ( $detail ['conf'], true );
  129. if (! isset ( $rule ['approval'] ))
  130. $rule ['approval'] = '';
  131. if (! isset ( $rule ['print'] ))
  132. $rule ['print'] = '';
  133. if (! isset ( $rule ['receivables'] ))
  134. $rule ['receivables'] = '';
  135. $this->data ['rule'] = $rule;
  136. $this->data ['memu'] = "adminmyinfo";
  137. $this->data ['hrMemu'] = "notificationConf";
  138. $this->data ['staff'] = $this->staff;
  139. $this->render ( "/setting/invoiceNotificationConf", $this->data );
  140. }
  141. /**
  142. * 异步设置微信通知
  143. */
  144. function ajaxSetNotificationConf() {
  145. $notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";
  146. $notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';
  147. if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff ['sid'] )) {
  148. Doo::loadModel ( "notificationConf" );
  149. $notificationConf = new notificationConf ();
  150. $detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );
  151. if (empty ( $detail )) {
  152. $rule = array (
  153. $notificationType => $notificationValue
  154. );
  155. $rule = json_encode ( $rule );
  156. $item = array (
  157. 'sid' => $this->staff ['sid'],
  158. 'conf' => $rule
  159. );
  160. $notificationConf->addNotification ( $item );
  161. } else {
  162. $rule = json_decode ( $detail ['conf'], true );
  163. $rule [$notificationType] = $notificationValue;
  164. $rule = json_encode ( $rule );
  165. $item = array (
  166. 'nid' => $detail ['nid'],
  167. 'conf' => $rule
  168. );
  169. $notificationConf->setNotificationByCondition ( $item );
  170. }
  171. echo json_encode ( array (
  172. 'status' => 1,
  173. 'msgType' => $notificationType,
  174. 'msg' => ''
  175. ) );
  176. die ();
  177. }
  178. echo json_encode ( array (
  179. 'status' => 2,
  180. 'msgType' => $notificationType,
  181. 'msg' => 'illegal request'
  182. ) );
  183. die ();
  184. }
  185. /**
  186. * 更新员工信息
  187. */
  188. function staffUpdate() {
  189. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  190. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  191. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';
  192. //$position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  193. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';
  194. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  195. // $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  196. // $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  197. // $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  198. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  199. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
  200. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : 0;
  201. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  202. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  203. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  204. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  205. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '0';
  206. $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';
  207. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  208. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  209. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  210. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : '';
  211. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : '';
  212. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : '';
  213. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : '';
  214. $salaryCard = $this->get_args ( 'salaryCard' ) ? $this->get_args ( 'salaryCard' ) : '';
  215. $salaryBank = $this->get_args ( 'salaryBank' ) ? $this->get_args ( 'salaryBank' ) : '';
  216. $employeeInfo = $this->get_args ( 'employeeInfo' ) ? $this->get_args ( 'employeeInfo' ) : 'employeeInfo';
  217. $nation = $this->get_args ( 'nation' ) ? $this->get_args ( 'nation' ) : '';
  218. $graduateInstitutions = $this->get_args ( 'graduateInstitutions' ) ? $this->get_args ( 'graduateInstitutions' ) : '';
  219. $major = $this->get_args ( 'major' ) ? $this->get_args ( 'major' ) : '';
  220. $education = $this->get_args ( 'education' ) ? $this->get_args ( 'education' ) : '';
  221. $graduationTime = $this->get_args ( 'graduationTime' ) ? $this->get_args ( 'graduationTime' ) : '';
  222. $registeredResidence = $this->get_args ( 'registeredResidence' ) ? $this->get_args ( 'registeredResidence' ) : '';
  223. $householdRegistrationType = $this->get_args ( 'householdRegistrationType' ) ? $this->get_args ( 'householdRegistrationType' ) : '';
  224. if (! empty ( $sidKey )) {
  225. Doo::loadClass ( 'XDeode' );
  226. $XDeode = new XDeode ( 5 );
  227. Doo::loadModel ( 'staff' );
  228. $staff = new staff ();
  229. Doo::loadModel ( 'L_category' );
  230. $L_category = new L_category ();
  231. Doo::loadModel ( 'tag' );
  232. Doo::loadModel ( 'holidaystaff' );
  233. Doo::loadModel ( 'staffManage' );
  234. $staffManage = new staffManage ();
  235. // 用户名检测
  236. if (! empty ( $username )) {
  237. $detail = $staff->getStaffByName ( $username );
  238. if (empty ( $detail ))
  239. die ( 'illegal request' );
  240. }
  241. $detail = $staff->getStaffBySid ( $sidKey );
  242. if (empty ( $detail ))
  243. die ( 'illegal request' );
  244. // if (!empty($username))
  245. // $staff->username = $username;
  246. if (! empty ( $hiredate ))
  247. $staff->hiredate = $hiredate;
  248. // if (! empty ( $position )){
  249. // $position = explode ( '_', $position );
  250. // $staff->position = $position[1];
  251. // $staff->positionId = $position[0];
  252. // }
  253. // 办事处-部门
  254. if (! empty ( $cid_did )) {
  255. $department = explode ( '_', $cid_did );
  256. $cid = $XDeode->decode ( $department [0] );
  257. // 加入默认总部分类
  258. if (! is_numeric ( $cid ))
  259. die ( 'illegal request' );
  260. $cagegory = $L_category->getCategoryById ( $cid );
  261. // 部门
  262. $staff->departmentID =0;
  263. if (! empty ( $department [1] )) {
  264. $did = $XDeode->decode ( $department [1] );
  265. if (! is_numeric ( $did ))
  266. die ( 'illegal request' );
  267. $staff->departmentID = $did;
  268. }
  269. $staff->cid = $cagegory [0] ['cid'];
  270. $staff->category = $cagegory [0] ['title'];
  271. }
  272. if (! empty ( $telephone ))
  273. $staff->telephone = $telephone;
  274. // if (!empty($baseWage))
  275. // $staff->baseWage = $baseWage;
  276. // if (!empty($postWage))
  277. // $staff->postWage = $postWage;
  278. // if (!empty($achievementBonus))
  279. // $staff->achievementBonus = $achievementBonus;
  280. if (! empty ( $gender ))
  281. $staff->gender = $gender;
  282. if (! empty ( $qq ))
  283. $staff->qq = $qq;
  284. if (! empty ( $phone ))
  285. $staff->phone = $phone;
  286. if (! empty ( $wecat ))
  287. $staff->wecat = $wecat;
  288. if (! empty ( $email ))
  289. $staff->email = $email;
  290. if (! empty ( $birthday ))
  291. $staff->birthday = $birthday;
  292. if (! empty ( $qualifications ))
  293. $staff->qualifications = $qualifications;
  294. if ($marriage != '请选择')
  295. $staff->marriage = $marriage;
  296. else
  297. $staff->marriage = '';
  298. if (! empty ( $IDcards ))
  299. $staff->IDcards = $IDcards;
  300. if (! empty ( $living ))
  301. $staff->living = $living;
  302. if (! empty ( $nativePlace ))
  303. $staff->nativePlace = $nativePlace;
  304. if (! empty ( $emergencyContacts ))
  305. $staff->emergencyContacts = $emergencyContacts;
  306. if (! empty ( $coupletNumber ))
  307. $staff->coupletNumber = $coupletNumber;
  308. if (! empty ( $bankName ))
  309. $staff->bankName = $bankName;
  310. if (! empty ( $bankNumber ))
  311. $staff->bankNumber = $bankNumber;
  312. if (! empty ( $remittanceName ))
  313. $staff->remittanceName = $remittanceName;
  314. if (! empty ( $salaryCard ))
  315. $staff->salaryCard = $salaryCard;
  316. if (! empty ( $salaryBank ))
  317. $staff->salaryBank = $salaryBank;
  318. if (! empty ( $nation ))
  319. $staff->nation = $nation;
  320. if (! empty ( $graduateInstitutions ))
  321. $staff->graduateInstitutions = $graduateInstitutions;
  322. if (! empty ( $major ))
  323. $staff->major = $major;
  324. if (! empty ( $education ))
  325. $staff->education = $education;
  326. if (! empty ( $graduationTime ))
  327. $staff->graduationTime = $graduationTime;
  328. if (! empty ( $registeredResidence ))
  329. $staff->registeredResidence = $registeredResidence;
  330. if (! empty ( $householdRegistrationType ))
  331. $staff->householdRegistrationType = $householdRegistrationType;
  332. $staff->update ( array (
  333. 'where' => 'sid=' . $detail ['sid']
  334. ) );
  335. if ($employeeInfo == 'employeeInfo') {
  336. return '/hr';
  337. } elseif ($employeeInfo == 'hrEmployee') {
  338. return '/hrEmployee';
  339. } elseif ($employeeInfo == 'settingEmployeeInfo') {
  340. return '/settingEmployeeInfo';
  341. } elseif ($employeeInfo == 'settingFinanceInfo') {
  342. return '/settingFinanceInfo';
  343. }
  344. }
  345. die ( 'illegal request' );
  346. }
  347. /**
  348. * 证件文件上传
  349. */
  350. function settingCredentialInfoDo() {
  351. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  352. $IDcards = is_numeric ( $this->get_args ( 'IDcards' ) ) ? $this->get_args ( 'IDcards' ) : 0;
  353. $certificate = $this->get_args ( 'certificate' ) ? $this->get_args ( 'certificate' ) : '';
  354. $diploma = $this->get_args ( 'diploma' ) ? $this->get_args ( 'diploma' ) : '';
  355. $professionalTitle = $this->get_args ( 'professionalTitle' ) ? $this->get_args ( 'professionalTitle' ) : '';
  356. $IDcardsValidity = $this->get_args ( 'IDcardsValidity' ) ? $this->get_args ( 'IDcardsValidity' ) : '';
  357. Doo::loadModel ( 'staff' );
  358. $staff = new staff ();
  359. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  360. $save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/";
  361. $webSite = WEB_SITE . '/upload/credentialInfo/';
  362. // if (!empty($IDcards))
  363. $staff->IDcards = $IDcards;
  364. $msg = '';
  365. $file_name = 'IDcardsImgA_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgA"] ['name'] );
  366. if (! empty ( $_FILES ["IDcardsImgA"] ["size"] )) {
  367. if (! @move_uploaded_file ( $_FILES ["IDcardsImgA"] ["tmp_name"], $save_path . $file_name ))
  368. $msg .= "文件无法保存";
  369. else {
  370. $staff->IDcardsImgA = $webSite . $file_name;
  371. }
  372. }
  373. $file_name = 'IDcardsImgB_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgB"] ['name'] );
  374. if (! empty ( $_FILES ["IDcardsImgB"] ["size"] ))
  375. if (! @move_uploaded_file ( $_FILES ["IDcardsImgB"] ["tmp_name"], $save_path . $file_name )) {
  376. $msg .= "文件无法保存";
  377. } else {
  378. $staff->IDcardsImgB = $webSite . $file_name;
  379. }
  380. if (! empty ( $certificate )) {
  381. $certificateArray = explode ( "-", $certificate );
  382. $name = json_decode ( $detail ['certificate'] );
  383. if (! empty ( $name )) {
  384. $certificateArray = array_merge_recursive ( $name, $certificateArray );
  385. $staff->certificate = json_encode ( $certificateArray );
  386. } else
  387. $staff->certificate = json_encode ( $certificateArray );
  388. }
  389. if (! empty ( $diploma )) {
  390. $diplomaArray = explode ( "-", $diploma );
  391. $name = json_decode ( $detail ['diploma'] );
  392. if (! empty ( $name )) {
  393. $diplomaArray = array_merge_recursive ( $name, $diplomaArray );
  394. $staff->diploma = json_encode ( $diplomaArray );
  395. } else
  396. $staff->diploma = json_encode ( $diplomaArray );
  397. }
  398. if (! empty ( $professionalTitle )) {
  399. $professionalTitleArray = explode ( "-", $professionalTitle );
  400. $name = json_decode ( $detail ['professionalTitle'] );
  401. if (! empty ( $name )) {
  402. $professionalTitleArray = array_merge_recursive ( $name, $professionalTitleArray );
  403. $staff->professionalTitle = json_encode ( $professionalTitleArray );
  404. } else
  405. $staff->professionalTitle = json_encode ( $professionalTitleArray );
  406. }
  407. if(!empty($IDcardsValidity)){
  408. $staff->IDcardsValidity = $IDcardsValidity;
  409. }
  410. $staff->update ( array (
  411. 'where' => 'sid=' . $this->staff ['sid']
  412. ) );
  413. return '/settingCredentialInfo';
  414. }
  415. /**
  416. * 上传学位证书
  417. * @return string
  418. */
  419. function settingCredentialInfoTypeDo() {
  420. $hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";
  421. if (empty ( $hunTian )) {
  422. echo "文件无法保存.";
  423. exit ( 0 );
  424. }
  425. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  426. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  427. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  428. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  429. header ( "HTTP/1.1 500 Internal Server Error" );
  430. echo "POST exceeded maximum allowed size.";
  431. exit ( 0 );
  432. }
  433. // Settings
  434. $save_path = DOO::conf ()->SITE_PATH . "/upload/credentialInfo/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  435. $upload_name = "Filedata";
  436. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  437. $extension_whitelist = array (
  438. "doc",
  439. "txt",
  440. "jpg",
  441. "gif",
  442. "png"
  443. ); // Allowed file extensions
  444. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  445. // Other variables
  446. $MAX_FILENAME_LENGTH = 260;
  447. $file_name = "";
  448. $file_extension = "";
  449. $uploadErrors = array (
  450. 0 => "文件上传成功",
  451. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  452. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  453. 3 => "上传的文件仅为部分文件",
  454. 4 => "没有文件上传",
  455. 6 => "缺少临时文件夹"
  456. );
  457. $nk = time ();
  458. if ($hunTian == 'diploma')
  459. $file_name = 'diploma_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  460. elseif ($hunTian == 'professionalTitle')
  461. $file_name = 'professionalTitle_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  462. elseif ($hunTian == 'certificate') {
  463. $file_name = 'certificate_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  464. }
  465. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  466. echo "文件无法保存.";
  467. exit ( 0 );
  468. }
  469. echo json_encode ( array (
  470. 'filename' => $file_name,
  471. 'id' => $nk
  472. ) );
  473. exit ( 0 );
  474. }
  475. /**
  476. * 删除证件文件
  477. */
  478. function delCredentialType() {
  479. $hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";
  480. $name = isset ( $this->params ['name'] ) ? $this->params ['name'] : "";
  481. if (empty ( $hunTian ) || empty ( $name )) {
  482. die ( 'illegal request' );
  483. }
  484. Doo::loadModel ( 'staff' );
  485. $staff = new staff ();
  486. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  487. if ($hunTian == 'certificate') {
  488. $msg = str_replace ( $name, "", $detail ['certificate'] );
  489. $msg = json_decode ( $msg );
  490. $msg = array_values ( array_filter ( $msg ) );
  491. $staff->certificate = json_encode ( $msg );
  492. }
  493. if ($hunTian == 'diploma') {
  494. $msg = str_replace ( $name, "", $detail ['diploma'] );
  495. $msg = json_decode ( $msg );
  496. $msg = array_values ( array_filter ( $msg ) );
  497. $staff->diploma = json_encode ( $msg );
  498. }
  499. if ($hunTian == 'professionalTitle') {
  500. $msg = str_replace ( $name, "", $detail ['professionalTitle'] );
  501. $msg = json_decode ( $msg );
  502. $msg = array_values ( array_filter ( $msg ) );
  503. $staff->professionalTitle = json_encode ( $msg );
  504. }
  505. $staff->update ( array (
  506. 'where' => 'sid=' . $this->staff ['sid']
  507. ) );
  508. return '/settingCredentialInfo';
  509. }
  510. /**
  511. * 上传头像专用
  512. */
  513. function _settingAvatar() {
  514. $result = array ();
  515. $result ['success'] = false;
  516. $successNum = 0;
  517. // 定义一个变量用以储存当前头像的序号
  518. $avatarNumber = 1;
  519. $i = 0;
  520. $msg = '';
  521. // 上传目录
  522. $dir = DOO::conf ()->SITE_PATH . "global/avatar";
  523. // 遍历所有文件域
  524. while ( list ( $key, $val ) = each ( $_FILES ) ) {
  525. if ($_FILES [$key] ['error'] > 0)
  526. $msg .= $_FILES [$key] ['error'];
  527. else {
  528. $fileName = 'avatar_' . $this->staff ['sid'];
  529. // 原始图片(file 域的名称:__source,如果客户端定义可以上传的话,可在此处理)。
  530. if ($key == '__source') { // 当前头像基于原图的初始化参数,用于修改头像时保证界面的视图跟保存头像时一致。帮助提升用户体验度。修改头像时设置默认加载的原图的url为此图片的url+该参数即可。
  531. $initParams = $_POST ["__initParams"];
  532. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  533. $result ['sourceUrl'] = '/' . $virtualPath . $initParams;
  534. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  535. $successNum ++;
  536. } else if (strpos ( $key, '__avatar' ) === 0) { // 头像图片(file 域的名称:__avatar1,2,3...)。
  537. $virtualPath = $dir . "/" . $fileName . "_" . $avatarNumber . ".jpg";
  538. $result ['avatarUrls'] [$i] = '/' . $virtualPath;
  539. move_uploaded_file ( $_FILES [$key] ["tmp_name"], $virtualPath );
  540. $avatarNumber ++;
  541. $successNum ++;
  542. $i ++;
  543. }
  544. }
  545. }
  546. $result ['msg'] = $msg;
  547. if ($successNum > 0)
  548. $result ['success'] = true;
  549. // 返回图片的保存结果(返回内容为json字符串)
  550. Doo::loadModel ( 'staff' );
  551. $staff = new staff ();
  552. $staff->sid = $this->staff ['sid'];
  553. $staff->avatar = "/global/avatar/" . $fileName;
  554. $staff->update ();
  555. header('Cache-Control:no-cache,must-revalidate');
  556. header('Pragma:no-cache');
  557. echo json_encode ( $result );
  558. }
  559. /**
  560. * 获取get或者POST值
  561. *
  562. * @param string $name 属性名称
  563. * @return fixed 值
  564. */
  565. function get_args($name) {
  566. if (isset ( $_GET [$name] )) {
  567. if (is_array ( $_GET [$name] ))
  568. return $_GET [$name];
  569. else
  570. return addslashes ( $_GET [$name] );
  571. } elseif (isset ( $_POST [$name] )) {
  572. if (is_array ( $_POST [$name] ))
  573. return $_POST [$name];
  574. else
  575. return addslashes ( $_POST [$name] );
  576. } else
  577. return false;
  578. }
  579. /**
  580. * 旧输入导入
  581. */
  582. function _GetFileEXT($filename) {
  583. $pics = explode ( '.', $filename );
  584. $num = count ( $pics );
  585. return $pics [$num - 1];
  586. }
  587. }
  588. ?>