SettingController.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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. $staff->departmentID =0;
  257. if (! empty ( $department [1] )) {
  258. $did = $XDeode->decode ( $department [1] );
  259. if (! is_numeric ( $did ))
  260. die ( 'illegal request' );
  261. $staff->departmentID = $did;
  262. }
  263. $staff->cid = $cagegory [0] ['cid'];
  264. $staff->category = $cagegory [0] ['title'];
  265. }
  266. if (! empty ( $telephone ))
  267. $staff->telephone = $telephone;
  268. // if (!empty($baseWage))
  269. // $staff->baseWage = $baseWage;
  270. // if (!empty($postWage))
  271. // $staff->postWage = $postWage;
  272. // if (!empty($achievementBonus))
  273. // $staff->achievementBonus = $achievementBonus;
  274. if (! empty ( $gender ))
  275. $staff->gender = $gender;
  276. if (! empty ( $qq ))
  277. $staff->qq = $qq;
  278. if (! empty ( $phone ))
  279. $staff->phone = $phone;
  280. if (! empty ( $wecat ))
  281. $staff->wecat = $wecat;
  282. if (! empty ( $email ))
  283. $staff->email = $email;
  284. if (! empty ( $birthday ))
  285. $staff->birthday = $birthday;
  286. if (! empty ( $qualifications ))
  287. $staff->qualifications = $qualifications;
  288. if ($marriage != '请选择')
  289. $staff->marriage = $marriage;
  290. else
  291. $staff->marriage = '';
  292. if (! empty ( $IDcards ))
  293. $staff->IDcards = $IDcards;
  294. if (! empty ( $living ))
  295. $staff->living = $living;
  296. if (! empty ( $nativePlace ))
  297. $staff->nativePlace = $nativePlace;
  298. if (! empty ( $emergencyContacts ))
  299. $staff->emergencyContacts = $emergencyContacts;
  300. if (! empty ( $coupletNumber ))
  301. $staff->coupletNumber = $coupletNumber;
  302. if (! empty ( $bankName ))
  303. $staff->bankName = $bankName;
  304. if (! empty ( $bankNumber ))
  305. $staff->bankNumber = $bankNumber;
  306. if (! empty ( $remittanceName ))
  307. $staff->remittanceName = $remittanceName;
  308. if (! empty ( $salaryCard ))
  309. $staff->salaryCard = $salaryCard;
  310. if (! empty ( $salaryBank ))
  311. $staff->salaryBank = $salaryBank;
  312. if (! empty ( $nation ))
  313. $staff->nation = $nation;
  314. if (! empty ( $graduateInstitutions ))
  315. $staff->graduateInstitutions = $graduateInstitutions;
  316. if (! empty ( $major ))
  317. $staff->major = $major;
  318. if (! empty ( $education ))
  319. $staff->education = $education;
  320. if (! empty ( $graduationTime ))
  321. $staff->graduationTime = $graduationTime;
  322. if (! empty ( $registeredResidence ))
  323. $staff->registeredResidence = $registeredResidence;
  324. if (! empty ( $householdRegistrationType ))
  325. $staff->householdRegistrationType = $householdRegistrationType;
  326. $staff->update ( array (
  327. 'where' => 'sid=' . $detail ['sid']
  328. ) );
  329. if ($employeeInfo == 'employeeInfo') {
  330. return '/hr';
  331. } elseif ($employeeInfo == 'hrEmployee') {
  332. return '/hrEmployee';
  333. } elseif ($employeeInfo == 'settingEmployeeInfo') {
  334. return '/settingEmployeeInfo';
  335. } elseif ($employeeInfo == 'settingFinanceInfo') {
  336. return '/settingFinanceInfo';
  337. }
  338. }
  339. die ( 'illegal request' );
  340. }
  341. /**
  342. * 证件文件上传
  343. */
  344. function settingCredentialInfoDo() {
  345. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  346. $IDcards = is_numeric ( $this->get_args ( 'IDcards' ) ) ? $this->get_args ( 'IDcards' ) : 0;
  347. $certificate = $this->get_args ( 'certificate' ) ? $this->get_args ( 'certificate' ) : '';
  348. $diploma = $this->get_args ( 'diploma' ) ? $this->get_args ( 'diploma' ) : '';
  349. $professionalTitle = $this->get_args ( 'professionalTitle' ) ? $this->get_args ( 'professionalTitle' ) : '';
  350. $IDcardsValidity = $this->get_args ( 'IDcardsValidity' ) ? $this->get_args ( 'IDcardsValidity' ) : '';
  351. Doo::loadModel ( 'staff' );
  352. $staff = new staff ();
  353. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  354. $save_path = DOO::conf ()->SITE_PATH . "upload/credentialInfo/";
  355. $webSite = WEB_SITE . '/upload/credentialInfo/';
  356. // if (!empty($IDcards))
  357. $staff->IDcards = $IDcards;
  358. $msg = '';
  359. $file_name = 'IDcardsImgA_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgA"] ['name'] );
  360. if (! empty ( $_FILES ["IDcardsImgA"] ["size"] )) {
  361. if (! @move_uploaded_file ( $_FILES ["IDcardsImgA"] ["tmp_name"], $save_path . $file_name ))
  362. $msg .= "文件无法保存";
  363. else {
  364. $staff->IDcardsImgA = $webSite . $file_name;
  365. }
  366. }
  367. $file_name = 'IDcardsImgB_' . $this->staff ['sid'] . '.' . $this->_GetFileEXT ( $_FILES ["IDcardsImgB"] ['name'] );
  368. if (! empty ( $_FILES ["IDcardsImgB"] ["size"] ))
  369. if (! @move_uploaded_file ( $_FILES ["IDcardsImgB"] ["tmp_name"], $save_path . $file_name )) {
  370. $msg .= "文件无法保存";
  371. } else {
  372. $staff->IDcardsImgB = $webSite . $file_name;
  373. }
  374. if (! empty ( $certificate )) {
  375. $certificateArray = explode ( "-", $certificate );
  376. $name = json_decode ( $detail ['certificate'] );
  377. if (! empty ( $name )) {
  378. $certificateArray = array_merge_recursive ( $name, $certificateArray );
  379. $staff->certificate = json_encode ( $certificateArray );
  380. } else
  381. $staff->certificate = json_encode ( $certificateArray );
  382. }
  383. if (! empty ( $diploma )) {
  384. $diplomaArray = explode ( "-", $diploma );
  385. $name = json_decode ( $detail ['diploma'] );
  386. if (! empty ( $name )) {
  387. $diplomaArray = array_merge_recursive ( $name, $diplomaArray );
  388. $staff->diploma = json_encode ( $diplomaArray );
  389. } else
  390. $staff->diploma = json_encode ( $diplomaArray );
  391. }
  392. if (! empty ( $professionalTitle )) {
  393. $professionalTitleArray = explode ( "-", $professionalTitle );
  394. $name = json_decode ( $detail ['professionalTitle'] );
  395. if (! empty ( $name )) {
  396. $professionalTitleArray = array_merge_recursive ( $name, $professionalTitleArray );
  397. $staff->professionalTitle = json_encode ( $professionalTitleArray );
  398. } else
  399. $staff->professionalTitle = json_encode ( $professionalTitleArray );
  400. }
  401. if(!empty($IDcardsValidity)){
  402. $staff->IDcardsValidity = $IDcardsValidity;
  403. }
  404. $staff->update ( array (
  405. 'where' => 'sid=' . $this->staff ['sid']
  406. ) );
  407. return '/settingCredentialInfo';
  408. }
  409. /**
  410. * 上传学位证书
  411. * @return string
  412. */
  413. function settingCredentialInfoTypeDo() {
  414. $hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";
  415. if (empty ( $hunTian )) {
  416. echo "文件无法保存.";
  417. exit ( 0 );
  418. }
  419. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  420. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  421. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  422. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  423. header ( "HTTP/1.1 500 Internal Server Error" );
  424. echo "POST exceeded maximum allowed size.";
  425. exit ( 0 );
  426. }
  427. // Settings
  428. $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)
  429. $upload_name = "Filedata";
  430. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  431. $extension_whitelist = array (
  432. "doc",
  433. "txt",
  434. "jpg",
  435. "gif",
  436. "png"
  437. ); // Allowed file extensions
  438. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  439. // Other variables
  440. $MAX_FILENAME_LENGTH = 260;
  441. $file_name = "";
  442. $file_extension = "";
  443. $uploadErrors = array (
  444. 0 => "文件上传成功",
  445. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  446. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  447. 3 => "上传的文件仅为部分文件",
  448. 4 => "没有文件上传",
  449. 6 => "缺少临时文件夹"
  450. );
  451. $nk = time ();
  452. if ($hunTian == 'diploma')
  453. $file_name = 'diploma_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  454. elseif ($hunTian == 'professionalTitle')
  455. $file_name = 'professionalTitle_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  456. elseif ($hunTian == 'certificate') {
  457. $file_name = 'certificate_' . $this->staff ['sid'] . '_' . $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] );
  458. }
  459. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  460. echo "文件无法保存.";
  461. exit ( 0 );
  462. }
  463. echo json_encode ( array (
  464. 'filename' => $file_name,
  465. 'id' => $nk
  466. ) );
  467. exit ( 0 );
  468. }
  469. /**
  470. * 删除证件文件
  471. */
  472. function delCredentialType() {
  473. $hunTian = isset ( $this->params ['hunTian'] ) ? $this->params ['hunTian'] : "";
  474. $name = isset ( $this->params ['name'] ) ? $this->params ['name'] : "";
  475. if (empty ( $hunTian ) || empty ( $name )) {
  476. die ( 'illegal request' );
  477. }
  478. Doo::loadModel ( 'staff' );
  479. $staff = new staff ();
  480. $detail = $staff->getStaffBySid ( $this->staff ['sid'] );
  481. if ($hunTian == 'certificate') {
  482. $msg = str_replace ( $name, "", $detail ['certificate'] );
  483. $msg = json_decode ( $msg );
  484. $msg = array_values ( array_filter ( $msg ) );
  485. $staff->certificate = json_encode ( $msg );
  486. }
  487. if ($hunTian == 'diploma') {
  488. $msg = str_replace ( $name, "", $detail ['diploma'] );
  489. $msg = json_decode ( $msg );
  490. $msg = array_values ( array_filter ( $msg ) );
  491. $staff->diploma = json_encode ( $msg );
  492. }
  493. if ($hunTian == 'professionalTitle') {
  494. $msg = str_replace ( $name, "", $detail ['professionalTitle'] );
  495. $msg = json_decode ( $msg );
  496. $msg = array_values ( array_filter ( $msg ) );
  497. $staff->professionalTitle = json_encode ( $msg );
  498. }
  499. $staff->update ( array (
  500. 'where' => 'sid=' . $this->staff ['sid']
  501. ) );
  502. return '/settingCredentialInfo';
  503. }
  504. /**
  505. * 获取get或者POST值
  506. *
  507. * @param string $name 属性名称
  508. * @return fixed 值
  509. */
  510. function get_args($name) {
  511. if (isset ( $_GET [$name] )) {
  512. if (is_array ( $_GET [$name] ))
  513. return $_GET [$name];
  514. else
  515. return addslashes ( $_GET [$name] );
  516. } elseif (isset ( $_POST [$name] )) {
  517. if (is_array ( $_POST [$name] ))
  518. return $_POST [$name];
  519. else
  520. return addslashes ( $_POST [$name] );
  521. } else
  522. return false;
  523. }
  524. /**
  525. * 旧输入导入
  526. */
  527. function _GetFileEXT($filename) {
  528. $pics = explode ( '.', $filename );
  529. $num = count ( $pics );
  530. return $pics [$num - 1];
  531. }
  532. }
  533. ?>