IndexController.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. *
  4. * @author Mike <m@9026.com>
  5. * @version 1.0
  6. * @date 2015年10月12日
  7. *
  8. */
  9. namespace App\Http\Controllers\Admin\Base;
  10. use App\Http\Controllers\Admin\Controller;
  11. use App\Models\InnerDevice;
  12. use App\Models\Option;
  13. use App\Models\Order;
  14. use App\Models\Project;
  15. use App\Models\User;
  16. use App\Models\UserAuth;
  17. use App\Services\Base\Tree;
  18. use App\Services\Base\BaseArea;
  19. use App\Services\Admin\Menus;
  20. use App\Services\Admin\Acl;
  21. class IndexController extends Controller
  22. {
  23. public function __construct()
  24. {
  25. parent::__construct();
  26. }
  27. function index() {
  28. if($this->_user['is_root']) {
  29. $obj = new Menus();
  30. $menus = $obj->search(array('level'=>2,'display'=>1),$orderby=array('sort'=>'desc'),$pagesize = 100000);
  31. $menus = $menus->toArray();
  32. $menus = list_to_tree($menus['data']);
  33. }else{
  34. $obj = new Acl();
  35. $data = $obj->getRoleMenu($this->_user['admin_role_id']);
  36. $menus = list_to_tree($data);
  37. }
  38. return view('admin.base.index.index',compact('menus'));
  39. }
  40. function welcome() {
  41. // return redirect('/admin/AdminUser/index');
  42. $total_device = InnerDevice::count();
  43. $total_project = Project::count();
  44. $total_money = Order::sum('money') / 100;
  45. $users_total = User::count();
  46. $users_not_auth_total = UserAuth::where('active', 2)->count();
  47. $users_auth_total = UserAuth::count();
  48. $items = InnerDevice::get();
  49. $types = ['free', 'using', 'repair', 'scrap'];
  50. $device_stat = [];
  51. foreach ($types as $type) {
  52. $id = Option::get('inner_devices', 'status', $type);
  53. $num = $items->where('status', $id)->count();
  54. $device_stat[$type] = $num;
  55. }
  56. $user_auths = UserAuth::where('active', 2)->limit(8)->get();
  57. return view('admin.base.index.welcome', compact('total_device', 'total_project', 'total_money', 'users_total', 'users_auth_total', 'users_not_auth_total', 'device_stat', 'user_auths'));
  58. }
  59. function createAreaDate(){
  60. //Base-index-createareadate.do
  61. header("Content-type:text/html;charset=utf-8");
  62. $areaObj = new BaseArea();
  63. $data = $areaObj->getLevel();
  64. $treeObj = new Tree();
  65. $treeObj -> init($data);
  66. $info = $treeObj -> getTree();
  67. $output = array();
  68. foreach($info AS $key => $val){
  69. if($val['id'] == '100000') continue;
  70. $val['level'] = $val['level'] - 1;
  71. unset($val['grade'], $val['spacer']);
  72. $output[]= $val;
  73. }
  74. $str = json_encode($output);
  75. $area_path = public_path() . '/base/js/areadata.js';
  76. file_put_contents($area_path, $str);
  77. echo $str;exit;
  78. }
  79. }