L_category.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. /**
  49. * 软件获取办事处
  50. * @return string
  51. */
  52. public function getCategoryBySoft() {
  53. Doo::loadClass ( 'XDeode' );
  54. $XDeode = new XDeode ( 5 );
  55. Doo::loadModel ( 'department' );
  56. $department = new department ();
  57. $list = $this->find ( array (
  58. 'asc' => 'cid',
  59. 'asArray' => TRUE
  60. ) );
  61. foreach ( $list as $key => $value ) {
  62. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  63. }
  64. return $list;
  65. }
  66. public function getCategory() {
  67. Doo::loadClass ( 'XDeode' );
  68. $XDeode = new XDeode ( 5 );
  69. Doo::loadModel ( 'department' );
  70. $department = new department ();
  71. $list = $this->find ( array (
  72. 'asc' => 'cid',
  73. 'asArray' => TRUE
  74. ) );
  75. foreach ( $list as $key => $value ) {
  76. $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
  77. $list [$key] ['department'] =$department->getDepartmentBycid($value ['cid']);
  78. }
  79. return $list;
  80. }
  81. /**
  82. * 获得办事处和部门
  83. * @return unknown
  84. */
  85. public function getCategoryDepartment(){
  86. Doo::loadClass ( 'XDeode' );
  87. $XDeode = new XDeode ( 5 );
  88. Doo::loadModel ( 'department' );
  89. $department = new department ();
  90. $categorylist2 = $this->find ( array (
  91. 'desc' => 'cid',
  92. 'asArray' => TRUE
  93. ) );
  94. $categorylist3=$categorylist2;
  95. $bakCategory = array ();
  96. foreach ( $categorylist3 as $key => $value ) {
  97. $departList = $department->getDepartmentBycid ( $value ['cid'] );
  98. if (! empty ( $departList )) {
  99. array_unshift ( $bakCategory, $value );
  100. unset ( $categorylist2 [$key] );
  101. foreach ( $departList as $v ) {
  102. array_unshift ( $bakCategory, array (
  103. 'cid' => $v ['cid'],
  104. 'cidKey'=> $XDeode->encode ( $v ['cid'] ),
  105. 'title' => $value ['title'],
  106. 'did' => $v ['did'],
  107. 'didKey'=>$XDeode->encode ( $v ['did'] ),
  108. 'departmentName' => $v ['departmentName']
  109. ) );
  110. }
  111. }
  112. }
  113. foreach ( $bakCategory as $value ) {
  114. array_unshift ( $categorylist2, $value );
  115. }
  116. foreach ($categorylist2 as $key=>$value){
  117. $categorylist2 [$key]['cidKey']=$XDeode->encode ( $value ['cid'] );
  118. if(!isset($categorylist2 [$key]['didKey'])||empty($categorylist2 [$key]['didKey']))
  119. $categorylist2 [$key]['didKey']='';
  120. }
  121. return $categorylist2;
  122. }
  123. public function getUserByIdList($puid) {
  124. return $this->find ( array (
  125. 'where' => "uid= '" . $puid . "'",
  126. 'asArray' => TRUE
  127. ) );
  128. }
  129. public function getCategoryStaff() {
  130. $list = $this->find ( array (
  131. 'asArray' => TRUE
  132. ) );
  133. Doo::loadModel ( 'staff' );
  134. $staff = new staff ();
  135. foreach ( $list as $key => $value ) {
  136. $list [$key] ['staff'] = $staff->getStaffByCid ( $value ['cid'] );
  137. }
  138. return $list;
  139. }
  140. }
  141. ?>