123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812 |
- <?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]
- ];
- $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"]]
- ];
- $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 {
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $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();
- //富文本类型
- 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'];
- $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" => 1]);
- $detail = $this->model->where("id", $id)->find();
- $num = $this->model->where([
- ["project_id", "=", $detail["project_id"],
- ["type", ">", $detail["type"]]],
- ["status", ">", 1],
- ["status", "<>", 2],
- ["status", "<", 4]
- ])->count();
- //type,0初审,1对数,2审定
- $report_status = $detail["type"] + 1;
- if ($num == 0) {
- $data = ['report_time' => time(), "report_status" => $report_status];
- } else {
- $data = ['report_time' => time()];
- }
- 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']);
- } 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();
- $num = $this->model->where([
- ["project_id", "=", $detail["project_id"],
- ["type", ">", $detail["type"]]],
- ["status", ">", 1],
- ["status", "<>", 2],
- ["status", "<", 4]
- ])->count();
- //type,0初审,1对数,2审定
- $report_status = $detail["type"] + 1;
- if ($num == 0) {
- $data = ['report_time' => time(), "report_status" => $report_status];
- } else {
- $data = ['report_time' => time()];
- }
- $type_status = $detail["status"];
- if ($type_status == 0) {
- ProjectReport::where("id", $param["else_id"])->update(["status" => 1, "update_time" => time()]);
- $this->CostModel->where('id', $param['project_id'])->strict(false)->update($data);
- } elseif ($type_status == 3) {
- ProjectReport::where("id", $param["else_id"])->update(["status" => 4, "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'], "报告审批通过");
- }
- 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]])->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']);
- } 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("contact")->where("id", $param["else_id"])->value("status");
- if ($type_status == 0) {
- //新建
- Db::name("contact")->where("id", $param["else_id"])->update(["status" => 2, "update_time" => time()]);
- } elseif ($type_status == 3) {
- //删除
- Db::name("contact")->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']);
- } 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();
- //type,0初审,1对数,2审定
- $num = $this->model->where([
- ["project_id", "=", $detail["project_id"],
- ["type", ">=", $detail["type"]]],
- ["status", ">", 1],
- ["status", "<>", 2],
- ["status", "<", 4]
- ])->count();
- //type,0初审,1对数,2审定
- $report_status = $detail["type"];
- if ($num == 0) {
- $data = ['report_time' => time(), "report_status" => $report_status];
- } else {
- $data = ['report_time' => time()];
- }
- 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]);
- } 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']);
- } else {
- $param['audit_time'] = time();
- $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();
- $num = $this->model->where([
- ["project_id", "=", $detail["project_id"],
- ["type", ">=", $detail["type"]]],
- ["status", ">", 1],
- ["status", "<>", 2],
- ["status", "<", 4]
- ])->count();
- //type,0初审,1对数,2审定
- $report_status = $detail["type"];
- if ($num == 0) {
- $data = ['report_time' => time(), "report_status" => $report_status];
- } else {
- $data = ['report_time' => time()];
- }
- $type_status = $detail["status"];
- if ($type_status == 0) {
- ProjectReport::where("id", $param["else_id"])->update(["status" => 1, "update_time" => time()]);
- $this->CostModel->where('id', $param['project_id'])->strict(false)->update($data);
- } elseif ($type_status == 3) {
- ProjectReport::where("id", $param["else_id"])->update(["status" => 4, "update_time" => time()]);
- Db::name("cost_project")->where("id", $detail["project_id"])->update(["report_status" => $report_status]);
- }
- $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"]]);
- } 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']);
- } 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("contact")->where("id", $param["else_id"])->value("status");
- if ($type_status == 0) {
- //新建
- Db::name("contact")->where("id", $param["else_id"])->update(["status" => 2, "update_time" => time()]);
- } elseif ($type_status == 3) {
- //删除
- Db::name("contact")->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']);
- } 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();
- }
- }
|