asusg_settings_mapping.php 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  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. require_once 'PHPExcel-1.8.2/Classes/PHPExcel.php';
  17. $url = explode('?',$_SERVER["REQUEST_URI"])[0];
  18. if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 6000)) {
  19. // last request was more than 30 minutes ago
  20. session_unset(); // unset $_SESSION variable for the run-time
  21. session_destroy(); // destroy session data in storage
  22. }
  23. $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
  24. $add = 'Login Area';
  25. foreach (array_keys($_REQUEST) as $var) {
  26. ${$var} = $_REQUEST[$var];
  27. //if ($name == "Admin12") {
  28. // echo "<b>$var:</b> ${$var} <br>";
  29. //}
  30. }
  31. if ($act == "exit")
  32. {
  33. session_unset();
  34. session_destroy();
  35. session_start();
  36. }
  37. if ($_SESSION['cmdlevel'])
  38. $cmdlevel = $_SESSION['cmdlevel'];
  39. if ($_SESSION['hostid'])
  40. $agent_id = $_SESSION['hostid'];
  41. if ($_SESSION['add'])
  42. $add = $_SESSION['add'];
  43. if ($_SESSION['id'])
  44. $id = $_SESSION['id'];
  45. if ($_SESSION['login'])
  46. $login = $_SESSION['login'];
  47. if ($_SESSION['name'])
  48. $name = $_SESSION['name'];
  49. foreach (array_keys($_SESSION) as $var) {
  50. ${$var} = $_SESSION[$var];
  51. //if ($name == "Admin12") {
  52. //echo "from session: <b>$var:</b> ${$var} <br>";
  53. //}
  54. }
  55. include 'functions.php';
  56. include 'auth.php';
  57. $logged_me_in_successfully234 = 0;
  58. $incl = '';
  59. if (!$_SESSION['pass'] && !$_SESSION['login'])
  60. {
  61. $table = 'accounts';
  62. $result=mysqli_query($link, "SELECT id, login, name, cmdlevel FROM $table WHERE login='".$login."' AND password='".md5($pass)."'");
  63. $res1 = mysqli_fetch_array($result);
  64. $cmdlevel = $res1['cmdlevel'];
  65. $name = $res1['name'];
  66. $id = $res1['id'];
  67. if ($cmdlevel == '10')
  68. {
  69. $add = "Head Administrator";
  70. }
  71. else if ($cmdlevel == '1')
  72. {
  73. $add = "Company Administrator";
  74. }
  75. else if ($cmdlevel == '2')
  76. {
  77. $add = "Company Operator";
  78. }
  79. if (mysqli_num_rows($result))
  80. {
  81. $_SESSION['pass']=$pass;
  82. $_SESSION['login']=$login;
  83. $_SESSION['name']=$name;
  84. $_SESSION['add']=$add;
  85. $_SESSION['cmdlevel']=$cmdlevel;
  86. $_SESSION['id']=$id;
  87. $logged_me_in_successfully234 = 1;
  88. }
  89. }
  90. else
  91. $logged_me_in_successfully234 = 1;
  92. $query = mysqli_query($link, "update accounts set last_seen_web =NOW() where id=".$id);
  93. $getincl = GetInclude($act, intval($cmdlevel));
  94. $incl = $getincl[0];
  95. $accnum = $getincl[1];
  96. ?>
  97. <!DOCTYPE html>
  98. <html lang="en">
  99. <head>
  100. <!-- Basic Page Needs
  101. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  102. <meta charset="utf-8">
  103. <title>ASUSG</title>
  104. <meta name="description" content="">
  105. <meta name="author" content="">
  106. <!-- Mobile Specific Metas
  107. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  108. <meta name="viewport" content="width=device-width, initial-scale=1">
  109. <!-- FONT
  110. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  111. <link rel="stylesheet" href="/lte/bower_components/bootstrap/dist/css/bootstrap.min.css">
  112. <!-- Font Awesome -->
  113. <link rel="stylesheet" href="/lte/bower_components/font-awesome/css/font-awesome.min.css">
  114. <!-- Ionicons -->
  115. <link rel="stylesheet" href="/lte/bower_components/Ionicons/css/ionicons.min.css">
  116. <!-- Theme style -->
  117. <link rel="stylesheet" href="/lte/dist/css/AdminLTE.min.css">
  118. <!-- AdminLTE Skins. Choose a skin from the css/skins
  119. folder instead of downloading all of them to reduce the load. -->
  120. <link rel="stylesheet" href="/lte/dist/css/skins/_all-skins.min.css">
  121. <!-- Morris chart -->
  122. <link rel="stylesheet" href="/lte/bower_components/morris.js/morris.css">
  123. <!-- jvectormap -->
  124. <link rel="stylesheet" href="/lte/bower_components/jvectormap/jquery-jvectormap.css">
  125. <!-- Date Picker -->
  126. <link rel="stylesheet" href="/lte/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  127. <!-- Daterange picker -->
  128. <link rel="stylesheet" href="/lte/bower_components/bootstrap-daterangepicker/daterangepicker.css">
  129. <!-- bootstrap wysihtml5 - text editor -->
  130. <link rel="stylesheet" href="/lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
  131. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  132. <link rel="stylesheet" href="/lte/bower_components/select2/dist/css/select2.min.css">
  133. </head>
  134. <body onload="accon(<? echo $accnum;?>)" >
  135. <!--<div style="min-width: 960px; height: 100%;">-->
  136. <?
  137. $mycompany = getCompanyByAccount($id);
  138. if (!isset($companyID))
  139. {
  140. // echo "ses com ".$_SESSION['company'];
  141. if ($_SESSION['company'])
  142. $companyID = $_SESSION['company'];
  143. else
  144. {
  145. $companyID = $mycompany[0];
  146. $_SESSION['company'] = $companyID;
  147. }
  148. }
  149. else
  150. {
  151. $_SESSION['company'] = $companyID;
  152. }
  153. $companyname = getCompanyByID($companyID)[1];
  154. if ((int)$_POST['appMykey'] == 123465) {$logged_me_in_successfully234 = 1;}
  155. if ($logged_me_in_successfully234 == 0)
  156. {
  157. echo "<center>";
  158. GetEnterForm();
  159. echo("<font color='red'><b>Access denied. Incorrect login or password</b><font>");
  160. echo "</center>";
  161. return;
  162. }
  163. $textlog2 = new \app\models\entity\Textlog();
  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 != $loco && null != $type ) {
  167. $asusgProjecttypeEntity = \app\models\entity\AsusgProjecttype::findOne(['loco_serie_id' => $loco, 'repair_type' => $type]);
  168. $asusgJob2CommandEntity = \app\models\entity\AsusgJob2Command::find()->where(['asusg_projecttype_id' => $asusgProjecttypeEntity->id])->orderBy(['cmd_order' => SORT_ASC])->all();
  169. } else {
  170. $asusgJob2CommandEntity = \app\models\entity\AsusgJob2Command::find()->orderBy(['cmd_order' => SORT_ASC])->all();
  171. }
  172. $tasktypesEntity = \app\models\entity\Tasktypes::find()->where(['main_task' => 0,'company' => $companyID])->orderBy(['name' => SORT_ASC])->all();
  173. $jobEntity = \app\models\entity\Jobtypes::find()->where(['company' => $companyID])->all();
  174. $locomotiveSeriesEntity = \app\models\entity\LocomotiveSeries::find()->orderBy(['name' => SORT_ASC])->all();
  175. $typeFix = \app\models\entity\Repairtypes::find()->all();
  176. $jobplanEntity = \app\models\entity\AsusgJobplan::findOne(['id'=> Yii::$app->request->get('asusgtask')]);
  177. //$locomotiveSeriesEntity = \app\models\entity\LocomotiveSeries::find()->orderBy(['name' => SORT_ASC])->all();
  178. //$projectsLocotechEntity = getLocomotiveList();
  179. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(["!=", "uuid" , ''])->all();
  180. //$series = LocoSeries::GetAllNames();
  181. //var_dump(\Yii::$app->request->post());
  182. //var_dump($_FILES);
  183. //var_dump((!empty($_FILES)));
  184. $loadFileError = '';
  185. if(!empty($_FILES) and isset($_FILES["nameXmlFile"]["tmp_name"])) {
  186. $filePath = $_FILES["nameXmlFile"]["tmp_name"];
  187. $textlog2->msg = 'user : '. $id .", fileName : " . $_FILES["nameXmlFile"]["name"];
  188. $textlog2->save();
  189. $arrayThirdPoints =readXlsFileThirdTbl($filePath);
  190. $arraySecondCommands = readXlsFileSecondTbl($filePath);
  191. if ( 0 < count($arraySecondCommands)) {
  192. $loadFileError .= 'Загрузка файла прошла успешно. ';
  193. }
  194. //if ( writeInData($arrayCommands)) {
  195. $idsToItems = writeInDataWide($arraySecondCommands,$arrayThirdPoints); // запись в базу
  196. $itemsCommand = readXlsFileFirstTbl($filePath,$idsToItems);
  197. $idsToItems = writeInData($itemsCommand); // запись в базу
  198. if ( !empty($idsToItems) and $idsToItems) {
  199. $loadFileError = 'Запись прошла успешно.';
  200. } else {
  201. $loadFileError = 'Ошибка записи в базу.';
  202. }
  203. $textlog = new \app\models\entity\Textlog();
  204. $textlog->msg = 'user : '. $id .", loadStatus :" . $loadFileError;
  205. $textlog->save();
  206. //$arrayCommands = readXlsFileFirstTbl($filePath,$idsToItems);
  207. // echo "<pre>";
  208. // var_dump($itemsCommand);
  209. // echo "</pre>";
  210. }
  211. ?>
  212. <!-- HTML -->
  213. <div class="wrapper">
  214. <header class="main-header">
  215. <!-- Logo -->
  216. <a href="/asusg_plan.php" class="logo">
  217. <!-- mini logo for sidebar mini 50x50 pixels -->
  218. <span class="logo-mini"><b>A</b>LT</span>
  219. <!-- logo for regular state and mobile devices -->
  220. <span class="logo-lg"><b>АСУ</b>СГ</span>
  221. </a>
  222. <!-- Header Navbar: style can be found in header.less -->
  223. <nav class="navbar navbar-static-top">
  224. <!-- Sidebar toggle button-->
  225. <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
  226. <span class="sr-only">Toggle navigation</span>
  227. </a>
  228. </nav>
  229. </header>
  230. <!-- Left side column. contains the logo and sidebar -->
  231. <aside class="main-sidebar">
  232. <!-- sidebar: style can be found in sidebar.less -->
  233. <section class="sidebar">
  234. <!-- Sidebar user panel -->
  235. <!-- search form -->
  236. <form action="#" method="get" class="sidebar-form">
  237. <div class="input-group">
  238. <input type="text" name="q" class="form-control" placeholder="Search...">
  239. <span class="input-group-btn">
  240. <button type="submit" name="search" id="search-btn" class="btn btn-flat">
  241. <i class="fa fa-search"></i>
  242. </button>
  243. </span>
  244. </div>
  245. </form>
  246. <!-- /.search form -->
  247. <!-- sidebar menu: : style can be found in sidebar.less -->
  248. <?php require_once 'asusg_menu.php';?>
  249. </section>
  250. <!-- /.sidebar -->
  251. </aside>
  252. <!-- Content Wrapper. Contains page content -->
  253. <div class="content-wrapper">
  254. <!-- Content Header (Page header) -->
  255. <section class="content-header">
  256. <h1>Список работ</h1>
  257. <ol class="breadcrumb">
  258. <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
  259. <li class="active">Dashboard</li>
  260. </ol>
  261. </section>
  262. <!-- Main content -->
  263. <section class="content">
  264. <div class="row">
  265. <!-- START CUSTOM TABS -->
  266. <div class="col-md-12">
  267. <!-- Custom Tabs -->
  268. <!-- НАЧАЛО ПЕРВОЙ ВКЛАДКИ -->
  269. <div class="row">
  270. <div class="col-xs-5">
  271. <div class="box">
  272. <div class="box-header">
  273. <h3 class="box-title">Список проектов</h3>
  274. </div>
  275. <div class="box-body">
  276. <form id="addFileListTaskTypesAsusgForm" method='post' enctype="multipart/form-data">
  277. <div class="form-group">
  278. <label for="exampleInputFile">Загрузить список работ.</label>
  279. <input id="exampleInputFile" type="file" name="nameXmlFile">
  280. <?php if( '' != $loadFileError):?>
  281. <p><?php echo $loadFileError;?></p>
  282. <? endif;?>
  283. </div>
  284. <div class="box-footer">
  285. <button id="addFileListTaskTypesAsusgButton" type="submit" class="btn btn-primary">Загрузить</button>
  286. </div>
  287. </form>
  288. <form id="addNewTaskTypesAsusgForm">
  289. <table id="example2" class="table table-bordered table-hover">
  290. <tr>
  291. <td>
  292. <div class="row">
  293. <div class="col-xs-6">
  294. <div class="form-group">
  295. <label for="exampleInputEmail1">Серия локомотива</label>
  296. <select id="loco_series_command_h" name="loco_series" class="form-control select2" style="width: 100%;">
  297. <? foreach( $locomotiveSeriesEntity as $loco):?>
  298. <option value="<?php echo $loco->id?>"><?php echo $loco->name;?></option>
  299. <? endforeach;?>
  300. </select>
  301. </div>
  302. </div>
  303. <div class="col-xs-6">
  304. <div class="form-group">
  305. <label for="exampleInputPassword1">Вид ремонта</label>
  306. <select id="type_fix_id_h" name="typefix" class="form-control select2" style="width: 100%;">
  307. <? foreach( $typeFix as $type):?>
  308. <option data_id="1" value="<?php echo $type->id;?>"><?php echo $type->name;?></option>
  309. <? endforeach;?>
  310. </select>
  311. </div>
  312. </div>
  313. </div>
  314. </td>
  315. <td>
  316. </td>
  317. </tr>
  318. <thead>
  319. <tr>
  320. <th>Задача</th>
  321. <!--<th>Вид ремонта</th>-->
  322. <th>Действие</th>
  323. </tr>
  324. </thead>
  325. <tbody>
  326. <tr>
  327. <td>
  328. <div class="form-group">
  329. <input class="form-control" id="AAAAA" name="taskName" type="text">
  330. </div>
  331. </td>
  332. <!--<td>
  333. <div class="form-group">
  334. <select id="type_fix_id" name="typefix" class="form-control select2" style="width: 100%;">
  335. <? //foreach( $typeFix as $key => $type):?>
  336. <option data_id="1" value="<?php //echo $key;?>"><?php //echo $type;?></option>
  337. <? //endforeach;?>
  338. </select>
  339. </div>
  340. </td>-->
  341. <td><button id="addNewTaskTypesAsusg" type="button" class="btn btn-block btn-primary " data_id="<?php echo $template->asusg_id;?>">Добавить</button></td>
  342. </tr>
  343. <? foreach( $asusgJobplanEntity as $key => $type):?>
  344. <tr class="param_for_template" data_id='<?php echo $type->id?>' >
  345. <td><?php echo $type->name;?></td>
  346. <!--<td><?php //echo $typeFix[$type->repair_type]?></td>-->
  347. <td>
  348. <!--<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>
  349. </tr>
  350. <? endforeach;?>
  351. </tbody>
  352. </table>
  353. </form>
  354. <div class="box box-default collapsed-box">
  355. <div class="box-header with-border">
  356. <h3 class="box-title">Теститка для загрузки файла</h3>
  357. <div class="box-tools pull-right">
  358. <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i>
  359. </button>
  360. </div>
  361. <!-- /.box-tools -->
  362. </div>
  363. <!-- /.box-header -->
  364. <div class="box-body" style="display: none;">
  365. <form id="addFileListTaskTypesAsusgForm2" method='post' enctype="multipart/form-data">
  366. <div class="form-group">
  367. <label for="exampleInputFile">Загрузить список работ.</label>
  368. <input id="exampleInputFile" type="file" name="nameXmlFile2">
  369. <?php if( '' != $loadFileError):?>
  370. <p><?php echo $loadFileError;?></p>
  371. <? endif;?>
  372. </div>
  373. <div class="box-footer">
  374. <button id="addFileListTaskTypesAsusgButton2" type="submit" class="btn btn-primary">Загрузить</button>
  375. </div>
  376. </form>
  377. </div>
  378. <!-- /.box-body -->
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. <div class="col-xs-7">
  384. <div class="box">
  385. <div class="box-header">
  386. <h3 class="box-title">Список проектов</h3>
  387. </div>
  388. <? //foreach( $asusgJobplanEntity as $template):?>
  389. <div class="box box-primary">
  390. <div class="box-header with-border">
  391. <div class="box-tools pull-right">
  392. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  393. <i class="fa fa-minus"></i>
  394. </button>
  395. </div>
  396. </div>
  397. <div class="box-body">
  398. <div class="row">
  399. <div class="col-xs-6">
  400. <h3 class="box-title">
  401. <?php echo $jobplanEntity->name?>
  402. </h3>
  403. </div>
  404. <div class="col-xs-3 col-xs-offset-2">
  405. <div class="form-group">
  406. <label for="exampleInputPassword1">Сохранить команду</label>
  407. <button type="button" class="btn btn-block btn-warning saveTaskTypesAsusg" data_id="<?php echo \Yii::$app->request->get('asusgtask');?>" data_projecttype="<?php echo $asusgProjecttypeEntity->id;?>">Сохранить</button>
  408. </div>
  409. </div>
  410. <div class="col-xs-5">
  411. <div class="form-group">
  412. <div class="form-group">
  413. <label for="exampleInputPassword1">Список команд</label>
  414. <select id="listJobForAsusg" class="form-control select2" style="width: 100%;">
  415. <?php foreach( $tasktypesEntity as $plan):?>
  416. <option value="<?php echo $plan->id?>" data_id_option="<?php echo $plan->id?>"><?php echo $plan->name;?></option>
  417. <?php endforeach;?>
  418. </select>
  419. </div>
  420. </div>
  421. </div>
  422. <div class="col-xs-3">
  423. <label for="exampleInputPassword1">Добавить команду</label>
  424. <button id="bindNewTaskTypesAsusg" type="button" class="btn btn-block btn-primary" task_id="<?php echo $jobplanEntity->id;?>">Добавить</button>
  425. </div>
  426. <div class="col-xs-8">
  427. <ul id="sortable" class="list-unstyled list_asusg_command_id sortable">
  428. <? $i = 100;?>
  429. <?php foreach ($asusgJob2CommandEntity as $item):?>
  430. <? //var_dump($item->asusg_job_id .'=='. \Yii::$app->request->get('asusgtask'));?>
  431. <? if ($item->asusg_job_id == \Yii::$app->request->get('asusgtask')):?>
  432. <li id="li_<?php echo \Yii::$app->request->get('asusgtask');?>_<?php echo $item->smopp_cmd_id;?>_<?php echo $i;?>" class="ui-state-default" data_id="<?php echo \Yii::$app->request->get('asusgtask');?>_<?php echo $item->smopp_cmd_id;?>_<?php echo $i;?>" select_id="listJobForAsusg_<?php echo $i?>"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
  433. <div class="box box-warning">
  434. <div class="box-header with-border">
  435. <h3 class="box-title"><?php echo $item->tasktypes->name;?></h3>
  436. <div class="box-tools pull-right">
  437. <button type="button" class="btn btn-box-tool remove_command_button_asusg" data-widget="remove" data_id="<?php echo \Yii::$app->request->get('asusgtask');?>_<?php echo $item->smopp_cmd_id;?>_<?php echo $i;?>"><i class="fa fa-times"></i></button>
  438. </div>
  439. <div class="form-group">
  440. <label for="exampleInputPassword1">Список должностей</label>
  441. <select id="listJobForAsusg_<?php echo $i?>" class="form-control select2" style="width: 100%;">
  442. <?php foreach( $jobEntity as $job):?>
  443. <option value="<?php echo $job->id?>" data_id_option="<?php echo $job->id?>" <? echo ( $job->id == $item->jobtype_id)?'selected="selected"':'';?>><?php echo $job->name;?></option>
  444. <?php endforeach;?>
  445. </select>
  446. </div>
  447. </div>
  448. </div>
  449. </li>
  450. <? endif;?>
  451. <?php $i++;?>
  452. <?php endforeach;?>
  453. </ul>
  454. </div>
  455. </div>
  456. </div>
  457. <? //endforeach;?>
  458. <!-- /.box-header -->
  459. </div>
  460. <!-- /.box-body -->
  461. </div>
  462. </div>
  463. </div>
  464. </div>
  465. </div>
  466. </section>
  467. <!-- /.content -->
  468. </div>
  469. <!-- Add the sidebar's background. This div must be placed
  470. immediately after the control sidebar -->
  471. <div class="control-sidebar-bg"></div>
  472. </div>
  473. <!-- HTML -->
  474. <div class="ASU_select_map0" style="display:none">
  475. <select class="form-control select hide_field_select_0" style="width: 100%;" name="newListJ_<? echo $i;?>" id="listJobForAsusg_<?php echo $i?>">
  476. <?php foreach( $jobEntity as $job):?>
  477. <option value="<?php echo $job->id?>" data_id_option="<?php echo $job->id?>" ><?php echo $job->name;?></option>
  478. <?php endforeach;?>
  479. </select>
  480. </div>
  481. <!--<select id="listJobForAsusg" class="form-control select2" style="width: 100%;">
  482. </select>-->
  483. <!-- End Document
  484. –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  485. <script src="/lte/bower_components/jquery/dist/jquery.min.js"></script>
  486. <!-- jQuery UI 1.11.4 -->
  487. <script src="/lte/bower_components/jquery-ui/jquery-ui.min.js"></script>
  488. <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  489. <script>
  490. $.widget.bridge('uibutton', $.ui.button);
  491. </script>
  492. <!-- Bootstrap 3.3.7 -->
  493. <script src="/lte/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  494. <!-- Morris.js charts -->
  495. <script src="/lte/bower_components/raphael/raphael.min.js"></script>
  496. <script src="/lte/bower_components/morris.js/morris.min.js"></script>
  497. <!-- Sparkline -->
  498. <script src="/lte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
  499. <!-- jvectormap -->
  500. <script src="/lte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
  501. <script src="/lte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
  502. <!-- jQuery Knob Chart -->
  503. <script src="/lte/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
  504. <!-- daterangepicker -->
  505. <script src="/lte/bower_components/moment/min/moment.min.js"></script>
  506. <script src="/lte/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
  507. <!-- datepicker -->
  508. <script src="/lte/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
  509. <!-- Bootstrap WYSIHTML5 -->
  510. <script src="/lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
  511. <!-- Slimscroll -->
  512. <script src="/lte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
  513. <!-- FastClick -->
  514. <script src="/lte/bower_components/fastclick/lib/fastclick.js"></script>
  515. <!-- AdminLTE App -->
  516. <script src="/lte/dist/js/adminlte.min.js"></script>
  517. <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
  518. <script src="/lte/dist/js/pages/dashboard.js"></script>
  519. <!-- AdminLTE for demo purposes -->
  520. <script src="/lte/dist/js/demo.js"></script>
  521. <script src="/loco.js"></script>
  522. <script src="/mail.js"></script>
  523. <script src="/lte/bower_components/select2/dist/js/select2.full.min.js"></script>
  524. <script>
  525. $( function() {
  526. $( ".sortable" ).sortable();
  527. $( ".sortable" ).disableSelection();
  528. } );
  529. </script>
  530. </body>
  531. </html>
  532. <?php
  533. function GetEnterForm()
  534. {
  535. echo "<article>
  536. <form method='post' action='?login'>
  537. <table>
  538. <tr>
  539. <td width=70>
  540. <b>Login</b>
  541. </td>
  542. <td>
  543. &nbsp;
  544. </td>
  545. <td>
  546. <input type='text' name=login value=''><br/>
  547. </td>
  548. </tr>
  549. <tr>
  550. <td>
  551. <b>Password </b>
  552. </td>
  553. <td>
  554. &nbsp;
  555. </td>
  556. <td>
  557. <input type='password' name=pass value=''>
  558. </td>
  559. </tr>
  560. <tr>
  561. <td></td>
  562. <td>&nbsp;</td>
  563. <td>
  564. <input type='submit' value='Enter'>
  565. </td>
  566. </tr>
  567. </table>
  568. </form>
  569. </article>";
  570. }
  571. function getLocomotiveList(){
  572. $result = [];
  573. //var_dump($companyID);
  574. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(['company' => 2] )->orderBy(['id' => SORT_DESC])->all();
  575. $listArray = [];
  576. foreach( $projectsLocotechEntity as $item){ //var_dump($item->projecttypes->name);echo "\n";
  577. //$tempArray = GetTasksForProject($item->id);
  578. $status = GetProjectStatus($item->id);
  579. if ($status != 2 && $status != 1) {continue;}
  580. $countDone = ['done' => 0, 'all' => 0 ];
  581. foreach( GetTasksForProject($item->id) as $proj) { //var_dump($proj);echo "<br>";
  582. $countDone['all']++;
  583. $tempArray = $proj;
  584. $tempArray['status'] = CheckAcceptedStatus($proj);
  585. $tempArray['name'] = GetTaskNameAndDesc($proj['type'])[0];
  586. //$tempArray['listAccounts'] = $this->getAccountListForTask($proj['type']);
  587. if ( 5 == $tempArray['status'] ) {$countDone['done']++;}
  588. //$countDone['all'] ." / " . $countDone['done'];
  589. $listArray[] = $tempArray;
  590. }
  591. $result[$item->id]['countDone'] = [ 'done' => $countDone['done'], 'all' => $countDone['all'] ];
  592. //$tempArray['name'] = GetTaskNameAndDesc($tempArray['type'])[0];
  593. $result[$item->id]['arr'] = $listArray;//GetTasksForProject($item->id);
  594. $result[$item->id]['obj'] = $item;
  595. $listArray = [];
  596. }
  597. //exit;
  598. return $result;
  599. }
  600. function CheckAcceptedStatus($task) {
  601. $result = false;
  602. $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
  603. from (select count(t.id) as total,
  604. sum(if(t.accepted_time is not null, 1, 0)) as accepted,
  605. sum(if(t.finished_time is not null, 1, 0)) as finished,
  606. sum(if(t.finished_time is null, if(timestampdiff(MINUTE, t.accepted_time, NOW()) > tt.time_to_complete_minutes, 1, 0), 0)) as attention
  607. from tasks t
  608. right join tasktypes tt on t.type = tt.id
  609. where t.parent_id = ".$task['id'].") tx;";
  610. $result = \Yii::$app->db->createCommand($query)->queryAll();
  611. $result = $result[0]["taskstatus"];
  612. return $result;
  613. }
  614. // ПРОЕКТЫ
  615. function readXlsFileFirstTbl( $filePath, $arrayIds){
  616. $Excel = \PHPExcel_IOFactory::load($filePath);
  617. //$maxCell = $Excel->setActiveSheetIndex(0);
  618. $maxCell = $Excel->setActiveSheetIndexByName('Проект');
  619. $maxCell = $Excel->getActiveSheet()->getHighestRowAndColumn();
  620. $data = $Excel->getActiveSheet()->rangeToArray('A6:'. $maxCell['column'].'6'. $maxCell['row']);
  621. $loco_serie = $Excel->getActiveSheet()->getCell('B1')->getValue();
  622. $repair = $Excel->getActiveSheet()->getCell('B2')->getValue();
  623. $repair_id = \app\models\entity\Repairtypes::findOne(['name' => $repair]);
  624. $loco_serie_id = \app\models\entity\locomotiveSeries::findOne(['name' => $loco_serie]);
  625. $asusgProjecttypeEntity = \app\models\entity\AsusgProjecttype::findOne(['repair_type' => $repair_id,'loco_serie_id' => $loco_serie_id]);
  626. $asusgProjecttypeEntity_id = $asusgProjecttypeEntity->id;
  627. if ( null == $asusgProjecttypeEntity->id) {
  628. $asusgProjecttypeEntity2 = new \app\models\entity\AsusgProjecttype();
  629. $asusgProjecttypeEntity2->repair_type = $repair_id->id;
  630. $asusgProjecttypeEntity2->loco_serie_id = $loco_serie_id->id;
  631. $asusgProjecttypeEntity2->save();
  632. $asusgProjecttypeEntity_id = $asusgProjecttypeEntity2->id;
  633. }
  634. $data = array_map('array_filter', $data);
  635. $data = array_filter($data);
  636. $result = [];
  637. $temArray = [];
  638. $arrayIdsTemp = [];
  639. foreach( $arrayIds as $pre_item){
  640. $arrayIdsTemp[$pre_item['id']][] = $pre_item;
  641. }
  642. $eee = 0;
  643. $point = 0;
  644. $rrr2 = 1;
  645. //$namesArrayJobPlan = [];
  646. $JobPlanCount = '';
  647. $tempArray = [];
  648. $newData = [];
  649. foreach($data as $item){
  650. $count = 0;
  651. $tempIt = $item[0];
  652. if (!in_array ($item[0],$tempArray)){
  653. $newData[] = $item;
  654. } else {
  655. foreach ( $tempArray as $tempItem){
  656. if ($item[0] == $tempItem ){
  657. $count++;
  658. }
  659. }
  660. $item[0] .= ' ' . $count;
  661. $newData[] = $item;
  662. }
  663. $tempArray[] = $tempIt;
  664. }
  665. foreach( $newData as $key => $item){
  666. foreach( $item as $key => $i) {
  667. if ( 0 == $key ){ // такого вы еще невидели ))
  668. $point = trim($i);
  669. }
  670. if ( 0 == $key ){ // такого вы еще невидели ))
  671. $countModel = \app\models\entity\AsusgJobplan::find()->where(['name' => $point])->count();
  672. if ( 0 == $countModel) {
  673. $modelJP = new \app\models\entity\AsusgJobplan();
  674. $modelJP->name = trim($point . $JobPlanCount);
  675. $modelJP->save();
  676. }
  677. $asusgJobplanEntity = \app\models\entity\AsusgJobplan::findOne(['name' => $point]);
  678. $temArray['asusg_id'] = $asusgJobplanEntity->id;
  679. $temArray['asusg_projecttype_id'] = $asusgProjecttypeEntity_id;
  680. $temArray['cmd_order'] = $eee;
  681. //$namesArrayJobPlan[] = $point;
  682. }
  683. if (1 == $key){
  684. $sectionType = \app\models\HelperModel::clearSectionString($i,\Yii::$app->params['maskArray']);
  685. $Jobplan = \app\models\entity\AsusgJobplan::findOne($asusgJobplanEntity->id);
  686. $Jobplan->sections = $sectionType;
  687. $Jobplan->save();
  688. }
  689. foreach( $arrayIdsTemp[$i] as $key2 => $itemId) {
  690. $rrr2++;
  691. $temArray['smopp_ids'][] = ['id'=>$itemId['id'], 'smop_id' => $itemId['cmd_id'],'job_type_id' => $itemId['job_type_id']];
  692. }
  693. $eee++;
  694. }
  695. $result[] = $temArray;
  696. $temArray = [];
  697. }
  698. //echo "<pre>";
  699. //var_dump($itemId);
  700. // var_dump($result);
  701. //echo "</pre>";
  702. //echo "<hr>";
  703. //exit;
  704. return $result;
  705. }
  706. /*
  707. предыдущая версия
  708. function readXlsFileFirstTbl( $filePath, $arrayIds){
  709. $Excel = \PHPExcel_IOFactory::load($filePath);
  710. $maxCell = $Excel->getActiveSheet()->getHighestRowAndColumn();
  711. $data = $Excel->getActiveSheet()->rangeToArray('A6:E6'. $maxCell['row']);
  712. $loco_serie = $Excel->getActiveSheet()->getCell('B1')->getValue();
  713. $repair = $Excel->getActiveSheet()->getCell('B2')->getValue();
  714. $repair_id = \app\models\entity\Repairtypes::findOne(['name' => $repair]);
  715. $loco_serie_id = \app\models\entity\locomotiveSeries::findOne(['name' => $loco_serie]);
  716. $asusgProjecttypeEntity = \app\models\entity\AsusgProjecttype::findOne(['repair_type' => $repair_id,'loco_serie_id' => $loco_serie_id]);
  717. $asusgProjecttypeEntity_id = $asusgProjecttypeEntity->id;
  718. if ( null == $asusgProjecttypeEntity->id) {
  719. $asusgProjecttypeEntity2 = new \app\models\entity\AsusgProjecttype();
  720. $asusgProjecttypeEntity2->repair_type = $repair_id->id;
  721. $asusgProjecttypeEntity2->loco_serie_id = $loco_serie_id->id;
  722. $asusgProjecttypeEntity2->save();
  723. $asusgProjecttypeEntity_id = $asusgProjecttypeEntity2->id;
  724. }
  725. $data = array_map('array_filter', $data);
  726. $data = array_filter($data);
  727. $result = [];
  728. $temArray = [];
  729. $arrayIdsTemp = [];
  730. foreach( $arrayIds as $pre_item){
  731. $arrayIdsTemp[$pre_item['id']][] = $pre_item;
  732. }
  733. $eee = 0;
  734. $point = 0;
  735. $rrr2 = 1;
  736. $namesArrayJobPlan = [];
  737. $JobPlanCount = '';
  738. $tempArray = [];
  739. $newData = [];
  740. foreach($data as $item){
  741. $count = 0;
  742. $tempIt = $item[0];
  743. if (!in_array ($item[0],$tempArray)){
  744. $newData[] = $item;
  745. } else {
  746. foreach ( $tempArray as $tempItem){
  747. if ($item[0] == $tempItem ){
  748. $count++;
  749. }
  750. }
  751. $item[0] .= ' ' . $count;
  752. $newData[] = $item;
  753. }
  754. $tempArray[] = $tempIt;
  755. }
  756. foreach( $newData as $key => $item){
  757. foreach( $item as $key => $i) {
  758. if ( 0 == $key ){ // такого вы еще невидели ))
  759. $point = trim($i);
  760. }
  761. if ( 0 == $key ){ // такого вы еще невидели ))
  762. $countModel = \app\models\entity\AsusgJobplan::find()->where(['name' => $point])->count();
  763. if ( 0 == $countModel) {
  764. $modelJP = new \app\models\entity\AsusgJobplan();
  765. $modelJP->name = trim($point . $JobPlanCount);
  766. $modelJP->save();
  767. }
  768. $asusgJobplanEntity = \app\models\entity\AsusgJobplan::findOne(['name' => $point]);
  769. $temArray['asusg_id'] = $asusgJobplanEntity->id;
  770. $temArray['asusg_projecttype_id'] = $asusgProjecttypeEntity_id;
  771. $temArray['cmd_order'] = $eee;
  772. $namesArrayJobPlan[] = $point;
  773. }
  774. foreach( $arrayIdsTemp[$i] as $key2 => $itemId) {
  775. // if ( 0 == $key2 ){ //echo $key2; echo "<br>";
  776. //$temArray['smopp_ids'][] = $arrayIds[$i];
  777. //} else {
  778. $rrr2++;
  779. //$temArray['smopp_ids'][] = ['smop_id' => $arrayIds['cmd_id'],'job_type_id' => $arrayIds['job_type_id']];
  780. $temArray['smopp_ids'][] = ['smop_id' => $itemId['cmd_id'],'job_type_id' => $itemId['job_type_id']];
  781. //$temArray['job_type_id'][] = $arrayIds[$i]['job_type_id'];
  782. //echo "<pre>@";
  783. //var_dump($result);
  784. //echo "<hr>";
  785. //var_dump($eee);
  786. //echo "</pre>";
  787. //}
  788. }
  789. $eee++;
  790. }
  791. $result[] = $temArray;
  792. $temArray = [];
  793. }
  794. //echo "<pre>";
  795. //var_dump($result);
  796. //echo "<hr>";
  797. // var_dump($result);
  798. //echo "</pre>";
  799. return $result;
  800. }
  801. */
  802. // КОНТРОЛЬНЫЕ КАРТЫ
  803. function readXlsFileThirdTbl($filePath){
  804. $param = ['Множественный выбор' => 2,'Выбор' => 1,'Ввод значения' => 3 ];
  805. $Excel = \PHPExcel_IOFactory::load($filePath);
  806. //$maxCell = $Excel->setActiveSheetIndex(2);
  807. $maxCell = $Excel->setActiveSheetIndexByName('Контрольные карты');
  808. $maxCell = $Excel->getActiveSheet()->getHighestRowAndColumn();
  809. $data = $Excel->getActiveSheet()->rangeToArray('A3:H3' . $maxCell['row']);
  810. $result = [];
  811. foreach( $data as $item){
  812. $tempArray = [];
  813. foreach($item as $key => $points){
  814. if ( $key > 3 && null != $points){
  815. $tempArray[] = $points;
  816. }
  817. }
  818. $result[$item[0]][] = [$item[0],$item[1],$item[2],$param[$item[3]],$tempArray];
  819. }
  820. //echo "<pre>";
  821. // var_dump($result);
  822. //echo "</pre>";
  823. //exit;
  824. return $result;
  825. }
  826. // СОСТАВ КОМАНД
  827. function readXlsFileSecondTbl($filePath){
  828. $Excel = \PHPExcel_IOFactory::load($filePath);
  829. //$maxCell = $Excel->setActiveSheetIndex(1);
  830. $maxCell = $Excel->setActiveSheetIndexByName('Команды');
  831. $maxCell = $Excel->getActiveSheet()->getHighestRowAndColumn();
  832. $data = $Excel->getActiveSheet()->rangeToArray('A3:F3' . $maxCell['row']);
  833. $paramArray = ['0' => 'initiator','1' => 'command_name', '2' =>'jobtype','3' => 'time_to_finish','4' =>'confirm_type','5' =>'control_map_id'];
  834. $data = array_map('array_filter', $data);
  835. $data = array_filter($data);
  836. $result = [];
  837. $temArray = [];
  838. $l = 1;
  839. foreach( $data as $k => $item){
  840. foreach( $item as $key => $i) {
  841. if( 0 == $key) {
  842. global $id;
  843. $temArray['control_map_id'] = '';
  844. $temArray[$paramArray[$key]] = $id;
  845. continue;
  846. }
  847. $temArray['control_map_id'] = '';
  848. $temArray[$paramArray[$key]] = $i;
  849. }
  850. $arrTemp = explode(',',$temArray[jobtype]);
  851. if ( 1 < count($arrTemp) ){
  852. foreach($arrTemp as $it){
  853. $temArray['jobtype'] = trim($it);
  854. $temArray['id'] = $l;
  855. $result[]= $temArray;
  856. }
  857. continue;
  858. }
  859. $temArray['id'] = $l;
  860. $l++;
  861. $result[]= $temArray;
  862. }
  863. //echo "<pre>";
  864. // var_dump($result);
  865. //echo "</pre>";
  866. //exit;
  867. return $result;
  868. //exit;
  869. }
  870. /*
  871. первоначальная версия
  872. function readXlsFileSecondTbl($filePath){
  873. $Excel = \PHPExcel_IOFactory::load($filePath);
  874. $maxCell = $Excel->getActiveSheet()->getHighestRowAndColumn();
  875. $data = $Excel->getActiveSheet()->rangeToArray('G6:L6' . $maxCell['row']);
  876. $paramArray = ['0' => 'initiator','1' => 'command_name', '2' =>'jobtype','3' => 'time_to_finish','4' =>'confirm_type','5' =>'control_map_id'];
  877. $data = array_map('array_filter', $data);
  878. $data = array_filter($data);
  879. $result = [];
  880. $temArray = [];
  881. $l = 1;
  882. foreach( $data as $k => $item){
  883. foreach( $item as $key => $i) {
  884. if( 0 == $key) {
  885. global $id;
  886. $temArray['control_map_id'] = '';
  887. $temArray[$paramArray[$key]] = $id;
  888. continue;
  889. }
  890. $temArray['control_map_id'] = '';
  891. $temArray[$paramArray[$key]] = $i;
  892. }
  893. $arrTemp = explode(',',$temArray[jobtype]);
  894. if ( 1 < count($arrTemp) ){
  895. foreach($arrTemp as $it){
  896. $temArray['jobtype'] = trim($it);
  897. $temArray['id'] = $l;
  898. $result[]= $temArray;
  899. }
  900. continue;
  901. }
  902. $temArray['id'] = $l;
  903. $l++;
  904. $result[]= $temArray;
  905. }
  906. //echo "<pre>";
  907. // var_dump($result);
  908. //echo "</pre>";
  909. return $result;
  910. //exit;
  911. }
  912. */
  913. function writeInData($arrayCommands) {
  914. //echo '<pre>';
  915. //var_dump($arrayCommands);
  916. //echo '</pre>';
  917. //return true;
  918. $result = false;
  919. if (!empty($arrayCommands)){
  920. foreach( $arrayCommands as $command){
  921. \app\models\entity\AsusgJob2Command::deleteAll(['asusg_projecttype_id' => $command['asusg_projecttype_id']]);
  922. //\app\models\entity\AsusgJob2Project::deleteAll(['asusg_projecttype_id' => $command['asusg_projecttype_id']]);
  923. break;
  924. }
  925. $k = 0;
  926. foreach( $arrayCommands as $command){
  927. //var_dump($command); echo "<br>";
  928. /*
  929. $asusgJob2ProjectEntity = new \app\models\entity\AsusgJob2Project();
  930. $asusgJob2ProjectEntity->asusg_jobplan_id = $command['asusg_id'];
  931. $asusgJob2ProjectEntity->asusg_projecttype_id = $command['asusg_projecttype_id'];
  932. $asusgJob2ProjectEntity->job_order = $k;
  933. $k++;
  934. try {
  935. $asusgJob2ProjectEntity->save();
  936. }
  937. catch (\yii\db\Exception $exception) {
  938. $loadFileError .= 'Повторная запись.';
  939. //return false;
  940. }
  941. */
  942. //echo "<pre>";
  943. // var_dump($command);
  944. //echo "</pre>";
  945. foreach( $command['smopp_ids'] as $key => $com){
  946. $asusgJob2CommandEntity = new \app\models\entity\AsusgJob2Command();
  947. $asusgJob2CommandEntity->asusg_job_id = $command['asusg_id'];
  948. $asusgJob2CommandEntity->asusg_projecttype_id = $command['asusg_projecttype_id'];
  949. $asusgJob2CommandEntity->smopp_cmd_id = $com["smop_id"];
  950. $asusgJob2CommandEntity->jobtype_id = $com["job_type_id"];
  951. $asusgJob2CommandEntity->cmd_order = $command["cmd_order"];//$key;
  952. $asusgJob2CommandEntity->job_order = $k;
  953. $asusgJob2CommandEntity->original_order = $com["id"];
  954. //echo "<pre>";
  955. // var_dump($com["id"]);
  956. //echo "</pre>";
  957. try {
  958. $asusgJob2CommandEntity->save();
  959. }
  960. catch (\yii\db\Exception $exception) {
  961. $loadFileError .= 'Повторная запись.';
  962. //return false;
  963. }
  964. }
  965. $k++;
  966. $result = true;
  967. }
  968. }
  969. return $result;
  970. }
  971. function writeInDataWide($arrayCommands,$arrayThirdPoints) {
  972. global $link;
  973. $result = false;
  974. $tempArr = [];
  975. /*
  976. if (!empty($arrayCommands)){
  977. foreach( $arrayCommands as $command){
  978. foreach( $command['smopp_ids'] as $key => $com){
  979. $asusgJob2CommandEntity = new \app\models\entity\AsusgJob2Command();
  980. $asusgJob2CommandEntity->asusg_job_id = $command['asusg_id'];
  981. $asusgJob2CommandEntity->smopp_cmd_id = $com;
  982. $asusgJob2CommandEntity->cmd_order = $key;
  983. try {
  984. $asusgJob2CommandEntity->save();
  985. }
  986. catch (\yii\db\Exception $exception) {
  987. $loadFileError .= 'Повторная запись.';
  988. return false;
  989. }
  990. //var_dump($command['asusg_id'],$com,$key); echo "<br>";
  991. }
  992. $result = true;
  993. }
  994. }*/
  995. $i = 1;
  996. $controlMapTempArray = [];
  997. foreach( $arrayCommands as $command){
  998. $command['time_to_finish'] = round($command['time_to_finish']);
  999. $command['jobtype'] = \app\models\HelperModel::stripWhitespaces($command['jobtype']);
  1000. $query = "call `asusg_add_command_type`( " . $command['initiator'] . ",'" . $command['command_name'] . "','" . $command['jobtype'] . "'," . $command['time_to_finish'] . ",'" . $command['confirm_type'] . "'," . (int)$command['control_map_id'].", @cmd_id, @job_type_id)";
  1001. mysqli_query($link, "SET @cmd_id = '', @job_type_id = ''");
  1002. $res = mysqli_query($link, $query);
  1003. $res = mysqli_query($link, "SELECT @cmd_id as _asusg_add_command_type_out, @job_type_id as _asusg_add_command_type_out2");
  1004. $row = $res->fetch_assoc();
  1005. $tempArr[$i] = [ 'cmd_id' => $row['_asusg_add_command_type_out'] , 'job_type_id' => $row['_asusg_add_command_type_out2'],'id' => $command['id']];
  1006. $querydel = "delete from checkpoint_types_for_tasks where tasktype_id = " . $row['_asusg_add_command_type_out'] . " and cp_type_id > 0";
  1007. mysqli_query($link, $querydel);
  1008. // CHECKPOINTS
  1009. if ( isset($command['control_map_id']) and null != $command['control_map_id']) {
  1010. foreach ($arrayThirdPoints[$command['control_map_id']] as $checpoint){
  1011. mysqli_query($link, "SET @checkoipt_id = ''");
  1012. $query2 = "call asusg_add_checkpoint_type(".$row['_asusg_add_command_type_out'].",'".$checpoint[2]."',".$checpoint[3].", @checkpoint_id)";
  1013. //$query2 = "call asusg_add_checkpoint_type(".$row['_asusg_add_command_type_out'].",'" . $checpoint[0] . ". ".$checpoint[2]."',".$checpoint[3].", @checkpoint_id)";
  1014. $res2 = mysqli_query($link, $query2);
  1015. $res2 = mysqli_query($link, "SELECT @checkpoint_id as checkpoint");
  1016. $row2 = $res2->fetch_assoc();
  1017. foreach($checpoint[4] as $p) {
  1018. $query3 = "call asusg_add_checkbox_to_checkpoint(" . $row2['checkpoint'] . ",'" . $p . "')";
  1019. mysqli_query($link, $query3);
  1020. //echo "<pre>";
  1021. //var_dump("call asusg_add_checkbox_to_checkpoint(" . $row2['checkpoint'] . ",'" . $p . "')");
  1022. //echo "</pre>";
  1023. }
  1024. }
  1025. }
  1026. // CHECKPOINTS
  1027. $i++;
  1028. //\Yii::$app->db->createCommand($query)->queryAll();
  1029. }
  1030. //var_dump(gettype($res));
  1031. //echo "<pre>";
  1032. //var_dump($tempArr);
  1033. //echo "</pre>";
  1034. //exit;
  1035. return $tempArr;
  1036. }
  1037. ?>