AdminController.php 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class AdminController extends DooController {
  6. public $staff;
  7. public $nature=array('1'=>'设计',
  8. '2'=>'造价管理',
  9. '3'=>'业主',
  10. '4'=>'交通局',
  11. '5'=>'公路局',
  12. '6'=>'审计',
  13. '7'=>'财政',
  14. '8'=>'审核',
  15. '9'=>'施工',
  16. '10'=>'咨询',
  17. '11'=>'招标代理',
  18. '12'=>'监理',
  19. '13'=>'学校',
  20. '14'=>'个人',
  21. '15'=>'合作伙伴',
  22. );
  23. public $tooltip=array('1'=>array('L','点击筛选标签'),
  24. '2'=>array('M','点击筛选标签'),
  25. '3'=>array('N','点击筛选标签'),
  26. '4'=>array('O','点击筛选标签'),
  27. '5'=>array('P','点击筛选标签'),
  28. '6'=>array('Q','点击筛选标签'),
  29. '7'=>array('R','点击筛选标签'),
  30. );
  31. public $webPath="http://cld.smartcost.com.cn/upload/emailAnnex/";
  32. function __construct() {
  33. if(isset($_COOKIE["adStaff"])){
  34. if(!empty($_COOKIE["adStaff"])){
  35. Doo::loadModel ( 'staff' );
  36. $staff = new staff ();
  37. $this->staff=$staff->getUserByIdList($_COOKIE["adStaff"]);
  38. if ($this->staff[0]['isadmin']==1&&$this->staff[0]['username']=='admin'){
  39. return "/adminoffice";
  40. }
  41. }
  42. }
  43. Doo::loadCore ( 'uri/DooUriRouter' );
  44. $router = new DooUriRouter ();
  45. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  46. if($routeRs['1']!="adlogin"){
  47. header ( 'Content-Type:text/html;charset=utf-8' );
  48. @header ( "Location: /adlogin" );
  49. }
  50. }
  51. function adlogin(){
  52. $passwork = isset ( $_POST['passwork'] ) ? $_POST['passwork'] : "";
  53. $uid = isset ( $_POST['user'] ) ? $_POST['user'] : "";
  54. Doo::loadModel ( 'staff' );
  55. $staff = new staff ();
  56. if(!empty($passwork)){
  57. $userinfo=$staff->getOne(array('where'=>"username='admin'",'asArray'=>true));
  58. if(!empty($userinfo)){
  59. if ($userinfo['username']==$uid&&$userinfo['passwork']==md5($passwork)){
  60. setcookie("adStaff", $userinfo['sid'], time()+36000,"/");
  61. return "/adminoffice";
  62. }
  63. }
  64. }
  65. $data ['staff'] = "";
  66. $data['login']="";
  67. if(!empty($passwork))
  68. $data['login']="inputErrow";
  69. $this->render ( "/admin/adminLogin", $data );
  70. }
  71. function adout(){
  72. setcookie("adStaff", "", time()-3600,"/");
  73. return "/adlogin";
  74. }
  75. function adminPW(){
  76. $msg= $this->params['msg']?$this->params['msg']:"";
  77. $data['msg']="msg";
  78. $data['memu']="adminpw";
  79. $data['staff']=$this->staff;
  80. $data['msg']=urldecode($this->params['msg']);
  81. $this->render ( "/admin/admin-admininfo", $data );
  82. }
  83. function upAdP(){
  84. $opw=$this->get_args('opw')?$this->get_args('opw'):"";
  85. $npw1=$this->get_args('npw1')?$this->get_args('npw1'):"";
  86. $npw2=$this->get_args('npw2')?$this->get_args('npw2'):"";
  87. if(!empty($opw)){
  88. Doo::loadModel ( 'staff' );
  89. $staff = new staff ();
  90. $userinfo=$staff->getOne(array('where'=>"username='admin'",'asArray'=>true));
  91. if(!empty($userinfo)){
  92. if ($userinfo['sid']==$_COOKIE["adStaff"]&&$userinfo['passwork']==md5($opw)){
  93. if (($npw1==$npw2)&&($npw1!="")){
  94. $staff->passwork=md5($npw1);
  95. $staff->update(array('where'=>"sid='".$_COOKIE["adStaff"]."'"));
  96. return "/adminpw/".urlencode('密码修改成功');
  97. }else
  98. return "/adminpw/".urlencode('新密码不一致');
  99. }else
  100. return "/adminpw/".urlencode('旧密码不正确');
  101. }else
  102. return "/adminpw/".urlencode('未找到用户');
  103. }else
  104. return "/adminpw/".urlencode('请输入旧密码');
  105. }
  106. function adminoffice(){
  107. $data['memu']="adminoffice";
  108. $data['staff']=$this->staff;
  109. Doo::loadModel ( 'L_category' );
  110. Doo::loadModel ( 'staff' );
  111. Doo::loadModel('district');
  112. $district= new district();
  113. $staff = new staff ();
  114. $L_category = new L_category ();
  115. $data['category']=$L_category->getCategory();
  116. $data['district']=$district->get_lv(1);
  117. foreach ($data['category'] as $key=>$value){
  118. $data['category'][$key]['count']=$staff->count(array('where'=>'cid='.$value['cid']));
  119. }
  120. $data['msg']=urldecode($this->params['msg']);
  121. $this->render ( "/admin/admin_group", $data );
  122. }
  123. function addCategory(){
  124. $msg="添加成功";
  125. $title=isset($_POST['title'])?$_POST['title']:"";
  126. $district=isset($_POST['district'])?$_POST['district']:"";
  127. if(!empty($title)&&!empty($district)){
  128. Doo::loadModel ( 'L_category' );
  129. $L_category = new L_category ();
  130. $L_category->title=$title;
  131. $L_category->districtid=$district;
  132. $L_category->insert();
  133. }else{
  134. $msg="请输入正确的信息";
  135. }
  136. return "/adminoffice/".$msg;
  137. }
  138. function adminuser(){
  139. $data['memu']="adminuser";
  140. $data['staff']=$this->staff;
  141. Doo::loadModel ( 'L_category' );
  142. Doo::loadModel ( 'staff' );
  143. $staff = new staff ();
  144. $L_category = new L_category ();
  145. $data['category']=$L_category->getCategory();
  146. $data['stafflist']=$staff->getStaff();
  147. $data['staff']=$this->staff;
  148. $this->render ( "/admin/admin_user", $data );
  149. }
  150. function adduser(){
  151. $username=$this->get_args('username')?$this->get_args('username'):"";
  152. $password=$this->get_args('password')?$this->get_args('password'):"";
  153. $cid=is_numeric($this->get_args('cid'))?$this->get_args('cid'):0;
  154. $hiredate=$this->get_args('hiredate')?$this->get_args('hiredate'):"";
  155. $nature=is_numeric($this->get_args('nature'))?$this->get_args('nature'):1;
  156. if(!empty($username)&&!empty($password)&&!empty($cid)&&!empty($hiredate)&&!empty($nature)){
  157. Doo::loadModel ( 'L_category' );
  158. Doo::loadModel ( 'staff' );
  159. Doo::loadModel ( 'tag' );
  160. Doo::loadModel ( 'holidaystaff' );
  161. $staff = new staff ();
  162. $L_category = new L_category ();
  163. //加入默认总部分类
  164. $cagegory=$L_category->getCategoryById($cid);
  165. //根据这个分类加入管理权限
  166. if($cagegory[0]['defult']==1){
  167. $staff->isadmin=1;
  168. }
  169. $staff->username=$username;
  170. $staff->passwork=md5($password);
  171. $staff->cid=$cagegory[0]['cid'];
  172. $staff->category=$cagegory[0]['title'];
  173. $staff->hiredate=$hiredate;
  174. $staff->nature=$nature;
  175. $id=$staff->insert();
  176. $holidaystaff = new HStaff();
  177. $holidaystaff->uid = $id;
  178. $holidaystaff->yearnum = $nature == 1 ? (time() > strtotime("+ 1 year", strtotime($hiredate)) ? 5 : 0) : 0;
  179. $holidaystaff->insert();
  180. for ($i=1;$i<=7;$i++){
  181. $tag = new tag ();
  182. $tag->name="个人标签";
  183. $tag->sid=$id;
  184. $tag->colorid=$i;
  185. $tag->insert();
  186. }
  187. }
  188. return "/adminuser";
  189. }
  190. function adminEdiUser(){
  191. $sid= is_numeric($this->params['sid'])?$this->params['sid']:0;
  192. $msg= isset($this->params['msg'])?$this->params['msg']:"";
  193. if(!empty($sid)){
  194. $data['msg']=urldecode($msg);
  195. Doo::loadModel ( 'L_category' );
  196. Doo::loadModel ( 'staff' );
  197. $staff = new staff ();
  198. $L_category = new L_category ();
  199. $data['newPw']='';
  200. $data['staffInfo']=$staff->getUserById($sid);
  201. $data['category']=$L_category->getCategory();
  202. $data['staff']=$this->staff;
  203. $data['memu']="adminuser";
  204. $this->render ( "/admin/admin_EdiUser", $data );
  205. }else
  206. return "/adminuser";
  207. }
  208. function adminResetUserPw(){
  209. $sid= is_numeric($this->params['sid'])?$this->params['sid']:0;
  210. $msg= isset($this->params['msg'])?$this->params['msg']:"";
  211. if(!empty($sid)){
  212. $data['msg']=urldecode($msg);
  213. Doo::loadModel ( 'L_category' );
  214. Doo::loadModel ( 'staff' );
  215. $staff = new staff ();
  216. $L_category = new L_category ();
  217. $newPw=$this->getRandChar(6);
  218. $staff->sid=$sid;
  219. $staff->passwork=md5($newPw);
  220. $staff->update();
  221. $data['newPw']=$newPw;
  222. $data['staffInfo']=$staff->getUserById($sid);
  223. $data['category']=$L_category->getCategory();
  224. $data['staff']=$this->staff;
  225. $data['memu']="adminuser";
  226. $this->render ( "/admin/admin_EdiUser", $data );
  227. }else
  228. return "/adminuser";
  229. }
  230. function adminDoEdiUser(){
  231. $sid=is_numeric($this->get_args('sid'))?$this->get_args('sid'):0;
  232. $cid=is_numeric($this->get_args('cid'))?$this->get_args('cid'):0;
  233. $gender=$this->get_args('gender')?$this->get_args('gender'):"";
  234. $qq=is_numeric($this->get_args('qq'))?$this->get_args('qq'):0;
  235. $phone=$this->get_args('phone')?$this->get_args('phone'):"";
  236. $telephone=$this->get_args('telephone')?$this->get_args('telephone'):"";
  237. $email=$this->get_args('email')?$this->get_args('email'):"";
  238. $username=$this->get_args('username')?$this->get_args('username'):"";
  239. $nature=$this->get_args('nature')?$this->get_args('nature'):"";
  240. $hiredate=$this->get_args('hiredate')?$this->get_args('hiredate'):"";
  241. if(!empty($sid)){
  242. $msg="";
  243. Doo::loadModel ( 'L_category' );
  244. Doo::loadModel ( 'staff' );
  245. $staff = new staff ();
  246. $L_category = new L_category ();
  247. $categoryInfo=$L_category->getCategoryById($cid);
  248. $staff->sid=$sid;
  249. if ($cid!=0){
  250. $staff->cid=$categoryInfo[0]['cid'];
  251. $staff->category=$categoryInfo[0]['title'];
  252. }
  253. if($categoryInfo[0]['defult']==1){
  254. $staff->isadmin=1;
  255. }else{
  256. $staff->isadmin=0;
  257. }
  258. if (!empty($username))
  259. $staff->username=$username;
  260. if(!empty($gender))
  261. $staff->gender=$gender;
  262. if(!empty($qq)&&is_numeric($qq))
  263. $staff->qq=$qq;
  264. if(!empty($phone))
  265. $staff->phone=$phone;
  266. if(!empty($telephone))
  267. $staff->telephone=$telephone;
  268. if(!empty($email)&&filter_var($email, FILTER_VALIDATE_EMAIL))
  269. $staff->email=$email;
  270. else
  271. $msg="邮箱不正确";
  272. if(!empty($hiredate))
  273. $staff->hiredate=$hiredate;
  274. $staff->nature=$nature;
  275. $staff->update();
  276. $staffmsg = $staff->getUserById($sid);
  277. $this->updateAnnualLeave($staffmsg[0]);
  278. return "/edi/user/".$sid."/".$msg;
  279. }else{
  280. return "/adminuser";
  281. }
  282. }
  283. function adminDoAddCategory(){
  284. $sid=is_numeric($this->get_args('sid'))?$this->get_args('sid'):0;
  285. $cid=is_numeric($this->get_args('cid'))?$this->get_args('cid'):0;
  286. if(!empty($sid)){
  287. Doo::loadModel ( 'L_category' );
  288. Doo::loadModel ( 'staff' );
  289. $staff = new staff ();
  290. $L_category = new L_category ();
  291. $stfInfo=$staff->getOne(array('where'=>'sid ='.$sid,'asArray'=>true));
  292. if($stfInfo['cid']==$cid)
  293. return "/adminuser";
  294. $othcid=explode(',', $stfInfo['othercid']);
  295. if(in_array($cid, $othcid))
  296. return "/adminuser";
  297. array_push($othcid, $cid);
  298. $strCid=implode(',',array_filter($othcid));
  299. $catename=$L_category->getCategoryById($cid);
  300. $othcategory=explode(',', $stfInfo['othercategory']);
  301. array_push($othcategory, $catename[0]['title']);
  302. $strcategory=implode(',',array_filter($othcategory));
  303. $staff->sid=$sid;
  304. $staff->othercid=$strCid;
  305. $staff->othercategory=$strcategory;
  306. $staff->update();
  307. }
  308. return "/adminuser";
  309. }
  310. function adminDeleteUser(){
  311. $sid= is_numeric($this->params['sid'])?$this->params['sid']:0;
  312. if (!empty($sid)){
  313. Doo::loadModel ( 'staff' );
  314. $staff = new staff ();
  315. $staff->sid=$sid;
  316. $staff->delete();
  317. }
  318. return "/adminuser";
  319. }
  320. function adminproduct(){
  321. $data['memu']="adminproduct";
  322. $data['staff']=$this->staff;
  323. Doo::loadModel ( 'product' );
  324. Doo::loadModel ( 'longle' );
  325. $product = new product ();
  326. $longle = new longle ();
  327. $data['product']=$product->getProudct();
  328. foreach ($data['product'] as $key=>$value){
  329. $data['product'][$key]['count']=$longle->count(array('where'=>'product="'.$value['title'].'"'));
  330. }
  331. $this->render ( "/admin/admin_product", $data );
  332. }
  333. function addproduct(){
  334. $title=$this->get_args('title')?$this->get_args('title'):"";
  335. if(!empty($title)){
  336. Doo::loadModel ( 'product' );
  337. $product = new product ();
  338. $product->title=$title;
  339. $product->insert();
  340. }
  341. return "/adminproduct";
  342. }
  343. function adminDeleteProduct(){
  344. $pid= is_numeric($this->params['pid'])?$this->params['pid']:0;
  345. if (!empty($pid)){
  346. Doo::loadModel ( 'product' );
  347. $product = new product ();
  348. $product->pid=$pid;
  349. $product->delete();
  350. }
  351. return "/adminproduct";
  352. }
  353. function adminEdiProduct(){
  354. $pid= is_numeric($this->params['pid'])?$this->params['pid']:0;
  355. $msg= isset($this->params['msg'])?$this->params['msg']:"";
  356. if(!empty($pid)){
  357. $data['msg']=urldecode($msg);
  358. Doo::loadModel ( 'product' );
  359. $product = new product ();
  360. $data['productInfo']=$product->getProductById($pid);
  361. $data['memu']="adminproduct";
  362. $data['staff']=$this->staff;
  363. $this->render ( "/admin/admin_EdiProduct", $data );
  364. }else
  365. return "/adminproduct";
  366. }
  367. function adminDoEdiProduct(){
  368. $pid=is_numeric($this->get_args('pid'))?$this->get_args('pid'):"";
  369. $title=$this->get_args('title')?$this->get_args('title'):"";
  370. $typeid=$this->get_args('typeid')?$this->get_args('typeid'):"";
  371. if(!empty($pid)&&!empty($title)&&!empty($typeid)){
  372. $msg="";
  373. Doo::loadModel ( 'product' );
  374. $product = new product ();
  375. $product->pid=$pid;
  376. $product->title=$title;
  377. $product->typeid=$typeid;
  378. $product->update();
  379. return "/adminproduct";
  380. }else{
  381. return "/adminproduct";
  382. }
  383. }
  384. function adminverify(){
  385. Doo::loadModel('staff');
  386. Doo::loadModel("verify");
  387. $verify=new verify();
  388. $staff=new staff();
  389. Doo::loadModel("role");
  390. $role=new role();
  391. $data['staffList']=$staff->find(array('select'=>'username,sid,avatar','asArray'=>true));
  392. $list=$verify->find(array('asArray'=>true));
  393. $roleList=$role->find(array('asArray'=>true));
  394. foreach ($roleList as $key=>$value){
  395. $staffList=json_decode($value['staff']);
  396. foreach ($staffList as $k=>$v){
  397. $staffList[$k]=substr(strstr($v, '_'), 1);
  398. }
  399. $roleList[$key]['staff']=implode(',', $staffList);
  400. }
  401. foreach ($list as $key=>$value){
  402. $name=json_decode($value['staff']);
  403. $list[$key]['staff']="";
  404. foreach ($name as $k=>$v){
  405. if ($v[1]=='ROLE'){
  406. $roleInfo=$role->getOne(array('where'=>'rid = "'.$v[0].'"','asArray'=>true));
  407. $v[1]=$roleInfo['name'];
  408. }
  409. $list[$key]['staff'].=" ".$v[1];
  410. }
  411. }
  412. $data['roleList']=$roleList;
  413. $data['verify']=$list;
  414. $data['memu']="verify";
  415. $data['staff']=$this->staff;
  416. $this->render ( "/admin/admin_reportGroup", $data );
  417. }
  418. function addVerify(){
  419. $description=$this->get_args('description')?$this->get_args('description'):"";
  420. $staff=$this->get_args('staff')?$this->get_args('staff'):"";
  421. $uidlist=$this->get_args('uidlist')?$this->get_args('uidlist'):"";
  422. $uidlist=explode(",", $uidlist);
  423. Doo::loadModel("role");
  424. $role=new role();
  425. $list=array();
  426. foreach ($uidlist as $key=>$value){
  427. $info=explode(":", $value);
  428. if ($info[1]=='ROLE'){
  429. $roleInfo=$role->getOne(array('where'=>'rid = "'.$info[0].'"','asArray'=>true));
  430. array_push($info, $roleInfo['staff']);
  431. }
  432. array_push($list, $info);
  433. }
  434. if(!empty($description)&&!empty($list)){
  435. Doo::loadModel("verify");
  436. $verify=new verify();
  437. $verify->description=$description;
  438. $verify->staff=json_encode($list);
  439. $verify->insert();
  440. }
  441. return "/adminverify";
  442. }
  443. function adminRole(){
  444. Doo::loadModel('staff');
  445. $staff=new staff();
  446. Doo::loadModel("verify");
  447. $verify=new verify();
  448. Doo::loadModel("role");
  449. $role=new role();
  450. $data['staffList']=$staff->find(array('select'=>'username,sid,avatar','asArray'=>true));
  451. $list=$verify->find(array('asArray'=>true));
  452. $roleList=$role->find(array('asArray'=>true));
  453. foreach ($list as $key=>$value){
  454. $name=json_decode($value['staff']);
  455. $list[$key]['staff']="";
  456. foreach ($name as $k=>$v){
  457. $list[$key]['staff'].=" ".$v[1];
  458. }
  459. }
  460. foreach ($roleList as $key=>$value){
  461. $staff=json_decode($value['staff']);
  462. foreach ($staff as $k=>$v){
  463. //print_r($info);
  464. //$staff[$k]=substr(strstr($v, '_'), 1);
  465. $info=explode('_', $v);
  466. $staff[$k]=$info;
  467. }
  468. $roleList[$key]['list']=$staff;
  469. }
  470. $data['roleList']=$roleList;
  471. $data['verify']=$list;
  472. $data['memu']="verify";
  473. $data['staff']=$this->staff;
  474. $this->render ( "/admin/adminReportGroupRole", $data );
  475. }
  476. function addRole(){
  477. $name=$this->get_args('title')?$this->get_args('title'):"";
  478. $staff=$this->get_args('staff')?$this->get_args('staff'):"";
  479. $list=array();
  480. foreach ($staff as $key=>$value){
  481. $na=explode(":", $value);
  482. array_push($list, $na[0].'_'.$na[1]);
  483. }
  484. if(!empty($name)&&!empty($list)){
  485. Doo::loadModel("role");
  486. $role=new role();
  487. $role->name=$name;
  488. $role->staff=json_encode($list);
  489. $role->insert();
  490. }
  491. return "/adminRole";
  492. }
  493. function delRole(){
  494. $rid= isset($this->params['rid'])?$this->params['rid']:0;
  495. if(!empty($rid)){
  496. Doo::loadModel("role");
  497. $role=new role();
  498. $role->delete(array('where'=>'rid="'.$rid.'"'));
  499. }
  500. return "/adminRole";
  501. }
  502. function updateRole(){
  503. $oldStaff=$this->get_args('oldStaff')?$this->get_args('oldStaff'):"";
  504. $newStaff=$this->get_args('newStaff')?$this->get_args('newStaff'):"";
  505. $rid=$this->get_args('rid')?$this->get_args('rid'):"";
  506. if(!empty($oldStaff)&&!empty($newStaff)&&!empty($rid)){
  507. Doo::loadModel("role");
  508. $role=new role();
  509. $roleInfo=$role->getOne(array('where'=>'rid = "'.$rid.'"','asArray'=>true));
  510. $staffList=json_decode($roleInfo['staff'],true);
  511. foreach ($staffList as $key=>$value){
  512. if ($value==$oldStaff){
  513. $staffList[$key]=$newStaff;
  514. break;
  515. }
  516. }
  517. $role->staff=json_encode($staffList);
  518. $role->update(array('where'=>'rid = "'.$rid.'"'));
  519. }
  520. return "/adminRole";
  521. }
  522. function adminExecute(){
  523. Doo::loadModel('staff');
  524. $staff=new staff();
  525. Doo::loadModel("execute");
  526. $execute=new execute();
  527. $data['staffList']=$staff->find(array('select'=>'username,sid,avatar','asArray'=>true));
  528. $list=$execute->find(array('asArray'=>true));
  529. $execute=array('借款执行人'=>'','借款费用执行人'=>'','报销单执行人'=>'','对公汇款执行人'=>'');
  530. foreach ($list as $key=>$value){
  531. $name=json_decode($value['staff']);
  532. $staffString="";
  533. if (!empty($name)){
  534. foreach ($name as $k=>$v){
  535. $staffString.=" ".$v[1].'<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/'.$v[0].'/'.$value['eid'].'\'" title="删除" class="icon-">k</a>';
  536. }
  537. }
  538. foreach ($execute as $k=>$v){
  539. if ($k==$value['mold']){
  540. $execute[$k]=$name=$staffString;
  541. }
  542. }
  543. }
  544. //print_r($execute);die;
  545. $data['execute']=$execute;
  546. $data['memu']="verify";
  547. $data['staff']=$this->staff;
  548. $this->render ( "/admin/adminCarriedout", $data );
  549. }
  550. function addExecute(){
  551. $mold=$this->get_args('mold')?$this->get_args('mold'):"";
  552. $staff=$this->get_args('staff')?$this->get_args('staff'):"";
  553. if(!empty($mold)&&!empty($staff)){
  554. Doo::loadModel("execute");
  555. $execute=new execute();
  556. $executeInfo=$execute->getOne(array('where'=>'mold ="'.$mold.'" ','asArray'=>true));
  557. if (empty($executeInfo)){
  558. $list=array();
  559. foreach ($staff as $key=>$value){
  560. $info=explode(":", $value);
  561. array_push($list, $info);
  562. }
  563. $execute->mold=$mold;
  564. $execute->staff=json_encode($list);
  565. $execute->insert();
  566. }else{
  567. $list=json_decode($executeInfo['staff'],true);
  568. foreach ($staff as $k=>$v){
  569. $info=explode(":", $v);
  570. foreach ($list as $key=>$value){
  571. if($value[1]==$info[1]){
  572. unset($staff[$k]);
  573. break;
  574. }
  575. }
  576. }
  577. foreach ($staff as $k=>$v){
  578. $info=explode(":", $v);
  579. array_push($list, $info);
  580. }
  581. $execute->staff=json_encode($list);
  582. $execute->update(array('where'=>'eid = '.$executeInfo['eid']));
  583. }
  584. }
  585. return "/adminExecute";
  586. }
  587. function delExecute(){
  588. $uid=isset($this->params['uid'])&&is_numeric($this->params['uid'])?$this->params['uid']:0;
  589. $eid=isset($this->params['eid'])&&is_numeric($this->params['eid'])?$this->params['eid']:0;
  590. if(!empty($uid)&&!empty($eid)){
  591. Doo::loadModel("execute");
  592. $execute=new execute();
  593. $executeInfo=$execute->getOne(array('where'=>'eid ="'.$eid.'" ','asArray'=>true));
  594. if (empty($executeInfo))
  595. return "/adminExecute";
  596. $ini=array();
  597. $list=json_decode($executeInfo['staff'],true);
  598. foreach ($list as $k=>$v){
  599. if ($v[0]==$uid){
  600. $ini=$list[$k];
  601. unset($list[$k]);break;
  602. }
  603. }
  604. file_put_contents("protected/config/execute/execute.ini", ",".$ini[0], FILE_APPEND);
  605. $execute->staff=json_encode($list);
  606. $execute->update(array('where'=>'eid = '.$executeInfo['eid']));
  607. }
  608. return "/adminExecute";
  609. }
  610. function adminInvoice(){
  611. Doo::loadModel('staff');
  612. $staff=new staff();
  613. Doo::loadModel("invoiceManage");
  614. $invoiceManage=new invoiceManage();
  615. $data['staffList']=$staff->find(array('select'=>'username,sid,avatar','asArray'=>true));
  616. $list=$invoiceManage->find(array('asArray'=>true));
  617. $execute=array('收款管理'=>'','发票审批'=>'','发票打印'=>'','发票邮寄'=>'','公司汇总查阅'=>'');
  618. foreach ($list as $key=>$value){
  619. $name=json_decode($value['staff']);
  620. $staffString="";
  621. if (!empty($name)){
  622. foreach ($name as $k=>$v){
  623. $staffString.="<span class='tagGroup'> ".$v[1].'<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceManage/'.$v[0].'/'.$value['iid'].'\'" title="删除" class="icon-">k</a></span>';
  624. }
  625. }
  626. foreach ($execute as $k=>$v){
  627. if ($k==$value['mold']){
  628. $execute[$k]=$name=$staffString;
  629. }
  630. }
  631. }
  632. $data['invoice']=$execute;
  633. $data['memu']="invoice";
  634. $data['staff']=$this->staff;
  635. $this->render ( "/admin/adminInvoice", $data );
  636. }
  637. function addInvoiceManage(){
  638. $mold=$this->get_args('mold')?$this->get_args('mold'):"";
  639. $staff=$this->get_args('staff')?$this->get_args('staff'):"";
  640. if(!empty($mold)&&!empty($staff)){
  641. Doo::loadModel("invoiceManage");
  642. $execute=new invoiceManage();
  643. $executeInfo=$execute->getOne(array('where'=>'mold ="'.$mold.'" ','asArray'=>true));
  644. if (empty($executeInfo)){
  645. $list=array();
  646. foreach ($staff as $key=>$value){
  647. $info=explode(":", $value);
  648. array_push($list, $info);
  649. }
  650. $execute->mold=$mold;
  651. $execute->staff=json_encode($list);
  652. $execute->insert();
  653. }else{
  654. $list=json_decode($executeInfo['staff'],true);
  655. foreach ($staff as $k=>$v){
  656. $info=explode(":", $v);
  657. foreach ($list as $key=>$value){
  658. if($value[1]==$info[1]){
  659. unset($staff[$k]);
  660. break;
  661. }
  662. }
  663. }
  664. foreach ($staff as $k=>$v){
  665. $info=explode(":", $v);
  666. array_push($list, $info);
  667. }
  668. $execute->staff=json_encode($list);
  669. $execute->update(array('where'=>'iid = '.$executeInfo['iid']));
  670. }
  671. }
  672. return "/adminInvoice";
  673. }
  674. function delInvoiceManage(){
  675. $uid=isset($this->params['uid'])&&is_numeric($this->params['uid'])?$this->params['uid']:0;
  676. $iid=isset($this->params['iid'])&&is_numeric($this->params['iid'])?$this->params['iid']:0;
  677. if(!empty($uid)&&!empty($iid)){
  678. Doo::loadModel("invoiceManage");
  679. $execute=new invoiceManage();
  680. $executeInfo=$execute->getOne(array('where'=>'iid ="'.$iid.'" ','asArray'=>true));
  681. if (empty($executeInfo))
  682. return "/adminInvoice";
  683. $ini=array();
  684. $list=json_decode($executeInfo['staff'],true);
  685. foreach ($list as $k=>$v){
  686. if ($v[0]==$uid){
  687. $ini=$list[$k];
  688. unset($list[$k]);break;
  689. }
  690. }
  691. $execute->staff=json_encode($list);
  692. $execute->update(array('where'=>'iid = '.$executeInfo['iid']));
  693. }
  694. return "/adminInvoice";
  695. }
  696. function ajaxRoleStaff(){
  697. $name=$this->get_args('name')?$this->get_args('name'):"";
  698. Doo::loadModel('staff');
  699. $staff=new staff();
  700. $staffList=$staff->find(array('select'=>'username,sid,avatar','where'=>'username != "'.$name.'" and username !="admin"','asArray'=>true));
  701. $html='';
  702. foreach ($staffList as $key=>$value){
  703. $html.='<option value='.$value['sid'].'_'.$value['username'].'>'.$value['username'].'</option>';
  704. }
  705. echo json_encode(array("success"=>true,'html'=>$html));die;
  706. }
  707. function loadCVS(){
  708. Doo::loadModel('longle');
  709. $longle=new longle();
  710. $list=$longle->find(array('select'=>'key_num','asArray' => TRUE));
  711. $file = fopen(DOO::conf()->SITE_PATH."upload/key2.csv",'r');
  712. while ($data = fgetcsv($file)) {
  713. $goods_list[$data[0]] = $data[1] ;
  714. }
  715. fclose($file);
  716. $sqlArray=array();
  717. $sql='UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  718. foreach($list as $key=>$value){
  719. if(array_key_exists($value['key_num'],$goods_list)){
  720. //echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  721. //$longle->SerialNumber=$goods_list[$value['key_num']];
  722. //$longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  723. $sql.=' WHEN "'.$value['key_num'].'" THEN "'.$goods_list[$value['key_num']].'" ';
  724. array_push($sqlArray, '"'.$value['key_num'].'"');
  725. unset($goods_list[$value['key_num']]);
  726. }
  727. }
  728. $sql.='END WHERE key_num IN ('.implode(',', $sqlArray).')';
  729. echo $sql.'<br/>--------------------------------<br/>';
  730. foreach ($goods_list as $key=>$value){
  731. echo $key.','.$value.'<br/>';
  732. }
  733. }
  734. private function getRandChar($length){
  735. $str = null;
  736. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  737. $max = strlen($strPol)-1;
  738. for($i=0;$i<$length;$i++){
  739. $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
  740. }
  741. return $str;
  742. }
  743. private function getReceiptCount(){
  744. $status=2;
  745. $year=date('Y');
  746. Doo::loadModel('receipt');
  747. $receipt=new receipt();
  748. Doo::loadModel('verify');
  749. $verify=new verify();
  750. //user verify ID
  751. $vidList=array();
  752. $verifyDetail=$verify->find(array('where'=>'staff like "%\"'.$this->staff[0]['sid'].'\"%"','asArray'=>true));
  753. foreach ($verifyDetail as $key=>$value){
  754. array_push($vidList, $value['vid']);
  755. }
  756. $vid=implode(",", $vidList);
  757. if(empty($verifyDetail))
  758. $vid=0;
  759. $dateCondition=" and Year(date) =".$year;
  760. $approvalCondition=' and verifyStaff not like "%\"'.$this->staff[0]['sid'].'\":{%" ';
  761. $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  762. return count($receiptList);
  763. }
  764. /**
  765. * 格式化excel文件为数组
  766. * @param unknown_type $file_url
  767. * @param unknown_type $mcid
  768. */
  769. function _format_excel_to_array($file_url = "") {
  770. if (! file_exists ( $file_url ))
  771. return array ();
  772. Doo::loadClass ( 'PHPExcel' );
  773. $PHPExcel = new PHPExcel ();
  774. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  775. if (! $PHPReader->canRead ( $file_url )) {
  776. $PHPReader = new PHPExcel_Reader_Excel5 ();
  777. if (! $PHPReader->canRead ( $file_url )) {
  778. echo 'no Excel';
  779. return;
  780. }
  781. }
  782. $PHPExcel = $PHPReader->load ( $file_url );
  783. /**读取excel文件中的第一个工作表*/
  784. $currentSheet = $PHPExcel->getSheet ( 0 );
  785. /**取得最大的列号*/
  786. $allColumn = $currentSheet->getHighestColumn ();
  787. /**取得一共有多少行*/
  788. $allRow = $currentSheet->getHighestRow ();
  789. $excel_array = array ();
  790. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  791. $excel_column = array ();
  792. //后期改进
  793. if($allColumn=='AM')
  794. $allColumn='Z';
  795. /**从第A列开始输出*/
  796. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  797. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  798. /**ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',*/
  799. $val = "'" . addslashes ( $val ) . "'";
  800. if ($currentColumn == 'A')
  801. $excel_column ['key_num'] = $val;
  802. elseif ($currentColumn == 'C')
  803. $excel_column ['product'] = $val;
  804. elseif ($currentColumn == 'D'){
  805. $val=str_replace("'","",$val);
  806. $excel_column ['make_day'] = $this->excelTime($val);
  807. }elseif($currentColumn == 'E'){
  808. $val=str_replace("'","",$val);
  809. $excel_column ['alloted_time'] = $this->excelTime($val);
  810. }elseif($currentColumn == 'F'){
  811. $val=str_replace("'","",$val);
  812. $excel_column ['version'] = $val;
  813. }elseif ($currentColumn == 'B'){
  814. $val=str_replace("'","",$val);
  815. $excel_column ['SerialNumber'] = $val;
  816. }
  817. }
  818. array_push ( $excel_array, $excel_column );
  819. }
  820. return $excel_array;
  821. }
  822. function excelTime($date, $time = false)
  823. {
  824. if (function_exists ( 'GregorianToJD' ))
  825. {
  826. if (is_numeric ( $date ))
  827. {
  828. $jd = GregorianToJD ( 1, 1, 1970 );
  829. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  830. $date = explode ( '/', $gregorian );
  831. $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" .
  832. str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" .
  833. str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
  834. return $date_str;
  835. }
  836. } else
  837. {
  838. $date = $date > 25568 ? $date + 1 : 25569;
  839. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  840. $ofs = (70 * 365 + 17 + 2) * 86400;
  841. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  842. }
  843. return $date;
  844. }
  845. function _GetFileEXT($filename) {
  846. $pics = explode ( '.', $filename );
  847. $num = count ( $pics );
  848. return $pics [$num - 1];
  849. }
  850. /**
  851. * 获取get或者POST值
  852. * @param string $name 属性名称
  853. * @return fixed 值
  854. */
  855. function get_args($name) {
  856. if (isset ( $_GET [$name] )) {
  857. if (is_array ( $_GET [$name] ))
  858. return $_GET [$name];
  859. else {
  860. return addslashes ( $_GET [$name] );
  861. //return $_GET [$name] ;
  862. }
  863. } elseif (isset ( $_POST [$name] )) {
  864. if (is_array ( $_POST [$name] ))
  865. return $_POST [$name];
  866. else {
  867. return addslashes ( $_POST [$name] );
  868. //return $_POST [$name];
  869. }
  870. } else {
  871. return false;
  872. }
  873. }
  874. function get_previous($on_page = 1) {
  875. return $on_page != 0 ? $on_page - 1 : $on_page;
  876. }
  877. /**
  878. * 获得分页数据
  879. * @param unknown_type $table
  880. * @param unknown_type $condition
  881. * @param unknown_type $on_page
  882. * @param unknown_type $page_size
  883. */
  884. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "",$tagSQL) {
  885. $page_c = "";
  886. $page ['previous'] = $this->get_previous ( $on_page );
  887. $page ['on_page'] = $on_page;
  888. $total_count = $this->get_table_Tcount ( $table, $condition,$tagSQL );
  889. $total = intval ( $total_count / $page_size );
  890. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  891. $page ['total_data'] = $total_count;
  892. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  893. $i = 1;
  894. $page_max = 1;
  895. if ($on_page > 10) {
  896. $page_max = intval ( $on_page / 10 ) + 1;
  897. $i = intval ( $on_page / 10 ) * 10 - 1;
  898. }
  899. $page ['page'] = $page_c;
  900. $page ['lower'] = (-- $on_page) * $page_size;
  901. return $page;
  902. }
  903. /**
  904. * 获得分页数据
  905. * @param unknown_type $table
  906. * @param unknown_type $condition
  907. * @param unknown_type $on_page
  908. * @param unknown_type $page_size
  909. */
  910. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page",$staffid="",$search,$tooltip,$cateid,$tagSQL) {
  911. $page_c = "";
  912. $page ['previous'] = $this->get_previous ( $on_page );
  913. $page ['on_page'] = $on_page;
  914. $total_count = $this->get_table_count ( $table, $condition ,$staffid,$search,$tooltip,$cateid,$tagSQL);
  915. $total = intval ( $total_count / $page_size );
  916. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  917. $page ['total_data'] = $total_count;
  918. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  919. $i = 1;
  920. $page_max = 1;
  921. if ($on_page > 10) {
  922. $page_max = intval ( $on_page / 10 ) + 1;
  923. $i = intval ( $on_page / 10 ) * 10 - 1;
  924. }
  925. for(; $i <= $page ['total_page']; $i ++) {
  926. if ($i == $on_page) {
  927. if ($other == "page")
  928. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  929. else
  930. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  931. } else if ($other == "page")
  932. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  933. else
  934. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  935. if ($i == (10 * $page_max))
  936. break;
  937. }
  938. $page ['page'] = $page_c;
  939. $page ['lower'] = (-- $on_page) * $page_size;
  940. return $page;
  941. }
  942. /**
  943. * 获取总页数
  944. * @param unknown_type $table
  945. * @param unknown_type $condition
  946. */
  947. public function get_table_Tcount($table = "", $condition = "",$tagSQL) {
  948. if ($tagSQL)
  949. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where ".$condition ;
  950. else
  951. $sql = "select count(*) as count from CLD_company where " . $condition ;
  952. $query = Doo::db ()->query ( $sql );
  953. $result = $query->fetch ();
  954. return $result ['count'];
  955. }
  956. /**
  957. * 获取总页数
  958. * @param unknown_type $table
  959. * @param unknown_type $condition
  960. */
  961. public function get_table_count($table = "", $condition = "",$staffid="",$search,$tooltip,$cateid,$tagSQL) {
  962. //$sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  963. //echo $staffid;die;
  964. //
  965. if (!empty($staffid)){
  966. //$staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  967. $sql = "select count(*) as count from CLD_client as b left join CLD_tag_client as c on (b.cid=c.client) where 1 " . $condition ;
  968. }else{
  969. if(strlen($condition)==1||empty($condition))
  970. $sql = "select count(*) as count from CLD_client as a ".$condition;
  971. else
  972. $sql = "select count(*) as count from CLD_client as a left join CLD_tag_client as c on (a.cid=c.client) where 1 ".$condition;
  973. }
  974. if(!empty($search))
  975. $sql = "select count(*) as count from CLD_client as a where 1 ".$condition ;
  976. if(!empty($tooltip)){
  977. $condition=str_replace("a.","c.",$condition);
  978. if ($tagSQL)
  979. $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_tag_client as c on (a.cid=c.client) left join CLD_client as b on (c.client=b.cid ) where a.name like '%".$tooltip."%' and a.cateid = ".$cateid." ".$condition ;
  980. else
  981. $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_client as b on (a.cid=b.cid ) where a.name like '%".$tooltip."%' and a.cateid = ".$cateid." ".$condition ;
  982. }
  983. //echo $sql;
  984. $query = Doo::db ()->query ( $sql );
  985. $result = $query->fetch ();
  986. return $result ['count'];
  987. }
  988. public function holidayGroup(){
  989. Doo::loadModel('staff');
  990. Doo::loadModel("holidayacman");
  991. $acman=new HACMan();
  992. $staff=new staff();
  993. $data['staffList']=$staff->find(array('select'=>'username,sid,wxid', 'where' => 'cid!=1','asArray'=>true));
  994. $acmanlist=$acman->find(array('where' => 'type=0','asArray'=>true));
  995. $data['acmanlist'] = $acmanlist;
  996. $data['staff']=$this->staff;
  997. $data['memu'] = 'holiday';
  998. $this->render( "/admin/admin_holidayGroup", $data );
  999. }
  1000. public function addHolidayApprover(){
  1001. if(!isset($_POST['title']) || empty($_POST['title'])){
  1002. exit('请输入组名');
  1003. }
  1004. if(!isset($_POST['staff']) || empty($_POST['staff'])){
  1005. exit('请选择成员');
  1006. }
  1007. $idname = $name = $pinyinname = array();
  1008. foreach($_POST['staff'] as $k => $v){
  1009. $msg = explode(':',$v);
  1010. array_push($idname,$msg[0]);
  1011. array_push($name,$msg[1]);
  1012. array_push($pinyinname,$msg[2]);
  1013. }
  1014. var_dump($idname);
  1015. var_dump($name);
  1016. var_dump($pinyinname);
  1017. exit;
  1018. Doo::loadModel("holidayacman");
  1019. $acman=new HACMan();
  1020. $acman->typename = $_POST['title'];
  1021. var_dump($_POST);
  1022. exit;
  1023. }
  1024. public function holidayCSGroup(){
  1025. $data['memu'] = 'holiday';
  1026. $this->render( "/admin/admin_holidayGroup_cc", $data );
  1027. }
  1028. //检查年假是否过期并更新年假
  1029. private function updateAnnualLeave($staff){
  1030. Doo::loadModel('holidaystaff');
  1031. $hstaff = new HStaff();
  1032. $hstaffmsg = $hstaff->getOne(array('where' => 'uid='.$staff['sid'],'asArray' => TRUE));
  1033. $hiredate = $staff['hiredate'];
  1034. if(intval((time()-strtotime($hiredate))/(86400*365)) != $hstaffmsg['hadyear'] && $staff['nature'] == 1 ){
  1035. $hstaff->uid = $staff['sid'];
  1036. $hstaff->hadyear = intval((time()-strtotime($hiredate))/(86400*365));
  1037. $hstaff->yearnum = intval((time()-strtotime($hiredate))/(86400*365)) != 0 ? 5 : 0;
  1038. $hstaff->update();
  1039. }
  1040. }
  1041. }
  1042. ?>