123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535 |
- <?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\Appointment as AppointmentModel;
- 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->AppointmentModel = new AppointmentModel();
- $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;
- }
- $appointmentList = $this->AppointmentModel->where("project_id",$id)->paginate(9999, false, ['query' => $param])
- ->each(function ($item) {
- if($item->sponsor_unit==get_login_admin("unit_name")){
- $item->operate = false;
- }else{
- $item->operate = true;
- }
- });;
- // halt($appointmentList->toArray());
- View::assign('field', $fields);
- if (!empty($detail)) {
- View::assign('appointmentList', $appointmentList);
- 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();
- }
- }
|