asusg_build_project.php 25 KB

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