1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150 |
- <?php
- declare (strict_types=1);
- namespace app\admin\controller\project;
- use app\admin\BaseController;
- use app\admin\controller\Pushmessage;
- use app\admin\model\CostProject;
- use app\admin\model\ProjectAudit;
- use app\admin\model\ProjectAudit as AuditModel;
- use app\admin\model\ProjectMsg;
- use app\admin\model\ProjectReport;
- use app\wechat\controller\Officialaccount;
- use think\db\exception\DbException;
- use think\exception\ValidateException;
- use HTMLPurifier;
- use HTMLPurifier_Config;
- use think\facade\Db;
- use think\facade\View;
- class Report extends BaseController
- {
- /**
- * 构造函数
- */
- public function __construct()
- {
- $this->model = new ProjectReport();
- $this->CostModel = new CostProject();
- $this->uid = get_login_admin('id');
- $this->ProjectMsg = new ProjectMsg();
- $this->Auditmodel = new AuditModel();
- $this->Officialaccount = new Officialaccount();
- $this->Pushmessage = new Pushmessage();
- }
- /**
- * 数据列表-财政局
- */
- public function datalist()
- {
- $param = get_params();
- // halt($param);
- $where = [
- ["cp_project_report.delete_time", "=", 0],
- ["project_id", "=", $param["project_id"]],
- ["a.status","<>",6],//公司待审批之前
- ["a.status","<>",7]//公司待审批之前
- ];
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $order = empty($param['order']) ? 'a.id desc' : $param['order'];
- $list = $this->model->where($where)
- ->field('a.*,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
- ->alias('a')
- ->join('file f', "a.file = f.id", "left")
- ->order($order)
- ->paginate($rows, false, ['query' => $param])
- ->each(function ($item, $key) {
- });
- return table_assign(0, '', $list);
- }
- /**
- * 数据列表-公司
- */
- public function datalist_company()
- {
- $param = get_params();
- $where = [
- ["cp_project_report.delete_time", "=", 0],
- ["project_id", "=", $param["project_id"]],
- ];
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $order = empty($param['order']) ? 'a.id desc' : $param['order'];
- $list = $this->model->where($where)
- ->field('a.*,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
- ->alias('a')
- ->join('file f', "a.file = f.id", "left")
- ->order($order)
- ->paginate($rows, false, ['query' => $param])
- ->each(function ($item, $key) {
- });
- // halt($list);
- return table_assign(0, '', $list);
- }
- /**
- * 数据列表-业主
- */
- public function datalist_proprietor()
- {
- $param = get_params();
- $where = [
- ["cp_project_report.delete_time", "=", 0],
- ["project_id", "=", $param["project_id"]],
- // ["a.status",">",7],//财评审完后才到业主
- ["a.status","<>",2]//财评拒绝后,业主端不显示
- ];
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $order = empty($param['order']) ? 'a.id desc' : $param['order'];
- $list = $this->model->where($where)
- ->field('a.*,u.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
- ->alias('a')
- ->join('file f', "a.file = f.id", "left")
- ->join('Admin u', 'a.maker_id = u.id', "left")
- ->order($order)
- ->paginate($rows, false, ['query' => $param])
- ->each(function ($item, $key) {
- });
- return table_assign(0, '', $list);
- }
- /**
- * 添加报告-公司
- */
- public function add_company()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (request()->isAjax()) {
- if (isset($param['table-align'])) {
- unset($param['table-align']);
- }
- if (isset($param['content'])) {
- $param['md_content'] = '';
- }
- if (isset($param['docContent-html-code'])) {
- $param['content'] = $param['docContent-html-code'];
- $param['md_content'] = $param['docContent-markdown-doc'];
- unset($param['docContent-html-code']);
- unset($param['docContent-markdown-doc']);
- }
- // 创建HTMLPurifier配置对象
- $config = HTMLPurifier_Config::createDefault();
- $config->set('HTML.DefinitionID', 'html5-definitions');
- $config->set('HTML.DefinitionRev', 1);
- $config->set('HTML.ForbiddenAttributes', ['width', 'height']);
- //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd');
- $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname
- if ($def = $config->maybeGetRawHTMLDefinition()) {
- $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
- 'src' => 'URI',
- 'type' => 'Text',
- 'poster' => 'URI',
- 'preload' => 'Enum#auto,metadata,none',
- 'controls' => 'Bool',
- ]);
- $def->addElement('source', 'Block', 'Flow', 'Common', [
- 'src' => 'URI',
- 'type' => 'Text',
- ]);
- }
- // 创建HTMLPurifier对象
- $purifier = new HTMLPurifier($config);
- //防止xss,过滤输入并输出结果
- //$param['content'] = '测试<script>alert(0);</script>';
- $param['content'] = $purifier->purify($param['content']);
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $param['status'] = 6;
- $param['project_id'] = $project_id;
- $param['maker_id'] = $this->uid;
- $param['admin_name'] = get_login_admin('nickname');
- try {
- $param['create_time'] = time();
- $insertId = $this->model->strict(false)->field(true)->insertGetId($param);
-
- $log = $param;
- unset($log['content']);
- add_log('add', $insertId, $log);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- $detail = Db::name("cost_project")->where("id", $project_id)->field("project_name,project_status,entrust_maker,entrust_maker_name")->find();
- $auditDataArr = [];
- $auditData = [
- "project_id" => $project_id,
- "project_name" => $detail["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "报告一审",
- "audit_type" => 4,
- "else_id" => $insertId,
- "sponsor" => get_login_admin("nickname"),
- "sponsor_id" => $this->uid,
- "sponsor_unit" => Db::name("department")->where("id", get_login_admin('unit_name'))->value("title"),
- "approver" => $param["first"],
- "approver_name" => get_admin($param["first"])["nickname"],
- "create_time" => time()
- ];
- //1项目,2报告,3公司一级审核,4公司二级审核,5公司三级审核
- if (!empty($param["first"])) {
- $auditData["audit_name"] = "报告一审";
- $auditData["audit_type"] = 4;
- $auditData["approver"] = $param["first"];
- $auditData["approver_name"] = get_admin($param["first"])["nickname"];
- $auditDataArr[] = $auditData;
- if (empty($handle['financial'])) {
- $handle['company'] = (array)$param["first"];
- } else {
- $handle['company'] = array_merge($param["first"], $handle['financial']);
- }
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
- } else {
- return to_assign(1, "请选择审批人");
- }
- if (!empty($param["second"])) {
- $auditData["audit_name"] = "报告二审";
- $auditData["audit_type"] = 5;
- $auditData["audit_status"] = 5;
- $auditData["approver"] = $param["second"];
- $auditData["approver_name"] = get_admin($param["second"])["nickname"];
- $auditDataArr[] = $auditData;
- }
- if (!empty($param["third"])) {
- $auditData["audit_name"] = "报告三审";
- $auditData["audit_type"] = 6;
- $auditData["audit_status"] = 5;
- $auditData["approver"] = $param["third"];
- $auditData["approver_name"] = get_admin($param["third"])["nickname"];
- $auditDataArr[] = $auditData;
- }
- if (!empty($param["fourth"])) {
- $auditData["audit_name"] = "报告四审";
- $auditData["audit_type"] = 14;
- $auditData["audit_status"] = 5;
- $auditData["approver"] = $param["fourth"];
- $auditData["approver_name"] = get_admin($param["fourth"])["nickname"];
- $auditDataArr[] = $auditData;
- }
- if (!empty($param["fifth"])) {
- $auditData["audit_name"] = "报告五审";
- $auditData["audit_type"] = 15;
- $auditData["audit_status"] = 5;
- $auditData["approver"] = $param["fifth"];
- $auditData["approver_name"] = get_admin($param["fifth"])["nickname"];
- $auditDataArr[] = $auditData;
- }
- // halt($auditDataArr);
- if (!empty($auditDataArr)) {
- $ProjectAudit = new ProjectAudit();
- try {
- $ProjectAudit->saveAll($auditDataArr);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- return to_assign(0, '操作成功');
- } else {
- //dump($param);=>project_id
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- //委托单位的id(财政局),评审单位id(公司),操作负责人id(作业部长),操作成员id(工人)
- $ids = Db::name('CostProject')->where("id", $project_id)->field("entrust_maker,review_head,operate_head,operate_team")->find();
- //halt($ids);
- $idarr = $ids["operate_team"] . ',' . $ids["operate_head"] . ',' . $ids["review_head"];
- $idarr = explode(",", $idarr);
- $people = Db::name("admin")->whereIn('id', $idarr)->field('id,nickname')->select();
- //dump($people);
- //富文本类型
- View::assign('editor', get_system_config('other', 'editor'));
- //关联项目id
- View::assign('project_id', $project_id);
- View::assign('people', $people);
- return view('add');
- }
- }
- /**
- * 查看信息-财政局
- */
- public function view()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = (new ProjectReport())->detail($id);
- if (empty($detail)) {
- if (empty($detail)) {
- echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
- exit;
- }
- } else {
- $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
- $detail["maker_name"] = $maker_name;
- $file_array = Db::name('ProjectReport')
- ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
- ->alias('r')
- ->join('File f', 'r.file = f.id')
- ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
- ->order('r.create_time desc')
- ->where(array('r.id' => $id))
- ->select()->toArray();
- View::assign('file_array', $file_array);
- View::assign('detail', $detail);
- return view();
- }
- }
- /**
- * 查看信息-公司
- */
- public function view_company()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = (new ProjectReport())->detail($id);
- if (empty($detail)) {
- if (empty($detail)) {
- echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
- exit;
- }
- } else {
- $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
- $detail["maker_name"] = $maker_name;
- $file_array = Db::name('ProjectReport')
- ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
- ->alias('r')
- ->join('File f', 'r.file = f.id')
- ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
- ->order('r.create_time desc')
- ->where(array('r.id' => $id))
- ->select()->toArray();
- View::assign('file_array', $file_array);
- View::assign('detail', $detail);
- return view();
- }
- }
- /**
- * 查看信息-业主
- */
- public function view_proprietor()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = (new ProjectReport())->detail($id);
- if (empty($detail)) {
- if (empty($detail)) {
- echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
- exit;
- }
- } else {
- $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
- $detail["maker_name"] = $maker_name;
- $file_array = Db::name('ProjectReport')
- ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
- ->alias('r')
- ->join('File f', 'r.file = f.id')
- ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
- ->order('r.create_time desc')
- ->where(array('r.id' => $id))
- ->select()->toArray();
- View::assign('file_array', $file_array);
- View::assign('detail', $detail);
- return view();
- }
- }
- /**
- * 删除-公司
- * 跟财评申请删除
- */
- public function delete_company()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->model->where("id", $id)->find();
- $approver = Db::name("cost_project")->where("id", $detail["project_id"])->value("entrust_maker");
- $details = Db::name("cost_project")->where("id", $detail["project_id"])->field("project_name,project_status,entrust_maker,entrust_maker_name")->find();
- $auditData = [
- "project_id" => $detail["project_id"],
- "project_name" => $details["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "财评删除报告审核",
- "audit_type" => 2,
- "else_id" => $id,
- "sponsor" => get_login_admin("nickname"),
- "sponsor_id" => $this->uid,
- "sponsor_unit" => Db::name("department")->where("id", get_login_admin('unit_name'))->value("title"),
- "approver" => $details["entrust_maker"],
- "approver_name" => $details["entrust_maker_name"],
- "remark" => $param["remark"],
- "create_time" => time()
- ];
- ProjectAudit::create($auditData);
- if (empty($handle['financial'])) {
- $handle['financial'] = (array)$details["entrust_maker"];
- } else {
- $handle['financial'] = array_merge($details["entrust_maker"], $handle['financial']);
- }
- $this->Pushmessage->pushMessage($detail["project_id"], $handle['financial'], $handle['company']);
- $this->model->where("id", $id)->update(["status" => 3]);
- add_project_log("发起删除项目报告审批", $detail["project_id"], $detail["title"]);
- return to_assign(0, "操作成功");
- }
- /**
- * 财评
- * 同意-报告
- */
- public function agree_report()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (!isset($param["type"])) {//在项目列表通过
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->model->where("id", $id)->find();//在Project_report里
- $project_id = $this->model->where("id", $id)->value("project_id");//在Project_report里
- try {
- Db::name("project_audit")->where([["else_id", "=", $id]])->where("audit_name","财评报告审核")->update(["audit_status" => 2, "audit_time" => time()]);//更新审批通过
- $this->model->where("id", $id)->update(["status" => 1]);//财评已通过
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- //给业主新增报告审核
- $where = [
- ["project_id", "=", $project_id],
- ["else_id", "=", $id],//项目报告id
- ["audit_type", "=", 2]
- ];
- $de = Db::name("costProject")->where("id", $detail["project_id"])->field("sent_review_head,sent_review_head_name")->find();
- if (isset($de)) {
- $auditData = $this->Auditmodel->where($where)->find()->toArray();
- $auditData["audit_name"] = "业主报告审核";
- $auditData["audit_status"] = 1;
- $auditData["audit_type"] = 2;
- $auditData["approver"] = $de["sent_review_head"];
- $auditData["approver_name"] = $de["sent_review_head_name"];
- $auditData["create_time"] = time();
- $auditData["audit_time"] = null;
- $auditData["remark"] = null;
- $auditData["audit_remark"] = null;
- unset($auditData["id"]);
- try {
- $this->Auditmodel->save($auditData);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- //发给公司
- $people = $this->model->where('id', $id)->value("maker_id");
- $proprietor =Db::name("costProject")->where("id", $project_id)->value("sent_review_head");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- if (empty($handle['proprietor'])) {
- $handle['proprietor'] = (array)$proprietor;
- } else {
- $handle['proprietor'] = array_merge($handle['proprietor'], (array)$proprietor);
- }
- $this->Pushmessage->pushMessage( $project_id, $handle['financial'], $handle['company'],$handle["proprietor"]);
- add_project_log('财政局审批通过', $project_id, "报告审批通过");
- } else {//在审核列表里同意
- //$param['audit_time'] = time();
- $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
- add_log('edit', $param['id'], $param);
- $id = $param['id'];
- $this->model->where("id", $id)->update(["status" => 1]);//财评已通过
- unset($param["id"]);
- $detail = ProjectReport::where("id", $param["else_id"])->find();
- $type_status = $detail["status"];
- if ($type_status == 0) {//通过
- ProjectReport::where("id", $param["else_id"])->update(["status" => 1, "update_time" => time()]);
- }
- //给业主新增报告审核
- $where = [
- ["project_id", "=", $param["project_id"]],
- ["else_id", "=", $param["else_id"]],//项目报告id
- ["audit_type", "=", 2]
- ];
- $de = Db::name("cost_project")->where("id", $param["project_id"])->field("sent_review_head,sent_review_head_name")->find();
- if (isset($de)) {
- $auditData = $this->Auditmodel->where($where)->find()->toArray();
- $auditData["audit_name"] = "业主报告审核";
- $auditData["audit_status"] = 1;
- //$auditData["audit_type"] = 2;
- $auditData["approver"] = $de["sent_review_head"];
- $auditData["approver_name"] = $de["sent_review_head_name"];
- $auditData["create_time"] = time();
- $auditData["audit_time"] = null;
- $auditData["remark"] = null;
- $auditData["audit_remark"] = null;
- unset($auditData["id"]);
- try {
- $this->Auditmodel->save($auditData);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- $proprietor =Db::name("costProject")->where("id",$detail["project_id"])->value("sent_review_head");
- if (empty($handle['proprietor'])) {
- $handle['proprietor'] = (array)$proprietor;
- } else {
- $handle['proprietor'] = array_merge($handle['proprietor'], (array)$proprietor);
- }
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'],$handle['proprietor']);
- add_project_log('财政局审批通过', $param['project_id'], "报告审批通过");
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 业主
- * 同意-报告 (已修改)
- */
- public function proprietor_agree_report()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- //$type = isset($param['type']) ? $param['type'] : 0;
- if (!isset($param["type"])) {//在审核列表通过
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->model->where("id", $id)->update(["status" => 8]);
- $detail = $this->model->where("id", $id)->find();
- //type,0初审,1对数,2审定
- $report_status = $detail["type"] + 1;
- $data = ['report_time' => time(), "report_status" => $report_status];
- try {
- Db::name("cost_project")->where("id", $detail["project_id"])->update($data);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- try {
- Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status" => 2, "audit_time" => time()]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- $people = $this->model->where('id', $id)->value("maker_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage( $detail["project_id"], $handle['financial'], $handle['company']);
- //add_project_log('业主审批通过', $detail["project_id"], "报告审批通过");
- } else {//在项目报告里通过
- $param['audit_time'] = time();
- $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
- add_log('edit', $param['id'], $param);
- $id = $param['id'];
- unset($param["id"]);
- $detail = ProjectReport::where("id", $param["else_id"])->find();
- //type,0初审,1对数,2审定
- $report_status = $detail["type"] + 1;
- $data = ['report_time' => time(), "report_status" => $report_status];
- $type_status = $detail["status"];
- if ($type_status == 1) {//财政局已通过
- ProjectReport::where("id", $param["else_id"])->update(["status" => 8, "update_time" => time()]);
- $this->CostModel->where('id', $param['project_id'])->strict(false)->update($data);
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
- add_project_log('审批通过', $param['project_id'], "报告审批通过");
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 财评(已修改)
- * 不同意-报告
- */
- public function un_report()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (!isset($param["type"])) {//审核列表拒绝
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->model->where("id", $id)->update(["status" => 2]);
- try {
- //全部的都变成已拒绝,修改为仅改变财评的状态
- Db::name("project_audit")->where([["else_id", "=", $id]])->where("audit_name","财评报告审核")->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"]]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- $people = $this->model->where('id', $id)->value("maker_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $project_id = $this->model->where("id", $id)->value("project_id");
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
- add_project_log('审批未通过', $project_id, "报告审批未通过");
- } else {//项目报告列表拒绝
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- try {
- $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
- $id = $param['id'];
- unset($param["id"]);
- $type_status = Db::name("project_report")->where("id", $param["else_id"])->value("status");
- if ($type_status == 0) {
- //新建
- Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 2, "update_time" => time()]);
- } elseif ($type_status == 3) {
- //删除
- Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 5, "update_time" => time()]);
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
- add_project_log('审批未通过', $param['project_id'], "报告审批未通过");
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 业主 (已修改)
- * 不同意-报告
- */
- public function proprietor_un_report()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (!isset($param["type"])) {//项目报告列表
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->model->where("id", $id)->update(["status" => 9]);
- try {
- //一开始将所有的都改成了拒绝,改成了只改变业主的审批状态
- Db::name("project_audit")->where([["else_id", "=", $id]])->where("audit_name","业主报告审核")->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"],"audit_time" => time()]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- $people = $this->model->where('id', $id)->value("maker_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $project_id = $this->model->where("id", $id)->value("project_id");
- $this->Pushmessage->pushMessage($project_id, [], $handle['company']);
- //add_project_log('审批未通过', $project_id, "报告审批未通过");
- } else {//项目报告列表
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- try {
- //$param['audit_time'] = time();
- $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
- $id = $param['id'];
- unset($param["id"]);
- $type_status = Db::name("project_report")->where("id", $param["else_id"])->value("status");
- if ($type_status == 1) {
- //新建
- Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 9, "update_time" => time()]);
- } elseif ($type_status == 4) {
- //删除
- Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 11, "update_time" => time()]);
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], [], $handle['company']);
- //add_project_log('审批未通过', $param['project_id'], "报告审批未通过");
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 财评(已修改)
- * 同意-删除
- */
- public function agree_delete()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (!isset($param["type"])) {//在
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->model->where("id", $id)->update(["status" => 4]);
- $detail = $this->model->where("id", $id)->find();
- $project_id = $this->model->where("id", $id)->value("project_id");//在Project_report里
- Db::name("project_audit")->where([["else_id", "=", $id]])->where("audit_name","财评删除报告审核")->update(["audit_status" => 2]);
- //给业主新增报告删除审核
- $where = [
- ["project_id", "=",$project_id],
- ["else_id", "=", $id],//项目报告id
- ["audit_type", "=", 2],
- ["audit_name","=","财评删除报告审核"]
- ];
- $de = Db::name("cost_project")->where("id", $project_id)->field("sent_review_head,sent_review_head_name")->find();
- if (isset($de)) {
- $auditData = $this->Auditmodel->where($where)->find()->toArray();//
- $auditData["audit_name"] = "业主删除报告审核";
- $auditData["audit_status"] = 1;
- $auditData["approver"] = $de["sent_review_head"];
- $auditData["approver_name"] = $de["sent_review_head_name"];
- $auditData["create_time"] = time();
- $auditData["audit_time"] = null;
- //$auditData["remark"] = null;
- $auditData["audit_remark"] = null;
- unset($auditData["id"]);
- try {
- $this->Auditmodel->save($auditData);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- $people = $this->model->where('id', $id)->value("maker_id");
- $proprietor =Db::name("costProject")->where("id",$project_id)->value("sent_review_head");
- if (empty($handle['proprietor'])) {
- $handle['proprietor'] = (array)$proprietor;
- } else {
- $handle['proprietor'] = array_merge($handle['proprietor'], (array)$proprietor);
- }
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company'],$handle["proprietor"]);
- add_project_log('审批通过', $project_id, "报告删除审批通过");
- } else {//审核项目里
- $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
- $id = $param['id'];
- unset($param["id"]);
- //$param{else_id是项目报告id
- $detail = ProjectReport::where("id", $param["else_id"])->find();
- $type_status = $detail["status"];
- if ($type_status == 3) {
- ProjectReport::where("id", $param["else_id"])->update(["status" => 4, "update_time" => time()]);
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- $proprietor =Db::name("costProject")->where("id",$detail["project_id"])->value("sent_review_head");
- if (empty($handle['proprietor'])) {
- $handle['proprietor'] = (array)$proprietor;
- } else {
- $handle['proprietor'] = array_merge($handle['proprietor'], (array)$proprietor);
- }
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company'],$handle["proprietor"]);
- add_project_log('审批通过', $param['project_id'], "报告删除审批通过");
- //给业主新增报告删除审核
- $where = [
- ["project_id", "=", $param["project_id"]],
- ["else_id", "=", $param["else_id"]],//项目报告id
- ["audit_type", "=", 2],
- ["audit_name","=","财评删除报告审核"]
- ];
- $de = Db::name("cost_project")->where("id", $param["project_id"])->field("sent_review_head,sent_review_head_name")->find();
- if (isset($de)) {
- $auditData = $this->Auditmodel->where($where)->find()->toArray();
- $auditData["audit_name"] = "业主删除报告审核";
- $auditData["audit_status"] = 1;
- $auditData["approver"] = $de["sent_review_head"];
- $auditData["approver_name"] = $de["sent_review_head_name"];
- $auditData["create_time"] = time();
- $auditData["audit_time"] = null;
- //$auditData["remark"] = null;
- $auditData["audit_remark"] = null;
- unset($auditData["id"]);
- try {
- $this->Auditmodel->save($auditData);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 业主 (已修改)
- * 同意-删除
- */
- public function proprietor_agree_delete()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (!isset($param["type"])) {
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->model->where("id", $id)->update(["status" => 10]);
- $detail = $this->model->where("id", $id)->find();
- try {
- Db::name("cost_project")->where("id", $detail["project_id"])->update(['report_time' => time()]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- try {
- Db::name("project_audit")->where([["else_id", "=", $id]])->where("audit_name","业主删除报告审核")->update(["audit_status" => 2]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- $people = $this->model->where('id', $id)->value("maker_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $project_id = $this->model->where("id", $id)->value("project_id");
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
- add_project_log('业主审批通过', $project_id, "报告删除审批通过");
- } else {//在项目报告里
- $this->Auditmodel->where('id', $param['id'])->strict(false)->field(true)->update(["audit_status" => 2, "audit_time" => time()]);
- $id = $param['id'];
- unset($param["id"]);
- $detail = ProjectReport::where("id", $param["else_id"])->find();
- $type_status = $detail["status"];
- if ($type_status == 4) {
- ProjectReport::where("id", $param["else_id"])->update(["status" => 10, "update_time" => time()]);
- Db::name("cost_project")->where("id", $detail["project_id"])->update(['report_time' => time()]);
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
- add_project_log('业主审批通过', $param['project_id'], "报告删除审批通过");
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 财评(已修改)
- * 不同意-删除
- */
- public function un_delete()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (!isset($param["type"])) {
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->model->where("id", $id)->update(["status" => 5]);
- try {
- Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- $people = $this->model->where('id', $id)->value("maker_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $project_id = $this->model->where("id", $id)->value("project_id");
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
- add_project_log('财政局审批未通过', $project_id, "报告删除审批未通过");
- } else {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- try {
- $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
- $id = $param['id'];
- unset($param["id"]);
- $type_status = Db::name("project_report")->where("id", $param["else_id"])->value("status");
- if ($type_status == 3) {
- //删除
- Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 5, "update_time" => time()]);
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
- add_project_log('财政局审批未通过', $param['project_id'], "报告删除审批未通过");
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 业主 (已修改)
- * 不同意-删除
- */
- public function proprietor_un_delete()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if (!isset($param["type"])) {
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->model->where("id", $id)->update(["status" => 11]);
- try {
- Db::name("project_audit")->where([["else_id", "=", $id]])->where("audit_name","业主删除报告审核")->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- $people = $this->model->where('id', $id)->value("maker_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $project_id = $this->model->where("id", $id)->value("project_id");
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
- add_project_log('业主审批未通过', $project_id, "报告删除审批未通过");
- } else {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- try {
- $this->Auditmodel->where('id', $param["id"])->strict(false)->field(true)->update(["audit_status" => 3, "audit_remark" => $param["audit_remark"], "audit_time" => time()]);
- $id = $param['id'];
- unset($param["id"]);
- $type_status = Db::name("project_report")->where("id", $param["else_id"])->value("status");
- if ($type_status == 4) {
- //删除
- Db::name("project_report")->where("id", $param["else_id"])->update(["status" => 11, "update_time" => time()]);
- }
- $people = $this->Auditmodel->where('id', $id)->value("sponsor_id");
- if (empty($handle['company'])) {
- $handle['company'] = (array)$people;
- } else {
- $handle['company'] = array_merge($handle['company'], (array)$people);
- }
- $this->Pushmessage->pushMessage($param['project_id'], $handle['financial'], $handle['company']);
- add_project_log('业主审批未通过', $param['project_id'], "报告删除审批未通过");
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
- return to_assign(0, "操作成功");
- }
- /**
- * 报告附件上传
- */
- public function add_file_company()
- {
- $param = get_params();
- // $param['create_time'] = time();
- $param['maker_id'] = $this->uid;
- $file_array = Db::name('file')
- ->field("f.id,f.name,f.filesize,f.filepath,f.fileext,f.admin_id,f.create_time,a.nickname as admin_name")
- ->alias("f")
- // ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
- ->join('Admin a', 'f.admin_id = a.id', 'LEFT')
- ->order('f.create_time desc')
- ->where(array('f.id' => $param["file"]))
- ->select()->toArray();
- // ->find();
- View::assign("file_array", $file_array);
- return json($file_array);
- }
- /**
- * 查看审批进度
- */
- public function progress()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $list = $this->Auditmodel->alias('a')->join("cost_project c", "a.project_id=c.id", 'left')
- ->field("a.*,c.project_status,c.sent_review_amount,c.engineering_type,c.review_unit_name")->where('else_id', $id)->order('create_time', "sec")
- ->select()
- ->each(function ($item) {
- switch ($item["audit_type"]) {
- case 4:
- $item->else_name = "报告一级审核";
- break;
- case 5:
- $item->else_name = "报告二级审核";
- break;
- case 6:
- $item->else_name = "报告三级审核";
- break;
- }
- });
- View::assign('list', $list);
- return view();
- }
- }
|