12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519 |
- <?php
- /**
- * @copyright Copyright (c) 2021 勾股工作室
- * @license https://opensource.org/licenses/Apache-2.0
- * @link https://www.gougucms.com
- */
- declare (strict_types=1);
- namespace app\mobile\controller;
- use app\admin\BaseController;
- use app\admin\controller\field\Field;
- use app\admin\model\Admin;
- use app\admin\model\Admin as AdminList;
- use app\admin\model\Contact;
- use app\admin\model\Contact as ContactModel;
- use app\admin\model\CostProject as CostProjectModel;
- use app\admin\model\ProjectAudit as AuditModel;
- use app\admin\model\ProjectRecord;
- use think\App;
- use think\facade\Db;
- use think\facade\Request;
- use think\facade\Session;
- use think\facade\View;
- use app\admin\model\Appropriation as AppropriationModel;
- use app\admin\controller\datastat\Datastat;
- class Index
- {
- /**
- * 构造函数
- */
- public function __construct(App $app)
- {
- $this->Datastat = new Datastat($app);
- $this->AppropriationModel = new AppropriationModel();
- $this->Field = new Field($app);
- $this->model = new CostProjectModel();
- $this->Adminmodel = new Admin();
- $this->Auditmodel = new AuditModel();
- $this->ContactModel = new ContactModel();
- $this->uid = get_login_admin('id');
- $this->unit = get_login_admin('unit_name');
- $this->user_tpe = Db::name("department")->where("id", $this->unit)->value("type");
- // $session_admin = get_config('app.session_admin');
- // $request = Request::instance();
- // if (!Session::has($session_admin) && $request->url() !== '/mobile/index/login.html') {
- // redirect('/mobile/index/login.html')->send();
- // exit;
- // }
- }
- /**
- * 财评首页
- * 通用
- */
- public function main()
- {
- // halt(session::get('gougu_admin'));
- if (session::get(get_config('app.session_admin')) == NULL) {
- $param = get_params();
- if ($param == NULL) {
- redirect('/mobile/index/login.html')->send();
- } else { // 微信登录 但session为空
- $session_admin = get_config('app.session_admin');
- $admin = Db::name('Admin')->where('id', $param['admin'])->find();
- Session::set($session_admin, $admin); // null
- $token = make_token();
- set_cache($token, $admin, 7200);
- $admin['token'] = $token;
- $this->uid = $param['admin'];
- $this->unit = Db::name('Admin')->where('id', $this->uid)->value('unit_name');
- }
- }
- //0->财政局,1->业主,2->公司
- if ($this->user_tpe == 0) {
- $sent_review_amount = Db::name("cost_project")->where([
- ["entrust_unit", "=", get_login_admin("unit_name")],
- ['delete_time', '=', 0],
- ["project_status", ">", 2],
- ["project_status", "<>", 9],
- ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select();
- } else if ($this->user_tpe == 2) {
- $sent_review_amount = Db::name("cost_project")->where([
- ["review_unit", "=", $this->unit],
- ['delete_time', '=', 0],
- ["project_status", ">", 3]
- ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select();
- } else if ($this->user_tpe == 1) {
- $sent_review_amount = Db::name("cost_project")->where([
- ["sent_review_unit", "=", $this->unit],
- ['delete_time', '=', 0],
- ["project_status", ">", 2]
- ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select();
- }
- //engineering_type1=1是预算,2是结算
- $amount = [
- //送审总额
- 'sent_review_amount' => 0,
- //评审服务费
- 'sent_review_cost' => 0,
- //审定总额
- 'authorize_amount' => 0,
- //总审减率
- 'review_add_reduce_rate' => 0
- ];
- $sent_review_amount_tol = [
- "sent_review_amount_type1" => 0,
- "sent_review_amount_type2" => 0,
- "authorize_amount_type1" => 0,
- "authorize_amount_type2" => 0,
- "review_add_reduce_rate_type1" => 0,
- "review_add_reduce_rate_type2" => 0
- ];
- for ($i = 0; $i < count($sent_review_amount); $i++) {
- $a = $sent_review_amount[$i];
- if ($a['engineering_type1'] == 1) {
- if ((int)$a["sent_review_amount"]) {
- //预算总额
- $sent_review_amount_tol["sent_review_amount_type1"] += $a["sent_review_amount"];
- }
- if ((int)$a["authorize_amount"]) {
- //审定
- $sent_review_amount_tol["authorize_amount_type1"] += $a["authorize_amount"];
- }
- } elseif ($a['engineering_type1'] == 2) {
- if ((int)$a["sent_review_amount"]) {
- //结算总额
- $sent_review_amount_tol["sent_review_amount_type2"] += $a["sent_review_amount"];
- }
- if ((int)$a["authorize_amount"]) {
- //审定
- $sent_review_amount_tol["authorize_amount_type2"] += $a["authorize_amount"];
- }
- }
- }
- //什么率的
- $sentReviewAmount = 0;
- $authorizeAmount = 0;
- $sent_review_amount_type1 = 0;
- $authorize_amount_type1 = 0;
- $sent_review_amount_type2 = 0;
- $authorize_amount_type2 = 0;
- for ($i = 0; $i < count($sent_review_amount); $i++) {
- $a = $sent_review_amount[$i];
- if ($a['engineering_type1'] == 1 && (int)$a["authorize_amount"]) {
- if ((int)$a["sent_review_amount"]) {
- //预算总额
- $sent_review_amount_type1 += $a["sent_review_amount"];
- //审定
- $authorize_amount_type1 += $a["authorize_amount"];
- }
- } elseif ($a['engineering_type1'] == 2) {
- if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
- //结算总额
- $sent_review_amount_type2 += $a["sent_review_amount"];
- //审定
- $authorize_amount_type2 += $a["authorize_amount"];
- }
- }
- if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
- //结算总额
- $sentReviewAmount += $a["sent_review_amount"];
- //审定
- $authorizeAmount += $a["authorize_amount"];
- }
- }
- if ((int)$sent_review_amount_type1 && (int)$authorize_amount_type1) {
- //预算核增减率
- $sent_review_amount_tol["review_add_reduce_rate_type1"] = sprintf("%.4f", ($authorize_amount_type1 - $sent_review_amount_type1) / $sent_review_amount_type1) * 100;
- }
- if ($sent_review_amount_type2 && $authorize_amount_type2) {
- //结算核增减率
- $sent_review_amount_tol["review_add_reduce_rate_type2"] = sprintf("%.4f", ($authorize_amount_type2 - $sent_review_amount_type2) / $sent_review_amount_type2) * 100;
- }
- if ((int)$sentReviewAmount && (int)$authorizeAmount) {
- $amount['review_add_reduce_rate'] = (sprintf("%.4f", ($authorizeAmount - $sentReviewAmount) / $sentReviewAmount)) * 100;
- }
- for ($i = 0; $i < count($sent_review_amount); $i++) {
- $a = $sent_review_amount[$i];
- if ((int)$a['sent_review_amount']) {
- $amount["sent_review_amount"] += $a['sent_review_amount'];
- }
- if ((int)$a['sent_review_cost']) {
- $amount["sent_review_cost"] += $a['sent_review_cost'];
- }
- if ((int)$a['authorize_amount']) {
- $amount["authorize_amount"] += $a['authorize_amount'];
- }
- }
- //评审服务费,上半年服务费用,下半年服务费用 start
- $currentTime = time();
- $year = date('Y', $currentTime);
- // 计算上半年时间范围
- $firstHalfStart = strtotime($year . '-01-01');
- $firstHalfEnd = strtotime($year . '-06-30 23:59:59');
- // 计算下半年时间范围
- $secondHalfStart = strtotime($year . '-07-01');
- $secondHalfEnd = strtotime($year . '-12-31 23:59:59');
- if ($this->user_tpe == 0) {
- $first_sent_review_cost = Db::name("cost_project")->where([
- ['delete_time', '=', 0],
- ["project_status", ">", 2],
- ["project_status", "<>", 9],
- ["entrust_unit", "=", get_login_admin("unit_name")]
- ])->whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select();
- if (!$first_sent_review_cost->isEmpty()) {
- $first_sent_review_cost->toArray();
- } else {
- $first_sent_review_cost = [];
- }
- $second_sent_review_cost = Db::name("cost_project")->where([
- ['delete_time', '=', 0],
- ["project_status", ">", 2],
- ["project_status", "<>", 9],
- ["entrust_unit", "=", get_login_admin("unit_name")]
- ])->whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select();
- if (!$second_sent_review_cost->isEmpty()) {
- $second_sent_review_cost->toArray();
- } else {
- $second_sent_review_cost = [];
- }
- } else if ($this->user_tpe == 2) {
- $first_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 3],
- ["review_unit", "=", get_login_admin("unit_name")],
- ["project_status", "<>", 7],
- ["project_status", "<>", 9]
- ])->
- whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select();
- if (!$first_sent_review_cost->isEmpty()) {
- $first_sent_review_cost->toArray();
- } else {
- $first_sent_review_cost = [];
- }
- $second_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 3],
- ["review_unit", "=", get_login_admin("unit_name")],
- ["project_status", "<>", 7],
- ["project_status", "<>", 9]
- ])->
- whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select();
- if (!$second_sent_review_cost->isEmpty()) {
- $second_sent_review_cost->toArray();
- } else {
- $second_sent_review_cost = [];
- }
- } else if ($this->user_tpe == 1) {
- $first_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 2], ["sent_review_unit", "=", $this->unit]
- ])->
- whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select();
- if (!$first_sent_review_cost->isEmpty()) {
- $first_sent_review_cost->toArray();
- } else {
- $first_sent_review_cost = [];
- }
- $second_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 2], ["sent_review_unit", "=", $this->unit]
- ])->
- whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select();
- if (!$second_sent_review_cost->isEmpty()) {
- $second_sent_review_cost->toArray();
- } else {
- $second_sent_review_cost = [];
- }
- }
- $sent_review_cost = [
- 'first_sent_review_cost' => 0,
- 'second_sent_review_cost' => 0
- ];
- for ($i = 0; $i < count($first_sent_review_cost); $i++) {
- $a = $first_sent_review_cost[$i];
- $sent_review_cost["first_sent_review_cost"] += $a['sent_review_cost'];
- }
- for ($i = 0; $i < count($second_sent_review_cost); $i++) {
- $a = $second_sent_review_cost[$i];
- $sent_review_cost["second_sent_review_cost"] += $a['sent_review_cost'];
- }
- //评审服务费,上半年服务费用,下半年服务费用 end
- //项目数量,正在作业,已归档
- $num = Db::name("cost_project")->where([
- ["entrust_unit", "=", $this->unit],
- ['delete_time', '=', 0],
- ["project_status", '>', 2],
- ])->count();
- if ($this->user_tpe == 0) {
- $where = [
- ["entrust_unit", "=", $this->unit],
- ['delete_time', '=', 0],
- ["project_status", '>', 2],
- ];
- } else if ($this->user_tpe == 2) {
- $where = [
- ["review_unit", "=", $this->unit],
- ['delete_time', '=', 0],
- ["project_status", '>', 2],
- ];
- } else if ($this->user_tpe == 1) {
- $where = [
- ["sent_review_unit", "=", $this->unit],
- ['delete_time', '=', 0],
- ["project_status", '>', 2],
- ];
- }
- $data = Db::name("cost_project")->where($where)->select();
- // halt($data);
- $num_project = [
- 'num' => 0,
- "yu" => 0,
- "jie" => 0,
- "zuo" => 0,
- "gui" => 0,
- "tui" => 0,
- ];
- foreach ($data as $key => $value) {
- $num_project["num"] += 1;
- if ($value["project_status"] < 6 && $value["project_status"] > 3) {
- $num_project["zuo"] += 1;
- }
- if ($value["project_status"] < 8 && $value["project_status"] > 3) {
- if ($value["engineering_type1"] == 1) {
- $num_project["yu"] += 1;
- }
- if ($value["engineering_type1"] == 2) {
- $num_project["jie"] += 1;
- }
- }
- if ($value["project_status"] == 8) {
- $num_project["gui"] += 1;
- }
- if ($value["project_status"] == 9) {
- $num_project["tui"] += 1;
- }
- }
- $sent_review_cost_real = [];
- foreach ($sent_review_cost as $item => $value) {
- $sent_review_cost_real[$item] = number_format($value / 10000, 2, ".", "");
- }
- $sent_review_amount_tol_real = [];
- foreach ($sent_review_amount_tol as $item => $value) {
- if (!($item == "review_add_reduce_rate_type1" || $item == "review_add_reduce_rate_type2")) {
- $sent_review_amount_tol_real[$item] = number_format($value / 10000, 2, ".", "");
- } else {
- $sent_review_amount_tol_real[$item] = number_format($value, 2, ".", "");
- }
- }
- $amount_real = [];
- foreach ($amount as $item => $value) {
- if ($item == "review_add_reduce_rate") {
- $amount_real[$item] = number_format($value, 2, ".", "");
- } else {
- $amount_real[$item] = number_format($value / 10000, 2, ".", "");
- }
- }
- $red = $this->Auditmodel->where("approver", $this->uid)->where("audit_status", 1)->count();
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- $unread_id = Db::name("admin")->where("id", $this->uid)->value("unread");
- if (empty($unread_id)) {
- $unread_id = 0;
- } else {
- $unread_id = 1;
- }
- View::assign("red_kan", $red_kan);
- View::assign("sent_review_cost", $sent_review_cost_real);
- View::assign("amount", $amount_real);
- View::assign("num", $num);
- View::assign("num_project", $num_project);
- View::assign("sent_review_amount_tol", $sent_review_amount_tol_real);
- View::assign("red", $red);
- View::assign("red_notice", $unread_id);
- return View();
- }
- /**
- * 公司首页
- */
- public function main_company()
- {
- $sent_review_amount = Db::name("cost_project")->where([
- ["review_unit", "=", get_login_admin("unit_name")],
- ['delete_time', '=', 0],
- ['project_status', '>', 3],
- ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select();
- //engineering_type1=1是预算,2是结算
- $amount = [
- //送审总额
- 'sent_review_amount' => 0,
- //评审服务费
- 'sent_review_cost' => 0,
- //审定总额
- 'authorize_amount' => 0,
- //总审减率
- 'review_add_reduce_rate' => 0
- ];
- $sent_review_amount_tol = [
- "sent_review_amount_type1" => 0,
- "sent_review_amount_type2" => 0,
- "authorize_amount_type1" => 0,
- "authorize_amount_type2" => 0,
- "review_add_reduce_rate_type1" => 0,
- "review_add_reduce_rate_type2" => 0
- ];
- for ($i = 0; $i < count($sent_review_amount); $i++) {
- $a = $sent_review_amount[$i];
- if ($a['engineering_type1'] == 1) {
- if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
- //预算总额
- $sent_review_amount_tol["sent_review_amount_type1"] += $a["sent_review_amount"];
- //审定
- $sent_review_amount_tol["authorize_amount_type1"] += $a["authorize_amount"];
- }
- } elseif ($a['engineering_type1'] == 2) {
- if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
- //结算总额
- $sent_review_amount_tol["sent_review_amount_type2"] += $a["sent_review_amount"];
- //审定
- $sent_review_amount_tol["authorize_amount_type2"] += $a["authorize_amount"];
- }
- }
- }
- if ((int)$sent_review_amount_tol["sent_review_amount_type1"] && (int)$sent_review_amount_tol["authorize_amount_type1"]) {
- //预算核增减率
- $sent_review_amount_tol["review_add_reduce_rate_type1"] = (sprintf("%.4f", ($sent_review_amount_tol["authorize_amount_type1"] - $sent_review_amount_tol["sent_review_amount_type1"]) / $sent_review_amount_tol["sent_review_amount_type1"])) * 100;
- }
- if ((int)$sent_review_amount_tol["sent_review_amount_type2"] && (int)$sent_review_amount_tol["authorize_amount_type2"]) {
- //结算核增减率
- $sent_review_amount_tol["review_add_reduce_rate_type2"] = (sprintf("%.4f", ($sent_review_amount_tol["authorize_amount_type2"] - $sent_review_amount_tol["sent_review_amount_type2"]) / $sent_review_amount_tol["sent_review_amount_type2"])) * 100;
- }
- for ($i = 0; $i < count($sent_review_amount); $i++) {
- $a = $sent_review_amount[$i];
- if ((int)$a['sent_review_amount'] && (int)$a['sent_review_cost'] && (int)$a['authorize_amount']) {
- $amount["sent_review_amount"] += $a['sent_review_amount'];
- $amount["sent_review_cost"] += $a['sent_review_cost'];
- $amount["authorize_amount"] += $a['authorize_amount'];
- }
- }
- if ((int)$amount['sent_review_amount'] && (int)$amount["authorize_amount"]) {
- $amount['review_add_reduce_rate'] = (sprintf("%.4f", ($amount["authorize_amount"] - $amount["sent_review_amount"]) / $amount["sent_review_amount"])) * 100;
- }
- //评审服务费,上半年服务费用,下半年服务费用 start
- $currentTime = time();
- $year = date('Y', $currentTime);
- // 计算上半年时间范围
- $firstHalfStart = strtotime($year . '-01-01');
- $firstHalfEnd = strtotime($year . '-06-30 23:59:59');
- // 计算下半年时间范围
- $secondHalfStart = strtotime($year . '-07-01');
- $secondHalfEnd = strtotime($year . '-12-31 23:59:59');
- $first_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 2], ["review_unit", "=", get_login_admin("unit_name")]
- ])->
- whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select()->toArray();
- $second_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 2], ["review_unit", "=", get_login_admin("unit_name")]
- ])->
- whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select()->toArray();
- $sent_review_cost = [
- 'first_sent_review_cost' => 0,
- 'second_sent_review_cost' => 0
- ];
- for ($i = 0; $i < count($first_sent_review_cost); $i++) {
- $a = $first_sent_review_cost[$i];
- $sent_review_cost["first_sent_review_cost"] += $a['sent_review_cost'];
- }
- for ($i = 0; $i < count($second_sent_review_cost); $i++) {
- $a = $second_sent_review_cost[$i];
- $sent_review_cost["second_sent_review_cost"] += $a['sent_review_cost'];
- }
- //评审服务费,上半年服务费用,下半年服务费用 end
- //项目数量,正在作业,已归档
- $num = Db::name("cost_project")->where([
- ["review_unit", "=", get_login_admin("unit_name")],
- ['delete_time', '=', 0],
- ["project_status", '>', 3],
- ])->count();
- $where = [
- ["review_unit", "=", get_login_admin("unit_name")],
- ['delete_time', '=', 0],
- ["project_status", ">", 3]
- ];
- $data = Db::name("cost_project")->where($where)->select();
- $num_project = [
- 'num' => 0,
- "yu" => 0,
- "jie" => 0,
- "zuo" => 0,
- "gui" => 0,
- "tui" => 0,
- ];
- foreach ($data as $key => $value) {
- $num_project["num"] += 1;
- if ($value["project_status"] < 6 && $value["project_status"] > 3) {
- $num_project["zuo"] += 1;
- }
- if ($value["engineering_type1"] == 1) {
- $num_project["yu"] += 1;
- }
- if ($value["engineering_type1"] == 2) {
- $num_project["jie"] += 1;
- }
- if ($value["project_status"] == 8) {
- $num_project["gui"] += 1;
- }
- if ($value["project_status"] == 9) {
- $num_project["tui"] += 1;
- }
- }
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- View::assign("red_kan", $red_kan);
- View::assign("sent_review_cost", $sent_review_cost);
- View::assign("amount", $amount);
- View::assign("num", $num);
- View::assign("num_project", $num_project);
- View::assign("sent_review_amount_tol", $sent_review_amount_tol);
- return View();
- }
- /**
- * cp看板列表
- */
- public function kan_list()
- {
- //根据所登录的账号,查询跟本身有关的项目
- //2是公司,0是财政局,1是业主
- $param = get_params();
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- if (isset($param["project_start_time"])) {
- $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
- }
- if (isset($param["project_end_time"])) {
- $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
- }
- $where3 = [];//搜索条件
- if (!empty($param['project_status'])) {
- $where3[] = ['project_status', '=', $param['project_status']];
- }
- if (!empty($param['province'])) {
- $where3[] = ['province', '=', $param['province']];
- }
- if (!empty($param['city'])) {
- $where3[] = ['city', '=', $param['city']];
- }
- if (!empty($param['area'])) {
- $where3[] = ['area', '=', $param['area']];
- }
- if (!empty($param['project_end_time'])) {
- $where3[] = ['project_end_time', '<', $param['project_end_time']];
- }
- if (!empty($param['project_start_time'])) {
- $where3[] = ['project_start_time', '>', $param['project_start_time']];
- }
- if (!empty($param['keyword'])) {
- $keyword = $param['keyword'];
- $where3[] = ['project_num|project_name|review_unit', 'like', '%' . $keyword . '%'];
- }
- if (!empty($param['review_unit_name'])) {
- $where3[] = ['review_unit_name', 'like', '%' . $param['review_unit_name'] . '%'];
- }
- if (!empty($param['sent_review_unit_name'])) {
- $where3[] = ['sent_review_unit_name', 'like', '%' . $param['sent_review_unit_name'] . '%'];
- }
- if (!empty($param['entrust_unit_name'])) {
- $where3[] = ['entrust_unit_name', 'like', '%' . $param['entrust_unit_name'] . '%'];
- }
- $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
- $inarr = array();
- if ($unit_type == 0) {
- $where[] = ["delete_time", "=", 0];
- $where[] = ["project_status", ">", 0];
- $where[] = ["entrust_unit", "=", get_login_admin('unit_name')];
- $where2[] = ["delete_time", "=", 0];
- $where2[] = ["project_status", ">", 0];
- $where2[] = ["entrust_unit", "=", get_login_admin('unit_name')];
- //项目可见的权限
- $field = $this->Field->get_field_rules_new($this->uid);
- //1全部-可查看可编辑,2全部-可查看,0与我有关
- $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
- if ($see_auth == 3) {
- $where[] = ["entrust_maker", "=", $this->uid];
- $where2[] = ["entrust_approver", "=", $this->uid];
- $where2[] = ["project_status", ">", 1];
- } elseif ($see_auth == 0) {
- $where[] = ["entrust_maker", "=", $this->uid];
- $where[] = ["project_status", ">", 0];
- $where2[] = ["entrust_approver", "=", $this->uid];
- $where2[] = ["project_status", ">", 1];
- }
- $list = $this->model->where($where3)
- ->where(function ($query) use ($where,$where2) {
- // 第一组条件(entrust_maker)
- $query->where(function ($q1) use ($where) {
- $q1->where($where);
- });
- // 使用 OR 连接第二组条件(entrust_approver)
- $query->whereOr(function ($q2) use ($where2) {
- $q2->where($where2);
- });
- })
- ->order("create_time desc")->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- } else {
- $item->red = 0;
- }
- } else {
- $item->red = 0;
- }
- if (($item->province && $item->city && $item->area)) {
- $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
- }
- })->toArray();
- } elseif ($unit_type == 2) {
- $order = empty($param['order']) ? 'project_receive_time desc,id desc' : $param['order'];
- $where = [
- ["delete_time", "=", 0],
- ["project_status", ">", 3],
- ["review_unit", "=", get_login_admin("unit_name")]
- ];
- $review_unit = $this->model->where($where)->where($where3)->field('id,review_head,operate_head,operate_team')->select()->toArray();
- for ($i = 0; $i < count($review_unit); $i++) {
- $a = $review_unit[$i];
- $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
- $ids = explode(",", $ids);
- $c = in_array($this->uid, $ids);
- if ($c) {
- $inarr[] = $a["id"];
- }
- }
- $field = $this->Field->get_field_rules_New($this->uid);
- $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
- $this->see_auth = $see_auth;
- if ($see_auth == 3) {
- $list = $this->model
- ->where($where)->where($where3)->whereIn("id", $inarr)
- ->order($order)->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- } else {
- $item->red = 0;
- }
- } else {
- $item->red = 0;
- }
- })->toArray();
- } elseif ($see_auth == 0) {
- $list = $this->model
- ->where($where)->where($where3)->whereIn("id", $inarr)
- ->order($order)->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- } else {
- $item->red = 0;
- }
- } else {
- $item->red = 0;
- }
- })->toArray();
- } else {
- $list = $this->model
- ->where($where)
- ->order($order)->where($where3)->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- } else {
- $item->red = 0;
- }
- } else {
- $item->red = 0;
- }
- })->toArray();
- }
- } elseif ($unit_type == 1) {
- $field = $this->Field->get_field_rules_New($this->uid);
- $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
- if ($see_auth == 0 || $see_auth == 3) {
- $where = [
- ["delete_time", "=", 0],
- ["sent_review_unit", "=", get_login_admin("unit_name")],
- ["sent_review_head", "=", $this->uid]
- ];
- } else {
- $where = [
- ["delete_time", "=", 0],
- ["sent_review_unit", "=", get_login_admin("unit_name")]
- ];
- }
- $list = $this->model
- ->where($where)
- ->order($order)->where($where3)->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
- if ($red) {
- if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
- $item->red = 1;
- } else {
- $item->red = 0;
- }
- } else {
- $item->red = 0;
- }
- })->toArray();
- } else {
- $list["data"] = [];
- }
- $data = $list["data"];
- $real_list = array_values(array_column($data, NULL, 'id'));
- $red = $this->Auditmodel->where("approver", $this->uid)->where("audit_status", 1)->count();
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- // halt($real_list);
- View::assign("red_kan", $red_kan);
- View::assign("detail", $real_list);
- View::assign("red", $red);
- View::assign("unit_type", $unit_type);
- return view();
- }
- public function pending_invite()
- {
- $param = get_params();
- $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
- $where1 = [];
- //2是公司,0是财政局,1是业主
- if ($unit_type == 0) {
- if (!empty($param['invite_keyword'])) {
- $keyword = $param['invite_keyword'];
- $where1[] = ['review_unit_name', 'like', '%' . $keyword . '%'];
- }
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $Appropriationlist = $this->AppropriationModel->where("entrust_unit", get_login_admin("unit_name"))
- ->where("status",">",0)->where($where1)
- ->order( $order)->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $data = Db::name("appropriation_project")->alias("a")->join("cost_project c","a.project_id=c.id","left")
- ->where("a.uid","not null")->where("a.uid",$item->id)
- ->where("c.entrust_unit",get_login_admin("unit_name"))->column("c.project_name,c.sent_review_cost");
- if (!empty($data)) {
- $a = 0;
- $project_name = [];
- $appropriation_amount = 0;
- foreach ($data as $key => $value) {
- $a += 1;
- $project_name[] = $a . "." . $value["project_name"];
- $appropriation_amount += $value["sent_review_cost"];
- }
- $item->a = count($data);
- $item->appropriation_amount = $appropriation_amount;
- $item->project_names = $project_name;
- }
- });
- } else if($unit_type == 2) {
- $where = [
- ["a.approver", "=", $this->uid],
- ["a.audit_type", ">", 3],
- ["a.audit_status", "<", 5]
- ];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- if (!empty($param['invite_keyword'])) {
- $keyword = $param['invite_keyword'];
- $where[] = ['entrust_unit_name', 'like', '%' . $keyword . '%'];
- }
- $Appropriationlist = $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($where)->order($order)
- ->paginate(9999, false, ['query' => $param])
- ->where('audit_type','in',[10,11,12])
- ->each(function ($item){
- switch ($item["audit_type"]) {
- case 10:
- $item->else_name = "请款一级审核";
- break;
- case 11:
- $item->else_name = "请款二级审核";
- break;
- case 12:
- $item->else_name = "请款三级审核";
- break;
- }
- });
- }
-
-
- $app_red = 0;
- if($this->user_tpe==0){
- $app_where=[
- ["status","=",1],
- ["entrust_unit","=",get_login_admin("unit_name")]
- ];
- if(Db::name("appropriation")->where($app_where)->count()>0){$app_red=1;}
- }else if($this->user_tpe==2){
- //10请款一审,11请款二审,12,请款三审
- $app_where=[
- ["audit_type",">",9],
- ["audit_type","<",13],
- ["audit_status","=",1],
- ["approver","=",$this->uid]
- ];
- if($this->Auditmodel->where($app_where)->count()>0){$app_red=1;}
- }
-
-
- //红点
- $where = [
- ["approver", "=", $this->uid],
- ["audit_status", "<", 5]
- ];
- $list = $this->Auditmodel->alias("a")->join("cost_project c", "a.project_id=c.id", "left")
- ->where($where)->field("a.*,c.project_num,c.project_status,c.engineering_type,c.sent_review_amount")
- ->paginate(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- $item->approver_name = Db::name("admin")->where("id", $item->approver)->value("nickname");
- })->toArray();
- $red = 0;
- foreach ($list["data"] as $item => $value) {
- if ($value["audit_status"] == 1) {
- $red = 1;
- }
- }
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- View::assign('unit_type', $unit_type);
- View::assign('list', $Appropriationlist);
- View::assign("red_kan", $red_kan);
- View::assign('red', $red);
- View::assign('app_red', $app_red);
- return view();
- }
- /**
- * cp待办列表
- */
- public function pending()
- {
- $param = get_params();
- //1项目,2报告,3联系函,4公司一级审核,5公司二级审核,6公司三级审核,7联系函一审,8联系过二审,9联系函三审,10请款一审,11请款二审,12,请款三审,14报告四审,15报告五审
- $where = [
- ["approver", "=", $this->uid],
- ["audit_status", "<", 5],
- ["audit_type", "<>", 10],
- ["audit_type", "<>", 11],
- ["audit_type", "<>", 12],
- ];
- if (!empty($param['project_status'])) {
- $where[] = ['c.project_status', '=', $param['project_status']];
- }
- if (!empty($param['province'])) {
- $where[] = ['c.province', '=', $param['province']];
- }
- if (!empty($param['city'])) {
- $where[] = ['c.city', '=', $param['city']];
- }
- if (!empty($param['area'])) {
- $where[] = ['c.area', '=', $param['area']];
- }
- if (!empty($param['project_end_time'])) {
- $where[] = ['c.project_end_time', '<', $param['project_end_time']];
- }
- if (!empty($param['project_start_time'])) {
- $where[] = ['c.project_start_time', '>', $param['project_start_time']];
- }
- if (!empty($param['keyword'])) {
- $keyword = $param['keyword'];
- $where[] = ['c.project_num|c.project_name|c.review_unit', 'like', '%' . $keyword . '%'];
- }
- if (!empty($param['list_keyword'])) {
- $keyword = $param['list_keyword'];
- $where[] = ['c.project_name', 'like', '%' . $keyword . '%'];
- }
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $app_red = 0;
- if($this->user_tpe==0){
- $app_where=[
- ["status","=",1],
- ["entrust_unit","=",get_login_admin("unit_name")]
- ];
- if(Db::name("appropriation")->where($app_where)->count()>0){$app_red=1;}
- }else if($this->user_tpe==2){
- //10请款一审,11请款二审,12,请款三审
- $app_where=[
- ["audit_type",">",9],
- ["audit_type","<",13],
- ["audit_status","=",1],
- ["approver","=",$this->uid]
- ];
- if($this->Auditmodel->where($app_where)->count()>0){$app_red=1;}
- }
- $list = $this->Auditmodel->alias("a")->join("cost_project c", "a.project_id=c.id", "left")->where($where)->field("a.*,c.project_num,c.project_status,c.engineering_type,c.sent_review_amount")
- ->order($order)->paginate(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- $item->approver_name = Db::name("admin")->where("id", $item->approver)->value("nickname");
- })->toArray();
- $red = 0;
- foreach ($list["data"] as $item => $value) {
- if ($value["audit_status"] == 1) {
- $red = 1;
- }
- }
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- $real_list = [];
- foreach ($list["data"] as $item => $value) {
- if (in_array($value["audit_type"], [2,4, 5, 6,14,15])) {
- $a = Db::name("project_report")->where("id", $value["else_id"])->field("title,status")->find();
- $value["else_name"] = $a["title"];
- $value["else_status"] = $a["status"];
- } elseif (in_array($value["audit_type"], [3,7, 8, 9])) {
- $a = Db::name("contact")->where("id", $value["else_id"])->field("title,status")->find();
- $value["else_name"] = $a["title"];
- $value["else_status"] = $a["status"];
- }
- //,14报告四审,15报告五审
- if (in_array($value["audit_type"], [4, 5, 6,14,15])) {
- switch ($value["audit_type"]) {
- case 4:
- $value["audit_name"] = "报告一审";
- break;
- case 5:
- $value["audit_name"] = "报告二审";
- break;
- case 6:
- $value["audit_name"] = "报告三审";
- break;
- case 14:
- $value["audit_name"] = "报告四审";
- break;
- case 15:
- $value["audit_name"] = "报告五审";
- break;
- }
- } elseif (in_array($value["audit_type"], [7, 8, 9])) {
- switch ($value["audit_type"]) {
- case 7:
- $value["audit_name"] = "联系函一审";
- break;
- case 8:
- $value["audit_name"] = "联系函二审";
- break;
- case 9:
- $value["audit_name"] = "联系函三审";
- break;
- }
- } elseif (in_array($value["audit_type"], [10, 11, 12])) {
- switch ($value["audit_type"]) {
- case 10:
- $value["audit_name"] = "请款一审";
- break;
- case 11:
- $value["audit_name"] = "请款二审";
- break;
- case 12:
- $value["audit_name"] = "请款三审";
- break;
- }
- }
- $real_list[] = $value;
- }
- // halt($real_list);
- View::assign("red_kan", $red_kan);
- View::assign('app_red', $app_red);
- View::assign('red', $red);
- View::assign('list', $real_list);
- // halt($real_list);
- return view();
- }
- /**
- *个人资料
- */
- public function person()
- {
- $person = get_login_admin();
- $red = $this->Auditmodel->where("approver", $this->uid)->where("audit_status", 1)->count();
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- View::assign("red_kan", $red_kan);
- View::assign('red', $red);
- View::assign('person', $person);
- return view();
- }
- /**
- * cp看板内容
- */
- public function detail()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $type = isset($param['type']) ? $param['type'] : 0;
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $order = empty($param['order']) ? 'a.id desc' : $param['order'];
- $detail = $this->model->getCostProjectById($id);
- $comment = Db::name("project_comment")->where("project_id", $id)->order('create_time', 'desc')->select();
- $file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
- ->select()->toArray();
- $report = Db::name("project_report")
- ->where([["project_id", "=", $id]])
- ->alias("r")->join("admin a", "r.maker_id = a.id")
- ->field("r.*,a.nickname")
- ->select();
- $contact = $this->ContactModel->where([['project_id', '=', $id]])
- ->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(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- })->toArray();
- $contact = $contact['data'];
- $where = [
- ["cp_project_record.delete_time", "=", 0],
- ["project_id", "=", $id],
- ["maker_id", "=", get_login_admin('id')]
- ];
- $record = Db::name('project_record')->where($where)
- ->field('a.*,u.nickname as admin_name')
- ->alias('a')
- ->join('Admin u', 'a.maker_id = u.id', "left")
- ->order($order)
- ->select();
- //2是公司,0是财政局,1是业主
- $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
- if ($unit_type == 0) {
- $person = self::user($id);
- View::assign('project_five', self::getProjectFive());
- } elseif ($unit_type == 2) {
- $person = self::user($id);
- View::assign('project_five', self::getProjectFiveCompany());
- } else {
- $person = 0;
- View::assign('project_five', self::getProjectFiveYezhu());
- }
- $appropriation_uid = Db::name("appropriation_project")->where("project_id", $id)->value("uid");
- if (empty($appropriation_uid)) {
- $appropriation_data = [];
- $appropriation_file_array = [];
- } else {
- $where = [
- ["id", "=", $appropriation_uid],
- ["status", ">", 0]
- ];
- //请款
- $appropriation = Db::name("appropriation")->where($where)->find();
- if (!empty($appropriation)) {
- $projects = Db::name("appropriation_project")->alias("a")
- ->leftJoin("cost_project c", "a.project_id=c.id")
- ->where("uid", $appropriation["id"])->column("c.project_name,c.sent_review_cost");
- $data = [];
- $appropriation_amount = 0;
- for ($i = 0; $i < count($projects); $i++) {
- $v = $projects[$i];
- $b = $i + 1;
- $appropriation_amount += $v["sent_review_cost"];
- $data[] = $b . "." . $v["project_name"];
- }
- $appropriation_data = $appropriation;
- $appropriation_data["appropriation_amount"] = $appropriation_amount;
- $appropriation_data["project_name"] = $data;
- $appropriation_file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $appropriation_uid, 'mf.module' => 'appropriation'))
- ->select()->toArray();
- } else {
- $appropriation_data = [];
- $appropriation_file_array = [];
- }
- }
- $project_log = self::project_log($id);
- $red = Db::name("new_msg")->where([["uid", '=', $this->uid], ["project_id", "=", $id]])->field('detail,comment,report,user,contact')->find();
- if (empty($red)) {
- $red = ["detail" => 0, "comment" => 0, "report" => 0, "user" => 0, "contact" => 0];
- }
- $field = $this->Field->get_field_rules_new($this->uid);
- $fields = [];
- foreach ($field as $k=>$v){
- if($v==1){
- $fields[$k] = true;
- }else{
- $fields[$k] = false;
- }
- }
- if($this->user_tpe==2){
- $fields["sent_review_approver_amount"] = false;
- $fields["construction_approver_amount"] = false;
- }
- View::assign('field', $fields);
- if (!empty($detail)) {
- View::assign('project_log', $project_log);
- View::assign('project_id', $id);
- View::assign('comment', $comment);
- View::assign('record', $record);
- View::assign('contact', $contact);
- View::assign('detail', $detail);
- View::assign('appropriation', $appropriation_data);
- View::assign('file_array', $file_array);
- View::assign('appropriation_file_array', $appropriation_file_array);
- View::assign('report', $report);
- View::assign('person', $person);
- View::assign('red', $red);
- View::assign('unit_type', $unit_type);
- return view();
- } else {
- throw new \think\exception\HttpException(404, '找不到页面');
- }
- }
- /**
- * cp代办内容
- */
- public function pdetail()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $type = isset($param['type']) ? $param['type'] : 0;
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $order = empty($param['order']) ? 'a.id desc' : $param['order'];
- $detail = $this->model->getCostProjectById($id);
- $comment = Db::name("project_comment")->where("project_id", $id)->order('create_time', 'desc')->select();
- $file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
- ->select()->toArray();
- $report = Db::name("project_report")->where([["project_id", "=", $id], ["r.status", "=", 1]])->alias("r")->join("admin a", "r.maker_id = a.id")->field("r.*,a.nickname")->select();
- $contact = $this->ContactModel->where([['project_id', '=', $id]])
- ->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(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- })->toArray();
- $contact = $contact['data'];
- $where = [
- ["cp_project_record.delete_time", "=", 0],
- ["project_id", "=", $id],
- ["maker_id", "=", get_login_admin('id')]
- ];
- $record = Db::name('project_record')->where($where)
- ->field('a.*,u.nickname as admin_name')
- ->alias('a')
- ->join('Admin u', 'a.maker_id = u.id', "left")
- ->order($order)
- ->select();
- //2是公司,0是财政局,1是业主
- $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
- if ($unit_type == 0) {
- $person = self::user($id);
- View::assign('project_five', self::getProjectFive());
- } elseif ($unit_type == 2) {
- $person = self::user($id);
- View::assign('project_five', self::getProjectFiveCompany());
- } else {
- $person = 0;
- View::assign('project_five', self::getProjectFiveYezhu());
- }
- $field = $this->Field->get_field_rules_new($this->uid);
- $fields = [];
- foreach ($field as $k=>$v){
- if($v==1){
- $fields[$k] = true;
- }else{
- $fields[$k] = false;
- }
- }
- if($this->user_tpe==2){
- $fields["sent_review_approver_amount"] = false;
- $fields["construction_approver_amount"] = false;
- }
- View::assign('field', $fields);
- $project_log = self::project_log($id);
- // halt($detail);
- if (!empty($detail)) {
- View::assign('project_log', $project_log);
- View::assign('project_id', $id);
- View::assign('comment', $comment);
- View::assign('record', $record);
- View::assign('contact', $contact);
- View::assign('detail', $detail);
- View::assign('file_array', $file_array);
- View::assign('report', $report);
- View::assign('person', $person);
- return view();
- } else {
- echo '<div style="text-align:center;color:red;margin-top:20%;font-size:425%"><span>项目不存在!</span><br><span>已被删除</span></div>';
- // throw new \think\exception\HttpException(404, '项目不存在');
- }
- }
- /**
- * cp看板报告内容
- */
- public function report_detail()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $detail = Db::name('ProjectReport')->where(['id' => $id])->find();
- 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('project_id', $project_id);
- View::assign('detail', $detail);
- return view();
- }
- }
- /**
- * cp待办报告内容
- */
- public function report_pdetail()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $detail = Db::name('ProjectReport')->where(['id' => $id])->find();
- 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('project_id', $project_id);
- View::assign('detail', $detail);
- return view();
- }
- }
- /**
- *项目日志
- */
- public function project_log($project_id)
- {
- // $project_id = 24;
- $login_admin = get_login_admin();
- $where = array();
- if ($login_admin['user_type'] == 2) {
- $where = [
- ['project_status', '>=', 3],
- ['unit_name', '=', $login_admin['unit_name']],
- ];
- } else {
- if ($login_admin['permission'] != 1) {
- $where = [
- ['unit_name', '=', $login_admin['unit_name']],
- ];
- }
- }
- // dump($where);
- $project_log = Db::name('ProjectLog')->where($where)->where('project_id', $project_id)->order('create_time', 'desc')->select()->toArray();
- foreach ($project_log as $key => $value) {
- $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
- }
- // dump($project_log);
- // View::assign('project_log', $project_log);
- // return View();
- return $project_log;
- }
- /**
- *
- */
- public function sift()
- {
- return view();
- }
- /**
- *项目人员
- */
- public function user($id)
- {
- $ids = $this->model->where("id", $id)->field("entrust_maker,review_head,operate_head,operate_team")->find();
- if (empty($ids)) {
- return [];
- } else {
- $ids->toArray();
- }
- $idarr = $ids["operate_team"] . ',' . $ids["operate_head"] . ',' . $ids["review_head"] . ',' . $ids["entrust_maker"];
- $idarr = explode(",", $idarr);
- $param = [];
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $list = $this->Adminmodel->whereIn("id", $idarr)->field("id,nickname,unit_name,mobile,email")->paginate(9999, false, ['query' => $param])
- // field("a.id,a.nickname,a.unit_name,a.mobile,a.email,d.title,d.type")->join('department d', 'a.unit_name = d.id', 'LEFT')
- ->each(function ($item) {
- //获取单位的邮箱,单位信息页没做
- $item->email = Db::name('department')->where(['id' => $item->unit_name])->value('email');
- $type = Db::name('department')->where(['id' => $item->unit_name])->value('type');
- $item->unit_name = Db::name('department')->where(['id' => $item->unit_name])->value('title');
- // dump($type);
- if ($type == 0) {
- $item->unit_type = "委托单位";
- } elseif ($type == 1) {
- $item->unit_type = "送审单位";
- } elseif ($type == 2) {
- $item->unit_type = "评审机构";
- } else {
- $item->unit_type = "施工单位";
- }
- })->toArray();
- $list = $list["data"];
- $time_id = time();
- $shigong = $this->model->where('id', $id)->find();
- if ($shigong["construction_unit"] !== null ||
- $shigong["construction_head"] !== null ||
- $shigong["construction_email"] !== null ||
- $shigong["construction_phone"] !== null
- ) {
- $shigongdata["id"] = $time_id;
- $shigongdata["nickname"] = $shigong["construction_unit"];
- $shigongdata["unit_name"] = $shigong["construction_head"];
- $shigongdata["email"] = $shigong["construction_email"];
- $shigongdata["mobile"] = $shigong["construction_phone"];
- $shigongdata["unit_type"] = "施工单位";
- array_push($list, $shigongdata);
- }
- $time_id_sent = time() - 200;
- if ($shigong["sent_review_unit"] !== null ||
- $shigong["sent_review_head"] !== null ||
- $shigong["sent_review_phone"] !== null ||
- $shigong["sent_review_head_email"] !== null
- ) {
- $sent_review_data["id"] = $time_id_sent;
- $sent_review_data["nickname"] = $shigong["sent_review_head_name"];
- $sent_review_data["unit_name"] = $shigong["sent_review_unit_name"];
- $sent_review_data["email"] = $shigong["sent_review_head_email"];
- $sent_review_data["mobile"] = $shigong["sent_review_phone"];
- $sent_review_data["unit_type"] = "送审单位";
- array_push($list, $sent_review_data);
- }
- if (empty($ids['operate_team'])) {
- $operate_team[] = '0';
- } else {
- $operate_team = explode(',', $ids['operate_team']);
- }
- for ($i = 0; $i < count($list); $i++) {
- if ($list[$i]['id'] == $ids['entrust_maker']) {
- // dump($list[$i]['id'],$ids['entrust_maker']);
- $list[$i]["type"] = 1;
- } elseif ($list[$i]['id'] == $ids['review_head']) {
- $list[$i]["type"] = 2;
- } elseif ($list[$i]['id'] == $ids['operate_head']) {
- $list[$i]["type"] = 3;
- } elseif (in_array($list[$i]['id'], $operate_team)) {
- $list[$i]["type"] = 4;
- } elseif ($list[$i]['id'] == $time_id) {
- $list[$i]["type"] = 5;
- } elseif ($list[$i]['id'] !== time() - 1000) {
- $list[$i]["type"] = 6;
- }
- }
- $type = array_column($list, 'type');
- array_multisort($type, SORT_ASC, $list);
- return $list;
- }
- /**
- * 修改个人资料
- */
- public function revise()
- {
- $person = get_login_admin();
- View::assign('person', $person);
- return view();
- }
- /**
- * 消息通知
- * 通用
- */
- public function notice()
- {
- $unread_id = Db::name("admin")->where("id", $this->uid)->value("unread");
- if (empty($unread_id)) {
- $unread_ids = [];
- } else {
- $unread_ids = explode(",", $unread_id);
- }
- $list = Db::name("ProjectMsg")->where("uid", $this->uid)->select();
- if (is_object($list)) {
- $data = $list->toArray();
- }
- $real_data = [];
- foreach ($data as $item => $v) {
- if (in_array($v["id"], $unread_ids)) {
- $v["red"] = 1;
- $real_data[] = $v;
- } else {
- $v["red"] = 0;
- $real_data[] = $v;
- }
- }
- Db::name("admin")->where("id", $this->uid)->update(["unread" => null]);
- View::assign("msg", $real_data);
- return view();
- }
- public function notice_content()
- {
- return view();
- }
- /**
- * 工作记录
- */
- public function record()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $detail = (new ProjectRecord())->detail($id);
- if (empty($detail)) {
- if (empty($detail)) {
- echo '<div style="text-align:center;color:red;margin-top:20%;">该记录不存在</div>';
- exit;
- }
- return '';
- }
- $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
- $detail["maker_name"] = $maker_name;
- View::assign('detail', $detail);
- View::assign('project_id', $project_id);
- return view();
- }
- /**
- * 编辑工作记录
- */
- public function record_edit()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;//记录id
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $project = Db::name("cost_project")->where("id", $project_id)->value("project_name");
- $detail = (new ProjectRecord())->getRecordById($id);
- if (!empty($detail)) {
- View::assign('id', $id);
- View::assign('user_type', $this->user_tpe);
- View::assign('project_id', $project_id);
- View::assign('project', $project);
- View::assign('detail', $detail);
- return view();
- } else {
- throw new \think\exception\HttpException(404, '页面不存在');
- }
- }
- /**
- * 添加工作记录
- */
- public function record_add()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;//记录id
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $project = Db::name("cost_project")->where("id", $project_id)->value("project_name");
- View::assign('id', $id);
- View::assign('user_type', $this->user_tpe);
- View::assign('project_id', $project_id);
- View::assign('project', $project);
- return view();
- }
- /**
- * 临期表格
- */
- public function pending_advent()
- {
- $param = get_params();
- $where = [
- ["delete_time", "=", 0],
- ['project_end_time', '<', strtotime('15 days')],
- ['project_end_time', '>', time()],
- ];
- $where2 = [
- ["delete_time", "=", 0],
- ['project_end_time', '<', strtotime('15 days')],
- ['project_end_time', '>', time()],
- ["project_status", ">", 1]
- ];
- $where3[] = ["project_status", "<", 8];
- if (!empty($param['project_status'])) {
- $where3[] = ['project_status', '=', $param['project_status']];
- }
- if (!empty($param['province'])) {
- $where3[] = ['province', '=', $param['province']];
- }
- if (!empty($param['city'])) {
- $where3[] = ['city', '=', $param['city']];
- }
- if (!empty($param['area'])) {
- $where3[] = ['area', '=', $param['area']];
- }
- if (!empty($param['project_end_time'])) {
- $where3[] = ['project_end_time', '<', $param['project_end_time']];
- }
- if (!empty($param['project_start_time'])) {
- $where3[] = ['project_start_time', '>', $param['project_start_time']];
- }
- if (!empty($param['keyword'])) {
- $keyword = $param['keyword'];
- $where3[] = ['project_name', 'like', '%' . $keyword . '%'];
- }
- if ($this->user_tpe == 0) {
- $where[] = ["entrust_maker", "=", $this->uid];
- $where2[] = ["entrust_approver", "=", $this->uid];
- } else if ($this->user_tpe == 2) {
- $inarr = array();
- $review_unit = $this->model->where("review_unit", get_login_admin("unit_name"))->field('id,review_head,operate_head,operate_team')->select()->toArray();
- for ($i = 0; $i < count($review_unit); $i++) {
- $a = $review_unit[$i];
- $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
- $ids = explode(",", $ids);
- $c = in_array($this->uid, $ids);
- if ($c) {
- $inarr[] = $a["id"];
- }
- }
- $where3[] = ["id","in", $inarr];
- } else if ($this->user_tpe == 1) {
- $where[] = ["entrust_maker", "=", $this->uid];
- $where2[] = ["entrust_approver", "=", $this->uid];
- }
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $advent_list = $this->model->where($where3)->where(function ($query) use ($where,$where2) {
- // 第一组条件(entrust_maker)
- $query->where(function ($q1) use ($where) {
- $q1->where($where);
- });
- // 使用 OR 连接第二组条件(entrust_approver)
- $query->whereOr(function ($q2) use ($where2) {
- $q2->where($where2);
- });
- })
- ->order($order)
- ->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $c = $item->project_end_time - time();
- $item->advent_time = floor($c / 86400) . "天";
- });
- $list = $this->Auditmodel->alias("a")->join("cost_project c", "a.project_id=c.id", "left")->where("approver", $this->uid)->field("a.*,c.project_num,c.project_status,c.engineering_type,c.sent_review_amount")
- ->order($order)->paginate(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- $item->approver_name = Db::name("admin")->where("id", $item->approver)->value("nickname");
- })->toArray();
- $red = 0;
- foreach ($list["data"] as $item => $value) {
- if ($value["audit_status"] == 1) {
- $red = 1;
- }
- }
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- View::assign("red_kan", $red_kan);
- View::assign('red', $red);
- View::assign('advent_list', $advent_list);
- return view();
- }
- /**
- * 逾期项目
- */
- public function pending_late()
- {
- $param = get_params();
- $where = [
- ["delete_time", "=", 0],
- ['project_end_time', '<', time()],
- ];
- $where2 = [
- ["delete_time", "=", 0],
- ['project_end_time', '<', time()],
- ["project_status", ">", 1]
- ];
- if (!empty($param['project_status'])) {
- $where[] = ['project_status', '=', $param['project_status']];
- $where2[] = ['project_status', '=', $param['project_status']];
- }
- if (!empty($param['province'])) {
- $where[] = ['province', '=', $param['province']];
- $where2[] = ['province', '=', $param['province']];
- }
- if (!empty($param['city'])) {
- $where[] = ['city', '=', $param['city']];
- $where2[] = ['city', '=', $param['city']];
- }
- if (!empty($param['area'])) {
- $where[] = ['area', '=', $param['area']];
- $where2[] = ['area', '=', $param['area']];
- }
- if (!empty($param['project_end_time'])) {
- $where[] = ['project_end_time', '<', $param['project_end_time']];
- $where2[] = ['project_end_time', '<', $param['project_end_time']];
- }
- if (!empty($param['project_start_time'])) {
- $where[] = ['project_start_time', '>', $param['project_start_time']];
- $where2[] = ['project_start_time', '>', $param['project_start_time']];
- }
- $where3[] = ["project_status", "<", 8];
- if (!empty($param['keyword'])) {
- $keyword = $param['keyword'];
- $where3[] = ['project_name', 'like', '%' . $keyword . '%'];
- }
- if ($this->user_tpe == 0) {
- $where[] = ["entrust_maker", "=", $this->uid];
- $where2[] = ["entrust_approver", "=", $this->uid];
- } else if ($this->user_tpe == 2) {
- $inarr = array();
- $review_unit = $this->model->where("review_unit", get_login_admin("unit_name"))->field('id,review_head,operate_head,operate_team')->select()->toArray();
- for ($i = 0; $i < count($review_unit); $i++) {
- $a = $review_unit[$i];
- $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
- $ids = explode(",", $ids);
- $c = in_array($this->uid, $ids);
- if ($c) {
- $inarr[] = $a["id"];
- }
- }
- $where3[] = ["id","in", $inarr];
- } else if ($this->user_tpe == 1) {
- }
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- // halt($where,$where2);
- $late_list = $this->model->where($where3)
- ->where(function ($query) use ($where,$where2) {
- // 第一组条件(entrust_maker)
- $query->where(function ($q1) use ($where) {
- $q1->where($where);
- });
- // 使用 OR 连接第二组条件(entrust_approver)
- $query->whereOr(function ($q2) use ($where2) {
- $q2->where($where2);
- });
- })->order($order)->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- $c = time() - $item->project_end_time;
- $item->advent_time = floor($c / 86400) . "天";
- });
- // halt($late_list->toArray());
- $list = $this->Auditmodel->alias("a")->join("cost_project c", "a.project_id=c.id", "left")->where("approver", $this->uid)->field("a.*,c.project_num,c.project_status,c.engineering_type,c.sent_review_amount")
- ->order($order)->paginate(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- $item->approver_name = Db::name("admin")->where("id", $item->approver)->value("nickname");
- })->toArray();
- $red = 0;
- foreach ($list["data"] as $item => $value) {
- if ($value["audit_status"] == 1) {
- $red = 1;
- }
- }
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- View::assign("red_kan", $red_kan);
- View::assign('red', $red);
- View::assign('late_list', $late_list);
- return view();
- }
- /**
- * 邀请函
- */
- public function invite()
- {
- $param = get_params();
- $id = isset($param['id']) ? $param['id'] : 0;//记录id
- $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
- $project = Db::name("cost_project")->where("id", $project_id)->value("project_name");
- $detail = (new Contact())->detail($id);
- $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();
- if (!empty($detail)) {
- View::assign('id', $id);
- View::assign('project_id', $project_id);
- View::assign('project', $project);
- View::assign('detail', $detail);
- View::assign('file_array', $file_array);
- return view();
- } else {
- throw new \think\exception\HttpException(404, '页面不存在');
- }
- }
- public function cost_detail()
- {
- return view();
- }
- public function login()
- {
- return view();
- }
- /**
- * 关联账号
- * 通用
- *
- */
- public function associated()
- {
- $param = get_params();
- $id = get_login_admin("id");
- $acct_connect = Db::name('Admin')->where('id', $id)->value('acct_connect');
- $where = array();
- $where[] = ['status', '>=', 0];
- $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
- $admins = AdminList::where($where)->with('Department')
- ->where('id', 'in', $acct_connect)
- ->order('create_time asc')
- ->paginate(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- $groupId = Db::name('AdminGroupAccess')->where(['uid' => $item->id])->column('group_id');
- $groupName = Db::name('AdminGroup')->where('id', 'in', $groupId)->column('title');
- $item->groupName = implode(',', $groupName);
- $item->last_login_time = empty($item->last_login_time) ? '-' : date('Y-m-d H:i', $item->last_login_time);
- })->toArray();
- View::assign('admin', $admins["data"]);
- return view();
- }
- // cp请款函内容
- public function request_detail()
- {
- $param = get_params();
- return view();
- }
- /**
- * 查看审批进度
- */
- 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();
- }
- /**
- * 通讯录
- */
- /**
- * 通讯录
- */
- public function contacts()
- {
- $param = get_params();
- $where = [];
- if (!empty($param["keyword"])) {
- $where = [["a.nickname|d.title", "like", "%" . $param["keyword"] . "%"]];
- }
- //0:财政局;1:业主;2:公司
- if ($this->user_tpe == 0) {
- //财评内部
- $list = Db::name("admin")->alias("a")
- ->where("a.unit_name", get_login_admin("unit_name"))
- ->where("a.status", 1)
- ->where($where)
- ->join("department d", "a.did=d.id", "left")
- ->field("a.id,d.title,a.nickname,a.mobile,a.email")->select();
- } else if ($this->user_tpe == 1) {
- //业主内部
- $list = Db::name("admin")->alias("a")
- ->where("a.unit_name", get_login_admin("unit_name"))
- ->where("a.status", 1)
- ->where($where)
- ->join("department d", "a.did=d.id", "left")
- ->field("a.id,d.title,a.nickname,a.mobile,a.email")
- ->select();
- } else if ($this->user_tpe == 2) {
- $list = Db::name("admin")->alias("a")
- ->where("a.unit_name", get_login_admin("unit_name"))
- ->where("a.status", 1)
- ->where($where)
- ->join("department d", "a.did=d.id", "left")
- ->field("a.id,d.title,a.nickname,a.mobile,a.email")
- ->select();
- }
- View::assign('list', $list);
- return view();
- }
- public function contacts_exterior()
- {
- $param = get_params();
- $where = [];
- if (!empty($param["keyword"])) {
- $where = [["a.nickname|d.title", "like", "%" . $param["keyword"] . "%"]];
- }
- //0:财政局;1:业主;2:公司
- if ($this->user_tpe == 0) {
- //公司负责人
- $list_company = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
- ->where([["d.type", "=", 2], ["pid", "=", 0], ["d.status", "=", 1]])
- ->where($where)->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
- ->select()->toArray();
- $list_proprietor = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
- ->where([["d.type", "=", 1], ["pid", "=", 0], ["d.status", "=", 1]])
- ->where($where)
- ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
- ->select()->toArray();
- $list_exterior = array_merge($list_company,$list_proprietor);
- } else if ($this->user_tpe == 1) {
- //公司负责人
- $list_company = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
- ->where([["d.type", "=", 2], ["pid", "=", 0], ["d.status", "=", 1]])
- ->where($where)->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
- ->select()->toArray();
- //财评负责人
- $list_entrust = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
- ->where([["d.type", "=", 0], ["pid", "=", 0], ["d.status", "=", 1]])
- ->where($where)
- ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
- ->select()->toArray();
- $list_exterior = array_merge($list_company,$list_entrust);
- } else if ($this->user_tpe == 2) {
- //公司内部通讯录
- $list_entrust = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
- ->where([["d.type", "=", 0], ["pid", "=", 0], ["d.status", "=", 1]])
- ->where($where)
- ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
- ->select()->toArray();
- $list_proprietor = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
- ->where([["d.type", "=", 1], ["pid", "=", 0], ["d.status", "=", 1]])
- ->where($where)
- ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
- ->select()->toArray();
- $list_exterior = array_merge($list_proprietor,$list_entrust);
- }
- View::assign('list_exterior', $list_exterior);
- return view();
- }
- public function getProjectFive()
- {
- $where = [
- ['name', '=', '作业日志-财政局'],
- ['name', '=', '工作记录-财政局'],
- ['name', '=', '项目报告-财政局'],
- ['name', '=', '项目人员-财政局'],
- ['name', '=', '项目动态-财政局'],
- ['name', '=', '项目附件-财政局'],
- ['name', '=', '联系函-财政局'],
- ];
- $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
- $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
- $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
- $login_rules = explode(',', $login_rules);
- $rules_id = array();
- foreach ($list as $key => $value) {
- if ($value['name'] == "作业日志-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_comments'] = 1;
- } else {
- $rules_id['project_comments'] = 0;
- }
- } else if ($value['name'] == "工作记录-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_record'] = 1;
- } else {
- $rules_id['project_record'] = 0;
- }
- } else if ($value['name'] == "项目报告-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_report'] = 1;
- } else {
- $rules_id['project_report'] = 0;
- }
- } else if ($value['name'] == "项目人员-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_user'] = 1;
- } else {
- $rules_id['project_user'] = 0;
- }
- } else if ($value['name'] == "项目动态-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_log'] = 1;
- } else {
- $rules_id['project_log'] = 0;
- }
- } else if ($value['name'] == "项目附件-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_file'] = 1;
- } else {
- $rules_id['project_file'] = 0;
- }
- } else if ($value['name'] == "联系函-财政局") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_contact'] = 1;
- } else {
- $rules_id['project_contact'] = 0;
- }
- }
- }
- return $rules_id;
- }
- public function getProjectFiveCompany()
- {
- $where = [
- ['name', '=', '作业日志-公司'],
- ['name', '=', '工作记录-公司'],
- ['name', '=', '项目报告-公司'],
- ['name', '=', '项目人员-公司'],
- ['name', '=', '项目动态-公司'],
- ['name', '=', '项目附件-公司'],
- ['name', '=', '联系函-公司'],
- ];
- $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
- $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
- $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
- $login_rules = explode(',', $login_rules);
- $rules_id = array();
- foreach ($list as $key => $value) {
- if ($value['name'] == "作业日志-公司") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_comments'] = 1;
- } else {
- $rules_id['project_comments'] = 0;
- }
- } else if ($value['name'] == "工作记录-公司") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_record'] = 1;
- } else {
- $rules_id['project_record'] = 0;
- }
- } else if ($value['name'] == "项目报告-公司") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_report'] = 1;
- } else {
- $rules_id['project_report'] = 0;
- }
- } else if ($value['name'] == "项目人员-公司") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_user'] = 1;
- } else {
- $rules_id['project_user'] = 0;
- }
- } else if ($value['name'] == "项目动态-公司") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_log'] = 1;
- } else {
- $rules_id['project_log'] = 0;
- }
- } else if ($value['name'] == "项目附件-公司") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_file'] = 1;
- } else {
- $rules_id['project_file'] = 0;
- }
- } else if ($value['name'] == "联系函-公司") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_contact'] = 1;
- } else {
- $rules_id['project_contact'] = 0;
- }
- }
- }
- return $rules_id;
- }
- public function getProjectFiveYezhu()
- {
- $where = [
- ['name', '=', '作业日志-业主'],
- ['name', '=', '工作记录-业主'],
- ['name', '=', '项目报告-业主'],
- ['name', '=', '项目人员-业主'],
- ['name', '=', '项目动态-业主'],
- ['name', '=', '项目附件-业主'],
- ['name', '=', '联系函-业主'],
- ];
- $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
- $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
- $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
- $login_rules = explode(',', $login_rules);
- $rules_id = array();
- foreach ($list as $key => $value) {
- if ($value['name'] == "作业日志-业主") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_comments'] = 1;
- } else {
- $rules_id['project_comments'] = 0;
- }
- } else if ($value['name'] == "工作记录-业主") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_record'] = 1;
- } else {
- $rules_id['project_record'] = 0;
- }
- } else if ($value['name'] == "项目报告-业主") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_report'] = 1;
- } else {
- $rules_id['project_report'] = 0;
- }
- } else if ($value['name'] == "项目人员-业主") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_user'] = 1;
- } else {
- $rules_id['project_user'] = 0;
- }
- } else if ($value['name'] == "项目动态-业主") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_log'] = 1;
- } else {
- $rules_id['project_log'] = 0;
- }
- } else if ($value['name'] == "项目附件-业主") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_file'] = 1;
- } else {
- $rules_id['project_file'] = 0;
- }
- } else if ($value['name'] == "联系函-业主") {
- if (in_array($value['id'], $login_rules)) {
- $rules_id['project_contact'] = 1;
- } else {
- $rules_id['project_contact'] = 0;
- }
- }
- }
- return $rules_id;
- }
- public function read_company()
- {
- $param = get_params();
- $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
- // halt($param);
- $a = time();
- $id = isset($param["project_id"]) ? $param["project_id"] : $a;
- if ($id == $a) {
- $datas = array();
- $datas["data"] = null;
- return table_assign(0, "无项目", $datas);
- }
- $project = Db::name("appropriation_project")->where("uid", $id)->select();
- $datas["data"] = $project;
- $datas["total"] = count($project);
- if ($param["type"] > 9) {
- $a = time();
- $id = isset($param["project_id"]) ? $param["project_id"] : $a;
- $detail = Db::name("appropriation")->where("id", $id)->find();
- $file_array = Db::name('ProjectFile')
- ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
- ->alias('mf')
- ->join('File f', 'mf.file_id = f.id', 'LEFT')
- ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
- ->order('mf.create_time desc')
- ->where(array('mf.topic_id' => $id, 'mf.module' => 'appropriation'))
- ->select()->toArray();
- $where = [
- ["approver", "=", $this->uid],
- ["audit_status", "<", 5]
- ];
- $list = $this->Auditmodel->alias("a")->join("cost_project c", "a.project_id=c.id", "left")
- ->where($where)->where('audit_status',1)->where('audit_type','in',[10,11,12])
- ->field("a.*,c.project_num,c.project_status,c.engineering_type,c.sent_review_amount")
- ->paginate(9999, false, ['query' => $param])
- ->each(function ($item, $key) {
- $item->approver_name = Db::name("admin")->where("id", $item->approver)->value("nickname");
- })->toArray();
- // halt($list);
- $red = 0;
- foreach ($list["data"] as $item => $value) {
- if ($value["audit_status"] == 1) {
- $red = 1;
- }
- }
- $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
- $red_kan = 0;
- foreach ($red_id as $item => $value) {
- if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
- $red_kan = 1;
- }
- }
- if($unit_type == 2){
- $auditdata = $this->Auditmodel->where('id',$param['id'])->find();
- $detail['audit_status'] = $auditdata['audit_status'];
- View::assign('auditdata', $auditdata);
- }else{
- $detail['audit_status'] = 0;
- }
- // halt($audit_status,$id);
- // halt($list);
- View::assign('unit_type', $unit_type);
- View::assign('datas', $datas['data']);
- View::assign('id', $id);
- View::assign('detail', $detail);
- View::assign("red_kan", $red_kan);
- View::assign('red', $red);
- View::assign('file_array', $file_array);
- return view();
- }
- }
- public function datastat(){
- return View();
- }
- public function contract()
- {
- return view();
- }
- public function contract_detail()
- {
- return view();
- }
- public function data_statistics($today = 2024)
- {
- $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
- if($unit_type == 2){
- $all_sent_review_cost_company = $this->Datastat->sent_review_cost_company($today);
- $review_poportion_company = $this->Datastat->review_poportion_company();
- $sent_poportion_company = $this->Datastat->sent_poportion_company();
- View::assign('all_sent_review_cost_company', $all_sent_review_cost_company);
- View::assign('review_poportion_company', $review_poportion_company);
- View::assign('sent_poportion_company', $sent_poportion_company);
- }elseif($unit_type == 0){
- $all_sent_review_cost = $this->Datastat->sent_review_cost($today);
- $review_poportion = $this->Datastat->review_poportion();
- $sent_poportion = $this->Datastat->sent_poportion();
- View::assign('sent', $all_sent_review_cost);
- View::assign('review_poportion', $review_poportion);
- View::assign('sent_poportion', $sent_poportion);
- }
- View::assign('unit_type', $unit_type);
- return view();
- }
- public function data_statistics_member($today = 2024)
- {
- $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
- $cost_project_member = $this->Datastat->cost_project_member($today);
- $cost_month_member = $this->Datastat->cost_month_member($today);
- View::assign('unit_type', $unit_type);
- View::assign('cost_project_member', $cost_project_member);
- View::assign('cost_month_member', $cost_month_member);
- return View();
- }
- }
|