all(); if ($new == "1") { echo "
Введите данные нового сотрудника:

ФИО:

Имя аккаунта:

Уровень аккаунта:

Смена:

Телефон:

Пароль:

"; echo '

Вернуться к списку сотрудников

'; } else if ($new == "2") { echo '
Отсканируйте или распечатайте данный QR-код для идентификации сотрудника '.$staff_name.'!
'; $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 ''; echo '

'.$hex_string.'

'; if ($cmdlevel == 10) { $acc = Account::Find($staff_id); $decr = encrypt_decrypt('decrypt', $acc->hash); echo "Account: ".$acc->getLogin(); echo "
Password: $decr "; } $_SESSION['printer'] = $staff_id; if (!isset($print)) { echo '

'; echo '

Вернуться к списку сотрудников

'; } } else if ($new == "7" && 10 == $cmdlevel ) { //echo $staff_id; $query1 = mysqli_query($link, "select `name`,`cmdlevel`,`login`,`shift_id` from accounts where company=$companyID and id=$staff_id"); //while($res2 = mysqli_fetch_row($query1)){ //var_dump($res2); //} $res = mysqli_fetch_assoc($query1); $checked = ( 0 != $res['cmdlevel'])? "

Деактивировать пользователя:

": "

Активировать пользователя:

"; echo "
Изменить данные сотрудника:

ФИО:

Смена:

Логин:

Пароль:

" . $checked."
"; echo '

Вернуться к списку сотрудников

'; } 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 '
' . $pwd . '
';
        //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, shift_id) values ('$staffName', $cmd, '$staffPhone', '$pwd','$staffAccount', '$companyID','$hash', $companyID, '$shift')");
        //echo '
' . $query1 . '
';
        $lastid = mysqli_insert_id($link);
        //echo '
' . $lastid . '
';
        if ($lastid > 0)
            echo "Запись добавлена!";
        else
            echo "Ошибка! Проверьте правильность заполнения полей. Возможно имя или логин уже заняты.";
    }
    else if ($new == '8' && 10 == $cmdlevel )
    {
        $deactivateCheckbox = '';
        if ( 1 == $deactivate) { 
            $deactivateCheckbox = ',cmdlevel = 0, company = company + 100'; } 
        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', shift_id='$shift' where id=$staff_id");
        } else {
            $lastid = mysqli_query($link, "update  accounts set  name='$staffName' ". $deactivateCheckbox .", login='$log', shift_id='$shift' where id=$staff_id");
        }

        if ($lastid > 0)
            echo "Запись добавлена!";
        else
            echo "OOOOОшибка! Проверьте правильность заполнения полей. Возможно имя или логин уже заняты.";
    }
    
    echo "
"; echo '

Сотрудники компании '.$companyname.'


'; echo "
"; $jobtypes_company = GetJobtypes($companyID); $strinOptionJob = ''; foreach( $jobtypes_company as $job){ $strinOptionJob .= ""; } $job_typeArray = ['all'=>'Все должности','main' => 'Основная', 'slave' => 'Замещающая']; $stringOption = ''; foreach( $job_typeArray as $keys => $job_t) { $stringOption .= ""; } $ascArray = ['ASC'=>'А-Я','DESC' => 'Я-А']; $strinOptionShift = ''; foreach( $shiftEntity as $item_shift) { $strinOptionShift .= ""; } echo "
"; echo ""; echo ""; echo ""; echo "
"; if (isset($shift)){ echo ""; } if (isset($jobs_type)){ echo ""; } if (isset($jobs)){ echo ""; } if (isset($kind)){ echo ""; } if (isset($asc)){ echo ""; } echo "
"; echo " "; $find_staff = (isset($find_staff)) ? $find_staff : ''; echo "
"; echo '
'; echo "
"; // GetOnlineAccountList(); $query1 = mysqli_query($link, "select * from accounts where company=$companyID"); /** * @var $company Company */ $orderName = 'name';//(isset($kind) and null != $kind )? $kind : 'name' ; $orderValue = (isset($asc) and null != $asc )? "".$asc : 'ASC' ; $sort = $orderName .' '.$orderValue; $filter3 = []; $filter4 = []; $filter2 = []; if (isset($find_staff)) { $filter2 = ['like', 'name', $find_staff]; } $filter['company'] = $companyID; if ( $shift > 0 ) { $filter['shift_id'] = $shift; } if ( 'slave' == $jobs_type ) { $filter3 = ['<>','priority',0];// = $shift_filter; } switch ($jobs_type){ case 'main': $filter3 = ['=','priority',0]; break; case 'slave': $filter3 = ['<>','priority',0]; break; case 'all': $filter3 = ( null != $jobs && '0' != $jobs)? ['=', 'jobtype_id', $jobs] :[]; break; } //var_dump($_POST); if( 0 != $jobs && null !== $jobs && null != $jobs_type && 'all' != $jobs_type) { $filter['jobtype_id'] = $jobs; } //echo '
';
    //var_dump($filter, $filter2,$filter3);
    //echo '
'; //var_dump($filter4,$jobs); //exit; //$accountsEntity = \app\models\entity\Accounts::find()->where($filter)->andWhere($filter2)->orderBy($sort)->all(); $accountsEntity = \app\models\entity\Accounts::find() ->joinWith('accountsJobtypes', ['account_id' => 'id'], 'LEFT JOIN') ->where($filter) ->andWhere($filter2) ->andWhere($filter3) //->andWhere($filter4) ->orderBy($sort) ->all(); $company = Company::Find($companyID); $accounts = $company->accounts; // \Doctrine\Common\Util\Debug::dump($accounts); //$tasks = $entityManager->getRepository('Task')->findAll(); //var_dump(count($accountsEntity)); //var_dump(count()); // $accs = Account::GetIdle($companyID); // \Doctrine\Common\Util\Debug::dump($accs); $accountsEntityCount = count($accountsEntity); $count = 1; echo ""; foreach ($accountsEntity as $account) { $staff_id = $account->id; $staff_name = $account->name; $staff_cmdlevel = $account->cmdlevel; $overplan_mode = $account->overplan_mode?"Внеплан":""; // $active_task_id = $account->getActiveTaskIds(); $activeTasks = $account->tasks; $last_seen_mobile = ( null != $account->last_seen_mobile )? new DateTime($account->last_seen_mobile): $account->last_seen_mobile ; $last_seen_web = ( null != $account->last_seen_web ) ? new DateTime($account->last_seen_web) : $account->last_seen_web; $online_mobile = OnlineAccountCheck(TimeString($last_seen_mobile)); $online_web = OnlineAccountCheck(TimeString($last_seen_web)); if ( !$online_web && 'last_seen_web' == $kind ){ continue; } if ( !$online_mobile && 'last_seen_mobile' == $kind ){ continue; } if ( ($online_mobile || $online_web) && 'offline' == $kind ){ continue; } // echo "

". $staff_name ." [".$staff_id."]

"; echo "
"; //var_dump(TimeString($last_seen_web)); //var_dump($online_web); // var_dump($last_seen_web); if ($online_mobile) { echo "Online "; } if ($online_web) { echo "OnlineWeb "; } if (sizeof($activeTasks) > 0) { echo "Есть незавершённые задачи "; } if ($online_mobile) { echo "Выход"; } //Quit($accid) if ($overplan_mode) echo "Внеплан"; echo "
"; $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->accountsJobtypes;//getJobtypesIds(); $arrIds = []; foreach($job_ids_account as $id) { $arrIds[] = $id->jobtype_id; } $jobstr = implode(',', $arrIds); //$jobstr = implode(',', $job_ids_account); if ($jobstr=='') $jobstr = '""'; else $jobstr = '"'.$jobstr.'"'; //$jobnames_account = GetJobNames($job_ids_account); $jobnames_account = GetJobNames($arrIds); $jobamount = sizeof($jobnames_account); $jobnamesstring = implode(',', $jobnames_account); $ttshow = ''; if (sizeof($activeTasks) == 0) { $ttshow = 'нет'; } echo "

$staff_name [$staff_id]

"; echo ""; echo "
"; $count++; } /* foreach ($accounts as $account) { // echo "

". $staff_name ." [".$staff_id."]

"; echo "
"; $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(TimeString($last_seen_web)); var_dump($online_web); if ($online_mobile) echo "Online "; if ($online_web) echo "OnlineWeb "; $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 "

$staff_name [$staff_id]

"; echo ""; echo "
"; } */ $arrayForPdf = []; echo "
"; foreach ($accountsEntity as $account) { $buf = pack("vL*",1, $account->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); $decr = encrypt_decrypt('decrypt', $account->hash); echo ""; $arrayForPdf[] = ['name' => $account->name, 'login' => $account->login, 'password' => $decr, 'qr' => $PNG_WEB_DIR.basename($filename) ]; } echo "
Имя Логин Пароль QR код
". $account->name ." ". $account->login ." ". $decr ."
"; EchoEdit($jobtypes_company); } $_SESSION['staffQRList'] = $arrayForPdf; function EchoJobs($staff_id, $jobnames, $jobtypes, $countbasic,$count) { $account_jobindex = 0; // $basic = 0; $secondary = false; $countSubJob = count($jobnames)-1; $dataCount = ''; 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 "
Основные:
"; $dataCount = "data='" . $countSubJob ."'"; } else if (!$secondary && $countbasic == $basic){ $secondary = true; echo "
Замещение:
"; $dataCount = ''; } $data_pos_class = 'data_pos_'.$count.'_'.$account_jobindex; echo " "; if ($countbasic > $basic) { $basic++; } else echo "
"; $account_jobindex++; } } function EchoEdit($jobtypes)//, $job_ids_account) { echo "
"; echo "Выберите добавляемую должность:"; echo "
"; echo " "; echo " "; echo "

"; } ?>