Skip to content

Commit

Permalink
start date of a project is now selected from start_date field of proj…
Browse files Browse the repository at this point in the history
…ect table
  • Loading branch information
katmastt committed Jan 8, 2024
1 parent 63edc1b commit f224d45
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
41 changes: 24 additions & 17 deletions controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1006,19 +1006,22 @@ public function actionViewRequest($id,$filter='all')
$project_request = ProjectRequest::findOne($id);
$project_status = ProjectRequest::STATUSES[$project_request->status];

$project=Project::find()->where(['id'=>$project_request->project_id])->one();
$start = date('Y-m-d', strtotime($project->start_date));

if (!Userw::hasRole('Admin',$superadminAllowed=true) && (!Userw::hasRole('Moderator',$superadminAllowed=true)) )
{
return $this->render('//site/error_unauthorized');
}

if(is_null($project_request->approval_date))
{
$start = date('Y-m-d', strtotime($project_request->submission_date));
}
else
{
$start = date('Y-m-d', strtotime($project_request->approval_date));
}
// if(is_null($project_request->approval_date))
// {
// $start = date('Y-m-d', strtotime($project_request->submission_date));
// }
// else
// {
// $start = date('Y-m-d', strtotime($project_request->approval_date));
// }
if(is_null($project_request->end_date))
{
$ends=date('Y-m-d', strtotime($start. " + $project_request->duration months"));
Expand Down Expand Up @@ -1349,6 +1352,8 @@ public function actionViewRequestUser($id,$filter='all',$return='index')
ProjectRequest::recordViewed($id);
$project_request=ProjectRequest::findOne($id);
$project=Project::find()->where(['id'=>$project_request->project_id])->one();

$start = date('Y-m-d', strtotime($project->start_date));

$user_list=$project_request->user_list->getValue();
$users=User::find()->where(['id'=>$user_list])->all();
Expand All @@ -1367,14 +1372,15 @@ public function actionViewRequestUser($id,$filter='all',$return='index')
// }


if(is_null($project_request->approval_date))
{
$start = date('Y-m-d', strtotime($project_request->submission_date));
}
else
{
$start = date('Y-m-d', strtotime($project_request->approval_date));
}
// if(is_null($project_request->approval_date))
// {
// $start = date('Y-m-d', strtotime($project_request->submission_date));
// }
// else
// {
// $start = date('Y-m-d', strtotime($project_request->approval_date));
// }

if(is_null($project_request->end_date))
{
$ends=date('Y-m-d', strtotime($start. " + $project_request->duration months"));
Expand Down Expand Up @@ -2325,6 +2331,7 @@ public function actionEditProject($id)
{
$images = '';
$prequest=ProjectRequest::find()->where(['id'=>$id])->one();
$project=Project::find()->where(['id'=>$prequest->project_id])->one();
$exceed_limits = 0;
if((Userw::hasRole('Admin', $superadminAllowed=true)) || (Userw::hasRole('Moderator', $superadminAllowed=true))){
$exceed_limits = 1;
Expand Down Expand Up @@ -2382,7 +2389,7 @@ public function actionEditProject($id)
$vm_exists=false;

$date3=new \DateTime(date("Y-m-d"));
$start=new \DateTime($prequest->approval_date);
$start=new \DateTime($project->start_date);
$today= new \DateTime();

$interval=$start->diff($today)->format("%d" );
Expand Down
2 changes: 1 addition & 1 deletion models/ProjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function uploadNew($project_type)
{
$submitted_by=User::findByUsername(Userw::getCurrentUser()['username'])->id;

Yii::$app->db->createCommand()->insert('project', ['name' => $this->name,'project_type'=> $project_type])->execute();
Yii::$app->db->createCommand()->insert('project', ['name' => $this->name,'project_type'=> $project_type, 'start_date' => 'NOW()'])->execute();
$project_id=$id = Yii::$app->db->getLastInsertID();

Yii::$app->db->createCommand()->insert('project_request', [
Expand Down
2 changes: 1 addition & 1 deletion views/project/view_cold_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<tr>
<th class="col-md-6 text-right" scope="col">Started on:</th>
<td class="col-md-6 text-left" scope="col">
<?= ProjectValueDisplay::startDate($start,$requestHistory); ?>
<?= $start ?>
</td>
</tr>
<?php
Expand Down
2 changes: 1 addition & 1 deletion views/project/view_jupyter_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<tr>
<th class="col-md-6 text-right" scope="col">Started on:</th>
<td class="col-md-6 text-left" scope="col">
<?= ProjectValueDisplay::startDate($start,$requestHistory); ?>
<?= $start ?>
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion views/project/view_machine_compute_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<tr>
<th class="col-md-6 text-right" scope="col">Started on:</th>
<td class="col-md-6 text-left" scope="col">
<?= ProjectValueDisplay::startDate($start,$requestHistory); ?>
<?= $start ?>
</td>
</tr>
<?php
Expand Down
2 changes: 1 addition & 1 deletion views/project/view_ondemand_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<tr>
<th class="col-md-6 text-right" scope="col">Started on:</th>
<td class="col-md-6 text-left" scope="col">
<?= ProjectValueDisplay::startDate($start,$requestHistory); ?>
<?= $start ?>
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion views/project/view_service_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<tr>
<th class="col-md-6 text-right" scope="col">Started on:</th>
<td class="col-md-6 text-left" scope="col">
<?= ProjectValueDisplay::startDate($start,$requestHistory); ?>
<?= $start ?>
</td>
</tr>
<?php
Expand Down

0 comments on commit f224d45

Please sign in to comment.