asusg_settings_task_edit.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. $post = \Yii::$app->request->post();
  136. $mycompany = getCompanyByAccount($id);
  137. if (!isset($companyID))
  138. {
  139. // echo "ses com ".$_SESSION['company'];
  140. if ($_SESSION['company'])
  141. $companyID = $_SESSION['company'];
  142. else
  143. {
  144. $companyID = $mycompany[0];
  145. $_SESSION['company'] = $companyID;
  146. }
  147. }
  148. else
  149. {
  150. $_SESSION['company'] = $companyID;
  151. }
  152. $companyname = getCompanyByID($companyID)[1];
  153. if ((int)$_POST['appMykey'] == 123465) {$logged_me_in_successfully234 = 1;}
  154. if ($logged_me_in_successfully234 == 0)
  155. {
  156. echo "<center>";
  157. GetEnterForm();
  158. echo("<font color='red'><b>Access denied. Incorrect login or password</b><font>");
  159. echo "</center>";
  160. return;
  161. }
  162. $asusgProjectEntity = \app\models\entity\AsusgProject::find()->orderBy(['id' => SORT_DESC])->all();
  163. //$asusgTaskTemplatesEntity = \app\models\entity\AsusgTasktemplate::find()->orderBy(['id' => SORT_ASC])->all();
  164. //$asusgEmployeeEntity = \app\models\entity\AsusgEmployee::find()->orderBy(['name' => SORT_ASC])->all();
  165. //$asusgJobplanEntity = \app\models\entity\AsusgJobplan::find()->orderBy(['name' => SORT_ASC])->all();
  166. if ( null != $post['typefix'] and null != $post['loco_seria']) {
  167. $asusgProjectTypeEntity = \app\models\entity\AsusgProjectType::findOne(['repair_type' => $post['typefix'], 'loco_serie_id' => $post['loco_seria']]);
  168. //$asusgJob2ProjectEntity = \app\models\entity\AsusgJob2Project::find()->where(['asusg_projecttype_id' => $post['typefix'], 'asusg_jobplan_id' => $post['loco_seria']])->orderBy(['job_order' => SORT_ASC])->all();
  169. } else {
  170. //$asusgJob2ProjectEntity = \app\models\entity\AsusgJob2Project::find()->orderBy(['job_order' => SORT_ASC])->all();
  171. }
  172. //$tasktypesEntity = \app\models\entity\Tasktypes::find()->where(['main_task' => 0,'company' => $companyID])->orderBy(['name' => SORT_ASC])->all();
  173. //$locomotiveSeriesEntity = \app\models\entity\LocomotiveSeries::find()->orderBy(['name' => SORT_ASC])->all();
  174. $typeFix = ['1' => 'TO-1','2' => 'TO-2','3' => 'TO-3','4' => 'TO-4','5' => 'TO-5',];
  175. //$projectsLocotechEntity = getLocomotiveList();
  176. //$projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(["!=", "uuid" , ''])->all();
  177. //$series = LocoSeries::GetAllNames();
  178. ?>
  179. <!-- HTML -->
  180. <div class="wrapper">
  181. <header class="main-header">
  182. <!-- Logo -->
  183. <a href="/asusg_plan.php" class="logo">
  184. <!-- mini logo for sidebar mini 50x50 pixels -->
  185. <span class="logo-mini"><b>A</b>LT</span>
  186. <!-- logo for regular state and mobile devices -->
  187. <span class="logo-lg"><b>АСУ</b>СГ</span>
  188. </a>
  189. <!-- Header Navbar: style can be found in header.less -->
  190. <nav class="navbar navbar-static-top">
  191. <!-- Sidebar toggle button-->
  192. <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
  193. <span class="sr-only">Toggle navigation</span>
  194. </a>
  195. </nav>
  196. </header>
  197. <aside class="main-sidebar">
  198. <section class="sidebar">
  199. <form action="#" method="get" class="sidebar-form">
  200. <div class="input-group">
  201. <input type="text" name="q" class="form-control" placeholder="Search...">
  202. <span class="input-group-btn">
  203. <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
  204. </button>
  205. </span>
  206. </div>
  207. </form>
  208. <?php require_once 'asusg_menu.php';?>
  209. </section>
  210. </aside>
  211. <div class="content-wrapper">
  212. <section class="content-header">
  213. <h1>Список проектов</h1>
  214. <!--<ol class="breadcrumb">
  215. <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
  216. <li class="active">Dashboard</li>
  217. </ol>-->
  218. </section>
  219. <section class="content">
  220. <div class="row">
  221. <div class="col-md-12">
  222. <div class="nav-tabs-custom">
  223. <!--<ul class="nav nav-tabs">
  224. <li class="active"><a href="#tab_1" data-toggle="tab">Новый вариант</a></li>
  225. <li><a href="#tab_2" data-toggle="tab">Альтернативный вариант</a></li>
  226. <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
  227. </ul>-->
  228. <div class="tab-content">
  229. <!-- НАЧАЛО ПЕРВОЙ ВКЛАДКИ -->
  230. <div class="tab-pane active" id="tab_1">
  231. <div class="row">
  232. <!--h2>Список проектов</h2-->
  233. <ul>
  234. <? foreach( $asusgProjectEntity as $project):?>
  235. <? if ( 1 == $project->status) :?>
  236. <a href="/asusg_settings_task.php?id=<?php echo $project->id;?>&status=1"><li><i class="fa fa-edit"></i> Проект № <?php echo $project->id . ', <b>тип</b>: ' . $project->repairtypes->name . ', <b>серия</b>: ' . $project->locomotiveSeries->name. ', <b>номер</b>: ' . $project->loco_number ;?> </li></a>
  237. <br>
  238. <? else:?>
  239. <a href="/asusg_settings_task_cmpl.php?id=<?php echo $project->id;?>&status=2"><li><i class="fa fa-eye"></i> Проект № <?php echo $project->id . ', <b>тип</b>: ' . $project->repairtypes->name . ', <b>серия</b>: ' . $project->locomotiveSeries->name. ', <b>номер</b>: ' . $project->loco_number;?> </li> </a>
  240. <br>
  241. <? endif;?>
  242. <? endforeach;?>
  243. <ul>
  244. </div>
  245. </div>
  246. <!-- КОНЕЦ ПЕРВОЙ ВКЛАДКИ -->
  247. <!-- НАЧАЛО ВТОРОЙ ВКЛАДКИ -->
  248. <div class="tab-pane" id="tab_2">
  249. </div>
  250. <!-- КОНЕЦ ВТОРОЙ ВКЛАДКИ -->
  251. </div>
  252. </div>
  253. </div>
  254. </div>
  255. </section>
  256. <!-- /.content -->
  257. </div>
  258. <!-- /.content-wrapper -->
  259. <footer class="main-footer">
  260. </footer>
  261. <!-- Add the sidebar's background. This div must be placed
  262. immediately after the control sidebar -->
  263. <div class="control-sidebar-bg"></div>
  264. </div>
  265. <!-- End Document
  266. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  267. <script src="/lte/bower_components/jquery/dist/jquery.min.js"></script>
  268. <!-- jQuery UI 1.11.4 -->
  269. <script src="/lte/bower_components/jquery-ui/jquery-ui.min.js"></script>
  270. <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  271. <script>
  272. $.widget.bridge('uibutton', $.ui.button);
  273. </script>
  274. <!-- Bootstrap 3.3.7 -->
  275. <script src="/lte/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  276. <!-- Morris.js charts -->
  277. <script src="/lte/bower_components/raphael/raphael.min.js"></script>
  278. <script src="/lte/bower_components/morris.js/morris.min.js"></script>
  279. <!-- Sparkline -->
  280. <script src="/lte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
  281. <!-- jvectormap -->
  282. <script src="/lte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
  283. <script src="/lte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
  284. <!-- jQuery Knob Chart -->
  285. <script src="/lte/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
  286. <!-- daterangepicker -->
  287. <script src="/lte/bower_components/moment/min/moment.min.js"></script>
  288. <script src="/lte/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
  289. <!-- datepicker -->
  290. <script src="/lte/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
  291. <!-- Bootstrap WYSIHTML5 -->
  292. <script src="/lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
  293. <!-- Slimscroll -->
  294. <script src="/lte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
  295. <!-- FastClick -->
  296. <script src="/lte/bower_components/fastclick/lib/fastclick.js"></script>
  297. <!-- AdminLTE App -->
  298. <script src="/lte/dist/js/adminlte.min.js"></script>
  299. <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
  300. <script src="/lte/dist/js/pages/dashboard.js"></script>
  301. <!-- AdminLTE for demo purposes -->
  302. <script src="/lte/dist/js/demo.js"></script>
  303. <script src="/loco.js"></script>
  304. <script src="/mail.js"></script>
  305. <script src="/lte/bower_components/select2/dist/js/select2.full.min.js"></script>
  306. <script>
  307. $( function() {
  308. $( ".sortable" ).sortable();
  309. $( ".sortable" ).disableSelection();
  310. } );
  311. </script>
  312. </body>
  313. </html>
  314. <?php
  315. function GetEnterForm()
  316. {
  317. echo "<article>
  318. <form method='post' action='?login'>
  319. <table>
  320. <tr>
  321. <td width=70>
  322. <b>Login</b>
  323. </td>
  324. <td>
  325. &nbsp;
  326. </td>
  327. <td>
  328. <input type='text' name=login value=''><br/>
  329. </td>
  330. </tr>
  331. <tr>
  332. <td>
  333. <b>Password </b>
  334. </td>
  335. <td>
  336. &nbsp;
  337. </td>
  338. <td>
  339. <input type='password' name=pass value=''>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td></td>
  344. <td>&nbsp;</td>
  345. <td>
  346. <input type='submit' value='Enter'>
  347. </td>
  348. </tr>
  349. </table>
  350. </form>
  351. </article>";
  352. }
  353. function getLocomotiveList(){
  354. $result = [];
  355. //var_dump($companyID);
  356. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(['company' => 2] )->orderBy(['id' => SORT_DESC])->all();
  357. $listArray = [];
  358. foreach( $projectsLocotechEntity as $item){ //var_dump($item->projecttypes->name);echo "\n";
  359. //$tempArray = GetTasksForProject($item->id);
  360. $status = GetProjectStatus($item->id);
  361. if ($status != 2 && $status != 1) {continue;}
  362. $countDone = ['done' => 0, 'all' => 0 ];
  363. foreach( GetTasksForProject($item->id) as $proj) { //var_dump($proj);echo "<br>";
  364. $countDone['all']++;
  365. $tempArray = $proj;
  366. $tempArray['status'] = CheckAcceptedStatus($proj);
  367. $tempArray['name'] = GetTaskNameAndDesc($proj['type'])[0];
  368. //$tempArray['listAccounts'] = $this->getAccountListForTask($proj['type']);
  369. if ( 5 == $tempArray['status'] ) {$countDone['done']++;}
  370. //$countDone['all'] ." / " . $countDone['done'];
  371. $listArray[] = $tempArray;
  372. }
  373. $result[$item->id]['countDone'] = [ 'done' => $countDone['done'], 'all' => $countDone['all'] ];
  374. //$tempArray['name'] = GetTaskNameAndDesc($tempArray['type'])[0];
  375. $result[$item->id]['arr'] = $listArray;//GetTasksForProject($item->id);
  376. $result[$item->id]['obj'] = $item;
  377. $listArray = [];
  378. }
  379. //exit;
  380. return $result;
  381. }
  382. function CheckAcceptedStatus($task) {
  383. $result = false;
  384. $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
  385. from (select count(t.id) as total,
  386. sum(if(t.accepted_time is not null, 1, 0)) as accepted,
  387. sum(if(t.finished_time is not null, 1, 0)) as finished,
  388. sum(if(t.finished_time is null, if(timestampdiff(MINUTE, t.accepted_time, NOW()) > tt.time_to_complete_minutes, 1, 0), 0)) as attention
  389. from tasks t
  390. right join tasktypes tt on t.type = tt.id
  391. where t.parent_id = ".$task['id'].") tx;";
  392. $result = \Yii::$app->db->createCommand($query)->queryAll();
  393. $result = $result[0]["taskstatus"];
  394. return $result;
  395. }
  396. ?>