AdminController.php 35 KB

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