12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664 |
- <?php
- declare (strict_types=1);
- namespace app\admin\controller\project;
- use app\admin\BaseController;
- use app\admin\model\CostProject as CostProjectModel;
- use app\admin\model\ProjectAudit;
- use app\admin\model\Admin;
- use app\admin\model\ProjectFile;
- use app\admin\validate\project\CostProjectValidate;
- use think\App;
- use think\exception\ValidateException;
- use think\facade\Db;
- use think\facade\Session;
- use think\facade\View;
- use app\admin\controller\field\Fieldcompany;
- use app\admin\controller\Pushmessage;
- class CostCompany extends BaseController
- {
- /**
- * 构造函数
- */
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->Field = new Fieldcompany($this->app);
- $this->model = new CostProjectModel();
- $this->Adminmodel = new Admin();
- $this->uid = get_login_admin('id');
- $this->filemodel = new ProjectFile();
- $this->Pushmessage = new Pushmessage();
- $this->isPay = Db::name("department")->where("id",get_login_admin("unit_name"))->value("is_pay");
- }
- private array $field_name=[
- "engineering_type" => "工程类型",
- "engineering_category" => "工程类别",
- "province" => "省",
- "city" => "市" ,
- "area" => "县" ,
- "project_scale" => "项目规模",
- "fiscal_nature" => "财政性质" ,
- "sent_review_cost" => "送审服务费" ,
- "sent_review_amount" => "送审金额",
- "authorize_amount" => "审定金额" ,
- "review_add_reduce_amount" => "审增减额",
- "review_add_reduce_rate" => "审增减率" ,
- "charge_standard" => "收费标准" ,
- ];
- /**
- * 数据列表
- */
- public function datalist()
- {
- if (request()->isAjax()) {
- $inarr = array();
- $review_unit = $this->model->where("review_unit", get_login_admin("unit_name"))->field('id,review_head,operate_head,operate_team')->select()->toArray();
- for ($i = 0; $i < count($review_unit); $i++) {
- $a = $review_unit[$i];
- $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
- $ids = explode(",", $ids);
- $c = in_array($this->uid, $ids);
- if ($c) {
- $inarr[] = $a["id"];
- }
- }
- //$inarr没去重,应该不要紧
- $param = get_params();
- if (isset($param["project_start_time"])) {
- $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
- }
- if (isset($param["project_end_time"])) {
- $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
- }
- $where3 = array();
- if (!empty($param['project_status'])) {
- $where3[] = ['project_status', '=', $param['project_status']];
- }
- if (!empty($param['province'])) {
- $where3[] = ['province', '=', $param['province']];
- }
- if (!empty($param['city'])) {
- $where3[] = ['city', '=', $param['city']];
- }
- if (!empty($param['area'])) {
- $where3[] = ['area', '=', $param['area']];
- }
- if (!empty($param['project_end_time'])) {
- $where3[] = ['project_end_time', '<', $param['project_end_time']];
- }
- if (!empty($param['project_start_time'])) {
- $where3[] = ['project_start_time', '>', $param['project_start_time']];
- }
- if (!empty($param['entrust_unit_name'])) {
- $where3[] = ['entrust_unit_name', 'like', '%' . $param['entrust_unit_name']. '%'];
- }
- if (!empty($param['sent_review_unit_name'])) {
- $where3[] = ['sent_review_unit_name', 'like', '%' . $param['sent_review_unit_name']. '%'];
- }
- if (!empty($param['keyword'])) {
- $keyword = $param['keyword'];
- $where3[] = ['project_num|project_name|entrust_maker_name', 'like', '%' . $keyword . '%'];
- }
- $where = [
- ["cp_cost_project.delete_time", "=", 0],
- ["project_status", ">", 3],
- ["review_unit","=",get_login_admin("unit_name")]
- ];
- if($this->isPay==0){
- $where[] = ["project_status","<",8];
- }
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'project_receive_time desc,id desc' : $param['order'];
- $field = $this->Field->get_field_rules_New($this->uid);
- $see_auth = isset($field["see_auth"])?$field["see_auth"]:3;
- $this->see_auth = $see_auth;
- if($see_auth==3){
- $list = $this->model
- ->where($where)->whereIn("id", $inarr)->where($where3)
- ->order($order)->paginate($rows, false, ['query' => $param])
- ->each(function ($item) {
- $item->creator = Db::name("admin")->where("id",$item->creator)->value("nickname");
-
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- }
- } else {
- $item->red = 0;
- }
-
- $entrust_head_id = Db::name('department')->where(['id' => $item->entrust_unit])->value('leader_id');
- if (!($item->entrust_head_phone)) {
- $item->entrust_head_phone = Db::name('admin')->where("id", $entrust_head_id)->value("mobile");
- }
- if ( ($item->province&&$item->city&&$item->area)) {
- $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
- }
- $item->self_id = $this->see_auth;
- //作业人
- $item->operate_name = Db::name("admin")->where("id", $item->operate_head)->value("nickname");
- $operate_team_names = null;
- // halt($item->operate_team);
- //只有一个人会报错
- // dump($item->operate_team);
- $aaa = empty($item->operate_team) ? $item->operate_team : "0";
- // dump($aaa);
- // $aaa = isset($param['id']) ? $param['id'] : 0;
- $operate_team_names_ids = explode(",", $aaa);
- for ($i = 0; $i < count($operate_team_names_ids); $i++) {
- $name = Db::name("admin")->where("id", $operate_team_names_ids[$i])->value("nickname");
- if (!($i == 0)) {
- $name = "," . $name;
- }
- $operate_team_names = $operate_team_names . $name;
- }
- $item->operate_team_names = $operate_team_names;
- });
-
- }elseif ($see_auth==0){
- $list = $this->model
- ->where($where)->whereIn("id", $inarr)->where($where3)
- ->order($order)->paginate($rows, false, ['query' => $param])
- ->each(function ($item) {
- $item->creator = Db::name("admin")->where("id",$item->creator)->value("nickname");
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- }
- } else {
- $item->red = 0;
- }
- $entrust_head_id = Db::name('department')->where(['id' => $item->entrust_unit])->value('leader_id');
- if (!($item->entrust_head_phone)) {
- $item->entrust_head_phone = Db::name('admin')->where("id", $entrust_head_id)->value("mobile");
- }
- if ( ($item->province&&$item->city&&$item->area)) {
- $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
- }
- //作业人
- $item->operate_name = Db::name("admin")->where("id", $item->operate_head)->value("nickname");
- $operate_team_names = null;
- // halt($item->operate_team);
- //只有一个人会报错
- // dump($item->operate_team);
- $aaa = isset($item->operate_team) ? $item->operate_team : "0";
- // dump($aaa);
- // $aaa = isset($param['id']) ? $param['id'] : 0;
- $operate_team_names_ids = explode(",", $aaa);
- for ($i = 0; $i < count($operate_team_names_ids); $i++) {
- $name = Db::name("admin")->where("id", $operate_team_names_ids[$i])->value("nickname");
- if (!($i == 0)) {
- $name = "," . $name;
- }
- $operate_team_names = $operate_team_names . $name;
- }
- $item->operate_team_names = $operate_team_names;
- });
- }else{
- $list = $this->model
- ->where($where)->where($where3)
- ->order($order)->paginate($rows, false, ['query' => $param])
- ->each(function ($item) {
- $item->creator = Db::name("admin")->where("id",$item->creator)->value("nickname");
-
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- }
- } else {
- $item->red = 0;
- }
- $entrust_head_id = Db::name('department')->where(['id' => $item->entrust_unit])->value('leader_id');
- if (!($item->entrust_head_phone)) {
- $item->entrust_head_phone = Db::name('admin')->where("id", $entrust_head_id)->value("mobile");
- }
- if ( ($item->province&&$item->city&&$item->area)) {
- $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
- }
- $item->self_id = $this->see_auth;
- //作业人
- $item->operate_name = Db::name("admin")->where("id", $item->operate_head)->value("nickname");
- $operate_team_names = null;
- // halt($item->operate_team);
- //只有一个人会报错
- // dump($item->operate_team);
- $aaa = isset($item->operate_team) ? $item->operate_team : "0";
-
- // dump($aaa);
- // $aaa = isset($param['id']) ? $param['id'] : 0;
- $operate_team_names_ids = explode(",", $aaa);
- for ($i = 0; $i < count($operate_team_names_ids); $i++) {
- $name = Db::name("admin")->where("id", $operate_team_names_ids[$i])->value("nickname");
- if (!($i == 0)) {
- $name = "," . $name;
- }
- $operate_team_names = $operate_team_names . $name;
- }
- $item->operate_team_names = $operate_team_names;
- });
- }
- return table_assign(0, '', $list);
- } else {
- $field = $this->Field->get_field_rules_New($this->uid);
- $fields = [];
- foreach ($field as $k=>$v){
- if($v!=1){
- $fields[$k] = true;
- }else{
- $fields[$k] = false;
- }
- }
- // halt( json_encode($fields));
- View::assign('field', $fields);
- return view();
- }
- }
- /**
- * 首页临期数据列表
- */
- public function list1(){
- $param = get_params();
- $inarr = array();
- $review_unit = $this->model->where("review_unit", get_login_admin("unit_name"))->field('id,review_head,operate_head,operate_team')->select()->toArray();
- for ($i = 0; $i < count($review_unit); $i++) {
- $a = $review_unit[$i];
- $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
- $ids = explode(",", $ids);
- $c = in_array($this->uid, $ids);
- if ($c) {
- $inarr[] = $a["id"];
- }
- }
- $where = [
- ["cp_cost_project.delete_time", "=", 0],
- ["project_status", ">", 4],
- ["project_status", "<", 7],
- ['project_end_time', '<', strtotime('15 days')],
- ['project_end_time', '>', time()],
- ];
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $list = $this->model
- ->where($where)->whereIn("id", $inarr)->order($order)
- ->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- });
- return table_assign(0, '', $list);
- }
- /**
- * 首页逾期数据列表
- */
- public function list2(){
- $param = get_params();
- $inarr = array();
- $review_unit = $this->model->where("review_unit", get_login_admin("unit_name"))->field('id,review_head,operate_head,operate_team')->select()->toArray();
- for ($i = 0; $i < count($review_unit); $i++) {
- $a = $review_unit[$i];
- $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
- $ids = explode(",", $ids);
- $c = in_array($this->uid, $ids);
- if ($c) {
- $inarr[] = $a["id"];
- }
- }
- $where = [
- ["cp_cost_project.delete_time", "=", 0],
- ["project_status", ">=", 4],
- ["project_status", "<=", 7],
- ['project_end_time', '<', time()],
- ];
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $list = $this->model
- ->where($where)->whereIn("id", $inarr)
- ->order($order)
- ->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- });;
- return table_assign(0, '', $list);
- }
- /**
- * 公司建立项目
- */
- public function add(){
- if (request()->isAjax()) {
- $param = get_params();
- if (isset($param["project_start_time"])) {
- $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
- }
- if (isset($param["project_end_time"])) {
- $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
- }
- $param["review_unit"] = get_login_admin("unit_name");
- $param["review_unit_name"] = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title");
- $param["review_head"] = $this->uid;
- $param["review_head_name"] = get_login_admin("nickname");
- $param["review_head_phone"] = get_login_admin("mobile");
- $param["project_status"] = 4;
- $param["maker_type"] = 2;
- $param["creator"] = $this->uid;
- $file_ids = isset($param["file_ids"]) ? $param["file_ids"] : 0;
- unset($param["file_ids"]);
- $file_id = [];
- $insertId = 0;
- try {
- $param['create_time'] = time();
- $insertId = $this->model->strict(false)->field(true)->insertGetId($param);
- if ($file_ids) {
- for ($a = 0; $a < count($file_ids); $a++) {
- $file_id[] = ["id" => $file_ids[$a], "topic_id" => $insertId];
- }
- $this->filemodel->saveAll($file_id);
- }
- add_log('add', $insertId, $param);
- add_project_log("创建项目", $insertId, "创建项目");
- add_user($param["review_head"], $insertId);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- return to_assign(0, '操作成功', ['aid' => $insertId]);
- }else{
- return view();
- }
- }
- public function save()
- {
- if (request()->isAjax()) {
- $param = get_params();
- // 检验完整性
- try {
- validate(CostProjectValidate::class)->check($param);
- } catch (ValidateException $e) {
- // 验证失败 输出错误信息
- return to_assign(1, $e->getError());
- }
- if (isset($param["plan_time"])) {
- $param["plan_time"] = $param["plan_time"] ? strtotime($param["plan_time"]) : 0;
- }
- if (isset($param["due_time"])) {
- $param["due_time"] = $param["due_time"] ? strtotime($param["due_time"]) : 0;
- }
- $param = array_merge($param, ["status" => 6]);
- // halt($param);
- $this->model->editCostProject($param);
- }
- }
- /**
- * 编辑
- */
- public function edit()
- {
- $param = get_params();
- $param["type"] = isset($param["type"]) ? $param["type"] : 0;
-
- if (request()->isAjax()) {
- // 检验完整性
- // try {
- // validate(CostProjectValidate::class)->check($param);
- // } catch (ValidateException $e) {
- // // 验证失败 输出错误信息
- // return to_assign(1, $e->getError());
- // }
- if (isset($param["project_start_time"])) {
- $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
- }
- if (isset($param["project_end_time"])) {
- $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
- }
- if ($param["type"] == 2) {
- $id = isset($param['id']) ? $param['id'] : 0;
- $project_status = $this->model->where("id", $id)->value("project_status");
- //判断当前状态是否是可编辑状态
-
- $detail = $this->model->getCostProjectById($id);
- $file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
- ->select()->toArray();
- $comment_type = isset($param["comment_type"])?$param['comment_type'] : 0;
- $comment = Db::name("project_comment")->where("type",$comment_type)
- ->where("project_id", $id)->order('create_time', 'asc')->select();
- $project_log = self::project_log($id);
- // halt($project_log);
- View::assign('project_log', $project_log);
- $field = $this->Field->get_field_rules_new($this->uid);
- $field_edit = $this->Field->get_field_rules_edit_new($this->uid);
- //剩余时间
- $c = $detail['project_end_time']-time();
- if($c>0){
- $advent_time = floor($c / 86400)."天";
- }else{
- $c = -$c;
- $advent_time = floor($c / 86400)."天";
- }
- if (!empty($detail)) {
- View::assign('advent_time', $advent_time);
- View::assign('detail', $detail);
- View::assign('file_array', $file_array);
- View::assign('comment', $comment);
- View::assign('field', $field);
- View::assign('field_edit', $field_edit);
- View::assign('project_five', self::getProjectFive());
- return view();
- } else {
- throw new \think\exception\HttpException(404, '找不到页面');
- }
-
- }
- $field_name = array_keys($this->field_name);
- $ab= $this->model->where("id",$param["id"])->field($field_name)->find()->toArray();
- $c = array_intersect_key($param,$ab);
- $maker_name = get_login_admin("nickname");
- $content = '';
- // $a = [];
- foreach ($c as $key => $value) {
- if($c[$key]!==$ab[$key]){
- // $a[]=$c[$key];
- // $a[]=$ab[$key];
- $ab[$key] = !empty($ab[$key])?$ab[$key]:"无";
- $value = !empty($value)?$value:"无";
-
- $content = $content . $this->field_name[$key]."从".$ab[$key]."修改为".$value.",";
- }
- }
- // halt($a);
- $content =rtrim($content ,",");
- if(!empty($content)){
- $content = $maker_name."将".$content;
- }else{
- $content = "无修改";
- }
- add_project_log('编辑项目', $param['id'],$content,1);
- $this->model->editCostProject($param);
- } else {
- $id = isset($param['id']) ? $param['id'] : 0;
- $project_status = $this->model->where("id", $id)->value("project_status");
- //判断当前状态是否是可编辑状态
- // if ($project_status == 5) {
- $detail = $this->model->getCostProjectById($id);
- $file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
- ->select()->toArray();
- $comment_type = isset($param["comment_type"])?$param['comment_type'] : 0;
- $comment = Db::name("project_comment")->where("type",$comment_type)
- ->where("project_id", $id)->order('create_time', 'asc')->select();
- $project_log = self::project_log($id);
- // halt($file_array);
- View::assign('project_log', $project_log);
- $field = $this->Field->get_field_rules_new($this->uid);
- $field_edit = $this->Field->get_field_rules_edit_new($this->uid);
- //剩余时间
- $c = $detail['project_end_time']-time();
- if($c>0){
- $advent_time = floor($c / 86400)."天";
- }else{
- $c = -$c;
- $advent_time = floor($c / 86400)."天";
- }
- $red = Db::name("new_msg")->where([["uid",'=',$this->uid],["project_id","=",$id]])->field('detail,comment,record,report,user,contact')->find();
- if(empty($red)){
- $red = ["detail"=>0,"comment"=>0,"record"=>0,"report"=>0,"user"=>0,"contact"=>0];
- }
- if (!empty($detail)) {
- View::assign('advent_time', $advent_time);
- View::assign('red', $red);
- View::assign('detail', $detail);
- View::assign('file_array', $file_array);
- View::assign('comment', $comment);
- View::assign('project_five', self::getProjectFive());
- View::assign('field', $field);
- View::assign('field_edit', $field_edit);
- return view();
- } else {
- throw new \think\exception\HttpException(404, '找不到页面');
- }
- }
- }
- /**
- * 归档
- */
- public function finish()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- $id = isset($param['id']) ? $param['id'] : 0;
- $approver_name = $this->model->where("id", $id)->value("entrust_maker");
- $auditData = [
- "project_id" => $param["id"],
- "project_name" => $this->model->where("id", $id)->value('project_name'),
- "project_type" => "造价项目",
- "audit_name" => "申请归档审核",
- "audit_type" => 1,
- "sponsor" => Db::name('admin')->where("id", $this->uid)->value("nickname"),
- "sponsor_id" => $this->uid,
- "sponsor_unit" => Db::name("department")->where("id", get_login_admin("unit_name"))->value("title"),
- "approver" => $approver_name,
- "approver_name" => Db::name('admin')->where("id", $approver_name)->value("nickname"),
- "remark" => $param["finish_reason"],
- "create_time" => time()
- ];
- ProjectAudit::create($auditData);
- $this->model->where("id", $id)->update(["project_status" => 6]);
- if(empty($handle['financial'])){
- $handle['financial'] = (array)$approver_name;
- }else{
- $handle['financial'] = array_merge($handle['financial'],(array)$approver_name);
- }
- add_project_log("归档审批", $id,"归档审批");
- $this->Pushmessage->pushMessage($id, $handle['financial'], $handle['company']);
- return to_assign(0, "操作成功");
- }
- /**
- * 退审
- */
- public function dismissal()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- $id = isset($param['id']) ? $param['id'] : 0;
- if (empty($param["dismissal_reason"])) {
- return to_assign(0, "退审原因不能为空");
- } else {
- $approver_name = $this->model->where("id", $id)->value("entrust_maker");
- $auditData = [
- "project_id" => $param["id"],
- "project_name" => $this->model->where("id", $id)->value('project_name'),
- "project_type" => "造价项目",
- "audit_name" => "申请退审审核",
- "audit_type" => 1,
- "sponsor" => Db::name('admin')->where("id", $this->uid)->value("nickname"),
- "sponsor_id" => $this->uid,
- "sponsor_unit" => Db::name("department")->where("id", get_login_admin("unit_name"))->value("title"),
- "approver" => $approver_name,
- "approver_name" => Db::name('admin')->where("id", $approver_name)->value("nickname"),
- "remark" => $param["dismissal_reason"],
- "create_time" => time()
- ];
- // halt($auditData);
- ProjectAudit::create($auditData);
- $this->model->where("id", $id)->update(["project_status" => 7]);
- add_project_log("退审审批", $id,"退审审批");
- if(empty($handle['financial'])){
- $handle['financial'] = (array)$approver_name;
- }else{
- $handle['financial'] = array_merge($handle['financial'],(array)$approver_name);
- }
- $this->Pushmessage->pushMessage($id, $handle['financial'], $handle['company']);
- return to_assign(0, "操作成功");
- }
- }
- /**
- * 查看信息
- */
- public function read()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->model->getCostProjectById($id);
- $comment_type = isset($param["comment_type"])?$param['comment_type'] : 0;
- $comment = Db::name("project_comment")->where("type",$comment_type)
- ->where("project_id", $id)->order('create_time', 'asc')->select();
- $file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
- ->select()->toArray();
- $report = Db::name("project_report")->where([["project_id", "=", $id], ["r.status", "=", 1]])->alias("r")->join("admin a", "r.maker_id = a.id")->field("r.*,a.nickname")->select();
- $uid = Db::name("relation")->where("uuid",$id)->column("uid");
- $contract = Db::name("contract")->whereIn("id",$uid)
- ->where("subject_id",get_login_admin("unit_name"))->column("id,name,type,sign_time,sign_name");
- $project_log = self::project_log($id);
- View::assign('project_log', $project_log);
- $field = $this->Field->get_field_rules_new($this->uid);
- $red = Db::name("new_msg")->where([["uid",'=',$this->uid],["project_id","=",$id]])->field('detail,comment,record,report,user,contact')->find();
- if(empty($red)){
- $red = ["detail"=>0,"comment"=>0,"record"=>0,"report"=>0,"user"=>0,"contact"=>0];
- }
- //剩余时间
- $c = $detail['project_end_time']-time();
- if($c>0){
- $advent_time = floor($c / 86400)."天";
- }else{
- $c = -$c;
- $advent_time = floor($c / 86400)."天";
- }
- // dump($field);
- if (!empty($detail)) {
-
- View::assign('advent_time', $advent_time);
- View::assign('detail', $detail);
- View::assign('project_id', $id);
- View::assign('comment', $comment);
- View::assign('contract', $contract);
- View::assign('file_array', $file_array);
- View::assign('report', $report);
- View::assign('field', $field);
- View::assign('red', $red);
- View::assign('project_five', self::getProjectFive());
- return view();
- } else {
- throw new \think\exception\HttpException(404, '找不到页面');
- }
- }
- //获取客户列表
- public function get_customer()
- {
- $param = get_params();
- $where = array();
- if (!empty($param['keywords'])) {
- $where[] = ['id|name', 'like', '%' . $param['keywords'] . '%'];
- }
- $where[] = ['delete_time', '=', 0];
- $where[] = ['status', '=', 1];
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $list = Db::name('institution')->where('institution_type', 1)->field('id,institution,address')->order('id asc')->where($where)->paginate($rows, false);
- table_assign(0, '', $list);
- }
- //添加附件
- public function add_file()
- {
- $param = get_params();
- $param['create_time'] = time();
- $param['admin_id'] = $this->uid;
- $fid = Db::name('project_file')->strict(false)->field(true)->insertGetId($param);
- }
- //删除
- public function delete_file()
- {
- if (request()->isDelete()) {
- $id = get_params("id");
- $detail = Db::name('ProjectFile')->where('id', $id)->find();
- if (Db::name('ProjectFile')->where('id', $id)->delete() !== false) {
- return to_assign(0, "删除成功");
- } else {
- return to_assign(0, "删除失败");
- }
- } else {
- return to_assign(1, "错误的请求");
- }
- }
- public function project_log($project_id)
- {
- // $project_id = 24;
- $login_admin = get_login_admin();
- $where = array();
- if ($login_admin['user_type'] == 2) {
- $where = [
- ['project_status', '>=', 3],
- ['unit_name', '=', $login_admin['unit_name']],
- ];
- } else {
- if ($login_admin['permission'] != 1) {
- $where = [
- ['unit_name', '=', $login_admin['unit_name']],
- ];
- }
- }
- // dump($where);
- $project_log = Db::name('ProjectLog')->where($where)
- ->where('project_id', $project_id)
- ->order('create_time', 'desc')
- ->select()->toArray();
- // foreach ($project_log as $key => $value) {
- // $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
- // if($login_admin['user_type'] != 0){
- // if(str($project_log[$key]['content'], '送审单位承担审核费')){
- // unset($project_log[$key]);
- // }
- // if(str($project_log[$key]['content'], '施工单位负责核减超5%评审费部分')){
- // unset($project_log[$key]);
- // }
- // }
- // }
- // dump($project_log);
- // View::assign('project_log', $project_log);
- // return View();
- return $project_log;
- }
- public function project_user()
- {
- $param = get_params();
- $ids = $this->model->where("id", $param["project_id"])->field("entrust_maker,review_head,operate_head,operate_team")->find()->toArray();
- $idarr = $ids["operate_team"] . ',' . $ids["operate_head"] . ',' . $ids["review_head"] . ',' . $ids["entrust_maker"];
- $idarr = explode(",", $idarr);
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $list = $this->Adminmodel->whereIn("id", $idarr)->field("id,nickname,unit_name,mobile")->paginate($rows, false, ['query' => $param])
- ->each(function ($item) {
- //获取单位的邮箱,单位信息页没做
- $item->email = Db::name('department')->where(['id' => $item->unit_name])->value('email');
- $type = Db::name('department')->where(['id' => $item->unit_name])->value('type');
- $item->unit_name = Db::name('department')->where(['id' => $item->unit_name])->value('title');
- // dump($type);
- if ($type == 0) {
- $item->unit_type = "委托单位";
- } elseif ($type == 1) {
- $item->unit_type = "送审单位";
- } elseif ($type == 2) {
- $item->unit_type = "评审机构";
- }
- })->toArray();
- $list = $list["data"];
- $shigong = $this->model->where('id', $param["project_id"])->find();
- $time_id_sent = time()-200;
- if ($shigong["sent_review_unit"] !== null ||
- $shigong["sent_review_head"] !== null ||
- $shigong["sent_review_phone"] !== null ||
- $shigong["sent_review_head_email"] !== null
- ) {
- $sent_review_data["id"] = $time_id_sent;
- $sent_review_data["nickname"] = $shigong["sent_review_head_name"];
- $sent_review_data["unit_name"] = $shigong["sent_review_unit_name"];
- $sent_review_data["email"] = $shigong["sent_review_head_email"];
- $sent_review_data["mobile"] = $shigong["sent_review_phone"];
- $sent_review_data["unit_type"] = "送审单位";
- array_push($list, $sent_review_data);
- }
- if(empty($ids['operate_team'])){
- $operate_team[] = '0';
- }else{
- $operate_team = explode(',', $ids['operate_team']);
- }
- for ($i = 0; $i < count($list); $i++) {
- if ($list[$i]['id'] == $ids['entrust_maker']) {
- // dump($list[$i]['id'],$ids['entrust_maker']);
- $list[$i]["type"] = 1;
- } elseif ($list[$i]['id'] == $ids['review_head']) {
- $list[$i]["type"] = 2;
- } elseif ($list[$i]['id'] == $ids['operate_head']) {
- $list[$i]["type"] = 3;
- } elseif (in_array($list[$i]['id'], $operate_team)) {
- $list[$i]["type"] = 4;
- } elseif ($list[$i]['id'] !== time() - 1000) {
- $list[$i]["type"] = 6;
- }
- }
- $type = array_column($list, 'type');
- array_multisort($type, SORT_ASC, $list);
- $lists["total"] = count($list);
- $lists["data"] = $list;
- return table_assign(0, '', $lists);
- }
- // 财政局接口
- public function remove_user()
- {
- $param = get_params();
- if ($param["type"] == 3) {
- $this->model->where("id", $param["project_id"])->update(["operate_head" => 0]);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- add_project_log("移除项目负责人",$param["project_id"],$name,5);
- remove_user($param["id"]);
- return to_assign(0, '操作成功');
- }
- if ($param["type"] == 4) {
- $idarr = $this->model->where("id", $param["project_id"])->value("operate_team");
- $idarr = explode(",", $idarr);
- $key = array_search($param["id"], $idarr);
- unset($idarr[$key]);
- $str = implode(',', $idarr);
- $this->model->where("id", $param["project_id"])->update(["operate_team" => $str]);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- remove_user($param["id"]);
- add_project_log("移除项目成员",$param["project_id"],$name,5);
- return to_assign(0, '操作成功');
- }
- return to_assign(0, '操作失败');
- }
- // 公司接口
- public function remove_user_company()
- {
- $param = get_params();
- if ($param["type"] == 3) {
- $this->model->where("id", $param["project_id"])->update(["operate_head" => 0,"operate_head_name"=>null]);
- $operate_team = $this->model->where("id", $param["project_id"])->value("operate_team");
- if(empty($operate_team)){
- $this->model->where("id", $param["project_id"])->update(["project_status" => 4]);
- }
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- $content = get_login_admin("nickname")."移除了作业负责人".$name;
- add_project_log("移除项目负责人",$param["project_id"],$content,5);
- remove_user($param["id"]);
- return to_assign(0, '操作成功');
- }
- if ($param["type"] == 4) {
- $idarr = $this->model->where("id", $param["project_id"])->value("operate_team");
- $idarr = explode(",", $idarr);
- $key = array_search($param["id"], $idarr);
- unset($idarr[$key]);
- $str = implode(',', $idarr);
- $this->model->where("id", $param["project_id"])->update(["operate_team" => $str]);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- $operate_head = $this->model->where("id", $param["project_id"])->value("operate_head");
- if($operate_head==0&&empty($str)){
- $this->model->where("id", $param["project_id"])->update(["project_status" => 4]);
- }
- add_project_log("移除项目成员",$param["project_id"],$name,5);
- remove_user($param["id"]);
- return to_assign(0, '操作成功');
- }
- return to_assign(0, '操作失败');
- }
- // 公司接口
- public function add_company_user()
- {
- //都没做原来就有的校验
- $param = get_params();
- if ($param["type"] == 1) {
- $a=$this->model->where("id", $param["project_id"])->value("operate_head");
- if($a){
- return to_assign(1, '已有负责人,请移除后再添加');
- }
- $b=$this->model->where("id", $param["project_id"])->value("review_head");
- if($b==$param["id"]){
- return to_assign(1, '已是评审单位负责人,请移除后再添加');
- }
- $c = $this->model->where("id", $param["project_id"])->value("operate_team");
- if($c){
- $c = explode(",", $c);
- if(in_array($param["id"],$c)){
- return to_assign(1, '已是作业成员,不可再添加');
- }
- }
- $this->model->where("id", $param["project_id"])->update(["operate_head" => $param["id"],"project_status" => 5]);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- add_user($param["id"],$param["project_id"]);
- add_project_log("新增了作业负责人",$param["project_id"],$name,5);
- return to_assign(0, '操作成功');
- } elseif ($param["type"] == 2) {
- $a=$this->model->where("id", $param["project_id"])->value("sent_review_head");
- if($a){
- return to_assign(1, '已有负责人,请移除后再添加');
- }
- $data=[
- "sent_review_unit" =>get_admin($param["id"])["unit_name"],
- "sent_review_unit_name" =>Db::name("department")->where("id",get_admin($param["id"])["unit_name"])->value("title"),
- "sent_review_head" => $param["id"],
- "sent_review_head_name" => get_admin($param["id"])["nickname"],
- "sent_review_phone"=>get_admin($param["id"])["mobile"]
- ];
- $this->model->where('id', $param["project_id"])->update($data);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- add_user($param["id"],$param["project_id"]);
- add_project_log("新增了送审单位负责人",$param["project_id"],$name,5);
- return to_assign(0, "操作成功");
- }
- }
- // 财政局接口
- public function add_user()
- {
- $param = get_params();
- if ($param["type"] == 1) {
- $a=$this->model->where("id", $param["project_id"])->value("operate_head");
- if($a){
- return to_assign(1, '已有负责人,请移除后再添加');
- }
- $b=$this->model->where("id", $param["project_id"])->value("review_head");
- if($b==$param["id"]){
- return to_assign(1, '已是评审单位负责人,请移除后再添加');
- }
- $c = $this->model->where("id", $param["project_id"])->value("operate_team");
- if($c){
- $c = explode(",", $c);
- if(in_array($param["id"],$c)){
- return to_assign(1, '已是作业成员,不可再添加');
- }
- }
- $this->model->where("id", $param["project_id"])->update(["operate_head" => $param["id"]]);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- add_user($param["id"],$param["project_id"]);
- add_project_log("新增了作业负责人",$param["project_id"],$name,5);
- return to_assign(0, '操作成功');
- } elseif ($param["type"] == 2) {
- $a=$this->model->where("id", $param["project_id"])->value("sent_review_head");
- if($a){
- return to_assign(1, '已有负责人,请移除后再添加');
- }
- $data=[
- "sent_review_unit" =>get_admin($param["id"])["unit_name"],
- "sent_review_unit_name" =>Db::name("department")->where("id",get_admin($param["id"])["unit_name"])->value("title"),
- "sent_review_head" => $param["id"],
- "sent_review_head_name" => get_admin($param["id"])["nickname"],
- "sent_review_phone"=>get_admin($param["id"])["mobile"]
- ];
- $this->model->where('id', $param["project_id"])->update($data);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- add_project_log("新增了送审单位负责人",$param["project_id"],$name,5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, "操作成功");
- }
- }
- public function add_user_company_head(){
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- $a=$this->model->where("id", $param["project_id"])->value("review_head");
- if($a){
- return to_assign(1, '已有联系人,请移除后再添加');
- }
- $a=$this->model->where("id", $param["project_id"])->field("operate_head,operate_team")->find();
- $b = $a["operate_head"];
- if($b==$param["id"]){
- return to_assign(1, '已是作业负责人,请移除后再添加');
- }
- $c = $a["operate_team"];
- if($c){
- $c = explode(",", $c);
- if(in_array($param["id"],$c)){
- return to_assign(1, '已是作业成员,不可再添加');
- }
- }
- $name = Db::name("admin")->where("id",$param["id"])->field("nickname,mobile")->find();
- $this->model->where("id", $param["project_id"])->update(["review_head" => $param["id"],"review_head_name"=>$name["nickname"],"review_head_phone"=>$name["mobile"]]);
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], (array)$param['id']);
- add_project_log("新增项目成员",$param["project_id"],$name["nickname"],5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, '操作成功');
- }
- // 公司接口
- public function add_user_company_type1()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if ($param["type"] == 1) {
- $a=$this->model->where("id", $param["project_id"])->value("operate_head");
- if($a){
- return to_assign(1, '已有负责人,请移除后再添加');
- }
- $a=$this->model->where("id", $param["project_id"])->field("review_head,operate_team")->find();
- $b = $a["review_head"];
- if($b==$param["id"]){
- return to_assign(1, '已是评审单位负责人,请移除后再添加');
- }
- $c = $a["operate_team"];
- if($c){
- $c = explode(",", $c);
- if(in_array($param["id"],$c)){
- return to_assign(1, '已是作业成员,不可再添加');
- }
- }
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- $this->model->where("id", $param["project_id"])->update(["operate_head" => $param["id"],"project_status" => 5,"operate_head_name"=>$name]);
- $content = get_login_admin("nickname")."新增了作业负责人".$name;
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], (array)$param['id']);
- add_project_log("新增项目成员",$param["project_id"],$content,5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, '操作成功');
- } elseif ($param["type"] == 2) {
- $b=$this->model->where("id", $param["project_id"])->value("review_head");
- if($b==$param["id"]){
- return to_assign(1, '已是评审单位负责人,请移除后再添加');
- }
- $a=$this->model->where("id", $param["project_id"])->value("operate_head");
- if($a==$param["id"]){
- return to_assign(1, '已是负责人,不可再添加');
- }
- $ids = $this->model->where("id", $param["project_id"])->value("operate_team");
- if($ids){
- $idarr = explode(",", $ids);
- if(in_array($param["id"],$idarr)){
- return to_assign(1, '已存在,不可再添加');
- }
- }
- $ids = !empty($ids)?$ids:0;
- if ($ids == 0) {
- $ids = $param["id"];
- } else {
- $ids = $ids . "," . $param["id"];
- }
- $this->model->where('id', $param["project_id"])->update(["operate_team" => $ids,"project_status" => 5]);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], (array)$param['id']);
- add_project_log("新增项目成员",$param["project_id"],$name,5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, "操作成功");
- }elseif ($param["type"] == 3) {
- $a=$this->model->where("id", $param["project_id"])->value("review_head");
- if($a){
- return to_assign(1, '已有联系人,请移除后再添加');
- }
- $a=$this->model->where("id", $param["project_id"])->field("operate_head,operate_team")->find();
- $b = $a["operate_head"];
- if($b==$param["id"]){
- return to_assign(1, '已是作业负责人,请移除后再添加');
- }
- $c = $a["operate_team"];
- if($c){
- $c = explode(",", $c);
- if(in_array($param["id"],$c)){
- return to_assign(1, '已是作业成员,不可再添加');
- }
- }
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- $this->model->where("id", $param["project_id"])->update(["operate_head" => $param["id"],"operate_head_name"=>$name]);
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], (array)$param['id']);
- add_project_log("新增项目成员",$param["project_id"],$name,5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, '操作成功');
- }
- }
- // 公司接口
- public function add_user_company_type2()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if ($param["type"] == 1) {
- $a=$this->model->where("id", $param["project_id"])->value("operate_head");
- if($a){
- return to_assign(1, '已有负责人,请移除后再添加');
- }
- $b=$this->model->where("id", $param["project_id"])->value("review_head");
- if($b==$param["id"]){
- return to_assign(1, '已是评审单位负责人,请移除后再添加');
- }
- $c = $this->model->where("id", $param["project_id"])->value("operate_team");
- if($c){
- $c = explode(",", $c);
- if(in_array($param["id"],$c)){
- return to_assign(1, '已是作业成员,不可再添加');
- }
- }
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- $this->model->where("id", $param["project_id"])->update(["operate_head" => $param["id"],"project_status" => 5,"operate_head_name"=>$name]);
- $content = get_login_admin("nickname")."新增了作业负责人".$name;
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], (array)$param['id']);
- add_project_log("新增项目成员",$param["project_id"],$content,5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, '操作成功');
- } elseif ($param["type"] == 2) {
- $b=$this->model->where("id", $param["project_id"])->value("review_head");
- if($b==$param["id"]){
- return to_assign(1, '已是评审单位负责人,请移除后再添加');
- }
- $a=$this->model->where("id", $param["project_id"])->value("operate_head");
- if($a==$param["id"]){
- return to_assign(1, '已是作业负责人,请移除后再添加');
- }
- $ids = $this->model->where("id", $param["project_id"])->value("operate_team");
- if($ids){
- $idarr = explode(",", $ids);
- if(in_array($param["id"],$idarr)){
- return to_assign(1, '已存在,不可再添加');
- }
- }
- $ids = !empty($ids)?$ids:0;
- if ($ids == 0) {
- $ids = $param["id"];
- } else {
- $ids = $ids . "," . $param["id"];
- }
- $this->model->where('id', $param["project_id"])->update(["operate_team" => $ids,"project_status" => 5]);
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], (array)$param['id']);
- $name = Db::name("admin")->where("id",$param["id"])->value("nickname");
- $content = get_login_admin("nickname")."新增了作业成员".$name;
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], (array)$param['id']);
- add_project_log("新增项目成员",$param["project_id"],$content,5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, "操作成功");
- }
- }
- public function add_entrust_people(){
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (request()->isAjax()) {
- $param = get_params();
- $id = isset($param["id"])?$param["id"]:0;
- $project_id = isset($param["project_id"])?$param["project_id"]:0;
- $selfData = get_admin($id);
- $data = [
- "id" => $project_id,
- "entrust_maker" => $id,
- "entrust_maker_name" => $selfData["nickname"],
- "entrust_unit" => $selfData["unit_name"],
- "entrust_unit_name" => Db::name("department")->where("id",$selfData["unit_name"])->value("title")
- ];
- try{
- $this->model->update($data);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- return to_assign(0, "操作成功");
- }
- }
- public function add_sent_review_unit()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (request()->isAjax()) {
- $a = $this->model->where("id", $param["project_id"])->find();
- if($a["sent_review_head"]){
- return to_assign(1, '送审单位负责人已经存在,请移除后再添加');
- }
- $user = Db::name("admin")->where("id",$param["id"])->find();
- $department = Db::name("department")->where("id",$user["unit_name"])->find();
- $this->model->where("id",
- $param["project_id"])
- ->update(
- [
- "sent_review_head" => $param["id"],
- "sent_review_head_name"=>$user['nickname'],
- "sent_review_phone"=> $user["mobile"],
- "sent_review_unit_name"=>$department["title"],
- "sent_review_unit"=> $department["id"]
- ]
- );
- $content = get_login_admin("nickname") . "新增了送审单位负责人". $user['nickname'];
- add_project_log("新增项目成员",$param["project_id"],$content,5);
- add_user($param["id"],$param["project_id"]);
- return to_assign(0, '操作成功');
- } else {
- $param = get_params();
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- //关联项目id
- View::assign('project_id', $project_id);
- return view();
- }
- }
- /*public function add_sent_review_unit()
- {
- if (request()->isAjax()) {
- $param = get_params();
- $id = isset($param["id"]) ? $param["id"] : 0;
- $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
- $a = $this->model->where("id", $project_id)->value("sent_review_head");
- if ($a) {
- return to_assign(1, '已有负责人,请移除后再添加');
- }
- $selfData = get_admin($id);
- $data = [
- "id" => $project_id,
- "sent_review_head" => $id,
- "sent_review_head_name" => $selfData["nickname"],
- "sent_review_unit" => $selfData["unit_name"],
- "sent_review_unit_name" => Db::name("department")->where("id", $selfData["unit_name"])->value("title"),
- "sent_review_phone" => $selfData["mobile"]
- ];
- try {
- $this->model->update($data);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- return to_assign(0, "操作成功");
- }
- }*/
- //公司
- public function remove_sent_review(){
- $p = get_params();
- $data = [
- "sent_review_unit" => null,
- "sent_review_unit_name" => null,
- "sent_review_head_name" => null,
- "sent_review_head" => null,
- "sent_review_phone" => null,
- "sent_review_head_email" => null,
- ];
- $this->model->where("id",$p["project_id"])->update($data);
- remove_user($p["id"]);
- add_project_log('移除送审单位成员',$p["project_id"],$p["nickname"],5);
- return to_assign(0,"操作成功");
- }
- //公司
- public function remove_review_head(){
- $p = get_params();
- $data = [
- "review_head" => null,
- "review_head_name" => null,
- "review_head_phone" => null,
- ];
- $this->model->where("id",$p["project_id"])->update($data);
- $name= Db::name("admin")->where("id",$p["id"])->value("nickname");
- remove_user($p["id"]);
- add_project_log('移除送审单位成员',$p["project_id"],$name,5);
- return to_assign(0,"操作成功");
- }
- public function get_department_tree()
- {
- $unit_id = get_unit(get_login_admin("unit_name"));
- $department = Db::name('Department')->where(['status' => 1])->select()->toArray();
- $list = get_tree($department, 0, 2);
- $data['trees'] = $list;
- $result = null;
- for ($i = 0; $i < count($data['trees']); $i++) {
- $point = $data['trees'][$i];
- if ($point["id"] == $unit_id) {
- $result['trees'][] = $point;
- break;
- }
- }
- // halt($result);
- return json($result);
- }
- public function get_department_tree_proprietor($project_id)
- {
- $project = $this->model->where("id" , $project_id)->find();
- $entrust_unit = $project["entrust_unit"];
- $department = Db::name('Department')->where(['status' => 1 , "entrust_unit" => $entrust_unit])->select()->toArray();
- $list = get_tree($department, 0, 2);
- $data['trees'] = $list;
- $result = null;
- for ($i = 0; $i < count($data['trees']); $i++) {
- $point = $data['trees'][$i];
- $result['trees'][] = $point;
- }
- return json($result);
- }
- //获取子部门所有员工
- public function get_employee_proprietor()
- {
- $did = get_params('did');
- if ($did == 1) {
- $department = $did;
- } else {
- $department = get_department_son($did);
- }
- // halt($department);
- $employee = Db::name('admin')
- ->field('a.id,a.did,a.position_id,a.mobile,a.nickname,a.status,a.thumb,a.username,d.title as department')
- ->alias('a')
- ->join('Department d', 'a.did = d.id')
- ->where(['a.status' => 1])
- ->where('a.id', ">", 1)
- ->where('a.did', "in", $department)
- ->select();
- return to_assign(0, '', $employee);
- }
- //获取子部门所有员工
- public function get_employee()
- {
- $did = get_params('did');
- if ($did == 1) {
- $department = $did;
- } else {
- $department = get_department_son(get_login_admin("unit_name"));
- }
- // halt($department);
- $employee = Db::name('admin')
- ->field('a.id,a.did,a.position_id,a.mobile,a.nickname,a.status,a.thumb,a.username,d.title as department')
- ->alias('a')
- ->join('Department d', 'a.did = d.id')
- ->where(['a.status' => 1])
- ->where('a.id', ">", 1)
- ->where('a.did', "in", $department)
- ->select();
- return to_assign(0, '', $employee);
- }
- public function get_yezhu_tree()
- {
- // $unit_id = get_unit(get_login_admin("unit_name"));
- $yezhulist = Db::name('Department')->where(['status' => 1, 'type' => 1])->select()->toArray();
- $list = get_tree($yezhulist, 0, 2);
- $data['trees'] = $list;
- return json($data);
- }
- //获取子部门所有员工
- public function get_people($did = 1)
- {
- $did = get_params('did');
- if ($did == 1) {
- $department = $did;
- } else {
- $department = get_department_son($did);
- }
- $employee = Db::name('admin')
- ->field('a.id,a.did,a.position_id,a.mobile,a.nickname,a.status,a.thumb,a.username,d.title as department')
- ->alias('a')
- ->join('Department d', 'a.did = d.id')
- ->where(['a.status' => 1])
- ->where('a.id', ">", 1)
- ->where('a.did', "in", $department)
- ->select();
- // $employee = $employee->map(function ($employee) {
- // $employee['name'] = $employee["nickname"];
- // return $employee;
- // });
- return to_assign(0, '', $employee);
- }
- public function getProjectFive(){
- $where = [
- ['name', '=', '作业日志-公司'],
- ['name', '=', '工作记录-公司'],
- ['name', '=', '项目报告-公司'],
- ['name', '=', '项目人员-公司'],
- ['name', '=', '项目动态-公司'],
- ['name', '=', '项目附件-公司'],
- ['name', '=', '联系函-公司'],
- ];
- $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
- $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
- $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
- $login_rules = explode(',', $login_rules);
- $rules_id = array();
- foreach($list as $key => $value){
- if($value['name'] == "作业日志-公司"){
- if(in_array($value['id'], $login_rules)){
- $rules_id['project_comments'] = 1;
- }else{
- $rules_id['project_comments'] = 0;
- }
- }else if($value['name'] == "工作记录-公司"){
- if(in_array($value['id'], $login_rules)){
- $rules_id['project_record'] = 1;
- }else{
- $rules_id['project_record'] = 0;
- }
- }else if($value['name'] == "项目报告-公司"){
- if(in_array($value['id'], $login_rules)){
- $rules_id['project_report'] = 1;
- }else{
- $rules_id['project_report'] = 0;
- }
- }else if($value['name'] == "项目人员-公司"){
- if(in_array($value['id'], $login_rules)){
- $rules_id['project_user'] = 1;
- }else{
- $rules_id['project_user'] = 0;
- }
- }else if($value['name'] == "项目动态-公司"){
- if(in_array($value['id'], $login_rules)){
- $rules_id['project_log'] = 1;
- }else{
- $rules_id['project_log'] = 0;
- }
- }else if($value['name'] == "项目附件-公司"){
- if(in_array($value['id'], $login_rules)){
- $rules_id['project_file'] = 1;
- }else{
- $rules_id['project_file'] = 0;
- }
- }else if($value['name'] == "联系函-公司"){
- if(in_array($value['id'], $login_rules)){
- $rules_id['project_contact'] = 1;
- }else{
- $rules_id['project_contact'] = 0;
- }
- }
- }
-
- return $rules_id;
- }
-
- public function ceshi($id)
- {
- View::assign('detailId', $id);
- return view();
- }
-
- }
|