asusg_settings_employees.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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>ASUS</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()->all();
  162. $accountsEntity = \app\models\entity\Accounts::find()->orderBy(['name' => SORT_ASC])->all();
  163. $asusgEmployeeEntity = \app\models\entity\AsusgEmployee::find()->orderBy(['name' => SORT_ASC])->all();
  164. $asusgJobplanEntity = \app\models\entity\AsusgJobplan::find()->orderBy(['name' => SORT_ASC])->all();
  165. $tasksEntity = \app\models\entity\Tasktypes::find()->where(['main_task' => 1])->orderBy(['name' => SORT_ASC])->all();
  166. //$tasksEntity = \app\models\entity\Tasks::find()->all();
  167. //$projectsLocotechEntity = getLocomotiveList();
  168. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(["!=", "uuid" , ''])->all();
  169. $series = LocoSeries::GetAllNames();
  170. $subtasks=0;
  171. ?>
  172. <!-- HTML -->
  173. <div class="wrapper">
  174. <header class="main-header">
  175. <!-- Logo -->
  176. <a href="/asusg_plan.php" class="logo">
  177. <!-- mini logo for sidebar mini 50x50 pixels -->
  178. <span class="logo-mini"><b>A</b>LT</span>
  179. <!-- logo for regular state and mobile devices -->
  180. <span class="logo-lg"><b>АСУ</b>СГ</span>
  181. </a>
  182. <!-- Header Navbar: style can be found in header.less -->
  183. <nav class="navbar navbar-static-top">
  184. <!-- Sidebar toggle button-->
  185. <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
  186. <span class="sr-only">Toggle navigation</span>
  187. </a>
  188. </nav>
  189. </header>
  190. <!-- Left side column. contains the logo and sidebar -->
  191. <aside class="main-sidebar">
  192. <!-- sidebar: style can be found in sidebar.less -->
  193. <section class="sidebar">
  194. <!-- Sidebar user panel -->
  195. <!-- search form -->
  196. <form action="#" method="get" class="sidebar-form">
  197. <div class="input-group">
  198. <input type="text" name="q" class="form-control" placeholder="Search...">
  199. <span class="input-group-btn">
  200. <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
  201. </button>
  202. </span>
  203. </div>
  204. </form>
  205. <!-- /.search form -->
  206. <!-- sidebar menu: : style can be found in sidebar.less -->
  207. <ul class="sidebar-menu" data-widget="tree">
  208. <li class="header">Главное меню</li>
  209. <li class="active treeview">
  210. <a href="#">
  211. <i class="fa fa-dashboard"></i> <span>Настройки</span>
  212. <span class="pull-right-container">
  213. <i class="fa fa-angle-left pull-right"></i>
  214. </span>
  215. </a>
  216. <ul class="treeview-menu">
  217. <li class="active"><a href="asusg_settings.php"><i class="fa fa-circle-o"></i>Соответствие работ</a></li>
  218. <li><a href="asusg_settings_employees.php"><i class="fa fa-circle-o"></i>Cоответствие сотрудников</a></li>
  219. </ul>
  220. </li>
  221. </ul>
  222. </section>
  223. <!-- /.sidebar -->
  224. </aside>
  225. <!-- Content Wrapper. Contains page content -->
  226. <div class="content-wrapper">
  227. <!-- Content Header (Page header) -->
  228. <section class="content-header">
  229. <h1>
  230. Страница настройки маппинга
  231. </h1>
  232. <ol class="breadcrumb">
  233. <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
  234. <li class="active">Dashboard</li>
  235. </ol>
  236. </section>
  237. <!-- Main content -->
  238. <section class="content">
  239. <div class="row">
  240. <div class="col-xs-12">
  241. <div class="box">
  242. <div class="box-header">
  243. <h3 class="box-title">Список сотрудников</h3>
  244. </div>
  245. <!-- /.box-header -->
  246. <div class="box-body">
  247. <table id="example2" class="table table-bordered table-hover">
  248. <thead>
  249. <tr>
  250. <th style="width: 520px;">Сотрудник АСУ СГ</th>
  251. <th style="width: 280px;">ИД сотрудника АСУ СГ</th>
  252. <th>Привязка SMoPP</th>
  253. </tr>
  254. </thead>
  255. <tbody>
  256. <? foreach($asusgEmployeeEntity as $employee):?>
  257. <tr>
  258. <td><?php echo "[". $employee->id."] " . $employee->name?></td>
  259. <td><?php echo $employee->asu_id;?>
  260. </td>
  261. <td>
  262. <div class="row">
  263. <div class="col-xs-5">
  264. <div class="form-group">
  265. <label>ИД сотрудника SMOPP</label>
  266. <select id="selectBindEmployee_<?php echo $employee->asu_id;?>" class="form-control select2" style="width: 100%;">
  267. <? foreach( $accountsEntity as $empl):?>
  268. <option <?php echo ($employee->smopp_id == $empl->id)?'selected=selected':'';?> value="<?php echo $empl->id;?>"><?php echo $empl->name?></option>
  269. <? endforeach;?>
  270. </select>
  271. </div>
  272. </div>
  273. <div class="col-xs-5 col-xs-offset-2">
  274. <div class="form-group">
  275. <label for="exampleInputEmail1">#</label>
  276. <button type="button" data_id="<?php echo $employee->asu_id;?>" class="btn btn-block btn-primary selectBindEmployee">Привязать</button>
  277. </div>
  278. </div>
  279. </div>
  280. </td>
  281. </tr>
  282. <? endforeach;?>
  283. </tbody>
  284. </table>
  285. </div>
  286. <!-- /.box-body -->
  287. </div>
  288. </div>
  289. <!-- /.box -->
  290. </div>
  291. </div>
  292. </section>
  293. <!-- /.content -->
  294. </div>
  295. <!-- /.content-wrapper -->
  296. <footer class="main-footer">
  297. </footer>
  298. <!-- Add the sidebar's background. This div must be placed
  299. immediately after the control sidebar -->
  300. <div class="control-sidebar-bg"></div>
  301. </div>
  302. <!-- HTML -->
  303. <!-- End Document
  304. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  305. <script src="/lte/bower_components/jquery/dist/jquery.min.js"></script>
  306. <!-- jQuery UI 1.11.4 -->
  307. <script src="/lte/bower_components/jquery-ui/jquery-ui.min.js"></script>
  308. <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  309. <script>
  310. $.widget.bridge('uibutton', $.ui.button);
  311. </script>
  312. <!-- Bootstrap 3.3.7 -->
  313. <script src="/lte/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  314. <!-- Morris.js charts -->
  315. <script src="/lte/bower_components/raphael/raphael.min.js"></script>
  316. <script src="/lte/bower_components/morris.js/morris.min.js"></script>
  317. <!-- Sparkline -->
  318. <script src="/lte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
  319. <!-- jvectormap -->
  320. <script src="/lte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
  321. <script src="/lte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
  322. <!-- jQuery Knob Chart -->
  323. <script src="/lte/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
  324. <!-- daterangepicker -->
  325. <script src="/lte/bower_components/moment/min/moment.min.js"></script>
  326. <script src="/lte/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
  327. <!-- datepicker -->
  328. <script src="/lte/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
  329. <!-- Bootstrap WYSIHTML5 -->
  330. <script src="/lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
  331. <!-- Slimscroll -->
  332. <script src="/lte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
  333. <!-- FastClick -->
  334. <script src="/lte/bower_components/fastclick/lib/fastclick.js"></script>
  335. <!-- AdminLTE App -->
  336. <script src="/lte/dist/js/adminlte.min.js"></script>
  337. <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
  338. <script src="/lte/dist/js/pages/dashboard.js"></script>
  339. <!-- AdminLTE for demo purposes -->
  340. <script src="/lte/dist/js/demo.js"></script>
  341. <script src="/loco.js"></script>
  342. <script src="/mail.js"></script>
  343. <script src="/lte/bower_components/select2/dist/js/select2.full.min.js"></script>
  344. </body>
  345. </html>
  346. <?php
  347. function GetEnterForm()
  348. {
  349. echo "<article>
  350. <form method='post' action='?login'>
  351. <table>
  352. <tr>
  353. <td width=70>
  354. <b>Login</b>
  355. </td>
  356. <td>
  357. &nbsp;
  358. </td>
  359. <td>
  360. <input type='text' name=login value=''><br/>
  361. </td>
  362. </tr>
  363. <tr>
  364. <td>
  365. <b>Password </b>
  366. </td>
  367. <td>
  368. &nbsp;
  369. </td>
  370. <td>
  371. <input type='password' name=pass value=''>
  372. </td>
  373. </tr>
  374. <tr>
  375. <td></td>
  376. <td>&nbsp;</td>
  377. <td>
  378. <input type='submit' value='Enter'>
  379. </td>
  380. </tr>
  381. </table>
  382. </form>
  383. </article>";
  384. }
  385. function getLocomotiveList(){
  386. $result = [];
  387. //var_dump($companyID);
  388. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(['company' => 2] )->orderBy(['id' => SORT_DESC])->all();
  389. $listArray = [];
  390. foreach( $projectsLocotechEntity as $item){ //var_dump($item->projecttypes->name);echo "\n";
  391. //$tempArray = GetTasksForProject($item->id);
  392. $status = GetProjectStatus($item->id);
  393. if ($status != 2 && $status != 1) {continue;}
  394. $countDone = ['done' => 0, 'all' => 0 ];
  395. foreach( GetTasksForProject($item->id) as $proj) { //var_dump($proj);echo "<br>";
  396. $countDone['all']++;
  397. $tempArray = $proj;
  398. $tempArray['status'] = CheckAcceptedStatus($proj);
  399. $tempArray['name'] = GetTaskNameAndDesc($proj['type'])[0];
  400. //$tempArray['listAccounts'] = $this->getAccountListForTask($proj['type']);
  401. if ( 5 == $tempArray['status'] ) {$countDone['done']++;}
  402. //$countDone['all'] ." / " . $countDone['done'];
  403. $listArray[] = $tempArray;
  404. }
  405. $result[$item->id]['countDone'] = [ 'done' => $countDone['done'], 'all' => $countDone['all'] ];
  406. //$tempArray['name'] = GetTaskNameAndDesc($tempArray['type'])[0];
  407. $result[$item->id]['arr'] = $listArray;//GetTasksForProject($item->id);
  408. $result[$item->id]['obj'] = $item;
  409. $listArray = [];
  410. }
  411. //exit;
  412. return $result;
  413. }
  414. function CheckAcceptedStatus($task) {
  415. $result = false;
  416. $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
  417. from (select count(t.id) as total,
  418. sum(if(t.accepted_time is not null, 1, 0)) as accepted,
  419. sum(if(t.finished_time is not null, 1, 0)) as finished,
  420. sum(if(t.finished_time is null, if(timestampdiff(MINUTE, t.accepted_time, NOW()) > tt.time_to_complete_minutes, 1, 0), 0)) as attention
  421. from tasks t
  422. right join tasktypes tt on t.type = tt.id
  423. where t.parent_id = ".$task['id'].") tx;";
  424. $result = \Yii::$app->db->createCommand($query)->queryAll();
  425. $result = $result[0]["taskstatus"];
  426. return $result;
  427. }
  428. ?>