staff.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <?
  2. if (!$logged_me_in_successfully234)
  3. return;
  4. require_once( "fpdf/fpdf.php" );
  5. include "qrcode.php";
  6. $shiftEntity = \app\models\entity\Shift::find()->all();
  7. if ($new == "1")
  8. {
  9. echo "<form action='?act=staff' method='post'>
  10. <b>Введите данные нового сотрудника:</b>
  11. <br>
  12. <p>ФИО: <input name='staffName''></p>
  13. <p>Имя аккаунта: <input name='staffAccount'></p>
  14. <p>Уровень аккаунта:
  15. <select name='cmd'>
  16. <option value='1''>Company Admin#</option>
  17. <option value='2'>Company Operator#</option>
  18. </select>
  19. </p>
  20. <p>Смена:
  21. <select name='shift'>";
  22. foreach( $shiftEntity as $shift) {
  23. echo "<option value='".$shift->id."'>". $shift->name."</option>";
  24. }
  25. echo " </select>
  26. </p>
  27. <p>Телефон: <input name='staffPhone'></p>
  28. <p>Пароль: <input name='pwd'></p>
  29. <input type='submit' value='Добавить'>
  30. <input type='hidden' name='new' value='6'>
  31. </form>";
  32. echo '<p></p><a href="?act=staff">Вернуться к списку сотрудников</a></p>';
  33. }
  34. else if ($new == "2")
  35. {
  36. echo '<form action="?act=devices" method="post">
  37. <b>Отсканируйте или распечатайте данный QR-код для идентификации сотрудника '.$staff_name.'!</b>
  38. <br></form>';
  39. $buf=pack("vL*",1, $staff_id); //заголовок - номер пакета 1б и длина 2б. v-ushort, c- byte, C- ubyte, s - short, L - int, l - uint
  40. $hex_string = base64_encode($buf);
  41. $filename = $PNG_TEMP_DIR.'test'.md5($hex_string.'|'.$errorCorrectionLevel.'|7').'.png';
  42. QRcode::png($hex_string, $filename, $errorCorrectionLevel, 7, 2);
  43. echo '<img src="'.$PNG_WEB_DIR.basename($filename).'" />';
  44. echo '<p>'.$hex_string.'</p>';
  45. if ($cmdlevel == 10) {
  46. $acc = Account::Find($staff_id);
  47. $decr = encrypt_decrypt('decrypt', $acc->hash);
  48. echo "<b>Account:</b> ".$acc->getLogin();
  49. echo "<br><b>Password:</b> $decr ";
  50. }
  51. $_SESSION['printer'] = $staff_id;
  52. if (!isset($print)) {
  53. echo '<br><br><input name="Subm" type="button" id="Subm" onclick="openwin(\'staff\',' . $staff_id . ',\''.$staff_name.'\')" value="Печать">';
  54. echo '<p></p><a href="?act=staff">Вернуться к списку сотрудников</a></p>';
  55. }
  56. }
  57. else if ($new == "7" && 10 == $cmdlevel )
  58. {
  59. //echo $staff_id;
  60. $query1 = mysqli_query($link, "select `name`,`cmdlevel`,`login`,`shift_id` from accounts where company=$companyID and id=$staff_id");
  61. //while($res2 = mysqli_fetch_row($query1)){
  62. //var_dump($res2);
  63. //}
  64. $res = mysqli_fetch_assoc($query1);
  65. $checked = ( 0 != $res['cmdlevel'])?
  66. "<p>Деактивировать пользователя: <input type='checkbox' name='deactivate' value='1' ></p>":
  67. "<p>Активировать пользователя: <input type='checkbox' name='deactivate' value='2' ></p>";
  68. echo "<form action='?act=staff' method='post'>
  69. <b>Изменить данные сотрудника:</b>
  70. <br>
  71. <p><input type='hidden' name='staff_id' value='".$staff_id."'></p>
  72. <p>ФИО: <input name='staffName'' value='".$res['name']."'></p>
  73. <p>Смена:
  74. <select name='shift'>";
  75. foreach( $shiftEntity as $item_shift) {
  76. $selected = '';
  77. if ( $res['shift_id'] == $item_shift->id) {
  78. $selected = 'selected';
  79. }
  80. echo "<option value='".$item_shift->id."' ".$selected.">". $item_shift->name."</option>";
  81. }
  82. echo " </select>
  83. </p>
  84. <p>Логин: <input name='log' value='".$res['login']."'></p>
  85. <p>Пароль: <input name='pwd'></p>
  86. " . $checked."
  87. <input type='submit' value='Отправить'>
  88. <input type='hidden' name='new' value='8'>
  89. </form>";
  90. echo '<p></p><a href="?act=staff">Вернуться к списку сотрудников</a></p>';
  91. }
  92. else
  93. {
  94. if ($new == "3")
  95. {
  96. $account = Account::Find($new_job_accid);
  97. /**
  98. * @var $account Account
  99. */
  100. if ($account != null)
  101. {
  102. $jobsize = sizeof($account->getJobtypes());
  103. $jobtype = Jobtype::Find($new_jobtype_id);
  104. if ($jobtype != null && !$account->hasJobtype($jobtype)) {
  105. $account->addJobtype($jobtype, $jobsize);
  106. $account->Save();
  107. AddJob($new_job_accid, $new_jobtype_id, $job_ids);
  108. }
  109. }
  110. }
  111. if ($new == "4")
  112. {
  113. UpdateJob($newjob_accid, $jobvalue, $index, $previous);
  114. }
  115. else if ($new == '5')
  116. {
  117. Account::ClearTasksFromAccount($del_id);
  118. }
  119. else if ($new == '6')
  120. {
  121. $hash = encrypt_decrypt('encrypt', $pwd);
  122. $pwd = md5($pwd);
  123. //echo '<pre>' . $pwd . '<pre>';
  124. //echo "insert into accounts (name, cmdlevel, phone, password, login, company) values ('$staffName', $cmd, '$staffPhone', '$pwd','$staffAccount', '$companyID')";
  125. $query1 = mysqli_query($link, "insert into accounts (name, cmdlevel, phone, password, login, company, hash, company_id, shift_id) values ('$staffName', $cmd, '$staffPhone', '$pwd','$staffAccount', '$companyID','$hash', $companyID, '$shift')");
  126. //echo '<pre>' . $query1 . '<pre>';
  127. $lastid = mysqli_insert_id($link);
  128. //echo '<pre>' . $lastid . '<pre>';
  129. if ($lastid > 0)
  130. echo "<span style='color:green'><b>Запись добавлена!</b></span>";
  131. else
  132. echo "<span style='color:red'><b>Ошибка! Проверьте правильность заполнения полей. Возможно имя или логин уже заняты.</b></span>";
  133. }
  134. else if ($new == '8' && 10 == $cmdlevel )
  135. {
  136. $deactivateCheckbox = '';
  137. if ( 1 == $deactivate) {
  138. $deactivateCheckbox = ',cmdlevel = 0, company = company + 100'; }
  139. if ( 2 == $deactivate) {
  140. $deactivateCheckbox = ',cmdlevel = 1' ;
  141. }
  142. if ( '' != $pwd ) {
  143. $hash = encrypt_decrypt('encrypt', $pwd);
  144. $pwd = md5($pwd);
  145. $lastid = mysqli_query($link, "update accounts set name='$staffName', password='$pwd', hash='$hash' ". $deactivateCheckbox .", login='$log', shift_id='$shift' where id=$staff_id");
  146. } else {
  147. $lastid = mysqli_query($link, "update accounts set name='$staffName' ". $deactivateCheckbox .", login='$log', shift_id='$shift' where id=$staff_id");
  148. }
  149. if ($lastid > 0)
  150. echo "<span style='color:green'><b>Запись добавлена!</b></span>";
  151. else
  152. echo "<span style='color:red'><b>OOOOОшибка! Проверьте правильность заполнения полей. Возможно имя или логин уже заняты.</b></span>";
  153. }
  154. echo "<div style='width: 540px;'></div>";
  155. echo '<h3>Сотрудники компании '.$companyname.'</h3><br>';
  156. echo "<div id='result' style='border: solid; border-width: 1px'></div>";
  157. $jobtypes_company = GetJobtypes($companyID);
  158. $strinOptionJob = '';
  159. foreach( $jobtypes_company as $job){
  160. $strinOptionJob .= "<option value='".$job['id']."' >".$job['name']."</option>";
  161. }
  162. $job_typeArray = ['all'=>'Все должности','main' => 'Основная', 'slave' => 'Замещающая'];
  163. $stringOption = '';
  164. foreach( $job_typeArray as $keys => $job_t) {
  165. $stringOption .= "<option value='" . $keys . "' >" . $job_t ."</option>";
  166. }
  167. $ascArray = ['ASC'=>'А-Я','DESC' => 'Я-А'];
  168. $strinOptionShift = '';
  169. foreach( $shiftEntity as $item_shift) {
  170. $strinOptionShift .= "<option value='".$item_shift->id."' >". $item_shift->name."</option>";
  171. }
  172. echo "<br>
  173. <form id='form6' name='form6' method='post' >
  174. <select name='asc' id='asc_sort'>";
  175. foreach( $ascArray as $key => $item_asc){
  176. echo "<option ".$selected." value='".$key."' >".$item_asc."</option>";
  177. }
  178. echo "
  179. </select>
  180. <select name='kind' id='kind_sort' style='width:100px'>
  181. <option value='allstaff' >Все</option>
  182. <option value='last_seen_web'>Онлайн Веб</option>
  183. <option value='last_seen_mobile'>Онлайн Мобил</option>
  184. <option value='offline'>Оффлайн</option>
  185. </select>";
  186. echo "<select name='jobs_type' id='jobs_type_sort'>" . $stringOption . "</select>";
  187. echo "<select name='jobs' id='jobs_sort'>
  188. <option value='0'>Без фильтрации</option>" . $strinOptionJob . "</select>";
  189. echo "<select name='shift' id='shift_sort'>
  190. <option value='0' selected >Все смены</option>" . $strinOptionShift . "</select>";
  191. echo "
  192. </form>
  193. ";
  194. if (isset($shift)){
  195. echo "<script>
  196. $('select#shift_sort').val('".$shift."');
  197. </script>";
  198. }
  199. if (isset($jobs_type)){
  200. echo "<script>
  201. $('select#jobs_type_sort').val('".$jobs_type."');
  202. </script>";
  203. }
  204. if (isset($jobs)){
  205. echo "<script>
  206. $('select#jobs_sort').val('".$jobs."');
  207. </script>";
  208. }
  209. if (isset($kind)){
  210. echo "<script>
  211. $('select#kind_sort').val('".$kind."');
  212. </script>";
  213. }
  214. if (isset($asc)){
  215. echo "<script>
  216. $('select#asc_sort').val('".$asc."');
  217. </script>";
  218. }
  219. echo "
  220. <form id='form2' name='form2' method='post'>
  221. <input type='submit' value='Добавить нового сотрудника'>
  222. <input type='hidden' name='new' value='1'>
  223. </form>
  224. ";
  225. echo "
  226. <input type='submit' value='Скачать список в pdf' onclick='downloadStaff()'>
  227. <input type='hidden' name='new' value='1'>
  228. ";
  229. $find_staff = (isset($find_staff)) ? $find_staff : '';
  230. echo "
  231. <form id='form7' name='form7' method='post'>
  232. <input type='text' name='find_staff' value='". $find_staff ."' placeholder = 'Введите ФИО сотрудника' size='50'>
  233. <input type='submit' value='Найти сотрудника' >
  234. </form>
  235. ";
  236. echo '<div id="tabs">
  237. <ul>
  238. <li><a href="#tabs-1">Список</a></li>
  239. <li><a href="#tabs-2">Таблица</a></li>
  240. </ul>';
  241. echo "<div id='tabs-1'>
  242. <form id='form1' name='form1' method='post'>";
  243. // GetOnlineAccountList();
  244. $query1 = mysqli_query($link, "select * from accounts where company=$companyID");
  245. /**
  246. * @var $company Company
  247. */
  248. $orderName = 'name';//(isset($kind) and null != $kind )? $kind : 'name' ;
  249. $orderValue = (isset($asc) and null != $asc )? "".$asc : 'ASC' ;
  250. $sort = $orderName .' '.$orderValue;
  251. $filter3 = [];
  252. $filter4 = [];
  253. $filter2 = [];
  254. if (isset($find_staff)) {
  255. $filter2 = ['like', 'name', $find_staff];
  256. }
  257. $filter['company'] = $companyID;
  258. if ( $shift > 0 ) {
  259. $filter['shift_id'] = $shift;
  260. }
  261. if ( 'slave' == $jobs_type ) {
  262. $filter3 = ['<>','priority',0];// = $shift_filter;
  263. }
  264. switch ($jobs_type){
  265. case 'main':
  266. $filter3 = ['=','priority',0];
  267. break;
  268. case 'slave':
  269. $filter3 = ['<>','priority',0];
  270. break;
  271. case 'all':
  272. $filter3 = ( null != $jobs && '0' != $jobs)? ['=', 'jobtype_id', $jobs] :[];
  273. break;
  274. }
  275. //var_dump($_POST);
  276. if( 0 != $jobs && null !== $jobs && null != $jobs_type && 'all' != $jobs_type) {
  277. $filter['jobtype_id'] = $jobs;
  278. }
  279. //echo '<pre>';
  280. //var_dump($filter, $filter2,$filter3);
  281. //echo '</pre>';
  282. //var_dump($filter4,$jobs);
  283. //exit;
  284. //$accountsEntity = \app\models\entity\Accounts::find()->where($filter)->andWhere($filter2)->orderBy($sort)->all();
  285. $accountsEntity = \app\models\entity\Accounts::find()
  286. ->joinWith('accountsJobtypes', ['account_id' => 'id'], 'LEFT JOIN')
  287. ->where($filter)
  288. ->andWhere($filter2)
  289. ->andWhere($filter3)
  290. //->andWhere($filter4)
  291. ->orderBy($sort)
  292. ->all();
  293. $company = Company::Find($companyID);
  294. $accounts = $company->accounts;
  295. // \Doctrine\Common\Util\Debug::dump($accounts);
  296. //$tasks = $entityManager->getRepository('Task')->findAll();
  297. //var_dump(count($accountsEntity));
  298. //var_dump(count());
  299. // $accs = Account::GetIdle($companyID);
  300. // \Doctrine\Common\Util\Debug::dump($accs);
  301. $accountsEntityCount = count($accountsEntity);
  302. $count = 1;
  303. echo "<span id='accountsEntityCount' data_pos='$accountsEntityCount' data_pos_num='$count'></span>";
  304. foreach ($accountsEntity as $account)
  305. {
  306. $staff_id = $account->id;
  307. $staff_name = $account->name;
  308. $staff_cmdlevel = $account->cmdlevel;
  309. $overplan_mode = $account->overplan_mode?"Внеплан":"";
  310. // $active_task_id = $account->getActiveTaskIds();
  311. $activeTasks = $account->tasks;
  312. $last_seen_mobile = ( null != $account->last_seen_mobile )? new DateTime($account->last_seen_mobile): $account->last_seen_mobile ;
  313. $last_seen_web = ( null != $account->last_seen_web ) ? new DateTime($account->last_seen_web) : $account->last_seen_web;
  314. $online_mobile = OnlineAccountCheck(TimeString($last_seen_mobile));
  315. $online_web = OnlineAccountCheck(TimeString($last_seen_web));
  316. if ( !$online_web && 'last_seen_web' == $kind ){
  317. continue;
  318. }
  319. if ( !$online_mobile && 'last_seen_mobile' == $kind ){
  320. continue;
  321. }
  322. if ( ($online_mobile || $online_web) && 'offline' == $kind ){
  323. continue;
  324. }
  325. // echo " <h4 style='font-size: 1.8rem;'>". $staff_name ."<b><span style='color: darkolivegreen'> [".$staff_id."] </b></h4> <div >";
  326. echo "<div style='border: solid; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; margin-bottom:20px; padding: 5px'>";
  327. //var_dump(TimeString($last_seen_web));
  328. //var_dump($online_web);
  329. // var_dump($last_seen_web);
  330. if ($online_mobile) {
  331. echo "<span style='color: green'>Online </span>";
  332. }
  333. if ($online_web) {
  334. echo "<span style='color: darkcyan'>OnlineWeb </span>";
  335. }
  336. if (sizeof($activeTasks) > 0) {
  337. echo "<span style='color: darkred'>Есть незавершённые задачи </span>";
  338. }
  339. if ($online_mobile) {
  340. echo "<span id='quitAccount' title='$staff_id' style='color: darkred; cursor: pointer'>Выход</span>";
  341. }
  342. //Quit($accid)
  343. if ($overplan_mode)
  344. echo "<span style='color: darkorange'>Внеплан</span>";
  345. echo "<div id='data_pos_top_$count' class='slider_staff_toggle" . $staff_id . "_top' ></div>";
  346. $query2 = mysqli_query($link, "select name from accounttypes where type=$staff_cmdlevel");
  347. if ($res2 = mysqli_fetch_row($query2))
  348. {
  349. $type = $res2[0];
  350. }
  351. $job_ids_account = $account->accountsJobtypes;//getJobtypesIds();
  352. $arrIds = [];
  353. foreach($job_ids_account as $id) {
  354. $arrIds[] = $id->jobtype_id;
  355. }
  356. $jobstr = implode(',', $arrIds);
  357. //$jobstr = implode(',', $job_ids_account);
  358. if ($jobstr=='')
  359. $jobstr = '""';
  360. else
  361. $jobstr = '"'.$jobstr.'"';
  362. //$jobnames_account = GetJobNames($job_ids_account);
  363. $jobnames_account = GetJobNames($arrIds);
  364. $jobamount = sizeof($jobnames_account);
  365. $jobnamesstring = implode(',', $jobnames_account);
  366. $ttshow = '';
  367. if (sizeof($activeTasks) == 0) {
  368. $ttshow = 'нет';
  369. }
  370. echo "</span><h4 class='button_staff_toggle' data='slider_staff_toggle" . $staff_id . "'>$staff_name <b><span style='color: darkolivegreen'>[$staff_id]</b></h4> ";
  371. echo "<div class='slider_staff_toggle" . $staff_id . "' style='display: none;'><input type='button' onclick='ChangeStaff($staff_id,\"$staff_name\")' value='QR'> ";
  372. if( 10 == $cmdlevel ) {
  373. echo "<input type='button' onclick='UpdateStaff($staff_id,\"$staff_name\")' value='Изменить данные пользователя/удалить'> ";
  374. }
  375. echo "<p><h4 style='margin-bottom: 5px'>Активные задачи:</h4> $ttshow ";
  376. // $active_tasks = explode(',',$active_task_id);
  377. // asort($active_tasks);
  378. if (sizeof($activeTasks) > 0) {
  379. foreach ($activeTasks as $task) {
  380. //
  381. // @var $task Task
  382. //
  383. // $task = GrabTask($atask);
  384. $parent = intval($task->parent_id);
  385. $projid = $task->project->id;
  386. $tasktype = $task->type;
  387. $taskTypeName = GrabTasktype($tasktype)['name'];
  388. // $status = GetTaskStatus($atask);
  389. $status = $task->status;
  390. $color = "blue";
  391. if ($status == 2)
  392. {
  393. $color = "darkorange";
  394. }
  395. elseif ($status == 3)
  396. $color = "darkolivegreen";
  397. elseif ($status == 5)
  398. $color = "green";
  399. $sname = getTaskStatusName($status);
  400. echo "<b>";
  401. $myid = $task->id;
  402. if ($parent != 0) {
  403. $myid = $parent;
  404. echo 'Команда ';
  405. }
  406. else
  407. {
  408. echo "(Проект $projid) ";
  409. }
  410. $sort = $status;
  411. echo $task->id . ":</b><a href='?act=tasks&activeid=$myid&sort=$sort'> $taskTypeName </a><b>Статус:</b> <span style='color: $color'>".$sname[0]."</span>";
  412. echo '<br>';
  413. }
  414. echo '</p>';
  415. }
  416. echo "<br><h4>Должности:</h4> ";
  417. $countbasic = intval($account->basic_jobs_count);
  418. echo "Количество основных должностей: ";
  419. echo "<input id='basic_count' type='number' min='1' value='$countbasic' onchange='ChangeBasic(this.value, $staff_id)'>";
  420. $jobtypes_company = GetJobtypes($companyID);
  421. EchoJobs($staff_id, $jobnames_account, $jobtypes_company, $countbasic,$count);
  422. echo "<br><input type='button' onclick='ShowJobs($staff_id, $jobstr)' value='Добавить должность'>";
  423. if (sizeof($activeTasks) > 0)
  424. echo " <input type='button' onclick='DelTasks($staff_id)' value='Стереть задачи'><br>";
  425. echo "<p><b>Среднее время выполнения задач за месяц </b>
  426. <select style='max-width: 100%'>";
  427. $effarr = EfficiencyReport($staff_id);
  428. echo sizeof($effarr);
  429. foreach ($effarr as $ttype=>$atime)
  430. {
  431. $tdesc = GetTaskNameAndDesc($ttype);
  432. if ($atime > 120)
  433. $atime = "---";
  434. echo "<option>".$tdesc[0]." выполняется за ".$atime." минут</option>";
  435. }
  436. echo "</select></p>";
  437. echo "</div>";
  438. echo "</div>";
  439. $count++;
  440. }
  441. /*
  442. foreach ($accounts as $account)
  443. {
  444. // echo " <h4 style='font-size: 1.8rem;'>". $staff_name ."<b><span style='color: darkolivegreen'> [".$staff_id."] </b></h4> <div >";
  445. echo "<div style='border: solid; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; margin-bottom:20px; padding: 5px'>";
  446. $staff_id = $account->id;
  447. $staff_name = $account->getName();
  448. $staff_cmdlevel = $account->getCmdlevel();
  449. // $active_task_id = $account->getActiveTaskIds();
  450. $activeTasks = $account->getActiveTasks();
  451. $last_seen_mobile = $account->getLastSeenMobile();
  452. $last_seen_web = $account->getLastSeenWeb();
  453. $online_mobile = OnlineAccountCheck(TimeString($last_seen_mobile));
  454. $online_web = OnlineAccountCheck(TimeString($last_seen_web));
  455. var_dump(TimeString($last_seen_web));
  456. var_dump($online_web);
  457. if ($online_mobile)
  458. echo "<span style='color: green'>Online </span>";
  459. if ($online_web)
  460. echo "<span style='color: darkcyan'>OnlineWeb </span>";
  461. $query2 = mysqli_query($link, "select name from accounttypes where type=$staff_cmdlevel");
  462. if ($res2 = mysqli_fetch_row($query2))
  463. {
  464. $type = $res2[0];
  465. }
  466. $job_ids_account = $account->getJobtypesIds();
  467. $jobstr = implode(',', $job_ids_account);
  468. if ($jobstr=='')
  469. $jobstr = '""';
  470. else
  471. $jobstr = '"'.$jobstr.'"';
  472. $jobnames_account = GetJobNames($job_ids_account);
  473. $jobamount = sizeof($jobnames_account);
  474. $jobnamesstring = implode(',', $jobnames_account);
  475. $ttshow = '';
  476. if (sizeof($activeTasks) == 0) {
  477. $ttshow = 'нет';
  478. }
  479. echo "</span><h4 class='button_staff_toggle' data='slider_staff_toggle" . $staff_id . "'>$staff_name <b><span style='color: darkolivegreen'>[$staff_id] </b></h4> ";
  480. echo "<div class='slider_staff_toggle" . $staff_id . "' style='display: none;'><input type='button' onclick='ChangeStaff($staff_id,\"$staff_name\")' value='QR'> ";
  481. if( 10 == $cmdlevel ) {
  482. echo "<input type='button' onclick='UpdateStaff($staff_id,\"$staff_name\")' value='Изменить данные пользователя/удалить'> ";
  483. }
  484. echo "<p><h4 style='margin-bottom: 5px'>Активные задачи:</h4> $ttshow ";
  485. $active_tasks = explode(',',$active_task_id);
  486. // asort($active_tasks);
  487. if (sizeof($activeTasks) > 0) {
  488. foreach ($activeTasks as $task) {
  489. //
  490. // @var $task Task
  491. //
  492. // $task = GrabTask($atask);
  493. $parent = intval($task->parent_id);
  494. $projid = $task->project->id;
  495. $tasktype = $task->type;
  496. $taskTypeName = GrabTasktype($tasktype)['name'];
  497. // $status = GetTaskStatus($atask);
  498. $status = $task->status;
  499. $color = "blue";
  500. if ($status == 2)
  501. {
  502. $color = "darkorange";
  503. }
  504. elseif ($status == 3)
  505. $color = "darkolivegreen";
  506. elseif ($status == 5)
  507. $color = "green";
  508. $sname = getTaskStatusName($status);
  509. echo "<b>";
  510. $myid = $task->id;
  511. if ($parent != 0) {
  512. $myid = $parent;
  513. echo 'Команда ';
  514. }
  515. else
  516. {
  517. echo "(Проект $projid) ";
  518. }
  519. $sort = $status;
  520. echo $task->id . ":</b><a href='?act=tasks&activeid=$myid&sort=$sort'> $taskTypeName </a><b>Статус:</b> <span style='color: $color'>".$sname[0]."</span>";
  521. echo '<br>';
  522. }
  523. echo '</p>';
  524. }
  525. echo "<br><h4>Должности:</h4> ";
  526. $countbasic = intval($account->basic_jobs_count);
  527. echo "Количество основных должностей: ";
  528. echo "<div id='result'></div>";
  529. echo "<input id='basic_count' type='number' min='1' value='$countbasic' onchange='ChangeBasic(this.value, $staff_id)'>";
  530. $jobtypes_company = GetJobtypes($companyID);
  531. EchoJobs($staff_id, $jobnames_account, $jobtypes_company, $countbasic);
  532. echo "<br><input type='button' onclick='ShowJobs($staff_id, $jobstr)' value='Добавить должность'>";
  533. if ($active_task_id != 'нет')
  534. echo " <input type='button' onclick='DelTasks($staff_id)' value='Стереть задачи'><br>";
  535. echo "<p><b>Среднее время выполнения задач за месяц </b>
  536. <select>";
  537. $effarr = EfficiencyReport($staff_id);
  538. echo sizeof($effarr);
  539. foreach ($effarr as $ttype=>$atime)
  540. {
  541. $tdesc = GetTaskNameAndDesc($ttype);
  542. if ($atime > 120)
  543. $atime = "---";
  544. echo "<option>".$tdesc[0]." выполняется за ".$atime." минут</option>";
  545. }
  546. echo "</select></p>";
  547. echo "</div>";
  548. echo "</div>";
  549. }
  550. */
  551. $arrayForPdf = [];
  552. echo "</form></div>
  553. <div id='tabs-2'>
  554. <table style='width:100%'>
  555. <tr>
  556. <th>Имя</th>
  557. <th>Логин</th>
  558. <th>Пароль</th>
  559. <th>QR код</th>
  560. </tr>";
  561. foreach ($accountsEntity as $account) {
  562. $buf = pack("vL*",1, $account->id); //заголовок - номер пакета 1б и длина 2б. v-ushort, c- byte, C- ubyte, s - short, L - int, l - uint
  563. $hex_string = base64_encode($buf);
  564. $filename = $PNG_TEMP_DIR.'test'.md5($hex_string.'|'.$errorCorrectionLevel.'|7').'.png';
  565. QRcode::png($hex_string, $filename, $errorCorrectionLevel, 7, 2);
  566. $decr = encrypt_decrypt('decrypt', $account->hash);
  567. echo "<tr>
  568. <td>". $account->name ."</td>
  569. <td>". $account->login ."</td>
  570. <td>". $decr ."</td>
  571. <td><img src='".$PNG_WEB_DIR.basename($filename)."' /></td>
  572. </tr>";
  573. $arrayForPdf[] = ['name' => $account->name,
  574. 'login' => $account->login,
  575. 'password' => $decr,
  576. 'qr' => $PNG_WEB_DIR.basename($filename)
  577. ];
  578. }
  579. echo "</table>
  580. </div>
  581. </div>";
  582. EchoEdit($jobtypes_company);
  583. }
  584. $_SESSION['staffQRList'] = $arrayForPdf;
  585. function EchoJobs($staff_id, $jobnames, $jobtypes, $countbasic,$count)
  586. {
  587. $account_jobindex = 0; //
  588. $basic = 0;
  589. $secondary = false;
  590. $countSubJob = count($jobnames)-1;
  591. $dataCount = '';
  592. foreach ($jobnames as $jobname)
  593. {
  594. foreach ($jobtypes as $jobtype) {
  595. if ($jobname == $jobtype['name']) {
  596. $previous = $jobtype['id']; break;
  597. }
  598. }
  599. //ChangeJob acc_id, new job id, index from company jobtypes list
  600. if ($basic == 0)
  601. {
  602. echo "<h5>Основные:</h5>";
  603. $dataCount = "data='" . $countSubJob ."'";
  604. }
  605. else if (!$secondary && $countbasic == $basic){
  606. $secondary = true;
  607. echo "<h5>Замещение:</h5>";
  608. $dataCount = '';
  609. }
  610. $data_pos_class = 'data_pos_'.$count.'_'.$account_jobindex;
  611. echo " <select id='jobselect$account_jobindex' name='jobs' $dataCount class='$data_pos_class' onchange='if (!ChangeJob(".$staff_id.", this.value, $account_jobindex, $previous)) this.form.reset();'>";
  612. foreach ($jobtypes as $jobtype) {
  613. $sel = "";
  614. if ($jobname == $jobtype['name'])
  615. $sel = "selected";
  616. echo "<option ".$sel." value='" . $jobtype['id'] . "'>" . $jobtype['name'] . "</option>";
  617. }
  618. echo "<option value='deletejob'>Очистить должность</option>";
  619. echo "</select>";
  620. if ($countbasic > $basic)
  621. {
  622. $basic++;
  623. }
  624. else
  625. echo "<br>";
  626. $account_jobindex++;
  627. }
  628. }
  629. function EchoEdit($jobtypes)//, $job_ids_account)
  630. {
  631. 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 \">";
  632. echo "<span style='color: green'><b>Выберите добавляемую должность:</b></span>";
  633. echo "<form id='form3' name='form3' method='post'>";
  634. echo " <select name='new_jobtype_id'>";
  635. foreach ($jobtypes as $jobtype)
  636. {
  637. echo "<option value='" . $jobtype['id'] . "'>" . $jobtype['name'] . "</option>";
  638. }
  639. echo "</select>";
  640. echo "<input type='submit' value='Добавить'>
  641. <input type='hidden' name='new' value='3'>
  642. <input type='hidden' name='new_job_accid' value=''>
  643. <input type='hidden' name='job_ids' value=''>";
  644. echo "</form></div><br>";
  645. }
  646. ?>