1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063 |
- <?php
- // 联系函
- namespace app\admin\controller\project;
- use app\admin\BaseController;
- use app\admin\controller\Pushmessage;
- use app\admin\model\Admin;
- use app\admin\model\ProjectAudit;
- use app\admin\model\ProjectAudit as AuditModel;
- use app\admin\model\ProjectMsg;
- 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\Session;
- use think\facade\View;
- use think\App;
- use app\admin\model\Contact as ContactModel;
- class Contact extends BaseController
- {
- /**
- * 构造函数
- */
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->uid = get_login_admin('id');
- $this->Adminmodel = new Admin();
- $this->ProjectMsg = new ProjectMsg();
- $this->ContactModel = new ContactModel();
- $this->Officialaccount = new Officialaccount();
- $this->Pushmessage = new Pushmessage();
- $this->Auditmodel = new AuditModel();
- }
- public function conList()
- {
- $param = get_params();
- // halt($param);
- // $param = [
- // 'project_id' => 290,
- // ];
- $where = [
- ['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->ContactModel->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) {
- })->toArray();
- // halt($list);
- // dump($list);
- return table_assign(0, '', $list);
- }
- public function conList_company()
- {
- $param = get_params();
- // halt($param);
- // $param = [
- // 'project_id' => 290,
- // ];
- $where = [
- ['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->ContactModel->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) {
- })->toArray();
- // halt($list);
- // dump($list);
- return table_assign(0, '', $list);
- }
- public function conList_proprietor()
- {
- $param = get_params();
- // halt($param);
- // $param = [
- // 'project_id' => 290,
- // ];
- $where = [
- ['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->ContactModel->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) {
- })->toArray();
- // halt($list);
- // dump($list);
- return table_assign(0, '', $list);
- }
- /**
- * 添加-财政局
- */
- public function add()
- {
- $param = get_params();
- 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['project_id'] = $project_id;
- $param['maker_id'] = $this->uid;
- $param['admin_name'] = get_login_admin('nickname');
- $param['status'] = 8;
- $content = $param["title"];
- add_project_log("新增联系函", $project_id, $content);
- try {
- $param['create_time'] = time();
- $insertId = $this->ContactModel->strict(false)->field(true)->insertGetId($param);
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- return to_assign(0, '操作成功');
- } else {
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- //富文本类型
- View::assign('editor', get_system_config('other', 'editor'));
- //关联项目id
- View::assign('project_id', $project_id);
- return view();
- }
- }
- /**
- * 添加-公司
- */
- public function add_company()
- {
- $param = get_params();
- 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['project_id'] = $project_id;
- $param['maker_id'] = $this->uid;
- $param['admin_name'] = get_login_admin('nickname');
- try {
- $param['create_time'] = time();
- $insertId = $this->ContactModel->strict(false)->field(true)->insertGetId($param);
- } 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 = [];
- //1项目,2报告,3公司一级审核,4公司二级审核,5公司三级审核
- if (!empty($param["first"])) {
- $auditData = [
- "project_id" => $project_id,
- "project_name" => $detail["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "联系函一审",
- "audit_type" => 7,
- "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()
- ];
- $auditDataArr[] = $auditData;
- } else {
- return to_assign(1, "请选择审批人");
- }
- if (!empty($param["second"])) {
- $auditData = [
- "project_id" => $project_id,
- "project_name" => $detail["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "联系函二审",
- "audit_type" => 8,
- "audit_status" => 5,
- "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["second"],
- "approver_name" => get_admin($param["second"])["nickname"],
- "create_time" => time()
- ];
- $auditDataArr[] = $auditData;
- }
- if (!empty($param["third"])) {
- $auditData = [
- "project_id" => $project_id,
- "project_name" => $detail["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "联系函三审",
- "audit_type" => 9,
- "audit_status" => 5,
- "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["third"],
- "approver_name" => get_admin($param["third"])["nickname"],
- "create_time" => time()
- ];
- $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;
- //富文本类型
- View::assign('editor', get_system_config('other', 'editor'));
- //关联项目id
- View::assign('project_id', $project_id);
- $ids = Db::name('CostProject')->where("id", $project_id)->field("entrust_maker,review_head,operate_head,operate_team")->find();
- $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('people', $people);
- return view();
- }
- }
- /**
- * 添加-业主
- */
- public function add_proprietor()
- {
- $param = get_params();
- 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['project_id'] = $project_id;
- $param['maker_id'] = $this->uid;
- $param['admin_name'] = get_login_admin('nickname');
- try {
- $param['create_time'] = time();
- $insertId = $this->ContactModel->strict(false)->field(true)->insertGetId($param);
- } 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 = [];
- //1项目,2报告,3公司一级审核,4公司二级审核,5公司三级审核
- if (!empty($param["first"])) {
- $auditData = [
- "project_id" => $project_id,
- "project_name" => $detail["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "联系函一审",
- "audit_type" => 7,
- "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()
- ];
- $auditDataArr[] = $auditData;
- } else {
- return to_assign(1, "请选择审批人");
- }
- if (!empty($param["second"])) {
- $auditData = [
- "project_id" => $project_id,
- "project_name" => $detail["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "联系函二审",
- "audit_type" => 8,
- "audit_status" => 5,
- "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["second"],
- "approver_name" => get_admin($param["second"])["nickname"],
- "create_time" => time()
- ];
- $auditDataArr[] = $auditData;
- }
- if (!empty($param["third"])) {
- $auditData = [
- "project_id" => $project_id,
- "project_name" => $detail["project_name"],
- "project_type" => "造价项目",
- "audit_name" => "联系函三审",
- "audit_type" => 9,
- "audit_status" => 5,
- "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["third"],
- "approver_name" => get_admin($param["third"])["nickname"],
- "create_time" => time()
- ];
- $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;
- //富文本类型
- View::assign('editor', get_system_config('other', 'editor'));
- //关联项目id
- View::assign('project_id', $project_id);
- $ids = Db::name('CostProject')->where("id", $project_id)->field("entrust_maker,review_head,operate_head,operate_team")->find();
- $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('people', $people);
- return view();
- }
- }
- /**
- *
- * 编辑-公司
- */
- public function edit_company()
- {
- $param = get_params();
- if (request()->isAjax()) {
- // halt($param);
- 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']);
- $contact_id = isset($param['id']) ? $param['id'] : 0;
- $param['project_id'] = Db::name('Contact')->where('id', $contact_id)->value('project_id');
- $param['maker_id'] = $this->uid;
- $param['audit_status'] = 0;
- $content = $param["title"];
- add_project_log("编辑联系函", $param['project_id'], $content);
- // $this->ContactModel->addContact($param);
- $this->ContactModel->where('id', $contact_id)->save($param);
- return to_assign(0, '修改成功');
- } else {
- $contact_id = isset($param['id']) ? $param['id'] : 0;
- $detail = Db::name('Contact')->where('id', $contact_id)->find();
- $file_array = Db::name('Contact')
- ->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' => $contact_id))
- ->select()->toArray();
- View::assign('file_array', $file_array);
- //富文本类型
- View::assign('editor', get_system_config('other', 'editor'));
- View::assign('detail', $detail);
- // dump($detail);
- //关联项目id
- // View::assign('project_id', $project_id);
- return view('edit');
- }
- }
- /**
- * 查看信息-财政局
- */
- public function view()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->ContactModel->detail($id);
- // dump($param);
- // dump($detail);
- 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('Contact')
- ->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);
- View::assign('user', get_login_admin('user_type'));
- // dump($detail);
- return view();
- }
- }
- /**
- * 查看信息-公司
- */
- public function view_company()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->ContactModel->detail($id);
- // dump($param);
- // dump($detail);
- 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('Contact')
- ->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);
- View::assign('user', get_login_admin('user_type'));
- // dump($detail);
- return view('view');
- }
- }
- /**
- * 查看信息-业主
- */
- public function view_proprietor()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->ContactModel->detail($id);
- // dump($param);
- // dump($detail);
- 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('Contact')
- ->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);
- View::assign('user', get_login_admin('user_type'));
- // dump($detail);
- return view('view');
- }
- }
- public function add_file()
- {
- $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 delete_file()
- {
- if (request()->isDelete()) {
- if (true) {
- return to_assign(0, "删除成功");
- }
- } else {
- return to_assign(1, "错误的请求");
- }
- }
- /**
- * 删除-公司
- * 跟财评申请删除
- */
- public function delete_company()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->ContactModel->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" => 3,
- "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($handle['company'], (array)$details["entrust_maker"]);
- }
- $this->Pushmessage->pushMessage($detail['project_id'], $handle['financial'], $handle['company']);
- $this->ContactModel->where("id", $id)->update(["status" => 3]);
- add_project_log("发起删除项目联系函审批", $detail["project_id"], $detail["title"]);
- return to_assign(0, "操作成功");
- }
- /**
- * 删除-业主
- * 跟财评申请删除
- */
- public function delete_proprietor()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- $id = isset($param['id']) ? $param['id'] : 0;
- $detail = $this->ContactModel->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" => 3,
- "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($handle['company'], (array)$details["entrust_maker"]);
- }
- $this->Pushmessage->pushMessage($detail['project_id'], $handle['financial'], $handle['company']);
- $this->ContactModel->where("id", $id)->update(["status" => 3]);
- add_project_log("发起删除项目联系函审批", $detail["project_id"], $detail["title"]);
- return to_assign(0, "操作成功");
- }
- /**
- * 财评
- * 同意-联系函
- */
- public function agree_contact()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if(!isset($param["type"])){
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->ContactModel->where("id", $id)->update(["status" => 1]);
- try {
- Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status"=>2]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:'.$e->getMessage());
- }
- $people = $this->ContactModel->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->ContactModel->where("id", $id)->value("project_id");
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
- 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()]);
- $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" => 1, "update_time" => time()]);
- } elseif ($type_status == 3) {
- Db::name("contact")->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_contact()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if(!isset($param["type"])){
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->ContactModel->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->ContactModel->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->ContactModel->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 {
- $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']);
- 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->ContactModel->where("id", $id)->update(["status" => 4]);
- try {
- Db::name("project_audit")->where([["else_id", "=", $id]])->update(["audit_status"=> 2]);
- } catch (DbException $e) {
- return to_assign(1, '操作失败,原因:'.$e->getMessage());
- }
- $people = $this->ContactModel->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->ContactModel->where("id", $id)->value("project_id");
- $this->Pushmessage->pushMessage($project_id, $handle['financial'], $handle['company']);
- 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'];
- 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" => 1, "update_time" => time()]);
- } elseif ($type_status == 3) {
- Db::name("contact")->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_delete()
- {
- $param = get_params();
- $handle = $this->Pushmessage->handleParam($param);
- $param = $handle['param'];
- if(!isset($param["type"])){
- $id = isset($param['id']) ? $param['id'] : 0;
- $this->ContactModel->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->ContactModel->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->ContactModel->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 {
- $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']);
- add_project_log('审批通过', $param['project_id'], "联系函删除审批拒绝");
- } catch (\Exception $e) {
- return to_assign(1, '操作失败,原因:' . $e->getMessage());
- }
- }
-
- return to_assign(0, "操作成功");
- }
- }
|