select(); foreach ($list as &$item){ if($item['id'] == '7'){ //halt($item['title']); //halt(json_decode($item['title'],true)); } $item['title'] = json_decode($item['title']); } $this->success('',$list); } public function index(){ $param = $this->request->param(); if($param['type'] == '1'){ $Model = new Xtuqll(); $bill_ids = $this->filtrateBillIds($Model,'ats_xtuqll'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('xtuqll.id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->with('business')->order('createtime desc')->select(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item){ $item['customer_id'] = $customerModel->where('id',$item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id',$item['business_id'])->value('name'); $item['url'] = (new Amodel())->where('bill_id',$item['id'])->where('type','contract')->value('file'); } } //请假 elseif ($param['type'] == '2'){ $Model = new Hvuxhg(); $bill_ids = $this->filtrateBillIds($Model,'ats_hvuxhg'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //出差 elseif ($param['type'] == '3'){ $Model = new Aysdrr(); $bill_ids = $this->filtrateBillIds($Model,'ats_aysdrr'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('aysdrr.id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->with('business')->order('createtime desc')->select(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item) { $item['customer_id'] = $customerModel->where('id', $item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id', $item['business_id'])->value('name'); } } //转正 elseif ($param['type'] == '4'){ $Model = new Dudzeq(); $bill_ids = $this->filtrateBillIds($Model,'ats_dudzeq'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('dudzeq.id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->with('user')->order('createtime desc')->select(); $staffModel = new \addons\qingdong\model\Staff(); foreach ($list as &$item) { $item['admin_id'] = $staffModel->where('id', $item['admin_id'])->value('name'); } } //招聘 elseif ($param['type'] == '5'){ $Model = new Wbvnia(); $bill_ids = $this->filtrateBillIds($Model,'ats_wbvnia'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //用车 elseif ($param['type'] == '6'){ $Model = new Nidsvn(); $bill_ids = $this->filtrateBillIds($Model,'ats_nidsvn'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //用章 elseif ($param['type'] == '7'){ $Model = new Wduzfa(); $bill_ids = $this->filtrateBillIds($Model,'ats_wduzfa'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('wduzfa.id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->with(['business','customer'])->order('createtime desc')->select(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item) { $item['customer_id'] = $customerModel->where('id', $item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id', $item['business_id'])->value('name'); } } //退换货单 elseif ($param['type'] == '8'){ $Model = new Xnsdti(); $bill_ids = $this->filtrateBillIds($Model,'ats_xnsdti'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('xnsdti.id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->with(['business','customer'])->order('createtime desc')->select(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item) { $item['customer_id'] = $customerModel->where('id', $item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id', $item['business_id'])->value('name'); } } //借支款 elseif ($param['type'] == '9'){ $Model = new Mowpvu(); $bill_ids = $this->filtrateBillIds($Model,'ats_mowpvu'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //离职申请 elseif ($param['type'] == '10'){ $Model = new Kmqpxi(); $bill_ids = $this->filtrateBillIds($Model,'ats_kmqpxi'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); $staffModel = new \addons\qingdong\model\Staff(); foreach ($list as &$item) { $item['admin_id'] = $staffModel->where('id', $item['admin_id'])->value('name'); } } //业务费预申请 elseif ($param['type'] == '11'){ $Model = new Havols(); $bill_ids = $this->filtrateBillIds($Model,'ats_havols'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //临时单次报销 elseif ($param['type'] == '12'){ $Model = new Jxbunq(); $bill_ids = $this->filtrateBillIds($Model,'ats_jxbunq'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //产品样品借样 elseif ($param['type'] == '13'){ $Model = new Zaxsta(); $bill_ids = $this->filtrateBillIds($Model,'ats_zaxsta'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('zaxsta.id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->with(['business','customer'])->order('createtime desc')->select(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item) { $item['customer_id'] = $customerModel->where('id', $item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id', $item['business_id'])->value('name'); } } //酒水申领 elseif ($param['type'] == '14'){ $Model = new Dbxovs(); $bill_ids = $this->filtrateBillIds($Model,'ats_dbxovs'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); //foreach ($list as &$item){ // $item['createtime'] = date('Y-m-d H:i',$item['createtime']); //} } //物品领用 elseif ($param['type'] == '15'){ $Model = new Yoirpj(); $bill_ids = $this->filtrateBillIds($Model,'ats_yoirpj'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); //foreach ($list as &$item){ // $item['createtime'] = date('Y-m-d H:i',$item['createtime']); //} } //设备赠送 elseif ($param['type'] == '16'){ $Model = new Zmqrbq(); $bill_ids = $this->filtrateBillIds($Model,'ats_zmqrbq'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('zmqrbq.id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->with(['business','customer'])->order('createtime desc')->select(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item) { $item['customer_id'] = $customerModel->where('id', $item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id', $item['business_id'])->value('name'); } } //付款申请 elseif ($param['type'] == '17'){ $Model = new Kiahkj(); $bill_ids = $this->filtrateBillIds($Model,'ats_kiahkj'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //报价申请 elseif ($param['type'] == '18'){ $Model = new Czgprz(); $bill_ids = $this->filtrateBillIds($Model,'ats_czgprz'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item) { $item['customer_id'] = $customerModel->where('id', $item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id', $item['business_id'])->value('name'); } } //合同审批 elseif ($param['type'] == '19'){ $Model = new Bywnpk(); $bill_ids = $this->filtrateBillIds($Model,'ats_bywnpk'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); $CzgprzModel = new Czgprz(); $customerModel = new \addons\qingdong\model\Customer(); $businessModel = new \addons\qingdong\model\Business(); foreach ($list as &$item) { $item['bill_id'] = $CzgprzModel->where('id', $item['bill_id'])->value('name'); $item['customer_id'] = $customerModel->where('id', $item['customer_id'])->value('name'); $item['business_id'] = $businessModel->where('id', $item['business_id'])->value('name'); } } //采购申请 elseif ($param['type'] == '20'){ $Model = new Txdphj(); $bill_ids = $this->filtrateBillIds($Model,'ats_txdphj'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //入库申请确认 elseif ($param['type'] == '21'){ $Model = new Jiopho(); $bill_ids = $this->filtrateBillIds($Model,'ats_jiopho'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //调薪申请 elseif ($param['type'] == '22'){ $Model = new Hwgvrz(); $bill_ids = $this->filtrateBillIds($Model,'ats_hwgvrz'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } //外出申请 elseif ($param['type'] == '23'){ $Model = new Stwoae(); $bill_ids = $this->filtrateBillIds($Model,'ats_stwoae'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); }elseif ($param['type'] == '24'){ $Model = new Asiitn(); $bill_ids = $this->filtrateBillIds($Model,'ats_asiitn'); if (is_array($bill_ids) && empty($bill_ids)) { $this->success('',[]); } if (is_array($bill_ids) && !empty($bill_ids)) { $Model->where('id in (' . implode(',', $bill_ids) . ')'); } $list = $Model->order('createtime desc')->select(); } $this->success('',$list); } public function getCzgprz(){ $list = (new Czgprz())->where('initiator_id',$this->auth->id)->select(); $this->success('',$list); } //获取能查看的单据ids public function filtrateBillIds($model,$bill) { $auth_row = (new \app\admin\model\fastflow\flow\BillAuth())->where(['bill' => $bill])->find(); if ($auth_row) { $rules = json_decode($auth_row['rules'], true); if (isset($rules['view'])) { $view_rule = $rules['view']; } } $canCheck_ids = []; $needStart_ids = []; $mine_ids = []; $participant_ids = []; $user_id = $this->auth->id; $canCheckIndexRows_byUser = CancheckIndex::where(['bill' => $bill, 'worker_id' => $user_id])->where('scope', 'in', [1, 3])->select();//通过user_id获取待审批单据ids foreach ($canCheckIndexRows_byUser as $canCheckIndexRow_byUesr) { $canCheck_ids[] = $canCheckIndexRow_byUesr['bill_id']; } $group_ids = $this->getGroups(); //halt($user_id); $canCheckIndexRows_byGroup = CancheckIndex::where(['bill' => $bill])->where('scope', 'in', [2, 4])->where('worker_id', 'in', $group_ids)->select();//通过group_id获取待审批单据ids foreach ($canCheckIndexRows_byGroup as $canCheckIndexRow_byGroup) { $canCheck_ids[] = $canCheckIndexRow_byGroup['bill_id']; } $canCheck_ids = array_unique($canCheck_ids); $needStartBill_rows = $model->where(['initiator_id' => $user_id, 'status' => 0])->field('id')->select();//待发起单据 foreach ($needStartBill_rows as $needStartBill_row) { $needStart_ids[] = $needStartBill_row['id']; } $mineBill_rows = $model->where(['initiator_id' => $user_id])->field('id')->select(); foreach ($mineBill_rows as $mineBill_row) { $mine_ids[] = $mineBill_row['id']; } //$participant_ids $participantIndex_rows = ParticipantIndex::where(['bill' => $bill, 'worker_id' => $user_id])->select(); foreach ($participantIndex_rows as $participantIndex_row) { $participant_ids[] = $participantIndex_row['bill_id']; } //halt($canCheck_ids); $canView_ids = array_merge($mine_ids, $canCheck_ids, $participant_ids); return array_unique($canView_ids); } public function getGroups(){ $uid = $this->auth->id; $user_groups = Db::name('auth_group_access') ->alias('aga') ->join('ats_auth_group ag', 'aga.group_id = ag.id', 'LEFT') ->field('aga.uid, aga.group_id, ag.id, ag.pid, ag.name, ag.rules') ->where("aga.uid='{$uid}' and ag.status='normal'") ->select(); $groupIds = []; foreach ($user_groups as $K => $v) { $groupIds[] = (int)$v['group_id']; } return $groupIds; } }