예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $project = Project::findOrFail($id);
     $validator = Validator::make(Input::all(), array('cac' => 'required|cac|unique:projects,cac,' . $id, 'title' => 'required', 'target_start' => 'required', 'target_end' => 'required', 'target_mandays' => 'required', 'budget' => 'required', 'confidentiality' => 'required'));
     if ($validator->fails()) {
         return redirect()->action('ProjectsController@edit', $project->id)->withErrors($validator);
     } else {
         $users = User::all();
         //$input = Request::all();
         $input = Input::all();
         foreach ($users as $user) {
             if ($user->id == $input['pm']) {
                 $pmid = $user->id;
                 $pmname = User::find($pmid);
             }
         }
         if ($input['target_mandays'] >= 60 or $input['budget'] >= 2000000) {
             $importance = "MAJOR";
         } else {
             $importance = "MINOR";
         }
         $project->update(['cac' => $input['cac'], 'title' => $input['title'], 'user_id' => $pmid, 'pm' => $pmname->name, 'percent' => $input['percent'], 'target_start' => $input['target_start'], 'target_end' => $input['target_end'], 'status' => $input['status'], 'color' => $input['color'], 'rationale' => $input['rationale'], 'actual_start' => $input['actual_start'], 'actual_end' => $input['actual_end'], 'budget' => $input['budget'], 'utilization' => $input['utilization'], 'target_mandays' => $input['target_mandays'], 'actual_mandays' => $input['actual_mandays'], 'hardware' => $input['hardware'], 'software' => $input['software'], 'importance' => $importance, 'applicability' => $input['applicability'], 'confidentiality' => $input['confidentiality']]);
         if ($input['status'] != 'Not Started') {
             $project->update(['actual_start' => $input['actual_start']]);
         }
         if ($input['status'] == 'Completed' or $input['status'] == 'Cancelled') {
             $project->update(['actual_end' => $input['actual_end']]);
         }
         //$input = Request::all();
         //$request = new CreateProjectRequest;
         if (isset($input['users']) == true) {
             $project->users()->sync($input['users']);
         } else {
             DB::delete('delete from project_user where project_id = ?', array($project->id));
         }
         $deliverables = Deliverable::where('project_id', $id)->get();
         $i = 0;
         $required = [];
         if ($input['applicability'] == 'New or Replacement of IT Solution') {
             $required = ['M', 'O', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'O', 'M', 'M', 'O', 'M', 'M', 'M', 'M', 'O', 'O', 'O', 'N/A', 'M', 'M', 'M', 'M', 'O', 'M', 'O', 'O', 'M', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'O', 'O', 'M', 'M', 'M', 'M', 'O', 'O'];
         } elseif ($input['applicability'] == 'Enhancement or Application System Upgrade') {
             $required = ['M', 'O', '-', '-', '-', 'M', 'M', 'M', 'M', 'M', 'M', 'M', '-', 'O', 'M', 'M', 'O', '-', '-', 'M', 'M', 'O', 'O', 'O', 'N/A', 'M', 'M', 'M', 'M', 'O', 'M', 'O', 'O', 'M', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'O', 'O', 'O', 'O', 'O', 'M', 'O', 'O'];
         } elseif ($input['applicability'] == 'IT Infrastructure') {
             $required = ['M', '-', '-', '-', '-', 'M', 'M', 'M', 'M', 'M', 'M', 'M', '-', '-', '-', '-', '-', '-', 'M', 'M', 'M', 'O', 'O', 'O', 'N/A', 'M', 'M', 'M', 'M', 'O', 'M', 'O', 'O', 'M', 'M', 'M', 'O', '-', '-', 'M', 'M', 'O', 'O', 'O', 'M', '-', '-', 'M', '-', 'M', 'M', 'M', '-', 'O', 'O', 'O', 'O', 'M', 'O', 'O'];
         }
         foreach ($deliverables as $deliverable) {
             $deliverable->update(['required' => $required[$i]]);
             $i = $i + 1;
         }
         flash()->success('Your project has been successfully updated!');
         return redirect()->action('ProjectsController@show', [$id]);
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //
     $deliverables = Deliverable::where('project_id', $id)->get();
     $i = 1;
     $input = Request::all();
     /* Check if $input["submit$i"] checkbox is checked or not */
     foreach ($deliverables as $deliverable) {
         if (isset($input["submit{$i}"])) {
             $deliverable->update(['submitted' => 1]);
         } else {
             $deliverable->update(['submitted' => 0]);
         }
         $deliverable->update(['required' => $input["required{$i}"], 'incharge' => $input["incharge{$i}"], 'condition' => $input["condition{$i}"]]);
         $i = $i + 1;
     }
     return redirect()->action('DeliverablesController@show', [$id]);
 }
예제 #3
0
 public function generate()
 {
     ini_set("max_execution_time", 0);
     if (Auth::user()->role == "Project Manager") {
         $activities = Activity::whereIn('action', array('Created', 'Deleted', 'Updated'))->where(function ($query) {
             return $query->where('action', '!=', 'Created')->orWhere('type', '!=', 'Deliverable');
         })->where('user_id', Auth::user()->id)->get();
         $projects = Project::where('user_id', Auth::user()->id)->get();
         $projectids = array_pluck($projects, 'id');
         $milestones = Milestone::whereIn('project_id', $projectids)->get();
         $accomplishments = Accomplishment::whereIn('project_id', $projectids)->get();
         $issues = Issue::whereIn('project_id', $projectids)->get();
         $risks = Risk::whereIn('project_id', $projectids)->get();
         $expenses = Expense::whereIn('project_id', $projectids)->get();
         $actions = Action::whereIn('project_id', $projectids)->get();
         $deliverables = Deliverable::whereIn('project_id', $projectids)->get();
         $business_project_team_members = BusinessProjectTeamMember::whereIn('project_id', $projectids)->get();
         $technical_project_team_members = TechnicalProjectTeamMember::whereIn('project_id', $projectids)->get();
         $support_team_members = SupportTeamMember::whereIn('project_id', $projectids)->get();
         return view('audit.generate', compact('activities', 'projects', 'milestones', 'accomplishments', 'issues', 'risks', 'expenses', 'actions', 'deliverables', 'business_project_team_members', 'technical_project_team_members', 'support_team_members'));
     } elseif (Auth::user()->role == "System Administrator") {
         $activities = Activity::whereIn('action', array('Created', 'Deleted', 'Updated'))->where(function ($query) {
             return $query->where('action', '!=', 'Created')->orWhere('type', '!=', 'Deliverable');
         })->get();
         $projects = Project::all();
         $milestones = Milestone::all();
         $accomplishments = Accomplishment::all();
         $issues = Issue::all();
         $risks = Risk::all();
         $users = User::all();
         $expenses = Expense::all();
         $actions = Action::all();
         $deliverables = Deliverable::all();
         $business_project_team_members = BusinessProjectTeamMember::all();
         $technical_project_team_members = TechnicalProjectTeamMember::all();
         $support_team_members = SupportTeamMember::all();
         return view('audit.generate', compact('activities', 'projects', 'milestones', 'accomplishments', 'issues', 'risks', 'users', 'expenses', 'actions', 'deliverables', 'business_project_team_members', 'technical_project_team_members', 'support_team_members'));
     } else {
         flash()->error('You are not authorized to proceed.');
         return redirect()->action('ProjectsController@index');
     }
 }