SettingController.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. /**
  61. * 证件信息
  62. */
  63. function settingCredentialInfo() {
  64. Doo::loadModel ( 'staff' );
  65. $staff = new staff ();
  66. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  67. $this->data ['staff'] = $this->staff;
  68. $this->data ['memu'] = "adminmyinfo";
  69. $this->data ['hrMemu'] = "settingEmployeeInfo";
  70. $this->render ( "/setting/settingCredentialInfo", $this->data );
  71. }
  72. /**
  73. * 财务信息
  74. */
  75. function settingFinanceInfo() {
  76. $this->data ['staff'] = $this->staff;
  77. $this->data ['memu'] = "adminmyinfo";
  78. $this->data ['hrMemu'] = "settingEmployeeInfo";
  79. $this->render ( "/setting/settingFinanceInfo", $this->data );
  80. }
  81. function settingPW() {
  82. $this->data ['msg'] = urldecode ( $this->params ['msg'] );
  83. $this->data ['staff'] = $this->staff;
  84. $this->data ['memu'] = "adminmyinfo";
  85. $this->data ['hrMemu'] = "settingPW";
  86. $this->render ( "/setting/settingPW", $this->data );
  87. }
  88. /*
  89. * 更新密码
  90. */
  91. function updateMyPW() {
  92. $oldpassword = $this->get_args ( 'oldpassword' ) ? $this->get_args ( 'oldpassword' ) : "";
  93. $newpassword = $this->get_args ( 'newpassword' ) ? $this->get_args ( 'newpassword' ) : "";
  94. $rnewpassword = $this->get_args ( 'rnewpassword' ) ? $this->get_args ( 'rnewpassword' ) : "";
  95. Doo::loadModel ( 'staff' );
  96. $staff = new staff ();
  97. Doo::loadModel ( 'staffDynamic' );
  98. $staffDynamic = new staffDynamic ();
  99. $staff->sid = $this->staff ['sid'];
  100. $msg = "更新成功";
  101. if ($this->staff ['passwork'] == md5 ( $oldpassword )) {
  102. if ($newpassword == $rnewpassword && (! empty ( $newpassword )))
  103. $staff->passwork = md5 ( $newpassword );
  104. else
  105. $msg = "密码不一致";
  106. } else {
  107. if ($oldpassword != "")
  108. $msg = "密码错误";
  109. }
  110. $staff->update ( array (
  111. 'where' => ' sid=' . $this->staff ['sid']
  112. ) );
  113. return "/settingPW/" . $msg;
  114. }
  115. /**
  116. * 微信通知设置
  117. */
  118. function notificationConf() {
  119. Doo::loadModel ( "notificationConf" );
  120. $notificationConf = new notificationConf ();
  121. $detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );
  122. $rule = json_decode ( $detail ['conf'], true );
  123. if (! isset ( $rule ['approval'] ))
  124. $rule ['approval'] = '';
  125. if (! isset ( $rule ['print'] ))
  126. $rule ['print'] = '';
  127. if (! isset ( $rule ['receivables'] ))
  128. $rule ['receivables'] = '';
  129. $this->data ['rule'] = $rule;
  130. $this->data ['memu'] = "adminmyinfo";
  131. $this->data ['hrMemu'] = "notificationConf";
  132. $this->data ['staff'] = $this->staff;
  133. $this->render ( "/setting/invoiceNotificationConf", $this->data );
  134. }
  135. /**
  136. * 异步设置微信通知
  137. */
  138. function ajaxSetNotificationConf() {
  139. $notificationType = $this->get_args ( 'notificationType' ) ? $this->get_args ( 'notificationType' ) : "";
  140. $notificationValue = $this->get_args ( 'notificationValue' ) ? $this->get_args ( 'notificationValue' ) : '';
  141. if (! empty ( $notificationType ) && ! empty ( $notificationValue ) && ! empty ( $this->staff ['sid'] )) {
  142. Doo::loadModel ( "notificationConf" );
  143. $notificationConf = new notificationConf ();
  144. $detail = $notificationConf->getNotificationConfBySid ( $this->staff ['sid'] );
  145. if (empty ( $detail )) {
  146. $rule = array (
  147. $notificationType => $notificationValue
  148. );
  149. $rule = json_encode ( $rule );
  150. $item = array (
  151. 'sid' => $this->staff ['sid'],
  152. 'conf' => $rule
  153. );
  154. $notificationConf->addNotification ( $item );
  155. } else {
  156. $rule = json_decode ( $detail ['conf'], true );
  157. $rule [$notificationType] = $notificationValue;
  158. $rule = json_encode ( $rule );
  159. $item = array (
  160. 'nid' => $detail ['nid'],
  161. 'conf' => $rule
  162. );
  163. $notificationConf->setNotificationByCondition ( $item );
  164. }
  165. echo json_encode ( array (
  166. 'status' => 1,
  167. 'msgType' => $notificationType,
  168. 'msg' => ''
  169. ) );
  170. die ();
  171. }
  172. echo json_encode ( array (
  173. 'status' => 2,
  174. 'msgType' => $notificationType,
  175. 'msg' => 'illegal request'
  176. ) );
  177. die ();
  178. }
  179. /**
  180. * 更新员工信息
  181. */
  182. function staffUpdate() {
  183. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  184. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  185. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';
  186. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  187. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';
  188. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  189. // $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  190. // $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  191. // $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  192. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  193. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
  194. $phone = is_numeric ( $this->get_args ( 'phone' ) ) ? $this->get_args ( 'phone' ) : 0;
  195. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  196. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  197. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  198. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  199. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '0';
  200. $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';
  201. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  202. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  203. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  204. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : '';
  205. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : '';
  206. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : '';
  207. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : '';
  208. $salaryCard = $this->get_args ( 'salaryCard' ) ? $this->get_args ( 'salaryCard' ) : '';
  209. $salaryBank = $this->get_args ( 'salaryBank' ) ? $this->get_args ( 'salaryBank' ) : '';
  210. $employeeInfo = $this->get_args ( 'employeeInfo' ) ? $this->get_args ( 'employeeInfo' ) : 'employeeInfo';
  211. $nation = $this->get_args ( 'nation' ) ? $this->get_args ( 'nation' ) : '';
  212. $graduateInstitutions = $this->get_args ( 'graduateInstitutions' ) ? $this->get_args ( 'graduateInstitutions' ) : '';
  213. $major = $this->get_args ( 'major' ) ? $this->get_args ( 'major' ) : '';
  214. $education = $this->get_args ( 'education' ) ? $this->get_args ( 'education' ) : '';
  215. $graduationTime = $this->get_args ( 'graduationTime' ) ? $this->get_args ( 'graduationTime' ) : '';
  216. $registeredResidence = $this->get_args ( 'registeredResidence' ) ? $this->get_args ( 'registeredResidence' ) : '';
  217. $householdRegistrationType = $this->get_args ( 'householdRegistrationType' ) ? $this->get_args ( 'householdRegistrationType' ) : '';
  218. if (! empty ( $sidKey )) {
  219. Doo::loadClass ( 'XDeode' );
  220. $XDeode = new XDeode ( 5 );
  221. Doo::loadModel ( 'staff' );
  222. $staff = new staff ();
  223. Doo::loadModel ( 'L_category' );
  224. $L_category = new L_category ();
  225. Doo::loadModel ( 'tag' );
  226. Doo::loadModel ( 'holidaystaff' );
  227. Doo::loadModel ( 'staffManage' );
  228. $staffManage = new staffManage ();
  229. // 用户名检测
  230. if (! empty ( $username )) {
  231. $detail = $staff->getStaffByName ( $username );
  232. if (empty ( $detail ))
  233. die ( 'illegal request' );
  234. }
  235. $detail = $staff->getStaffBySid ( $sidKey );
  236. if (empty ( $detail ))
  237. die ( 'illegal request' );
  238. // if (!empty($username))
  239. // $staff->username = $username;
  240. if (! empty ( $hiredate ))
  241. $staff->hiredate = $hiredate;
  242. if (! empty ( $position )){
  243. $position = explode ( '_', $position );
  244. $staff->position = $position[1];
  245. $staff->positionId = $position[0];
  246. }
  247. // 办事处-部门
  248. if (! empty ( $cid_did )) {
  249. $department = explode ( '_', $cid_did );
  250. $cid = $XDeode->decode ( $department [0] );
  251. // 加入默认总部分类
  252. if (! is_numeric ( $cid ))
  253. die ( 'illegal request' );
  254. $cagegory = $L_category->getCategoryById ( $cid );
  255. // 部门
  256. if (! empty ( $department [1] )) {
  257. $did = $XDeode->decode ( $department [1] );
  258. if (! is_numeric ( $did ))
  259. die ( 'illegal request' );
  260. $staff->departmentID = $did;
  261. }
  262. $staff->cid = $cagegory [0] ['cid'];
  263. $staff->category = $cagegory [0] ['title'];
  264. }
  265. if (! empty ( $telephone ))
  266. $staff->telephone = $telephone;
  267. // if (!empty($baseWage))
  268. // $staff->baseWage = $baseWage;
  269. // if (!empty($postWage))
  270. // $staff->postWage = $postWage;
  271. // if (!empty($achievementBonus))
  272. // $staff->achievementBonus = $achievementBonus;
  273. if (! empty ( $gender ))
  274. $staff->gender = $gender;
  275. if (! empty ( $qq ))
  276. $staff->qq = $qq;
  277. if (! empty ( $phone ))
  278. $staff->phone = $phone;
  279. if (! empty ( $wecat ))
  280. $staff->wecat = $wecat;
  281. if (! empty ( $email ))
  282. $staff->email = $email;
  283. if (! empty ( $birthday ))
  284. $staff->birthday = $birthday;
  285. if (! empty ( $qualifications ))
  286. $staff->qualifications = $qualifications;
  287. if ($marriage != '请选择')
  288. $staff->marriage = $marriage;
  289. else
  290. $staff->marriage = '';
  291. if (! empty ( $IDcards ))
  292. $staff->IDcards = $IDcards;
  293. if (! empty ( $living ))
  294. $staff->living = $living;
  295. if (! empty ( $nativePlace ))
  296. $staff->nativePlace = $nativePlace;
  297. if (! empty ( $emergencyContacts ))
  298. $staff->emergencyContacts = $emergencyContacts;
  299. if (! empty ( $coupletNumber ))
  300. $staff->coupletNumber = $coupletNumber;
  301. if (! empty ( $bankName ))
  302. $staff->bankName = $bankName;
  303. if (! empty ( $bankNumber ))
  304. $staff->bankNumber = $bankNumber;
  305. if (! empty ( $remittanceName ))
  306. $staff->remittanceName = $remittanceName;
  307. if (! empty ( $salaryCard ))
  308. $staff->salaryCard = $salaryCard;
  309. if (! empty ( $salaryBank ))
  310. $staff->salaryBank = $salaryBank;
  311. if (! empty ( $nation ))
  312. $staff->nation = $nation;
  313. if (! empty ( $graduateInstitutions ))
  314. $staff->graduateInstitutions = $graduateInstitutions;
  315. if (! empty ( $major ))
  316. $staff->major = $major;
  317. if (! empty ( $education ))
  318. $staff->education = $education;
  319. if (! empty ( $graduationTime ))
  320. $staff->graduationTime = $graduationTime;
  321. if (! empty ( $registeredResidence ))
  322. $staff->registeredResidence = $registeredResidence;
  323. if (! empty ( $householdRegistrationType ))
  324. $staff->householdRegistrationType = $householdRegistrationType;
  325. $staff->update ( array (
  326. 'where' => 'sid=' . $detail ['sid']
  327. ) );
  328. if ($employeeInfo == 'employeeInfo') {
  329. return '/hr';
  330. } elseif ($employeeInfo == 'hrEmployee') {
  331. return '/hrEmployee';
  332. } elseif ($employeeInfo == 'settingEmployeeInfo') {
  333. return '/settingEmployeeInfo';
  334. } elseif ($employeeInfo == 'settingFinanceInfo') {
  335. return '/settingFinanceInfo';
  336. }
  337. }
  338. die ( 'illegal request' );
  339. }
  340. /**
  341. * 证件文件上传
  342. */
  343. function settingCredentialInfoDo() {
  344. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  345. $IDcards = is_numeric ( $this->get_args ( 'IDcards' ) ) ? $this->get_args ( 'IDcards' ) : 0;
  346. $certificate = $this->get_args ( 'certificate' ) ? $this->get_args ( 'certificate' ) : '';
  347. $diploma = $this->get_args ( 'diploma' ) ? $this->get_args ( 'diploma' ) : '';
  348. $professionalTitle = $this->get_args ( 'professionalTitle' ) ? $this->get_args ( 'professionalTitle' ) : '';
  349. Doo::loadModel ( 'staff' );
  350. $staff = new staff ();
  351. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  352. $save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/";
  353. $webSite = WEB_SITE . '/upload/credentialInfo/';
  354. // if (!empty($IDcards))
  355. $staff->IDcards = $IDcards;
  356. $msg = '';
  357. $file_name = 'IDcardsImgA_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgA"] ['name'] );
  358. if (! empty ( $_FILES ["IDcardsImgA"] ["size"] )) {
  359. if (! @move_uploaded_file ( $_FILES ["IDcardsImgA"] ["tmp_name"], $save_path . $file_name ))
  360. $msg .= "文件无法保存";
  361. else {
  362. $staff->IDcardsImgA = $webSite . $file_name;
  363. }
  364. }
  365. $file_name = 'IDcardsImgB_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgB"] ['name'] );
  366. if (! empty ( $_FILES ["IDcardsImgB"] ["size"] ))
  367. if (! @move_uploaded_file ( $_FILES ["IDcardsImgB"] ["tmp_name"], $save_path . $file_name )) {
  368. $msg .= "文件无法保存";
  369. } else {
  370. $staff->IDcardsImgB = $webSite . $file_name;
  371. }
  372. if (! empty ( $certificate )) {
  373. $certificateArray = explode ( "-", $certificate );
  374. $name = json_decode ( $detail ['certificate'] );
  375. if (! empty ( $name )) {
  376. $certificateArray = array_merge_recursive ( $name, $certificateArray );
  377. $staff->certificate = json_encode ( $certificateArray );
  378. } else
  379. $staff->certificate = json_encode ( $certificateArray );
  380. }
  381. if (! empty ( $diploma )) {
  382. $diplomaArray = explode ( "-", $diploma );
  383. $name = json_decode ( $detail ['diploma'] );
  384. if (! empty ( $name )) {
  385. $diplomaArray = array_merge_recursive ( $name, $diplomaArray );
  386. $staff->diploma = json_encode ( $diplomaArray );
  387. } else
  388. $staff->diploma = json_encode ( $diplomaArray );
  389. }
  390. if (! empty ( $professionalTitle )) {
  391. $professionalTitleArray = explode ( "-", $professionalTitle );
  392. $name = json_decode ( $detail ['professionalTitle'] );
  393. if (! empty ( $name )) {
  394. $professionalTitleArray = array_merge_recursive ( $name, $professionalTitleArray );
  395. $staff->professionalTitle = json_encode ( $professionalTitleArray );
  396. } else
  397. $staff->professionalTitle = json_encode ( $professionalTitleArray );
  398. }
  399. $staff->update ( array (
  400. 'where' => 'sid=' . $this->staff ['sid']
  401. ) );
  402. return '/settingCredentialInfo';
  403. }
  404. /**
  405. * 上传学位证书
  406. * @return string
  407. */
  408. function settingCredentialInfoTypeDo() {
  409. $hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";
  410. if (empty ( $hunTian )) {
  411. echo "文件无法保存.";
  412. exit ( 0 );
  413. }
  414. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  415. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  416. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  417. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  418. header ( "HTTP/1.1 500 Internal Server Error" );
  419. echo "POST exceeded maximum allowed size.";
  420. exit ( 0 );
  421. }
  422. // Settings
  423. $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)
  424. $upload_name = "Filedata";
  425. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  426. $extension_whitelist = array (
  427. "doc",
  428. "txt",
  429. "jpg",
  430. "gif",
  431. "png"
  432. ); // Allowed file extensions
  433. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  434. // Other variables
  435. $MAX_FILENAME_LENGTH = 260;
  436. $file_name = "";
  437. $file_extension = "";
  438. $uploadErrors = array (
  439. 0 => "文件上传成功",
  440. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  441. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  442. 3 => "上传的文件仅为部分文件",
  443. 4 => "没有文件上传",
  444. 6 => "缺少临时文件夹"
  445. );
  446. $nk = time ();
  447. if ($hunTian == 'diploma')
  448. $file_name = 'diploma_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  449. elseif ($hunTian == 'professionalTitle')
  450. $file_name = 'professionalTitle_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  451. elseif ($hunTian == 'certificate') {
  452. $file_name = 'certificate_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  453. }
  454. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  455. echo "文件无法保存.";
  456. exit ( 0 );
  457. }
  458. echo json_encode ( array (
  459. 'filename' => $file_name,
  460. 'id' => $nk
  461. ) );
  462. exit ( 0 );
  463. }
  464. /**
  465. * 删除证件文件
  466. */
  467. function delCredentialType() {
  468. $hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";
  469. $name = isset ( $this->params ['name'] ) ? $this->params ['name'] : "";
  470. if (empty ( $hunTian ) || empty ( $name )) {
  471. die ( 'illegal request' );
  472. }
  473. Doo::loadModel ( 'staff' );
  474. $staff = new staff ();
  475. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  476. if ($hunTian == 'certificate') {
  477. $msg = str_replace ( $name, "", $detail ['certificate'] );
  478. $msg = json_decode ( $msg );
  479. $msg = array_values ( array_filter ( $msg ) );
  480. $staff->certificate = json_encode ( $msg );
  481. }
  482. if ($hunTian == 'diploma') {
  483. $msg = str_replace ( $name, "", $detail ['diploma'] );
  484. $msg = json_decode ( $msg );
  485. $msg = array_values ( array_filter ( $msg ) );
  486. $staff->diploma = json_encode ( $msg );
  487. }
  488. if ($hunTian == 'professionalTitle') {
  489. $msg = str_replace ( $name, "", $detail ['professionalTitle'] );
  490. $msg = json_decode ( $msg );
  491. $msg = array_values ( array_filter ( $msg ) );
  492. $staff->professionalTitle = json_encode ( $msg );
  493. }
  494. $staff->update ( array (
  495. 'where' => 'sid=' . $this->staff ['sid']
  496. ) );
  497. return '/settingCredentialInfo';
  498. }
  499. /**
  500. * 获取get或者POST值
  501. *
  502. * @param string $name 属性名称
  503. * @return fixed 值
  504. */
  505. function get_args($name) {
  506. if (isset ( $_GET [$name] )) {
  507. if (is_array ( $_GET [$name] ))
  508. return $_GET [$name];
  509. else
  510. return addslashes ( $_GET [$name] );
  511. } elseif (isset ( $_POST [$name] )) {
  512. if (is_array ( $_POST [$name] ))
  513. return $_POST [$name];
  514. else
  515. return addslashes ( $_POST [$name] );
  516. } else
  517. return false;
  518. }
  519. /**
  520. * 旧输入导入
  521. */
  522. function _GetFileEXT($filename) {
  523. $pics = explode ( '.', $filename );
  524. $num = count ( $pics );
  525. return $pics [$num - 1];
  526. }
  527. }
  528. ?>