123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- <?
- use CheckPointTypes\CheckPointType;
- use Tasks\Task;
- if (!$logged_me_in_successfully234)
- return;
- if (!isset($sort))
- {
- $sort = $_SESSION['sorttasks'];
- if (!isset($sort)) {
- $sort = 1;
- }
- }
- $_SESSION['sorttasks'] = $sort;
- if ($new != "2" && $new != "3")
- $taskarr = GrabTasktypes();
- if ($new == "2") {
- $subtask_string = FillArrayString("subtask");
- //$subtask_string = implode(",", $subtask_arr);
- $main_task = $sort;
- if ($main_task)
- {
- $confirmtype = 0;
- $timecomplete = 0;
- }
- echo "<span style='color:green'><b>Тип задачи добавлен!</b></span>";
- $names = 'creator_id, name, description, company, subtasks, main_task, confirmtype, time_to_complete_minutes, object_name, control_map, letter';
- $values = $id.",'$taskname','$description',$companyID,'$subtask_string',$main_task,$confirmtype,$timecomplete,'$object_name','$control','$letter'";
- if (strlen($action)>0) {
- $names .= ', action';
- $values .= ",".$action;
- }
- $str = "insert into tasktypes (".$names.") values (".$values.")";
- mysqli_query($link, $str);
- $lastid = mysqli_insert_id($link);
- $taskarr = GrabTasktypes();
- if ( $_FILES )
- {
- // var_dump($_FILES);
- $file = $_FILES['filename'];
- $rootPath = $_SERVER['DOCUMENT_ROOT'];
- $videoPath = $rootPath."/guides/$lastid/";
- if(!is_dir($videoPath))
- {
- mkdir($videoPath);
- }
- //Временно!!!
- // echo "fname ".$file['name'];
- // echo "tmp_name ".$file['tmp_name'];
- $namearr = explode(".", $file['name'][0]);
- $ext = end($namearr);
- if ($ext == "mp4" || $ext == "pdf" || $ext == "jpg" || $ext == "jpeg" || $ext == "avi")
- $file['name'][0] = "video.mp4";
- $target = $videoPath.$file['name'][0];
- move_uploaded_file( $file['tmp_name'][0], $target);
- }
- }
- else if ($new == "3") {
- echo "<span style='color:red'><b>Тип задач $task_id удален!</b></span>";
- DeleteTasksByType($task_id);
- ClearTaskTypeFromJobs($task_id);
- mysqli_query($link, "delete from tasktypes where id =".$task_id);
- mysqli_query($link, "delete from checkpoint_types_for_tasks where tasktype_id=$task_id");
- $taskarr = GrabTasktypes();
- }
- echo "<input type='hidden' id='scroll' value=$scroll>";
- $active1 = '';
- $active0 = '';
- switch ($sort)
- {
- case '0': $active0 = 'control-btn_active'; break;
- case '1': $active1 = 'control-btn_active'; break;
- default: $active1 = 'control-btn_active'; $sort = '1';
- }
- $taskword = "задач";
- if ($sort == '0')
- $taskword = "команд";
- echo
- "
- <div class='main__content'>
- <div class='content__menu'>
- <h2 class='content__title content__menu__title'>
- Типы задач
- </h2>
- <div class='content__filter'>
- <img src='ProSysNew/search.svg' alt='search' class='content__search'>
- <div class='content__controls'>
- <button class='control-btn control-btn_green content__filter__btn $active1' onclick='SortElements(1, \"tasktypes\")'>Задачи</button>
- <button class='control-btn control-btn_yellow content__filter__btn $active0' onclick='SortElements(0, \"tasktypes\")'>Команды</button>
- </div>
- </div>";
- echo '<div class="content__menu__list">';
- echo " <div class='content__menu__newproj content__menu__newproj_active' onclick = 'NewListElement(\"tasktypes\")'>
- <div class='content__menu__newproj__plus'>
- +
- </div>
- <div class='content__menu__newproj__text'>
- Новый тип $taskword
- </div>
- </div><br>";
- EchoTasktypes($sort, $taskarr);
- echo '</div>';
- echo '</div>';
- //PARENT TITLE IN CHILDREN LIST
- if ($new == 1)
- AddNewTaskType();
- else {
- $ttype = GrabTasktype($activeid);
- $ttypend = GetTaskNameAndDesc($activeid);
- $acttname = $ttypend[0];
- $ttdesc = $ttypend[1];
- $actionid = $ttype['ProjectType'];
- $action = FindAction($actionid);
- $acname = $action['name'];
- $main = $ttype['main_task'];
- $control = $ttype['control_map'];
- $subs = explode(',',$ttype['subtasks']);
- if ($activeid)
- {
- echo "<div class='content__main'>
- <h2 id='activeTaskTypeId' data-activeid='$activeid' class=\"content__title content__main__title\">$activeid. $acttname<p class='content__main__form__text black'>$ttdesc </p></h2>";
- if ($main) {
- $mytt = Tasktype::Find($activeid);
- $letter = $mytt->letter;
- if ($letter)
- $lettername = "[Секция $letter]";
- echo "<h3>$lettername</h3>";
- echo "<p class='content__main__form__text black'><b>Типы проекта с данным типом задач:</b></p>";
- foreach ($mytt->getProjecttypes() as $ptype) {
- $actionid = $ptype->id;
- $acname = $ptype->name;
- echo "<p class='content__main__form__text black'><a href='?act=project_types&activeid=$actionid'>$actionid. $acname </a><br></p>";
- }
- echo "<br>";
- }
- // switch ($letter)
- // {
- // case "А": $selectedA = "selected"; break;
- // case "Б": $selectedB = "selected"; break;
- // case "В": $selectedV = "selected"; break;
- // case "Г": $selectedG = "selected"; break;
- // }
- // echo "Буква секции:
- // <select id='letter_tasktype' class='form-input content__main__form__series' name='letter'>
- // <option value='0'><Выберите букву секции></option>
- // <option $selectedA value='А'>А</option>
- // <option $selectedB value='Б'>Б</option>
- // <option $selectedV value='В'>В</option>
- // <option $selectedG value='Г'>Г</option>
- // </select>";
- if (!$main) {
- EchoCheckPoints($activeid);
- }
- $confirmtype = $ttype['confirmtype'];
- $confirmtypename = getConfirmTypeName($confirmtype);
- $zone = $ttype['zone_required_id'];
- echo "<br><p class='content__main__form__text black'><b>Способ подтверждения задачи:</b> $confirmtypename<br>";
- echo "<br><p class='content__main__form__text black'><b>Выполнить в зоне:</b> $zone (".GetZoneName($zone).")<br>";
- $time = intval($ttype['time_to_complete_minutes']);
- echo "<div id='result'></div>";
- echo "<br><p class='content__main__form__text black'><b>Время на выполнение:</b> $time минут<br>";
- if ($main) {
- echo "<p class='content__main__form__text black'><b>Добавленные типы команд:</b> <br></p>";
- echo "<p class='content__main__form__text'>";
- $num = 0;
- foreach ($subs as $typeid)
- {
- $type = GrabTasktype($typeid);
- $tid = $type['id'];
- $taction = $type['ProjectType'];
- $num++;
- if ($type['main_task'])
- echo "[Главная] ";
- echo "<a href = '?act=tasktypes&activeid=" . $tid . "&sort=0'>$num. " . $type['name'] . " [" . $type['id'] . "]</a>";
- echo '<br>';
- }
- echo "</p>";
- }
- if (!$main) {
- $addcmd = " для данной команды";
- }
- echo "<br><p class='content__main__form__text black'><b>Активные задачи$addcmd:</b><br>";
- $tasks = GrabTasksByType($activeid);
- foreach ($tasks as $task)
- {
-
- $type = $task['type'];
- $id = $task['id'];
- $ttname = GetTaskNameAndDesc($type)[0];
- //$sort = $task['status'];
- $sort = GetTaskStatus($id);
- if ($task['parent_id'] == '0')
- {
- echo "<a href = '?act=tasks&activeid=".$id."&sort=".$sort."'>".$id.". $ttname</a><br>";
- }
- else
- {
- echo "<a href = '?act=tasks&activeid=" . $task['parent_id'] . "&sort=" . $sort . "'>" . $task['parent_id'].". $acttname</a><br>";
- }
- }
- echo "</p>";
- $imgpath = GetVideoPathFromTasktype($activeid);
- $files1 = scandir($imgpath);
- if (sizeof($files1) > 2)
- {
- echo "<br>
- <div style='overflow: auto; '>";
- foreach ($files1 as $file )
- {
- $x = pathinfo($file)['extension'];
- if($file === '.' || $file === '..') {continue;}
- echo '<br>';
- if ($x == 'mp4' || $x == 'jpg' || $x == 'jpeg' || $x == 'pdf' || $x == 'avi') {
- echo "<div style='float:left'><p class='content__main__form__text black'><a href=\"javascript:openvideo('" . $imgpath . $file . "');\">$file</a></p></div>";
- // echo "<a href='$imgpath$file'>$file</a>";
- }
- echo '<br>';
- }
- echo '</div><br></p>';
- }
- echo "<br><input type='button' onclick='DelTaskType($activeid)' value='Удалить тип и задачи данного типа'>";
- echo '</div>';
- }
- }
- echo '</div>'; //main__content
- function EchoCheckPoints($activeid)
- {
- include "checkpoints.php";
- \CheckPoints\CheckPoint::EchoTypes($activeid);
-
- }
- function GetCheckListTypes($task_id)
- {
- global $link;
- $query = mysqli_query($link, "select * from checkpoint_types where parent_task_type = $task_id");
- $arr = array();
- while ($res = mysqli_fetch_array($query)) {
- array_push($arr, $res);
- }
- return $arr;
- }
- function EchoTaskTypes($sort, $arr, $chooseSubtasks = false)
- {
- global $activeid;
- foreach ($arr as $tasktype)
- {
- $tasktype_id = $tasktype->id;
- $taskname = $tasktype->name;
- $description = $tasktype->description;
- $main = $tasktype->main_task;
- $letter = $tasktype->letter;
- if ($letter)
- $letter = "[Секция $letter]";
- if ($main != $sort)
- continue;
- $completeTime = intval($tasktype->time_to_complete_minutes);
- $class = 'content__menu__project';
- if ($activeid == $tasktype_id)
- $class .= ' content__menu__project_active';
- else
- $class .= ' list';
- $myid = " id='active'";
- echo "<div onclick='SelectElement($tasktype_id, \"tasktypes\")' class='$class'";
- if ($activeid == $tasktype_id && !$main)
- echo $myid;
- echo ">";
- echo "<div class=\"content__menu__project-title\">";
- echo $tasktype_id.". $taskname $letter<br>";
- echo "</div>";
- echo "<input id='active_task_type' type='hidden' value='$activeid'>";
- echo '<div class="content__menu___project-text">';
- if ($description != '')
- echo " [$description]<br>";
- if (!$main)
- echo "<b>На выполнение:</b> ".$completeTime." минут";
- echo '<br><br></div></div>';
- }
- }
- //new project
- function AddNewTaskType()
- {
- global $companyID, $sort, $taskword, $Subtaskarr, $c_action, $numsel;
- if (!isset($c_action))
- $c_action = 2;
- $confirmtypes = GrabConfirmTypes(intval($companyID));
- echo "<div class=\"content__main\">
- <h2 class=\"content__title content__new__title\">
- Введите данные <br>
- нового типа $taskword
- </h2>";
- echo
- '<input type="hidden" name="MAX_FILE_SIZE" value="20000000">
- <form action="?act=tasktypes" method="post" class="content__main__form" enctype="multipart/form-data">
- <div class="content__main__form__item">';
- // echo ' <p class="content__main__form__text">
- // Тип объекта
- // </p>';
- // echo
- // '<select class="form-input content__main__form__series" name="object_name">
- // <option value="Э5К">Э5К</option>
- // <option value="2ЭС5К">2ЭС5К</option>
- // <option value="3ЭС5К3">3ЭС5К</option>
- // </select>
- // ';
- echo '</div>';
- if ($sort == '0') //КОМАНДЫ
- {
- echo "<p class='content__main__form__text'>Способ подтверджения выполнения команды:</p>
- <select class='form-input content__main__form__goal' name='confirmtype'>";
- foreach ($confirmtypes as $res) {
- echo "<option value='" . $res["id"] . "'>" . $res["name"] . "</option>";
- }
- echo "</select>
- <br><p class='content__main__form__text'>
- Время на выполнение (минуты)</p>";
- echo "<input type='text' name='timecomplete'>";
- }
- //ЗАДАЧИ
- else {
- // echo '<p class="content__main__form__text">Буква секции:
- // <select class="form-input content__main__form__series" name="letter">
- // <option value="А">А</option>
- // <option value="Б">Б</option>
- // <option value="В">В</option>
- // <option value="Г">Г</option>
- // </select>
- // </p> ';
- echo '<p class="content__main__form__text">
- Команды (подзадачи):
- </p> ';
- if (!isset($numsel))
- $numsel = 1;
- $Subtaskarr = GrabTasktypes(true);
- $sublen = sizeof($Subtaskarr);
- echo "<div id='taskcont'>";
- ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask");
- echo "</div>";
- }
- echo '<div class="content__main__form__item"><br>
- <p class="content__main__form__text">Имя:
- <input class="form-input content__main__form__goal" type = "text" name="taskname" value="">
- </p>
-
- <p class="content__main__form__text">
- Описание
- </p>
- <textarea style="width: 500px" name="description" rows="3"></textarea>
- <input type="hidden" name="new" value="2">
- <input type="hidden" name="main_task" value="0">';
- echo '</div>';
- if ($sort == '0') {
- echo '<input type="submit" value="Добавить в новые:"">
- <label for="videoload" >Выберите файлы</label>
- <input id="videoload" type="file" name="filename[]" accept=".mp4,.avi,.jpg,.jpeg,.pdf" multiple>';
- }
- else
- echo '<input type="submit" value="Добавить в новые">';
- echo '</form>';
- echo " </div>";
- echo "
- <script>
- $('#videoload').change(function() {
- if ($(this).val() != '') $(this).prev().text('Выбрано файлов: ' + $(this)[0].files.length);
- else $(this).prev().text('Выберите файлы');
- });
- </script>
- ";
- }
- ?>
|