6000)) { // last request was more than 30 minutes ago session_unset(); // unset $_SESSION variable for the run-time session_destroy(); // destroy session data in storage } $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp $add = 'Login Area'; foreach (array_keys($_REQUEST) as $var) { ${$var} = $_REQUEST[$var]; //if ($name == "Admin12") { // echo "$var: ${$var}
"; //} } if ($act == "exit") { session_unset(); session_destroy(); session_start(); } if ($_SESSION['cmdlevel']) $cmdlevel = $_SESSION['cmdlevel']; if ($_SESSION['hostid']) $agent_id = $_SESSION['hostid']; if ($_SESSION['add']) $add = $_SESSION['add']; if ($_SESSION['id']) $id = $_SESSION['id']; if ($_SESSION['login']) $login = $_SESSION['login']; if ($_SESSION['name']) $name = $_SESSION['name']; foreach (array_keys($_SESSION) as $var) { ${$var} = $_SESSION[$var]; //if ($name == "Admin12") { //echo "from session: $var: ${$var}
"; //} } include 'functions.php'; include 'auth.php'; $logged_me_in_successfully234 = 0; $incl = ''; if (!$_SESSION['pass'] && !$_SESSION['login']) { $table = 'accounts'; $result=mysqli_query($link, "SELECT id, login, name, cmdlevel FROM $table WHERE login='".$login."' AND password='".md5($pass)."'"); $res1 = mysqli_fetch_array($result); $cmdlevel = $res1['cmdlevel']; $name = $res1['name']; $id = $res1['id']; if ($cmdlevel == '10') { $add = "Head Administrator"; } else if ($cmdlevel == '1') { $add = "Company Administrator"; } else if ($cmdlevel == '2') { $add = "Company Operator"; } if (mysqli_num_rows($result)) { $_SESSION['pass']=$pass; $_SESSION['login']=$login; $_SESSION['name']=$name; $_SESSION['add']=$add; $_SESSION['cmdlevel']=$cmdlevel; $_SESSION['id']=$id; $logged_me_in_successfully234 = 1; } } else $logged_me_in_successfully234 = 1; $query = mysqli_query($link, "update accounts set last_seen_web =NOW() where id=".$id); $getincl = GetInclude($act, intval($cmdlevel)); $incl = $getincl[0]; $accnum = $getincl[1]; $status_id = \Yii::$app->request->get('status'); ?> ASUSG request->post(); $get_id = \Yii::$app->request->get('id'); $mycompany = getCompanyByAccount($id); if (!isset($companyID)) { // echo "ses com ".$_SESSION['company']; if ($_SESSION['company']) $companyID = $_SESSION['company']; else { $companyID = $mycompany[0]; $_SESSION['company'] = $companyID; } } else { $_SESSION['company'] = $companyID; } $companyname = getCompanyByID($companyID)[1]; if ((int)$_POST['appMykey'] == 123465) {$logged_me_in_successfully234 = 1;} if ($logged_me_in_successfully234 == 0) { echo "
"; GetEnterForm(); echo("Access denied. Incorrect login or password"); echo "
"; return; } //$asusgEmployeeEntity = \app\models\entity\AsusgEmployee::find()->orderBy(['name' => SORT_ASC])->all(); $asusgEmployeeEntity = \app\models\entity\Accounts::find()->where(['company' => $companyID])->orderBy(['name' => SORT_ASC])->all(); $asusgJobplanEntity = \app\models\entity\AsusgJobplan::find()->orderBy(['name' => SORT_ASC])->all(); if ( null != $post['typefix'] and null != $post['loco_seria']) { $asusgProjectTypeEntity = \app\models\entity\AsusgProjectType::findOne(['repair_type' => explode('_',$post['typefix'])[0], 'loco_serie_id' => $post['loco_seria']]); //$asusgJob2ProjectEntity = \app\models\entity\AsusgJob2Project::find()->where(['asusg_projecttype_id' => $post['typefix'], 'asusg_jobplan_id' => $post['loco_seria']])->orderBy(['job_order' => SORT_ASC])->all(); } else if( null != $get_id){ $asusgProjectTypeEntity = \app\models\entity\AsusgJob2Launch::find()->where(['asusg_project_id' => $get_id])->all(); $asusgProjectsEntity = \app\models\entity\AsusgProject::findOne(['id' => $get_id]); } else { $asusgJob2ProjectEntity = \app\models\entity\AsusgJob2Command::find()->orderBy(['job_order' => SORT_ASC])->all(); } $tasktypesEntity = \app\models\entity\Tasktypes::find()->where(['main_task' => 0,'company' => $companyID])->orderBy(['name' => SORT_ASC])->all(); $locomotiveSeriesEntity = \app\models\entity\LocomotiveSeries::find()->orderBy(['name' => SORT_ASC])->all(); $typeFix = \app\models\entity\Repairtypes::find()->all(); //$typeFix = ['1' => 'TO-1','2' => 'TO-2','3' => 'TO-3','4' => 'TO-4','5' => 'TO-5',]; //$projectsLocotechEntity = getLocomotiveList(); $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(["!=", "uuid" , ''])->all(); $series = LocoSeries::GetAllNames(); /* $startPr = \Yii::$app->request->post('startPr'); if( isset($startPr)) { $asusgProjectEntity = new \app\models\entity\AsusgProject(); $asusgProjectEntity->loco_serie_id = \Yii::$app->request->post('loco_seria'); $asusgProjectEntity->loco_number = \Yii::$app->request->post('loco_number'); $asusgProjectEntity->repair_type = \Yii::$app->request->post('typefix'); $asusgProjectEntity->section_a = \Yii::$app->request->post('section_a'); $asusgProjectEntity->section_b = \Yii::$app->request->post('section_b'); $asusgProjectEntity->section_c = \Yii::$app->request->post('section_c'); try { $asusgProjectEntity->save(); } catch (\yii\db\Exception $exception) { $loadFormError = 'Данные не сохранились.'; } } */ $percent = getCompliteStatus(); ?>

Список задач

Login  
Password  
 
"; } function getLocomotiveList(){ $result = []; //var_dump($companyID); $projectsLocotechEntity = \app\models\entity\ProjectsLocotech::find()->where(['company' => 2] )->orderBy(['id' => SORT_DESC])->all(); $listArray = []; foreach( $projectsLocotechEntity as $item){ //var_dump($item->projecttypes->name);echo "\n"; //$tempArray = GetTasksForProject($item->id); $status = GetProjectStatus($item->id); if ($status != 2 && $status != 1) {continue;} $countDone = ['done' => 0, 'all' => 0 ]; foreach( GetTasksForProject($item->id) as $proj) { //var_dump($proj);echo "
"; $countDone['all']++; $tempArray = $proj; $tempArray['status'] = CheckAcceptedStatus($proj); $tempArray['name'] = GetTaskNameAndDesc($proj['type'])[0]; //$tempArray['listAccounts'] = $this->getAccountListForTask($proj['type']); if ( 5 == $tempArray['status'] ) {$countDone['done']++;} //$countDone['all'] ." / " . $countDone['done']; $listArray[] = $tempArray; } $result[$item->id]['countDone'] = [ 'done' => $countDone['done'], 'all' => $countDone['all'] ]; //$tempArray['name'] = GetTaskNameAndDesc($tempArray['type'])[0]; $result[$item->id]['arr'] = $listArray;//GetTasksForProject($item->id); $result[$item->id]['obj'] = $item; $listArray = []; } //exit; return $result; } function CheckAcceptedStatus($task) { $result = false; $query = "select if(tx.total = tx.finished, 5, if (tx.accepted <> tx.finished, if(tx.attention > 0, 7, 2), if (tx.accepted = 0, 1, 3))) as taskstatus from (select count(t.id) as total, sum(if(t.accepted_time is not null, 1, 0)) as accepted, sum(if(t.finished_time is not null, 1, 0)) as finished, sum(if(t.finished_time is null, if(timestampdiff(MINUTE, t.accepted_time, NOW()) > tt.time_to_complete_minutes, 1, 0), 0)) as attention from tasks t right join tasktypes tt on t.type = tt.id where t.parent_id = ".$task['id'].") tx;"; $result = \Yii::$app->db->createCommand($query)->queryAll(); $result = $result[0]["taskstatus"]; return $result; } function getCompliteStatus() { global $link; $result = []; $getParams = \Yii::$app->request->get('id'); $query = 'select aj2l.asusg_project_id, t.asusg_job_mapped_id, count(t.id) total, sum(case when t.status = 5 then 1 else 0 end) finished from tasks t left join asusg_job2launch aj2l on t.asusg_job_mapped_id = aj2l.id where aj2l.asusg_project_id = '. $getParams .' group by t.asusg_job_mapped_id order by aj2l.job_order;'; $resQuery = mysqli_query($link, $query); while($res = mysqli_fetch_assoc($resQuery)){ $tempArr = []; $percent = ((int)$res["finished"]/(int)$res["total"])*100; $result[$res["asusg_job_mapped_id"]]= $percent; } //echo "
";
    //var_dump($result);
    // echo "
"; return $result; } ?>