123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <?
- if (!$logged_me_in_successfully234)
- return;
- if ($new == "1")
- {
- echo "<form action='?act=staff' method='post'>
- <b>Введите данные нового сотрудника:</b>
- <br>
- <p>ФИО: <input name='staffName''></p>
- <p>Имя аккаунта: <input name='staffAccount'></p>
- <p>Уровень аккаунта:
- <select name='cmd'>
- <option value='1''>Company Admin#</option>
- <option value='2'>Company Operator#</option>
- </select>
- </p>
- <p>Телефон: <input name='staffPhone'></p>
- <p>Пароль: <input name='pwd'></p>
- <input type='submit' value='Добавить'>
- <input type='hidden' name='new' value='6'>
- </form>";
- echo '<p></p><a href="?act=staff">Вернуться к списку сотрудников</a></p>';
- }
- else if ($new == "2")
- {
- include "qrcode.php";
- echo '<form action="?act=devices" method="post">
- <b>Отсканируйте или распечатайте данный QR-код для идентификации сотрудника '.$staff_name.'!</b>
- <br></form>';
- $buf=pack("vL*",1, $staff_id); //заголовок - номер пакета 1б и длина 2б. v-ushort, c- byte, C- ubyte, s - short, L - int, l - uint
- $hex_string = base64_encode($buf);
- $filename = $PNG_TEMP_DIR.'test'.md5($hex_string.'|'.$errorCorrectionLevel.'|7').'.png';
- QRcode::png($hex_string, $filename, $errorCorrectionLevel, 7, 2);
- echo '<img src="'.$PNG_WEB_DIR.basename($filename).'" />';
- echo '<p>'.$hex_string.'</p>';
- if ($cmdlevel == 10) {
- $acc = Account::Find($staff_id);
- $decr = encrypt_decrypt('decrypt', $acc->hash);
- echo "<b>Account:</b> ".$acc->getLogin();
- echo "<br><b>Password:</b> $decr ";
- }
- $_SESSION['printer'] = $staff_id;
- if (!isset($print)) {
- echo '<br><br><input name="Subm" type="button" id="Subm" onclick="openwin(\'staff\',' . $staff_id . ',\''.$staff_name.'\')" value="Печать">';
- echo '<p></p><a href="?act=staff">Вернуться к списку сотрудников</a></p>';
- }
- }
- else if ($new == "7" && 10 == $cmdlevel )
- {
-
-
- //echo $staff_id;
- $query1 = mysqli_query($link, "select `name`,`cmdlevel` from accounts where company=$companyID and id=$staff_id");
- //while($res2 = mysqli_fetch_row($query1)){
- //var_dump($res2);
- //}
-
- $res = mysqli_fetch_assoc($query1);
-
- $checked = ( 1 == $res['cmdlevel'])?
- "<p>Деактивировать пользователя: <input type='checkbox' name='deactivate' value='1' ></p>":
- "<p>Активировать пользователя: <input type='checkbox' name='deactivate' value='2' ></p>";
-
- echo "<form action='?act=staff' method='post'>
- <b>Изменить данные сотрудника сотрудника:</b>
- <br>
- <p><input type='hidden' name='staff_id' value='".$staff_id."'></p>
- <p>ФИО: <input name='staffName'' value='".$res['name']."'></p>
- <p>Логин: <input name='log' value='".$res['login']."'></p>
- <p>Пароль: <input name='pwd'></p>
- " . $checked."
-
- <input type='submit' value='Отправить'>
- <input type='hidden' name='new' value='8'>
- </form>";
- echo '<p></p><a href="?act=staff">Вернуться к списку сотрудников</a></p>';
- }
- else
- {
- if ($new == "3")
- {
- $account = Account::Find($new_job_accid);
- /**
- * @var $account Account
- */
- if ($account != null)
- {
- $jobsize = sizeof($account->getJobtypes());
- $jobtype = Jobtype::Find($new_jobtype_id);
- if ($jobtype != null && !$account->hasJobtype($jobtype)) {
- $account->addJobtype($jobtype, $jobsize);
- $account->Save();
- AddJob($new_job_accid, $new_jobtype_id, $job_ids);
- }
- }
- }
- if ($new == "4")
- {
- UpdateJob($newjob_accid, $jobvalue, $index, $previous);
- }
- else if ($new == '5')
- {
- Account::ClearTasksFromAccount($del_id);
- }
- else if ($new == '6')
- {
-
- $hash = encrypt_decrypt('encrypt', $pwd);
- $pwd = md5($pwd);
- //echo '<pre>' . $pwd . '<pre>';
- //echo "insert into accounts (name, cmdlevel, phone, password, login, company) values ('$staffName', $cmd, '$staffPhone', '$pwd','$staffAccount', '$companyID')";
- $query1 = mysqli_query($link, "insert into accounts (name, cmdlevel, phone, password, login, company, hash, company_id) values ('$staffName', $cmd, '$staffPhone', '$pwd','$staffAccount', '$companyID','$hash', $companyID)");
- //echo '<pre>' . $query1 . '<pre>';
- $lastid = mysqli_insert_id($link);
- //echo '<pre>' . $lastid . '<pre>';
- if ($lastid > 0)
- echo "<span style='color:green'><b>Запись добавлена!</b></span>";
- else
- echo "<span style='color:red'><b>Ошибка! Проверьте правильность заполнения полей. Возможно имя или логин уже заняты.</b></span>";
- }
- else if ($new == '8' && 10 == $cmdlevel )
- {
- $deactivateCheckbox = '';
- if ( 1 == $deactivate) {
- $deactivateCheckbox = ',cmdlevel = 0'; }
- if ( 2 == $deactivate) {
- $deactivateCheckbox = ',cmdlevel = 1' ;
- }
-
- if ( '' != $pwd ) {
- $hash = encrypt_decrypt('encrypt', $pwd);
- $pwd = md5($pwd);
- $lastid = mysqli_query($link, "update accounts set name='$staffName', password='$pwd', hash='$hash' ". $deactivateCheckbox .", login='$log' where id=$staff_id");
- } else {
- $lastid = mysqli_query($link, "update accounts set name='$staffName' ". $deactivateCheckbox .", login='$log' where id=$staff_id");
- }
- if ($lastid > 0)
- echo "<span style='color:green'><b>Запись добавлена!</b></span>";
- else
- echo "<span style='color:red'><b>OOOOОшибка! Проверьте правильность заполнения полей. Возможно имя или логин уже заняты.</b></span>";
- }
- echo '<h3>Сотрудники компании '.$companyname.'</h3><br>';
- $jobtypes_company = GetJobtypes($companyID);
- echo "<br>
- <form id='form2' name='form2' method='post'>
- <input type='submit' value='Добавить нового сотрудника'>
- <input type='hidden' name='new' value='1'>
- </form>
- ";
- echo "
- <form id='form1' name='form1' method='post'>";
- // GetOnlineAccountList();
- $query1 = mysqli_query($link, "select * from accounts where company=$companyID");
- /**
- * @var $company Company
- */
- $company = Company::Find($companyID);
- $accounts = $company->accounts;
- // \Doctrine\Common\Util\Debug::dump($accounts);
- $tasks = $entityManager->getRepository('Task')->findAll();
- // $accs = Account::GetIdle($companyID);
- // \Doctrine\Common\Util\Debug::dump($accs);
- foreach ($accounts as $account)
- {
- echo "<div style='border: solid; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; margin-bottom:20px; padding: 5px'>";
- $staff_id = $account->id;
- $staff_name = $account->getName();
- $staff_cmdlevel = $account->getCmdlevel();
- // $active_task_id = $account->getActiveTaskIds();
- $activeTasks = $account->getActiveTasks();
- $last_seen_mobile = $account->getLastSeenMobile();
- $last_seen_web = $account->getLastSeenWeb();
- $online_mobile = OnlineAccountCheck(TimeString($last_seen_mobile));
- $online_web = OnlineAccountCheck(TimeString($last_seen_web));
- //var_dump($last_seen_mobile);
- // var_dump($last_seen_web);
- if ($online_mobile)
- echo "<span style='color: green'>Online </span>";
- if ($online_web)
- echo "<span style='color: darkcyan'>OnlineWeb </span>";
- $query2 = mysqli_query($link, "select name from accounttypes where type=$staff_cmdlevel");
- if ($res2 = mysqli_fetch_row($query2))
- {
- $type = $res2[0];
- }
- $job_ids_account = $account->getJobtypesIds();
- $jobstr = implode(',', $job_ids_account);
- if ($jobstr=='')
- $jobstr = '""';
- else
- $jobstr = '"'.$jobstr.'"';
- $jobnames_account = GetJobNames($job_ids_account);
- $jobamount = sizeof($jobnames_account);
- $jobnamesstring = implode(',', $jobnames_account);
- $ttshow = '';
- if (sizeof($activeTasks) == 0) {
- $ttshow = 'нет';
- }
- echo "<input type='button' onclick='ChangeStaff($staff_id,\"$staff_name\")' value='QR'> ";
- echo "</span><h4>$staff_name <b><span style='color: darkolivegreen'>[$staff_id] </h4></b> ";
- if( 10 == $cmdlevel ) {
- echo "<input type='button' onclick='UpdateStaff($staff_id,\"$staff_name\")' value='Изменить данные пользователя/удалить'> ";
- }
-
- echo "<p><h4 style='margin-bottom: 5px'>Активные задачи:</h4> $ttshow ";
- $active_tasks = explode(',',$active_task_id);
- // asort($active_tasks);
- if (sizeof($activeTasks) > 0) {
- foreach ($activeTasks as $task) {
- /**
- * @var $task Task
- */
- // $task = GrabTask($atask);
- $parent = intval($task->parent_id);
- $projid = $task->project->id;
- $tasktype = $task->type;
- $taskTypeName = GrabTasktype($tasktype)['name'];
- // $status = GetTaskStatus($atask);
- $status = $task->status;
- $color = "blue";
- if ($status == 2)
- {
- $color = "darkorange";
- }
- elseif ($status == 3)
- $color = "darkolivegreen";
- elseif ($status == 5)
- $color = "green";
- $sname = getTaskStatusName($status);
- echo "<b>";
- $myid = $task->id;
- if ($parent != 0) {
- $myid = $parent;
- echo 'Команда ';
- }
- else
- {
- echo "(Проект $projid) ";
- }
- $sort = $status;
- echo $task->id . ":</b><a href='?act=tasks&activeid=$myid&sort=$sort'> $taskTypeName </a><b>Статус:</b> <span style='color: $color'>".$sname[0]."</span>";
- echo '<br>';
- }
- echo '</p>';
- }
- echo "<br><h4>Должности:</h4> ";
- $countbasic = intval($account->basic_jobs_count);
- echo "Количество основных должностей: ";
- echo "<div id='result'></div>";
- echo "<input id='basic_count' type='number' min='1' value='$countbasic' onchange='ChangeBasic(this.value, $staff_id)'>";
- $jobtypes_company = GetJobtypes($companyID);
- EchoJobs($staff_id, $jobnames_account, $jobtypes_company, $countbasic);
- echo "<br><input type='button' onclick='ShowJobs($staff_id, $jobstr)' value='Добавить должность'>";
- if ($active_task_id != 'нет')
- echo " <input type='button' onclick='DelTasks($staff_id)' value='Стереть задачи'><br>";
- echo "<p><b>Среднее время выполнения задач за месяц </b>
- <select>";
- $effarr = EfficiencyReport($staff_id);
- echo sizeof($effarr);
- foreach ($effarr as $ttype=>$atime)
- {
- $tdesc = GetTaskNameAndDesc($ttype);
- if ($atime > 120)
- $atime = "---";
- echo "<option>".$tdesc[0]." выполняется за ".$atime." минут</option>";
- }
- echo "</select></p>";
- echo "</div>";
- }
- echo "</form>";
- EchoEdit($jobtypes_company);
- }
- function EchoJobs($staff_id, $jobnames, $jobtypes, $countbasic)
- {
- $account_jobindex = 0; //
- $basic = 0;
- $secondary = false;
- foreach ($jobnames as $jobname)
- {
- foreach ($jobtypes as $jobtype) {
- if ($jobname == $jobtype['name']) {
- $previous = $jobtype['id']; break;
- }
- }
- //ChangeJob acc_id, new job id, index from company jobtypes list
- if ($basic == 0)
- {
- echo "<h5>Основные:</h5>";
- }
- else if (!$secondary && $countbasic == $basic){
- $secondary = true;
- echo "<h5>Замещение:</h5>";
- }
- echo " <select id='jobselect$account_jobindex' name='jobs' onchange='if (!ChangeJob(".$staff_id.", this.value, $account_jobindex, $previous)) this.form.reset();'>";
- foreach ($jobtypes as $jobtype) {
- $sel = "";
- if ($jobname == $jobtype['name'])
- $sel = "selected";
- echo "<option ".$sel." value='" . $jobtype['id'] . "'>" . $jobtype['name'] . "</option>";
- }
- echo "<option value='deletejob'>Очистить должность</option>";
- echo "</select>";
- if ($countbasic > $basic)
- {
- $basic++;
- }
- else
- echo "<br>";
- $account_jobindex++;
- }
- }
- function EchoEdit($jobtypes)//, $job_ids_account)
- {
- echo "<div id='jobs_block' style=\"display: none; margin-left: 0px; padding: 10px; background-color: white; border-color: #E1E1E1; border: solid; border-width: 1px; position: fixed; top: 100px;left: 300px \">";
- echo "<span style='color: green'><b>Выберите добавляемую должность:</b></span>";
- echo "<form id='form3' name='form3' method='post'>";
- echo " <select name='new_jobtype_id'>";
- foreach ($jobtypes as $jobtype)
- {
- echo "<option value='" . $jobtype['id'] . "'>" . $jobtype['name'] . "</option>";
- }
- echo "</select>";
- echo "<input type='submit' value='Добавить'>
- <input type='hidden' name='new' value='3'>
- <input type='hidden' name='new_job_accid' value=''>
- <input type='hidden' name='job_ids' value=''>";
- echo "</form></div><br>";
- }
- ?>
|