asusg_settings_mapping3.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <?php
  2. defined('YII_DEBUG') or define('YII_DEBUG', true);
  3. defined('YII_ENV') or define('YII_ENV', 'dev');
  4. require __DIR__ . '/api/vendor/autoload.php';
  5. require __DIR__ . '/api/vendor/yiisoft/yii2/Yii.php';
  6. $config = require __DIR__ . '/api/config/web.php';
  7. (new yii\web\Application($config));
  8. require_once "doctrine/bootstrap.php";
  9. include 'CheckPoint.php';
  10. include 'CheckPointType.php';
  11. use CheckPoints\CheckPoint;
  12. use CheckPointTypes\CheckPointType;
  13. header("Expires: 0");
  14. header("Content-Type: text/html; charset=utf-8");
  15. session_start();
  16. if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 6000)) {
  17. // last request was more than 30 minutes ago
  18. session_unset(); // unset $_SESSION variable for the run-time
  19. session_destroy(); // destroy session data in storage
  20. }
  21. $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
  22. $add = 'Login Area';
  23. foreach (array_keys($_REQUEST) as $var) {
  24. ${$var} = $_REQUEST[$var];
  25. //if ($name == "Admin12") {
  26. // echo "<b>$var:</b> ${$var} <br>";
  27. //}
  28. }
  29. if ($act == "exit")
  30. {
  31. session_unset();
  32. session_destroy();
  33. session_start();
  34. }
  35. if ($_SESSION['cmdlevel'])
  36. $cmdlevel = $_SESSION['cmdlevel'];
  37. if ($_SESSION['hostid'])
  38. $agent_id = $_SESSION['hostid'];
  39. if ($_SESSION['add'])
  40. $add = $_SESSION['add'];
  41. if ($_SESSION['id'])
  42. $id = $_SESSION['id'];
  43. if ($_SESSION['login'])
  44. $login = $_SESSION['login'];
  45. if ($_SESSION['name'])
  46. $name = $_SESSION['name'];
  47. foreach (array_keys($_SESSION) as $var) {
  48. ${$var} = $_SESSION[$var];
  49. //if ($name == "Admin12") {
  50. //echo "from session: <b>$var:</b> ${$var} <br>";
  51. //}
  52. }
  53. include 'functions.php';
  54. include 'auth.php';
  55. $logged_me_in_successfully234 = 0;
  56. $incl = '';
  57. if (!$_SESSION['pass'] && !$_SESSION['login'])
  58. {
  59. $table = 'accounts';
  60. $result=mysqli_query($link, "SELECT id, login, name, cmdlevel FROM $table WHERE login='".$login."' AND password='".md5($pass)."'");
  61. $res1 = mysqli_fetch_array($result);
  62. $cmdlevel = $res1['cmdlevel'];
  63. $name = $res1['name'];
  64. $id = $res1['id'];
  65. if ($cmdlevel == '10')
  66. {
  67. $add = "Head Administrator";
  68. }
  69. else if ($cmdlevel == '1')
  70. {
  71. $add = "Company Administrator";
  72. }
  73. else if ($cmdlevel == '2')
  74. {
  75. $add = "Company Operator";
  76. }
  77. if (mysqli_num_rows($result))
  78. {
  79. $_SESSION['pass']=$pass;
  80. $_SESSION['login']=$login;
  81. $_SESSION['name']=$name;
  82. $_SESSION['add']=$add;
  83. $_SESSION['cmdlevel']=$cmdlevel;
  84. $_SESSION['id']=$id;
  85. $logged_me_in_successfully234 = 1;
  86. }
  87. }
  88. else
  89. $logged_me_in_successfully234 = 1;
  90. $query = mysqli_query($link, "update accounts set last_seen_web =NOW() where id=".$id);
  91. $getincl = GetInclude($act, intval($cmdlevel));
  92. $incl = $getincl[0];
  93. $accnum = $getincl[1];
  94. ?>
  95. <!DOCTYPE html>
  96. <html lang="en">
  97. <head>
  98. <!-- Basic Page Needs
  99. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  100. <meta charset="utf-8">
  101. <title>ASUSG</title>
  102. <meta name="description" content="">
  103. <meta name="author" content="">
  104. <!-- Mobile Specific Metas
  105. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  106. <meta name="viewport" content="width=device-width, initial-scale=1">
  107. <!-- FONT
  108. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  109. <link rel="stylesheet" href="/lte/bower_components/bootstrap/dist/css/bootstrap.min.css">
  110. <!-- Font Awesome -->
  111. <link rel="stylesheet" href="/lte/bower_components/font-awesome/css/font-awesome.min.css">
  112. <!-- Ionicons -->
  113. <link rel="stylesheet" href="/lte/bower_components/Ionicons/css/ionicons.min.css">
  114. <!-- Theme style -->
  115. <link rel="stylesheet" href="/lte/dist/css/AdminLTE.min.css">
  116. <!-- AdminLTE Skins. Choose a skin from the css/skins
  117. folder instead of downloading all of them to reduce the load. -->
  118. <link rel="stylesheet" href="/lte/dist/css/skins/_all-skins.min.css">
  119. <!-- Morris chart -->
  120. <link rel="stylesheet" href="/lte/bower_components/morris.js/morris.css">
  121. <!-- jvectormap -->
  122. <link rel="stylesheet" href="/lte/bower_components/jvectormap/jquery-jvectormap.css">
  123. <!-- Date Picker -->
  124. <link rel="stylesheet" href="/lte/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  125. <!-- Daterange picker -->
  126. <link rel="stylesheet" href="/lte/bower_components/bootstrap-daterangepicker/daterangepicker.css">
  127. <!-- bootstrap wysihtml5 - text editor -->
  128. <link rel="stylesheet" href="/lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
  129. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  130. <link rel="stylesheet" href="/lte/bower_components/select2/dist/css/select2.min.css">
  131. </head>
  132. <body onload="accon(<? echo $accnum;?>)" >
  133. <!--<div style="min-width: 960px; height: 100%;">-->
  134. <?
  135. $mycompany = getCompanyByAccount($id);
  136. if (!isset($companyID))
  137. {
  138. // echo "ses com ".$_SESSION['company'];
  139. if ($_SESSION['company'])
  140. $companyID = $_SESSION['company'];
  141. else
  142. {
  143. $companyID = $mycompany[0];
  144. $_SESSION['company'] = $companyID;
  145. }
  146. }
  147. else
  148. {
  149. $_SESSION['company'] = $companyID;
  150. }
  151. $companyname = getCompanyByID($companyID)[1];
  152. if ((int)$_POST['appMykey'] == 123465) {$logged_me_in_successfully234 = 1;}
  153. if ($logged_me_in_successfully234 == 0)
  154. {
  155. echo "<center>";
  156. GetEnterForm();
  157. echo("<font color='red'><b>Access denied. Incorrect login or password</b><font>");
  158. echo "</center>";
  159. return;
  160. }
  161. $asusgTaskTemplatesEntity = \app\models\entity\AsusgTasktemplate::find()->orderBy(['id' => SORT_ASC])->all();
  162. $asusgEmployeeEntity = \app\models\entity\AsusgEmployee::find()->orderBy(['name' => SORT_ASC])->all();
  163. $asusgJobplanEntity = \app\models\entity\AsusgJobplan::find()->orderBy(['name' => SORT_ASC])->all();
  164. $asusgJob2CommandEntity = \app\models\entity\AsusgJob2Command::find()->orderBy(['cmd_order' => SORT_ASC])->all();
  165. $tasktypesEntity = \app\models\entity\Tasktypes::find()->where(['main_task' => 0,'company' => $companyID])->orderBy(['name' => SORT_ASC])->all();
  166. //$locomotiveSeriesEntity = \app\models\entity\LocomotiveSeries::find()->orderBy(['name' => SORT_ASC])->all();
  167. //$projectsLocotechEntity = getLocomotiveList();
  168. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(["!=", "uuid" , ''])->all();
  169. //$series = LocoSeries::GetAllNames();
  170. ?>
  171. <!-- HTML -->
  172. <div class="wrapper">
  173. <header class="main-header">
  174. <!-- Logo -->
  175. <a href="/asusg_plan.php" class="logo">
  176. <!-- mini logo for sidebar mini 50x50 pixels -->
  177. <span class="logo-mini"><b>A</b>LT</span>
  178. <!-- logo for regular state and mobile devices -->
  179. <span class="logo-lg"><b>АСУ</b>СГ</span>
  180. </a>
  181. <!-- Header Navbar: style can be found in header.less -->
  182. <nav class="navbar navbar-static-top">
  183. <!-- Sidebar toggle button-->
  184. <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
  185. <span class="sr-only">Toggle navigation</span>
  186. </a>
  187. </nav>
  188. </header>
  189. <!-- Left side column. contains the logo and sidebar -->
  190. <aside class="main-sidebar">
  191. <!-- sidebar: style can be found in sidebar.less -->
  192. <section class="sidebar">
  193. <!-- Sidebar user panel -->
  194. <!-- search form -->
  195. <form action="#" method="get" class="sidebar-form">
  196. <div class="input-group">
  197. <input type="text" name="q" class="form-control" placeholder="Search...">
  198. <span class="input-group-btn">
  199. <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
  200. </button>
  201. </span>
  202. </div>
  203. </form>
  204. <!-- /.search form -->
  205. <!-- sidebar menu: : style can be found in sidebar.less -->
  206. <?php require_once 'asusg_menu.php';?>
  207. </section>
  208. <!-- /.sidebar -->
  209. </aside>
  210. <!-- Content Wrapper. Contains page content -->
  211. <div class="content-wrapper">
  212. <!-- Content Header (Page header) -->
  213. <section class="content-header">
  214. <h1>
  215. Список работ
  216. </h1>
  217. <ol class="breadcrumb">
  218. <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
  219. <li class="active">Dashboard</li>
  220. </ol>
  221. </section>
  222. <!-- Main content -->
  223. <section class="content">
  224. <div class="row">
  225. <!-- START CUSTOM TABS -->
  226. <div class="col-md-12">
  227. <!-- Custom Tabs -->
  228. <div class="nav-tabs-custom">
  229. <ul class="nav nav-tabs">
  230. <li class="active"><a href="#tab_1" data-toggle="tab">Новый вариант</a></li>
  231. <li><a href="#tab_2" data-toggle="tab">Альтернативный вариант</a></li>
  232. <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
  233. </ul>
  234. <div class="tab-content">
  235. <!-- НАЧАЛО ПЕРВОЙ ВКЛАДКИ -->
  236. <div class="tab-pane active" id="tab_1">
  237. <div class="row">
  238. <div class="col-xs-5">
  239. <? foreach( $asusgJobplanEntity as $template):?>
  240. <div class="box box-primary">
  241. <div class="box-header with-border">
  242. <h3 class="box-title"><?php echo $template->name?></h3>
  243. <div class="box-tools pull-right">
  244. <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
  245. </button>
  246. </div>
  247. </div>
  248. <div class="box-body">
  249. <div class="row">
  250. <div class="col-xs-5">
  251. <div class="form-group">
  252. <div class="form-group">
  253. <label for="exampleInputPassword1">Список команд</label>
  254. <select id="command_list_<?php echo $template->asusg_id?>" class="form-control select2" style="width: 100%;">
  255. <? foreach( $tasktypesEntity as $plan):?>
  256. <option data_id="<?php echo $plan->id?>_<?php echo $template->asusg_id;?>" value="<?php echo $plan->id?>"><?php echo $plan->name?></option>
  257. <? endforeach;?>
  258. </select>
  259. </div>
  260. </div>
  261. </div>
  262. <div class="col-xs-5 col-xs-offset-2">
  263. <div class="form-group">
  264. <label for="exampleInputPassword1">Привязать команду</label>
  265. <button type="button" class="btn btn-block btn-primary bindProjectTypes" data_id="<?php echo $template->asusg_id;?>">Привязать</button>
  266. <button type="button" class="btn btn-block btn-warning saveProjectTypes" data_id="<?php echo $template->asusg_id;?>">Сохранить</button>
  267. </div>
  268. </div>
  269. <div id="project_list_<?php echo $template->asusg_id?>">
  270. <? $query = "select projecttype_id from asusg_task2project where asusg_tasktemplate_id = " . $template->asusg_id . " and project_id is null";
  271. $res = Yii::$app->db->createCommand($query)->queryAll();
  272. if( 0 < count($res) ) {
  273. echo "<div class='box-body'><ul class='list-unstyled'>";
  274. foreach($res as $item){
  275. echo "<li>";
  276. echo "Проект №" . $item['projecttype_id']. " привязан.";
  277. echo "</li>";
  278. }
  279. echo "</ul></div>";
  280. }
  281. ?>
  282. </div>
  283. <div class="col-xs-8">
  284. <ul id="sortable" class="list-unstyled list_asusg_command_<?php echo $template->asusg_id;?> sortable">
  285. <? foreach ($asusgJob2CommandEntity as $item):?>
  286. <? if ($item->asusg_job_id == $template->asusg_id):?>
  287. <li id="li_<?php echo $template->asusg_id;?>_<?php echo $item->smopp_cmd_id;?>" class="ui-state-default" data_id="<?php echo $template->asusg_id;?>_<?php echo $item->smopp_cmd_id;?>"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
  288. <div class="box box-warning">
  289. <div class="box-header with-border">
  290. <h3 class="box-title"><?php echo $item->tasktypes->name;?></h3>
  291. <div class="box-tools pull-right">
  292. <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
  293. </button>
  294. <button type="button" class="btn btn-box-tool remove_command_button" data-widget="remove" data_id="<?php echo $template->asusg_id;?>_<?php echo $item->smopp_cmd_id;?>"><i class="fa fa-times"></i></button>
  295. </div>
  296. </div>
  297. </div>
  298. </li>
  299. <? endif;?>
  300. <? endforeach;?>
  301. </ul>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. <? endforeach;?>
  307. <div class="box">
  308. <!-- /.box-header -->
  309. <div class="box-body table-responsive ">
  310. <div class="form-group">
  311. <label>Укрупненные работы АСУ СГ</label>
  312. <select class="form-control select2" style="width: 100%;">
  313. <? foreach( $asusgTaskTemplatesEntity as $template):?>
  314. <option><?php echo $template->name?></option>
  315. <? endforeach;?>
  316. </select>
  317. </div>
  318. <div class="row">
  319. <div class="col-xs-3 col-xs-offset-9">
  320. <button type="button" class="btn btn-block btn-primary">Добавить</button>
  321. </div>
  322. </div>
  323. <div class="form-group">
  324. <label>Работы АСУ СГ</label>
  325. <select class="form-control select2" style="width: 100%;">
  326. <? foreach( $asusgJobplanEntity as $plan):?>
  327. <option><?php echo $plan->name?></option>
  328. <? endforeach;?>
  329. </select>
  330. </div>
  331. <div class="row">
  332. <div class="col-xs-3 col-xs-offset-9">
  333. <button type="button" class="btn btn-block btn-primary">Добавить</button>
  334. </div>
  335. </div>
  336. <div class="form-group">
  337. <label>Сотрудники</label>
  338. <select class="form-control select2" style="width: 100%;">
  339. <? foreach( $asusgEmployeeEntity as $employee):?>
  340. <option><?php echo $employee->name?></option>
  341. <? endforeach;?>
  342. </select>
  343. </div>
  344. <div class="row">
  345. <div class="col-xs-3 col-xs-offset-9">
  346. <button type="button" class="btn btn-block btn-primary">Добавить</button>
  347. </div>
  348. </div>
  349. </div>
  350. <!-- /.box-body -->
  351. </div>
  352. </div>
  353. <div class="col-xs-7">
  354. <div class="box">
  355. <!-- /.box-header -->
  356. </div>
  357. <!-- /.box-body -->
  358. </div>
  359. </div>
  360. </div>
  361. <!-- КОНЕЦ ПЕРВОЙ ВКЛАДКИ -->
  362. <!-- НАЧАЛО ВТОРОЙ ВКЛАДКИ -->
  363. <div class="tab-pane" id="tab_2">
  364. </div>
  365. <!-- КОНЕЦ ВТОРОЙ ВКЛАДКИ -->
  366. <!-- /.tab-pane -->
  367. </div>
  368. <!-- /.tab-content -->
  369. </div>
  370. <!-- nav-tabs-custom -->
  371. </div>
  372. <!-- /.row -->
  373. <!-- END CUSTOM TABS -->
  374. <!-- /.box -->
  375. </div>
  376. </div>
  377. </section>
  378. <!-- /.content -->
  379. </div>
  380. <!-- /.content-wrapper -->
  381. <footer class="main-footer">
  382. </footer>
  383. <!-- Add the sidebar's background. This div must be placed
  384. immediately after the control sidebar -->
  385. <div class="control-sidebar-bg"></div>
  386. </div>
  387. <!-- HTML -->
  388. <!-- End Document
  389. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  390. <script src="/lte/bower_components/jquery/dist/jquery.min.js"></script>
  391. <!-- jQuery UI 1.11.4 -->
  392. <script src="/lte/bower_components/jquery-ui/jquery-ui.min.js"></script>
  393. <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  394. <script>
  395. $.widget.bridge('uibutton', $.ui.button);
  396. </script>
  397. <!-- Bootstrap 3.3.7 -->
  398. <script src="/lte/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  399. <!-- Morris.js charts -->
  400. <script src="/lte/bower_components/raphael/raphael.min.js"></script>
  401. <script src="/lte/bower_components/morris.js/morris.min.js"></script>
  402. <!-- Sparkline -->
  403. <script src="/lte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
  404. <!-- jvectormap -->
  405. <script src="/lte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
  406. <script src="/lte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
  407. <!-- jQuery Knob Chart -->
  408. <script src="/lte/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
  409. <!-- daterangepicker -->
  410. <script src="/lte/bower_components/moment/min/moment.min.js"></script>
  411. <script src="/lte/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
  412. <!-- datepicker -->
  413. <script src="/lte/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
  414. <!-- Bootstrap WYSIHTML5 -->
  415. <script src="/lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
  416. <!-- Slimscroll -->
  417. <script src="/lte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
  418. <!-- FastClick -->
  419. <script src="/lte/bower_components/fastclick/lib/fastclick.js"></script>
  420. <!-- AdminLTE App -->
  421. <script src="/lte/dist/js/adminlte.min.js"></script>
  422. <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
  423. <script src="/lte/dist/js/pages/dashboard.js"></script>
  424. <!-- AdminLTE for demo purposes -->
  425. <script src="/lte/dist/js/demo.js"></script>
  426. <script src="/loco.js"></script>
  427. <script src="/mail.js"></script>
  428. <script src="/lte/bower_components/select2/dist/js/select2.full.min.js"></script>
  429. <script>
  430. $( function() {
  431. $( ".sortable" ).sortable();
  432. $( ".sortable" ).disableSelection();
  433. } );
  434. </script>
  435. </body>
  436. </html>
  437. <?php
  438. function GetEnterForm()
  439. {
  440. echo "<article>
  441. <form method='post' action='?login'>
  442. <table>
  443. <tr>
  444. <td width=70>
  445. <b>Login</b>
  446. </td>
  447. <td>
  448. &nbsp;
  449. </td>
  450. <td>
  451. <input type='text' name=login value=''><br/>
  452. </td>
  453. </tr>
  454. <tr>
  455. <td>
  456. <b>Password </b>
  457. </td>
  458. <td>
  459. &nbsp;
  460. </td>
  461. <td>
  462. <input type='password' name=pass value=''>
  463. </td>
  464. </tr>
  465. <tr>
  466. <td></td>
  467. <td>&nbsp;</td>
  468. <td>
  469. <input type='submit' value='Enter'>
  470. </td>
  471. </tr>
  472. </table>
  473. </form>
  474. </article>";
  475. }
  476. function getLocomotiveList(){
  477. $result = [];
  478. //var_dump($companyID);
  479. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(['company' => 2] )->orderBy(['id' => SORT_DESC])->all();
  480. $listArray = [];
  481. foreach( $projectsLocotechEntity as $item){ //var_dump($item->projecttypes->name);echo "\n";
  482. //$tempArray = GetTasksForProject($item->id);
  483. $status = GetProjectStatus($item->id);
  484. if ($status != 2 && $status != 1) {continue;}
  485. $countDone = ['done' => 0, 'all' => 0 ];
  486. foreach( GetTasksForProject($item->id) as $proj) { //var_dump($proj);echo "<br>";
  487. $countDone['all']++;
  488. $tempArray = $proj;
  489. $tempArray['status'] = CheckAcceptedStatus($proj);
  490. $tempArray['name'] = GetTaskNameAndDesc($proj['type'])[0];
  491. //$tempArray['listAccounts'] = $this->getAccountListForTask($proj['type']);
  492. if ( 5 == $tempArray['status'] ) {$countDone['done']++;}
  493. //$countDone['all'] ." / " . $countDone['done'];
  494. $listArray[] = $tempArray;
  495. }
  496. $result[$item->id]['countDone'] = [ 'done' => $countDone['done'], 'all' => $countDone['all'] ];
  497. //$tempArray['name'] = GetTaskNameAndDesc($tempArray['type'])[0];
  498. $result[$item->id]['arr'] = $listArray;//GetTasksForProject($item->id);
  499. $result[$item->id]['obj'] = $item;
  500. $listArray = [];
  501. }
  502. //exit;
  503. return $result;
  504. }
  505. function CheckAcceptedStatus($task) {
  506. $result = false;
  507. $query = "select if(tx.total = tx.finished, 5, if (tx.accepted <> tx.finished, if(tx.attention > 0, 7, 2), if (tx.accepted = 0, 1, 3))) as taskstatus
  508. from (select count(t.id) as total,
  509. sum(if(t.accepted_time is not null, 1, 0)) as accepted,
  510. sum(if(t.finished_time is not null, 1, 0)) as finished,
  511. sum(if(t.finished_time is null, if(timestampdiff(MINUTE, t.accepted_time, NOW()) > tt.time_to_complete_minutes, 1, 0), 0)) as attention
  512. from tasks t
  513. right join tasktypes tt on t.type = tt.id
  514. where t.parent_id = ".$task['id'].") tx;";
  515. $result = \Yii::$app->db->createCommand($query)->queryAll();
  516. $result = $result[0]["taskstatus"];
  517. return $result;
  518. }
  519. ?>