OrderTotal(cur_org_id()); $this->assign('data',$data); $this->assign('meta_title','订单统计'); return $this->fetch(); } /** * 完成工时统计 * * @author wst * @date 2021/4/12 16:05 */ public function duration(){ $month = request()->get('month')?request()->get('month'):date('Y-m'); $data = (new \app\model\Todo())->duration(cur_org_id(),$month); $this->assign('data',$data); $this->assign('month',$month); $this->assign('meta_title','完成工时统计'); return $this->fetch(); } /** * 巡更工作量统计 * * @author wst * @date 2021/4/12 18:13 */ public function PatrolWork(){ $data = (new \app\model\PatrolAddr())->PatrolWork(cur_org_id(),1); $this->assign('data',$data); $this->assign('meta_title','巡检巡查工作量统计'); return $this->fetch(); } /** * 设备台账工作量统计 * * @author wst * @date 2021/4/12 18:13 */ public function DeviceWork(){ $data = (new \app\common\model\Device())->DeviceWork(cur_org_id()); $this->assign('data',$data); $this->assign('meta_title','设备维保工作量统计'); return $this->fetch(); } /** * 日常工作工作量统计 * * @author wst * @date 2021/4/12 18:13 */ public function DailyWork(){ $data = (new \app\common\model\Daily())->DailyWork(cur_org_id()); $this->assign('data',$data); $this->assign('meta_title','日常工作量统计'); return $this->fetch(); } /** * 巡更人员工作量统计 * * @author wst * @date 2021/4/12 18:13 */ public function WorkerPatrol(){ $search['start'] = request()->get('start'); $search['end'] = request()->get('end'); if(empty($search['start'])){ // 未传时间默认近7天的 $search['start'] = date('Y-m-d',time()-(6*24*60*60)); $search['end'] = date('Y-m-d'); } $data = (new \app\model\PatrolTask())->WorkerPatrol(cur_org_id(),$search,1); $this->assign('data',$data); $this->assign('month',$search); $this->assign('meta_title','巡检巡查人员工作量统计'); return $this->fetch(); } //预约统计 public function ServiceCount(){ $type=input('type'); $start=input('start'); $end=input('end'); if($type == 1){ $meta_title = '餐饮预约统计'; }elseif ($type == 2){ $meta_title = '美发预约统计'; }elseif ($type == 3){ $meta_title = '洗衣预约统计'; }elseif ($type == 4){ $meta_title = '医疗预约统计'; }elseif ($type == 5){ $meta_title = '活动室预约统计'; } //获取服务id $serviceId = Db::name('service')->where('org_id',$this->org_id)->where('type',$type)->value('id'); if(!$serviceId){ $data = []; $this->assign('data',$data); } if(!$start && !$end){ $end = date('Y-m-d H:i:s'); $start = date('Y-m-d H:i:s',strtotime("$start -1 month")); } if($start >= $end){ $this->error('开始时间不能大于结束时间'); } if($type == 1 || $type == 2){ $map[] = ['service_id','=',$serviceId]; $cateList = Db::name('service_cate')->where($map)->order('id asc')->select()->toArray(); $map[] = ['del','=',0]; $itemList = Db::name('service_item')->where($map)->order('id asc')->select()->toArray(); $this->assign('itemList',$itemList); $this->assign('cateList',$cateList); if($start && $end){ $where[] = ['sb.create_time','>=',$start]; $where[] = ['sb.create_time','<=',$end]; } $where[] = ['sb.service_id','=',$serviceId]; $where[] = ['sb.org_id','=',$this->org_id]; $data = []; foreach ($itemList as $k=>$v){ $data[$k]['title']= $v['title']; foreach ($cateList as $kk=>$vv){ $bookList = Db::name('service_book') ->alias('sb') ->field('sb.*') ->join('service_book_cate sbc','sbc.service_book_id=sb.id') ->where('sb.service_item_id',$v['id']) ->where('sbc.service_cate_id',$vv['id']) ->where($where) ->select() ->toArray(); $total = 0; foreach ($bookList as $kay=>$val){ $total +=$val['nums']; } $data[$k]['list'][$kk] = $total; } } $count = []; foreach ($cateList as $k=>$v){ $bookList = Db::name('service_book') ->alias('sb') ->field('sb.*') ->join('service_book_cate sbc','sbc.service_book_id=sb.id') ->where('sbc.service_cate_id',$v['id']) ->where($where) ->select() ->toArray(); $countNum = 0; foreach ($bookList as $kk=>$vv){ $countNum +=$vv['nums']; } $count[$k]['count'] = $countNum; } $this->assign('count',$count); } if($type == 3){ $where[] = ['service_id','=',$serviceId]; $where[] = ['org_id','=',$this->org_id]; if($start && $end){ $where[] = ['create_time','>=',$start]; $where[] = ['create_time','<=',$end]; } $data = []; $bookList = Db::name('service_book')->where($where)->select()->toArray(); $total = 0; foreach ($bookList as $k=>$v){ $total +=$v['nums']; } $data['k'] = 1; $data['count'] = $total; } if($type == 4 || $type == 5){ $map[] = ['service_id','=',$serviceId]; $map[] = ['del','=',0]; $itemList = Db::name('service_item')->where($map)->order('id asc')->select()->toArray(); $this->assign('itemList',$itemList); $where[] = ['create_time','>=',$start]; $where[] = ['create_time','<=',$end]; $where[] = ['service_id','=',$serviceId]; $where[] = ['org_id','=',$this->org_id]; $data = []; foreach ($itemList as $k=>$v){ $data[$k]['id']= $v['id']; $data[$k]['title']= $v['title']; $bookList = Db::name('service_book') ->where('service_item_id',$v['id']) ->where($where) ->select() ->toArray(); $total = 0; foreach ($bookList as $kay=>$val){ $total +=$val['nums']; } $data[$k]['count'] = $total; } $countNum = 0; foreach ($data as $kay =>$val){ $countNum += $val['count']; } $this->assign('countNum',$countNum); } $this->assign('start',$start); $this->assign('end',$end); $this->assign('data',$data); $this->assign('type',$type); $this->assign('meta_title',$meta_title); return $this->fetch(); } public function serviceCountDetails(){ $month = input('month'); $itemId = input('itemId',0); $serviceId = input('serviceId',0); if(!$month && !$itemId){ $this->error('参数错误'); } $startMonth = $month.'-1 00:00:00'; $endMonth = $month.'-31 23:59:59'; $sWeek = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)); $eWeek = date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)); $startWeek = $sWeek.' 00:00:00'; $endWeek = $eWeek.' 23:59:59'; $day = date('Y-m-d'); $startDay= $day.' 00:00:00'; $endDay= $day.' 23:59:59'; $cateList = Db::name('service_cate')->where('service_id',$serviceId)->where('enable',1)->select()->toArray(); foreach ($cateList as $k=>$v){ $bookCate = Db::name('service_book_cate') ->where('service_book_cate_id',$v['id']) ->select() ->toArray(); $ids = []; foreach ($bookCate as $kay=>$val){ $ids[] = $val['service_book_id']; } $newIds = array_unique($ids); $bookList = Db::name('service_book') ->whereIn('id',$newIds) ->where('service_item_id',$itemId) ->where('service_id',$serviceId) ->where('org_id',$this->org_id) ->whereTime('create_time', 'between', [$startMonth, $endMonth]) ->select()->toArray(); $nums = 0; foreach ($bookList as $kk=>$vv){ $nums +=$vv['nums']; } $bookList1 = Db::name('service_book') ->whereIn('id',$newIds) ->where('service_item_id',$itemId) ->where('service_id',$serviceId) ->where('org_id',$this->org_id) ->whereTime('create_time', 'between', [$startWeek, $endWeek]) ->select()->toArray(); $nums1 = 0; foreach ($bookList1 as $kk=>$vv){ $nums1 +=$vv['nums']; } $bookList2 = Db::name('service_book') ->whereIn('id',$newIds) ->where('service_item_id',$itemId) ->where('service_id',$serviceId) ->where('org_id',$this->org_id) ->whereTime('create_time', 'between', [$startDay, $endDay]) ->select()->toArray(); $nums2 = 0; foreach ($bookList2 as $kk=>$vv){ $nums2 +=$vv['nums']; } $cateList[$k]['count'] = $nums; $cateList[$k]['week'] = $nums1; $cateList[$k]['day'] = $nums2; } $this->assign('meta_title','餐厅统计'); $this->assign('data',$cateList); return $this->fetch(); } public function userWork() { if(request()->isAjax()){ //分页参数 $length = input('rows',10,'intval'); //每页条数 $page = input('page',1,'intval'); //第几页 $start = ($page - 1) * $length; //分页开始位置 //排序 $sortRow = input('sidx','id','trim'); //排序列 $sort = input('sord','desc','trim'); //排序方式 $order = $sortRow.' '.$sort; $title = input('title','','trim'); if($title){ $map[] = ['u.nickname','like','%'.$title.'%']; } $map= empty($map) ? true: $map; $ret = Db::name('user') ->alias('u') ->field('u.id,u.nickname') ->join('user_org uo', 'uo.user_id=u.id') ->where('uo.org_id', $this->org_id) ->where('u.enable', 1) ->where('u.del', 0) ->where($map) ->limit($start,$length) ->order($order) ->select() ->toArray(); foreach ($ret as $k => $v) { //获取本月开始时间结束时间 $smonth = date('Y-m') . '-1 00:00:00'; $emonth = date('Y-m') . '-31 23:59:59'; $where[] = ['update_time','>=',$smonth]; $where[] = ['update_time','<=',$emonth]; $userWork = Db::name('user_work') ->where('user_id', $v['id']) ->where($where) ->whereNotNull('start_time') ->whereNotNull('end_time') ->select() ->toArray(); $num = 0; foreach ($userWork as $kk => $vv) { $stime = strtotime($vv['start_time']); $etime = strtotime($vv['end_time']); $newTime = $etime - $stime; $num += $newTime; } $ret[$k]['month'] = $num; //获取本周开始时间 结束时间 $sweek = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)) . ' 00:00:00'; $eweek = date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) . ' 23:59:59'; $where2[] = ['update_time','>=',$sweek]; $where2[] = ['update_time','<=',$eweek]; $userWork2 = Db::name('user_work') ->where('user_id', $v['id']) ->where($where2) ->whereNotNull('start_time') ->whereNotNull('end_time') ->select()->toArray(); $num2 = 0; foreach ($userWork2 as $kk => $vv) { $stime = strtotime($vv['start_time']); $etime = strtotime($vv['end_time']); $newTime = $etime - $stime; $num2 += $newTime; } $ret[$k]['week'] = $num2; //获取今天开始时间 结束时间 $sday = date('Y-m-d') . ' 00:00:00'; $eday = date('Y-m-d') . ' 23:59:59'; $where3[] = ['update_time','>=',$sday]; $where3[] = ['update_time','<=',$eday]; $userWork3 = Db::name('user_work') ->where('user_id', $v['id']) ->where($where3) ->whereNotNull('start_time') ->whereNotNull('end_time') ->select()->toArray(); $num3 = 0; foreach ($userWork3 as $kk => $vv) { $stime = strtotime($vv['start_time']); $etime = strtotime($vv['end_time']); $newTime = $etime - $stime; $num3 += $newTime; } $ret[$k]['day'] = $num3; } //数据返回 $totalCount = Db::name('user') ->alias('u') ->field('u.id,u.nickname') ->join('user_org uo', 'uo.user_id=u.id') ->where('uo.org_id', $this->org_id) ->where('u.enable', 1) ->where('u.del', 0) ->where($map) ->count();; $totalPage = ceil($totalCount/$length); $result['page'] = $page; $result['total'] = $totalPage; $result['records'] = $totalCount; $result['rows'] = $ret; return json($result); }else{ $this->assign('meta_title','用户工作时长统计'); return $this->fetch(); } } //耗材统计 public function mateItems(){ $month = input('month','','trim'); if($month){ $smonth = $month.'-01 :00:00:00'; $emonth = $month.'-31 :23:59:59'; $where[] = ['t.done_time','>=',$smonth]; $where[] = ['t.done_time','<=',$emonth]; }else{ //本月 $month = date('Y-m'); $sdate = date('Y-m').'-01 :00:00:00'; $edate = date('Y-m').'-31 :23:59:59'; $where[] = ['t.done_time','>=',$sdate]; $where[] = ['t.done_time','<=',$edate]; //本周 $sweek = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)) . ' 00:00:00'; $eweek = date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)) . ' 23:59:59'; $where2[] = ['t.done_time','>=',$sweek]; $where2[] = ['t.done_time','<=',$eweek]; //当天 $sday = date('Y-m-d') . ' 00:00:00'; $eday = date('Y-m-d') . ' 23:59:59'; $where3[] = ['t.done_time','>=',$sday]; $where3[] = ['t.done_time','<=',$eday]; } $map[] = ['enable','=',1]; $map[] = ['org_id','=',$this->org_id]; $map= empty($map) ? true: $map; $ret = Db::name('dep')->where($map)->select()->toArray(); foreach ($ret as $k=>$v){ //本月 $todo = Db::name('todo') ->alias('t') ->field('t.id,t.to_user_id,t.mate_price') ->join('user_dep ud','ud.user_id=t.to_user_id') ->where('ud.dep_id',$v['id']) ->where('t.todo_mode',3) ->where('t.del',0) ->where('t.org_id',$this->org_id) ->where($where) ->select() ->toArray(); $total = 0; foreach ($todo as $kk=>$vv){ $total +=$vv['mate_price']; } $ret[$k]['month'] = $total; //本周 $ret[$k]['week'] = 0; if(!empty($where2)){ $todo = Db::name('todo') ->alias('t') ->field('t.id,t.to_user_id,t.mate_price') ->join('user_dep ud','ud.user_id=t.to_user_id') ->where('ud.dep_id',$v['id']) ->where('t.todo_mode',3) ->where('t.del',0) ->where('t.org_id',$this->org_id) ->where($where2) ->select() ->toArray(); $total2 = 0; foreach ($todo as $kk=>$vv){ $total2 +=$vv['mate_price']; } $ret[$k]['week'] = $total2; } $ret[$k]['day'] = 0; if(!empty($where3)){ //当天 $todo = Db::name('todo') ->alias('t') ->field('t.id,t.to_user_id,t.mate_price') ->join('user_dep ud','ud.user_id=t.to_user_id') ->where('ud.dep_id',$v['id']) ->where('t.todo_mode',3) ->where('t.del',0) ->where('t.org_id',$this->org_id) ->where($where3) ->select() ->toArray(); $total3 = 0; foreach ($todo as $kk=>$vv){ $total3 +=$vv['mate_price']; } $ret[$k]['day'] = $total3; } } $this->assign('data',$ret); $this->assign('month',$month); $this->assign('meta_title','耗材统计列表'); return $this->fetch(); } public function mateItemsDetails($id,$month){ $sdate = $month.'-1 00:00:00'; $edate = $month.'-31 23:59:59'; $map[] = ['t.done_time','>=',$sdate]; $map[] = ['t.done_time','<=',$edate]; if(request()->isAjax()){ //分页参数 $length = input('rows',10,'intval'); //每页条数 $page = input('page',1,'intval'); //第几页 $start = ($page - 1) * $length; //分页开始位置 //排序 $sortRow = input('sidx','id','trim'); //排序列 $sort = input('sord','desc','trim'); //排序方式 $order = $sortRow.' '.$sort; $ret = Db::name('todo') ->alias('t') ->field('t.to_user_id,tmi.*') ->join('user_dep ud','ud.user_id=t.to_user_id') ->join('todo_mate_item tmi','tmi.todo_id=t.id') ->where('ud.dep_id',$id) ->where('t.todo_mode',3) ->where('t.del',0) ->where('t.org_id',$this->org_id) ->where($map) ->limit($start,$length) ->order($order) ->select() ->toArray(); foreach ($ret as $k=>$v){ $ret[$k]['title']=Db::name('mate_items') ->where('id',$v['items_id']) ->value('title'); $ret[$k]['nickname']=Db::name('user') ->where('id',$v['to_user_id']) ->value('nickname'); } //数据返回 $totalCount = Db::name('todo') ->alias('t') ->field('tmi.*') ->join('user_dep ud','ud.user_id=t.to_user_id') ->join('todo_mate_item tmi','tmi.todo_id=t.id') ->where('ud.dep_id',$id) ->where('t.todo_mode',3) ->where('t.del',0) ->where('t.org_id',$this->org_id) ->where($map) ->count(); $totalPage = ceil($totalCount/$length); $result['page'] = $page; $result['total'] = $totalPage; $result['records'] = $totalCount; $result['rows'] = $ret; return json($result); }else{ $this->assign('meta_title','部门使用耗材列表'); $this->assign('id',$id); $this->assign('month',$month); return $this->fetch(); } } //报修科室使用材料统计 public function cltj(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->cltjData($start1,$end1); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); return $this->fetch(); } public function cltjData($start,$end){ $orgId = $this->orgId; $ret = Db::name('order_repair') ->alias('a') ->join('orders b','a.order_id=b.id') ->where('b.org_id',$orgId) ->where('a.address_id','>',0) ->field('a.address_id') ->distinct(true) ->select(); $map = []; if(!empty($start)){ $map[] = ['t.done_time','>=',$start]; } if(!empty($end)){ $map[] = ['t.done_time','<',$end]; } $map[] = ['t.del','=',0]; $map[] = ['t.org_id','=',$orgId]; foreach ($ret as $k=>$v){ $map1 = []; $todo = Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->join('order_repair r','o.id = r.order_id') ->where('r.address_id',$v['address_id']) ->where($map) ->sum('tmi.total_money'); $num =$todo?round($todo,2):0; if($num<=0){ unset($ret[$k]); }else{ $ret[$k]['month'] = $num; if(!empty($start)){ $map1[] = ['t.done_time','>=',$start]; } if(!empty($end)){ $map1[] = ['t.done_time','<',$end]; } $map1[] = ['t.del','=',0]; $map1[] = ['t.org_id','=',$orgId]; $map1[] = ['r.address_id','=',$v['address_id']]; $lists =Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->join('user u','u.id = t.to_user_id') ->join('order_repair r','o.id = r.order_id') ->join('mate_goods ma','ma.id = tmi.items_id') ->field('tmi.*,u.real_name,ma.title') ->where($map1) ->select(); if(empty($lists)){ unset($ret[$k]); continue; } $ret[$k]['rows'] = count($lists); $ret[$k]['items'] = $lists; $ret[$k]['title'] =Db::name('address') ->where('id',$v['address_id']) ->value('title'); } } return $ret; } //耗材统计导出 public function cltjExport() { set_time_limit(0); ini_set("memory_limit", "1024M"); $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->cltjData($start1,$end1); $title = '报修科室使用材料统计报表'; header("Content-type: application/vnd.ms-excel"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".$title.".xls"); header('Expires:0'); header('Pragma:public'); $res = ''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; foreach ($data as $k=>$v){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; if(count($v['items']) >=2){ foreach ($v['items'] as $k1=>$v1){ if($k1>0){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; } } } } echo $res; } //员工维修工作量 public function finishTime(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->finishTimeData($start1,$end1); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); return $this->fetch(); } public function finishTimeData($start,$end) { $org_id = $this->orgId; $list = (new \app\common\model\WorkTypeMode())->getRolesUser(1,$this->orgId); $a = []; foreach ($list as $k=>$v){ if($v['user']){ foreach ($v['user'] as $k1=>$v1){ $a[] = $v1; } } } $accepted = $nFinish=0; $list = $a; $map = []; if(!empty($start)){ $map[] = ['todo.create_yyyymmdd','>=',date('Ymd',strtotime($start))]; } if(!empty($end)){ $map[] = ['todo.create_yyyymmdd','<=',date('Ymd',strtotime($end))]; } foreach ($list as $k=>$v){ $hs = 0; $orderList = Db::name('todo') ->alias('todo') ->where('todo.org_id',$org_id) ->where('todo.todo_mode',3) ->where('todo.to_user_id',$v['id']) ->where('todo.work_type_mode',1) ->where($map) ->select(); foreach ($orderList as $k1=>$v1){ $hs += strtotime($v1['done_time'])-strtotime($v1['create_time']); } $hszj = $hs >0?round($hs/3600,2):0; $list[$k]['hszj'] = $hszj; $wc_time = Db::name('todo') ->alias('todo') ->where('todo.org_id',$org_id) ->where('todo.todo_mode',3) ->where('todo.to_user_id',$v['id']) ->where('todo.work_type_mode',1) ->where($map) ->sum('todo.wc_time'); $total = $wc_time?round($wc_time/3600,2):0; $list[$k]['total'] = $total; $nums = Db::name('todo') ->alias('todo') ->where('todo.org_id',$org_id) ->where('todo.todo_mode',3) ->where('todo.to_user_id',$v['id']) ->where('todo.work_type_mode',1) ->where($map) ->count(); $list[$k]['num'] =$nums; if($nums>0){ $avg = round($total/$nums,2); }else{ $avg = 0; } $list[$k]['avg'] = $avg; $dep = Db::name('user_dep') ->alias('a') ->join('dep o','a.dep_id=o.id') ->where('a.user_id',$v['id']) ->field('o.title') ->find(); $list[$k]['dep'] = $dep?$dep['title']:''; // 已接工 $list[$k]['accepted'] = Db::name('todo') ->alias('todo') ->where('todo.org_id',$org_id) ->where('todo.todo_mode','>',1) ->where('todo.to_user_id',$v['id']) ->where('todo.work_type_mode',1) ->where($map) ->count(); $accepted += $list[$k]['accepted']; // 未完工 $list[$k]['nFinish'] = Db::name('todo') ->alias('todo') ->where('todo.org_id',$org_id) ->where('todo.todo_mode','in',[2,4,5,6,7,8]) ->where('todo.to_user_id',$v['id']) ->where('todo.work_type_mode',1) ->where($map) ->count(); $nFinish += $list[$k]['nFinish']; } return $list; } //excel导出 public function finishTimeExport() { $meta_title = '维修人员工作时长'; $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $ret = $this->finishTimeData($start1,$end1); include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php'; //实例化PHPExcel类 $objPHPExcel = new \PHPExcel(); //激活当前的sheet表 $objPHPExcel->setActiveSheetIndex(0); //设置表格头(即excel表格的第一行) $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', '姓名') ->setCellValue('B1', '班组名称') ->setCellValue('C1', '接工量') ->setCellValue('D1', '完工量') ->setCellValue('E1', '未完工量') ->setCellValue('F1', '维修耗时') ->setCellValue('G1', '工时总计'); // 设置表格头水平居中 $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('C1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('D1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('E1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('F1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('G1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('H1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //设置列水平居中 $objPHPExcel->setActiveSheetIndex(0)->getStyle('A')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('B')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('C')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('D')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('E')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('F')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('G')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('H')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //设置单元格宽度 $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(10); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(50); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setWidth(20); //循环刚取出来的数组,将数据逐一添加到excel表格。 for ($i = 0; $i < count($ret); $i++) { $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $ret[$i]['real_name']); $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $ret[$i]['dep']); $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $ret[$i]['accepted']); $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $ret[$i]['num']); $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $ret[$i]['nFinish']); $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $ret[$i]['hszj']); $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $ret[$i]['total']); } //设置保存的Excel表格名称 $filename = '维修人员工作时长' . date('YmdHis', time()) . '.xls'; //设置当前激活的sheet表格名称 $objPHPExcel->getActiveSheet()->setTitle('维修人员工作时长'); //设置浏览器窗口下载表格 ob_end_clean(); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header('Content-Disposition:inline;filename="' . $filename); //生成excel文件 $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //下载文件在浏览器窗口 return $objWriter->save('php://output'); } //班组维修工作量 public function bzwx(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $title = input('title',''); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->bzwxData($start1,$end1,$title); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); $this->assign('title', $title); return $this->fetch(); } public function bzwxData($start,$end,$title){ $org_id = $this->orgId; $m = []; if(!empty($title)){ $m[] =['title','like','%'.$title.'%']; } $list = Db::name('dep') ->where('del',0) ->where('enable',1) ->where('org_id',$org_id) ->select(); $map = []; if(!empty($start)){ $map[] = ['create_yyyymmdd','>=',date('Ymd',strtotime($start))]; } if(!empty($end)){ $map[] = ['create_yyyymmdd','<=',date('Ymd',strtotime($end))]; } $accepted = $nFinish=0; foreach ($list as $k=>$v){ $user = Db::name('user_dep') ->alias('b') ->join('user a','b.user_id=a.id') ->where('a.del',0) ->where('a.enable',1) ->where('b.dep_id',$v['id']) ->field('b.user_id') ->select(); $ids = $user?array_column($user,'user_id'):[]; $list[$k]['num'] =0; $list[$k]['accepted'] =0; $list[$k]['nFinish'] =0; if(!empty($ids)){ $nums =Db::name('todo') ->where('org_id',$org_id) ->where('to_user_id','in',$ids) ->where('work_type_mode',1) ->where('todo_mode','in',[2,3,9]) ->where($map) ->count(); $list[$k]['num'] =$nums; // 已接工 $list[$k]['accepted'] = Db::name('todo') ->where('org_id',$org_id) ->where('to_user_id','in',$ids) ->where('work_type_mode',1) ->where('todo_mode','>',1) ->where($map) ->count(); $accepted += $list[$k]['accepted']; // 未完工 $list[$k]['nFinish'] = Db::name('todo') ->where('org_id',$org_id) ->where('to_user_id','in',$ids) ->where('work_type_mode',1) ->where('todo_mode','in',[2,4,5,6,7]) ->where($map) ->count(); $nFinish += $list[$k]['nFinish']; if($nums==0 && $list[$k]['accepted']==0 && $list[$k]['nFinish']==0){ unset($list[$k]); } }else{ unset($list[$k]); } } return $list; } //excel导出 public function bzwxExport() { $meta_title = '班组维修工作量统计表'; $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $title = input('title',''); $ret = $this->bzwxData($start1,$end1,$title); include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php'; //实例化PHPExcel类 $objPHPExcel = new \PHPExcel(); //激活当前的sheet表 $objPHPExcel->setActiveSheetIndex(0); //设置表格头(即excel表格的第一行) $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', '班组名称') ->setCellValue('B1', '接工量') ->setCellValue('C1', '完工量') ->setCellValue('D1', '未完工量'); // 设置表格头水平居中 $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('C1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('D1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('E1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('F1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('G1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('H1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //设置列水平居中 $objPHPExcel->setActiveSheetIndex(0)->getStyle('A')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('B')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('C')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('D')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('E')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('F')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('G')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('H')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //设置单元格宽度 $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(10); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(50); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setWidth(20); //循环刚取出来的数组,将数据逐一添加到excel表格。 for ($i = 0; $i < count($ret); $i++) { $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $ret[$i]['title']); $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $ret[$i]['accepted']); $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $ret[$i]['num']); $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $ret[$i]['nFinish']); } //设置保存的Excel表格名称 $filename = '班组维修工作量统计表' . date('YmdHis', time()) . '.xls'; //设置当前激活的sheet表格名称 $objPHPExcel->getActiveSheet()->setTitle('班组维修工作量统计表'); //设置浏览器窗口下载表格 ob_end_clean(); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header('Content-Disposition:inline;filename="' . $filename); //生成excel文件 $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //下载文件在浏览器窗口 return $objWriter->save('php://output'); } public function bxks(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $title = input('title',''); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->bxksData($start1,$end1,$title); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); $this->assign('title', $title); return $this->fetch(); } public function bxksData($start,$end,$title){ $org_id = $this->orgId; $map = []; if(!empty($title)){ $ks = Db::name('address') ->where('org_id',$org_id) ->where('del',0) ->where('enable',1) ->where('title','like','%'.$title.'%') ->select(); if(empty($ks)){ $map[] = ['a.address_id','=',-1]; }else{ $map[] = ['a.address_id','in',array_column($ks,'id')]; } } $ret =Db::name('order_repair') ->alias('a') ->join('orders b','a.order_id=b.id') ->where('b.org_id',$org_id) ->where('a.address_id','>',0) ->where($map) ->field('a.address_id') ->distinct(true) ->select(); if(!empty($start)){ $map1[] = ['t.create_yyyymmdd','>=',date('Ymd',strtotime($start))]; } if(!empty($end)){ $map1[] = ['t.create_yyyymmdd','<=',date('Ymd',strtotime($end))]; } $map1[] = ['t.del','=',0]; $map1[] = ['t.org_id','=',$org_id]; foreach ($ret as $k=>$v){ $num = Db::name('order_repair') ->alias('a') ->join('orders t','a.order_id = t.id') ->where('a.address_id',$v['address_id']) ->where($map1) ->count(); $ret[$k]['num'] = $num; $ret[$k]['title'] = Db::name('address') ->where('id',$v['address_id']) ->value('title'); } return $ret; } //excel导出 public function bxksExport() { $meta_title = '报修科室统计'; $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $title = input('title',''); $ret = $this->bxksData($start1,$end1,$title); include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php'; //实例化PHPExcel类 $objPHPExcel = new \PHPExcel(); //激活当前的sheet表 $objPHPExcel->setActiveSheetIndex(0); //设置表格头(即excel表格的第一行) $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', '科室名称') ->setCellValue('B1', '报修订单数量'); // 设置表格头水平居中 $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('C1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('D1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('E1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('F1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('G1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('H1')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //设置列水平居中 $objPHPExcel->setActiveSheetIndex(0)->getStyle('A')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('B')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('C')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('D')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('E')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('F')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('G')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $objPHPExcel->setActiveSheetIndex(0)->getStyle('H')->getAlignment() ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //设置单元格宽度 $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(10); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(50); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setWidth(20); $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setWidth(20); //循环刚取出来的数组,将数据逐一添加到excel表格。 for ($i = 0; $i < count($ret); $i++) { $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $ret[$i]['title']); $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $ret[$i]['num']); } //设置保存的Excel表格名称 $filename = '报修科室统计' . date('YmdHis', time()) . '.xls'; //设置当前激活的sheet表格名称 $objPHPExcel->getActiveSheet()->setTitle('报修科室统计'); //设置浏览器窗口下载表格 ob_end_clean(); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header('Content-Disposition:inline;filename="' . $filename); //生成excel文件 $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //下载文件在浏览器窗口 return $objWriter->save('php://output'); } public function grcltj(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->grcltjData($start1,$end1); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); return $this->fetch(); } public function grcltjData($start,$end){ $orgId = $this->orgId; $ret = Db::name('todo_mate') ->alias('a') ->join('todo b','a.todo_id=b.id') ->field('a.*') ->where('a.org_id',$orgId) ->where('a.type',0) ->where('b.del',0) ->group('a.user_id') ->select(); $map = []; if(!empty($start)){ $map[] = ['tmi.create_time','>=',$start]; } if(!empty($end)){ $map[] = ['tmi.create_time','<',$end]; } $map[] = ['t.del','=',0]; $map[] = ['tm.org_id','=',$orgId]; foreach ($ret as $k=>$v){ $map1 = []; $todo = Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->where('tmi.user_id',$v['user_id']) ->where($map) ->sum('tmi.total_money'); $num =$todo?round($todo,2):0; if($num<=0){ unset($ret[$k]); }else{ $ret[$k]['month'] = $num; if(!empty($start)){ $map1[] = ['t.create_time','>=',$start]; } if(!empty($end)){ $map1[] = ['t.create_time','<',$end]; } $map1[] = ['t.del','=',0]; $map1[] = ['t.org_id','=',$orgId]; $map1[] = ['tm.user_id','=',$v['user_id']]; $lists =Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->join('user u','u.id = t.to_user_id') ->join('mate_goods ma','ma.id = tmi.items_id') ->field('tmi.*,u.real_name,ma.title') ->where($map1) ->select(); if(empty($lists)){ unset($ret[$k]); continue; } $ret[$k]['rows'] = count($lists); $ret[$k]['items'] = $lists; $ret[$k]['real_name'] = Db::name('user') ->where('id',$v['user_id']) ->value('real_name'); } } return $ret; } public function grcltjExport() { set_time_limit(0); ini_set("memory_limit", "1024M"); $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->grcltjData($start1,$end1); $title = '工人耗材用量统计'; header("Content-type: application/vnd.ms-excel"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".$title.".xls"); header('Expires:0'); header('Pragma:public'); $res = ''; $res.='
科室名称材料名称数量单价总价小计
'.$v['title'].''.$v['items'][0]['title'].''.$v['items'][0]['total'].''.$v['items'][0]['money'].''.$v['items'][0]['total_money'].''.$v['month'].'
'.$v1['title'].''.$v1['total'].''.$v1['money'].''.$v1['total_money'].'
'; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; foreach ($data as $k=>$v){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; if(count($v['items']) >=2){ foreach ($v['items'] as $k1=>$v1){ if($k1>0){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; } } } } echo $res; } public function bxrcltj(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->bxrcltjData($start1,$end1); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); return $this->fetch(); } public function bxrcltjData($start,$end){ $orgId = $this->orgId; $ret = Db::name('orders') ->alias('a') ->where('org_id',$orgId) ->where('del',0) ->where('finish_time','>=',$start) ->where('finish_time','<',$end) ->group('user_id') ->select(); $map = []; if(!empty($start)){ $map[] = ['t.done_time','>=',$start]; } if(!empty($end)){ $map[] = ['t.done_time','<',$end]; } $map[] = ['t.del','=',0]; $map[] = ['t.org_id','=',$orgId]; foreach ($ret as $k=>$v){ $map1 = []; $todo = Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->where('o.user_id',$v['user_id']) ->where($map) ->sum('tmi.total_money'); $num =$todo?round($todo,2):0; if($num<=0){ unset($ret[$k]); }else{ $ret[$k]['month'] = $num; if(!empty($start)){ $map1[] = ['t.done_time','>=',$start]; } if(!empty($end)){ $map1[] = ['t.done_time','<',$end]; } $map1[] = ['t.del','=',0]; $map1[] = ['t.org_id','=',$orgId]; $map1[] = ['o.user_id','=',$v['user_id']]; $lists =Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->join('user u','u.id = t.to_user_id') ->join('mate_goods ma','ma.id = tmi.items_id') ->field('tmi.*,u.real_name,ma.title') ->where($map1) ->select(); if(empty($lists)){ unset($ret[$k]); continue; } $ret[$k]['rows'] = count($lists); $ret[$k]['items'] = $lists; $ret[$k]['title'] =Db::name('user') ->where('id',$v['user_id']) ->value('real_name'); } } return $ret; } //耗材统计导出 public function bxrcltjExport() { set_time_limit(0); ini_set("memory_limit", "1024M"); $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->bxrcltjData($start1,$end1); $title = '报修人耗材统计报表'; header("Content-type: application/vnd.ms-excel"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".$title.".xls"); header('Expires:0'); header('Pragma:public'); $res = ''; $res.='
工人名称材料名称数量单价总价使用时间小计
'.$v['real_name'].''.$v['items'][0]['title'].''.$v['items'][0]['total'].''.$v['items'][0]['money'].''.$v['items'][0]['total_money'].''.$v['items'][0]['create_time'].''.$v['month'].'
'.$v1['title'].''.$v1['total'].''.$v1['money'].''.$v1['total_money'].''.$v1['create_time'].'
'; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; foreach ($data as $k=>$v){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; if(count($v['items']) >=2){ foreach ($v['items'] as $k1=>$v1){ if($k1>0){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; } } } } echo $res; } public function wlflcltj(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->wlflcltjData($start1,$end1); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); return $this->fetch(); } public function wlflcltjData($start,$end){ $orgId = $this->orgId; $ret = Db::name('mate_cate') ->where('org_id',$orgId) ->where('del',0) ->where('enable',1) ->select(); $map = []; if(!empty($start)){ $map[] = ['t.done_time','>=',$start]; } if(!empty($end)){ $map[] = ['t.done_time','<',$end]; } $map[] = ['t.del','=',0]; $map[] = ['t.org_id','=',$orgId]; foreach ($ret as $k=>$v){ $map1 = []; $todo = Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('mate_goods mg','tmi.items_id=mg.id') ->join('mate_cate mc','mg.cate_id = mc.id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->where('mc.id',$v['id']) ->where($map) ->sum('tmi.total_money'); $num =$todo?round($todo,2):0; if($num<=0){ unset($ret[$k]); }else{ $ret[$k]['month'] = $num; if(!empty($start)){ $map1[] = ['t.done_time','>=',$start]; } if(!empty($end)){ $map1[] = ['t.done_time','<',$end]; } $map1[] = ['t.del','=',0]; $map1[] = ['t.org_id','=',$orgId]; $map1[] = ['mc.id','=',$v['id']]; $lists =Db::name('todo_mate_item') ->alias('tmi') ->join('todo_mate tm','tm.id = tmi.todo_mate_id') ->join('mate_goods mg','tmi.items_id=mg.id') ->join('mate_cate mc','mg.cate_id = mc.id') ->join('todo t','tm.todo_id = t.id') ->join('orders o','o.id = t.order_id') ->join('user u','u.id = t.to_user_id') ->join('mate_goods ma','ma.id = tmi.items_id') ->field('tmi.*,u.real_name,ma.title') ->where($map1) ->select(); if(empty($lists)){ unset($ret[$k]); continue; } $ret[$k]['rows'] = count($lists); $ret[$k]['items'] = $lists; } } return $ret; } //耗材统计导出 public function wlflcltjExport() { set_time_limit(0); ini_set("memory_limit", "1024M"); $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->wlflcltjData($start1,$end1); $title = '物料分类统计报表'; header("Content-type: application/vnd.ms-excel"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".$title.".xls"); header('Expires:0'); header('Pragma:public'); $res = ''; $res.='
报修人材料名称数量单价使用人使用时间总价小计
'.$v['title'].''.$v['items'][0]['title'].''.$v['items'][0]['total'].''.$v['items'][0]['money'].''.$v['items'][0]['real_name'].''.$v['items'][0]['create_time'].''.$v['items'][0]['total_money'].''.$v['month'].'
'.$v1['title'].''.$v1['total'].''.$v1['money'].''.$v1['real_name'].''.$v1['create_time'].''.$v1['total_money'].'
'; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; foreach ($data as $k=>$v){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; if(count($v['items']) >=2){ foreach ($v['items'] as $k1=>$v1){ if($k1>0){ $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; $res.=''; } } } } echo $res; } public function wxOrderTj(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $title = input('title',''); $cateId = input('cateId',''); $goodsId = input('goodsId',''); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->wxOrderTjData($start1,$end1,$title,$cateId); $cateList = model('WxGoodsCate')->lists($this->orgId); $this->assign('cateList', $cateList); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); $this->assign('title', $title); $this->assign('cateId', $cateId?explode(',',$cateId):""); $this->assign('goodsId', $goodsId?explode(',',$goodsId):""); $glist = Db::name('wx_goods')->where('org_id',$this->orgId)->where('enable',1)->where('del',0)->select(); $this->assign('glist', $glist); return $this->fetch(); } public function wxOrderTjData($start,$end,$title,$cateId){ $org_id = $this->orgId; $map = []; $goodsId = input('goodsId',''); if(!empty($title)){ $map[] = ['g.title','like','%'.$title.'%']; } if(!empty($cateId)){ $map[] = ['g.cate_id','in',explode(',',$cateId)]; } if(!empty($goodsId)){ $map[] = ['g.id','in',explode(',',$goodsId)]; } if(!empty($start)){ $map[] = ['a.create_time','>=',$start]; } if(!empty($end)){ $map[] = ['a.create_time','<=',$end]; } $map[] = ['a.status','in',[1,2,3,5]]; $map[] = ['a.del','=',0]; $map[] = ['a.org_id','=',$org_id]; $ret =Db::name('wx_orders') ->alias('a') ->join('wx_orders_goods b','a.id=b.order_id') ->join('wx_goods g','b.goods_id=g.id') ->join('wx_goods_cate ca','g.cate_id=ca.id') ->where($map) ->field('b.goods_id,a.id,sum(b.nums) as num,b.price,g.title,ca.title as cateName') ->group('b.goods_id') ->select(); $total = 0; foreach ($ret as $k=>$v){ $refund = Db::name('wx_orders_refund') ->where('order_id',$v['id']) ->where('goods_id',$v['goods_id']) ->where('del',0) ->where('status','in',[0,1]) ->find(); $num = $v['num']; if($refund){ $num = $v['num']-$refund['num']; } if($num==0){ unset($ret[$k]); }else{ $t = $num*$v['price']; $total+=$t; $ret[$k]['total'] = $num*$v['price']; $ret[$k]['num'] = $num; } } array_push($ret,[ 'title'=>'合计:', 'cateName'=>'', 'num'=>'', 'price'=>'', 'total'=>$total, ]); return $ret; } public function wxOrderTjExport(){ $cur = date('Y-m-d'); $start = input('start', date('Y-m-d', strtotime('' . $cur . ' -1 week'))); $end = input('end', date('Y-m-d')); $title = input('title',''); $cateId = input('cateId',''); $start1 = $start . ' 00:00:00'; $end1 = $end . ' 23:59:59'; $data = $this->wxOrderTjData($start1,$end1,$title,$cateId); $header = [ ['title' => '商品名称', 'name' => 'title','width'=>'30'], ['title' => '分类', 'name' => 'cateName','width'=>'30'], ['title' => '数量', 'name' => 'num','width'=>'30'], ['title' => '单价', 'name' => 'price','width'=>'80'], ['title' => '总金额', 'name' => 'total','width'=>'30'], ]; $filename = '销售统计'; ExcelUtil::export($filename,$header,$data); } public function wxOrderView(){ $startY = beginYear(); $zjygy = date('Y-m-d 00:00:00',time()-(30*86400)); $type = input('type/d',0); if(request()->isPost()){ $dataTitle = []; $dataValue = []; $dataValue1 = []; $map[] = ['org_id','=',$this->orgId]; $map[] = ['del','=',0]; $map[] = ['status','in',[1,2,3,5]]; $ddzs = 0; $ddbl=0; $ddzt=0;//0持平1上升2下降 $yzfdd=0; $yzfbl=0; $yzfzt=0;//0持平1上升2下降 $ddze=0; $ddzebl=0; $ddzezt=0;//0持平1上升2下降 $map1[] = ['org_id','=',$this->orgId]; $map1[] = ['del','=',0]; $cateList = model('WxGoodsCate')->lists($this->orgId); $refund = Db::name('wx_orders_refund') ->where('org_id','=',$this->orgId) ->where('del',0) ->where('status','in',[0,1]) ->column('goods_id'); $rMap = []; if($refund){ $rMap[] = ['b.goods_id','not in',$refund]; } if($type==0){ $title = getMinFromRange(date('Y-m-d 00:00:00'),date('Y-m-d H:i:s')); foreach ($title as $k=>$v){ $dataTitle[] = date('H点',strtotime($v)); $dataValue[] = Db::name('wx_orders') ->where($map) ->where('create_yyyymmddhh','=',date('YmdH',strtotime($v))) ->count(); $dataValue1[] = Db::name('wx_orders') ->where($map) ->where('create_yyyymmddhh','=',date('YmdH',strtotime($v))) ->sum('amount'); } $zt = date("Ymd",strtotime("-1 day")); $ddzs =Db::name('wx_orders') ->where($map1) ->where('create_yyyymmdd','=',date('Ymd')) ->count(); $ztzs = Db::name('wx_orders') ->where($map1) ->where('create_yyyymmdd','=',$zt) ->count(); if($ztzs==$ddzs){ $ddzt = 0; }elseif ($ztzs>$ddzs){ $ddzt = 2; $ddbl = $ztzs>0?round((($ztzs-$ddzs)/$ztzs),2)*100:0; }elseif ($ztzs<$ddzs){ $ddzt = 1; $ddbl = $ddzs>0?round((($ddzs-$ztzs))/$ddzs,2)*100:0; } $yzfdd =Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymmdd','=',date('Ymd')) ->count(); $ztyzfdd = Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymmdd','=',$zt) ->count(); if($ztyzfdd==$yzfdd){ $yzfzt = 0; }elseif ($ztyzfdd>$yzfdd){ $yzfzt = 2; $yzfbl = $ztyzfdd>0?round((($ztyzfdd-$yzfdd)/$ztyzfdd),2)*100:0; }elseif ($ztyzfdd<$yzfdd){ $yzfzt = 1; $yzfbl = $yzfdd>0?round((($yzfdd-$ztyzfdd))/$yzfdd,2)*100:0; } $ddze =Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymmdd','=',date('Ymd')) ->sum('amount'); $ztddze = Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymmdd','=',$zt) ->sum('amount'); if($ztddze==$ddze){ $ddzezt = 0; }elseif ($ztddze>$ddze){ $ddzezt = 2; $ddzebl = $ztddze>0?round((($ztddze-$ddze)/$ztddze),2)*100:0; }elseif ($ztddze<$ddze){ $ddzezt = 1; $ddzebl = $ddze>0?round((($ddze-$ztddze))/$ddze,2)*100:0; } foreach ($cateList as $k=>$v){ $a = Db::name('wx_orders') ->alias('a') ->join('wx_orders_goods b','a.id=b.order_id') ->join('wx_goods c','b.goods_id=c.id') ->where('a.del','=',0) ->where('a.org_id','=',$this->orgId) ->where('c.cate_id','=',$v['id']) ->where('a.status','in',[1,2,3,5]) ->where($rMap) ->where('a.create_yyyymmdd','=',date('Ymd')) ->sum('b.nums*b.price'); $cateList[$k]['total'] = $a?$a:0; } }elseif ($type==1){ $title = getDateFromRange(date('Y-m-01'),date('Y-m-d')); foreach ($title as $k=>$v){ $dataTitle[] = date('Y-m-d',strtotime($v)); $dataValue[] = Db::name('wx_orders') ->where($map) ->where('create_yyyymmdd','=', date('Ymd',strtotime($v))) ->count(); $dataValue1[] = Db::name('wx_orders') ->where($map) ->where('create_yyyymmdd','=', date('Ymd',strtotime($v))) ->sum('amount'); } $zt = date("Ym",strtotime("-1 month")); $ddzs =Db::name('wx_orders') ->where($map1) ->where('create_yyyymm','=',date('Ym')) ->count(); $ztzs = Db::name('wx_orders') ->where($map1) ->where('create_yyyymm','=',$zt) ->count(); if($ztzs==$ddzs){ $ddzt = 0; }elseif ($ztzs>$ddzs){ $ddzt = 2; $ddbl = $ztzs>0?round((($ztzs-$ddzs)/$ztzs),2)*100:0; }elseif ($ztzs<$ddzs){ $ddzt = 1; $ddbl = $ddzs>0?round((($ddzs-$ztzs))/$ddzs,2)*100:0; } $yzfdd =Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymm','=',date('Ym')) ->count(); $ztyzfdd = Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymm','=',$zt) ->count(); if($ztyzfdd==$yzfdd){ $yzfzt = 0; }elseif ($ztyzfdd>$yzfdd){ $yzfzt = 2; $yzfbl = $ztyzfdd>0?round((($ztyzfdd-$yzfdd)/$ztyzfdd),2)*100:0; }elseif ($ztyzfdd<$yzfdd){ $yzfzt = 1; $yzfbl = $yzfdd>0?round((($yzfdd-$ztyzfdd))/$yzfdd,2)*100:0; } $ddze =Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymm','=',date('Ym')) ->sum('amount'); $ztddze = Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyymm','=',$zt) ->sum('amount'); if($ztddze==$ddze){ $ddzezt = 0; }elseif ($ztddze>$ddze){ $ddzezt = 2; $ddzebl = $ztddze>0?round((($ztddze-$ddze)/$ztddze),2)*100:0; }elseif ($ztddze<$ddze){ $ddzezt = 1; $ddzebl = $ddze>0?round((($ddze-$ztddze))/$ddze,2)*100:0; } foreach ($cateList as $k=>$v){ $a = Db::name('wx_orders') ->alias('a') ->join('wx_orders_goods b','a.id=b.order_id') ->join('wx_goods c','b.goods_id=c.id') ->where('a.del','=',0) ->where('a.org_id','=',$this->orgId) ->where('c.cate_id','=',$v['id']) ->where($rMap) ->where('a.status','in',[1,2,3,5]) ->where('a.create_yyyymm','=',date('Ym')) ->sum('b.nums*b.price'); $cateList[$k]['total'] = $a?$a:0; } }elseif ($type==2){ $title = getMonthFromRange($startY,date('Y-m-d H:i:s')); foreach ($title as $k=>$v){ $dataTitle[] = date('Y-m',strtotime($v)); $dataValue[] = Db::name('wx_orders') ->where($map) ->where('create_yyyymm','=', date('Ym',strtotime($v))) ->count(); $dataValue1[] = Db::name('wx_orders') ->where($map) ->where('create_yyyymm','=', date('Ym',strtotime($v))) ->sum('amount'); } $zt = date ( "Y" , strtotime ( "-1 year" )); $ddzs =Db::name('wx_orders') ->where($map1) ->where('create_yyyy','=',date('Y')) ->count(); $ztzs = Db::name('wx_orders') ->where($map1) ->where('create_yyyy','=',$zt) ->count(); if($ztzs==$ddzs){ $ddzt = 0; }elseif ($ztzs>$ddzs){ $ddzt = 2; $ddbl = $ztzs>0?round((($ztzs-$ddzs)/$ztzs),2)*100:0; }elseif ($ztzs<$ddzs){ $ddzt = 1; $ddbl = $ddzs>0?round((($ddzs-$ztzs))/$ddzs,2)*100:0; } $yzfdd =Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyy','=',date('Y')) ->count(); $ztyzfdd = Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyy','=',$zt) ->count(); if($ztyzfdd==$yzfdd){ $yzfzt = 0; }elseif ($ztyzfdd>$yzfdd){ $yzfzt = 2; $yzfbl = $ztyzfdd>0?round((($ztyzfdd-$yzfdd)/$ztyzfdd),2)*100:0; }elseif ($ztyzfdd<$yzfdd){ $yzfzt = 1; $yzfbl = $yzfdd>0?round((($yzfdd-$ztyzfdd))/$yzfdd,2)*100:0; } $ddze =Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyy','=',date('Y')) ->sum('amount'); $ztddze = Db::name('wx_orders') ->where($map1) ->where('status','in',[1,2,3,5]) ->where('create_yyyy','=',$zt) ->sum('amount'); if($ztddze==$ddze){ $ddzezt = 0; }elseif ($ztddze>$ddze){ $ddzezt = 2; $ddzebl = $ztddze>0?round((($ztddze-$ddze)/$ztddze),2)*100:0; }elseif ($ztddze<$ddze){ $ddzezt = 1; $ddzebl = $ddze>0?round((($ddze-$ztddze))/$ddze,2)*100:0; } foreach ($cateList as $k=>$v){ $a = Db::name('wx_orders') ->alias('a') ->join('wx_orders_goods b','a.id=b.order_id') ->join('wx_goods c','b.goods_id=c.id') ->where('a.del','=',0) ->where('a.org_id','=',$this->orgId) ->where('c.cate_id','=',$v['id']) ->where($rMap) ->where('a.status','in',[1,2,3,5]) ->where('a.create_yyyy','=',date('Y')) ->sum('b.nums*b.price'); $cateList[$k]['total'] = $a?$a:0; } } if($cateList){ $vol = array_column($cateList,'total'); array_multisort($vol,SORT_DESC,$cateList); } $p = [ 'title'=>$dataTitle, 'value'=>$dataValue, 'value1'=>$dataValue1, 'ddzs' => $ddzs, 'ddbl' => $ddbl, 'ddzt' => $ddzt, 'yzfdd' => $yzfdd, 'yzfbl' => $yzfbl, 'yzfzt' => $yzfzt, 'ddze' => $ddze, 'ddzebl' => $ddzebl, 'ddzezt' => $ddzezt, 'cateList' => $cateList, ]; $this->success('操作成功','',$p); }else{ $map[] = ['org_id','=',$this->orgId]; $map[] = ['del','=',0]; $data['orderAmount'] = Db::name('wx_orders') ->where($map) ->where('status','in',[1,2,3,5]) ->where('create_yyyymm','=',date('Ym')) ->sum('amount'); $data['orderCount'] = Db::name('wx_orders') ->where($map) ->where('status','in',[1,2,3,5]) ->where('create_yyyy','=',date('Y')) ->count(); $data['orderUser'] = Db::name('wx_orders') ->where($map) ->where('status','in',[1,2,3,5]) ->where('create_yyyymmdd','=',date('Ymd')) ->group('user_id') ->count(); $beginMonth = beginMonth(); $data['refundCount'] = Db::name('wx_orders_refund') ->where('org_id',$this->orgId) ->where('status',1) ->where('del',0) ->where('create_time','>=',$beginMonth) ->where('create_time','<=',getTime()) ->sum('money'); $this->assign('data',$data); return $this->fetch(); } } }
分类名称材料名称数量单价使用人使用时间总价小计
'.$v['title'].''.$v['items'][0]['title'].''.$v['items'][0]['total'].''.$v['items'][0]['money'].''.$v['items'][0]['real_name'].''.$v['items'][0]['create_time'].''.$v['items'][0]['total_money'].''.$v['month'].'
'.$v1['title'].''.$v1['total'].''.$v1['money'].''.$v1['real_name'].''.$v1['create_time'].''.$v1['total_money'].'