L_category.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class L_category extends DooModel {
  4. public $cid;
  5. public $title;
  6. public $defult;
  7. public $districtid;
  8. public $_table = 'CLD_L_category';
  9. public $_primarykey = 'cid';
  10. public $_fields = array (
  11. 'cid',
  12. 'title',
  13. 'defult',
  14. 'districtid'
  15. );
  16. public function checkUser($uid, $passwork) {
  17. return $this->find ( array (
  18. 'where' => "uid= '" . $uid . "' and passwork = '" . addslashes ( $passwork ) . "'",
  19. 'asArray' => TRUE
  20. ) );
  21. }
  22. public function getCategoryInCid($cidString = '') {
  23. Doo::loadClass ( 'XDeode' );
  24. $XDeode = new XDeode ( 5 );
  25. if (empty ( $cidString ))
  26. return array ();
  27. $list= $this->find ( array (
  28. 'where' => "cid in ( " .$cidString . ") ",
  29. 'asArray' => TRUE
  30. ) );
  31. foreach ( $list as $key => $value ) {
  32. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  33. }
  34. return $list;
  35. }
  36. public function getCategoryById($cid = 0, $othercid = "") {
  37. if (! empty ( $othercid ))
  38. return $this->find ( array (
  39. 'where' => "cid in ( " . $cid . "," . $othercid . ") ",
  40. 'asArray' => TRUE
  41. ) );
  42. else
  43. return $this->find ( array (
  44. 'where' => "cid= '" . $cid . "' ",
  45. 'asArray' => TRUE
  46. ) );
  47. }
  48. public function getCategory() {
  49. Doo::loadClass ( 'XDeode' );
  50. $XDeode = new XDeode ( 5 );
  51. Doo::loadModel ( 'department' );
  52. $department = new department ();
  53. $list = $this->find ( array (
  54. 'asc' => 'cid',
  55. 'asArray' => TRUE
  56. ) );
  57. foreach ( $list as $key => $value ) {
  58. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  59. $list [$key] ['department'] =$department->getDepartmentBycid($value ['cid']);
  60. }
  61. return $list;
  62. }
  63. /**
  64. * 获得办事处和部门
  65. * @return unknown
  66. */
  67. public function getCategoryDepartment(){
  68. Doo::loadClass ( 'XDeode' );
  69. $XDeode = new XDeode ( 5 );
  70. Doo::loadModel ( 'department' );
  71. $department = new department ();
  72. $categorylist2 = $this->find ( array (
  73. 'desc' => 'cid',
  74. 'asArray' => TRUE
  75. ) );
  76. $categorylist3=$categorylist2;
  77. $bakCategory = array ();
  78. foreach ( $categorylist3 as $key => $value ) {
  79. $departList = $department->getDepartmentBycid ( $value ['cid'] );
  80. if (! empty ( $departList )) {
  81. array_unshift ( $bakCategory, $value );
  82. unset ( $categorylist2 [$key] );
  83. foreach ( $departList as $v ) {
  84. array_unshift ( $bakCategory, array (
  85. 'cid' => $v ['cid'],
  86. 'cidKey'=> $XDeode->encode ( $v ['cid'] ),
  87. 'title' => $value ['title'],
  88. 'did' => $v ['did'],
  89. 'didKey'=>$XDeode->encode ( $v ['did'] ),
  90. 'departmentName' => $v ['departmentName']
  91. ) );
  92. }
  93. }
  94. }
  95. foreach ( $bakCategory as $value ) {
  96. array_unshift ( $categorylist2, $value );
  97. }
  98. foreach ($categorylist2 as $key=>$value){
  99. $categorylist2 [$key]['cidKey']=$XDeode->encode ( $value ['cid'] );
  100. if(!isset($categorylist2 [$key]['didKey'])||empty($categorylist2 [$key]['didKey']))
  101. $categorylist2 [$key]['didKey']='';
  102. }
  103. return $categorylist2;
  104. }
  105. public function getUserByIdList($puid) {
  106. return $this->find ( array (
  107. 'where' => "uid= '" . $puid . "'",
  108. 'asArray' => TRUE
  109. ) );
  110. }
  111. public function getCategoryStaff() {
  112. $list = $this->find ( array (
  113. 'asArray' => TRUE
  114. ) );
  115. Doo::loadModel ( 'staff' );
  116. $staff = new staff ();
  117. foreach ( $list as $key => $value ) {
  118. $list [$key] ['staff'] = $staff->getStaffByCid ( $value ['cid'] );
  119. }
  120. return $list;
  121. }
  122. }
  123. ?>