oprt_management.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <?
  2. if (!$logged_me_in_successfully234)
  3. return;
  4. //$arResult = mainFuncController();
  5. $managementModel = new \app\models\ManagementModel();
  6. $arResult = $managementModel->mainFuncController();
  7. $company = Company::Find($companyID);
  8. if (isset($assign_id) && isset($assign_act)) {
  9. if (StartProject($assign_act, $assign_id))
  10. TasksAssign('', true, $assign_id);
  11. }
  12. //echo "sort1 $sorttasks $sort";
  13. if (!isset($sort))
  14. {
  15. $sort = $_SESSION['sorttasks'];
  16. if (!isset($sort)) {
  17. $sort = 1;
  18. }
  19. }
  20. $_SESSION['sorttasks'] = $sort;
  21. //echo "scr ".$scroll;
  22. echo "<input type='hidden' id='scroll' value=$scroll>";
  23. //echo "sort $sorttasks $sort";
  24. //getAccountList();
  25. //var_dump(getAccountList()); echo "<br>";
  26. echo
  27. "
  28. <div class='main__content'>
  29. <div class='content__menu'>
  30. <h2 class='content__title content__menu__title'>
  31. Сотрудники
  32. </h2>
  33. ";
  34. echo '<table style="height: 154px;" width="413">
  35. <thead>
  36. <tr>
  37. <td style="width: 42px;">Сотрудники</td>
  38. <td style="width: 42px;">Должности</td>
  39. </tr>
  40. </thead>
  41. <tbody>';
  42. if( count($arResult['accountList']) > 0 ) {
  43. foreach($arResult['accountList'] as $acc) {
  44. echo '<tr>
  45. <td style="width: 42px;">'. $acc['name'] .'</td>
  46. <td style="width: 42px;">
  47. <select>';
  48. foreach($acc as $position) {
  49. if (!is_array($position)) {continue;}
  50. $selected = ( 0 == $position['priority'])? 'selected="selected"': '';
  51. echo '<option value="'. $position['id'].'" '.$selected.'>'. $position['job_name'].'</option>';
  52. }
  53. echo '</select>
  54. <input type="button" value="Сохранить">
  55. </td>
  56. </tr>';
  57. }
  58. } else {
  59. echo '<tr>
  60. <td style="width: 42px;">Никого не найдено</td>
  61. <td style="width: 42px;">Ничего не найдено</td>
  62. </tr>';
  63. }
  64. echo '
  65. </tbody>
  66. </table>';
  67. echo '<div class="content__menu__list">';
  68. echo '<br>';
  69. //EchoProjects($sort);
  70. echo '</div>';
  71. echo '</div>';
  72. //PARENT TITLE IN CHILDREN LIST
  73. if ($new == 1){
  74. } else if ($activeid) {
  75. // $proj = GetProject($activeid);
  76. /**
  77. * @var $proj Project
  78. */
  79. $proj = Project::Find($activeid);
  80. if ($proj != null) {
  81. $action = FindAction($proj->getAction());
  82. $actionid = $action['id'];
  83. $types = ProjectType::GrabTasktypesByProjectType($actionid);
  84. $acname = $action['name'];
  85. $section = $proj->section;
  86. if ($section != null) {
  87. $loco_type = $section->locomotive_series;//$proj['loco_type'];
  88. $loco_number = $section->getSectionNumber();//intval($proj['loco_number']);
  89. }
  90. $depo = $proj->getDepo();
  91. $depos = $proj->getDepoService();
  92. if ($activeid) {
  93. echo "<div class='content__main'>
  94. <h2 class='content__title content__main__title'>$activeid. $acname</h2>
  95. <p class='content__main__item__text'>";
  96. echo "<span style='color: black'>
  97. Тип проекта: <a href='?act=project_types&activeid=$actionid'>$actionid. $acname</a><br>
  98. Локомотив серии: $loco_type № $loco_number <br>
  99. Депо приписки: $depo<br>
  100. Депо обслуживания: $depos<br><br>
  101. Доступные типы задач:
  102. </span><br><br>";
  103. foreach ($types as $type) {
  104. //if ($type['main_task']) {
  105. if ($type->main_task) {
  106. echo "[Главная] ";
  107. $sort = '1';
  108. }
  109. $tid = $type->GetId();
  110. $tname = $type->name;
  111. echo "<a href = '?act=tasktypes&activeid=" . $tid . "&sort=$sort'>$tid. $tname</a>";
  112. echo '<br>';
  113. }
  114. echo "<br><span style='color: black'>Созданные задачи:</span><br><br>";
  115. $tasks = GetTasksForProject($activeid);
  116. // ПОЛУЧЕНИЕ XML НАЧАЛО
  117. $parents = $entityManager->getRepository('Task')->findBy(array('parent_id' => 0), array('id' => 'DESC'));
  118. $tasktypesIds = GrabTasktypesIDs();
  119. $array_children = [];
  120. $array_parent = [];
  121. foreach ($parents as $parent) {
  122. if (!in_array(intval($parent->type), $tasktypesIds)) {
  123. continue;
  124. }
  125. $status = GetTaskStatus($parent->id);
  126. if ($status == 5) {
  127. $array_parent[$parent->id] = $parent;
  128. $children = $entityManager->getRepository('Task')->findBy(array('parent_id' => $parent->id));
  129. $array_children[$parent->id] = $children;
  130. }
  131. }
  132. $array_type = [];
  133. $array_id = [];
  134. $_SESSION['array_children'] = $array_children;
  135. $_SESSION['array_parent'] = $array_parent;
  136. $arrayTasksId = [];
  137. foreach ($tasks as $task) {
  138. $type = $task['type'];
  139. $id = $task['id'];
  140. $_SESSION['actid'] = $id;
  141. foreach ($array_children as $parent_id => $children) {
  142. if ($id == $parent_id) {
  143. foreach ($children as $res1) {
  144. $array_type[] = $res1->type;
  145. $array_id[] = $res1->id;
  146. }
  147. }
  148. }
  149. $xmltype = implode(',', $array_type);
  150. $xmlid = implode(',', $array_id);
  151. $name = GetTaskNameAndDesc($type)[0];
  152. $sort = GetTaskStatus($id);
  153. if ($task['parent_id'] == '0') {
  154. $arrayTasksId[] = $id;
  155. echo "<a href = '?act=tasks&activeid=$id&sort=$sort'>$id [$sort]. $name </a><br>";
  156. http://corp.prmsys.net/index.php?act=tasks&activeid=679&scroll=0
  157. }
  158. }
  159. echo '</p></div>';
  160. }
  161. }
  162. }
  163. echo '<div class="content__main" >
  164. <h2 class="content__title content__menu__title">
  165. Локомотивы
  166. </h2><br>
  167. <div>
  168. <h3>Новая задача:</h3>';
  169. echo "<select class='form-input content__main__form__goal' name='newtasktype'>";
  170. $tasktypes = GrabTasktypes();
  171. foreach ($tasktypes as $tasktype)
  172. {
  173. if ($tasktype->main_task == '1') {
  174. $ttype = $tasktype->id;
  175. $ttname = $tasktype->name;
  176. echo "<p class='content__menu__task-text'><option value = '".$ttype."'>[" . $ttype . "] " . $ttname . "</option></p>";
  177. }
  178. }
  179. echo '</select></div>
  180. <ul id="sortable">';
  181. foreach( $arResult['locomotiveList'] as $loco )
  182. {
  183. $project = $loco['obj'];
  184. $project_id = $project->id;
  185. $urgent = $project->urgent;
  186. if (!$urgent)
  187. $makeurgent = "Назначить приоритетным";
  188. else
  189. $makeurgent = "Снять приоритетность";
  190. echo '<li>
  191. <div id="'.$project_id.'" style="border: solid; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; margin-bottom:20px; padding: 5px">
  192. <div id="data_pos_top_1" class="slider_staff_toggle27_top" ></div>
  193. <p class="button_staff_toggle button_sou_toggle" data="slider_staff_toggle'.$loco['obj']->loco_number .'" style="float: right; font-size: 10px;text-decoration: underline;color: blueviolet;">Развернуть</p>
  194. <h4 class="_button_staff_toggle" data="slider_staff_toggle'.$loco['obj']->loco_number .'">' . $loco['obj']->loco_type .' <b><span style="color: darkolivegreen">['. $loco['obj']->loco_number.'] </span></b> Выполнено задач: '.$loco["countDone"]['done'].' из '. $loco["countDone"]['all'] .'</h4>
  195. <input id="makeurgent" value="'.$makeurgent.'" type="button">
  196. <input id="addtask" value="Добавить задачу" type="button">';
  197. echo '<div class="slider_staff_toggle'.$loco['obj']->loco_number .'" style="display: none;">
  198. <p></p>
  199. <h4 style="margin-bottom: 5px">Активные задачи:</h4>
  200. <div id="result"></div><ul id="sortableIn">';
  201. foreach ($loco['arr'] as $item)
  202. {
  203. $color = \Yii::$app->params['task_status']['color'][$item['status']];
  204. echo '<li style="list-style-type: none"><div style="border: solid; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; margin-bottom:20px; padding: 5px; background-color:'.$color.'">';
  205. echo "<a href = '' > " . $item['id'] . " " . $item['name']."</a><br>";
  206. echo \Yii::$app->params['task_status']['attributes'][$item['status']] . ": ";
  207. echo "<select>";
  208. foreach($item['listAccounts'] as $employee) {
  209. $selected = ($item['assignees_arr'] == $employee['id'])? 'selected="selected"': '';
  210. echo "<option value='".$employee['id']."' $selected>". $employee['name']."</option>";
  211. }
  212. echo "</select>";
  213. //var_dump( $item['listAccounts']);
  214. echo "</div></li>";
  215. }
  216. echo '</ul>
  217. <br>
  218. </div>
  219. </div>';
  220. }
  221. echo '</div></li>';
  222. // ПОЛУЧЕНИЕ XML КОНЕЦ
  223. echo '</ul></div>'; //main__content
  224. echo '
  225. <script>
  226. $( function() {
  227. $( "#sortable" ).sortable();
  228. $( "#sortableIn" ).sortable();
  229. $( "#sortable" ).disableSelection();
  230. } );
  231. </script>';
  232. function mainFuncController(){
  233. $arResult = [];
  234. $arResult['accountList'] = getAccountList();
  235. $arResult['locomotiveList'] = getLocomotiveList();
  236. return $arResult;
  237. }
  238. function getAccountList(){
  239. global $companyID;
  240. $result = [];
  241. //var_dump($companyID);
  242. $accountsEntity = \app\models\entity\Accounts::find()->where(['company' => $companyID])->all();
  243. foreach( $accountsEntity as $item){
  244. $last_seen_mobile = ( null != $item->last_seen_mobile )? new DateTime($item->last_seen_mobile): $item->last_seen_mobile ;
  245. $online_mobile = OnlineAccountCheck(TimeString($last_seen_mobile));
  246. if (!$online_mobile) { continue;}
  247. foreach($item->jobtype as $it) {
  248. $result[] = ['name' => $item->name,'position' => $it->name];
  249. }
  250. }
  251. return $result;
  252. }
  253. function getLocomotiveList(){
  254. global $companyID;
  255. $result = [];
  256. //var_dump($companyID);
  257. $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(['company' => $companyID,'status' => 2] )->orderBy(['id' => SORT_DESC])->all();
  258. foreach( $projectsLocotechEntity as $item){
  259. //$tempArray = GetTasksForProject($item->id);
  260. foreach( GetTasksForProject($item->id) as &$proj) {
  261. $proj['name'] = GetTaskNameAndDesc($proj['type'])[0];
  262. }
  263. //$tempArray['name'] = GetTaskNameAndDesc($tempArray['type'])[0];
  264. $result[$item->id]['arr'] = GetTasksForProject($item->id);
  265. $result[$item->id]['obj'] = $item;
  266. }
  267. return $result;
  268. } ?>
  269. <style type="text/css">
  270. .ui-sortable li {
  271. list-style: none;
  272. }
  273. .ui-sortable-handle {
  274. margin: 0;
  275. }
  276. .ui-sortable-handle div {
  277. margin: 15px 0 0 !important;
  278. padding: 0 15px !important;
  279. }
  280. </style>