123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502 |
- <?
- if (!$logged_me_in_successfully234) return;
- EchoScriptName(basename(__FILE__, '.php'));
- $company = Company::Find($companyID);
- if (isset($assign_id) && isset($assign_act)) {
- if (StartProject($assign_act, $assign_id))
- TasksAssign('', true, $assign_id);
- }
- //Создание проекта
- if ($new == "2") {
- /** @var int $loco_number */
- /** @var string $loco_type */
- /** @var int $action_num тип проекта */
- /** @var int $А */
- /** @var int $Б */
- /** @var int $В */
- /** @var int $Г */
- /** @var bool $urgent срочность проекта */
- /** @var int $sections ИД секции */
- //$task_string = FillArrayString("subtask");
- if (!$loco_number) {
- /** @var $section Section */
- $section = Section::Find($sections);
- if ($section) {
- $loco_number = $section->getSectionNumber();
- }
- } else {
- //буква секции на кириллице
- CheckSection("А", $loco_type, $loco_number, $А);
- CheckSection("Б", $loco_type, $loco_number, $Б);
- CheckSection("В", $loco_type, $loco_number, $В);
- CheckSection("Г", $loco_type, $loco_number, $Г);
- }
- $projs = $entityManager->getRepository('Project')->findBy(array('company' => $companyID, 'loco_number' => $loco_number, 'loco_type' => $loco_type));
- $nostart = false;
- foreach ($projs as $proj)
- {
- //родной статус похоже не проставляется при выполнении
- if (intval(GetProjectStatus($proj->id)) < 5 && $proj->getAction() == $action_num)
- {
- $nostart = $proj->id;
- echo "<span style='color:red'><b>Ошибка: для данного типа уже запущен проект $nostart с тем же локомотивом</b></span>";
- break;
- }
- }
- if (!$nostart && $loco_type) {
- $urgent = ($urgent == "on") ? 1 : 0;
- //$qstr = "insert into projects_locotech (action, company, status, loco_type,loco_number,depo,depo_service, created, tasks ) values (" . $action_num . "," . $companyID . ",1,'$loco_type',$loco_number,'$depo','$depo_service', NOW(),'$task_string' )";
- $qstr = "insert into projects_locotech (action, company, status, loco_type,loco_number,depo,depo_service, created, urgent) values (" . $action_num . "," . $companyID . ",1,'$loco_type','$loco_number','$depo','$depo_service', NOW(), $urgent)";
- //echo "qstr $qstr ";
- mysqli_query($link, $qstr);
- $activeid = mysqli_insert_id($link);
- $project = Project::Find($activeid);
- if ($project != null) {
- /**
- * @var $project Project
- */
- if ($section) {
- $project->section = $section;
- $project->Save();
- }
- }
- if ($activeid > 0) {
- echo "<span style='color:green'><b>Запись добавлена!</b></span>";
- $sort = 1;
- if (StartProject($action_num, $activeid))
- TasksAssign('', true, $assign_id);
- } else
- echo "<span style='color:red'><b>Ошибка ввода данных!</b></span>";
- }
- }
- else if ($new == "3") {
-
- echo "<span style='color:red'><b>Проект $del_id и его задачи удалены!</b></span>";
- //CleanTasks($del_id);
- $textlog = new app\models\entity\Textlog();
- $textlog->msg = "Пользователь: ". $id.", Попытка удалить проект (номер): " . $del_id;
- $textlog->save();
- $companyIDfake = (int)$companyID + 1000;
- echo "UPDATE projects_locotech SET `company`=".$companyIDfake ." WHERE `id` = $del_id";
- //die();
- OCSremoveproject($del_id);
- $project = Project::Find($del_id);
- if (isset($project))
- $project->reopenTasks();
- mysqli_query($link, "UPDATE projects_locotech SET `company`=".$companyIDfake." WHERE `id`= $del_id");
- //mysqli_query($link, "delete from projects_locotech where id = $del_id");
- }
- // else if ($new == "4") {
- // echo "<p style='color: red'>Не предоставлен образец входного документа!</p>";
- //}
- else if ($new == "5") {
- //echo "<span style='color: green'>Все проекты удалены!</span>";
- echo "<span style='color: green'>Удаление всех проектов временно отключено! Обратитесь к разработчику!</span>";
- // $projs = $entityManager->getRepository('Project')->findAll();
- // foreach ($projs as $proj) {
- // CleanTasks($proj->id);
- // mysqli_query($link, "delete from projects_locotech where id = $proj->id");
- // }
- }
- if (!isset($sort))
- {
- $sort = $_SESSION['sorttasks'];
- if (!isset($sort)) {
- $sort = 1;
- }
- }
- $_SESSION['sorttasks'] = $sort;
- echo "<input type='hidden' id='scroll' value=$scroll>";
- $active1 = '';
- $active2 = '';
- $active3 = '';
- $active4 = '';
- $active5 = '';
- switch ($sort)
- {
- case '1': $active1 = 'control-btn_active'; break;
- case '2': $active2 = 'control-btn_active'; break;
- case '3': $active2 = 'control-btn_active'; break;
- case '4': $active4 = 'control-btn_active'; break;
- case '5': $active5 = 'control-btn_active'; break;
- }
- if (!$project_limit)
- $project_limit = '20';
- echo
- "
- <div class='main__content'>
- <div class='content__menu'>
- <h2 class='content__title content__menu__title' style='margin-bottom: 20px'>
- Проекты
- </h2>
- <p class='content__main__item__text' style='padding: 0; text-align: center'>Показывать на странице: <input type='button' id='project_limit' value='$project_limit'></p>
- <div class='content__filter'>
- <img src='ProSysNew/search.svg' alt='search' class='content__search'>
- <div class='content__controls'>
- <button class='control-btn control-btn_red content__filter__btn $active1' onclick='SortElements(1, \"projects\")'>Новые</button>
- <button class='control-btn control-btn_yellow content__filter__btn $active2' onclick='SortElements(2, \"projects\")'>В работе</button>
- <button class='control-btn control-btn_green content__filter__btn $active5' onclick='SortElements(5, \"projects\")'>Готово</button>
- </div>
- </div>";
- echo '<div class="content__menu__list">';
- echo ' <div class="content__menu__newproj content__menu__newproj_active" onclick = "NewListElement(\'projects\')">
- <div class="content__menu__newproj__plus">
- +
- </div>
- <div class="content__menu__newproj__text">
- Новый проект
- </div>
- </div><br>';
- EchoProjects($sort);
- echo '</div>';
- echo '</div>';
- //PARENT TITLE IN CHILDREN LIST
- if ($new == 1)
- AddNewProject();
- else if ($activeid && $activeid != "undefined") {
- // $proj = GetProject($activeid);
- /**
- * @var $proj Project
- */
- $proj = Project::Find($activeid);
- if ($proj != null) {
- $action = FindAction($proj->getAction());
- $actionid = $action['id'];
- // $types = ProjectType::GrabTasktypesByProjectType($actionid);
- $acname = $action['name'];
- // $section = $proj->section;
- // if ($section != null) {
- // $loco_type = $section->locomotive_series;//$proj['loco_type'];
- // $loco_number = $section->getSectionNumber();//intval($proj['loco_number']);
- // }
- $loco_number = $proj->loco_number;
- $depo = $proj->getDepo();
- $depos = $proj->getDepoService();
- if ($activeid) {
- $project_comment = '';
- $cmt = $proj->getUuid();
- if ('' != $cmt)
- {
- $project_comment = "Комментарий: <i>".$cmt."</i><br>";
- }
- echo "<div class='content__main'>
- <h2 class='content__title content__main__title'>$activeid. $acname</h2>
- <p class='content__main__item__text'>
- <span style='color: black'>".
- $project_comment
- ."
- Тип проекта: <a href='?act=project_types&activeid=$actionid'>$actionid. $acname</a><br>
- Локомотив серии: $loco_type № $loco_number <br>
- Депо приписки: $depo<br>
- Депо обслуживания: $depos<br><br></span>";
- echo "<span style='color: black'>Созданные задачи:</span><br><br>";
- // $tasks = GetTasksForProject($activeid);
- $tasks = $proj->getTasks();
- // ПОЛУЧЕНИЕ XML НАЧАЛО
- $parents = $entityManager->getRepository('Task')->findBy(array('parent_id' => 0, 'input_id' => $activeid), array('id' => 'DESC'));
- $tasktypesIds = GrabTasktypesIDs();
- $array_children = [];
- $array_parent = [];
- foreach ($parents as $parent) {
- if (!in_array(intval($parent->type), $tasktypesIds)) {
- continue;
- }
- $status = GetTaskStatus($parent->id);
- if ($status == 5) {
- $array_parent[$parent->id] = $parent;
- $children = $entityManager->getRepository('Task')->findBy(array('parent_id' => $parent->id));
- $array_children[$parent->id] = $children;
- }
- }
- $array_type = [];
- $array_id = [];
- $_SESSION['array_children'] = $array_children;
- $_SESSION['array_parent'] = $array_parent;
-
- $arrayTasksId = [];
- foreach ($tasks as $task) {
- $type = $task->type;
- $id = $task->id;
- $_SESSION['actid'] = $id;
- foreach ($array_children as $parent_id => $children) {
- if ($id == $parent_id) {
- foreach ($children as $res1) {
- $array_type[] = $res1->type;
- $array_id[] = $res1->id;
- }
- }
- }
- $xmltype = implode(',', $array_type);
- $xmlid = implode(',', $array_id);
- $name = GetTaskNameAndDesc($type)[0];
- $sortTask = GetTaskStatus($id);
- if ($task->parent_id == '0') {
- // echo $task->id;
- $arrayTasksId[] = $id;
- //echo "<a href = '?act=tasks&activeid=$id&sort=$sort'>$id [$sort]. $name </a><br>";
- echo "<a href = '?act=tasks&activeid=$id&sort=$sort'>$id. $name </a><br>";
- echo $task->text . "<br>";
- // if ($task->getAccount() != null) {
- if ($sortTask < 5 && $sortTask > 1) {
- if ($task->status == 2) {
- $sname = "Выдана";
- $ass = "[".TimeString($task->assigned)."]";
- }
- else if ($task->status == 3) {
- $sname = "Принята";
- $ass = "[выдана: ".TimeString($task->assigned)."]";;
- }
- $sname = "<span style='color: darkgoldenrod'>$sname $ass:</span> ";
- }
- else if ($sortTask <= 1)
- $sname = "<span style='color: red'>Не выдана</span> ";
- else
- $sname = "<span style='color: green'>Выполнена:</span> ";
- if ($task->getAccount() != null) {
- $assignee_names_parent = $task->getAccount()->name;
- echo "$sname $assignee_names_parent<br><br>";
- }
- else
- echo "$sname<br><br>";
- // }
- }
- }
- // echo "<br><span style='color: black'>Доступные типы задач:</span><br><br>";
- //
- // foreach ($types as $type) {
- // //if ($type['main_task']) {
- // if ($type->main_task) {
- // echo "[Главная] ";
- // $sort = '1';
- // }
- // $tid = $type->GetId();
- // $tname = $type->name;
- // echo "<a href = '?act=tasktypes&activeid=" . $tid . "&sort=$sort'>$tid. $tname</a>";
- // echo '<br>';
- // }
- echo "<input type='hidden' id='activeproj' value=$activeid>";
- $sections = $proj->getSections();
- $numDM = 0;
- foreach ($sections as $section)
- {
- $dm = $section->diagnostic_map;
- if ($dm != null && $dm != '00000000-0000-0000-0000-000000000000')
- {
- $numDM++;
- }
- }
- $sizes = sizeof($sections);
- if ($sizes > 0 && $numDM == $sizes)
- $disabled = "";
- else
- $disabled = "disabled";
- if ($disabled) {
- echo "<span style='color: red'>Нет полных данных от АСУ СГ по секциям локомотива из данного проекта</span><br>";
- echo "<br><input id='get_sections_from_twx' type='button' value='Получить данные секций локомотива из АСУ СГ'>";
- }
- else {
- echo "<br><input id='write_project_to_twx' type='button' value='Запись в АСУ СГ'>";
- }
-
- if (intval($sort) < 5) {
- echo "<br><input id='project_complete' type='button' value='Закрыть проект (Завершение)'>";
- }
- echo '<input id="userId" hidden value="' . $id . '">';
- echo '<div id="result"></div>';
- echo '</p></div>';
- }
- }
- }
- $_SESSION['array_tasksid'] = $arrayTasksId;
- $_SESSION['proj_sort'] = $sort;
- echo '<p><a class="xlsbutton" href = XLSProjectList.php?activeid=' . $activeid . '&type=' . $xmltype . '&id=' . $xmlid . '><button class="control-bigbtn content__main__toexec-btn" >Скачать XLS акт</button></a></p>';
- echo '<p><a class="xlsbutton" href = XLStu162table.php?activeid=' . $activeid . '&type=' . $xmltype . '&id=' . $xmlid . '> <button class="control-bigbtn content__main__toexec-btn" >Скачать ТУ-162</button></a></p>';
- // ПОЛУЧЕНИЕ XML КОНЕЦ
- echo '</div>'; //main__content
- echo "<br><form id='form5' name='form5' method='post'>
- <input type='submit' value='Удалить все проекты' class='control-bigbtn'>
- <input type='hidden' name='new' value='5'>
- </form>";
- function EchoProjects($sort)
- {
- // echo "sort $sort";
- global $companyID, $link, $activeid, $project_limit;
- if ($project_limit == '20') {
- $project_limit = "limit 20";
- }
- else
- $project_limit = 'limit 2500';
- $str = "select * from projects_locotech where company=$companyID order by id desc $project_limit";
- $query1 = mysqli_query($link, $str); // limit 20
- $projects = array();
- while ($res1 = mysqli_fetch_array($query1)) {
-
- $data_id = $res1['id'];
- $status = $res1['status'];
- // $status = GetProjectStatus($data_id);
- // $status = intval($res1['status']);
- // echo "id $data_id status $status";
- if ($status != $sort){
- if ( !(2 == $sort and 3 == $status) ){
- continue;
- }
- }
- // $proj = Project::Find($data_id);
- // if ($proj == null) {
- //// echo "not found $data_id<br>";
- // continue;
- // }
- $loco_number = "Не найден!";//intval($res1['loco_number']);
- $subnumber = "Не найден!";
- /**
- * @var $section Section
- */
- // $section = $proj->section;
- // if ($section != null) {
- // echo "Section not found $data_id<br>";
- // $loco_number = $section->getSectionNumber();//intval($res1['loco_number']);
- // $subnumber = $section->getSectionSubnumber();
- // }
- $loco_number = intval($res1['loco_number']);
- $action = $res1['action'];
- // $status = intval($res1['status']);
- $loco_type = $res1['loco_type'];
- $depo = $res1['depo'];
- $created = $res1['created'];
- $depo_service = $res1['depo_service'];
- $class = 'content__menu__project';
- if ($activeid == $data_id)
- $class .= ' content__menu__project_active';
- else
- $class .= ' list';
- $action_data = FindAction($action);
- echo "<div onclick='SelectProject($data_id)' class='$class'>";
- echo "<div class=\"content__menu__project-title\">";
- echo $data_id.". ".$action_data["name"] ." <br> $loco_type № $loco_number";
- echo "</div>";
- echo '<div class="content__menu___project-text">';
- if (intval($res1['urgent']))
- $urgent = "<span style='color: #bf800c'> Срочный</span>";
- else
- $urgent = "";
- echo "Поступил: $created.$urgent";
- echo '<br><br></div>';
- if($status == '1')
- echo "<input type='button' onclick='AssignTask($data_id, $action, $companyID)' value='В работу!'>";
- echo " <input type='button' onclick='DelProj($data_id)' value='Удалить'>";
- echo " <input type='button' onclick='EditGantt($data_id)' value='План'>";
- echo '</div>';
- }
- }
- //new project
- function AddNewProject()
- {
- global $action, $company;
- echo
- '
- <div class="content__main">
- <h2 class="content__title content__new__title">
- Введите данные <br>
- для нового проекта
- </h2>';
- $series = LocoSeries::GetAllNames();
- // \Doctrine\Common\Util\Debug::dump($series);
- // $series = $series->toArray();
- //foreach ($series as $serie)
- //{
- // echo $serie."<br>";
- //}
- echo '<form action="?act=projects" method="post" class="content__main__form">
- <div class="content__main__form__item">
- <p class="content__main__form__text">
- Тип проекта
- <select id="projecttypes" class="form-input content__main__form__goal" name="action_num">';
- //ActionsForm(FindActions());
- ActionsForm(FindActions(), $action);
- echo '</select>
- <br>
- <div id="chooseseries"></div>
- </p>
- </div>
- <p class="content__main__form__text">Срочный: <input type="checkbox" name="urgent" style="width:20px; height:20px; margin-left: 5px"></p>
- <div class="content__main__form__item">';
- include "loco.php";
- echo '<div>';
- // <select class="form-input content__main__form__series" name="loco_type">';
- // foreach ($series as $serie) {
- // echo "<option value = '$serie' >$serie</option >";
- // }
- //echo '</select>
- echo '<p class="content__main__form__text">Номер локомотива - ручной ввод:</p><input type="text" min="1" name="loco_number" >';
- echo '</div>
- </div>
- ';
- // if ($company != null)
- // {
- // foreach ($company->locations as $location)
- // {
- // if ($location->type == "sld")
- // echo "<option value='$location->id'>$location->name</option>";
- // }
- // }
- //<option value="Братское">Братское</option>
- echo '
- <input type="submit" value="Добавить в новые и отправить в работу">
- <input type="hidden" name="new" value="2">
- </form>
- </div>
- ';
- }
- ?>
|