diff --git a/controllers/ProjectController.php b/controllers/ProjectController.php index 85d0556..3c2143d 100644 --- a/controllers/ProjectController.php +++ b/controllers/ProjectController.php @@ -84,6 +84,9 @@ public function beforeAction($action) return false; } + // Set the flash message + Yii::$app->session->setFlash('danger', 'Dear HYPATIA users,
We would like to inform you that we are aware of a major issue on the infrastructure causing problems during the allocation and connection to resources. We are currently investigating the issue and trying to resolve it as soon as possible.
HYPATIA support team
'); + // Continue with the action return true; } @@ -117,18 +120,18 @@ public function actionIndex() $project_types=Project::TYPES; - $button_links=[0=>'/project/view-ondemand-request-user', 1=>'/project/view-service-request-user', - 2=>'/project/view-cold-storage-request-user', 3=>'/project/view-machine-computation-request-user', 4=>'/project/view-jupyter-request-user']; + $button_links=[0=>'/project/view-ondemand-request-user', 1=>'/project/view-service-request-user', + 2=>'/project/view-cold-storage-request-user', 3=>'/project/view-machine-computation-request-user', 4=>'/project/view-jupyter-request-user']; - $deleted=Project::getDeletedProjects(); + $deleted=Project::getDeletedProjects(); $owner=Project::getActiveProjectsOwner(); $participant=Project::getActiveProjectsParticipant(); $expired_owner=Project::getExpiredProjects(); $role=User::getRoleType(); - + $username=Userw::getCurrentUser()['username']; $user_split=explode('@',$username)[0]; - $all_projects=array_merge($owner,$participant); + $all_projects=array_merge($owner,$participant); //if there are expired books projects, check if there are active servers and delete them @@ -147,10 +150,10 @@ public function actionIndex() $active=[]; $expired=[]; - - foreach ($all_projects as $project) + + foreach ($all_projects as $project) { - $now = strtotime(date("Y-m-d")); + $now = strtotime(date("Y-m-d")); $end_project = strtotime($project['end_date']); $remaining_secs=$end_project-$now; $remaining_days=$remaining_secs/86400; @@ -162,28 +165,28 @@ public function actionIndex() array_push($project, ['favorite'=>$project['favorite']]); } else - { + { array_push($project, "$project[username]"); array_push($project, $remaining_days); array_push($project, ['favorite'=>$project['favorite']]); - } - $active[]=$project; + } + $active[]=$project; } $favorite = array_column($active, 'favorite'); $submission_date = array_column($active, 'submission_date'); array_multisort($favorite, SORT_DESC, $submission_date, SORT_DESC, $active); - - - foreach ($expired_owner as $project) + + + foreach ($expired_owner as $project) { - $now = strtotime(date("Y-m-d")); + $now = strtotime(date("Y-m-d")); $end_project = strtotime($project['end_date']); $remaining_secs=$end_project-$now; $remaining_days=$remaining_secs/86400; $remaining_months=round($remaining_days/30); - if($username==$project['username']) + if($username==$project['username']) { array_push($project,'You'); array_push($project, $project['end_date']); @@ -193,15 +196,15 @@ public function actionIndex() array_push($project, "$project[username]"); array_push($project, $project['end_date']); } - $expired[]=$project; - } + $expired[]=$project; + } $number_of_active=count($active); $number_of_expired=count($expired); - - - + + + return $this->render('index',['owner'=>$owner,'participant'=>$participant, 'button_links'=>$button_links,'project_types'=>$project_types,'role'=>$role, 'deleted'=>$deleted,'expired'=>$expired, 'active'=>$active, 'number_of_active'=>$number_of_active, 'number_of_expired'=>$number_of_expired, 'schema_url'=>$schema_url]); @@ -230,7 +233,7 @@ public function actionNewRequest() return $this->render('new_request'); } - + @@ -258,27 +261,27 @@ public function actionNewServiceRequest() $service_autoaccept_number=$service_autoaccept->autoaccept_number; $autoaccepted_num=ProjectRequest::find()->where(['status'=>2,'project_type'=>1,'submitted_by'=>Userw::getCurrentUser()['id'], ])->andWhere(['>=','end_date', date("Y-m-d")])->count(); - - $autoaccept_allowed=($autoaccepted_num - $service_autoaccept_number < 0) ? true :false; - - + $autoaccept_allowed=($autoaccepted_num - $service_autoaccept_number < 0) ? true :false; + + + $upperlimits=$limitsModel::find()->where(['user_type'=>$role])->one(); - + $autoacceptlimits=$autoacceptModel::find()->where(['user_type'=>$role])->one(); $project_types=['service'=>1, 'ondemand'=>0, 'coldstorage'=>2]; $form_params = - [ - 'action' => URL::to(['project/new-service-request']), - 'options' => [ - 'class' => 'service_request_form', - 'id'=> "service_request_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/new-service-request']), + 'options' => + [ + 'class' => 'service_request_form', + 'id'=> "service_request_form" + ], + 'method' => 'POST' + ]; $trls=[]; $trls[0]='Unspecified'; @@ -293,7 +296,7 @@ public function actionNewServiceRequest() $username=Userw::getCurrentUser()['username']; $user_split=explode('@',$username)[0]; $participating= (isset($_POST['participating'])) ? $_POST['participating'] : [ $user_split ]; - + if ( ($serviceModel->load(Yii::$app->request->post())) && ($projectModel->load(Yii::$app->request->post())) ) { /* @@ -319,8 +322,8 @@ public function actionNewServiceRequest() $isValid = $serviceModel->validate() && $isValid; if ($isValid) - { - + { + $messages=$projectModel->uploadNew($project_types['service']); $errors.=$messages[0]; $success.=$messages[1]; @@ -352,23 +355,23 @@ public function actionNewServiceRequest() if(empty($message_autoaccept)) { - EmailEventsModerator::NotifyByEmail('new_project', $project_id,$submitted_email); + EmailEventsModerator::NotifyByEmail('new_project', $project_id,$submitted_email); } else { Yii::$app->session->setFlash('success', "$message_autoaccept"); - EmailEventsModerator::NotifyByEmail('project_decision', $project_id,$message_autoaccept_mod); + EmailEventsModerator::NotifyByEmail('project_decision', $project_id,$message_autoaccept_mod); EmailEventsUser::NotifyByEmail('project_decision', $project_id,$message_autoaccept); } - + return $this->redirect(['project/index']); } } } - - return $this->render('new_service_request',['service'=>$serviceModel, 'project'=>$projectModel, - 'trls'=>$trls, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, 'new_project_allowed'=>$new_project_allowed, 'upperlimits'=>$upperlimits]); + + return $this->render('new_service_request',['service'=>$serviceModel, 'project'=>$projectModel, + 'trls'=>$trls, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, 'new_project_allowed'=>$new_project_allowed, 'upperlimits'=>$upperlimits]); @@ -376,8 +379,8 @@ public function actionNewServiceRequest() public function actionNewMachineComputeRequest() { - - + + $role=User::getRoleType(); $machineLimits=MachineComputeLimits::find()->where(['user_type'=>$role])->one(); $machine_maximum_number=$machineLimits->number_of_projects; @@ -396,15 +399,15 @@ public function actionNewMachineComputeRequest() $project_types=['service'=>1, 'ondemand'=>0, 'coldstorage'=>2, 'machine_compute'=>3]; $form_params = - [ - 'action' => URL::to(['project/new-machine-compute-request']), - 'options' => [ - 'class' => 'machine_compute_request_form', - 'id'=> "machine_compute_request_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/new-machine-compute-request']), + 'options' => + [ + 'class' => 'machine_compute_request_form', + 'id'=> "machine_compute_request_form" + ], + 'method' => 'POST' + ]; $errors=''; @@ -420,13 +423,13 @@ public function actionNewMachineComputeRequest() for ($i=1; $i<31; $i++) $num_vms_dropdown[$i]=$i; - + if ( ($serviceModel->load(Yii::$app->request->post())) && ($projectModel->load(Yii::$app->request->post())) ) { $participant_ids_tmp=[]; foreach ($participating as $participant) { - + $username=$participant . '@elixir-europe.org'; $pid=User::findByUsername($username)->id; $participant_ids_tmp[$pid]=null; @@ -444,23 +447,23 @@ public function actionNewMachineComputeRequest() // $isValid = $projectModel->machinesDuration30() && $isValid; if ($isValid) - { + { + - $messages=$projectModel->uploadNew($project_types['machine_compute']); $errors.=$messages[0]; $success.=$messages[1]; $warnings.=$messages[2]; $requestId=$messages[3]; - - + + if ($requestId!=-1) { $messages=$serviceModel->uploadNew($requestId); $errors.=$messages[0]; $success.=$messages[1]; $warnings.=$messages[2]; - + } if (empty($errors)) @@ -474,13 +477,13 @@ public function actionNewMachineComputeRequest() Yii::$app->session->setFlash('warning', "$warnings"); } - - + + return $this->redirect(['project/index']); } } } - + return $this->render('new_machine_compute_request',['service'=>$serviceModel, 'project'=>$projectModel, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'new_project_allowed'=>$new_project_allowed,'num_vms_dropdown'=>$num_vms_dropdown]); @@ -513,7 +516,7 @@ public function actionNewColdStorageRequest() $limitsModel=new ColdStorageLimits; $autoacceptModel=new ColdStorageAutoaccept; - + $cold_autoaccept= ColdStorageAutoaccept::find()->where(['user_type'=>$role])->one(); $cold_autoaccept_number=$cold_autoaccept->autoaccept_number; $autoaccepted_num=ProjectRequest::find()->where(['status'=>2,'project_type'=>2,'submitted_by'=>Userw::getCurrentUser()['id'],])->andWhere(['>=','end_date', date("Y-m-d")])->count(); @@ -535,26 +538,26 @@ public function actionNewColdStorageRequest() { $multiple[$i]=$i; } - - + + $upperlimits=$limitsModel::find()->where(['user_type'=>$role])->one(); - + $autoacceptlimits=$autoacceptModel::find()->where(['user_type'=>$role])->one(); - + $project_types=['service'=>1, 'ondemand'=>0, 'coldstorage'=>2]; $form_params = - [ - 'action' => URL::to(['project/new-cold-storage-request']), - 'options' => [ - 'class' => 'cold_storage_request_form', - 'id'=> "cold_storage_request_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/new-cold-storage-request']), + 'options' => + [ + 'class' => 'cold_storage_request_form', + 'id'=> "cold_storage_request_form" + ], + 'method' => 'POST' + ]; $errors=''; $success=''; @@ -564,7 +567,7 @@ public function actionNewColdStorageRequest() $participating= (isset($_POST['participating'])) ? $_POST['participating'] : [ $user_split ]; - + if ( ($coldStorageModel->load(Yii::$app->request->post())) && ($projectModel->load(Yii::$app->request->post())) ) { $participant_ids_tmp=[]; @@ -587,8 +590,8 @@ public function actionNewColdStorageRequest() // $projectModel->end_date='2100-1-1'; if ($isValid) - { - + { + $messages=$projectModel->uploadNew($project_types['coldstorage']); $errors.=$messages[0]; $success.=$messages[1]; @@ -608,7 +611,7 @@ public function actionNewColdStorageRequest() if (empty($errors)) { - + if(!empty($success)) { Yii::$app->session->setFlash('success', "$success"); @@ -628,18 +631,18 @@ public function actionNewColdStorageRequest() EmailEventsModerator::NotifyByEmail('project_decision', $project_id,$message_autoaccept_mod); EmailEventsUser::NotifyByEmail('project_decision', $project_id,$message_autoaccept); } - + return $this->redirect(['project/index']); } } } - - - return $this->render('new_cold_storage_request',['coldStorage'=>$coldStorageModel, 'project'=>$projectModel, - 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, - 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, - 'new_project_allowed'=>$new_project_allowed, 'vm_types'=>$vm_types, 'multiple' => $multiple]); + + + return $this->render('new_cold_storage_request',['coldStorage'=>$coldStorageModel, 'project'=>$projectModel, + 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, + 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, + 'new_project_allowed'=>$new_project_allowed, 'vm_types'=>$vm_types, 'multiple' => $multiple]); } @@ -657,7 +660,7 @@ public function actionNewOndemandRequest() if((!$new_project_allowed) && (!Userw::hasRole('Admin', $superadminAllowed=true)) && (!Userw::hasRole('Moderator', $superadminAllowed=true)) ) { return $this->render('no_project_allowed', ['project'=>"On-demand batch computations", 'user_type'=>$role]); - } + } $ondemandModel=new OndemandRequest(); $projectModel=new ProjectRequest; @@ -665,34 +668,34 @@ public function actionNewOndemandRequest() $autoacceptModel=new OndemandAutoaccept; $upperlimits=$limitsModel::find()->where(['user_type'=>$role])->one(); - + $ondemand_autoaccept= OndemandAutoaccept::find()->where(['user_type'=>$role])->one(); $ondemand_autoaccept_number=$ondemand_autoaccept->autoaccept_number; $autoaccepted_num=ProjectRequest::find()->where(['status'=>2,'project_type'=>0,'submitted_by'=>Userw::getCurrentUser()['id'],])->andWhere(['>=','end_date', date("Y-m-d")])->count(); - $autoaccept_allowed=($autoaccepted_num-$ondemand_autoaccept_number < 0) ? true :false; + $autoaccept_allowed=($autoaccepted_num-$ondemand_autoaccept_number < 0) ? true :false; + + + - - - $upperlimits=$limitsModel::find()->where(['user_type'=>$role])->one(); - + $autoacceptlimits=$autoacceptModel::find()->where(['user_type'=>$role])->one(); - + $project_types=['service'=>1, 'ondemand'=>0, 'coldstorage'=>2]; $form_params = - [ - 'action' => URL::to(['project/new-ondemand-request']), - 'options' => [ - 'class' => 'ondemand_project', - 'id'=> "ondemand_project" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/new-ondemand-request']), + 'options' => + [ + 'class' => 'ondemand_project', + 'id'=> "ondemand_project" + ], + 'method' => 'POST' + ]; $maturities=["developing"=>'Developing', 'testing'=> 'Testing', 'production'=>'Production']; @@ -703,8 +706,8 @@ public function actionNewOndemandRequest() $username=Userw::getCurrentUser()['username']; $user_split=explode('@',$username)[0]; $participating= (isset($_POST['participating'])) ? $_POST['participating'] : [ $user_split ]; - - + + if ( ($ondemandModel->load(Yii::$app->request->post())) && ($projectModel->load(Yii::$app->request->post())) ) { @@ -770,15 +773,15 @@ public function actionNewOndemandRequest() EmailEventsModerator::NotifyByEmail('project_decision', $project_id,$message_autoaccept_mod); EmailEventsUser::NotifyByEmail('project_decision', $project_id,$message_autoaccept); } - + return $this->redirect(['project/index']); } } } - - return $this->render('new_ondemand_request',['ondemand'=>$ondemandModel, 'project'=>$projectModel, - 'maturities'=>$maturities, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, 'new_project_allowed'=>$new_project_allowed, 'upperlimits'=>$upperlimits]); + + return $this->render('new_ondemand_request',['ondemand'=>$ondemandModel, 'project'=>$projectModel, + 'maturities'=>$maturities, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, 'new_project_allowed'=>$new_project_allowed, 'upperlimits'=>$upperlimits]); } //jupyter notebooks controller @@ -808,42 +811,42 @@ public function actionNewJupyterRequestNew() if((!$new_project_allowed) && (!Userw::hasRole('Admin', $superadminAllowed=true)) && (!Userw::hasRole('Moderator', $superadminAllowed=true)) ) { return $this->render('no_project_allowed', ['project'=>"Jupyter notebooks", 'user_type'=>$role]); - } + } $jupyterModel=new JupyterRequestNew(); $projectModel=new ProjectRequest; $limitsModel=new JupyterLimits; $autoacceptModel=new JupyterAutoaccept; - + $jupyter_autoaccept= JupyterAutoaccept::find()->where(['user_type'=>$role])->one(); $jupyter_autoaccept_number=$jupyter_autoaccept->autoaccept_number; //change project type $autoaccepted_num=ProjectRequest::find()->where(['status'=>2,'project_type'=>4,'submitted_by'=>Userw::getCurrentUser()['id'],])->andWhere(['>=','end_date', date("Y-m-d")])->count(); - $autoaccept_allowed=($autoaccepted_num-$jupyter_autoaccept_number < 0) ? true :false; + $autoaccept_allowed=($autoaccepted_num-$jupyter_autoaccept_number < 0) ? true :false; + + + - - - $upperlimits=$limitsModel::find()->where(['user_type'=>$role])->one(); - + $autoacceptlimits=$autoacceptModel::find()->where(['user_type'=>$role])->one(); - + //need to change project type $project_types=['service'=>1, 'ondemand'=>0, 'coldstorage'=>2, 'jupyter'=>4]; $form_params = - [ - 'action' => URL::to(['project/new-jupyter-request-new']), - 'options' => [ - 'class' => 'jupyter_project', - 'id'=> "jupyter_project" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/new-jupyter-request-new']), + 'options' => + [ + 'class' => 'jupyter_project', + 'id'=> "jupyter_project" + ], + 'method' => 'POST' + ]; // $maturities=["developing"=>'Developing', 'testing'=> 'Testing', 'production'=>'Production']; @@ -854,7 +857,7 @@ public function actionNewJupyterRequestNew() $username=Userw::getCurrentUser()['username']; $user_split=explode('@',$username)[0]; $participating= (isset($_POST['participating'])) ? $_POST['participating'] : [ $user_split ]; - + if ( ($jupyterModel->load(Yii::$app->request->post())) && ($projectModel->load(Yii::$app->request->post())) ) { @@ -925,15 +928,15 @@ public function actionNewJupyterRequestNew() EmailEventsModerator::NotifyByEmail('project_decision', $project_id,$message_autoaccept_mod); EmailEventsUser::NotifyByEmail('project_decision', $project_id,$message_autoaccept); } - + return $this->redirect(['project/index']); } } } - - return $this->render('new_jupyter_request',['jupyter'=>$jupyterModel, 'project'=>$projectModel, - 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, 'new_project_allowed'=>$new_project_allowed, 'images'=>$images]); + + return $this->render('new_jupyter_request',['jupyter'=>$jupyterModel, 'project'=>$projectModel, + 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'autoaccept_allowed' => $autoaccept_allowed, 'role'=>$role, 'new_project_allowed'=>$new_project_allowed, 'images'=>$images]); } @@ -947,17 +950,17 @@ public function actionAutoCompleteNames($expansion, $max_num, $term) $names = $model::getNamesAutoComplete($expansion, $max_num, $term); $namesDecoded=json_decode($names); //Check if results are empty - if(empty($namesDecoded)) + if(empty($namesDecoded)) { $names = json_encode(["No suggestions found"]); - } + } //Return results - these are already encoded in json - return $names; + return $names; } public function actionRequestList($filter='all', $page=1) { - + $statuses=ProjectRequest::STATUSES; $filters=['all'=>'All','pending'=>'Pending','approved'=>'Approved','auto-approved'=>'Auto-approved','rejected'=>'Rejected']; $project_types=Project::TYPES; @@ -979,24 +982,24 @@ public function actionRequestList($filter='all', $page=1) } return $this->render('request_list',['results'=>$results,'pages'=>$pages,'statuses'=>$statuses, - 'sideItems'=>$sidebarItems,'project_types'=>$project_types, - 'line_classes'=>$line_classes,'filter'=>$filter, 'page'=>$page]); + 'sideItems'=>$sidebarItems,'project_types'=>$project_types, + 'line_classes'=>$line_classes,'filter'=>$filter, 'page'=>$page]); } public function actionUserRequestList($filter='all', $page=1) { $statuses=ProjectRequest::STATUSES; - + $filters=['all'=>'All','pending'=>'Pending','approved'=>'Approved','auto-approved'=>'Auto-approved','rejected'=>'Rejected']; $project_types=Project::TYPES; - // $button_links=[0=>'/project/view-ondemand-request-user', 1=>'/project/view-service-request-user', + // $button_links=[0=>'/project/view-ondemand-request-user', 1=>'/project/view-service-request-user', // 2=>'/project/view-cold-storage-request-user']; $line_classes=[-5=>'expired',-4=>'deleted',-3=>'modified',-1=>'rejected',0=>'pending', 1=>'approved', 2=>'approved']; // $user=User::getCurrentUser()['username']; $results=ProjectRequest::getUserRequestList($filter); - + $pages=$results[0]; $results=$results[1]; @@ -1011,8 +1014,8 @@ public function actionUserRequestList($filter='all', $page=1) } return $this->render('request_list_user',['results'=>$results,'pages'=>$pages,'statuses'=>$statuses, - 'sideItems'=>$sidebarItems,'project_types'=>$project_types, - 'filter'=>$filter,'line_classes'=>$line_classes, 'expired'=>$expired, 'page'=>$page]); + 'sideItems'=>$sidebarItems,'project_types'=>$project_types, + 'filter'=>$filter,'line_classes'=>$line_classes, 'expired'=>$expired, 'page'=>$page]); } public function actionViewRequest($id,$filter='all', $page=1) @@ -1053,7 +1056,7 @@ public function actionViewRequest($id,$filter='all', $page=1) $secs = $datetime2 - $datetime1; $remaining_time = $secs / 86400; if($remaining_time<=0) - { + { $remaining_time=0; } @@ -1066,7 +1069,7 @@ public function actionViewRequest($id,$filter='all', $page=1) //Request details must be retrieved by the project request id if ($project_request->project_type==0) { - + $details=OndemandRequest::findOne(['request_id'=>$id]); $view_file='view_ondemand_request'; $usage=ProjectRequest::getProjectSchemaUsage($project_request->name); @@ -1081,10 +1084,10 @@ public function actionViewRequest($id,$filter='all', $page=1) $diff = $project_request->getFormattedDiff($previouslyApprovedProjectRequest); } } - //added jupyter + //added jupyter } else if ($project_request->project_type==4) { - + $details=JupyterRequestNew::findOne(['request_id'=>$id]); $view_file='view_jupyter_request'; $usage=ProjectRequest::getProjectSchemaUsage($project_request->name); @@ -1108,7 +1111,7 @@ public function actionViewRequest($id,$filter='all', $page=1) $image=$description; - } + } else if ($project_request->project_type==1) { $vm=Vm::find()->where(['project_id'=>$project['id']])->andwhere(['active'=>true])->one(); @@ -1282,7 +1285,7 @@ public function actionViewRequest($id,$filter='all', $page=1) } }else if ($project_request->project_type==4) { - + $details=JupyterRequestNew::findOne(['request_id'=>$id]); $view_file='view_jupyter_request'; $usage=ProjectRequest::getProjectSchemaUsage($project_request->name); @@ -1305,7 +1308,7 @@ public function actionViewRequest($id,$filter='all', $page=1) } $image=$description; - //added jupyter + //added jupyter } // Configure general information about statistics and visualizations @@ -1376,7 +1379,7 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 $vm_flavour=''; $start = date('Y-m-d', strtotime($project->start_date)); - + $user_list=$project_request->user_list->getValue(); $users=User::find()->where(['id'=>$user_list])->all(); @@ -1392,7 +1395,7 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 // { // $return='index'; // } - + // if(is_null($project_request->approval_date)) // { @@ -1417,12 +1420,12 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 $secs = $datetime2 - $datetime1; $remaining_time = $secs / 86400; if($remaining_time<=0) - { + { $remaining_time=0; } $usage=[]; $remaining_jobs=0; - + //Request details must be retrieved by the project request id if ($project_request->project_type==0) @@ -1464,7 +1467,7 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 $total_vms=VM::find()->where(['project_id'=>$project->id])->count(); $usage['active_vms']=$active_vms; $usage['total_vms']=$total_vms; - + } else if ($project_request->project_type==3) @@ -1476,7 +1479,7 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 $total_vms=VmMachines::find()->where(['project_id'=>$project->id])->count(); $usage['active_vms']=$active_vms; $usage['total_vms']=$total_vms; - + } else if ($project_request->project_type==2) { @@ -1489,7 +1492,7 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 $usage['active_volumes']=$active_volumes; $usage['total_volumes']=$total_volumes; } - + $submitted=User::find()->where(['id'=>$project_request->submitted_by])->one(); $project_owner= ($submitted->username==Userw::getCurrentUser()['username']); @@ -1497,7 +1500,7 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 * Fix username so that it is shown without @ */ $submitted->username=explode('@',$submitted->username)[0]; - + $maximum_number_users=$project_request->user_num; @@ -1509,12 +1512,12 @@ public function actionViewRequestUser($id,$filter='all',$return='index', $page=1 $number_of_users=count($users); - + $expired=0; return $this->render($view_file,['project'=>$project_request,'details'=>$details, 'return'=>$return, 'filter'=>$filter,'usage'=>$usage,'user_list'=>$username_list, 'submitted'=>$submitted,'request_id'=>$id, 'type'=>$type, 'ends'=>$ends, 'start'=>$start, 'remaining_time'=>$remaining_time, 'vm_flavour'=>$vm_flavour, - 'project_owner'=>$project_owner, 'number_of_users'=>$number_of_users, 'maximum_number_users'=>$maximum_number_users, 'remaining_jobs'=>$remaining_jobs, 'expired'=>$expired, 'active_servers'=>$active_servers, 'image'=>$image, 'superAdmin'=>$superAdmin, 'page'=>$page, + 'project_owner'=>$project_owner, 'number_of_users'=>$number_of_users, 'maximum_number_users'=>$maximum_number_users, 'remaining_jobs'=>$remaining_jobs, 'expired'=>$expired, 'active_servers'=>$active_servers, 'image'=>$image, 'superAdmin'=>$superAdmin, 'page'=>$page, 'ptype'=>$ptype,'exp'=>$exp, 'puser'=>$puser, 'pproject'=>$pproject]); } @@ -1567,8 +1570,8 @@ public function actionConfigureVm($id,$backTarget='s') $project=Project::find()->where(['id'=>$id])->one(); $project_id=$project->id; - - + + if (empty($existing)) { /* @@ -1578,7 +1581,7 @@ public function actionConfigureVm($id,$backTarget='s') session_write_close(); $avResources=VM::getOpenstackAvailableResources(); session_start(); - + $project=Project::find()->where(['id'=>$id])->one(); $latest_project_request_id=$project->latest_project_request_id; $service=ServiceRequest::find()->where(['request_id'=>$latest_project_request_id])->one(); @@ -1587,19 +1590,19 @@ public function actionConfigureVm($id,$backTarget='s') { return $this->render('service_unavailable_resources'); } - + $imageDD=Vm::getOpenstackImages(); $form_params = - [ - 'action' => URL::to(['project/configure-vm','id'=>$id]), - 'options' => [ - 'class' => 'vm__form', - 'id'=> "vm_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/configure-vm','id'=>$id]), + 'options' => + [ + 'class' => 'vm__form', + 'id'=> "vm_form" + ], + 'method' => 'POST' + ]; if ($model->load(Yii::$app->request->post())) { @@ -1617,7 +1620,7 @@ public function actionConfigureVm($id,$backTarget='s') $openstackMessage=$result[2]; if ($error!=0) { - + return $this->render('error_vm_creation',['error' => $error,'message'=>$message,'openstackMessage'=>$openstackMessage]); } @@ -1628,25 +1631,25 @@ public function actionConfigureVm($id,$backTarget='s') $existing->getConsoleLink(); $existing->getServerStatus(); session_start(); - + return $this->render('vm_details',['model'=>$existing, 'requestId'=>$id, 'service'=>$service,'backTarget'=>$backTarget]); } } } - + return $this->render('configure_vm',['model'=>$model,'form_params'=>$form_params,'imageDD'=>$imageDD,'service'=>$service,'backTarget'=>$backTarget]); } else { $user_id=Userw::getCurrentUser()['id']; $volume_exists=HotVolumes::getCreatedVolumesServicesUser($user_id); - + $hotvolume=HotVolumes::find()->where(['vm_id'=>$existing->id])->andWhere(['active'=>true])->all(); $additional_storage=[]; if(!empty($hotvolume)) { - foreach ($hotvolume as $hot) + foreach ($hotvolume as $hot) { $project=Project::find()->where(['id'=>$hot->project_id])->one(); $cold_storage_request=ColdStorageRequest::find()->where(['request_id'=>$project->latest_project_request_id])->one(); @@ -1655,10 +1658,10 @@ public function actionConfigureVm($id,$backTarget='s') } $attached_volumes_ids=array_column($hotvolume, 'id'); $not_attached_volumes=HotVolumes::find() - ->where(['NOT',['id'=>$attached_volumes_ids]]) - ->andWhere(['active'=>true]) - ->andWhere(['vm_type'=>1]) - ->all(); + ->where(['NOT',['id'=>$attached_volumes_ids]]) + ->andWhere(['active'=>true]) + ->andWhere(['vm_type'=>1]) + ->all(); $service_old=ServiceRequest::find()->where(['request_id'=>$existing->request_id])->one(); @@ -1679,7 +1682,7 @@ public function actionConfigureVm($id,$backTarget='s') session_start(); return $this->render('vm_details',['model'=>$existing,'requestId'=>$id, 'service'=>$service, 'additional_storage'=>$additional_storage]); } - + } @@ -1687,7 +1690,7 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' { /* * Check that someone is not trying to do something illegal - * by "hacking" at URLs + * by "hacking" at URLs */ $owner=Project::userInProject($id); @@ -1715,14 +1718,14 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' } } } - - + + if (empty($existing)) { /* * Create new VM */ - + $model=new VmMachines; session_write_close(); @@ -1734,7 +1737,7 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' $service=MachineComputeRequest::find()->where(['request_id'=>$latest_project_request_id])->one(); /* - * If someone is trying to do something fishy with the + * If someone is trying to do something fishy with the * parameters in the URL to create more VMs than allowed, * stop them. */ @@ -1742,24 +1745,24 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' { return $this->render('error_unauthorized'); } - + if ( ($service->num_of_ips>$avResources[2]) || ($service->ram>$avResources[1]) || ($service->num_of_cores > $avResources[0]) || ($service->storage > $avResources[3]) ) { return $this->render('service_unavailable_resources'); } - + $imageDD=VmMachines::getOpenstackImages(); $form_params = - [ - 'action' => URL::to(['project/machine-compute-configure-vm','id'=>$id,'multOrder'=>$multOrder,'backTarget'=>'m']), - 'options' => [ - 'class' => 'vm__form', - 'id'=> "vm_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/machine-compute-configure-vm','id'=>$id,'multOrder'=>$multOrder,'backTarget'=>'m']), + 'options' => + [ + 'class' => 'vm__form', + 'id'=> "vm_form" + ], + 'method' => 'POST' + ]; if ($model->load(Yii::$app->request->post())) { @@ -1767,7 +1770,7 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' $model->keyFile = UploadedFile::getInstance($model, 'keyFile'); if ($model->validate()) { - + $model->project_multiple_order=$multOrder; session_write_close(); $result=$model->createVM($latest_project_request_id,$service, $imageDD,$service->disk); @@ -1777,7 +1780,7 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' $openstackMessage=$result[2]; if ($error!=0) { - + return $this->render('error_vm_creation',['error' => $error,'message'=>$message,'openstackMessage'=>$openstackMessage]); } @@ -1785,12 +1788,12 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' { $existing=VmMachines::find()->where(['project_id'=>$id])->andWhere(['active'=>true])->one(); $existing->getConsoleLink(); - + return $this->render('vm_machines_details',['model'=>$existing, 'requestId'=>$id, 'service'=>$service,'backTarget'=>$backTarget]); } } } - + return $this->render('configure_vm',['model'=>$model,'form_params'=>$form_params,'imageDD'=>$imageDD,'service'=>$service,'backTarget'=>$backTarget,'project_id'=>$project->id]); } else @@ -1799,7 +1802,7 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' $additional_storage=[]; if(!empty($hotvolume)) { - foreach ($hotvolume as $hot) + foreach ($hotvolume as $hot) { $project=Project::find()->where(['id'=>$hot->project_id])->one(); $cold_storage_request=ColdStorageRequest::find()->where(['request_id'=>$project->latest_project_request_id])->one(); @@ -1809,15 +1812,15 @@ public function actionMachineComputeConfigureVm($id,$multOrder=1,$backTarget='s' - + session_write_close(); $existing->getConsoleLink(); $existing->getServerStatus(); session_start(); - - return $this->render('vm_machines_details',['model'=>$existing,'requestId'=>$id, 'service'=>$service, 'additional_storage'=>$additional_storage,'backTarget'=>$backTarget]); + + return $this->render('vm_machines_details',['model'=>$existing,'requestId'=>$id, 'service'=>$service, 'additional_storage'=>$additional_storage,'backTarget'=>$backTarget]); } - + } @@ -1838,7 +1841,7 @@ public function actionMachineComputeAccessProject($id) /* * if project has only one vm - * then redirect to the appropriate + * then redirect to the appropriate * configure vm action */ if ($details->num_of_vms == 1 ) @@ -1883,7 +1886,7 @@ public function actionMachineComputeAccessProject($id) } $storage[$ord][]=['name'=>$volume->name,'mountpoint'=>$volume->mountpoint]; } - + } @@ -1903,7 +1906,7 @@ public function actionGetVmStatus($vm_id='') $vm = new Vm(); $vm->vm_id=$vm_id; $status=empty($vm->getServerStatus($vm_id))? '' : $vm->status; - + return $this->asJson($status); } @@ -1985,7 +1988,7 @@ public function actionGetVmMachinesStatus($vm_id='') $vm = new VmMachines(); $vm->vm_id=$vm_id; $status=empty($vm->getServerStatus($vm_id))? '' : $vm->status; - + return $this->asJson($status); } @@ -2093,8 +2096,8 @@ public function actionDeleteVm($id) /* * If there are no errors, load the index page */ - - + + $success='Successfully deleted VM.'; @@ -2102,10 +2105,10 @@ public function actionDeleteVm($id) { Yii::$app->session->setFlash('success', "$success"); } - - + + return $this->redirect(['project/index']); - + } @@ -2146,8 +2149,8 @@ public function actionDeleteVmMachines($id) /* * If there are no errors, load the index page */ - - + + $success='Successfully deleted VM.'; @@ -2155,10 +2158,10 @@ public function actionDeleteVmMachines($id) { Yii::$app->session->setFlash('success', "$success"); } - - + + return $this->redirect(['project/index']); - + } @@ -2174,12 +2177,12 @@ public function actionVmList($filter='all') $new_results=[]; $ips = array(); - foreach ($results[1] as $res) + foreach ($results[1] as $res) { $now = strtotime(date("Y-m-d")); $end_project = strtotime($res['end_date']); $remaining=$now-$end_project; - + $vm=VM::find()->where(['id'=>$res['vm_id']])->one(); $ips[] = $vm->ip_address; @@ -2197,23 +2200,23 @@ public function actionVmList($filter='all') { $expired=0; $res['expired']=$expired; - - } + + } else - { + { $expired=1; $res['expired']=$expired; - + } $new_results[]=$res; - + } $pages=$results[0]; $results=$new_results; - + $sidebarItems=[]; $filters=['all', 'active', 'deleted']; $filter_names=['all'=>'All','active'=>'Active','deleted'=>'Deleted']; @@ -2225,14 +2228,14 @@ public function actionVmList($filter='all') } return $this->render('vm_list',['results'=>$results,'pages'=>$pages, - 'sideItems'=>$sidebarItems,'filter'=>$filter, "count_all"=>$vmcount_all, "count_active"=>$vmcount_active,"count_deleted"=>$vmcount_deleted, - 'ips'=>$ips,'filters'=>$filters_search, 'search_user'=>$filters_search['user'], 'search_project'=>$filters_search['project'], 'ip_address'=>$filters_search['ip']]); + 'sideItems'=>$sidebarItems,'filter'=>$filter, "count_all"=>$vmcount_all, "count_active"=>$vmcount_active,"count_deleted"=>$vmcount_deleted, + 'ips'=>$ips,'filters'=>$filters_search, 'search_user'=>$filters_search['user'], 'search_project'=>$filters_search['project'], 'ip_address'=>$filters_search['ip']]); } public function actionVmMachinesList($filter='all') { $filters_search=['user'=>Yii::$app->request->get('username',''), 'project'=>Yii::$app->request->get('project_name',''), 'ip'=>Yii::$app->request->get('ip_address','')]; - + $results=ProjectRequest::getVmMachinesList($filter, $filters_search['user'], $filters_search['project'], $filters_search['ip']); $vmcount_all=ProjectRequest::getVmMachinesCount("all"); $vmcount_active=ProjectRequest::getVmMachinesCount("active"); @@ -2240,9 +2243,9 @@ public function actionVmMachinesList($filter='all') $new_results=[]; $ips = array(); - foreach ($results[1] as $res) + foreach ($results[1] as $res) { - + $now = strtotime(date("Y-m-d")); $end_project = strtotime($res['end_date']); $remaining=$now-$end_project; @@ -2264,21 +2267,21 @@ public function actionVmMachinesList($filter='all') { $expired=0; $res['expired']=$expired; - - } + + } else - { + { $expired=1; $res['expired']=$expired; - + } $new_results[]=$res; } $pages=$results[0]; $results=$new_results; - + $sidebarItems=[]; $filters=['all', 'active', 'deleted']; $filter_names=['all'=>'All','active'=>'Active','deleted'=>'Deleted']; @@ -2290,21 +2293,21 @@ public function actionVmMachinesList($filter='all') } return $this->render('vm_machines_list',['results'=>$results,'pages'=>$pages, - 'sideItems'=>$sidebarItems,'filter'=>$filter, "count_all"=>$vmcount_all, "count_active"=>$vmcount_active,"count_deleted"=>$vmcount_deleted, 'ips'=>$ips, - 'filters'=>$filters_search, 'search_user'=>$filters_search['user'], 'search_project'=>$filters_search['project'], 'ip_address'=>$filters_search['ip']]); + 'sideItems'=>$sidebarItems,'filter'=>$filter, "count_all"=>$vmcount_all, "count_active"=>$vmcount_active,"count_deleted"=>$vmcount_deleted, 'ips'=>$ips, + 'filters'=>$filters_search, 'search_user'=>$filters_search['user'], 'search_project'=>$filters_search['project'], 'ip_address'=>$filters_search['ip']]); } public function actionAdminVmDetails($id,$project_id,$filter,$pages=null) { - + if (!Userw::hasRole('Admin',$superadminAllowed=true)) { return $this->render('error_unauthorized'); } $project=Project::find()->where(['id'=>$project_id])->one(); $project_request=ProjectRequest::find()->where(['id'=>$project->latest_project_request_id])->one(); - // $project_request=ProjectRequest::find()->where(['id'=>$request_id])->one(); + // $project_request=ProjectRequest::find()->where(['id'=>$request_id])->one(); $projectOwner=User::returnUsernameById($project_request->submitted_by); $projectOwner=explode('@', $projectOwner)[0]; $service=ServiceRequest::find()->where(['request_id'=>$project_request->id])->one(); @@ -2315,24 +2318,24 @@ public function actionAdminVmDetails($id,$project_id,$filter,$pages=null) $deletedBy=explode('@', $deletedBy)[0]; - + return $this->render('vm_admin_details',['project'=>$project,'service'=>$service, - 'vm'=>$vm, 'projectOwner'=>$projectOwner, 'createdBy'=>$createdBy, - 'deletedBy'=>$deletedBy, 'filter'=>$filter, 'project_id'=>$project->id, 'pages'=>$pages]); + 'vm'=>$vm, 'projectOwner'=>$projectOwner, 'createdBy'=>$createdBy, + 'deletedBy'=>$deletedBy, 'filter'=>$filter, 'project_id'=>$project->id, 'pages'=>$pages]); } - + public function actionAdminVmMachinesDetails($id,$project_id,$filter) { - + if (!Userw::hasRole('Admin',$superadminAllowed=true)) { return $this->render('error_unauthorized'); } $project=Project::find()->where(['id'=>$project_id])->one(); $project_request=ProjectRequest::find()->where(['id'=>$project->latest_project_request_id])->one(); - // $project_request=ProjectRequest::find()->where(['id'=>$request_id])->one(); + // $project_request=ProjectRequest::find()->where(['id'=>$request_id])->one(); $projectOwner=User::returnUsernameById($project_request->submitted_by); $projectOwner=explode('@', $projectOwner)[0]; $service=MachineComputeRequest::find()->where(['request_id'=>$project_request->id])->one(); @@ -2343,10 +2346,10 @@ public function actionAdminVmMachinesDetails($id,$project_id,$filter) $deletedBy=explode('@', $deletedBy)[0]; - + return $this->render('vm_machines_admin_details',['project'=>$project,'service'=>$service, - 'vm'=>$vm, 'projectOwner'=>$projectOwner, 'createdBy'=>$createdBy, - 'deletedBy'=>$deletedBy, 'filter'=>$filter, 'project_id'=>$project->id ]); + 'vm'=>$vm, 'projectOwner'=>$projectOwner, 'createdBy'=>$createdBy, + 'deletedBy'=>$deletedBy, 'filter'=>$filter, 'project_id'=>$project->id ]); } public function actionModeratorOptions() @@ -2393,14 +2396,14 @@ public function actionEditProject($id) /* * Since datetime involves time too - * equality will not work. Instead, check that + * equality will not work. Instead, check that * the date strings are not the same */ if (($date1->format("Y-m-d")!=$date2->format("Y-m-d")) && ($date2>$date1)) { return $this->render('error_expired'); } - + $prequest->fillUsernameList(); $prType=$prequest->project_type; @@ -2418,18 +2421,18 @@ public function actionEditProject($id) $date3=new \DateTime(date("Y-m-d")); $start=new \DateTime($project->start_date); $today= new \DateTime(); - + $interval=$start->diff($today)->format("%d" ); $duration=$prequest->duration; if(empty($prequest->end_date)) { - $ends=date('Y-m-d', strtotime($start. " + $duration months")); + $ends=date('Y-m-d', strtotime($start. " + $duration months")); } else { - $ends= explode(' ', $prequest->end_date)[0]; + $ends= explode(' ', $prequest->end_date)[0]; } $prequest->end_date=$ends; @@ -2459,7 +2462,7 @@ public function actionEditProject($id) $upperlimits=ServiceLimits::find()->where(['user_type'=>$role])->one(); $autoacceptlimits=ServiceAutoaccept::find()->where(['user_type'=>$role])->one(); $prequest->end_date=$ends; - + $project_id=$prequest->project_id; $vm=VM::find()->where(['project_id'=>$project_id, 'active'=>true])->one(); if (!empty($vm)) @@ -2478,7 +2481,7 @@ public function actionEditProject($id) /* Get request quotas */ $drequest=MachineComputeRequest::find()->where(['request_id'=>$id])->one(); /* - * If flavor has been changed from openstack allow system to continue, in order to + * If flavor has been changed from openstack allow system to continue, in order to * be able to update the flavor (provided that the VM does not exist). */ $drequest->flavour=isset($drequest->flavourIdNameLimitless[$drequest->vm_flavour])?$drequest->flavourIdNameLimitless[$drequest->vm_flavour]:''; @@ -2504,7 +2507,7 @@ public function actionEditProject($id) $view_file='edit_cold_storage'; for ($i=1; $i<31; $i++) $num_vms_dropdown[$i]=$i; - + // $prequest->end_date='2100-1-1'; $prequest->end_date=$ends; $volume=''; @@ -2545,7 +2548,7 @@ public function actionEditProject($id) { $description.=' (GPU)'; } - + $images[$i->id]=$description; } @@ -2553,15 +2556,15 @@ public function actionEditProject($id) //id= most recent project request $form_params = - [ - 'action' => URL::to(['project/edit-project', 'id'=>$id]), - 'options' => [ - 'class' => 'service_request_form', - 'id'=> "service_request_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/edit-project', 'id'=>$id]), + 'options' => + [ + 'class' => 'service_request_form', + 'id'=> "service_request_form" + ], + 'method' => 'POST' + ]; $errors=''; $success=''; @@ -2596,7 +2599,7 @@ public function actionEditProject($id) { $participant_ids[]=$pid; } - + $prequest->user_list=new yii\db\ArrayExpression($participant_ids, 'int4'); $isValid = $prequest->validate(); @@ -2605,31 +2608,31 @@ public function actionEditProject($id) // { // $isValid = $prequest->machinesDuration30() && $isValid; // } - + $pchanged_tmp= ProjectRequest::ProjectModelChanged($pold,$prequest); $pchanged=$pchanged_tmp[0]; $uchanged=$pchanged_tmp[1]; $dchanged= ProjectRequest::modelChanged($dold,$drequest); - + $project_id=$prequest->project_id; $vm=VM::find()->where(['project_id'=>$project_id, 'active'=>true])->one(); - + if (!empty($vm)) { - + if(ServiceRequest::compareServices($dold,$drequest)) { Yii::$app->session->setFlash('danger', "You are not allowed to request fewer resources, since you have already created a VM"); return $this->redirect(['project/edit-project', 'id'=>$id]); - } - + } + } - + if ($isValid) - { + { if ($prType==4){ - + //if the owner removed users, find their active servers and delete them $removed_users = array(); foreach ($pold['user_list'] as $prev_user){ @@ -2641,7 +2644,7 @@ public function actionEditProject($id) } if ($found==0){ $removed_users[] = $prev_user; - } + } } foreach ($removed_users as $removed_user) { $user=User::returnUsernameById($removed_user); @@ -2649,7 +2652,7 @@ public function actionEditProject($id) if(!empty($server)){ $server->stopserver(); } - + } //if the cpu or ram changed, delete all active servers of the project @@ -2663,12 +2666,12 @@ public function actionEditProject($id) } - - + + } if ($prType==0){ - + //if the owner removed users, delete them from the schema api project $removed_users = array(); $schema_api_url=Yii::$app->params['schema_api_url']; @@ -2687,7 +2690,7 @@ public function actionEditProject($id) } if ($found==0){ $removed_users[] = $prev_user; - } + } } foreach ($removed_users as $removed_user) { $user=User::returnUsernameById($removed_user); @@ -2696,9 +2699,9 @@ public function actionEditProject($id) // ob_flush(); $URL = $schema_api_url."/api_auth/contexts/{$prequest->name}/users/{$username}"; Token::DeleteUserFromProject($URL, $headers); - + } - + } if ($prType==2) @@ -2757,7 +2760,7 @@ public function actionEditProject($id) $success.=$messages[1]; $warnings.=$messages[2]; } - + } } else @@ -2775,15 +2778,15 @@ public function actionEditProject($id) { Yii::$app->session->setFlash('warning', "$warnings"); } - + return $this->redirect(['project/index']); } } } - return $this->render($view_file,['details'=>$drequest, 'project'=>$prequest, - 'trls'=>$trls, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'maturities'=>$maturities, 'vm_exists'=>$vm_exists, 'ends'=>$ends, 'role'=>$role, 'num_vms_dropdown'=>$num_vms_dropdown, 'volume_exists'=>$volume_exists, 'images'=>$images, 'interval'=>$interval, 'exceed_limits'=>$exceed_limits]); + return $this->render($view_file,['details'=>$drequest, 'project'=>$prequest, + 'trls'=>$trls, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'maturities'=>$maturities, 'vm_exists'=>$vm_exists, 'ends'=>$ends, 'role'=>$role, 'num_vms_dropdown'=>$num_vms_dropdown, 'volume_exists'=>$volume_exists, 'images'=>$images, 'interval'=>$interval, 'exceed_limits'=>$exceed_limits]); } @@ -2852,7 +2855,7 @@ public function actionDeleteUser($id, $pid, $user){ Yii::$app->session->setFlash('success', "The user " .$user." has been successfully removed from your project!"); return $this->redirect(array('jupyter-index', 'id'=>$requestId, 'pid'=>$prequest_new['project_id'])); } - + } } @@ -2881,18 +2884,18 @@ public function actionModifyRequest($id) if(empty($prequest->end_date)) { - $ends=date('Y-m-d', strtotime($start. " + $duration months")); + $ends=date('Y-m-d', strtotime($start. " + $duration months")); } else { - $ends= explode(' ', $prequest->end_date)[0]; + $ends= explode(' ', $prequest->end_date)[0]; } $prequest->end_date=$ends; $num_vms_dropdown=[]; $vm_exists=false; - + $prequest->fillUsernameList(); $prType=$prequest->project_type; @@ -2903,7 +2906,6 @@ public function actionModifyRequest($id) $volume_exists=false; $role=User::getRoleType(); - if ($prType==0) { $drequest=OndemandRequest::find()->where(['request_id'=>$id])->one(); @@ -2912,9 +2914,33 @@ public function actionModifyRequest($id) $autoacceptlimits=OndemandAutoaccept::find()->where(['user_type'=>$role])->one(); $maturities=["developing"=>'Developing', 'testing'=> 'Testing', 'production'=>'Production']; + } + else if ($prType==4) + { + $drequest=JupyterRequestNew::find()->where(['request_id'=>$id])->one(); + $view_file='edit_jupyter'; + $upperlimits=JupyterLimits::find()->where(['user_type'=>$role])->one(); + $autoacceptlimits=JupyterAutoaccept::find()->where(['user_type'=>$role])->one(); + $maturities=["developing"=>'Developing', 'testing'=> 'Testing', 'production'=>'Production']; + $prequest->end_date=$ends; + $img=JupyterImages::find()->all(); + $images=[]; + $users_list_bef = $prequest['user_list']; + foreach ($img as $i) + { + $description=$i->description; + if ($i->gpu==true) + { + $description.=' (GPU)'; + } + + $images[$i->id]=$description; + } + } else if ($prType==1) { + $drequest=ServiceRequest::find()->where(['request_id'=>$id])->one(); $drequest->flavour=$drequest->flavourIdName[$drequest->vm_flavour]; $view_file='edit_service'; @@ -2976,21 +3002,21 @@ public function actionModifyRequest($id) $autoacceptlimits=ColdStorageAutoaccept::find()->where(['user_type'=>$role])->one(); } - + $form_params = - [ - 'action' => URL::to(['project/modify-request', 'id'=>$id]), - 'options' => [ - 'class' => 'service_request_form', - 'id'=> "service_request_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/modify-request', 'id'=>$id]), + 'options' => + [ + 'class' => 'service_request_form', + 'id'=> "service_request_form" + ], + 'method' => 'POST' + ]; + + - - $errors=''; $success=''; @@ -2998,9 +3024,11 @@ public function actionModifyRequest($id) $username=Userw::getCurrentUser()['username']; $user_split=explode('@',$username)[0]; $participating= (isset($_POST['participating'])) ? $_POST['participating'] : $prequest->usernameList; + $pold=clone $prequest; + $dold=clone $drequest; - + if ( ($drequest->load(Yii::$app->request->post())) && ($prequest->load(Yii::$app->request->post())) ) { @@ -3013,7 +3041,7 @@ public function actionModifyRequest($id) } - /* + /* * Get participant ids */ $participant_ids_tmp=[]; @@ -3030,20 +3058,20 @@ public function actionModifyRequest($id) $participant_ids[]=$pid; } - + $prequest->user_list=new yii\db\ArrayExpression($participant_ids, 'int4'); $pchanged_tmp= ProjectRequest::ProjectModelChanged($pold,$prequest); $pchanged=$pchanged_tmp[0]; $uchanged=$pchanged_tmp[1]; $dchanged= ProjectRequest::modelChanged($dold,$drequest); - + $project_id=$prequest->project_id; $vm=VM::find()->where(['project_id'=>$project_id, 'active'=>true])->one(); - + if ($isValid) - { + { if ($prType==1 || $prType==3) { @@ -3083,14 +3111,14 @@ public function actionModifyRequest($id) { Yii::$app->session->setFlash('warning', "$warnings"); } - + return $this->redirect(['project/index']); } } } - return $this->render($view_file,['details'=>$drequest, 'project'=>$prequest, - 'trls'=>$trls, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'maturities'=>$maturities, 'ends'=>$ends, 'vm_exists'=>$vm_exists,'role'=>$role, 'num_vms_dropdown'=>$num_vms_dropdown,'volume_exists'=>$volume_exists, 'exceed_limits'=>$exceed_limits]); + return $this->render($view_file,['details'=>$drequest, 'images' => $images,'project'=>$prequest, + 'trls'=>$trls, 'form_params'=>$form_params, 'participating'=>$participating, 'errors'=>$errors, 'upperlimits'=>$upperlimits, 'autoacceptlimits'=>$autoacceptlimits,'maturities'=>$maturities, 'ends'=>$ends, 'vm_exists'=>$vm_exists,'role'=>$role, 'num_vms_dropdown'=>$num_vms_dropdown,'volume_exists'=>$volume_exists, 'exceed_limits'=>$exceed_limits]); } @@ -3124,7 +3152,7 @@ public function actionCancelRequest($id) { Yii::$app->session->setFlash('warning', "$warnings"); } - + return $this->redirect(['project/index']); } @@ -3165,7 +3193,7 @@ public function actionCancelProject($id) { Yii::$app->session->setFlash('warning', "$warnings"); } - + return $this->redirect(['project/index']); } @@ -3191,18 +3219,18 @@ public function actionModeratorEmailNotifications() $user=Userw::getCurrentUser(); $user_id=$user->id; if (!Userw::hasRole('Moderator',$superadminAllowed=true)) - + { return $this->render('error_unauthorized'); } $user_notifications=EmailEventsModerator::find()->where(['user_id'=>$user_id])->one(); if(empty($user_notifications)) { - $user_notifications=new EmailEventsModerator; - $user_notifications->user_id=$user_id; - $user_notifications->save(); - - } + $user_notifications=new EmailEventsModerator; + $user_notifications->user_id=$user_id; + $user_notifications->save(); + + } $smtp=Smtp::find()->one(); $smtp_config=true; @@ -3211,12 +3239,12 @@ public function actionModeratorEmailNotifications() Yii::$app->session->setFlash('danger', "SMTP is not configured properly to enable email notifications"); $smtp_config=false; } - if($user->load(Yii::$app->request->post()) && $user_notifications->load(Yii::$app->request->post())) + if($user->load(Yii::$app->request->post()) && $user_notifications->load(Yii::$app->request->post())) { - + $user->update(); - $user_notifications->update(); - Yii::$app->session->setFlash('success', "Your changes have been successfully submitted"); + $user_notifications->update(); + Yii::$app->session->setFlash('success', "Your changes have been successfully submitted"); return $this->redirect(['moderator-options']); } @@ -3233,7 +3261,7 @@ public function actionStorageVolumes() $results=ColdStorageRequest::getActiveProjects(); $services=$results[0]; $machines=$results[1]; - + return $this->render('storage_volumes', ['services'=>$services, 'machines'=>$machines, 'results'=>$results]); } @@ -3285,15 +3313,15 @@ public function actionCreateVolume($id,$order=1,$ret='u') /* * Create volume */ - + $hotvolume->create($project,$crequest,$order); if (!empty($hotvolume->errorMessage)) { - Yii::$app->session->setFlash('danger', $hotvolume->errorMessage); + Yii::$app->session->setFlash('danger', $hotvolume->errorMessage); return $this->redirect($return); } - Yii::$app->session->setFlash('success', "Volume created successfully"); + Yii::$app->session->setFlash('success', "Volume created successfully"); return $this->redirect($return); } else @@ -3302,7 +3330,7 @@ public function actionCreateVolume($id,$order=1,$ret='u') * This is a placeholder for when the cold storage * backend is provided; */ - + } $this->redirect($return); @@ -3340,7 +3368,7 @@ public function actionDeleteVolume($vid,$ret='u') Yii::$app->session->setFlash('danger', $volume->errorMessage); return $this->redirect($return); } - + $volume->deleteVolume(); if (!empty($volume->errorMessage)) @@ -3351,7 +3379,7 @@ public function actionDeleteVolume($vid,$ret='u') Yii::$app->session->setFlash('success', "Volume $volume->name has been successfully deleted."); return $this->redirect($return); - + } public function actionManageVolumes($id,$vid,$ret='u') @@ -3432,14 +3460,14 @@ public function actionManageVolumes($id,$vid,$ret='u') return $this->redirect($return); } - + $vm_name=(isset($volume->vm_dropdown[$volume->vm_id])) ? $volume->vm_dropdown[$volume->vm_id] : ''; $form_params= - [ - 'action' => URL::to(['project/manage-volumes','id'=>$id, 'vid'=>$vid,'ret'=>$ret,'return'=>$return]), - 'method' => 'POST' - ]; + [ + 'action' => URL::to(['project/manage-volumes','id'=>$id, 'vid'=>$vid,'ret'=>$ret,'return'=>$return]), + 'method' => 'POST' + ]; return $this->render('manage_volumes', ['volume'=>$volume,'pid'=>$id, 'vm_name'=>$vm_name,'form_params'=>$form_params, 'ret'=>$ret]); } @@ -3482,7 +3510,7 @@ public function actionDetachVolumeFromVm($id,$vid,$ret='u') Yii::$app->session->setFlash('danger', $volume->errorMessage); return $this->redirect($return); } - + Yii::$app->session->setFlash('success', "Volume has been successfully detached from the VM."); return $this->redirect($return); @@ -3503,7 +3531,7 @@ public function actionJupyterIndex($pid, $id) { Yii::debug("Inside controllers.ProjectController.actionJupyterIndex()"); $name = Project::find('name')->where(['id'=>$pid])->one(); - $owner = Project::getProjectOwner($name['name']); + $owner = Project::getProjectOwner($name['name']); $current_user = Userw::getCurrentUser()['id']; //check if there is a server running, created by the current user $server=JupyterServer::find()->where(['active'=>true,'project'=>$name['name'], 'created_by'=>Userw::getCurrentUser()['username']])->one(); @@ -3523,7 +3551,7 @@ public function actionJupyterIndex($pid, $id) $im=$image->image; $imageDrop[$image->id]=$im; } - + $user_list=$project_request->user_list->getValue(); $users=User::find()->where(['id'=>$user_list])->all(); $username=explode('@',Userw::getCurrentUser()['username'])[0]; @@ -3534,18 +3562,18 @@ public function actionJupyterIndex($pid, $id) JupyterServer::exec_log("mkdir $userFolder"); JupyterServer::exec_log("chmod 777 $userFolder"); } - + $jup = JupyterRequestNew::find()->where(['request_id'=>$id])->one(); $form_params = - [ - 'action' => URL::to(['project/jupyter-index', "pid"=>$pid, "id"=>$id]), - 'options' => [ - 'class' => 'service_request_form', - 'id'=> "service_request_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['project/jupyter-index', "pid"=>$pid, "id"=>$id]), + 'options' => + [ + 'class' => 'service_request_form', + 'id'=> "service_request_form" + ], + 'method' => 'POST' + ]; $quotas = JupyterRequestNew::GetProjectQuotas($pid); @@ -3595,15 +3623,15 @@ public function actionJupyterStartServer($project, $pid, $id) $owner = Project::getProjectOwner($name['name']); $current_user = Userw::getCurrentUser()['id']; $form_params = - [ - 'action' => URL::to(['jupyter-start-server', 'project'=>$project, 'pid'=>$pid, 'id'=>$id]), - 'options' => [ - 'class' => 'jupyter_start_form', - 'id'=> "jupyter_start_form" - ], - 'method' => 'POST' - ]; + 'action' => URL::to(['jupyter-start-server', 'project'=>$project, 'pid'=>$pid, 'id'=>$id]), + 'options' => + [ + 'class' => 'jupyter_start_form', + 'id'=> "jupyter_start_form" + ], + 'method' => 'POST' + ]; // if (!Yii::$app->params['standalone']) // { @@ -3612,7 +3640,7 @@ public function actionJupyterStartServer($project, $pid, $id) // */ // // $quotas=JupyterServer::getProjectQuotas($project); // $quotas=['cores'=>1,'ram'=>1,'end_date'=>'2250-12-31' ]; - + // // if (empty($quotas)) // // { // // return $this->render('project_error',['project'=>$project]); @@ -3656,7 +3684,7 @@ public function actionJupyterStartServer($project, $pid, $id) } $model = new JupyterServer; - if ($model->load(Yii::$app->request->post()) && $model->validate()) + if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->image_id = $image_id; $model->cpu=$quotas['cores']; @@ -3677,7 +3705,7 @@ public function actionJupyterStartServer($project, $pid, $id) ProjectRequest::recordViewed($id); $project_request=ProjectRequest::findOne($id); $project=Project::find()->where(['id'=>$project_request->project_id])->one(); - + $user_list=$project_request->user_list->getValue(); $users=User::find()->where(['id'=>$user_list])->all(); foreach ($users as $user) @@ -3688,9 +3716,9 @@ public function actionJupyterStartServer($project, $pid, $id) $all_servers=JupyterServer::find()->where(['active'=>true,'project'=>$name['name']])->all(); $server=JupyterServer::find()->where(['active'=>true,'project'=>$project, 'created_by'=>Userw::getCurrentUser()['username']])->one(); return $this->redirect(array('jupyter-index','name'=>$name,'ram'=>$quotas['ram'], 'cpu'=>$quotas['cores'],'images'=>$images, 'description'=>$quotas['description'], 'req'=>$quotas['request_id'], 'end_date'=>$days, 'pid'=>$pid, 'participants'=>$username_list, 'server'=>$server, 'id'=>$id, 'owner'=>$owner, 'current_user'=>$current_user, 'all_servers'=>$all_servers )); - - } - + + } + return $this->render('jupyter_start_server',['model'=>$model, 'imageDrop'=>$imageDrop,'form_params' => $form_params, 'project' => $project, 'pid'=>$pid, 'image__id'=>$image_id]); @@ -3752,7 +3780,7 @@ public function actionJupyterStopServer($project,$return='s', $id, $pid, $user_d ProjectRequest::recordViewed($id); $project_request=ProjectRequest::findOne($id); $project=Project::find()->where(['id'=>$project_request->project_id])->one(); - + $user_list=$project_request->user_list->getValue(); $users=User::find()->where(['id'=>$user_list])->all(); foreach ($users as $user) @@ -3780,7 +3808,7 @@ public function actionJupyterStopServer($project,$return='s', $id, $pid, $user_d else { return $this->redirect(array('jupyter-index','name'=>$name,'ram'=>$quotas['ram'], 'cpu'=>$quotas['cores'],'images'=>$images, 'description'=>$quotas['description'], 'req'=>$quotas['request_id'], 'end_date'=>$days, 'pid'=>$pid, 'participants'=>$username_list, 'server'=>$server, 'id'=>$id, 'image_id'=>$imageDrop[$image->id], 'owner'=>$owner, 'current_user'=>$current_user, 'all_servers'=>$all_servers )); - + } } @@ -3795,12 +3823,12 @@ public function actionStopExpiredJupyterServers() { return $this->render('unauthorized'); } - + /* * Get expired servers */ $servers=JupyterServer::find()->where(['active'=>true])->andWhere(['<','expires_on','NOW()'])->all(); - + /* * If no servers exist, return */ @@ -3820,7 +3848,7 @@ public function actionStopExpiredJupyterServers() Yii::$app->session->setFlash('success','Successfully stopped all expired Jupyter servers'); - + return $this->redirect(['administration/view-active-jupyters']); } @@ -3923,10 +3951,10 @@ public function actionTokenManagement($id) { $URL = $schema_api_url."/api_auth/contexts/{$pname}"; //$project_post = $temp1.$temp4; $return=Token::EditToken($URL, $headers, $project_post); - // $URL2 = "/tokens"; - // $URL = $URL1.$pname.$URL2; - // $issued_tokens = Token::GetTokens($URL, $headers); - + // $URL2 = "/tokens"; + // $URL = $URL1.$pname.$URL2; + // $issued_tokens = Token::GetTokens($URL, $headers); + } else { //placeholder for bad request @@ -3935,7 +3963,7 @@ public function actionTokenManagement($id) { $URL = $schema_api_url."/api_auth/contexts/{$pname}/users"; //check if the user is registered to the project $user_registered = Token::IsUserRegisteredProject($URL, $headers, $username); - //user is not registered to the project + //user is not registered to the project if ($user_registered == 0) { $temp1 = '{"username":'; $temp2 = '"'; @@ -3943,19 +3971,19 @@ public function actionTokenManagement($id) { $post_body = $temp1.$temp4; $return = Token::Register($URL, $headers, $post_body); return $this->render('token_management',['model'=>$existing, 'requestId'=>$id, 'project'=>$project, 'issued_tokens'=>0, - 'strArray'=>'', 'URL'=>$URL, 'headers'=>$headers, 'project_exists'=>$project_exists]); + 'strArray'=>'', 'URL'=>$URL, 'headers'=>$headers, 'project_exists'=>$project_exists]); } else { // $URL = "http://62.217.122.242:8080/api_auth/contexts/{$pname}/users/{$username}/tokens?status=active"; $URL = $schema_api_url."/api_auth/contexts/{$pname}/users/{$username}/tokens?status=active"; //$URL = "http://62.217.122.242:8080/api_auth/contexts/context0/users/user0/tokens"; $issued_tokens = Token::GetTokens($URL, $headers); return $this->render('token_management',['model'=>$existing, 'requestId'=>$id, 'project'=>$project, 'issued_tokens'=>$issued_tokens[0], - 'strArray'=>$issued_tokens[1], 'URL'=>$URL, 'headers'=>$headers, 'project_exists'=>$project_exists]); + 'strArray'=>$issued_tokens[1], 'URL'=>$URL, 'headers'=>$headers, 'project_exists'=>$project_exists]); } } public function actionNewTokenRequest($id, $mode, $uuid){ - //retrieve schema API base url and authentication token + //retrieve schema API base url and authentication token // $schema_api=SchemaAPI::find()->one(); $schema_api_url=Yii::$app->params['schema_api_url']; $schema_api_token=Yii::$app->params['schema_api_token']; @@ -3981,7 +4009,7 @@ public function actionNewTokenRequest($id, $mode, $uuid){ $message=$model->validateDates($exp_date, $s_exp_date, $mode); if( $message=='ok'|| $message =='empty') { - // valid data received in $model + // valid data received in $model if ($message!='ok' && $message!='empty' && !empty($prequest)){ Yii::$app->session->setFlash('danger', "$message"); return $this->redirect(['project/token-management', 'id'=>$id]); @@ -3989,7 +4017,7 @@ public function actionNewTokenRequest($id, $mode, $uuid){ } elseif($message=='empty'&& !empty($prequest) && $mode==0 ) { $s_exp_date = $exp_date; - } + } $time = date('h:i:s'); if ($mode == 1){ @@ -4029,13 +4057,13 @@ public function actionNewTokenRequest($id, $mode, $uuid){ } return $this->redirect(['project/token-management','id'=>$id]); //return $this->actionTokenManagement($project_id,$model->expiration_date); - } + } } else { Yii::$app->session->setFlash('danger', "$message"); //return $this->actionOnDemandLp($project_id,$model->expiration_date); } - + } else { if ($mode == 1) { @@ -4047,10 +4075,10 @@ public function actionNewTokenRequest($id, $mode, $uuid){ $token_details = Token::GetTokenDetails($URL, $headers); $exp_date = $token_details[1]->format('y-m-d'); return $this->render('new_token_request', ['model' => $model, 'requestId'=>$id, 'project'=>$project, 'mode'=>$mode, 'uuid'=>$uuid, 'title'=>$token_details[0], 'exp_date'=>$exp_date]); - + } elseif ($mode==0) { return $this->render('new_token_request', ['model' => $model, 'requestId'=>$id, 'project'=>$project, 'mode'=>$mode, 'uuid'=>$uuid]); - + } else { $pname = $project->name; @@ -4065,9 +4093,9 @@ public function actionNewTokenRequest($id, $mode, $uuid){ //return $this->actionTokenManagement($project_id); return $this->redirect(['project/token-management', 'id'=>$id]); - } + } // either the page is initially displayed or there is some validation error - + } if ($mode == 0){ return $this->render('new_token_request', ['model' => $model, 'requestId'=>$id, 'project'=>$project, 'mode'=>$mode, 'uuid'=>$uuid]); @@ -4075,14 +4103,14 @@ public function actionNewTokenRequest($id, $mode, $uuid){ $pname = $project->name; $user=Userw::getCurrentUser(); $username=explode('@',$user['username'])[0]; - // $URL = "http://62.217.122.242:8080/api_auth/contexts/{$pname}/users/{$username}/tokens/{$uuid}"; + // $URL = "http://62.217.122.242:8080/api_auth/contexts/{$pname}/users/{$username}/tokens/{$uuid}"; $URL = $schema_api_url."/api_auth/contexts/{$pname}/users/{$username}/tokens/{$uuid}"; - //$URL = "http://62.217.122.242:8080/api_auth/contexts/context0/users/user0/tokens/{$uuid}"; + //$URL = "http://62.217.122.242:8080/api_auth/contexts/context0/users/user0/tokens/{$uuid}"; $token_details = Token::GetTokenDetails($URL, $headers); $exp_date = $token_details[1]->format('y-m-d'); return $this->render('new_token_request', ['model' => $model, 'requestId'=>$id, 'project'=>$project, 'mode'=>$mode, 'uuid'=>$uuid, 'title'=>$token_details[0], 'exp_date'=>$exp_date]); } - + } @@ -4102,7 +4130,7 @@ public function actionOnDemandAccess($id) { $remaining_jobs=$num_of_jobs-$used_jobs; return $this->render('on_demand_access', ['project'=>$project, 'details'=>$details,'initial_jobs'=>$num_of_jobs, 'remaining_jobs'=>$remaining_jobs, 'usage'=>$usage, 'request_id'=>$request_id, 'id'=>$id, 'compute'=>$schema_url ]); - + } diff --git a/views/project/edit_jupyter.php b/views/project/edit_jupyter.php index a4e0bbd..5faeb15 100644 --- a/views/project/edit_jupyter.php +++ b/views/project/edit_jupyter.php @@ -10,36 +10,41 @@ /* @var $this yii\web\View */ /* @var $model app\models\ServiceRequest */ /* @var $form ActiveForm */ - echo Html::CssFile('@web/css/project/project-request.css'); $this->registerJsFile('@web/js/project/project-request.js', ['depends' => [\yii\web\JqueryAsset::className()]]); -$this->title = "Edit on-demand notebooks project request"; -echo $interval; -$participating_label = "Participating users "; -$cancel_icon = ''; -$exclamation_icon = ''; +$this->title="Edit on-demand notebooks project request"; +$participating_label="Participating users "; +$cancel_icon=''; +$exclamation_icon=''; -if ($autoacceptlimits->ram == $upperlimits->ram) { - $ram_label = "Maximum allowed memory per server (in GBs) * [upper limits: $upperlimits->ram] "; -} else { - $ram_label = "Maximum allowed memory per server (in GBs) * [upper limits: $autoacceptlimits->ram (automatically accepted), $upperlimits->ram (with review)] "; +if($autoacceptlimits->ram==$upperlimits->ram) +{ + $ram_label= "Maximum allowed memory per server (in GBs) * [upper limits: $upperlimits->ram] "; +} +else +{ + $ram_label= "Maximum allowed memory per server (in GBs) * [upper limits: $autoacceptlimits->ram (automatically accepted), $upperlimits->ram (with review)] "; } -if ($autoacceptlimits->cores == $upperlimits->cores) { - $cores_label = "Available cores per server * [upper limits: $autoacceptlimits->cores] "; -} else { - $cores_label = "Available cores per server * [upper limits: $autoacceptlimits->cores (automatically accepted), $upperlimits->cores (with review)] "; +if($autoacceptlimits->cores==$upperlimits->cores) +{ + $cores_label= "Available cores per server * [upper limits: $autoacceptlimits->cores] " ; +} +else +{ + $cores_label= "Available cores per server * [upper limits: $autoacceptlimits->cores (automatically accepted), $upperlimits->cores (with review)] " ; } -$participants_label = "Maximum number of users to participate in the project * [upper limit: $upperlimits->participants] "; +$participants_label= "Maximum number of users to participate in the project * [upper limit: $upperlimits->participants] " ; -if (!empty($errors)) { +if (!empty($errors)) +{ echo '